Minor fixes/cleanup
All checks were successful
Run Unit Tests / build-and-run-unit-tests (push) Successful in 5s
All checks were successful
Run Unit Tests / build-and-run-unit-tests (push) Successful in 5s
This commit is contained in:
parent
3bace3286f
commit
952808aefc
18 changed files with 23 additions and 28 deletions
|
@ -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
|
||||||
|
|
|
@ -39,4 +39,4 @@ void c_simple_http_free_args(Args *args);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// vim: ts=2 sts=2 sw=2
|
// vim: et ts=2 sts=2 sw=2
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -23,4 +23,4 @@ unsigned short u16_be_swap(unsigned short value);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// vim: ts=2 sts=2 sw=2
|
// vim: et ts=2 sts=2 sw=2
|
||||||
|
|
|
@ -462,4 +462,4 @@ void c_simple_http_clean_up_parsed_config(C_SIMPLE_HTTP_ParsedConfig *config) {
|
||||||
simple_archiver_hash_map_free(&config->paths);
|
simple_archiver_hash_map_free(&config->paths);
|
||||||
}
|
}
|
||||||
|
|
||||||
// vim: ts=2 sts=2 sw=2
|
// vim: et ts=2 sts=2 sw=2
|
||||||
|
|
|
@ -69,4 +69,4 @@ void c_simple_http_clean_up_parsed_config(C_SIMPLE_HTTP_ParsedConfig *config);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// vim: ts=2 sts=2 sw=2
|
// vim: et ts=2 sts=2 sw=2
|
||||||
|
|
|
@ -18,4 +18,4 @@
|
||||||
|
|
||||||
int C_SIMPLE_HTTP_KEEP_RUNNING = 1;
|
int C_SIMPLE_HTTP_KEEP_RUNNING = 1;
|
||||||
|
|
||||||
// vim: ts=2 sts=2 sw=2
|
// vim: et ts=2 sts=2 sw=2
|
||||||
|
|
|
@ -21,4 +21,4 @@ extern int C_SIMPLE_HTTP_KEEP_RUNNING;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// vim: ts=2 sts=2 sw=2
|
// vim: et ts=2 sts=2 sw=2
|
||||||
|
|
|
@ -281,4 +281,4 @@ SDArchiverHashMap *c_simple_http_request_to_headers_map(
|
||||||
return hash_map;
|
return hash_map;
|
||||||
}
|
}
|
||||||
|
|
||||||
// vim: ts=2 sts=2 sw=2
|
// vim: et ts=2 sts=2 sw=2
|
||||||
|
|
|
@ -65,4 +65,4 @@ SDArchiverHashMap *c_simple_http_request_to_headers_map(
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// vim: ts=2 sts=2 sw=2
|
// vim: et ts=2 sts=2 sw=2
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -33,4 +33,4 @@ char *c_simple_http_path_to_generated(
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// vim: ts=2 sts=2 sw=2
|
// vim: et ts=2 sts=2 sw=2
|
||||||
|
|
17
src/main.c
17
src/main.c
|
@ -40,10 +40,6 @@
|
||||||
#include "http.h"
|
#include "http.h"
|
||||||
#include "helpers.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) \
|
#define CHECK_ERROR_WRITE(write_expr) \
|
||||||
if (write_expr < 0) { \
|
if (write_expr < 0) { \
|
||||||
close(connection_fd); \
|
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) {
|
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;
|
const char *header_c_str = data;
|
||||||
|
|
||||||
__attribute__((cleanup(simple_archiver_helper_cleanup_c_string)))
|
__attribute__((cleanup(simple_archiver_helper_cleanup_c_string)))
|
||||||
char *header_c_str_lowercase = c_simple_http_helper_to_lowercase(
|
char *header_c_str_lowercase = c_simple_http_helper_to_lowercase(
|
||||||
header_c_str, strlen(header_c_str) + 1);
|
header_c_str, strlen(header_c_str) + 1);
|
||||||
char *matching_line = simple_archiver_hash_map_get(
|
char *matching_line = simple_archiver_hash_map_get(
|
||||||
ctx->headers_map,
|
headers_map,
|
||||||
header_c_str_lowercase,
|
header_c_str_lowercase,
|
||||||
strlen(header_c_str) + 1);
|
strlen(header_c_str) + 1);
|
||||||
if (matching_line) {
|
if (matching_line) {
|
||||||
|
@ -169,15 +165,14 @@ int main(int argc, char **argv) {
|
||||||
puts("");
|
puts("");
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
C_SIMPLE_HTTP_INTERNAL_Header_Check_Ctx ctx;
|
SDArchiverHashMap *headers_map = c_simple_http_request_to_headers_map(
|
||||||
ctx.headers_map = c_simple_http_request_to_headers_map(
|
|
||||||
(const char*)recv_buf,
|
(const char*)recv_buf,
|
||||||
(size_t)read_ret);
|
(size_t)read_ret);
|
||||||
simple_archiver_list_get(
|
simple_archiver_list_get(
|
||||||
args.list_of_headers_to_log,
|
args.list_of_headers_to_log,
|
||||||
c_simple_http_headers_check_print,
|
c_simple_http_headers_check_print,
|
||||||
&ctx);
|
headers_map);
|
||||||
simple_archiver_hash_map_free(&ctx.headers_map);
|
simple_archiver_hash_map_free(&headers_map);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t response_size = 0;
|
size_t response_size = 0;
|
||||||
|
@ -249,4 +244,4 @@ int main(int argc, char **argv) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// vim: ts=2 sts=2 sw=2
|
// vim: et ts=2 sts=2 sw=2
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -21,4 +21,4 @@ void C_SIMPLE_HTTP_handle_sigint(int signal);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// vim: ts=2 sts=2 sw=2
|
// vim: et ts=2 sts=2 sw=2
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -25,4 +25,4 @@ void cleanup_tcp_socket(int *tcp_socket);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// vim: ts=2 sts=2 sw=2
|
// vim: et ts=2 sts=2 sw=2
|
||||||
|
|
|
@ -465,4 +465,4 @@ int main(void) {
|
||||||
RETURN()
|
RETURN()
|
||||||
}
|
}
|
||||||
|
|
||||||
// vim: ts=2 sts=2 sw=2
|
// vim: et ts=2 sts=2 sw=2
|
||||||
|
|
Loading…
Reference in a new issue