aboutsummaryrefslogtreecommitdiff
path: root/src/include/protocol.h
diff options
context:
space:
mode:
authorPreston Pan <ret2pop@gmail.com>2024-12-28 16:47:43 -0800
committerPreston Pan <ret2pop@gmail.com>2024-12-28 16:47:43 -0800
commit1fd608288ee47c2c560817f12f14b21069fed2f6 (patch)
treee6460b92dba5bb0d089c8c2a4e794e3504098359 /src/include/protocol.h
parent63f11aaec8d21844a07fd27003a992c102a3a297 (diff)
makefile and directory structure change completely to build client and server
Diffstat (limited to 'src/include/protocol.h')
-rw-r--r--src/include/protocol.h68
1 files changed, 68 insertions, 0 deletions
diff --git a/src/include/protocol.h b/src/include/protocol.h
new file mode 100644
index 0000000..204a507
--- /dev/null
+++ b/src/include/protocol.h
@@ -0,0 +1,68 @@
+#ifndef PROTOCOL_H
+#define PROTOCOL_H
+
+#include <time.h>
+#include <stdbool.h>
+
+#include "array.h"
+#include "better_string.h"
+#include "hash_table.h"
+#include <openssl/sha.h>
+
+#define MAX_OP_LEN 10
+#define MAX_ARG_LEN 50
+#define MAX_ARGS 5
+#define MAX_BUFSIZE 4096
+#define DEFAULT_PORT 11111
+#define MAX_CONNECTIONS 32768
+#define DEFAULT_TIMEOUT 6000
+#define USERNAME_SIZE 30
+#define KEYLEN 512
+
+typedef struct {
+ string_t *nick;
+ bool is_guest;
+ int fd;
+
+ /* list of channels where user is in */
+ array_t *channels;
+ array_t *dms;
+ array_t *autojoin;
+ unsigned char passhash[SHA256_DIGEST_LENGTH];
+} user_t;
+
+typedef struct {
+ string_t *nick;
+ string_t *msg;
+ time_t time;
+} message_t;
+
+typedef struct {
+ array_t *messages;
+
+ user_t *admin;
+ array_t *mods;
+
+ bool registered_only;
+
+ bool invite_only;
+ array_t *allowed_users;
+
+ array_t *users;
+
+ string_t *chan_name;
+ string_t *desc;
+} channel_t;
+
+typedef struct {
+ user_t *user1;
+ user_t *user2;
+
+ array_t *messages;
+} dm_t;
+
+string_t *encode_chanstate(ht_t *chans);
+
+string_t *encode_usersstate(ht_t *u);
+
+#endif