djumbai/libs/protocol/protocol.c

14 lines
419 B
C

#include "protocol.h"
int new_message(message *m, unsigned int sender, unsigned int isgroup, unsigned int receiver, char *content) {
if (strlen(content) > MAX_CONTENT_SIZE) {
return 1;
}
m->header.version = VERSION;
m->header.sender = sender;
m->header.isgroup = isgroup;
m->header.receiver = receiver;
gettimeofday(&m->header.timestamp,NULL);
strncpy(m->content, content, MAX_CONTENT_SIZE);
return 0;
}