aboutsummaryrefslogtreecommitdiff
path: root/src/lib/mhd_itc.h
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2019-10-17 16:56:41 +0200
committerChristian Grothoff <christian@grothoff.org>2019-10-17 16:56:41 +0200
commit972103dc288e2a2396e060018e7c3733f29a940d (patch)
treeaeb0b3a182d5168f12752928d3204342c9581e91 /src/lib/mhd_itc.h
parentcbbfd0591fc639ddd21a5850f54f403fb7394174 (diff)
downloadlibmicrohttpd-972103dc288e2a2396e060018e7c3733f29a940d.tar.gz
libmicrohttpd-972103dc288e2a2396e060018e7c3733f29a940d.zip
applying uncrustify to ensure uniform indentation
Diffstat (limited to 'src/lib/mhd_itc.h')
-rw-r--r--src/lib/mhd_itc.h103
1 files changed, 54 insertions, 49 deletions
diff --git a/src/lib/mhd_itc.h b/src/lib/mhd_itc.h
index 01331f13..8e303ef9 100644
--- a/src/lib/mhd_itc.h
+++ b/src/lib/mhd_itc.h
@@ -41,8 +41,9 @@
41# include <stdlib.h> 41# include <stdlib.h>
42/* Simple implementation of MHD_PANIC, to be used outside lib */ 42/* Simple implementation of MHD_PANIC, to be used outside lib */
43# define MHD_PANIC(msg) do { fprintf (stderr, \ 43# define MHD_PANIC(msg) do { fprintf (stderr, \
44 "Abnormal termination at %d line in file %s: %s\n", \ 44 "Abnormal termination at %d line in file %s: %s\n", \
45 (int)__LINE__, __FILE__, msg); abort();} while(0) 45 (int) __LINE__, __FILE__, msg); abort (); \
46} while (0)
46#endif /* ! MHD_PANIC */ 47#endif /* ! MHD_PANIC */
47 48
48#if defined(_MHD_ITC_EVENTFD) 49#if defined(_MHD_ITC_EVENTFD)
@@ -63,12 +64,13 @@
63 * @param itc the itc to initialise 64 * @param itc the itc to initialise
64 * @return non-zero if succeeded, zero otherwise 65 * @return non-zero if succeeded, zero otherwise
65 */ 66 */
66#define MHD_itc_init_(itc) (-1 != ((itc).fd = eventfd (0, EFD_CLOEXEC | EFD_NONBLOCK))) 67#define MHD_itc_init_(itc) (-1 != ((itc).fd = eventfd (0, EFD_CLOEXEC \
68 | EFD_NONBLOCK)))
67 69
68/** 70/**
69 * Get description string of last errno for itc operations. 71 * Get description string of last errno for itc operations.
70 */ 72 */
71#define MHD_itc_last_strerror_() strerror(errno) 73#define MHD_itc_last_strerror_() strerror (errno)
72 74
73/** 75/**
74 * Internal static const helper for MHD_itc_activate_() 76 * Internal static const helper for MHD_itc_activate_()
@@ -82,7 +84,8 @@ static const uint64_t _MHD_itc_wr_data = 1;
82 * @return non-zero if succeeded, zero otherwise 84 * @return non-zero if succeeded, zero otherwise
83 */ 85 */
84#define MHD_itc_activate_(itc, str) \ 86#define MHD_itc_activate_(itc, str) \
85 ((write((itc).fd, (const void*)&_MHD_itc_wr_data, 8) > 0) || (EAGAIN == errno)) 87 ((write ((itc).fd, (const void*) &_MHD_itc_wr_data, 8) > 0) || (EAGAIN == \
88 errno))
86 89
87/** 90/**
88 * Return read FD of @a itc which can be used for poll(), select() etc. 91 * Return read FD of @a itc which can be used for poll(), select() etc.
@@ -104,8 +107,8 @@ static const uint64_t _MHD_itc_wr_data = 1;
104 */ 107 */
105#define MHD_itc_clear_(itc) \ 108#define MHD_itc_clear_(itc) \
106 do { uint64_t __b; int __r; \ 109 do { uint64_t __b; int __r; \
107 __r = read((itc).fd, &__b, sizeof(__b)); \ 110 __r = read ((itc).fd, &__b, sizeof(__b)); \
108 (void)__r; } while(0) 111 (void) __r; } while (0)
109 112
110/** 113/**
111 * Destroy previously initialised ITC. Note that close() 114 * Destroy previously initialised ITC. Note that close()
@@ -155,20 +158,20 @@ static const uint64_t _MHD_itc_wr_data = 1;
155 * @return non-zero if succeeded, zero otherwise 158 * @return non-zero if succeeded, zero otherwise
156 */ 159 */
157#ifdef HAVE_PIPE2_FUNC 160#ifdef HAVE_PIPE2_FUNC
158# define MHD_itc_init_(itc) (!pipe2((itc).fd, O_CLOEXEC | O_NONBLOCK)) 161# define MHD_itc_init_(itc) (! pipe2 ((itc).fd, O_CLOEXEC | O_NONBLOCK))
159#else /* ! HAVE_PIPE2_FUNC */ 162#else /* ! HAVE_PIPE2_FUNC */
160# define MHD_itc_init_(itc) \ 163# define MHD_itc_init_(itc) \
161 ( (!pipe((itc).fd)) ? \ 164 ( (! pipe ((itc).fd)) ? \
162 (MHD_itc_nonblocking_((itc)) ? \ 165 (MHD_itc_nonblocking_ ((itc)) ? \
163 (!0) : \ 166 (! 0) : \
164 (MHD_itc_destroy_((itc)), 0) ) \ 167 (MHD_itc_destroy_ ((itc)), 0) ) \
165 : (0) ) 168 : (0) )
166#endif /* ! HAVE_PIPE2_FUNC */ 169#endif /* ! HAVE_PIPE2_FUNC */
167 170
168/** 171/**
169 * Get description string of last errno for itc operations. 172 * Get description string of last errno for itc operations.
170 */ 173 */
171#define MHD_itc_last_strerror_() strerror(errno) 174#define MHD_itc_last_strerror_() strerror (errno)
172 175
173/** 176/**
174 * Activate signal on @a itc 177 * Activate signal on @a itc
@@ -177,7 +180,7 @@ static const uint64_t _MHD_itc_wr_data = 1;
177 * @return non-zero if succeeded, zero otherwise 180 * @return non-zero if succeeded, zero otherwise
178 */ 181 */
179#define MHD_itc_activate_(itc, str) \ 182#define MHD_itc_activate_(itc, str) \
180 ((write((itc).fd[1], (const void*)(str), 1) > 0) || (EAGAIN == errno)) 183 ((write ((itc).fd[1], (const void*) (str), 1) > 0) || (EAGAIN == errno))
181 184
182 185
183/** 186/**
@@ -200,8 +203,8 @@ static const uint64_t _MHD_itc_wr_data = 1;
200 */ 203 */
201#define MHD_itc_clear_(itc) do \ 204#define MHD_itc_clear_(itc) do \
202 { long __b; \ 205 { long __b; \
203 while(0 < read((itc).fd[0], &__b, sizeof(__b))) \ 206 while (0 < read ((itc).fd[0], &__b, sizeof(__b))) \
204 {} } while(0) 207 {} } while (0)
205 208
206/** 209/**
207 * Destroy previously initialised ITC 210 * Destroy previously initialised ITC
@@ -210,8 +213,8 @@ static const uint64_t _MHD_itc_wr_data = 1;
210 */ 213 */
211#define MHD_itc_destroy_(itc) \ 214#define MHD_itc_destroy_(itc) \
212 ( (0 == close ((itc).fd[0])) ? \ 215 ( (0 == close ((itc).fd[0])) ? \
213 (0 == close ((itc).fd[1])) : \ 216 (0 == close ((itc).fd[1])) : \
214 ((close ((itc).fd[1])), 0) ) 217 ((close ((itc).fd[1])), 0) )
215 218
216/** 219/**
217 * Check whether ITC has valid value. 220 * Check whether ITC has valid value.
@@ -231,14 +234,14 @@ static const uint64_t _MHD_itc_wr_data = 1;
231#define MHD_itc_set_invalid_(itc) ((itc).fd[0] = (itc).fd[1] = -1) 234#define MHD_itc_set_invalid_(itc) ((itc).fd[0] = (itc).fd[1] = -1)
232 235
233#ifndef HAVE_PIPE2_FUNC 236#ifndef HAVE_PIPE2_FUNC
234 /** 237/**
235 * Change itc FD options to be non-blocking. 238 * Change itc FD options to be non-blocking.
236 * 239 *
237 * @param fd the FD to manipulate 240 * @param fd the FD to manipulate
238 * @return non-zero if succeeded, zero otherwise 241 * @return non-zero if succeeded, zero otherwise
239 */ 242 */
240 int 243int
241 MHD_itc_nonblocking_ (struct MHD_itc_ itc); 244MHD_itc_nonblocking_ (struct MHD_itc_ itc);
242#endif /* ! HAVE_PIPE2_FUNC */ 245#endif /* ! HAVE_PIPE2_FUNC */
243 246
244 247
@@ -255,20 +258,20 @@ static const uint64_t _MHD_itc_wr_data = 1;
255 * @return non-zero if succeeded, zero otherwise 258 * @return non-zero if succeeded, zero otherwise
256 */ 259 */
257#ifdef MHD_socket_pair_nblk_ 260#ifdef MHD_socket_pair_nblk_
258# define MHD_itc_init_(itc) MHD_socket_pair_nblk_((itc).sk) 261# define MHD_itc_init_(itc) MHD_socket_pair_nblk_ ((itc).sk)
259#else /* ! MHD_socket_pair_nblk_ */ 262#else /* ! MHD_socket_pair_nblk_ */
260# define MHD_itc_init_(itc) \ 263# define MHD_itc_init_(itc) \
261 (MHD_socket_pair_((itc).sk) ? \ 264 (MHD_socket_pair_ ((itc).sk) ? \
262 (MHD_itc_nonblocking_((itc)) ? \ 265 (MHD_itc_nonblocking_ ((itc)) ? \
263 (!0) : \ 266 (! 0) : \
264 (MHD_itc_destroy_((itc)), 0) ) \ 267 (MHD_itc_destroy_ ((itc)), 0) ) \
265 : (0)) 268 : (0))
266#endif /* ! MHD_socket_pair_nblk_ */ 269#endif /* ! MHD_socket_pair_nblk_ */
267 270
268/** 271/**
269 * Get description string of last error for itc operations. 272 * Get description string of last error for itc operations.
270 */ 273 */
271#define MHD_itc_last_strerror_() MHD_socket_last_strerr_() 274#define MHD_itc_last_strerror_() MHD_socket_last_strerr_ ()
272 275
273/** 276/**
274 * Activate signal on @a itc 277 * Activate signal on @a itc
@@ -277,8 +280,8 @@ static const uint64_t _MHD_itc_wr_data = 1;
277 * @return non-zero if succeeded, zero otherwise 280 * @return non-zero if succeeded, zero otherwise
278 */ 281 */
279#define MHD_itc_activate_(itc, str) \ 282#define MHD_itc_activate_(itc, str) \
280 ((MHD_send_((itc).sk[1], (str), 1) > 0) || \ 283 ((MHD_send_ ((itc).sk[1], (str), 1) > 0) || \
281 (MHD_SCKT_ERR_IS_EAGAIN_(MHD_socket_get_error_()))) 284 (MHD_SCKT_ERR_IS_EAGAIN_ (MHD_socket_get_error_ ())))
282 285
283/** 286/**
284 * Return read FD of @a itc which can be used for poll(), select() etc. 287 * Return read FD of @a itc which can be used for poll(), select() etc.
@@ -300,10 +303,10 @@ static const uint64_t _MHD_itc_wr_data = 1;
300 */ 303 */
301#define MHD_itc_clear_(itc) do \ 304#define MHD_itc_clear_(itc) do \
302 { long __b; \ 305 { long __b; \
303 while(0 < recv((itc).sk[0], \ 306 while (0 < recv ((itc).sk[0], \
304 (char*)&__b, \ 307 (char*) &__b, \
305 sizeof(__b), 0)) \ 308 sizeof(__b), 0)) \
306 {} } while(0) 309 {} } while (0)
307 310
308/** 311/**
309 * Destroy previously initialised ITC 312 * Destroy previously initialised ITC
@@ -311,9 +314,9 @@ static const uint64_t _MHD_itc_wr_data = 1;
311 * @return non-zero if succeeded, zero otherwise 314 * @return non-zero if succeeded, zero otherwise
312 */ 315 */
313#define MHD_itc_destroy_(itc) \ 316#define MHD_itc_destroy_(itc) \
314 ( MHD_socket_close_((itc).sk[0]) ? \ 317 (MHD_socket_close_ ((itc).sk[0]) ? \
315 MHD_socket_close_((itc).sk[1]) : \ 318 MHD_socket_close_ ((itc).sk[1]) : \
316 ((void)MHD_socket_close_((itc).sk[1]), 0) ) 319 ((void) MHD_socket_close_ ((itc).sk[1]), 0) )
317 320
318 321
319/** 322/**
@@ -331,10 +334,12 @@ static const uint64_t _MHD_itc_wr_data = 1;
331 * Set @a itc to invalid value. 334 * Set @a itc to invalid value.
332 * @param itc the itc to set 335 * @param itc the itc to set
333 */ 336 */
334#define MHD_itc_set_invalid_(itc) ((itc).sk[0] = (itc).sk[1] = MHD_INVALID_SOCKET) 337#define MHD_itc_set_invalid_(itc) ((itc).sk[0] = (itc).sk[1] = \
338 MHD_INVALID_SOCKET)
335 339
336#ifndef MHD_socket_pair_nblk_ 340#ifndef MHD_socket_pair_nblk_
337# define MHD_itc_nonblocking_(pip) (MHD_socket_nonblocking_((pip).sk[0]) && MHD_socket_nonblocking_((pip).sk[1])) 341# define MHD_itc_nonblocking_(pip) (MHD_socket_nonblocking_ ((pip).sk[0]) && \
342 MHD_socket_nonblocking_ ((pip).sk[1]))
338#endif /* ! MHD_socket_pair_nblk_ */ 343#endif /* ! MHD_socket_pair_nblk_ */
339 344
340#endif /* _MHD_ITC_SOCKETPAIR */ 345#endif /* _MHD_ITC_SOCKETPAIR */
@@ -345,9 +350,9 @@ static const uint64_t _MHD_itc_wr_data = 1;
345 * @param itc the itc to destroy 350 * @param itc the itc to destroy
346 */ 351 */
347#define MHD_itc_destroy_chk_(itc) do { \ 352#define MHD_itc_destroy_chk_(itc) do { \
348 if (!MHD_itc_destroy_(itc)) \ 353 if (! MHD_itc_destroy_ (itc)) \
349 MHD_PANIC(_("Failed to destroy ITC.\n")); \ 354 MHD_PANIC (_ ("Failed to destroy ITC.\n")); \
350 } while(0) 355} while (0)
351 356
352/** 357/**
353 * Check whether ITC has invalid value. 358 * Check whether ITC has invalid value.
@@ -358,6 +363,6 @@ static const uint64_t _MHD_itc_wr_data = 1;
358 * @return boolean true if @a itc has invalid value, 363 * @return boolean true if @a itc has invalid value,
359 * boolean false otherwise. 364 * boolean false otherwise.
360 */ 365 */
361#define MHD_ITC_IS_INVALID_(itc) (! MHD_ITC_IS_VALID_(itc)) 366#define MHD_ITC_IS_INVALID_(itc) (! MHD_ITC_IS_VALID_ (itc))
362 367
363#endif /* MHD_ITC_H */ 368#endif /* MHD_ITC_H */