]> git.vomp.tv Git - jsonserver.git/commitdiff
Fix types, remove -fpermissive
authorChris Tallon <chris@vomp.tv>
Thu, 26 May 2022 14:56:08 +0000 (15:56 +0100)
committerChris Tallon <chris@vomp.tv>
Thu, 26 May 2022 14:56:08 +0000 (15:56 +0100)
Makefile
httpdclient.c
httpdclient.h

index 4750574578c80aff37b7cb01a7bfab16be4c56e1..0ae5522390c74e6d032d406355bc7cd7d51eab89 100644 (file)
--- 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
index f815c521c1c253e72154ae7a6bb328e88642a940..e9800710ceec0e12399f23df78b5e2055ba5cbb1 100644 (file)
@@ -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 = "<html><body>Bad request</body></html>\n";
   const char *page404 = "<html><body>File not found</body></html>\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();
index b44d92890981fe9ee8a347b5c91c735b49952d4b..43ac407ee3a62c812c82b19ba65c8e2fe96bfd37 100644 (file)
@@ -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<spd::logger> 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<std::string, std::string> getVars;
     std::map<std::string, std::string> 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