]>
Commit | Line | Data |
---|---|---|
52ad194e | 1 | /* SPDX-License-Identifier: LGPL-2.1+ */ |
aa27b158 MP |
2 | #pragma once |
3 | ||
60f067b4 | 4 | #include <microhttpd.h> |
4c89c718 | 5 | #include <stdarg.h> |
663996b3 MS |
6 | |
7 | #include "macro.h" | |
8 | ||
f5e65279 MB |
9 | /* Those defines are added when options are renamed. If the old names |
10 | * are not '#define'd, then they are not deprecated yet and there are | |
11 | * enum elements with the same name. Hence let's check for the *old* name, | |
12 | * and define the new name by the value of the old name. */ | |
2897b343 | 13 | |
81c58355 MB |
14 | /* Renamed in µhttpd 0.9.51 */ |
15 | #ifndef MHD_USE_PIPE_FOR_SHUTDOWN | |
16 | # define MHD_USE_ITC MHD_USE_PIPE_FOR_SHUTDOWN | |
17 | #endif | |
18 | ||
2897b343 MP |
19 | /* Renamed in µhttpd 0.9.52 */ |
20 | #ifndef MHD_USE_EPOLL_LINUX_ONLY | |
21 | # define MHD_USE_EPOLL MHD_USE_EPOLL_LINUX_ONLY | |
22 | #endif | |
23 | ||
f5e65279 MB |
24 | /* Renamed in µhttpd 0.9.52 */ |
25 | #ifndef MHD_USE_SSL | |
26 | # define MHD_USE_TLS MHD_USE_SSL | |
27 | #endif | |
28 | ||
29 | /* Renamed in µhttpd 0.9.53 */ | |
30 | #ifndef MHD_USE_POLL_INTERNALLY | |
31 | # define MHD_USE_POLL_INTERNAL_THREAD MHD_USE_POLL_INTERNALLY | |
32 | #endif | |
33 | ||
81c58355 MB |
34 | /* Both the old and new names are defines, check for the new one. */ |
35 | ||
f5e65279 MB |
36 | /* Compatiblity with libmicrohttpd < 0.9.38 */ |
37 | #ifndef MHD_HTTP_NOT_ACCEPTABLE | |
38 | # define MHD_HTTP_NOT_ACCEPTABLE MHD_HTTP_METHOD_NOT_ACCEPTABLE | |
39 | #endif | |
40 | ||
81c58355 MB |
41 | /* Renamed in µhttpd 0.9.53 */ |
42 | #ifndef MHD_HTTP_PAYLOAD_TOO_LARGE | |
43 | # define MHD_HTTP_PAYLOAD_TOO_LARGE MHD_HTTP_REQUEST_ENTITY_TOO_LARGE | |
4c89c718 MP |
44 | #endif |
45 | ||
46 | #if MHD_VERSION < 0x00094203 | |
2897b343 | 47 | # define MHD_create_response_from_fd_at_offset64 MHD_create_response_from_fd_at_offset |
4c89c718 MP |
48 | #endif |
49 | ||
60f067b4 JS |
50 | void microhttpd_logger(void *arg, const char *fmt, va_list ap) _printf_(2, 0); |
51 | ||
52 | /* respond_oom() must be usable with return, hence this form. */ | |
53 | #define respond_oom(connection) log_oom(), mhd_respond_oom(connection) | |
54 | ||
55 | int mhd_respondf(struct MHD_Connection *connection, | |
8a584da2 | 56 | int error, |
60f067b4 | 57 | unsigned code, |
8a584da2 | 58 | const char *format, ...) _printf_(4,5); |
60f067b4 JS |
59 | |
60 | int mhd_respond(struct MHD_Connection *connection, | |
61 | unsigned code, | |
62 | const char *message); | |
63 | ||
64 | int mhd_respond_oom(struct MHD_Connection *connection); | |
65 | ||
5eef597e | 66 | int check_permissions(struct MHD_Connection *connection, int *code, char **hostname); |
60f067b4 | 67 | |
e3bff60a MP |
68 | /* Set gnutls internal logging function to a callback which uses our |
69 | * own logging framework. | |
70 | * | |
71 | * gnutls categories are additionally filtered by our internal log | |
72 | * level, so it should be set fairly high to capture all potentially | |
73 | * interesting events without overwhelming detail. | |
60f067b4 | 74 | */ |
e3bff60a | 75 | int setup_gnutls_logger(char **categories); |
6e866b33 MB |
76 | |
77 | DEFINE_TRIVIAL_CLEANUP_FUNC(struct MHD_Daemon*, MHD_stop_daemon); |