From 0351e4037b1d3fe5594eaae2ee29b137c5a9e563 Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Thu, 26 May 2022 15:56:08 +0100 Subject: [PATCH] Fix types, remove -fpermissive --- Makefile | 3 --- httpdclient.c | 26 +++++++++++++------------- httpdclient.h | 28 ++++++++++++++-------------- 3 files changed, 27 insertions(+), 30 deletions(-) diff --git a/Makefile b/Makefile index 4750574..0ae5522 100644 --- a/Makefile +++ b/Makefile @@ -54,9 +54,6 @@ INCLUDES += DEFINES += -DPLUGIN_NAME_I18N='"$(PLUGIN)"' -# JSONSERVER-INSERT -CXXFLAGS += -fpermissive - ### The object files (add further files here): OBJS = $(PLUGIN).o httpdclient.o vdrclient.o diff --git a/httpdclient.c b/httpdclient.c index f815c52..e980071 100644 --- a/httpdclient.c +++ b/httpdclient.c @@ -45,7 +45,7 @@ void HTTPDClient::StopServer() // Now for the libmicrohttpd callbacks -int HTTPDClient::uri_key_value(void *cls, enum MHD_ValueKind kind, const char* key, const char* value) +MHD_Result HTTPDClient::uri_key_value(void *cls, enum MHD_ValueKind kind, const char* key, const char* value) { if (kind != MHD_GET_ARGUMENT_KIND) return MHD_NO; HTTPDClient* httpdclient = (HTTPDClient*)cls; @@ -53,7 +53,7 @@ int HTTPDClient::uri_key_value(void *cls, enum MHD_ValueKind kind, const char* k return MHD_YES; } -int HTTPDClient::iterate_post(void *clientIdentifier, enum MHD_ValueKind kind, const char *key, +MHD_Result HTTPDClient::iterate_post(void *clientIdentifier, enum MHD_ValueKind kind, const char *key, const char *filename, const char* content_type, const char *transfer_encoding, const char *data, uint64_t off, size_t size) { @@ -88,10 +88,10 @@ void HTTPDClient::connection_notify(void *cls, struct MHD_Connection* mhd_connec } } -int HTTPDClient::handle_connection(void* cls, struct MHD_Connection* mhd_connection, +MHD_Result HTTPDClient::handle_connection(void* cls, struct MHD_Connection* mhd_connection, const char* url, const char* method, const char* version, const char* upload_data, - size_t* upload_data_size, void** userData) + long unsigned int* upload_data_size, void** userData) { const MHD_ConnectionInfo* mhdc = MHD_get_connection_info(mhd_connection, MHD_CONNECTION_INFO_SOCKET_CONTEXT); HTTPDClient* httpdclient = (HTTPDClient*)mhdc->socket_context; @@ -112,9 +112,9 @@ HTTPDClient::~HTTPDClient() if (url) free(url); } -int HTTPDClient::handleConnection(const char* turl, const char* method, - const char* version, const char* upload_data, - size_t* upload_data_size, void** userData) +MHD_Result HTTPDClient::handleConnection(const char* turl, const char* method, + const char* version, const char* upload_data, + size_t* upload_data_size, void** userData) { /* logger->debug("handle_connection called"); @@ -232,7 +232,7 @@ void HTTPDClient::addPostField(const char* key, const char* value, int valueLeng */ } -int HTTPDClient::processGET() +MHD_Result HTTPDClient::processGET() { const char* defaultfilename = "index.html"; @@ -264,7 +264,7 @@ int HTTPDClient::processGET() if (fd == -1) return MHD_NO; struct MHD_Response* response = MHD_create_response_from_fd(sbuf.st_size, fd); - int ret = MHD_queue_response(mhd_connection, MHD_HTTP_OK, response); + MHD_Result ret = MHD_queue_response(mhd_connection, MHD_HTTP_OK, response); getVars.clear(); postFields.clear(); @@ -273,7 +273,7 @@ int HTTPDClient::processGET() return ret; } -int HTTPDClient::processPOST() +MHD_Result HTTPDClient::processPOST() { // printf("Process POST:\n"); //printf("REQ: %s\n", getVars["req"].c_str()); @@ -288,7 +288,7 @@ int HTTPDClient::processPOST() struct MHD_Response* response = MHD_create_response_from_buffer(strlen(returnData.c_str()), (void *)returnData.c_str(), MHD_RESPMEM_MUST_COPY); MHD_add_response_header(response, "Content-Type", "application/json"); - int ret = MHD_queue_response(mhd_connection, MHD_HTTP_OK, response); + MHD_Result ret = MHD_queue_response(mhd_connection, MHD_HTTP_OK, response); getVars.clear(); postFields.clear(); @@ -296,7 +296,7 @@ int HTTPDClient::processPOST() return ret; } -int HTTPDClient::sendStockResponse(int code) +MHD_Result HTTPDClient::sendStockResponse(int code) { const char *page400 = "Bad request\n"; const char *page404 = "File not found\n"; @@ -310,7 +310,7 @@ int HTTPDClient::sendStockResponse(int code) else return MHD_NO; struct MHD_Response* response = MHD_create_response_from_buffer(strlen(page), (void *)page, MHD_RESPMEM_PERSISTENT); - int ret = MHD_queue_response(mhd_connection, code, response); + MHD_Result ret = MHD_queue_response(mhd_connection, code, response); getVars.clear(); postFields.clear(); diff --git a/httpdclient.h b/httpdclient.h index b44d928..43ac407 100644 --- a/httpdclient.h +++ b/httpdclient.h @@ -23,18 +23,18 @@ class HTTPDClient static void StopServer(); // static callbacks from libmicrohttpd - static int uri_key_value(void *cls, enum MHD_ValueKind kind, const char* key, const char* value); - static int iterate_post(void *clientIdentifier, enum MHD_ValueKind kind, const char *key, - const char *filename, const char* content_type, - const char *transfer_encoding, const char *data, uint64_t off, size_t size); + static MHD_Result uri_key_value(void *cls, enum MHD_ValueKind kind, const char* key, const char* value); + static MHD_Result iterate_post(void *clientIdentifier, enum MHD_ValueKind kind, const char *key, + const char *filename, const char* content_type, + const char *transfer_encoding, const char *data, uint64_t off, size_t size); static void request_completed(void *cls, struct MHD_Connection *mhd_connection, void **unused, enum MHD_RequestTerminationCode toe); static void connection_notify(void *cls, struct MHD_Connection* mhd_connection, void **socket_context, enum MHD_ConnectionNotificationCode toe); - static int handle_connection(void *cls, struct MHD_Connection *connection, - const char *url, const char *method, - const char *version, const char *upload_data, - size_t *upload_data_size, void **con_cls); + static MHD_Result handle_connection(void *cls, struct MHD_Connection *connection, + const char *url, const char *method, + const char *version, const char *upload_data, + long unsigned int* upload_data_size, void **con_cls); private: static std::shared_ptr logger; @@ -45,11 +45,11 @@ class HTTPDClient HTTPDClient(struct MHD_Connection*, const std::string& configDir); ~HTTPDClient(); - int handleConnection(const char *url, const char *method, - const char *version, const char *upload_data, - size_t *upload_data_size, void **con_cls); - int processGET(); - int processPOST(); + MHD_Result handleConnection(const char *url, const char *method, + const char *version, const char *upload_data, + size_t *upload_data_size, void **con_cls); + MHD_Result processGET(); + MHD_Result processPOST(); std::map getVars; std::map postFields; @@ -62,7 +62,7 @@ class HTTPDClient void addGetVar(const char* key, const char* value); void addPostField(const char* key, const char* value, int valueLength); void requestComplete(); - int sendStockResponse(int code); + MHD_Result sendStockResponse(int code); }; #endif -- 2.39.2