annotate dowa/dowa.h @ 17:d97ec3ded2ae

[Seobeo] Few changes... - Fixed seobeo edge for macos - Updated so that socket creation can be used for both client and server - Started on a cutelient library for making connection to the server.
author June Park <parkjune1995@gmail.com>
date Sat, 04 Oct 2025 07:53:12 -0700
parents 3e12bf044589
children fa2b8af609d9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
adcfad6e86fb Updated naming and separated out some logic within seobeo.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1 #ifndef DOWA
adcfad6e86fb Updated naming and separated out some logic within seobeo.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2 #define DOWA
adcfad6e86fb Updated naming and separated out some logic within seobeo.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3
adcfad6e86fb Updated naming and separated out some logic within seobeo.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4 #include <stdio.h>
2
8a43dedbe530 [Dowa] Added HashMap and Updated Arena naming.
June Park <parkjune1995@gmail.com>
parents: 1
diff changeset
5 #include <string.h> // stdup
1
adcfad6e86fb Updated naming and separated out some logic within seobeo.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
6 #include <stdlib.h> // only for malloc, free, stuff
2
8a43dedbe530 [Dowa] Added HashMap and Updated Arena naming.
June Park <parkjune1995@gmail.com>
parents: 1
diff changeset
7 #include <assert.h>
3
2758f5527d2b [Seobeo] Working on simple TCP server and client logic.
June Park <parkjune1995@gmail.com>
parents: 2
diff changeset
8 #include <dirent.h>
2758f5527d2b [Seobeo] Working on simple TCP server and client logic.
June Park <parkjune1995@gmail.com>
parents: 2
diff changeset
9
2758f5527d2b [Seobeo] Working on simple TCP server and client logic.
June Park <parkjune1995@gmail.com>
parents: 2
diff changeset
10 #include <sys/stat.h>
2758f5527d2b [Seobeo] Working on simple TCP server and client logic.
June Park <parkjune1995@gmail.com>
parents: 2
diff changeset
11 #include <limits.h>
2758f5527d2b [Seobeo] Working on simple TCP server and client logic.
June Park <parkjune1995@gmail.com>
parents: 2
diff changeset
12
1
adcfad6e86fb Updated naming and separated out some logic within seobeo.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
13 #include "dowa_internal.h"
adcfad6e86fb Updated naming and separated out some logic within seobeo.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
14
2
8a43dedbe530 [Dowa] Added HashMap and Updated Arena naming.
June Park <parkjune1995@gmail.com>
parents: 1
diff changeset
15 #define HASH_KEY_NUMBER 5381 // DJD hash number
5
3e12bf044589 Fixed Dowa hashmap to recursively add files into memory.
June Park <parkjune1995@gmail.com>
parents: 3
diff changeset
16 #define ONE_MEGA_BYTE 1048576
1
adcfad6e86fb Updated naming and separated out some logic within seobeo.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
17 typedef unsigned int uint32;
adcfad6e86fb Updated naming and separated out some logic within seobeo.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
18 typedef int int32;
adcfad6e86fb Updated naming and separated out some logic within seobeo.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
19 typedef unsigned short uint16;
adcfad6e86fb Updated naming and separated out some logic within seobeo.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
20 typedef short int16;
adcfad6e86fb Updated naming and separated out some logic within seobeo.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
21 typedef unsigned char uint8;
adcfad6e86fb Updated naming and separated out some logic within seobeo.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
22 typedef char int8;
adcfad6e86fb Updated naming and separated out some logic within seobeo.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
23 typedef char boolean;
adcfad6e86fb Updated naming and separated out some logic within seobeo.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
24
adcfad6e86fb Updated naming and separated out some logic within seobeo.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
25 // --- Misc --- //
adcfad6e86fb Updated naming and separated out some logic within seobeo.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
26 char *Dowa_Int32ToString(uint32 int32, char *buffer);
adcfad6e86fb Updated naming and separated out some logic within seobeo.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
27
adcfad6e86fb Updated naming and separated out some logic within seobeo.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
28 // --- Arena --- //
adcfad6e86fb Updated naming and separated out some logic within seobeo.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
29 typedef struct {
adcfad6e86fb Updated naming and separated out some logic within seobeo.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
30 char *buffer;
adcfad6e86fb Updated naming and separated out some logic within seobeo.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
31 size_t offset;
adcfad6e86fb Updated naming and separated out some logic within seobeo.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
32 size_t capacity;
5
3e12bf044589 Fixed Dowa hashmap to recursively add files into memory.
June Park <parkjune1995@gmail.com>
parents: 3
diff changeset
33 } Dowa_Arena, *Dowa_PArena;
2
8a43dedbe530 [Dowa] Added HashMap and Updated Arena naming.
June Park <parkjune1995@gmail.com>
parents: 1
diff changeset
34
5
3e12bf044589 Fixed Dowa hashmap to recursively add files into memory.
June Park <parkjune1995@gmail.com>
parents: 3
diff changeset
35 extern Dowa_PArena Dowa_Arena_Create(size_t capacity);
2
8a43dedbe530 [Dowa] Added HashMap and Updated Arena naming.
June Park <parkjune1995@gmail.com>
parents: 1
diff changeset
36 extern void *Dowa_Arena_Allocate(Dowa_PArena p_arena, size_t size);
8a43dedbe530 [Dowa] Added HashMap and Updated Arena naming.
June Park <parkjune1995@gmail.com>
parents: 1
diff changeset
37 extern void Dowa_Arena_Free(Dowa_PArena p_arena);
1
adcfad6e86fb Updated naming and separated out some logic within seobeo.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
38
5
3e12bf044589 Fixed Dowa hashmap to recursively add files into memory.
June Park <parkjune1995@gmail.com>
parents: 3
diff changeset
39 // --- HashMap --- //
3
2758f5527d2b [Seobeo] Working on simple TCP server and client logic.
June Park <parkjune1995@gmail.com>
parents: 2
diff changeset
40 typedef enum {
5
3e12bf044589 Fixed Dowa hashmap to recursively add files into memory.
June Park <parkjune1995@gmail.com>
parents: 3
diff changeset
41 DOWA_HASH_MAP_TYPE_BUFFER,
3e12bf044589 Fixed Dowa hashmap to recursively add files into memory.
June Park <parkjune1995@gmail.com>
parents: 3
diff changeset
42 DOWA_HASH_MAP_TYPE_STRING,
3e12bf044589 Fixed Dowa hashmap to recursively add files into memory.
June Park <parkjune1995@gmail.com>
parents: 3
diff changeset
43 DOWA_HASH_MAP_TYPE_HASHMAP,
3e12bf044589 Fixed Dowa hashmap to recursively add files into memory.
June Park <parkjune1995@gmail.com>
parents: 3
diff changeset
44 DOWA_HASH_MAP_TYPE_INT,
3e12bf044589 Fixed Dowa hashmap to recursively add files into memory.
June Park <parkjune1995@gmail.com>
parents: 3
diff changeset
45 } Dowa_HashMap_ValueType;
3
2758f5527d2b [Seobeo] Working on simple TCP server and client logic.
June Park <parkjune1995@gmail.com>
parents: 2
diff changeset
46
2
8a43dedbe530 [Dowa] Added HashMap and Updated Arena naming.
June Park <parkjune1995@gmail.com>
parents: 1
diff changeset
47 typedef struct {
3
2758f5527d2b [Seobeo] Working on simple TCP server and client logic.
June Park <parkjune1995@gmail.com>
parents: 2
diff changeset
48 char *key;
2758f5527d2b [Seobeo] Working on simple TCP server and client logic.
June Park <parkjune1995@gmail.com>
parents: 2
diff changeset
49 void *buffer;
2758f5527d2b [Seobeo] Working on simple TCP server and client logic.
June Park <parkjune1995@gmail.com>
parents: 2
diff changeset
50 size_t capacity;
5
3e12bf044589 Fixed Dowa hashmap to recursively add files into memory.
June Park <parkjune1995@gmail.com>
parents: 3
diff changeset
51 Dowa_HashMap_ValueType type;
2
8a43dedbe530 [Dowa] Added HashMap and Updated Arena naming.
June Park <parkjune1995@gmail.com>
parents: 1
diff changeset
52 } Dowa_HashEntry, *Dowa_PHashEntry;
8a43dedbe530 [Dowa] Added HashMap and Updated Arena naming.
June Park <parkjune1995@gmail.com>
parents: 1
diff changeset
53
8a43dedbe530 [Dowa] Added HashMap and Updated Arena naming.
June Park <parkjune1995@gmail.com>
parents: 1
diff changeset
54 typedef struct {
8a43dedbe530 [Dowa] Added HashMap and Updated Arena naming.
June Park <parkjune1995@gmail.com>
parents: 1
diff changeset
55 Dowa_PHashEntry *entries;
8a43dedbe530 [Dowa] Added HashMap and Updated Arena naming.
June Park <parkjune1995@gmail.com>
parents: 1
diff changeset
56 size_t capacity;
8a43dedbe530 [Dowa] Added HashMap and Updated Arena naming.
June Park <parkjune1995@gmail.com>
parents: 1
diff changeset
57 uint32 current_capacity;
8a43dedbe530 [Dowa] Added HashMap and Updated Arena naming.
June Park <parkjune1995@gmail.com>
parents: 1
diff changeset
58 } Dowa_HashMap, *Dowa_PHashMap;
8a43dedbe530 [Dowa] Added HashMap and Updated Arena naming.
June Park <parkjune1995@gmail.com>
parents: 1
diff changeset
59
5
3e12bf044589 Fixed Dowa hashmap to recursively add files into memory.
June Park <parkjune1995@gmail.com>
parents: 3
diff changeset
60 extern Dowa_PHashMap Dowa_HashMap_Create(size_t capacity);
3e12bf044589 Fixed Dowa hashmap to recursively add files into memory.
June Park <parkjune1995@gmail.com>
parents: 3
diff changeset
61 extern void Dowa_HashMap_Free(Dowa_PHashMap p_hash_map);
3e12bf044589 Fixed Dowa hashmap to recursively add files into memory.
June Park <parkjune1995@gmail.com>
parents: 3
diff changeset
62 extern int32 Dowa_HashMap_GetPosition(Dowa_PHashMap p_hash_map, char *key);
3e12bf044589 Fixed Dowa hashmap to recursively add files into memory.
June Park <parkjune1995@gmail.com>
parents: 3
diff changeset
63 extern void *Dowa_HashMap_Get(Dowa_PHashMap p_hash_map, char *key);
3e12bf044589 Fixed Dowa hashmap to recursively add files into memory.
June Park <parkjune1995@gmail.com>
parents: 3
diff changeset
64 extern void Dowa_HashMap_PushValue(Dowa_PHashMap p_hash_map, char *key, void *value, size_t value_size);
3e12bf044589 Fixed Dowa hashmap to recursively add files into memory.
June Park <parkjune1995@gmail.com>
parents: 3
diff changeset
65 extern int32 Dowa_HashMap_PushValueWithTypeNoCopy(Dowa_PHashMap p_hash_map, char *key, void *value, size_t value_size, Dowa_HashMap_ValueType type);
3e12bf044589 Fixed Dowa hashmap to recursively add files into memory.
June Park <parkjune1995@gmail.com>
parents: 3
diff changeset
66 extern int32 Dowa_HashMap_PushValueWithType(Dowa_PHashMap p_hash_map, char *key, void *value, size_t value_size, Dowa_HashMap_ValueType type);
3e12bf044589 Fixed Dowa hashmap to recursively add files into memory.
June Park <parkjune1995@gmail.com>
parents: 3
diff changeset
67 extern void Dowa_HashMap_PopKey(Dowa_PHashMap p_hash_map, char *key);
2
8a43dedbe530 [Dowa] Added HashMap and Updated Arena naming.
June Park <parkjune1995@gmail.com>
parents: 1
diff changeset
68
3
2758f5527d2b [Seobeo] Working on simple TCP server and client logic.
June Park <parkjune1995@gmail.com>
parents: 2
diff changeset
69 // --- Maybe Useful --- //
2758f5527d2b [Seobeo] Working on simple TCP server and client logic.
June Park <parkjune1995@gmail.com>
parents: 2
diff changeset
70 extern void Dowa_HashMap_Print(Dowa_PHashMap map);
5
3e12bf044589 Fixed Dowa hashmap to recursively add files into memory.
June Park <parkjune1995@gmail.com>
parents: 3
diff changeset
71 // 0 for success, -1 for failure. Get all files in the folder into key and vlaues.
3e12bf044589 Fixed Dowa hashmap to recursively add files into memory.
June Park <parkjune1995@gmail.com>
parents: 3
diff changeset
72 extern int Dowa_HashMap_Cache_Folder(Dowa_PHashMap map, const char *folder_path);
3
2758f5527d2b [Seobeo] Working on simple TCP server and client logic.
June Park <parkjune1995@gmail.com>
parents: 2
diff changeset
73
1
adcfad6e86fb Updated naming and separated out some logic within seobeo.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
74
adcfad6e86fb Updated naming and separated out some logic within seobeo.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
75 #endif