comparison seobeo/seobeo.h @ 7:114cad94008f

[Seobeo] Updated to support thread and edge server calls.
author June Park <parkjune1995@gmail.com>
date Mon, 29 Sep 2025 17:00:38 -0700
parents 1e61008b9980
children fb2cff495a60
comparison
equal deleted inserted replaced
6:1e61008b9980 7:114cad94008f
16 #include <netdb.h> 16 #include <netdb.h>
17 #include <arpa/inet.h> 17 #include <arpa/inet.h>
18 #include <sys/wait.h> 18 #include <sys/wait.h>
19 #include <signal.h> 19 #include <signal.h>
20 #include <fcntl.h> 20 #include <fcntl.h>
21 #include <pthread.h>
21 22
22 #include "dowa/dowa.h" 23 #include "dowa/dowa.h"
23 24
24 #define INITIAL_BUFFER_CAPACITY 4096 25 #define INITIAL_BUFFER_CAPACITY 4096
25 26
51 void *file; 52 void *file;
52 void *text_copy; 53 void *text_copy;
53 char *file_name; 54 char *file_name;
54 } Sebeo_Handle, *Seobeo_PHandle; 55 } Sebeo_Handle, *Seobeo_PHandle;
55 56
57 typedef struct {
58 Seobeo_PHandle srv;
59 Dowa_PHashMap cache;
60 int evfd; // epoll‐fd or kqueue‐fd
61 } WorkerArgs;
62
63 typedef enum {
64 SEOBEO_MODE_FORK,
65 SEOBEO_MODE_EDGE,
66 } Seobeo_ServerMode;
56 67
57 // --- Socket, IP related --- // 68 // --- Socket, IP related --- //
58 extern int Seobeo_CreateSocket(int32 stream, const char *host, const char* port, int32 backlog); 69 extern int Seobeo_CreateSocket(int32 stream, const char *host, const char* port, int32 backlog);
59 extern void *Seobeo_GetIP4OrIP6(struct sockaddr *sa); 70 extern void *Seobeo_GetIP4OrIP6(struct sockaddr *sa);
60 71
65 76
66 // --- Web --- // 77 // --- Web --- //
67 extern void Seobeo_Web_GenerateResponseHeader(void *buffer, int status, const char *content_type, const int content_length); 78 extern void Seobeo_Web_GenerateResponseHeader(void *buffer, int status, const char *content_type, const int content_length);
68 extern void Seobeo_Web_HandleClientRequest(Seobeo_PHandle cli, Dowa_PHashMap p_html_cache); 79 extern void Seobeo_Web_HandleClientRequest(Seobeo_PHandle cli, Dowa_PHashMap p_html_cache);
69 extern int Seobeo_Web_ParseClientHeader(Seobeo_PHandle p_handle, Dowa_PHashMap map); 80 extern int Seobeo_Web_ParseClientHeader(Seobeo_PHandle p_handle, Dowa_PHashMap map);
70 extern int Seobeo_Web_StartBasicHTTPServer(const char *folder_path, const char *port); 81 extern int Seobeo_Web_StartBasicHTTPServer(const char *folder_path, const char *port, Seobeo_ServerMode mode, int thread_count);
82 extern void *Seobeo_Web_Edge_Worker(void *vargs); // Maybe not web only...
83 extern void Seobeo_Web_Edge(Seobeo_PHandle p_server_handle, int thread_count, Dowa_PHashMap p_html_cache);
71 84
72 // --- Helper functions --- // 85 // --- Helper functions --- //
73 extern void Seobeo_Handle_Destroy(Seobeo_PHandle p_handle); 86 extern void Seobeo_Handle_Destroy(Seobeo_PHandle p_handle);
74 extern int Seobeo_Handle_Flush(Seobeo_PHandle p_handle); 87 extern int Seobeo_Handle_Flush(Seobeo_PHandle p_handle);
75 extern int Seobeo_Handle_Queue(Seobeo_PHandle p_handle, const uint8_t *data, uint32_t data_size); 88 extern int Seobeo_Handle_Queue(Seobeo_PHandle p_handle, const uint8_t *data, uint32_t data_size);