]> git.ipfire.org Git - thirdparty/systemd.git/blame - 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
CommitLineData
53e1b683 1/* SPDX-License-Identifier: LGPL-2.1+ */
0ef6f454
LP
2#pragma once
3
e64690a8
ZJS
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
f12be7e8 23#include <microhttpd.h>
71d35b6b 24#include <stdarg.h>
e64690a8 25
b1e2b33c
CR
26#include "macro.h"
27
e2e8683e
YW
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. */
21b6ff36 32
58eb2798
ZJS
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
21b6ff36
ZJS
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
c831aa75
YW
43/* Renamed in µhttpd 0.9.52 */
44#ifndef MHD_USE_SSL
45# define MHD_USE_TLS MHD_USE_SSL
46#endif
47
315629a8
YW
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
58eb2798
ZJS
53/* Both the old and new names are defines, check for the new one. */
54
e2e8683e
YW
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
58eb2798
ZJS
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
ce7229a2
ZJS
63#endif
64
b3b0c23a 65#if MHD_VERSION < 0x00094203
21b6ff36 66# define MHD_create_response_from_fd_at_offset64 MHD_create_response_from_fd_at_offset
b3b0c23a
ZJS
67#endif
68
44b601bc 69void microhttpd_logger(void *arg, const char *fmt, va_list ap) _printf_(2, 0);
cafc7f91 70
f12be7e8 71/* respond_oom() must be usable with return, hence this form. */
e7216d11
ZJS
72#define respond_oom(connection) log_oom(), mhd_respond_oom(connection)
73
74int mhd_respondf(struct MHD_Connection *connection,
1b4cd646 75 int error,
e7216d11 76 unsigned code,
1b4cd646 77 const char *format, ...) _printf_(4,5);
e7216d11
ZJS
78
79int mhd_respond(struct MHD_Connection *connection,
80 unsigned code,
81 const char *message);
f12be7e8 82
e7216d11 83int mhd_respond_oom(struct MHD_Connection *connection);
cafc7f91 84
8201af08 85int check_permissions(struct MHD_Connection *connection, int *code, char **hostname);
f12be7e8 86
d357562c
ZJS
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.
cafc7f91 93 */
d357562c 94int setup_gnutls_logger(char **categories);