]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/journal-remote/microhttpd-util.h
Add SPDX license identifiers to source files under the LGPL
[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 systemd is free software; you can redistribute it and/or modify it
10 under the terms of the GNU Lesser General Public License as published by
11 the Free Software Foundation; either version 2.1 of the License, or
12 (at your option) any later version.
13
14 systemd is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Lesser General Public License for more details.
18
19 You should have received a copy of the GNU Lesser General Public License
20 along with systemd; If not, see <http://www.gnu.org/licenses/>.
21 ***/
22
23 #include <microhttpd.h>
24 #include <stdarg.h>
25
26 #include "macro.h"
27
28 /* Those defines are added when options are renamed. If the old names
29 * are not '#define'd, then they are not deprecated yet and there are
30 * enum elements with the same name. Hence let's check for the *old* name,
31 * and define the new name by the value of the old name. */
32
33 /* Renamed in µhttpd 0.9.51 */
34 #ifndef MHD_USE_PIPE_FOR_SHUTDOWN
35 # define MHD_USE_ITC MHD_USE_PIPE_FOR_SHUTDOWN
36 #endif
37
38 /* Renamed in µhttpd 0.9.52 */
39 #ifndef MHD_USE_EPOLL_LINUX_ONLY
40 # define MHD_USE_EPOLL MHD_USE_EPOLL_LINUX_ONLY
41 #endif
42
43 /* Renamed in µhttpd 0.9.52 */
44 #ifndef MHD_USE_SSL
45 # define MHD_USE_TLS MHD_USE_SSL
46 #endif
47
48 /* Renamed in µhttpd 0.9.53 */
49 #ifndef MHD_USE_POLL_INTERNALLY
50 # define MHD_USE_POLL_INTERNAL_THREAD MHD_USE_POLL_INTERNALLY
51 #endif
52
53 /* Both the old and new names are defines, check for the new one. */
54
55 /* Compatiblity with libmicrohttpd < 0.9.38 */
56 #ifndef MHD_HTTP_NOT_ACCEPTABLE
57 # define MHD_HTTP_NOT_ACCEPTABLE MHD_HTTP_METHOD_NOT_ACCEPTABLE
58 #endif
59
60 /* Renamed in µhttpd 0.9.53 */
61 #ifndef MHD_HTTP_PAYLOAD_TOO_LARGE
62 # define MHD_HTTP_PAYLOAD_TOO_LARGE MHD_HTTP_REQUEST_ENTITY_TOO_LARGE
63 #endif
64
65 #if MHD_VERSION < 0x00094203
66 # define MHD_create_response_from_fd_at_offset64 MHD_create_response_from_fd_at_offset
67 #endif
68
69 void microhttpd_logger(void *arg, const char *fmt, va_list ap) _printf_(2, 0);
70
71 /* respond_oom() must be usable with return, hence this form. */
72 #define respond_oom(connection) log_oom(), mhd_respond_oom(connection)
73
74 int mhd_respondf(struct MHD_Connection *connection,
75 int error,
76 unsigned code,
77 const char *format, ...) _printf_(4,5);
78
79 int mhd_respond(struct MHD_Connection *connection,
80 unsigned code,
81 const char *message);
82
83 int mhd_respond_oom(struct MHD_Connection *connection);
84
85 int check_permissions(struct MHD_Connection *connection, int *code, char **hostname);
86
87 /* Set gnutls internal logging function to a callback which uses our
88 * own logging framework.
89 *
90 * gnutls categories are additionally filtered by our internal log
91 * level, so it should be set fairly high to capture all potentially
92 * interesting events without overwhelming detail.
93 */
94 int setup_gnutls_logger(char **categories);