From 4a68008b817301c05c4eec803ec00eb2f54549c4 Mon Sep 17 00:00:00 2001 From: Bram Matthys Date: Wed, 8 Jun 2022 17:58:08 +0200 Subject: [PATCH] Rename some more: * WEB() now has handle_request() and handle_body(), makes more sense. * webserver_handle_body_data() -> webserver_handle_body() * and similar cases --- include/h.h | 4 ++-- include/modules.h | 2 +- include/struct.h | 2 +- src/api-efunctions.c | 4 ++-- src/misc.c | 2 +- src/modules/rpc/rpc.c | 4 ++-- src/modules/webserver.c | 14 +++++++------- src/modules/websocket.c | 2 +- 8 files changed, 17 insertions(+), 17 deletions(-) diff --git a/include/h.h b/include/h.h index 758838b18..110b840f6 100644 --- a/include/h.h +++ b/include/h.h @@ -837,7 +837,7 @@ extern MODVAR int (*make_oper)(Client *client, const char *operblock_name, const extern MODVAR int (*unreal_match_iplist)(Client *client, NameList *l); extern MODVAR void (*webserver_send_response)(Client *client, int status, char *msg); extern MODVAR void (*webserver_close_client)(Client *client); -extern MODVAR int (*webserver_handle_request_body)(Client *client, WebRequest *web, const char *readbuf, int length); +extern MODVAR int (*webserver_handle_body)(Client *client, WebRequest *web, const char *readbuf, int length); extern MODVAR void (*rpc_response)(Client *client, json_t *request, json_t *result); extern MODVAR void (*rpc_error)(Client *client, json_t *request, int error_code, const char *error_message); extern MODVAR void (*rpc_error_fmt)(Client *client, json_t *request, int error_code, FORMAT_STRING(const char *fmt), ...) __attribute__((format(printf,4,5))); @@ -879,7 +879,7 @@ extern void do_unreal_log_remote_deliver_default_handler(LogLevel loglevel, cons extern int make_oper_default_handler(Client *client, const char *operblock_name, const char *operclass, ConfigItem_class *clientclass, long modes, const char *snomask, const char *vhost); extern void webserver_send_response_default_handler(Client *client, int status, char *msg); extern void webserver_close_client_default_handler(Client *client); -extern int webserver_handle_request_body_default_handler(Client *client, WebRequest *web, const char *readbuf, int length); +extern int webserver_handle_body_default_handler(Client *client, WebRequest *web, const char *readbuf, int length); extern void rpc_response_default_handler(Client *client, json_t *request, json_t *result); extern void rpc_error_default_handler(Client *client, json_t *request, int error_code, const char *error_message); extern void rpc_error_fmt_default_handler(Client *client, json_t *request, int error_code, const char *fmt, ...); diff --git a/include/modules.h b/include/modules.h index 4804d745d..58a417095 100644 --- a/include/modules.h +++ b/include/modules.h @@ -2492,7 +2492,7 @@ enum EfunctionType { EFUNC_UNREAL_MATCH_IPLIST, EFUNC_WEBSERVER_SEND_RESPONSE, EFUNC_WEBSERVER_CLOSE_CLIENT, - EFUNC_WEBSERVER_HANDLE_BODY_DATA, + EFUNC_WEBSERVER_HANDLE_BODY, EFUNC_RPC_RESPONSE, EFUNC_RPC_ERROR, EFUNC_RPC_ERROR_FMT, diff --git a/include/struct.h b/include/struct.h index e953ddfd7..cd6dbef7d 100644 --- a/include/struct.h +++ b/include/struct.h @@ -1726,7 +1726,7 @@ struct WebRequest { typedef struct WebServer WebServer; struct WebServer { int (*handle_request)(Client *client, WebRequest *web); - int (*handle_data)(Client *client, WebRequest *web, const char *buf, int length); + int (*handle_body)(Client *client, WebRequest *web, const char *buf, int length); }; struct ConfigItem_listen { diff --git a/src/api-efunctions.c b/src/api-efunctions.c index a88057410..83a6f41d0 100644 --- a/src/api-efunctions.c +++ b/src/api-efunctions.c @@ -138,7 +138,7 @@ int (*make_oper)(Client *client, const char *operblock_name, const char *opercla int (*unreal_match_iplist)(Client *client, NameList *l); void (*webserver_send_response)(Client *client, int status, char *msg); void (*webserver_close_client)(Client *client); -int (*webserver_handle_request_body)(Client *client, WebRequest *web, const char *readbuf, int length); +int (*webserver_handle_body)(Client *client, WebRequest *web, const char *readbuf, int length); void (*rpc_response)(Client *client, json_t *request, json_t *result); void (*rpc_error)(Client *client, json_t *request, int error_code, const char *error_message); void (*rpc_error_fmt)(Client *client, json_t *request, int error_code, const char *fmt, ...); @@ -415,7 +415,7 @@ void efunctions_init(void) efunc_init_function(EFUNC_UNREAL_MATCH_IPLIST, unreal_match_iplist, NULL); efunc_init_function(EFUNC_WEBSERVER_SEND_RESPONSE, webserver_send_response, webserver_send_response_default_handler); efunc_init_function(EFUNC_WEBSERVER_CLOSE_CLIENT, webserver_close_client, webserver_close_client_default_handler); - efunc_init_function(EFUNC_WEBSERVER_HANDLE_BODY_DATA, webserver_handle_request_body, webserver_handle_request_body_default_handler); + efunc_init_function(EFUNC_WEBSERVER_HANDLE_BODY, webserver_handle_body, webserver_handle_body_default_handler); efunc_init_function(EFUNC_RPC_RESPONSE, rpc_response, rpc_response_default_handler); efunc_init_function(EFUNC_RPC_ERROR, rpc_error, rpc_error_default_handler); efunc_init_function(EFUNC_RPC_ERROR_FMT, rpc_error_fmt, rpc_error_fmt_default_handler); diff --git a/src/misc.c b/src/misc.c index f223fe7e3..f44976ae8 100644 --- a/src/misc.c +++ b/src/misc.c @@ -1392,7 +1392,7 @@ void webserver_close_client_default_handler(Client *client) { } -int webserver_handle_request_body_default_handler(Client *client, WebRequest *web, const char *readbuf, int length) +int webserver_handle_body_default_handler(Client *client, WebRequest *web, const char *readbuf, int length) { return 0; } diff --git a/src/modules/rpc/rpc.c b/src/modules/rpc/rpc.c index 3ff262d88..bfa0fdf50 100644 --- a/src/modules/rpc/rpc.c +++ b/src/modules/rpc/rpc.c @@ -147,7 +147,7 @@ int rpc_config_run_ex(ConfigFile *cf, ConfigEntry *ce, int type, void *ptr) l->start_handshake = rpc_client_handshake; l->webserver = safe_alloc(sizeof(WebServer)); l->webserver->handle_request = rpc_handle_webrequest; - l->webserver->handle_data = rpc_handle_webrequest_data; + l->webserver->handle_body = rpc_handle_webrequest_data; l->rpc_options = 1; return 1; @@ -207,7 +207,7 @@ int rpc_handle_webrequest_data(Client *client, WebRequest *web, const char *buf, // NB: content_length // NB: chunked transfers? - if (!webserver_handle_request_body(client, web, buf, len)) + if (!webserver_handle_body(client, web, buf, len)) { webserver_send_response(client, 400, "Error handling POST body data\n"); return 0; diff --git a/src/modules/webserver.c b/src/modules/webserver.c index be88e3dcc..2d22eb107 100644 --- a/src/modules/webserver.c +++ b/src/modules/webserver.c @@ -40,7 +40,7 @@ int webserver_handle_handshake(Client *client, const char *readbuf, int *length) int webserver_handle_request_header(Client *client, const char *readbuf, int *length); void _webserver_send_response(Client *client, int status, char *msg); void _webserver_close_client(Client *client); -int _webserver_handle_request_body(Client *client, WebRequest *web, const char *readbuf, int length); +int _webserver_handle_body(Client *client, WebRequest *web, const char *readbuf, int length); /* Global variables */ ModDataInfo *webserver_md; @@ -50,7 +50,7 @@ MOD_TEST() MARK_AS_OFFICIAL_MODULE(modinfo); EfunctionAddVoid(modinfo->handle, EFUNC_WEBSERVER_SEND_RESPONSE, _webserver_send_response); EfunctionAddVoid(modinfo->handle, EFUNC_WEBSERVER_CLOSE_CLIENT, _webserver_close_client); - EfunctionAdd(modinfo->handle, EFUNC_WEBSERVER_HANDLE_BODY_DATA, _webserver_handle_request_body); + EfunctionAdd(modinfo->handle, EFUNC_WEBSERVER_HANDLE_BODY, _webserver_handle_body); return MOD_SUCCESS; } @@ -160,7 +160,7 @@ int webserver_packet_in(Client *client, const char *readbuf, int *length) return 1; /* "normal" IRC client */ if (WEB(client)->request_header_parsed) - return WEBSERVER(client)->handle_data(client, WEB(client), readbuf, *length); + return WEBSERVER(client)->handle_body(client, WEB(client), readbuf, *length); /* else.. */ return webserver_handle_request_header(client, readbuf, length); @@ -408,7 +408,7 @@ int webserver_handle_request_header(Client *client, const char *readbuf, int *le */ nextframe = find_end_of_request(netbuf2, totalsize, &remaining_bytes); if (nextframe) - return WEBSERVER(client)->handle_data(client, WEB(client), nextframe, remaining_bytes); + return WEBSERVER(client)->handle_body(client, WEB(client), nextframe, remaining_bytes); return 0; } @@ -474,7 +474,7 @@ void _webserver_close_client(Client *client) } } -int webserver_handle_request_body_append_buffer(Client *client, const char *buf, int len) +int webserver_handle_body_append_buffer(Client *client, const char *buf, int len) { /* Guard.. */ if (len <= 0) @@ -490,7 +490,7 @@ int webserver_handle_request_body_append_buffer(Client *client, const char *buf, return 1; } -int _webserver_handle_request_body(Client *client, WebRequest *web, const char *readbuf, int length) +int _webserver_handle_body(Client *client, WebRequest *web, const char *readbuf, int length) { char *buf; long long n; @@ -499,7 +499,7 @@ int _webserver_handle_request_body(Client *client, WebRequest *web, const char * if (1) // (WEB(client)->transfer_encoding == TRANSFER_ENCODING_NONE) { /* Ohh.. so easy! */ - webserver_handle_request_body_append_buffer(client, readbuf, length); + webserver_handle_body_append_buffer(client, readbuf, length); WEB(client)->request_body_complete = 1; // FIXME: WRONG! But for testing ;) return 1; } diff --git a/src/modules/websocket.c b/src/modules/websocket.c index 59d9fdf46..24cb0bb33 100644 --- a/src/modules/websocket.c +++ b/src/modules/websocket.c @@ -231,7 +231,7 @@ int websocket_config_run_ex(ConfigFile *cf, ConfigEntry *ce, int type, void *ptr l = (ConfigItem_listen *)ptr; l->webserver = safe_alloc(sizeof(WebServer)); l->webserver->handle_request = websocket_handle_request; - l->webserver->handle_data = websocket_handle_websocket; + l->webserver->handle_body = websocket_handle_websocket; for (cep = ce->items; cep; cep = cep->next) {