aboutsummaryrefslogtreecommitdiff
path: root/include
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 /include
parent63f11aaec8d21844a07fd27003a992c102a3a297 (diff)
makefile and directory structure change completely to build client and server
Diffstat (limited to 'include')
-rw-r--r--include/array.h23
-rw-r--r--include/better_string.h23
-rw-r--r--include/hash_table.h43
-rw-r--r--include/helpers.h15
-rw-r--r--include/opcodes.h47
-rw-r--r--include/protocol.h68
-rw-r--r--include/tsv.h16
7 files changed, 0 insertions, 235 deletions
diff --git a/include/array.h b/include/array.h
deleted file mode 100644
index 948dad2..0000000
--- a/include/array.h
+++ /dev/null
@@ -1,23 +0,0 @@
-#ifndef ARRAY_H
-#define ARRAY_H
-
-#include <stdlib.h>
-#define DEFAULT_ARR_LEN 10
-
-typedef struct {
- void **items;
- size_t size;
- size_t capacity;
-} array_t;
-
-array_t *init_array();
-
-void array_push(array_t *a, void *item);
-
-void *array_pop(array_t *a);
-
-void *array_del(array_t *a, unsigned int ind);
-
-void array_free(void *a, void (*freefunc)(void *));
-
-#endif
diff --git a/include/better_string.h b/include/better_string.h
deleted file mode 100644
index a5f9954..0000000
--- a/include/better_string.h
+++ /dev/null
@@ -1,23 +0,0 @@
-#ifndef STRING_H
-#define STRING_H
-
-#include <stdlib.h>
-#define DEFAULT_STR_SIZE 10
-typedef struct {
- char *buf;
- size_t len;
- size_t size;
-} string_t;
-
-string_t *init_string(const char *source);
-
-void string_push(string_t *s, char c);
-
-void string_concat(string_t *s1, string_t *s2);
-
-void string_concat_const(string_t *s, const char *src);
-
-char string_pop(string_t *s);
-
-void string_free(void *s);
-#endif
diff --git a/include/hash_table.h b/include/hash_table.h
deleted file mode 100644
index 357e38a..0000000
--- a/include/hash_table.h
+++ /dev/null
@@ -1,43 +0,0 @@
-#ifndef HASH_TABLE_H
-#define HASH_TABLE_H
-#include <array.h>
-
-#define DEFAULT_HT_SIZE 500
-
-typedef struct PAIR_STRUCT {
- char *key;
- void *v;
-} pair_t;
-
-typedef struct NODE_STRUCT {
- char *key;
- void *v;
- struct NODE_STRUCT *next;
-} node_t;
-
-typedef struct {
- node_t *head;
- node_t *tail;
-} sll_t;
-
-typedef struct {
- sll_t **buckets;
- size_t size;
-} ht_t;
-
-node_t *init_node(char *key, void *v);
-
-void sll_push(sll_t *sll, char *key, void *v);
-
-void sll_delete(sll_t *sll, char *key);
-
-sll_t *sll_free(void *x, void (*freefunc)(void *));
-
-void ht_insert(ht_t *ht, char *key, void *value);
-
-void ht_delete(ht_t *ht, char *key);
-
-void *ht_get(ht_t *ht, char *key);
-
-ht_t *init_ht(size_t size);
-#endif
diff --git a/include/helpers.h b/include/helpers.h
deleted file mode 100644
index 276b590..0000000
--- a/include/helpers.h
+++ /dev/null
@@ -1,15 +0,0 @@
-#ifndef HELPERS_H
-#define HELPERS_H
-
-#include <stdlib.h>
-
-void die_lz(int code, const char *msg);
-
-void die(const char *msg);
-
-void *safe_calloc(unsigned int i, size_t size);
-
-void *safe_realloc(void *x, size_t size);
-
-void alloc_zero(void *ptr, size_t size);
-#endif
diff --git a/include/opcodes.h b/include/opcodes.h
deleted file mode 100644
index ff8400f..0000000
--- a/include/opcodes.h
+++ /dev/null
@@ -1,47 +0,0 @@
-#ifndef OPCODES_H
-#define OPCODES_H
-
-typedef enum {
- CO_NOP,
- CO_JN, /* join */
- CO_DM,
- CO_PST, /* post */
- CO_MSG,
- CO_REG,
- CO_NCK, /* nick */
- CO_PNG, /* pong */
- CO_LVE, /* leave */
- CO_QT, /* quit*/
-
- CO_CLM, /* claim channel */
- CO_DESC, /* change description */
- CO_TRSFR, /* ownership transfer of admin */
- CO_KCK, /* kick */
- CO_BAN,
- CO_KNGT, /* knight */
- CO_DMT, /* demote */
-
- CO_LOGS, /* allows users to download log file from date specified in unix time */
-
- CO_UNRECOGNIZED
-} copcode_t;
-
-typedef enum {
- SO_SUCCESS,
- SO_FAIL_PARSE,
- SO_FAIL_NOPERM,
- SO_FAIL_USER_TAKEN,
- SO_FAIL_RATE, /* rate limit */
- SO_PNG, /* ping */
- SO_BYE,
-} sopcode_t;
-
-char *decode_client_opcode(int op);
-
-char *decode_server_opcode(int op);
-
-int encode_client_opcode(char *c);
-
-int encode_server_opcode(char *c);
-
-#endif
diff --git a/include/protocol.h b/include/protocol.h
deleted file mode 100644
index 16ba818..0000000
--- a/include/protocol.h
+++ /dev/null
@@ -1,68 +0,0 @@
-#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
diff --git a/include/tsv.h b/include/tsv.h
deleted file mode 100644
index 5f6a9f6..0000000
--- a/include/tsv.h
+++ /dev/null
@@ -1,16 +0,0 @@
-#ifndef TSV_H
-#define TSV_H
-
-#include <better_string.h>
-
-typedef struct {
- char *source;
- unsigned int i;
- char c;
-} tsv_t;
-
-tsv_t *init_tsv(char *source);
-
-string_t *next_tsv(tsv_t *tsv);
-
-#endif