Mercurial
comparison dowa/dowa.h @ 63:fff1b048dda6
[Postdog] Fixed a problem where string did not wrap.
| author | June Park <parkjune1995@gmail.com> |
|---|---|
| date | Tue, 23 Dec 2025 14:00:37 -0800 |
| parents | e06bc03d9618 |
| children | a30944e5719e |
comparison
equal
deleted
inserted
replaced
| 62:ea9ef388ab97 | 63:fff1b048dda6 |
|---|---|
| 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> // mostly for TODO | 7 #include <assert.h> // mostly for TODO |
| 8 | |
| 9 #ifdef DIRECTORY | |
| 10 // Only for linux and mac since window do not support. | |
| 11 // Maybe move this into seobeo file directly? | |
| 8 #include <dirent.h> // some functions loop through files | 12 #include <dirent.h> // some functions loop through files |
| 13 #endif | |
| 9 #include <math.h> // I am not re-writing stuff I guess... | 14 #include <math.h> // I am not re-writing stuff I guess... |
| 10 | 15 |
| 11 #include <sys/stat.h> | 16 #include <sys/stat.h> |
| 12 #include <limits.h> | 17 #include <limits.h> |
| 13 | 18 |
| 31 typedef unsigned short uint16; // 16-bit unsigned integer | 36 typedef unsigned short uint16; // 16-bit unsigned integer |
| 32 typedef short int16; // 16-bit signed integer | 37 typedef short int16; // 16-bit signed integer |
| 33 typedef unsigned char uint8; // 8-bit unsigned integer | 38 typedef unsigned char uint8; // 8-bit unsigned integer |
| 34 typedef char int8; // 8-bit signed integer | 39 typedef char int8; // 8-bit signed integer |
| 35 typedef char boolean; // Boolean type (0 = false, nonzero = true) | 40 typedef char boolean; // Boolean type (0 = false, nonzero = true) |
| 36 | |
| 37 | |
| 38 // --- Miscellaneous --- // | |
| 39 /* Just use atoid lmao*/ | |
| 40 char *Dowa_Int32ToString(uint32 value, char *buffer); | |
| 41 | |
| 42 | 41 |
| 43 // --- Arena Allocator --- // | 42 // --- Arena Allocator --- // |
| 44 typedef struct { | 43 typedef struct { |
| 45 char *buffer; | 44 char *buffer; |
| 46 size_t offset; | 45 size_t offset; |
| 109 /* Removes all entries from the hashmap without destroying it. */ | 108 /* Removes all entries from the hashmap without destroying it. */ |
| 110 extern void Dowa_HashMap_Clear(Dowa_PHashMap p_hash_map); | 109 extern void Dowa_HashMap_Clear(Dowa_PHashMap p_hash_map); |
| 111 /* Returns the number of entries currently in the hashmap. */ | 110 /* Returns the number of entries currently in the hashmap. */ |
| 112 extern uint32 Dowa_HashMap_Get_Count(Dowa_PHashMap p_hash_map); | 111 extern uint32 Dowa_HashMap_Get_Count(Dowa_PHashMap p_hash_map); |
| 113 | 112 |
| 113 // --- String manipuliation -- // | |
| 114 // Splice string from start to end | |
| 115 const char *Dowa_String_Slice(const char *from, size_t start, size_t end); | |
| 116 // --- Miscellaneous --- // | |
| 117 char *Dowa_Int32ToString(uint32 value, char *buffer); /* Just use atoid lmao*/ | |
| 118 | |
| 114 // --- Utility Functions --- // | 119 // --- Utility Functions --- // |
| 115 /* Prints all entries in the hashmap to stdout for debugging purposes. */ | 120 /* Prints all entries in the hashmap to stdout for debugging purposes. */ |
| 116 extern void Dowa_HashMap_Print(Dowa_PHashMap map); | 121 extern void Dowa_HashMap_Print(Dowa_PHashMap map); |
| 117 /* Loads all files from the specified folder into the hashmap. Uses file names as keys and file contents as values. Returns 0 on success, or -1 on failure. */ | 122 /* Loads all files from the specified folder into the hashmap. Uses file names as keys and file contents as values. Returns 0 on success, or -1 on failure. */ |
| 118 extern int Dowa_HashMap_Cache_Folder(Dowa_PHashMap map, const char *folder_path); | 123 extern int Dowa_HashMap_Cache_Folder(Dowa_PHashMap map, const char *folder_path); |