From f8c0dc54e36cc201c657aa12e5a22029b092e1bc Mon Sep 17 00:00:00 2001 From: Aargh Rai Date: Mon, 13 Jul 2026 21:58:18 +0530 Subject: restructed all the files + uci done now also broke the symbol analyser in the process, i didn't help much, i had to pull out the pen & paper, but it made a cool graph never the less multithreading was a pain! but it got it in the end fixed the structs naming convention, if it's used outside by other files, it's typedeffed, otherwise it's not fixed the recursive imports issued i had in go_args*, where i was casting it to void* in uci to make it work now response.c doesn't deal with ipc, really happy with that change now every single thing has its own responsibility --- include/uci/internals/command.h | 21 +++++++++++++++++++++ include/uci/internals/response.h | 24 ++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 include/uci/internals/command.h create mode 100644 include/uci/internals/response.h (limited to 'include/uci/internals') diff --git a/include/uci/internals/command.h b/include/uci/internals/command.h new file mode 100644 index 0000000..2994b04 --- /dev/null +++ b/include/uci/internals/command.h @@ -0,0 +1,21 @@ +#ifndef UCI_COMMAND_H +#define UCI_COMMAND_H + +#define MAX_TOKEN_SIZE 32 + +typedef struct { + char root[MAX_TOKEN_SIZE]; + int args_count; + int args_capacity; + char* args; + bool empty; +} uci_cmd_t; + +uci_cmd_t uci_cmd_init(); +void uci_cmd_add(uci_cmd_t *cmd, const char *token); +void uci_cmd_set_root(uci_cmd_t *cmd, const char *token); +void uci_cmd_append_arg(uci_cmd_t *cmd, const char *token); +char *uci_cmd_get_arg(uci_cmd_t cmd, int i); +void uci_cmd_deinit(uci_cmd_t cmd); + +#endif // UCI_COMMAND_H diff --git a/include/uci/internals/response.h b/include/uci/internals/response.h new file mode 100644 index 0000000..a0a6e99 --- /dev/null +++ b/include/uci/internals/response.h @@ -0,0 +1,24 @@ +#ifndef UCI_RESPONSE_H +#define UCI_RESPONSE_H + +#include "uci/internals/command.h" +#include "uci/state.h" + +enum { + UCI_STATE_INITIAL, + UCI_STATE_IDLE, + UCI_STATE_SYNC, + UCI_STATE_PING, + UCI_STATE_ACTIVE, + UCI_STATE_HALT, +}; + +void handle_uci(uci_state_t *state, uci_cmd_t cmd); +void handle_initial(uci_state_t *state, uci_cmd_t cmd); +void handle_idle(uci_state_t *state, uci_cmd_t cmd); +void handle_sync(uci_state_t *state, uci_cmd_t cmd); +void handle_ping(uci_state_t *state, uci_cmd_t cmd); +void handle_active(uci_state_t *state, uci_cmd_t cmd); +void handle_halt(uci_state_t *state, uci_cmd_t cmd); + +#endif // UCI_RESPONSE_H -- cgit v1.2.3