GNU libmicrohttpd
1.0.10
Toggle main menu visibility
Loading...
Searching...
No Matches
mhd_check.h
Go to the documentation of this file.
1
/*
2
This file is part of libmicrohttpd
3
Copyright (C) 2026 Christian Grothoff
4
5
This library is free software; you can redistribute it and/or
6
modify it under the terms of the GNU Lesser General Public
7
License as published by the Free Software Foundation; either
8
version 2.1 of the License, or (at your option) any later version.
9
10
This library is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
Lesser General Public License for more details.
14
15
You should have received a copy of the GNU Lesser General Public
16
License along with this library.
17
If not, see <http://www.gnu.org/licenses/>.
18
*/
19
69
70
#ifndef MHD_CHECK_H
71
#define MHD_CHECK_H 1
72
73
#include "
mhd_options.h
"
74
78
#if defined(__GNUC__) || defined(__clang__)
79
# define MHD_CHECK_FAILED_(expr) (__builtin_expect (! (expr), 0))
80
#else
/* ! __GNUC__ */
81
# define MHD_CHECK_FAILED_(expr) (! (expr))
82
#endif
/* ! __GNUC__ */
83
90
#ifdef HAVE_MESSAGES
91
# define MHD_CHECK_LOG_(daemon,expr_str) \
92
MHD_DLOG (daemon, \
93
_ ("Internal invariant violated at %s:%u: (%s). " \
94
"Failing the connection.\n"), \
95
__FILE__, \
96
(unsigned int) __LINE__, \
97
expr_str)
98
#else
/* ! HAVE_MESSAGES */
99
# define MHD_CHECK_LOG_(daemon,expr_str) ((void) 0)
100
#endif
/* ! HAVE_MESSAGES */
101
102
118
#define MHD_CHECK_(daemon,expr,fail_stmt) \
119
do { \
120
if (MHD_CHECK_FAILED_ (expr)) \
121
{ \
122
MHD_CHECK_LOG_ (daemon, #expr); \
123
fail_stmt; \
124
} \
125
} while (0)
126
127
137
#define MHD_CHECK_RET_(expr,retval) \
138
do { \
139
if (MHD_CHECK_FAILED_ (expr)) \
140
return retval; \
141
} while (0)
142
143
153
#define MHD_CHECK_CONN_CLOSE_RET_(c,expr,retval) \
154
MHD_CHECK_ ((c)->daemon, \
155
expr, \
156
{ \
157
connection_close_error ((c), \
158
NULL); \
159
return retval; \
160
})
161
162
171
#define MHD_CHECK_CONN_CLOSE_RET_VOID_(c,expr) \
172
MHD_CHECK_ ((c)->daemon, \
173
expr, \
174
{ \
175
connection_close_error ((c), \
176
NULL); \
177
return; \
178
})
179
180
192
#define MHD_CHECK_CONN_REPLY_RET_(c,expr,code,msg,retval) \
193
MHD_CHECK_ ((c)->daemon, \
194
expr, \
195
{ \
196
transmit_error_response_static ((c), \
197
(code), \
198
msg); \
199
return retval; \
200
})
201
202
#endif
/* ! MHD_CHECK_H */
mhd_options.h
additional automatic macros for MHD_config.h
src
microhttpd
mhd_check.h
Generated by
1.17.0