basic structure and client process chain done
This commit is contained in:
parent
77657c7078
commit
83bd6fb796
21 changed files with 313 additions and 7 deletions
34
libs/protocol/protocol.h
Normal file
34
libs/protocol/protocol.h
Normal file
|
@ -0,0 +1,34 @@
|
|||
#ifndef PROTOCOL_H
|
||||
#define PROTOCOL_H
|
||||
|
||||
#include <limits.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
#define VERSION 1
|
||||
#define MAX_CONTENT_SIZE (PIPE_BUF - sizeof(struct MessageHeader))
|
||||
#define MESSAGE_SIZE sizeof(struct Message)
|
||||
|
||||
typedef struct MessageHeader {
|
||||
// The protocol's version
|
||||
unsigned int version;
|
||||
// The sender is a user
|
||||
unsigned int sender;
|
||||
// The receiver is either a user or a group
|
||||
unsigned int receiver;
|
||||
// The message was sent at this timestamp
|
||||
time_t timestamp;
|
||||
} message_header;
|
||||
|
||||
typedef struct Message {
|
||||
// The message's header
|
||||
message_header header;
|
||||
// The buffer holding the message
|
||||
char content[MAX_CONTENT_SIZE];
|
||||
} message;
|
||||
|
||||
|
||||
int new_message(message *m, unsigned int sender, unsigned int receiver, char *content);
|
||||
|
||||
#endif // !PROTOCOL_H
|
Loading…
Add table
Add a link
Reference in a new issue