From: Alberto Leiva Popper Date: Wed, 6 Aug 2025 17:19:48 +0000 (-0600) Subject: Fix libmicrohttpd <= 0.9.70 API usage X-Git-Tag: 1.6.7~8 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d7d4db71d86797a9ba1d62d99c39cd93f79dd99a;p=thirdparty%2FFORT-validator.git Fix libmicrohttpd <= 0.9.70 API usage Should now work for libmicrohttpd 0.9.61 to 1.0.2. For #50. --- diff --git a/src/config.c b/src/config.c index 22a25dac..36b953ab 100644 --- a/src/config.c +++ b/src/config.c @@ -2,6 +2,7 @@ #include #include +#include #include #include #include @@ -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 {"); diff --git a/src/prometheus.c b/src/prometheus.c index 663801f7..0ebfed20 100644 --- a/src/prometheus.c +++ b/src/prometheus.c @@ -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)