Mercurial
diff seobeo/s_web.c @ 19:875bb6e10db7
[Seobeo] Chaning Function naming to be easily readable.
| author | June Park <parkjune1995@gmail.com> |
|---|---|
| date | Mon, 06 Oct 2025 09:55:34 -0700 |
| parents | fa2b8af609d9 |
| children | 09def63429b9 |
line wrap: on
line diff
--- a/seobeo/s_web.c Mon Oct 06 08:21:34 2025 -0700 +++ b/seobeo/s_web.c Mon Oct 06 09:55:34 2025 -0700 @@ -26,7 +26,7 @@ ); } -void Seobeo_Web_GenerateResponseHeader(void *buffer, int status, +void Seobeo_Web_Header_Generate(void *buffer, int status, const char *content_type, const int content_length) { const char *status_text; @@ -71,10 +71,10 @@ if (!p_response_header) { perror("Dowa_Arena_Allocate"); goto clean_up; } p_req_map = Dowa_HashMap_Create(32); - if (Seobeo_Web_ParseClientHeader(p_cli_handle, p_req_map) != 0) + if (Seobeo_Web_Header_Parse(p_cli_handle, p_req_map) != 0) { // malformed request or closed — respond 400 - Seobeo_Web_GenerateResponseHeader(p_response_header, + Seobeo_Web_Header_Generate(p_response_header, HTTP_BAD_REQUEST, "text/plain", 0); Seobeo_Handle_Queue(p_cli_handle, @@ -126,7 +126,7 @@ if (!p_current) { fprintf(stderr, "No value in hashmap key: %s\n\n", dir); - Seobeo_Web_GenerateResponseHeader(p_response_header, + Seobeo_Web_Header_Generate(p_response_header, HTTP_NOT_FOUND, "text/html", 0); Seobeo_Handle_Queue(p_cli_handle, @@ -143,7 +143,7 @@ // Missing so 404 if (!entry) { - Seobeo_Web_GenerateResponseHeader(p_response_header, + Seobeo_Web_Header_Generate(p_response_header, HTTP_NOT_FOUND, "text/html", 0); Seobeo_Handle_Queue(p_cli_handle, @@ -168,7 +168,7 @@ size_t body_size = entry->capacity; printf("key: %s\n\n", entry->key); printf("Body Size: %zu\n\n", body_size); - Seobeo_Web_GenerateResponseHeader(p_response_header, + Seobeo_Web_Header_Generate(p_response_header, HTTP_OK, mime, body_size); @@ -193,7 +193,7 @@ Dowa_HashMap_Free(p_req_map); // TODO: Maybe initilized hashmap within the Arena? } -int Seobeo_Web_ParseClientHeader(Seobeo_PHandle p_handle, Dowa_PHashMap map) +int Seobeo_Web_Header_Parse(Seobeo_PHandle p_handle, Dowa_PHashMap map) { // 1) Fill read_buffer until we see "\r\n\r\n" while (1) @@ -302,7 +302,7 @@ errno = saved_errno; } -int Seobeo_Web_StartBasicHTTPServer( +int Seobeo_Web_Server_Start( const char *folder_path, const char *port, Seobeo_ServerMode mode, @@ -334,7 +334,7 @@ while (1) { Seobeo_PHandle cli = - Seobeo_Stream_Handle_Accept(p_server_handle); + Seobeo_Stream_Handle_Server_Accept(p_server_handle); if (!cli) continue; if (fork() == 0) @@ -356,10 +356,9 @@ return -1; } - -int Seobeo_Web_ClientGet(const char *host, - const char *port, - const char *path) +int Seobeo_Web_Client_Get(const char *host, + const char *port, + const char *path) { Seobeo_PHandle h = Seobeo_Stream_Handle_Client_Create(host, port, TRUE); if (!h || h->socket < 0) @@ -424,3 +423,14 @@ Seobeo_Handle_Destroy(h); return 0; } + +void Seobeo_Web_SSL_Init() +{ + SSL_load_error_strings(); + OpenSSL_add_ssl_algorithms(); +} + +void Seobeo_Web_SSL_Cleanup(void) +{ + EVP_cleanup(); // I don't think these are needed... +}