Mercurial
diff seobeo/seobeo.h @ 6:1e61008b9980
[Seobeo] Updated seobeo so that API is more opinionated. Added my webpage./build.sh
| author | June Park <parkjune1995@gmail.com> |
|---|---|
| date | Mon, 29 Sep 2025 16:00:44 -0700 |
| parents | 3e12bf044589 |
| children | 114cad94008f |
line wrap: on
line diff
--- a/seobeo/seobeo.h Sat Sep 27 16:23:04 2025 -0700 +++ b/seobeo/seobeo.h Mon Sep 29 16:00:44 2025 -0700 @@ -23,6 +23,17 @@ #define INITIAL_BUFFER_CAPACITY 4096 +// HTTP STATUS CODE +#define HTTP_OK 200 +#define HTTP_CREATED 201 +#define HTTP_MOVED_PERMANENTLY 301 +#define HTTP_FOUND 302 +#define HTTP_BAD_REQUEST 400 +#define HTTP_UNAUTHORIZED 401 +#define HTTP_FORBIDDEN 403 +#define HTTP_NOT_FOUND 404 +#define HTTP_INTERNAL_ERROR 500 + typedef struct { int socket; char *host; @@ -31,7 +42,7 @@ uint8 *read_buffer; uint32 read_buffer_capacity; uint32 read_buffer_len; // current size - uint32 read_buffer_pos; // TODO: Implement this for client + uint32 read_buffer_used; // TODO: Implement this for client uint8 *write_buffer; uint32 write_buffer_capacity; @@ -49,11 +60,21 @@ // --- TCP --- // extern Seobeo_PHandle Seobeo_Stream_Handle_Create(const char *host, const char* port); -extern Seobeo_PHandle Seobeo_Stream_Handle_Accept(Seobeo_PHandle server_h); +extern Seobeo_PHandle Seobeo_Stream_Handle_Accept(Seobeo_PHandle p_server_handle); +extern int Seobeo_Stream_Handle_Read(Seobeo_PHandle p_handle); + +// --- Web --- // +extern void Seobeo_Web_GenerateResponseHeader(void *buffer, int status, const char *content_type, const int content_length); +extern void Seobeo_Web_HandleClientRequest(Seobeo_PHandle cli, Dowa_PHashMap p_html_cache); +extern int Seobeo_Web_ParseClientHeader(Seobeo_PHandle p_handle, Dowa_PHashMap map); +extern int Seobeo_Web_StartBasicHTTPServer(const char *folder_path, const char *port); // --- Helper functions --- // -extern void Seobeo_Handle_Destroy(Seobeo_PHandle h); -extern int Seobeo_Handle_Flush(Seobeo_PHandle h); -extern int Seobeo_Handle_QueueData(Seobeo_PHandle h, const uint8_t *data, uint32_t data_size); +extern void Seobeo_Handle_Destroy(Seobeo_PHandle p_handle); +extern int Seobeo_Handle_Flush(Seobeo_PHandle p_handle); +extern int Seobeo_Handle_Queue(Seobeo_PHandle p_handle, const uint8_t *data, uint32_t data_size); +extern int Seobeo_Handle_Read(Seobeo_PHandle p_handle); +extern void Seobeo_Handle_Consume(Seobeo_PHandle p_handle, uint32 consumed); + #endif