comparison seobeo/seobeo_internal.h @ 71:75de5903355c

Giagantic changes that update Dowa library to be more align with stb style array and hashmap. Updated Seobeo to be caching on server side instead of file level caching. Deleted bunch of things I don't really use.
author June Park <parkjune1995@gmail.com>
date Sun, 28 Dec 2025 20:34:22 -0800
parents 6626ec933933
children 4532ce6d9eb8
comparison
equal deleted inserted replaced
70:4bc56e88e1f3 71:75de5903355c
1 #ifndef SEOBEO_SERVER_INTERNAL_H 1 #ifndef SEOBEO_SERVER_INTERNAL_H
2 #define SEOBEO_SERVER_INTERNAL_H 2 #define SEOBEO_SERVER_INTERNAL_H
3 3
4 // SSL - conditionally included
5 #ifndef SEOBEO_NO_SSL 4 #ifndef SEOBEO_NO_SSL
6 #include <openssl/ssl.h> 5 #include <openssl/ssl.h>
7 #include <openssl/err.h> 6 #include <openssl/err.h>
8 #define SSL_CTX_TYPE SSL_CTX 7 #define SSL_CTX_TYPE SSL_CTX
9 #define SSL_TYPE SSL 8 #define SSL_TYPE SSL
47 char *file_name; 46 char *file_name;
48 47
49 atomic_bool destroyed; 48 atomic_bool destroyed;
50 } Seobeo_Handle; 49 } Seobeo_Handle;
51 50
51 // HTML cache type: maps file paths (char*) to file contents (char*)
52 typedef Dowa_KV(char*, char*) Seobeo_Cache_Entry;
53
52 typedef struct { 54 typedef struct {
53 Seobeo_Handle *srv; 55 Seobeo_Handle *srv;
54 Dowa_HashMap *cache; 56 Seobeo_Cache_Entry *cache;
55 } WorkerArgs; 57 } WorkerArgs;
56 58
57 typedef enum { 59 typedef enum {
58 SEOBEO_MODE_FORK, 60 SEOBEO_MODE_FORK,
59 SEOBEO_MODE_EDGE, 61 SEOBEO_MODE_EDGE,
60 } Seobeo_ServerMode; 62 } Seobeo_ServerMode;
61 63
62 64
63 65 // HTTP request map type: maps header names to header values
66 typedef Dowa_KV(char*, char*) Seobeo_Request_Entry;
64 67
65 // --- Parse Header into Dowa Map ---// 68 // --- Parse Header into Dowa Map ---//
66 extern int Seobeo_Web_Header_Parse(Seobeo_Handle *p_handle, Dowa_HashMap *map); 69 extern int Seobeo_Web_Header_Parse(Seobeo_Handle *p_handle, Seobeo_Request_Entry **pp_map, Dowa_Arena *p_arena);
67 70
68 // --- Handle Request --- // 71 // --- Handle Request --- //
69 extern void Seobeo_Web_HandleClientRequest(Seobeo_Handle *cli, Dowa_HashMap *p_html_cache); 72 extern void Seobeo_Web_HandleClientRequest(Seobeo_Handle *cli, Seobeo_Cache_Entry *p_html_cache);
70 73
71 // --- SSL --- // 74 // --- SSL --- //
72 extern void Seobeo_Web_SSL_Init(); 75 extern void Seobeo_Web_SSL_Init();
73 extern void Seobeo_Web_SSL_Cleanup(); // Not used 76 extern void Seobeo_Web_SSL_Cleanup(); // Not used
74 extern int Seobeo_SSL_Setup_Client(Seobeo_Handle *p_handle, const char *host, int socket_fd); 77 extern int Seobeo_SSL_Setup_Client(Seobeo_Handle *p_handle, const char *host, int socket_fd);
75 extern void Seobeo_SSL_Cleanup(Seobeo_Handle *p_handle); 78 extern void Seobeo_SSL_Cleanup(Seobeo_Handle *p_handle);
76 extern int32 Seobeo_SSL_Write(Seobeo_Handle *p_handle, const uint8 *data, uint32 length); 79 extern int32 Seobeo_SSL_Write(Seobeo_Handle *p_handle, const uint8 *data, uint32 length);
77 extern int32 Seobeo_SSL_Read(Seobeo_Handle *p_handle, uint8 *buffer, uint32 length); 80 extern int32 Seobeo_SSL_Read(Seobeo_Handle *p_handle, uint8 *buffer, uint32 length);
78 81
79 // --- Serving using Edge --- // 82 // --- Serving using Edge --- //
80 extern void *Seobeo_Web_Edge_Worker(void *vargs); 83 extern void *Seobeo_Web_Edge_Worker(void *vargs);
81 extern void Seobeo_Web_Edge(Seobeo_Handle *p_server_handle, int thread_count, Dowa_HashMap *p_html_cache); 84 extern void Seobeo_Web_Edge(Seobeo_Handle *p_server_handle, int thread_count, Seobeo_Cache_Entry *p_html_cache);
82 extern void Seobeo_Web_Edge_2(Seobeo_Handle *p_server_handle, Dowa_HashMap *p_html_cache);
83 85
84 #endif 86 #endif