From 952808aefc70f2a7bbebbc08ab4913b6ea4fe495 Mon Sep 17 00:00:00 2001 From: Stephen Seo Date: Mon, 9 Sep 2024 13:53:58 +0900 Subject: [PATCH] Minor fixes/cleanup --- src/arg_parse.c | 2 +- src/arg_parse.h | 2 +- src/big_endian.c | 2 +- src/big_endian.h | 2 +- src/config.c | 2 +- src/config.h | 2 +- src/globals.c | 2 +- src/globals.h | 2 +- src/http.c | 2 +- src/http.h | 2 +- src/http_template.c | 2 +- src/http_template.h | 2 +- src/main.c | 17 ++++++----------- src/signal_handling.c | 2 +- src/signal_handling.h | 2 +- src/tcp_socket.c | 2 +- src/tcp_socket.h | 2 +- src/test.c | 2 +- 18 files changed, 23 insertions(+), 28 deletions(-) diff --git a/src/arg_parse.c b/src/arg_parse.c index 437d9c5..f981e83 100644 --- a/src/arg_parse.c +++ b/src/arg_parse.c @@ -90,4 +90,4 @@ void c_simple_http_free_args(Args *args) { } } -// vim: ts=2 sts=2 sw=2 +// vim: et ts=2 sts=2 sw=2 diff --git a/src/arg_parse.h b/src/arg_parse.h index f9b2d17..6aef990 100644 --- a/src/arg_parse.h +++ b/src/arg_parse.h @@ -39,4 +39,4 @@ void c_simple_http_free_args(Args *args); #endif -// vim: ts=2 sts=2 sw=2 +// vim: et ts=2 sts=2 sw=2 diff --git a/src/big_endian.c b/src/big_endian.c index 637fc29..7056f75 100644 --- a/src/big_endian.c +++ b/src/big_endian.c @@ -33,4 +33,4 @@ unsigned short u16_be_swap(unsigned short value) { } } -// vim: ts=2 sts=2 sw=2 +// vim: et ts=2 sts=2 sw=2 diff --git a/src/big_endian.h b/src/big_endian.h index 0930619..2cb3c3e 100644 --- a/src/big_endian.h +++ b/src/big_endian.h @@ -23,4 +23,4 @@ unsigned short u16_be_swap(unsigned short value); #endif -// vim: ts=2 sts=2 sw=2 +// vim: et ts=2 sts=2 sw=2 diff --git a/src/config.c b/src/config.c index f733bde..eb6578f 100644 --- a/src/config.c +++ b/src/config.c @@ -462,4 +462,4 @@ void c_simple_http_clean_up_parsed_config(C_SIMPLE_HTTP_ParsedConfig *config) { simple_archiver_hash_map_free(&config->paths); } -// vim: ts=2 sts=2 sw=2 +// vim: et ts=2 sts=2 sw=2 diff --git a/src/config.h b/src/config.h index 5794761..a194d28 100644 --- a/src/config.h +++ b/src/config.h @@ -69,4 +69,4 @@ void c_simple_http_clean_up_parsed_config(C_SIMPLE_HTTP_ParsedConfig *config); #endif -// vim: ts=2 sts=2 sw=2 +// vim: et ts=2 sts=2 sw=2 diff --git a/src/globals.c b/src/globals.c index a333d6f..9262d01 100644 --- a/src/globals.c +++ b/src/globals.c @@ -18,4 +18,4 @@ int C_SIMPLE_HTTP_KEEP_RUNNING = 1; -// vim: ts=2 sts=2 sw=2 +// vim: et ts=2 sts=2 sw=2 diff --git a/src/globals.h b/src/globals.h index 0d34ed9..209b32e 100644 --- a/src/globals.h +++ b/src/globals.h @@ -21,4 +21,4 @@ extern int C_SIMPLE_HTTP_KEEP_RUNNING; #endif -// vim: ts=2 sts=2 sw=2 +// vim: et ts=2 sts=2 sw=2 diff --git a/src/http.c b/src/http.c index 8213ffe..701d8fd 100644 --- a/src/http.c +++ b/src/http.c @@ -281,4 +281,4 @@ SDArchiverHashMap *c_simple_http_request_to_headers_map( return hash_map; } -// vim: ts=2 sts=2 sw=2 +// vim: et ts=2 sts=2 sw=2 diff --git a/src/http.h b/src/http.h index bee2cf6..411ff6b 100644 --- a/src/http.h +++ b/src/http.h @@ -65,4 +65,4 @@ SDArchiverHashMap *c_simple_http_request_to_headers_map( #endif -// vim: ts=2 sts=2 sw=2 +// vim: et ts=2 sts=2 sw=2 diff --git a/src/http_template.c b/src/http_template.c index ea242cd..99e86a1 100644 --- a/src/http_template.c +++ b/src/http_template.c @@ -346,4 +346,4 @@ char *c_simple_http_path_to_generated( } } -// vim: ts=2 sts=2 sw=2 +// vim: et ts=2 sts=2 sw=2 diff --git a/src/http_template.h b/src/http_template.h index e7a9da9..ae4586b 100644 --- a/src/http_template.h +++ b/src/http_template.h @@ -33,4 +33,4 @@ char *c_simple_http_path_to_generated( #endif -// vim: ts=2 sts=2 sw=2 +// vim: et ts=2 sts=2 sw=2 diff --git a/src/main.c b/src/main.c index b79de09..c797c61 100644 --- a/src/main.c +++ b/src/main.c @@ -40,10 +40,6 @@ #include "http.h" #include "helpers.h" -typedef struct C_SIMPLE_HTTP_INTERNAL_Header_Check_Ctx { - SDArchiverHashMap *headers_map; -} C_SIMPLE_HTTP_INTERNAL_Header_Check_Ctx; - #define CHECK_ERROR_WRITE(write_expr) \ if (write_expr < 0) { \ close(connection_fd); \ @@ -52,14 +48,14 @@ typedef struct C_SIMPLE_HTTP_INTERNAL_Header_Check_Ctx { } int c_simple_http_headers_check_print(void *data, void *ud) { - C_SIMPLE_HTTP_INTERNAL_Header_Check_Ctx *ctx = ud; + SDArchiverHashMap *headers_map = ud; const char *header_c_str = data; __attribute__((cleanup(simple_archiver_helper_cleanup_c_string))) char *header_c_str_lowercase = c_simple_http_helper_to_lowercase( header_c_str, strlen(header_c_str) + 1); char *matching_line = simple_archiver_hash_map_get( - ctx->headers_map, + headers_map, header_c_str_lowercase, strlen(header_c_str) + 1); if (matching_line) { @@ -169,15 +165,14 @@ int main(int argc, char **argv) { puts(""); #endif { - C_SIMPLE_HTTP_INTERNAL_Header_Check_Ctx ctx; - ctx.headers_map = c_simple_http_request_to_headers_map( + SDArchiverHashMap *headers_map = c_simple_http_request_to_headers_map( (const char*)recv_buf, (size_t)read_ret); simple_archiver_list_get( args.list_of_headers_to_log, c_simple_http_headers_check_print, - &ctx); - simple_archiver_hash_map_free(&ctx.headers_map); + headers_map); + simple_archiver_hash_map_free(&headers_map); } size_t response_size = 0; @@ -249,4 +244,4 @@ int main(int argc, char **argv) { return 0; } -// vim: ts=2 sts=2 sw=2 +// vim: et ts=2 sts=2 sw=2 diff --git a/src/signal_handling.c b/src/signal_handling.c index a76ed2d..dfe4340 100644 --- a/src/signal_handling.c +++ b/src/signal_handling.c @@ -34,4 +34,4 @@ void C_SIMPLE_HTTP_handle_sigint(int signal) { } } -// vim: ts=2 sts=2 sw=2 +// vim: et ts=2 sts=2 sw=2 diff --git a/src/signal_handling.h b/src/signal_handling.h index 543ea6b..3456ebf 100644 --- a/src/signal_handling.h +++ b/src/signal_handling.h @@ -21,4 +21,4 @@ void C_SIMPLE_HTTP_handle_sigint(int signal); #endif -// vim: ts=2 sts=2 sw=2 +// vim: et ts=2 sts=2 sw=2 diff --git a/src/tcp_socket.c b/src/tcp_socket.c index d8f4474..21b77b5 100644 --- a/src/tcp_socket.c +++ b/src/tcp_socket.c @@ -110,4 +110,4 @@ void cleanup_tcp_socket(int *tcp_socket) { } } -// vim: ts=2 sts=2 sw=2 +// vim: et ts=2 sts=2 sw=2 diff --git a/src/tcp_socket.h b/src/tcp_socket.h index 1b54880..4a8680d 100644 --- a/src/tcp_socket.h +++ b/src/tcp_socket.h @@ -25,4 +25,4 @@ void cleanup_tcp_socket(int *tcp_socket); #endif -// vim: ts=2 sts=2 sw=2 +// vim: et ts=2 sts=2 sw=2 diff --git a/src/test.c b/src/test.c index bff1ce0..0456c8f 100644 --- a/src/test.c +++ b/src/test.c @@ -465,4 +465,4 @@ int main(void) { RETURN() } -// vim: ts=2 sts=2 sw=2 +// vim: et ts=2 sts=2 sw=2