Mercurial
comparison dowa/dowa.h @ 3:2758f5527d2b
[Seobeo] Working on simple TCP server and client logic.
| author | June Park <parkjune1995@gmail.com> |
|---|---|
| date | Wed, 24 Sep 2025 18:49:09 -0700 |
| parents | 8a43dedbe530 |
| children | 3e12bf044589 |
comparison
equal
deleted
inserted
replaced
| 2:8a43dedbe530 | 3:2758f5527d2b |
|---|---|
| 3 | 3 |
| 4 #include <stdio.h> | 4 #include <stdio.h> |
| 5 #include <string.h> // stdup | 5 #include <string.h> // stdup |
| 6 #include <stdlib.h> // only for malloc, free, stuff | 6 #include <stdlib.h> // only for malloc, free, stuff |
| 7 #include <assert.h> | 7 #include <assert.h> |
| 8 #include <dirent.h> | |
| 9 | |
| 10 #include <sys/stat.h> | |
| 11 #include <limits.h> | |
| 12 | |
| 8 #include "dowa_internal.h" | 13 #include "dowa_internal.h" |
| 9 | 14 |
| 10 #define HASH_KEY_NUMBER 5381 // DJD hash number | 15 #define HASH_KEY_NUMBER 5381 // DJD hash number |
| 11 | 16 |
| 12 typedef unsigned int uint32; | 17 typedef unsigned int uint32; |
| 30 extern Dowa_PArena Dowa_Arena_Initialize(size_t capacity); | 35 extern Dowa_PArena Dowa_Arena_Initialize(size_t capacity); |
| 31 extern void *Dowa_Arena_Allocate(Dowa_PArena p_arena, size_t size); | 36 extern void *Dowa_Arena_Allocate(Dowa_PArena p_arena, size_t size); |
| 32 extern void Dowa_Arena_Free(Dowa_PArena p_arena); | 37 extern void Dowa_Arena_Free(Dowa_PArena p_arena); |
| 33 | 38 |
| 34 // --- Map --- // | 39 // --- Map --- // |
| 40 typedef enum { | |
| 41 DOWA_TYPE_BUFFER, | |
| 42 DOWA_TYPE_STRING, | |
| 43 DOWA_TYPE_INT, | |
| 44 } Dowa_ValueType; | |
| 45 | |
| 35 typedef struct { | 46 typedef struct { |
| 36 char *key; | 47 char *key; |
| 37 void *buffer; | 48 void *buffer; |
| 38 size_t capacity; | 49 size_t capacity; |
| 50 Dowa_ValueType type; | |
| 39 } Dowa_HashEntry, *Dowa_PHashEntry; | 51 } Dowa_HashEntry, *Dowa_PHashEntry; |
| 40 | 52 |
| 41 typedef struct { | 53 typedef struct { |
| 42 Dowa_PHashEntry *entries; | 54 Dowa_PHashEntry *entries; |
| 43 size_t capacity; | 55 size_t capacity; |
| 45 } Dowa_HashMap, *Dowa_PHashMap; | 57 } Dowa_HashMap, *Dowa_PHashMap; |
| 46 | 58 |
| 47 extern Dowa_PHashMap Dowa_HashMap_Create(size_t capacity); | 59 extern Dowa_PHashMap Dowa_HashMap_Create(size_t capacity); |
| 48 extern int32 Dowa_HashMap_GetPosition(Dowa_PHashMap p_hash_map, char *key); | 60 extern int32 Dowa_HashMap_GetPosition(Dowa_PHashMap p_hash_map, char *key); |
| 49 extern void Dowa_HashMap_PushValue(Dowa_PHashMap p_hash_map, char *key, void *value, size_t value_size); | 61 extern void Dowa_HashMap_PushValue(Dowa_PHashMap p_hash_map, char *key, void *value, size_t value_size); |
| 62 extern void Dowa_HashMap_PushValueWithType(Dowa_PHashMap p_hash_map, char *key, void *value, size_t value_size, Dowa_ValueType type); | |
| 50 extern void Dowa_HashMap_PopKey(Dowa_PHashMap p_hash_map, char *key); | 63 extern void Dowa_HashMap_PopKey(Dowa_PHashMap p_hash_map, char *key); |
| 64 | |
| 65 // --- Maybe Useful --- // | |
| 66 extern void Dowa_HashMap_Print(Dowa_PHashMap map); | |
| 67 // 0 for success, -1 for failure. | |
| 68 extern int Dowa_Cache_Folder(Dowa_PHashMap map, const char *folder_path); | |
| 51 | 69 |
| 52 | 70 |
| 53 #endif | 71 #endif |