From 51ecf18f6ce5b9e06ec61423548270b4746f379d Mon Sep 17 00:00:00 2001 From: bonmas14 Date: Mon, 29 Sep 2025 19:58:12 +0300 Subject: Added zlib --- src/cyn_compress.c | 9 +++++++++ src/cyn_file.c | 4 ++-- src/cyn_file_linux.c | 9 +++++++++ src/cyn_file_linux_x64.c | 9 --------- src/cyn_file_win.c | 37 +++++++++++++++++++++++++++++++++++++ src/cyn_file_win_x64.c | 37 ------------------------------------- src/cyn_lib_linux.c | 0 src/cyn_lib_win.c | 0 src/cynic.c | 8 ++++++++ src/cynic.h | 12 ++++++++++++ src/d_win.c | 3 ++- src/disgrace.c | 6 +++++- src/disgrace.h | 2 +- src/ungrateful.c | 1 - src/ungrateful.h | 3 +-- 15 files changed, 86 insertions(+), 54 deletions(-) create mode 100644 src/cyn_compress.c create mode 100644 src/cyn_file_linux.c delete mode 100644 src/cyn_file_linux_x64.c create mode 100644 src/cyn_file_win.c delete mode 100644 src/cyn_file_win_x64.c create mode 100644 src/cyn_lib_linux.c create mode 100644 src/cyn_lib_win.c (limited to 'src') diff --git a/src/cyn_compress.c b/src/cyn_compress.c new file mode 100644 index 0000000..d8640f6 --- /dev/null +++ b/src/cyn_compress.c @@ -0,0 +1,9 @@ +#include + +// @todo + + +int cyn_test(void) { + uncompress(); + +} diff --git a/src/cyn_file.c b/src/cyn_file.c index 4537eb7..5aa6bba 100644 --- a/src/cyn_file.c +++ b/src/cyn_file.c @@ -1,8 +1,8 @@ #if defined(OS_WINDOWS) -#include "cyn_file_win_x64.c" +#include "cyn_file_win.c" #elif defined(OS_LINUX) -#include "cyn_file_linux_x64.c" +#include "cyn_file_linux.c" #else #include "cyn_file_std.c" diff --git a/src/cyn_file_linux.c b/src/cyn_file_linux.c new file mode 100644 index 0000000..ff0c1c2 --- /dev/null +++ b/src/cyn_file_linux.c @@ -0,0 +1,9 @@ +File_Handle *cyn_file_open(String path, File_Status *status) { + UNUSED(path); + + if (status != NULL) { + *status = CYN_FILE_ERROR; + } + + return NULL; +} diff --git a/src/cyn_file_linux_x64.c b/src/cyn_file_linux_x64.c deleted file mode 100644 index ff0c1c2..0000000 --- a/src/cyn_file_linux_x64.c +++ /dev/null @@ -1,9 +0,0 @@ -File_Handle *cyn_file_open(String path, File_Status *status) { - UNUSED(path); - - if (status != NULL) { - *status = CYN_FILE_ERROR; - } - - return NULL; -} diff --git a/src/cyn_file_win.c b/src/cyn_file_win.c new file mode 100644 index 0000000..1ded1de --- /dev/null +++ b/src/cyn_file_win.c @@ -0,0 +1,37 @@ +File_Handle *cyn_file_open(String path, File_Status *status) { + wchar *final_path; + Allocator talloc; + + talloc = un_alloc_temp_get(); + + final_path = un_wstring_from_string(path, talloc); + + if (path.size > MAX_PATH) { + if (status != NULL) *status = CYN_FILE_ERROR_MAX_PATH; + return NULL; + } + + if (final_path == NULL) { + if (status != NULL) *status = CYN_FILE_ERROR_NULL_FILENAME; + return NULL; // @todo status + } + + //CreateFileW(); + + if (status != NULL) *status = CYN_FILE_ERROR; + + return NULL; +} + +/* + +HANDLE CreateFileW( + LPCWSTR lpFileName, + DWORD dwDesiredAccess, + DWORD dwShareMode, + NULL, + DWORD dwCreationDisposition, + DWORD dwFlagsAndAttributes, + NULL +); +*/ diff --git a/src/cyn_file_win_x64.c b/src/cyn_file_win_x64.c deleted file mode 100644 index 1ded1de..0000000 --- a/src/cyn_file_win_x64.c +++ /dev/null @@ -1,37 +0,0 @@ -File_Handle *cyn_file_open(String path, File_Status *status) { - wchar *final_path; - Allocator talloc; - - talloc = un_alloc_temp_get(); - - final_path = un_wstring_from_string(path, talloc); - - if (path.size > MAX_PATH) { - if (status != NULL) *status = CYN_FILE_ERROR_MAX_PATH; - return NULL; - } - - if (final_path == NULL) { - if (status != NULL) *status = CYN_FILE_ERROR_NULL_FILENAME; - return NULL; // @todo status - } - - //CreateFileW(); - - if (status != NULL) *status = CYN_FILE_ERROR; - - return NULL; -} - -/* - -HANDLE CreateFileW( - LPCWSTR lpFileName, - DWORD dwDesiredAccess, - DWORD dwShareMode, - NULL, - DWORD dwCreationDisposition, - DWORD dwFlagsAndAttributes, - NULL -); -*/ diff --git a/src/cyn_lib_linux.c b/src/cyn_lib_linux.c new file mode 100644 index 0000000..e69de29 diff --git a/src/cyn_lib_win.c b/src/cyn_lib_win.c new file mode 100644 index 0000000..e69de29 diff --git a/src/cynic.c b/src/cynic.c index a8f9174..e211352 100644 --- a/src/cynic.c +++ b/src/cynic.c @@ -3,3 +3,11 @@ #include "cyn_log.c" #include "cyn_file.c" + +#if defined(OS_WINDOWS) +#include "cyn_lib_win.c" +#elif defined(OS_LINUX) +#include "cyn_lib_linux.c" +#else +#error "Unknown platform" +#endif // OS diff --git a/src/cynic.h b/src/cynic.h index ef56555..66659ff 100644 --- a/src/cynic.h +++ b/src/cynic.h @@ -123,6 +123,18 @@ extern void cyn_file_close(struct File_Handle *handle); /* --------- Config API -------- */ +/* --------- Library load --------- */ + +struct CInterface; + + +extern struct CInterface* cyn_lib_interface_create(void); +extern void cyn_lib_interface_destroy(struct CInterface *interface); +extern void cyn_lib_interface_register(struct CInterface *interface, void *fp, String name); + + + + #if defined(__cplusplus) } #endif diff --git a/src/d_win.c b/src/d_win.c index 3375ee9..00b82a2 100644 --- a/src/d_win.c +++ b/src/d_win.c @@ -1,5 +1,6 @@ typedef struct DHandle { - u64 type; + u32 type; + u32 subtype; } DHandle; b32 d_init(void) { diff --git a/src/disgrace.c b/src/disgrace.c index 424ca5b..2e7c235 100644 --- a/src/disgrace.c +++ b/src/disgrace.c @@ -5,6 +5,11 @@ enum { D_TYPE_UDP }; +enum { + D_SUBTYPE_CLIENT, + D_SUBTYPE_SERVER, +}; + #if defined(OS_WINDOWS) #include @@ -25,7 +30,6 @@ enum { #include #include - #include "d_linux.c" #else diff --git a/src/disgrace.h b/src/disgrace.h index d129938..3127fb0 100644 --- a/src/disgrace.h +++ b/src/disgrace.h @@ -40,7 +40,7 @@ b32 d_init(void); extern String d_hostname_ip_get(String host, Allocator alloc); -extern struct DHandle* d_tcp_connect(String ip, u16 port); +extern struct DHandle* d_tcp_connect(String hostname, u16 port); extern struct DHandle* d_tcp_listen(); extern struct DHandle* d_udp_bind(); diff --git a/src/ungrateful.c b/src/ungrateful.c index 001d63a..554195f 100644 --- a/src/ungrateful.c +++ b/src/ungrateful.c @@ -17,7 +17,6 @@ #include "un_sort.c" - void un_init(u64 size_of_temp_mem) { un_alloc_temp_init(size_of_temp_mem); } diff --git a/src/ungrateful.h b/src/ungrateful.h index 70683a7..71e6231 100644 --- a/src/ungrateful.h +++ b/src/ungrateful.h @@ -95,7 +95,7 @@ #define assert(expr) if ((int)(expr) == 0) {\ fprintf(stderr, "Assert at %s:%d failed!\n", __FILE__, __LINE__); \ - *((int *)0) = 0; \ + __TRAP(); \ } #else @@ -623,7 +623,6 @@ extern double un_m_ease_oquadd(double t); extern void un_m_mat_mulf(float *v, float *left, float *right); extern void un_m_mat_identityf(float *v); - /* Sorting */ #define UN_COMP_PROC(name) s32 name(u64 size, void *a, void *b) -- cgit v1.2.3-70-g09d2