]>
Commit | Line | Data |
---|---|---|
53e1b683 | 1 | /* SPDX-License-Identifier: LGPL-2.1+ */ |
0ef6f454 LP |
2 | #pragma once |
3 | ||
f12be7e8 | 4 | #include <microhttpd.h> |
71d35b6b | 5 | #include <stdarg.h> |
e64690a8 | 6 | |
b1e2b33c CR |
7 | #include "macro.h" |
8 | ||
e2e8683e YW |
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. */ | |
21b6ff36 | 13 | |
58eb2798 ZJS |
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 | ||
21b6ff36 ZJS |
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 | ||
c831aa75 YW |
24 | /* Renamed in µhttpd 0.9.52 */ |
25 | #ifndef MHD_USE_SSL | |
26 | # define MHD_USE_TLS MHD_USE_SSL | |
27 | #endif | |
28 | ||
315629a8 YW |
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 | ||
58eb2798 ZJS |
34 | /* Both the old and new names are defines, check for the new one. */ |
35 | ||
5238e957 | 36 | /* Compatibility with libmicrohttpd < 0.9.38 */ |
e2e8683e YW |
37 | #ifndef MHD_HTTP_NOT_ACCEPTABLE |
38 | # define MHD_HTTP_NOT_ACCEPTABLE MHD_HTTP_METHOD_NOT_ACCEPTABLE | |
39 | #endif | |
40 | ||
58eb2798 ZJS |
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 | |
ce7229a2 ZJS |
44 | #endif |
45 | ||
b3b0c23a | 46 | #if MHD_VERSION < 0x00094203 |
21b6ff36 | 47 | # define MHD_create_response_from_fd_at_offset64 MHD_create_response_from_fd_at_offset |
b3b0c23a ZJS |
48 | #endif |
49 | ||
d17eabb1 ZJS |
50 | #if MHD_VERSION >= 0x00097002 |
51 | # define mhd_result enum MHD_Result | |
52 | #else | |
53 | # define mhd_result int | |
54 | #endif | |
55 | ||
44b601bc | 56 | void microhttpd_logger(void *arg, const char *fmt, va_list ap) _printf_(2, 0); |
cafc7f91 | 57 | |
f12be7e8 | 58 | /* respond_oom() must be usable with return, hence this form. */ |
e7216d11 ZJS |
59 | #define respond_oom(connection) log_oom(), mhd_respond_oom(connection) |
60 | ||
61 | int mhd_respondf(struct MHD_Connection *connection, | |
1b4cd646 | 62 | int error, |
e7216d11 | 63 | unsigned code, |
1b4cd646 | 64 | const char *format, ...) _printf_(4,5); |
e7216d11 ZJS |
65 | |
66 | int mhd_respond(struct MHD_Connection *connection, | |
67 | unsigned code, | |
68 | const char *message); | |
f12be7e8 | 69 | |
e7216d11 | 70 | int mhd_respond_oom(struct MHD_Connection *connection); |
cafc7f91 | 71 | |
8201af08 | 72 | int check_permissions(struct MHD_Connection *connection, int *code, char **hostname); |
f12be7e8 | 73 | |
d357562c ZJS |
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. | |
cafc7f91 | 80 | */ |
d357562c | 81 | int setup_gnutls_logger(char **categories); |
0d2a1a20 YW |
82 | |
83 | DEFINE_TRIVIAL_CLEANUP_FUNC(struct MHD_Daemon*, MHD_stop_daemon); | |
d101fb24 | 84 | DEFINE_TRIVIAL_CLEANUP_FUNC(struct MHD_Response*, MHD_destroy_response); |