diff options
| author | Aargh Rai <aargh.rai+git@gmail.com> | 2026-07-10 16:01:57 +0530 |
|---|---|---|
| committer | Aargh Rai <aargh.rai+git@gmail.com> | 2026-07-10 16:01:57 +0530 |
| commit | a14da2fe3864712dab4e7c4cfb5c323026d668de (patch) | |
| tree | 418c8c8ff44a611cbe1c1269b10926527046e232 /src/server/comms.c | |
| parent | 2761f8a533e2b025f209222a1e4ec70b91c7e8ee (diff) | |
moving header files to include directory & moving resources in it's own directory
i know currently there is race condition, but the code is getting too
messy, i will continue to this after i make a vis tool to analyse how i
should split up files & stuff
the code rn needs intense restructing for it to make any more progress
Diffstat (limited to 'src/server/comms.c')
| -rw-r--r-- | src/server/comms.c | 68 |
1 files changed, 0 insertions, 68 deletions
diff --git a/src/server/comms.c b/src/server/comms.c deleted file mode 100644 index 67e42a2..0000000 --- a/src/server/comms.c +++ /dev/null @@ -1,68 +0,0 @@ -#include <assert.h> -#include <string.h> -#include "../ipc.c" -#include "../logger/logger.h" - -struct str { - char msg[1023]; - int len; -}; - -void set_output(struct str* output, char* msg) { - int i = 0; - while (msg[i] != 0) { - assert(i < 1023); - output->msg[i] = msg[i]; - i++; - } - output->len = i; -} - -struct strs { - struct str* data; - int capacity; - int count; -}; - -struct strs init_strs() { - return (struct strs) { - .data = malloc(sizeof(struct str) * 10), - .count = 0, - .capacity = 10, - }; -} -void add_str(struct strs* strs, char* str) { - if (strs->count + 1 > strs->capacity) { - strs->capacity += 30; - strs->data = realloc(strs->data, sizeof(struct str) * strs->capacity); - } - - struct str item; - set_output(&item, str); - - strs->data[strs->count] = item; - strs->count++; -} - -struct strs handle_input(mqd_t logging, mqd_t tx, mqd_t rx, char* payload, int len) { - log_infof("after: %d", payload[len]); - send_queue(tx, payload, len + 1); - char* buf = read_queue(rx); - - struct strs output = init_strs(); - - if (strcmp(buf, "Sending") != 0) { - return output; - } - - while (1) { - char* buf = read_queue(rx); - if (strcmp(buf, "END-TRANSMISSION") == 0) { - free(buf); - break; - } - add_str(&output, buf); - free(buf); - } - return output; -} |
