]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/journal-remote/microhttpd-util.c
journal-remote: implement %m support in mhd_respondf
[thirdparty/systemd.git] / src / journal-remote / microhttpd-util.c
index df068a089caabfa10ece31ced92cfda9a3fbbe7d..67d97e24ff1aa34c19ba1d1071d388c3738ccecf 100644 (file)
@@ -1,5 +1,3 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
 /***
   This file is part of systemd.
 
 #include <gnutls/x509.h>
 #endif
 
+#include "alloc-util.h"
 #include "log.h"
 #include "macro.h"
+#include "microhttpd-util.h"
 #include "string-util.h"
 #include "strv.h"
 #include "util.h"
-#include "microhttpd-util.h"
 
 void microhttpd_logger(void *arg, const char *fmt, va_list ap) {
         char *f;
@@ -61,7 +60,7 @@ static int mhd_respond_internal(struct MHD_Connection *connection,
         if (!response)
                 return MHD_NO;
 
-        log_debug("Queing response %u: %s", code, buffer);
+        log_debug("Queueing response %u: %s", code, buffer);
         MHD_add_response_header(response, "Content-Type", "text/plain");
         r = MHD_queue_response(connection, code, response);
         MHD_destroy_response(response);
@@ -83,6 +82,7 @@ int mhd_respond_oom(struct MHD_Connection *connection) {
 }
 
 int mhd_respondf(struct MHD_Connection *connection,
+                 int error,
                  enum MHD_RequestTerminationCode code,
                  const char *format, ...) {
 
@@ -93,6 +93,9 @@ int mhd_respondf(struct MHD_Connection *connection,
         assert(connection);
         assert(format);
 
+        if (error < 0)
+                error = -error;
+        errno = -error;
         va_start(ap, format);
         r = vasprintf(&m, format, ap);
         va_end(ap);