]> git.ipfire.org Git - thirdparty/FORT-validator.git/commitdiff
Fix libmicrohttpd <= 0.9.70 API usage
authorAlberto Leiva Popper <ydahhrk@gmail.com>
Wed, 6 Aug 2025 17:19:48 +0000 (11:19 -0600)
committerAlberto Leiva Popper <ydahhrk@gmail.com>
Wed, 6 Aug 2025 17:19:48 +0000 (11:19 -0600)
Should now work for libmicrohttpd 0.9.61 to 1.0.2.

For #50.

src/config.c
src/prometheus.c

index 22a25dac3f216a6b46284c409a92e6a431dc7559..36b953abf9ca6a089fb3c86a28d6950d9c09a0da 100644 (file)
@@ -2,6 +2,7 @@
 
 #include <errno.h>
 #include <getopt.h>
+#include <microhttpd.h>
 #include <libxml/xmlreader.h>
 #include <openssl/opensslv.h>
 #include <syslog.h>
@@ -912,10 +913,13 @@ print_config(void)
        struct option_field const *opt;
 
        pr_op_info(PACKAGE_STRING);
-       pr_op_info("  libcrypto: " OPENSSL_VERSION_TEXT);
-       pr_op_info("  jansson:   " JANSSON_VERSION);
-       pr_op_info("  libcurl:   " LIBCURL_VERSION);
-       pr_op_info("  libxml:    " LIBXML_DOTTED_VERSION);
+       pr_op_info("  libcrypto:     " OPENSSL_VERSION_TEXT);
+       pr_op_info("  jansson:       " JANSSON_VERSION);
+       pr_op_info("  libcurl:       " LIBCURL_VERSION);
+       pr_op_info("  libxml:        " LIBXML_DOTTED_VERSION);
+       pr_op_info("  libmicrohttpd: %x.%x.%x-%x",
+           MHD_VERSION >> 24, (MHD_VERSION >> 16) & 0xFF,
+           (MHD_VERSION >> 8) & 0xFF, MHD_VERSION & 0xFF);
 
        pr_op_info("Configuration {");
 
index 663801f7379fa182c69870241cecafdda5f8c502..0ebfed20b305000b65aa2bcccaa36bfe7c531086 100644 (file)
@@ -7,15 +7,21 @@
 #include "log.h"
 #include "stats.h"
 
+#if MHD_VERSION > 0x00097000
+#define MHD_RESULT enum MHD_Result
+#else
+#define MHD_RESULT int
+#endif
+
 #define CONTENT_TYPE "application/openmetrics-text; version=1.0.0; charset=utf-8"
 
 static struct MHD_Daemon *prometheus_daemon;
 
-static enum MHD_Result
+static MHD_RESULT
 respond(struct MHD_Connection *conn, char *msg, unsigned int status)
 {
        struct MHD_Response *response;
-       enum MHD_Result result;
+       MHD_RESULT result;
 
        response = MHD_create_response_from_buffer(strlen(msg), msg,
            MHD_RESPMEM_PERSISTENT);
@@ -25,12 +31,12 @@ respond(struct MHD_Connection *conn, char *msg, unsigned int status)
        return result;
 }
 
-static enum MHD_Result
+static MHD_RESULT
 send_metrics(struct MHD_Connection *conn)
 {
        char *stats;
        struct MHD_Response *res;
-       enum MHD_Result ret;
+       MHD_RESULT ret;
 
        pr_op_debug("Handling Prometheus request...");
 
@@ -51,7 +57,7 @@ send_metrics(struct MHD_Connection *conn)
        return MHD_YES;
 }
 
-static enum MHD_Result
+static MHD_RESULT
 handle_prometheus_req(void *cls, struct MHD_Connection *conn,
                const char *url, const char *method, const char *version,
                const char *upload, size_t *uplen, void **state)