|
|
|
@ -4,14 +4,22 @@
|
|
|
|
|
#include <time.h>
|
|
|
|
|
#include "message.h"
|
|
|
|
|
|
|
|
|
|
Message new_message(char* string, User from, User to) {
|
|
|
|
|
Message new_message;
|
|
|
|
|
Message* new_message(char* string, User* from, User* to) {
|
|
|
|
|
Message* new_message;
|
|
|
|
|
|
|
|
|
|
new_message.text = malloc((strlen(string)+1)*sizeof(char));
|
|
|
|
|
strcpy(new_message.text,string);
|
|
|
|
|
new_message = malloc(sizeof(Message));
|
|
|
|
|
new_message->text = malloc((strlen(string)+1)*sizeof(char));
|
|
|
|
|
strcpy(new_message->text,string);
|
|
|
|
|
|
|
|
|
|
new_message.sender = from;
|
|
|
|
|
new_message.recipient = to;
|
|
|
|
|
new_message->sender = malloc(sizeof(User));
|
|
|
|
|
new_message->recipient = malloc(sizeof(User));
|
|
|
|
|
|
|
|
|
|
memcpy(new_message->sender, from, sizeof(User));
|
|
|
|
|
memcpy(new_message->recipient, to, sizeof(User));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// *(new_message->sender) = *from;
|
|
|
|
|
// *(new_message->recipient) = *to;
|
|
|
|
|
|
|
|
|
|
time_t rawtime;
|
|
|
|
|
struct tm timeinfo;
|
|
|
|
@ -19,7 +27,7 @@ Message new_message(char* string, User from, User to) {
|
|
|
|
|
time(&rawtime);
|
|
|
|
|
timeinfo = *localtime(&rawtime);
|
|
|
|
|
|
|
|
|
|
new_message.timeinfo = timeinfo;
|
|
|
|
|
new_message->timeinfo = timeinfo;
|
|
|
|
|
|
|
|
|
|
return new_message;
|
|
|
|
|
|
|
|
|
|