REENABLE_WARNING;
}
-static int mhd_respond_internal(struct MHD_Connection *connection,
- enum MHD_RequestTerminationCode code,
- const char *buffer,
- size_t size,
- enum MHD_ResponseMemoryMode mode) {
+int mhd_respond_internal(
+ struct MHD_Connection *connection,
+ enum MHD_RequestTerminationCode code,
+ const char *buffer,
+ size_t size,
+ enum MHD_ResponseMemoryMode mode) {
+
assert(connection);
_cleanup_(MHD_destroy_responsep) struct MHD_Response *response
return MHD_queue_response(connection, code, response);
}
-int mhd_respond(struct MHD_Connection *connection,
- enum MHD_RequestTerminationCode code,
- const char *message) {
-
- const char *fmt;
-
- fmt = strjoina(message, "\n");
-
- return mhd_respond_internal(connection, code,
- fmt, strlen(message) + 1,
- MHD_RESPMEM_PERSISTENT);
-}
-
int mhd_respond_oom(struct MHD_Connection *connection) {
- return mhd_respond(connection, MHD_HTTP_SERVICE_UNAVAILABLE, "Out of memory.");
+ return mhd_respond(connection, MHD_HTTP_SERVICE_UNAVAILABLE, "Out of memory.");
}
-int mhd_respondf(struct MHD_Connection *connection,
- int error,
- enum MHD_RequestTerminationCode code,
- const char *format, ...) {
+int mhd_respondf_internal(
+ struct MHD_Connection *connection,
+ int error,
+ enum MHD_RequestTerminationCode code,
+ const char *format, ...) {
- const char *fmt;
char *m;
int r;
va_list ap;
if (error < 0)
error = -error;
errno = -error;
- fmt = strjoina(format, "\n");
va_start(ap, format);
- DISABLE_WARNING_FORMAT_NONLITERAL;
- r = vasprintf(&m, fmt, ap);
- REENABLE_WARNING;
+ r = vasprintf(&m, format, ap);
va_end(ap);
if (r < 0)
/* respond_oom() must be usable with return, hence this form. */
#define respond_oom(connection) log_oom(), mhd_respond_oom(connection)
-int mhd_respondf(struct MHD_Connection *connection,
- int error,
- enum MHD_RequestTerminationCode code,
- const char *format, ...) _printf_(4,5);
-
-int mhd_respond(struct MHD_Connection *connection,
+int mhd_respond_internal(
+ struct MHD_Connection *connection,
enum MHD_RequestTerminationCode code,
- const char *message);
+ const char *buffer,
+ size_t size,
+ enum MHD_ResponseMemoryMode mode);
+
+#define mhd_respond(connection, code, message) \
+ mhd_respond_internal( \
+ connection, code, \
+ message "\n", \
+ strlen(message) + 1, \
+ MHD_RESPMEM_PERSISTENT)
int mhd_respond_oom(struct MHD_Connection *connection);
+int mhd_respondf_internal(
+ struct MHD_Connection *connection,
+ int error,
+ enum MHD_RequestTerminationCode code,
+ const char *format, ...) _printf_(4,5);
+
+#define mhd_respondf(connection, error, code, format, ...) \
+ mhd_respondf_internal( \
+ connection, error, code, \
+ format "\n", \
+ ##__VA_ARGS__)
+
int check_permissions(struct MHD_Connection *connection, int *code, char **hostname);
/* Set gnutls internal logging function to a callback which uses our