refactor: upgrade myclib dep

This commit is contained in:
2025-09-12 03:44:55 +02:00
parent 651b5e592b
commit fc21c740bd
8 changed files with 66 additions and 63 deletions

View File

@@ -1,10 +1,10 @@
#ifndef CWS_HTTP_H
#define CWS_HTTP_H
#include <myclib/myhashmap.h>
#include <myclib/mystring.h>
#include <stddef.h>
#include "myclib/hashmap/myhashmap.h"
#include "myclib/string/mystring.h"
#include "utils/config.h"
#define CWS_HTTP_HEADER_MAX 512
@@ -29,12 +29,12 @@ typedef enum cws_http_status_t {
*
*/
typedef struct cws_http_t {
int sockfd; /**< Socket file descriptor */
cws_http_method method; /**< HTTP request method */
mcl_string *location; /**< Resource requested */
mcl_string *location_path; /**< Full resource path */
mcl_string *http_version; /**< HTTP version */
mcl_hashmap *headers; /**< Headers hash map */
int sockfd; /**< Socket file descriptor */
cws_http_method method; /**< HTTP request method */
string_s *location; /**< Resource requested */
string_s *location_path; /**< Full resource path */
string_s *http_version; /**< HTTP version */
hashmap_s *headers; /**< Headers hash map */
} cws_http;
/**
@@ -43,7 +43,7 @@ typedef struct cws_http_t {
* @param[in] request_str The http request sent to the server
* @return Returns a http_t pointer to the request
*/
cws_http *cws_http_parse(mcl_string *request_str, int sockfd, cws_config *config);
cws_http *cws_http_parse(string_s *request_str, int sockfd, cws_config *config);
int cws_http_get_content_type(cws_http *request, char *content_type);

View File

@@ -1,11 +1,11 @@
#ifndef CWS_SERVER_H
#define CWS_SERVER_H
#include <myclib/myhashmap.h>
#include <netdb.h>
#include <signal.h>
#include <sys/socket.h>
#include "myclib/hashmap/myhashmap.h"
#include "utils/config.h"
/* Clients max queue */
@@ -48,7 +48,7 @@ typedef enum cws_server_ret_t {
cws_server_ret cws_server_start(cws_config *config);
cws_server_ret cws_server_loop(int server_fd, cws_config *config);
int cws_server_handle_new_client(int server_fd, mcl_hashmap *clients);
int cws_server_handle_new_client(int server_fd, hashmap_s *clients);
int cws_server_accept_client(int server_fd, struct sockaddr_storage *their_sa, socklen_t *theirsa_size);
cws_server_ret cws_fd_set_nonblocking(int sockfd);

View File

@@ -1,9 +1,9 @@
#ifndef CWS_WORKER_H
#define CWS_WORKER_H
#include <myclib/myhashmap.h>
#include <pthread.h>
#include "myclib/hashmap/myhashmap.h"
#include "server/server.h"
typedef struct cws_worker_t {
@@ -11,17 +11,17 @@ typedef struct cws_worker_t {
int pipefd[2];
size_t clients_num;
pthread_t thread;
mcl_hashmap *clients;
hashmap_s *clients;
cws_config *config;
} cws_worker;
cws_worker **cws_worker_init(size_t workers_num, mcl_hashmap *clients, cws_config *config);
cws_worker **cws_worker_init(size_t workers_num, hashmap_s *clients, cws_config *config);
void cws_worker_free(cws_worker **workers, size_t workers_num);
void *cws_worker_loop(void *arg);
void cws_server_close_client(int epfd, int client_fd, mcl_hashmap *clients);
void cws_server_close_client(int epfd, int client_fd, hashmap_s *clients);
cws_server_ret cws_epoll_add(int epfd, int sockfd, uint32_t events);
cws_server_ret cws_epoll_del(int epfd, int sockfd);
cws_server_ret cws_server_handle_client_data(int epfd, int client_fd, mcl_hashmap *clients, cws_config *config);
cws_server_ret cws_server_handle_client_data(int epfd, int client_fd, hashmap_s *clients, cws_config *config);
#endif