]> 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 09e6da0031d66c5f66af27c16edf212494875f02..67d97e24ff1aa34c19ba1d1071d388c3738ccecf 100644 (file)
@@ -1,5 +1,3 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
 /***
   This file is part of systemd.
 
@@ -62,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);
@@ -84,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, ...) {
 
@@ -94,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);