diff --git a/.clang-format b/.clang-format index db0a4e2..770640c 100644 --- a/.clang-format +++ b/.clang-format @@ -4,10 +4,23 @@ AccessModifierOffset: -4 InsertBraces: true AlignArrayOfStructures: Left AlignAfterOpenBracket: Align -AlignConsecutiveMacros: Consecutive -AlignConsecutiveAssignments: Consecutive +AlignConsecutiveMacros: + Enabled: true + AcrossEmptyLines: true + AcrossComments: true +AlignConsecutiveAssignments: + Enabled: true + AcrossEmptyLines: false + AcrossComments: true + PadOperators: true + AlignCompound: true AlignConsecutiveBitFields: None -AlignConsecutiveDeclarations: Consecutive +AlignConsecutiveDeclarations: + Enabled: true + AcrossEmptyLines: false + AcrossComments: true + PadOperators: true + AlignCompound: true AlignEscapedNewlines: Left AlignOperands: DontAlign AlignTrailingComments: true @@ -195,6 +208,7 @@ StatementMacros: TabWidth: 4 UseCRLF: false UseTab: Never +SeparateDefinitionBlocks: Always WhitespaceSensitiveMacros: - STRINGIZE - PP_STRINGIZE diff --git a/srcs/httpserver/include/haywire.h b/srcs/httpserver/include/haywire.h index 687f4ae..13ebb0a 100644 --- a/srcs/httpserver/include/haywire.h +++ b/srcs/httpserver/include/haywire.h @@ -166,6 +166,7 @@ typedef struct { void *headers; hw_string *body; size_t body_length; + enum { OK, SIZE_EXCEEDED, @@ -174,8 +175,9 @@ typedef struct { } state; } http_request; -typedef void(HAYWIRE_CALLING_CONVENTION *http_request_callback)(http_request *request, hw_http_response *response, - void *user_data); +typedef void(HAYWIRE_CALLING_CONVENTION *http_request_callback)(http_request *request, + hw_http_response *response, + void *user_data); typedef void(HAYWIRE_CALLING_CONVENTION *http_response_complete_callback)(void *user_data); HAYWIRE_EXTERN int hw_init_from_config(char *configuration_filename); @@ -185,13 +187,14 @@ HAYWIRE_EXTERN void free_http_server(); HAYWIRE_EXTERN void hw_http_add_route(char *route, http_request_callback callback, void *user_data); HAYWIRE_EXTERN hw_string *hw_get_header(http_request *request, hw_string *key); -HAYWIRE_EXTERN void hw_free_http_response(hw_http_response *response); -HAYWIRE_EXTERN void hw_set_http_version(hw_http_response *response, unsigned short major, unsigned short minor); -HAYWIRE_EXTERN void hw_set_response_status_code(hw_http_response *response, hw_string *status_code); -HAYWIRE_EXTERN void hw_set_response_header(hw_http_response *response, hw_string *name, hw_string *value); -HAYWIRE_EXTERN void hw_set_body(hw_http_response *response, hw_string *body); -HAYWIRE_EXTERN void hw_http_response_send(hw_http_response *response, void *user_data, - http_response_complete_callback callback); +HAYWIRE_EXTERN void hw_free_http_response(hw_http_response *response); +HAYWIRE_EXTERN void hw_set_http_version(hw_http_response *response, unsigned short major, unsigned short minor); +HAYWIRE_EXTERN void hw_set_response_status_code(hw_http_response *response, hw_string *status_code); +HAYWIRE_EXTERN void hw_set_response_header(hw_http_response *response, hw_string *name, hw_string *value); +HAYWIRE_EXTERN void hw_set_body(hw_http_response *response, hw_string *body); +HAYWIRE_EXTERN void hw_http_response_send(hw_http_response *response, + void *user_data, + http_response_complete_callback callback); HAYWIRE_EXTERN void hw_http_response_send_error(hw_http_response *response, const char *error, const char *err_msg); HAYWIRE_EXTERN void hw_print_request_headers(http_request *request); diff --git a/srcs/open_dhcp/opendhcpd.cpp b/srcs/open_dhcp/opendhcpd.cpp index c993225..7300b65 100644 --- a/srcs/open_dhcp/opendhcpd.cpp +++ b/srcs/open_dhcp/opendhcpd.cpp @@ -42,34 +42,34 @@ using namespace std; #include "task_manager.h" #include "user_errno.h" -void on_system_exit(void *p); +void on_system_exit(void *p); //Global Variables -timeval tv; -fd_set readfds; +timeval tv; +fd_set readfds; //fd_set writefds; -data9 dhcpr; -data9 token; -data1 network; -data1 newNetwork; -data2 cfig; -data71 lump; -bool kRunning = true; -dhcpMap dhcpCache; -char serviceName[] = "OpenDHCPServer"; +data9 dhcpr; +data9 token; +data1 network; +data1 newNetwork; +data2 cfig; +data71 lump; +bool kRunning = true; +dhcpMap dhcpCache; +char serviceName[] = "OpenDHCPServer"; //char tempbuff[512] = ""; //char logBuff[256]; //char extbuff[256] = ""; -bool verbatim = false; -char iniFile[256] = ""; -char leaFile[256] = ""; +bool verbatim = false; +char iniFile[256] = ""; +char leaFile[256] = ""; //char logFile[256] = ""; -char filePATH[256] = ""; -char htmlTitle[256] = ""; -char nicif[256] = ""; +char filePATH[256] = ""; +char htmlTitle[256] = ""; +char nicif[256] = ""; //char arpa[] = ".in-addr.arpa"; -time_t t = time(nullptr); -pthread_mutex_t mutStateFile = PTHREAD_MUTEX_INITIALIZER; -pthread_mutex_t mutLogFile = PTHREAD_MUTEX_INITIALIZER; +time_t t = time(nullptr); +pthread_mutex_t mutStateFile = PTHREAD_MUTEX_INITIALIZER; +pthread_mutex_t mutLogFile = PTHREAD_MUTEX_INITIALIZER; struct ifconf Ifc; struct ifreq IfcBuf[MAX_SERVERS]; @@ -81,11 +81,11 @@ const char GLOBALOPTIONS[] = "GLOBAL_OPTIONS"; //const char send200[] = "HTTP/1.1 200 OK\r\nDate: %s\r\nLast-Modified: %s\r\nContent-Type: text/html\r\nConnection: Close\r\nTransfer-Encoding: chunked\r\n"; //const char send200[] = "HTTP/1.1 200 OK\r\nDate: %s\r\nLast-Modified: %s\r\nContent-Type: text/html\r\nConnection: Close\r\nContent-Length: \r\n\r\n"; //const char send200[] = "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\nConnection: Close\r\n\r\n"; -const char send403[] = "HTTP/1.1 403 Forbidden\r\n\r\n