refactor(server): clean code

This commit is contained in:
2025-09-12 21:16:19 +02:00
parent b0151ca885
commit 15a0f0290b
9 changed files with 164 additions and 141 deletions

View File

@@ -4,6 +4,33 @@
#include <myclib/mysocket.h>
#include <stdbool.h>
typedef enum cws_server_ret {
CWS_SERVER_OK,
CWS_SERVER_CONFIG,
CWS_SERVER_FD_ERROR,
CWS_SERVER_CLIENT_NOT_FOUND,
CWS_SERVER_CLIENT_DISCONNECTED,
CWS_SERVER_CLIENT_DISCONNECTED_ERROR,
CWS_SERVER_HTTP_PARSE_ERROR,
CWS_SERVER_GETADDRINFO_ERROR,
CWS_SERVER_SOCKET_ERROR,
CWS_SERVER_SETSOCKOPT_ERROR,
CWS_SERVER_BIND_ERROR,
CWS_SERVER_LISTEN_ERROR,
CWS_SERVER_EPOLL_ADD_ERROR,
CWS_SERVER_EPOLL_DEL_ERROR,
CWS_SERVER_FD_NONBLOCKING_ERROR,
CWS_SERVER_ACCEPT_CLIENT_ERROR,
CWS_SERVER_HASHMAP_INIT,
CWS_SERVER_MALLOC_ERROR,
CWS_SERVER_REQUEST_TOO_LARGE,
CWS_SERVER_THREADPOOL_ERROR,
CWS_SERVER_EPOLL_CREATE_ERROR,
CWS_SERVER_WORKER_ERROR,
} cws_server_ret;
cws_server_ret cws_fd_set_nonblocking(int sockfd);
void cws_utils_get_client_ip(struct sockaddr_storage *sa, char *ip);
/* Functions used for hash maps */