Mercurial
view 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 |
line wrap: on
line source
#ifndef SEOBEO_SERVER_INTERNAL_H #define SEOBEO_SERVER_INTERNAL_H #ifndef SEOBEO_NO_SSL #include <openssl/ssl.h> #include <openssl/err.h> #define SSL_CTX_TYPE SSL_CTX #define SSL_TYPE SSL #else #define SSL_CTX_TYPE void #define SSL_TYPE void #endif #ifndef DIRECTORY #define DIRECTORY #endif #include "dowa/dowa.h" typedef enum { SEOBEO_STREAM_TYPE_SERVER, SEOBEO_STREAM_TYPE_CLIENT, } Seobeo_SocketType; typedef struct { int32 socket; Seobeo_SocketType type; boolean connected; char *host; char *port; SSL_CTX_TYPE *ssl_ctx; SSL_TYPE *ssl; uint8 *read_buffer; uint32 read_buffer_capacity; uint32 read_buffer_len; // current size uint32 read_buffer_used; // TODO: Implement this for client uint8 *write_buffer; uint32 write_buffer_capacity; uint32 write_buffer_len; // current size void *file; void *text_copy; char *file_name; atomic_bool destroyed; } Seobeo_Handle; // HTML cache type: maps file paths (char*) to file contents (char*) typedef Dowa_KV(char*, char*) Seobeo_Cache_Entry; typedef struct { Seobeo_Handle *srv; Seobeo_Cache_Entry *cache; } WorkerArgs; typedef enum { SEOBEO_MODE_FORK, SEOBEO_MODE_EDGE, } Seobeo_ServerMode; // HTTP request map type: maps header names to header values typedef Dowa_KV(char*, char*) Seobeo_Request_Entry; // --- Parse Header into Dowa Map ---// extern int Seobeo_Web_Header_Parse(Seobeo_Handle *p_handle, Seobeo_Request_Entry **pp_map, Dowa_Arena *p_arena); // --- Handle Request --- // extern void Seobeo_Web_HandleClientRequest(Seobeo_Handle *cli, Seobeo_Cache_Entry *p_html_cache); // --- SSL --- // extern void Seobeo_Web_SSL_Init(); extern void Seobeo_Web_SSL_Cleanup(); // Not used extern int Seobeo_SSL_Setup_Client(Seobeo_Handle *p_handle, const char *host, int socket_fd); extern void Seobeo_SSL_Cleanup(Seobeo_Handle *p_handle); extern int32 Seobeo_SSL_Write(Seobeo_Handle *p_handle, const uint8 *data, uint32 length); extern int32 Seobeo_SSL_Read(Seobeo_Handle *p_handle, uint8 *buffer, uint32 length); // --- Serving using Edge --- // extern void *Seobeo_Web_Edge_Worker(void *vargs); extern void Seobeo_Web_Edge(Seobeo_Handle *p_server_handle, int thread_count, Seobeo_Cache_Entry *p_html_cache); #endif