diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index 820942b..aa93e71 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -4,7 +4,8 @@ "name": "Linux", "includePath": [ "${workspaceFolder}/**", - "${workspaceFolder}/include" + "${workspaceFolder}/include", + "${workspaceFolder}/third_party" ], "defines": [], "compilerPath": "/usr/bin/clang", diff --git a/include/hammy/bot.h b/include/hammy/bot.h index a36d0cf..142ae91 100644 --- a/include/hammy/bot.h +++ b/include/hammy/bot.h @@ -5,13 +5,14 @@ #include #include +#include #include -typedef struct { +struct hammy_bot_t { struct discord* client; // Owning reference to the client - handoff from main.c bool commands_registered; // A flag if commands have been registered. Avoid re-registering every reconnect. vector_t* commands; // vector_t of commands. Owning. -} hammy_bot_t; +}; // Alloc on heap and create hammy_bot_t* hammy_bot_create(); diff --git a/include/hammy/command.h b/include/hammy/command.h index df554dd..b3393af 100644 --- a/include/hammy/command.h +++ b/include/hammy/command.h @@ -2,11 +2,12 @@ #define HAMMY_COMMAND_H #include +#include -typedef struct { +struct hammy_command_t { // TODO: add shit here char empty; -} hammy_command_t; +}; // Creates the command on the heap, returns NULL if failed. hammy_command_t* hammy_command_create(); diff --git a/include/hammy/job.h b/include/hammy/job.h index 5ac2ec2..be6bf56 100644 --- a/include/hammy/job.h +++ b/include/hammy/job.h @@ -3,14 +3,15 @@ #include #include +#include -typedef struct { +struct hammy_job_t { char* token; // Interaction token u64snowflake id; // Interaction ID u64snowflake user; // Interaction User ID char* command; char** args; // Might be useful to parse into a struct someday? TODO int64_t queued_at; // Staleness checks -} hammy_job_t; +}; #endif diff --git a/include/hammy/pool.h b/include/hammy/pool.h index a7aca10..e4d8d14 100644 --- a/include/hammy/pool.h +++ b/include/hammy/pool.h @@ -1,12 +1,11 @@ #ifndef HAMMY_POOL_H #define HAMMY_POOL_H -#include -#include +#include #include #include -typedef struct { +struct hammy_pool_t { pthread_mutex_t lock; pthread_cond_t notEmpty; hammy_job_t** jobs; // ring buffer @@ -18,6 +17,6 @@ typedef struct { hammy_worker_t* workers; size_t nWorkers; -} hammy_pool_t; +}; #endif diff --git a/include/hammy/types.h b/include/hammy/types.h new file mode 100644 index 0000000..d609b97 --- /dev/null +++ b/include/hammy/types.h @@ -0,0 +1,10 @@ +#ifndef HAMMY_TYPES_H +#define HAMMY_TYPES_H + +typedef struct hammy_pool_t hammy_pool_t; +typedef struct hammy_job_t hammy_job_t; +typedef struct hammy_worker_t hammy_worker_t; +typedef struct hammy_command_t hammy_command_t; +typedef struct hammy_bot_t hammy_bot_t; + +#endif diff --git a/include/hammy/worker.h b/include/hammy/worker.h index 865ffa8..82591a5 100644 --- a/include/hammy/worker.h +++ b/include/hammy/worker.h @@ -2,16 +2,14 @@ #define HAMMY_WORKER_H #include -#include +#include #include -typedef struct hammy_pool_t; // forward declare - -typedef struct { +struct hammy_worker_t { pthread_t thread; struct discord* clientCopy; // Clone of the client for concord threading safety hammy_pool_t* pool; int id; -} hammy_worker_t; +}; #endif