]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/journal-remote/microhttpd-util.h
Merge pull request #8676 from keszybz/drop-license-boilerplate
[thirdparty/systemd.git] / src / journal-remote / microhttpd-util.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 #pragma once
3
4 /***
5 This file is part of systemd.
6
7 Copyright 2012 Zbigniew Jędrzejewski-Szmek
8 ***/
9
10 #include <microhttpd.h>
11 #include <stdarg.h>
12
13 #include "macro.h"
14
15 /* Those defines are added when options are renamed. If the old names
16 * are not '#define'd, then they are not deprecated yet and there are
17 * enum elements with the same name. Hence let's check for the *old* name,
18 * and define the new name by the value of the old name. */
19
20 /* Renamed in µhttpd 0.9.51 */
21 #ifndef MHD_USE_PIPE_FOR_SHUTDOWN
22 # define MHD_USE_ITC MHD_USE_PIPE_FOR_SHUTDOWN
23 #endif
24
25 /* Renamed in µhttpd 0.9.52 */
26 #ifndef MHD_USE_EPOLL_LINUX_ONLY
27 # define MHD_USE_EPOLL MHD_USE_EPOLL_LINUX_ONLY
28 #endif
29
30 /* Renamed in µhttpd 0.9.52 */
31 #ifndef MHD_USE_SSL
32 # define MHD_USE_TLS MHD_USE_SSL
33 #endif
34
35 /* Renamed in µhttpd 0.9.53 */
36 #ifndef MHD_USE_POLL_INTERNALLY
37 # define MHD_USE_POLL_INTERNAL_THREAD MHD_USE_POLL_INTERNALLY
38 #endif
39
40 /* Both the old and new names are defines, check for the new one. */
41
42 /* Compatiblity with libmicrohttpd < 0.9.38 */
43 #ifndef MHD_HTTP_NOT_ACCEPTABLE
44 # define MHD_HTTP_NOT_ACCEPTABLE MHD_HTTP_METHOD_NOT_ACCEPTABLE
45 #endif
46
47 /* Renamed in µhttpd 0.9.53 */
48 #ifndef MHD_HTTP_PAYLOAD_TOO_LARGE
49 # define MHD_HTTP_PAYLOAD_TOO_LARGE MHD_HTTP_REQUEST_ENTITY_TOO_LARGE
50 #endif
51
52 #if MHD_VERSION < 0x00094203
53 # define MHD_create_response_from_fd_at_offset64 MHD_create_response_from_fd_at_offset
54 #endif
55
56 void microhttpd_logger(void *arg, const char *fmt, va_list ap) _printf_(2, 0);
57
58 /* respond_oom() must be usable with return, hence this form. */
59 #define respond_oom(connection) log_oom(), mhd_respond_oom(connection)
60
61 int mhd_respondf(struct MHD_Connection *connection,
62 int error,
63 unsigned code,
64 const char *format, ...) _printf_(4,5);
65
66 int mhd_respond(struct MHD_Connection *connection,
67 unsigned code,
68 const char *message);
69
70 int mhd_respond_oom(struct MHD_Connection *connection);
71
72 int check_permissions(struct MHD_Connection *connection, int *code, char **hostname);
73
74 /* Set gnutls internal logging function to a callback which uses our
75 * own logging framework.
76 *
77 * gnutls categories are additionally filtered by our internal log
78 * level, so it should be set fairly high to capture all potentially
79 * interesting events without overwhelming detail.
80 */
81 int setup_gnutls_logger(char **categories);