diff options
Diffstat (limited to 'src/include/gnunet_common.h')
-rw-r--r-- | src/include/gnunet_common.h | 454 |
1 files changed, 222 insertions, 232 deletions
diff --git a/src/include/gnunet_common.h b/src/include/gnunet_common.h index 6eed12ddb..afaf3a4de 100644 --- a/src/include/gnunet_common.h +++ b/src/include/gnunet_common.h | |||
@@ -16,7 +16,7 @@ | |||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @file include/gnunet_common.h | 22 | * @file include/gnunet_common.h |
@@ -116,7 +116,7 @@ extern "C" { | |||
116 | /** | 116 | /** |
117 | * wrap va_arg for enums | 117 | * wrap va_arg for enums |
118 | */ | 118 | */ |
119 | #define GNUNET_VA_ARG_ENUM(va, X) ((enum X) va_arg (va, int)) | 119 | #define GNUNET_VA_ARG_ENUM(va, X) ((enum X)va_arg(va, int)) |
120 | 120 | ||
121 | 121 | ||
122 | /** | 122 | /** |
@@ -133,36 +133,36 @@ extern "C" { | |||
133 | */ | 133 | */ |
134 | 134 | ||
135 | #if __BYTE_ORDER == __LITTLE_ENDIAN | 135 | #if __BYTE_ORDER == __LITTLE_ENDIAN |
136 | #define GNUNET_htobe16(x) __bswap_16 (x) | 136 | #define GNUNET_htobe16(x) __bswap_16(x) |
137 | #define GNUNET_htole16(x) (x) | 137 | #define GNUNET_htole16(x) (x) |
138 | #define GNUNET_be16toh(x) __bswap_16 (x) | 138 | #define GNUNET_be16toh(x) __bswap_16(x) |
139 | #define GNUNET_le16toh(x) (x) | 139 | #define GNUNET_le16toh(x) (x) |
140 | 140 | ||
141 | #define GNUNET_htobe32(x) __bswap_32 (x) | 141 | #define GNUNET_htobe32(x) __bswap_32(x) |
142 | #define GNUNET_htole32(x) (x) | 142 | #define GNUNET_htole32(x) (x) |
143 | #define GNUNET_be32toh(x) __bswap_32 (x) | 143 | #define GNUNET_be32toh(x) __bswap_32(x) |
144 | #define GNUNET_le32toh(x) (x) | 144 | #define GNUNET_le32toh(x) (x) |
145 | 145 | ||
146 | #define GNUNET_htobe64(x) __bswap_64 (x) | 146 | #define GNUNET_htobe64(x) __bswap_64(x) |
147 | #define GNUNET_htole64(x) (x) | 147 | #define GNUNET_htole64(x) (x) |
148 | #define GNUNET_be64toh(x) __bswap_64 (x) | 148 | #define GNUNET_be64toh(x) __bswap_64(x) |
149 | #define GNUNET_le64toh(x) (x) | 149 | #define GNUNET_le64toh(x) (x) |
150 | #endif | 150 | #endif |
151 | #if __BYTE_ORDER == __BIG_ENDIAN | 151 | #if __BYTE_ORDER == __BIG_ENDIAN |
152 | #define GNUNET_htobe16(x) (x) | 152 | #define GNUNET_htobe16(x) (x) |
153 | #define GNUNET_htole16(x) __bswap_16 (x) | 153 | #define GNUNET_htole16(x) __bswap_16(x) |
154 | #define GNUNET_be16toh(x) (x) | 154 | #define GNUNET_be16toh(x) (x) |
155 | #define GNUNET_le16toh(x) __bswap_16 (x) | 155 | #define GNUNET_le16toh(x) __bswap_16(x) |
156 | 156 | ||
157 | #define GNUNET_htobe32(x) (x) | 157 | #define GNUNET_htobe32(x) (x) |
158 | #define GNUNET_htole32(x) __bswap_32 (x) | 158 | #define GNUNET_htole32(x) __bswap_32(x) |
159 | #define GNUNET_be32toh(x) (x) | 159 | #define GNUNET_be32toh(x) (x) |
160 | #define GNUNET_le32toh(x) __bswap_32 (x) | 160 | #define GNUNET_le32toh(x) __bswap_32(x) |
161 | 161 | ||
162 | #define GNUNET_htobe64(x) (x) | 162 | #define GNUNET_htobe64(x) (x) |
163 | #define GNUNET_htole64(x) __bswap_64 (x) | 163 | #define GNUNET_htole64(x) __bswap_64(x) |
164 | #define GNUNET_be64toh(x) (x) | 164 | #define GNUNET_be64toh(x) (x) |
165 | #define GNUNET_le64toh(x) __bswap_64 (x) | 165 | #define GNUNET_le64toh(x) __bswap_64(x) |
166 | #endif | 166 | #endif |
167 | 167 | ||
168 | 168 | ||
@@ -178,7 +178,7 @@ extern "C" { | |||
178 | * on the stack with a variable-length that might be zero, write | 178 | * on the stack with a variable-length that might be zero, write |
179 | * "int[GNUNET_NZL(n)] x;" instead of "int[n] x". | 179 | * "int[GNUNET_NZL(n)] x;" instead of "int[n] x". |
180 | */ | 180 | */ |
181 | #define GNUNET_NZL(l) GNUNET_MAX (1, l) | 181 | #define GNUNET_NZL(l) GNUNET_MAX(1, l) |
182 | 182 | ||
183 | 183 | ||
184 | /** | 184 | /** |
@@ -201,9 +201,9 @@ extern "C" { | |||
201 | * bug #33594. | 201 | * bug #33594. |
202 | */ | 202 | */ |
203 | #ifdef __BIGGEST_ALIGNMENT__ | 203 | #ifdef __BIGGEST_ALIGNMENT__ |
204 | #define GNUNET_ALIGN __attribute__ ((aligned (__BIGGEST_ALIGNMENT__))) | 204 | #define GNUNET_ALIGN __attribute__ ((aligned(__BIGGEST_ALIGNMENT__))) |
205 | #else | 205 | #else |
206 | #define GNUNET_ALIGN __attribute__ ((aligned (8))) | 206 | #define GNUNET_ALIGN __attribute__ ((aligned(8))) |
207 | #endif | 207 | #endif |
208 | 208 | ||
209 | /** | 209 | /** |
@@ -224,7 +224,7 @@ extern "C" { | |||
224 | * so we *only* use this on W32 (see #670578 from Debian); fortunately, | 224 | * so we *only* use this on W32 (see #670578 from Debian); fortunately, |
225 | * W32 doesn't run on sparc anyway. | 225 | * W32 doesn't run on sparc anyway. |
226 | */ | 226 | */ |
227 | #define GNUNET_NETWORK_STRUCT_BEGIN _Pragma ("pack(push)") _Pragma ("pack(1)") | 227 | #define GNUNET_NETWORK_STRUCT_BEGIN _Pragma("pack(push)") _Pragma ("pack(1)") |
228 | 228 | ||
229 | /** | 229 | /** |
230 | * gcc 4.x-ism to pack structures even on W32 (to be used after structs) | 230 | * gcc 4.x-ism to pack structures even on W32 (to be used after structs) |
@@ -232,7 +232,7 @@ extern "C" { | |||
232 | * so we *only* use this on W32 (see #670578 from Debian); fortunately, | 232 | * so we *only* use this on W32 (see #670578 from Debian); fortunately, |
233 | * W32 doesn't run on sparc anyway. | 233 | * W32 doesn't run on sparc anyway. |
234 | */ | 234 | */ |
235 | #define GNUNET_NETWORK_STRUCT_END _Pragma ("pack(pop)") | 235 | #define GNUNET_NETWORK_STRUCT_END _Pragma("pack(pop)") |
236 | 236 | ||
237 | #else | 237 | #else |
238 | #error gcc 4.x or higher required on W32 systems | 238 | #error gcc 4.x or higher required on W32 systems |
@@ -256,9 +256,8 @@ GNUNET_NETWORK_STRUCT_BEGIN | |||
256 | /** | 256 | /** |
257 | * @brief A 512-bit hashcode. These are the default length for GNUnet, using SHA-512. | 257 | * @brief A 512-bit hashcode. These are the default length for GNUnet, using SHA-512. |
258 | */ | 258 | */ |
259 | struct GNUNET_HashCode | 259 | struct GNUNET_HashCode { |
260 | { | 260 | uint32_t bits[512 / 8 / sizeof(uint32_t)]; /* = 16 */ |
261 | uint32_t bits[512 / 8 / sizeof (uint32_t)]; /* = 16 */ | ||
262 | }; | 261 | }; |
263 | 262 | ||
264 | 263 | ||
@@ -266,17 +265,15 @@ struct GNUNET_HashCode | |||
266 | * @brief A 256-bit hashcode. Used under special conditions, like when space | 265 | * @brief A 256-bit hashcode. Used under special conditions, like when space |
267 | * is critical and security is not impacted by it. | 266 | * is critical and security is not impacted by it. |
268 | */ | 267 | */ |
269 | struct GNUNET_ShortHashCode | 268 | struct GNUNET_ShortHashCode { |
270 | { | 269 | uint32_t bits[256 / 8 / sizeof(uint32_t)]; /* = 8 */ |
271 | uint32_t bits[256 / 8 / sizeof (uint32_t)]; /* = 8 */ | ||
272 | }; | 270 | }; |
273 | 271 | ||
274 | 272 | ||
275 | /** | 273 | /** |
276 | * A UUID, a 128 bit random value. | 274 | * A UUID, a 128 bit random value. |
277 | */ | 275 | */ |
278 | struct GNUNET_Uuid | 276 | struct GNUNET_Uuid { |
279 | { | ||
280 | /** | 277 | /** |
281 | * 128 random bits. | 278 | * 128 random bits. |
282 | */ | 279 | */ |
@@ -287,9 +284,7 @@ struct GNUNET_Uuid | |||
287 | /** | 284 | /** |
288 | * Header for all communications. | 285 | * Header for all communications. |
289 | */ | 286 | */ |
290 | struct GNUNET_MessageHeader | 287 | struct GNUNET_MessageHeader { |
291 | { | ||
292 | |||
293 | /** | 288 | /** |
294 | * The length of the struct (in bytes, including the length field itself), | 289 | * The length of the struct (in bytes, including the length field itself), |
295 | * in big-endian format. | 290 | * in big-endian format. |
@@ -306,8 +301,7 @@ struct GNUNET_MessageHeader | |||
306 | /** | 301 | /** |
307 | * Answer from service to client about last operation. | 302 | * Answer from service to client about last operation. |
308 | */ | 303 | */ |
309 | struct GNUNET_OperationResultMessage | 304 | struct GNUNET_OperationResultMessage { |
310 | { | ||
311 | struct GNUNET_MessageHeader header; | 305 | struct GNUNET_MessageHeader header; |
312 | 306 | ||
313 | uint32_t reserved GNUNET_PACKED; | 307 | uint32_t reserved GNUNET_PACKED; |
@@ -329,9 +323,8 @@ struct GNUNET_OperationResultMessage | |||
329 | /** | 323 | /** |
330 | * Identifier for an asynchronous execution context. | 324 | * Identifier for an asynchronous execution context. |
331 | */ | 325 | */ |
332 | struct GNUNET_AsyncScopeId | 326 | struct GNUNET_AsyncScopeId { |
333 | { | 327 | uint32_t bits[16 / sizeof(uint32_t)]; /* = 16 bytes */ |
334 | uint32_t bits[16 / sizeof (uint32_t)]; /* = 16 bytes */ | ||
335 | }; | 328 | }; |
336 | 329 | ||
337 | GNUNET_NETWORK_STRUCT_END | 330 | GNUNET_NETWORK_STRUCT_END |
@@ -340,8 +333,7 @@ GNUNET_NETWORK_STRUCT_END | |||
340 | /** | 333 | /** |
341 | * Saved async scope identifier or root scope. | 334 | * Saved async scope identifier or root scope. |
342 | */ | 335 | */ |
343 | struct GNUNET_AsyncScopeSave | 336 | struct GNUNET_AsyncScopeSave { |
344 | { | ||
345 | /** | 337 | /** |
346 | * Saved scope. Unused if 'have_scope==GNUNET_NO'. | 338 | * Saved scope. Unused if 'have_scope==GNUNET_NO'. |
347 | */ | 339 | */ |
@@ -398,8 +390,7 @@ typedef void (*GNUNET_ResultCallback) (void *cls, | |||
398 | * @ingroup logging | 390 | * @ingroup logging |
399 | * Types of errors. | 391 | * Types of errors. |
400 | */ | 392 | */ |
401 | enum GNUNET_ErrorType | 393 | enum GNUNET_ErrorType { |
402 | { | ||
403 | GNUNET_ERROR_TYPE_UNSPECIFIED = -1, | 394 | GNUNET_ERROR_TYPE_UNSPECIFIED = -1, |
404 | GNUNET_ERROR_TYPE_NONE = 0, | 395 | GNUNET_ERROR_TYPE_NONE = 0, |
405 | GNUNET_ERROR_TYPE_ERROR = 1, | 396 | GNUNET_ERROR_TYPE_ERROR = 1, |
@@ -439,16 +430,16 @@ typedef void (*GNUNET_Logger) (void *cls, | |||
439 | * @return number of log calls to be ignored | 430 | * @return number of log calls to be ignored |
440 | */ | 431 | */ |
441 | int | 432 | int |
442 | GNUNET_get_log_skip (void); | 433 | GNUNET_get_log_skip(void); |
443 | 434 | ||
444 | 435 | ||
445 | #if ! defined(GNUNET_CULL_LOGGING) | 436 | #if !defined(GNUNET_CULL_LOGGING) |
446 | int | 437 | int |
447 | GNUNET_get_log_call_status (int caller_level, | 438 | GNUNET_get_log_call_status(int caller_level, |
448 | const char *comp, | 439 | const char *comp, |
449 | const char *file, | 440 | const char *file, |
450 | const char *function, | 441 | const char *function, |
451 | int line); | 442 | int line); |
452 | #endif | 443 | #endif |
453 | 444 | ||
454 | 445 | ||
@@ -461,8 +452,8 @@ GNUNET_get_log_call_status (int caller_level, | |||
461 | * @param ... arguments for format string | 452 | * @param ... arguments for format string |
462 | */ | 453 | */ |
463 | void | 454 | void |
464 | GNUNET_log_nocheck (enum GNUNET_ErrorType kind, const char *message, ...) | 455 | GNUNET_log_nocheck(enum GNUNET_ErrorType kind, const char *message, ...) |
465 | __attribute__ ((format (printf, 2, 3))); | 456 | __attribute__ ((format(printf, 2, 3))); |
466 | 457 | ||
467 | /* from glib */ | 458 | /* from glib */ |
468 | #if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__) | 459 | #if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__) |
@@ -470,19 +461,19 @@ GNUNET_log_nocheck (enum GNUNET_ErrorType kind, const char *message, ...) | |||
470 | __extension__({ \ | 461 | __extension__({ \ |
471 | int _gnunet_boolean_var_; \ | 462 | int _gnunet_boolean_var_; \ |
472 | if (expr) \ | 463 | if (expr) \ |
473 | _gnunet_boolean_var_ = 1; \ | 464 | _gnunet_boolean_var_ = 1; \ |
474 | else \ | 465 | else \ |
475 | _gnunet_boolean_var_ = 0; \ | 466 | _gnunet_boolean_var_ = 0; \ |
476 | _gnunet_boolean_var_; \ | 467 | _gnunet_boolean_var_; \ |
477 | }) | 468 | }) |
478 | #define GN_LIKELY(expr) (__builtin_expect (_GNUNET_BOOLEAN_EXPR (expr), 1)) | 469 | #define GN_LIKELY(expr) (__builtin_expect(_GNUNET_BOOLEAN_EXPR(expr), 1)) |
479 | #define GN_UNLIKELY(expr) (__builtin_expect (_GNUNET_BOOLEAN_EXPR (expr), 0)) | 470 | #define GN_UNLIKELY(expr) (__builtin_expect(_GNUNET_BOOLEAN_EXPR(expr), 0)) |
480 | #else | 471 | #else |
481 | #define GN_LIKELY(expr) (expr) | 472 | #define GN_LIKELY(expr) (expr) |
482 | #define GN_UNLIKELY(expr) (expr) | 473 | #define GN_UNLIKELY(expr) (expr) |
483 | #endif | 474 | #endif |
484 | 475 | ||
485 | #if ! defined(GNUNET_LOG_CALL_STATUS) | 476 | #if !defined(GNUNET_LOG_CALL_STATUS) |
486 | #define GNUNET_LOG_CALL_STATUS -1 | 477 | #define GNUNET_LOG_CALL_STATUS -1 |
487 | #endif | 478 | #endif |
488 | 479 | ||
@@ -498,12 +489,12 @@ GNUNET_log_nocheck (enum GNUNET_ErrorType kind, const char *message, ...) | |||
498 | * @param ... arguments for format string | 489 | * @param ... arguments for format string |
499 | */ | 490 | */ |
500 | void | 491 | void |
501 | GNUNET_log_from_nocheck (enum GNUNET_ErrorType kind, | 492 | GNUNET_log_from_nocheck(enum GNUNET_ErrorType kind, |
502 | const char *comp, | 493 | const char *comp, |
503 | const char *message, | 494 | const char *message, |
504 | ...); | 495 | ...); |
505 | 496 | ||
506 | #if ! defined(GNUNET_CULL_LOGGING) | 497 | #if !defined(GNUNET_CULL_LOGGING) |
507 | #define GNUNET_log_from(kind, comp, ...) \ | 498 | #define GNUNET_log_from(kind, comp, ...) \ |
508 | do \ | 499 | do \ |
509 | { \ | 500 | { \ |
@@ -511,21 +502,21 @@ GNUNET_log_from_nocheck (enum GNUNET_ErrorType kind, | |||
511 | if ((GNUNET_EXTRA_LOGGING > 0) || \ | 502 | if ((GNUNET_EXTRA_LOGGING > 0) || \ |
512 | ((GNUNET_ERROR_TYPE_DEBUG & (kind)) == 0)) \ | 503 | ((GNUNET_ERROR_TYPE_DEBUG & (kind)) == 0)) \ |
513 | { \ | 504 | { \ |
514 | if (GN_UNLIKELY (log_call_enabled == -1)) \ | 505 | if (GN_UNLIKELY(log_call_enabled == -1)) \ |
515 | log_call_enabled = \ | 506 | log_call_enabled = \ |
516 | GNUNET_get_log_call_status ((kind) & (~GNUNET_ERROR_TYPE_BULK), \ | 507 | GNUNET_get_log_call_status ((kind) & (~GNUNET_ERROR_TYPE_BULK), \ |
517 | (comp), \ | 508 | (comp), \ |
518 | __FILE__, \ | 509 | __FILE__, \ |
519 | __FUNCTION__, \ | 510 | __FUNCTION__, \ |
520 | __LINE__); \ | 511 | __LINE__); \ |
521 | if (GN_UNLIKELY (GNUNET_get_log_skip () > 0)) \ | 512 | if (GN_UNLIKELY(GNUNET_get_log_skip() > 0)) \ |
522 | { \ | 513 | { \ |
523 | GNUNET_log_skip (-1, GNUNET_NO); \ | 514 | GNUNET_log_skip(-1, GNUNET_NO); \ |
524 | } \ | 515 | } \ |
525 | else \ | 516 | else \ |
526 | { \ | 517 | { \ |
527 | if (GN_UNLIKELY (log_call_enabled)) \ | 518 | if (GN_UNLIKELY(log_call_enabled)) \ |
528 | GNUNET_log_from_nocheck ((kind), comp, __VA_ARGS__); \ | 519 | GNUNET_log_from_nocheck ((kind), comp, __VA_ARGS__); \ |
529 | } \ | 520 | } \ |
530 | } \ | 521 | } \ |
531 | } while (0) | 522 | } while (0) |
@@ -537,21 +528,21 @@ GNUNET_log_from_nocheck (enum GNUNET_ErrorType kind, | |||
537 | if ((GNUNET_EXTRA_LOGGING > 0) || \ | 528 | if ((GNUNET_EXTRA_LOGGING > 0) || \ |
538 | ((GNUNET_ERROR_TYPE_DEBUG & (kind)) == 0)) \ | 529 | ((GNUNET_ERROR_TYPE_DEBUG & (kind)) == 0)) \ |
539 | { \ | 530 | { \ |
540 | if (GN_UNLIKELY (log_call_enabled == -1)) \ | 531 | if (GN_UNLIKELY(log_call_enabled == -1)) \ |
541 | log_call_enabled = \ | 532 | log_call_enabled = \ |
542 | GNUNET_get_log_call_status ((kind) & (~GNUNET_ERROR_TYPE_BULK), \ | 533 | GNUNET_get_log_call_status ((kind) & (~GNUNET_ERROR_TYPE_BULK), \ |
543 | NULL, \ | 534 | NULL, \ |
544 | __FILE__, \ | 535 | __FILE__, \ |
545 | __FUNCTION__, \ | 536 | __FUNCTION__, \ |
546 | __LINE__); \ | 537 | __LINE__); \ |
547 | if (GN_UNLIKELY (GNUNET_get_log_skip () > 0)) \ | 538 | if (GN_UNLIKELY(GNUNET_get_log_skip() > 0)) \ |
548 | { \ | 539 | { \ |
549 | GNUNET_log_skip (-1, GNUNET_NO); \ | 540 | GNUNET_log_skip(-1, GNUNET_NO); \ |
550 | } \ | 541 | } \ |
551 | else \ | 542 | else \ |
552 | { \ | 543 | { \ |
553 | if (GN_UNLIKELY (log_call_enabled)) \ | 544 | if (GN_UNLIKELY(log_call_enabled)) \ |
554 | GNUNET_log_nocheck ((kind), __VA_ARGS__); \ | 545 | GNUNET_log_nocheck ((kind), __VA_ARGS__); \ |
555 | } \ | 546 | } \ |
556 | } \ | 547 | } \ |
557 | } while (0) | 548 | } while (0) |
@@ -570,9 +561,9 @@ GNUNET_log_from_nocheck (enum GNUNET_ErrorType kind, | |||
570 | * @param option name of missing option | 561 | * @param option name of missing option |
571 | */ | 562 | */ |
572 | void | 563 | void |
573 | GNUNET_log_config_missing (enum GNUNET_ErrorType kind, | 564 | GNUNET_log_config_missing(enum GNUNET_ErrorType kind, |
574 | const char *section, | 565 | const char *section, |
575 | const char *option); | 566 | const char *option); |
576 | 567 | ||
577 | 568 | ||
578 | /** | 569 | /** |
@@ -585,10 +576,10 @@ GNUNET_log_config_missing (enum GNUNET_ErrorType kind, | |||
585 | * @param required what is required that is invalid about the option | 576 | * @param required what is required that is invalid about the option |
586 | */ | 577 | */ |
587 | void | 578 | void |
588 | GNUNET_log_config_invalid (enum GNUNET_ErrorType kind, | 579 | GNUNET_log_config_invalid(enum GNUNET_ErrorType kind, |
589 | const char *section, | 580 | const char *section, |
590 | const char *option, | 581 | const char *option, |
591 | const char *required); | 582 | const char *required); |
592 | 583 | ||
593 | 584 | ||
594 | /** | 585 | /** |
@@ -598,7 +589,7 @@ GNUNET_log_config_invalid (enum GNUNET_ErrorType kind, | |||
598 | * first log the location of the failure. | 589 | * first log the location of the failure. |
599 | */ | 590 | */ |
600 | void | 591 | void |
601 | GNUNET_abort_ (void) GNUNET_NORETURN; | 592 | GNUNET_abort_(void) GNUNET_NORETURN; |
602 | 593 | ||
603 | 594 | ||
604 | /** | 595 | /** |
@@ -609,7 +600,7 @@ GNUNET_abort_ (void) GNUNET_NORETURN; | |||
609 | * @param check_reset #GNUNET_YES to assert that the log skip counter is currently zero | 600 | * @param check_reset #GNUNET_YES to assert that the log skip counter is currently zero |
610 | */ | 601 | */ |
611 | void | 602 | void |
612 | GNUNET_log_skip (int n, int check_reset); | 603 | GNUNET_log_skip(int n, int check_reset); |
613 | 604 | ||
614 | 605 | ||
615 | /** | 606 | /** |
@@ -622,7 +613,7 @@ GNUNET_log_skip (int n, int check_reset); | |||
622 | * @return #GNUNET_OK on success, #GNUNET_SYSERR if logfile could not be opened | 613 | * @return #GNUNET_OK on success, #GNUNET_SYSERR if logfile could not be opened |
623 | */ | 614 | */ |
624 | int | 615 | int |
625 | GNUNET_log_setup (const char *comp, const char *loglevel, const char *logfile); | 616 | GNUNET_log_setup(const char *comp, const char *loglevel, const char *logfile); |
626 | 617 | ||
627 | 618 | ||
628 | /** | 619 | /** |
@@ -636,7 +627,7 @@ GNUNET_log_setup (const char *comp, const char *loglevel, const char *logfile); | |||
636 | * @param logger_cls closure for @a logger | 627 | * @param logger_cls closure for @a logger |
637 | */ | 628 | */ |
638 | void | 629 | void |
639 | GNUNET_logger_add (GNUNET_Logger logger, void *logger_cls); | 630 | GNUNET_logger_add(GNUNET_Logger logger, void *logger_cls); |
640 | 631 | ||
641 | 632 | ||
642 | /** | 633 | /** |
@@ -647,7 +638,7 @@ GNUNET_logger_add (GNUNET_Logger logger, void *logger_cls); | |||
647 | * @param logger_cls closure for @a logger | 638 | * @param logger_cls closure for @a logger |
648 | */ | 639 | */ |
649 | void | 640 | void |
650 | GNUNET_logger_remove (GNUNET_Logger logger, void *logger_cls); | 641 | GNUNET_logger_remove(GNUNET_Logger logger, void *logger_cls); |
651 | 642 | ||
652 | 643 | ||
653 | /** | 644 | /** |
@@ -660,7 +651,7 @@ GNUNET_logger_remove (GNUNET_Logger logger, void *logger_cls); | |||
660 | * @return string | 651 | * @return string |
661 | */ | 652 | */ |
662 | const char * | 653 | const char * |
663 | GNUNET_sh2s (const struct GNUNET_ShortHashCode *shc); | 654 | GNUNET_sh2s(const struct GNUNET_ShortHashCode *shc); |
664 | 655 | ||
665 | 656 | ||
666 | /** | 657 | /** |
@@ -673,7 +664,7 @@ GNUNET_sh2s (const struct GNUNET_ShortHashCode *shc); | |||
673 | * @return string | 664 | * @return string |
674 | */ | 665 | */ |
675 | const char * | 666 | const char * |
676 | GNUNET_uuid2s (const struct GNUNET_Uuid *uuid); | 667 | GNUNET_uuid2s(const struct GNUNET_Uuid *uuid); |
677 | 668 | ||
678 | 669 | ||
679 | /** | 670 | /** |
@@ -686,7 +677,7 @@ GNUNET_uuid2s (const struct GNUNET_Uuid *uuid); | |||
686 | * @return string | 677 | * @return string |
687 | */ | 678 | */ |
688 | const char * | 679 | const char * |
689 | GNUNET_h2s (const struct GNUNET_HashCode *hc); | 680 | GNUNET_h2s(const struct GNUNET_HashCode *hc); |
690 | 681 | ||
691 | 682 | ||
692 | /** | 683 | /** |
@@ -701,7 +692,7 @@ GNUNET_h2s (const struct GNUNET_HashCode *hc); | |||
701 | * @return string | 692 | * @return string |
702 | */ | 693 | */ |
703 | const char * | 694 | const char * |
704 | GNUNET_h2s2 (const struct GNUNET_HashCode *hc); | 695 | GNUNET_h2s2(const struct GNUNET_HashCode *hc); |
705 | 696 | ||
706 | 697 | ||
707 | /** | 698 | /** |
@@ -715,7 +706,7 @@ GNUNET_h2s2 (const struct GNUNET_HashCode *hc); | |||
715 | * @return string | 706 | * @return string |
716 | */ | 707 | */ |
717 | const char * | 708 | const char * |
718 | GNUNET_h2s_full (const struct GNUNET_HashCode *hc); | 709 | GNUNET_h2s_full(const struct GNUNET_HashCode *hc); |
719 | 710 | ||
720 | 711 | ||
721 | /** | 712 | /** |
@@ -740,7 +731,7 @@ struct GNUNET_CRYPTO_EcdhePublicKey; | |||
740 | * @return string | 731 | * @return string |
741 | */ | 732 | */ |
742 | const char * | 733 | const char * |
743 | GNUNET_p2s (const struct GNUNET_CRYPTO_EddsaPublicKey *p); | 734 | GNUNET_p2s(const struct GNUNET_CRYPTO_EddsaPublicKey *p); |
744 | 735 | ||
745 | 736 | ||
746 | /** | 737 | /** |
@@ -753,7 +744,7 @@ GNUNET_p2s (const struct GNUNET_CRYPTO_EddsaPublicKey *p); | |||
753 | * @return string | 744 | * @return string |
754 | */ | 745 | */ |
755 | const char * | 746 | const char * |
756 | GNUNET_p2s2 (const struct GNUNET_CRYPTO_EddsaPublicKey *p); | 747 | GNUNET_p2s2(const struct GNUNET_CRYPTO_EddsaPublicKey *p); |
757 | 748 | ||
758 | 749 | ||
759 | /** | 750 | /** |
@@ -766,7 +757,7 @@ GNUNET_p2s2 (const struct GNUNET_CRYPTO_EddsaPublicKey *p); | |||
766 | * @return string | 757 | * @return string |
767 | */ | 758 | */ |
768 | const char * | 759 | const char * |
769 | GNUNET_e2s (const struct GNUNET_CRYPTO_EcdhePublicKey *p); | 760 | GNUNET_e2s(const struct GNUNET_CRYPTO_EcdhePublicKey *p); |
770 | 761 | ||
771 | 762 | ||
772 | /** | 763 | /** |
@@ -779,7 +770,7 @@ GNUNET_e2s (const struct GNUNET_CRYPTO_EcdhePublicKey *p); | |||
779 | * @return string | 770 | * @return string |
780 | */ | 771 | */ |
781 | const char * | 772 | const char * |
782 | GNUNET_e2s2 (const struct GNUNET_CRYPTO_EcdhePublicKey *p); | 773 | GNUNET_e2s2(const struct GNUNET_CRYPTO_EcdhePublicKey *p); |
783 | 774 | ||
784 | 775 | ||
785 | /** | 776 | /** |
@@ -793,7 +784,7 @@ GNUNET_e2s2 (const struct GNUNET_CRYPTO_EcdhePublicKey *p); | |||
793 | * call to #GNUNET_i2s(). | 784 | * call to #GNUNET_i2s(). |
794 | */ | 785 | */ |
795 | const char * | 786 | const char * |
796 | GNUNET_i2s (const struct GNUNET_PeerIdentity *pid); | 787 | GNUNET_i2s(const struct GNUNET_PeerIdentity *pid); |
797 | 788 | ||
798 | 789 | ||
799 | /** | 790 | /** |
@@ -809,7 +800,7 @@ GNUNET_i2s (const struct GNUNET_PeerIdentity *pid); | |||
809 | * call to #GNUNET_i2s(). | 800 | * call to #GNUNET_i2s(). |
810 | */ | 801 | */ |
811 | const char * | 802 | const char * |
812 | GNUNET_i2s2 (const struct GNUNET_PeerIdentity *pid); | 803 | GNUNET_i2s2(const struct GNUNET_PeerIdentity *pid); |
813 | 804 | ||
814 | 805 | ||
815 | /** | 806 | /** |
@@ -823,7 +814,7 @@ GNUNET_i2s2 (const struct GNUNET_PeerIdentity *pid); | |||
823 | * call to #GNUNET_i2s_full(). | 814 | * call to #GNUNET_i2s_full(). |
824 | */ | 815 | */ |
825 | const char * | 816 | const char * |
826 | GNUNET_i2s_full (const struct GNUNET_PeerIdentity *pid); | 817 | GNUNET_i2s_full(const struct GNUNET_PeerIdentity *pid); |
827 | 818 | ||
828 | 819 | ||
829 | /** | 820 | /** |
@@ -838,7 +829,7 @@ GNUNET_i2s_full (const struct GNUNET_PeerIdentity *pid); | |||
838 | * will be overwritten by next call to #GNUNET_a2s(). | 829 | * will be overwritten by next call to #GNUNET_a2s(). |
839 | */ | 830 | */ |
840 | const char * | 831 | const char * |
841 | GNUNET_a2s (const struct sockaddr *addr, socklen_t addrlen); | 832 | GNUNET_a2s(const struct sockaddr *addr, socklen_t addrlen); |
842 | 833 | ||
843 | 834 | ||
844 | /** | 835 | /** |
@@ -849,7 +840,7 @@ GNUNET_a2s (const struct sockaddr *addr, socklen_t addrlen); | |||
849 | * @return string corresponding to the type | 840 | * @return string corresponding to the type |
850 | */ | 841 | */ |
851 | const char * | 842 | const char * |
852 | GNUNET_error_type_to_string (enum GNUNET_ErrorType kind); | 843 | GNUNET_error_type_to_string(enum GNUNET_ErrorType kind); |
853 | 844 | ||
854 | 845 | ||
855 | /** | 846 | /** |
@@ -859,13 +850,13 @@ GNUNET_error_type_to_string (enum GNUNET_ErrorType kind); | |||
859 | #define GNUNET_assert(cond) \ | 850 | #define GNUNET_assert(cond) \ |
860 | do \ | 851 | do \ |
861 | { \ | 852 | { \ |
862 | if (! (cond)) \ | 853 | if (!(cond)) \ |
863 | { \ | 854 | { \ |
864 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, \ | 855 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, \ |
865 | _ ("Assertion failed at %s:%d. Aborting.\n"), \ | 856 | _("Assertion failed at %s:%d. Aborting.\n"), \ |
866 | __FILE__, \ | 857 | __FILE__, \ |
867 | __LINE__); \ | 858 | __LINE__); \ |
868 | GNUNET_abort_ (); \ | 859 | GNUNET_abort_(); \ |
869 | } \ | 860 | } \ |
870 | } while (0) | 861 | } while (0) |
871 | 862 | ||
@@ -877,13 +868,13 @@ GNUNET_error_type_to_string (enum GNUNET_ErrorType kind); | |||
877 | #define GNUNET_assert_at(cond, f, l) \ | 868 | #define GNUNET_assert_at(cond, f, l) \ |
878 | do \ | 869 | do \ |
879 | { \ | 870 | { \ |
880 | if (! (cond)) \ | 871 | if (!(cond)) \ |
881 | { \ | 872 | { \ |
882 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, \ | 873 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, \ |
883 | _ ("Assertion failed at %s:%d. Aborting.\n"), \ | 874 | _("Assertion failed at %s:%d. Aborting.\n"), \ |
884 | f, \ | 875 | f, \ |
885 | l); \ | 876 | l); \ |
886 | GNUNET_abort_ (); \ | 877 | GNUNET_abort_(); \ |
887 | } \ | 878 | } \ |
888 | } while (0) | 879 | } while (0) |
889 | 880 | ||
@@ -898,14 +889,14 @@ GNUNET_error_type_to_string (enum GNUNET_ErrorType kind); | |||
898 | #define GNUNET_assert_from(cond, comp) \ | 889 | #define GNUNET_assert_from(cond, comp) \ |
899 | do \ | 890 | do \ |
900 | { \ | 891 | { \ |
901 | if (! (cond)) \ | 892 | if (!(cond)) \ |
902 | { \ | 893 | { \ |
903 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, \ | 894 | GNUNET_log_from(GNUNET_ERROR_TYPE_ERROR, \ |
904 | comp, \ | 895 | comp, \ |
905 | _ ("Assertion failed at %s:%d. Aborting.\n"), \ | 896 | _("Assertion failed at %s:%d. Aborting.\n"), \ |
906 | __FILE__, \ | 897 | __FILE__, \ |
907 | __LINE__); \ | 898 | __LINE__); \ |
908 | GNUNET_abort_ (); \ | 899 | GNUNET_abort_(); \ |
909 | } \ | 900 | } \ |
910 | } while (0) | 901 | } while (0) |
911 | 902 | ||
@@ -918,12 +909,12 @@ GNUNET_error_type_to_string (enum GNUNET_ErrorType kind); | |||
918 | #define GNUNET_break(cond) \ | 909 | #define GNUNET_break(cond) \ |
919 | do \ | 910 | do \ |
920 | { \ | 911 | { \ |
921 | if (! (cond)) \ | 912 | if (!(cond)) \ |
922 | { \ | 913 | { \ |
923 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, \ | 914 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, \ |
924 | _ ("Assertion failed at %s:%d.\n"), \ | 915 | _("Assertion failed at %s:%d.\n"), \ |
925 | __FILE__, \ | 916 | __FILE__, \ |
926 | __LINE__); \ | 917 | __LINE__); \ |
927 | } \ | 918 | } \ |
928 | } while (0) | 919 | } while (0) |
929 | 920 | ||
@@ -940,12 +931,12 @@ GNUNET_error_type_to_string (enum GNUNET_ErrorType kind); | |||
940 | #define GNUNET_break_op(cond) \ | 931 | #define GNUNET_break_op(cond) \ |
941 | do \ | 932 | do \ |
942 | { \ | 933 | { \ |
943 | if (! (cond)) \ | 934 | if (!(cond)) \ |
944 | { \ | 935 | { \ |
945 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK, \ | 936 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK, \ |
946 | _ ("External protocol violation detected at %s:%d.\n"), \ | 937 | _("External protocol violation detected at %s:%d.\n"), \ |
947 | __FILE__, \ | 938 | __FILE__, \ |
948 | __LINE__); \ | 939 | __LINE__); \ |
949 | } \ | 940 | } \ |
950 | } while (0) | 941 | } while (0) |
951 | 942 | ||
@@ -959,12 +950,12 @@ GNUNET_error_type_to_string (enum GNUNET_ErrorType kind); | |||
959 | #define GNUNET_log_strerror(level, cmd) \ | 950 | #define GNUNET_log_strerror(level, cmd) \ |
960 | do \ | 951 | do \ |
961 | { \ | 952 | { \ |
962 | GNUNET_log (level, \ | 953 | GNUNET_log(level, \ |
963 | _ ("`%s' failed at %s:%d with error: %s\n"), \ | 954 | _("`%s' failed at %s:%d with error: %s\n"), \ |
964 | cmd, \ | 955 | cmd, \ |
965 | __FILE__, \ | 956 | __FILE__, \ |
966 | __LINE__, \ | 957 | __LINE__, \ |
967 | strerror (errno)); \ | 958 | strerror(errno)); \ |
968 | } while (0) | 959 | } while (0) |
969 | 960 | ||
970 | 961 | ||
@@ -977,13 +968,13 @@ GNUNET_error_type_to_string (enum GNUNET_ErrorType kind); | |||
977 | #define GNUNET_log_from_strerror(level, component, cmd) \ | 968 | #define GNUNET_log_from_strerror(level, component, cmd) \ |
978 | do \ | 969 | do \ |
979 | { \ | 970 | { \ |
980 | GNUNET_log_from (level, \ | 971 | GNUNET_log_from(level, \ |
981 | component, \ | 972 | component, \ |
982 | _ ("`%s' failed at %s:%d with error: %s\n"), \ | 973 | _("`%s' failed at %s:%d with error: %s\n"), \ |
983 | cmd, \ | 974 | cmd, \ |
984 | __FILE__, \ | 975 | __FILE__, \ |
985 | __LINE__, \ | 976 | __LINE__, \ |
986 | strerror (errno)); \ | 977 | strerror(errno)); \ |
987 | } while (0) | 978 | } while (0) |
988 | 979 | ||
989 | 980 | ||
@@ -996,13 +987,13 @@ GNUNET_error_type_to_string (enum GNUNET_ErrorType kind); | |||
996 | #define GNUNET_log_strerror_file(level, cmd, filename) \ | 987 | #define GNUNET_log_strerror_file(level, cmd, filename) \ |
997 | do \ | 988 | do \ |
998 | { \ | 989 | { \ |
999 | GNUNET_log (level, \ | 990 | GNUNET_log(level, \ |
1000 | _ ("`%s' failed on file `%s' at %s:%d with error: %s\n"), \ | 991 | _("`%s' failed on file `%s' at %s:%d with error: %s\n"), \ |
1001 | cmd, \ | 992 | cmd, \ |
1002 | filename, \ | 993 | filename, \ |
1003 | __FILE__, \ | 994 | __FILE__, \ |
1004 | __LINE__, \ | 995 | __LINE__, \ |
1005 | strerror (errno)); \ | 996 | strerror(errno)); \ |
1006 | } while (0) | 997 | } while (0) |
1007 | 998 | ||
1008 | 999 | ||
@@ -1015,14 +1006,14 @@ GNUNET_error_type_to_string (enum GNUNET_ErrorType kind); | |||
1015 | #define GNUNET_log_from_strerror_file(level, component, cmd, filename) \ | 1006 | #define GNUNET_log_from_strerror_file(level, component, cmd, filename) \ |
1016 | do \ | 1007 | do \ |
1017 | { \ | 1008 | { \ |
1018 | GNUNET_log_from (level, \ | 1009 | GNUNET_log_from(level, \ |
1019 | component, \ | 1010 | component, \ |
1020 | _ ("`%s' failed on file `%s' at %s:%d with error: %s\n"), \ | 1011 | _("`%s' failed on file `%s' at %s:%d with error: %s\n"), \ |
1021 | cmd, \ | 1012 | cmd, \ |
1022 | filename, \ | 1013 | filename, \ |
1023 | __FILE__, \ | 1014 | __FILE__, \ |
1024 | __LINE__, \ | 1015 | __LINE__, \ |
1025 | strerror (errno)); \ | 1016 | strerror(errno)); \ |
1026 | } while (0) | 1017 | } while (0) |
1027 | 1018 | ||
1028 | /* ************************* endianess conversion ****************** */ | 1019 | /* ************************* endianess conversion ****************** */ |
@@ -1036,7 +1027,7 @@ GNUNET_error_type_to_string (enum GNUNET_ErrorType kind); | |||
1036 | * @return The same value in network byte order. | 1027 | * @return The same value in network byte order. |
1037 | */ | 1028 | */ |
1038 | uint64_t | 1029 | uint64_t |
1039 | GNUNET_htonll (uint64_t n); | 1030 | GNUNET_htonll(uint64_t n); |
1040 | 1031 | ||
1041 | 1032 | ||
1042 | /** | 1033 | /** |
@@ -1048,7 +1039,7 @@ GNUNET_htonll (uint64_t n); | |||
1048 | * @return The same value in host byte order. | 1039 | * @return The same value in host byte order. |
1049 | */ | 1040 | */ |
1050 | uint64_t | 1041 | uint64_t |
1051 | GNUNET_ntohll (uint64_t n); | 1042 | GNUNET_ntohll(uint64_t n); |
1052 | 1043 | ||
1053 | 1044 | ||
1054 | /** | 1045 | /** |
@@ -1060,7 +1051,7 @@ GNUNET_ntohll (uint64_t n); | |||
1060 | * @return The same value in network byte order. | 1051 | * @return The same value in network byte order. |
1061 | */ | 1052 | */ |
1062 | double | 1053 | double |
1063 | GNUNET_hton_double (double d); | 1054 | GNUNET_hton_double(double d); |
1064 | 1055 | ||
1065 | 1056 | ||
1066 | /** | 1057 | /** |
@@ -1072,7 +1063,7 @@ GNUNET_hton_double (double d); | |||
1072 | * @return The same value in host byte order. | 1063 | * @return The same value in host byte order. |
1073 | */ | 1064 | */ |
1074 | double | 1065 | double |
1075 | GNUNET_ntoh_double (double d); | 1066 | GNUNET_ntoh_double(double d); |
1076 | 1067 | ||
1077 | 1068 | ||
1078 | /* ************************* allocation functions ****************** */ | 1069 | /* ************************* allocation functions ****************** */ |
@@ -1091,7 +1082,7 @@ GNUNET_ntoh_double (double d); | |||
1091 | * | 1082 | * |
1092 | * @param type name of the struct or union, i.e. pass 'struct Foo'. | 1083 | * @param type name of the struct or union, i.e. pass 'struct Foo'. |
1093 | */ | 1084 | */ |
1094 | #define GNUNET_new(type) (type *) GNUNET_malloc (sizeof (type)) | 1085 | #define GNUNET_new(type) (type *)GNUNET_malloc(sizeof(type)) |
1095 | 1086 | ||
1096 | 1087 | ||
1097 | /** | 1088 | /** |
@@ -1100,9 +1091,9 @@ GNUNET_ntoh_double (double d); | |||
1100 | */ | 1091 | */ |
1101 | #define GNUNET_memcmp(a, b) \ | 1092 | #define GNUNET_memcmp(a, b) \ |
1102 | ({ \ | 1093 | ({ \ |
1103 | const typeof (*b) *_a = (a); \ | 1094 | const typeof (*b) * _a = (a); \ |
1104 | const typeof (*a) *_b = (b); \ | 1095 | const typeof (*a) * _b = (b); \ |
1105 | memcmp (_a, _b, sizeof (*a)); \ | 1096 | memcmp(_a, _b, sizeof(*a)); \ |
1106 | }) | 1097 | }) |
1107 | 1098 | ||
1108 | 1099 | ||
@@ -1115,7 +1106,7 @@ GNUNET_ntoh_double (double d); | |||
1115 | #define GNUNET_is_zero(a) \ | 1106 | #define GNUNET_is_zero(a) \ |
1116 | ({ \ | 1107 | ({ \ |
1117 | static const typeof (*a) _z; \ | 1108 | static const typeof (*a) _z; \ |
1118 | memcmp ((a), &_z, sizeof (_z)); \ | 1109 | memcmp((a), &_z, sizeof(_z)); \ |
1119 | }) | 1110 | }) |
1120 | 1111 | ||
1121 | 1112 | ||
@@ -1133,7 +1124,7 @@ GNUNET_ntoh_double (double d); | |||
1133 | { \ | 1124 | { \ |
1134 | if (0 != n) \ | 1125 | if (0 != n) \ |
1135 | { \ | 1126 | { \ |
1136 | (void) memcpy (dst, src, n); \ | 1127 | (void)memcpy(dst, src, n); \ |
1137 | } \ | 1128 | } \ |
1138 | } while (0) | 1129 | } while (0) |
1139 | 1130 | ||
@@ -1147,7 +1138,7 @@ GNUNET_ntoh_double (double d); | |||
1147 | * @param n number of elements in the array | 1138 | * @param n number of elements in the array |
1148 | * @param type name of the struct or union, i.e. pass 'struct Foo'. | 1139 | * @param type name of the struct or union, i.e. pass 'struct Foo'. |
1149 | */ | 1140 | */ |
1150 | #define GNUNET_new_array(n, type) (type *) GNUNET_malloc ((n) * sizeof (type)) | 1141 | #define GNUNET_new_array(n, type) (type *)GNUNET_malloc((n) * sizeof(type)) |
1151 | 1142 | ||
1152 | /** | 1143 | /** |
1153 | * @ingroup memory | 1144 | * @ingroup memory |
@@ -1159,7 +1150,7 @@ GNUNET_ntoh_double (double d); | |||
1159 | * @param type name of the struct or union, i.e. pass 'struct Foo'. | 1150 | * @param type name of the struct or union, i.e. pass 'struct Foo'. |
1160 | */ | 1151 | */ |
1161 | #define GNUNET_new_array_2d(n, m, type) \ | 1152 | #define GNUNET_new_array_2d(n, m, type) \ |
1162 | (type **) GNUNET_xnew_array_2d_ (n, m, sizeof (type), __FILE__, __LINE__) | 1153 | (type **)GNUNET_xnew_array_2d_(n, m, sizeof(type), __FILE__, __LINE__) |
1163 | 1154 | ||
1164 | /** | 1155 | /** |
1165 | * @ingroup memory | 1156 | * @ingroup memory |
@@ -1172,7 +1163,7 @@ GNUNET_ntoh_double (double d); | |||
1172 | * @param type name of the struct or union, i.e. pass 'struct Foo'. | 1163 | * @param type name of the struct or union, i.e. pass 'struct Foo'. |
1173 | */ | 1164 | */ |
1174 | #define GNUNET_new_array_3d(n, m, o, type) \ | 1165 | #define GNUNET_new_array_3d(n, m, o, type) \ |
1175 | (type ***) GNUNET_xnew_array_3d_ (n, m, o, sizeof (type), __FILE__, __LINE__) | 1166 | (type ***)GNUNET_xnew_array_3d_(n, m, o, sizeof(type), __FILE__, __LINE__) |
1176 | 1167 | ||
1177 | /** | 1168 | /** |
1178 | * @ingroup memory | 1169 | * @ingroup memory |
@@ -1183,7 +1174,7 @@ GNUNET_ntoh_double (double d); | |||
1183 | * smaller than 40 MB. | 1174 | * smaller than 40 MB. |
1184 | * @return pointer to size bytes of memory, never NULL (!) | 1175 | * @return pointer to size bytes of memory, never NULL (!) |
1185 | */ | 1176 | */ |
1186 | #define GNUNET_malloc(size) GNUNET_xmalloc_ (size, __FILE__, __LINE__) | 1177 | #define GNUNET_malloc(size) GNUNET_xmalloc_(size, __FILE__, __LINE__) |
1187 | 1178 | ||
1188 | /** | 1179 | /** |
1189 | * @ingroup memory | 1180 | * @ingroup memory |
@@ -1193,7 +1184,7 @@ GNUNET_ntoh_double (double d); | |||
1193 | * @param size the number of bytes in buf (and size of the allocation) | 1184 | * @param size the number of bytes in buf (and size of the allocation) |
1194 | * @return pointer to size bytes of memory, never NULL (!) | 1185 | * @return pointer to size bytes of memory, never NULL (!) |
1195 | */ | 1186 | */ |
1196 | #define GNUNET_memdup(buf, size) GNUNET_xmemdup_ (buf, size, __FILE__, __LINE__) | 1187 | #define GNUNET_memdup(buf, size) GNUNET_xmemdup_(buf, size, __FILE__, __LINE__) |
1197 | 1188 | ||
1198 | /** | 1189 | /** |
1199 | * @ingroup memory | 1190 | * @ingroup memory |
@@ -1204,7 +1195,7 @@ GNUNET_ntoh_double (double d); | |||
1204 | * @return pointer to size bytes of memory, NULL if we do not have enough memory | 1195 | * @return pointer to size bytes of memory, NULL if we do not have enough memory |
1205 | */ | 1196 | */ |
1206 | #define GNUNET_malloc_large(size) \ | 1197 | #define GNUNET_malloc_large(size) \ |
1207 | GNUNET_xmalloc_unchecked_ (size, __FILE__, __LINE__) | 1198 | GNUNET_xmalloc_unchecked_(size, __FILE__, __LINE__) |
1208 | 1199 | ||
1209 | /** | 1200 | /** |
1210 | * @ingroup memory | 1201 | * @ingroup memory |
@@ -1216,7 +1207,7 @@ GNUNET_ntoh_double (double d); | |||
1216 | * @return pointer to size bytes of memory | 1207 | * @return pointer to size bytes of memory |
1217 | */ | 1208 | */ |
1218 | #define GNUNET_realloc(ptr, size) \ | 1209 | #define GNUNET_realloc(ptr, size) \ |
1219 | GNUNET_xrealloc_ (ptr, size, __FILE__, __LINE__) | 1210 | GNUNET_xrealloc_(ptr, size, __FILE__, __LINE__) |
1220 | 1211 | ||
1221 | /** | 1212 | /** |
1222 | * @ingroup memory | 1213 | * @ingroup memory |
@@ -1227,7 +1218,7 @@ GNUNET_ntoh_double (double d); | |||
1227 | * @param ptr location where to free the memory. ptr must have | 1218 | * @param ptr location where to free the memory. ptr must have |
1228 | * been returned by #GNUNET_strdup, #GNUNET_strndup, #GNUNET_malloc or #GNUNET_array_grow earlier. | 1219 | * been returned by #GNUNET_strdup, #GNUNET_strndup, #GNUNET_malloc or #GNUNET_array_grow earlier. |
1229 | */ | 1220 | */ |
1230 | #define GNUNET_free(ptr) GNUNET_xfree_ (ptr, __FILE__, __LINE__) | 1221 | #define GNUNET_free(ptr) GNUNET_xfree_(ptr, __FILE__, __LINE__) |
1231 | 1222 | ||
1232 | /** | 1223 | /** |
1233 | * @ingroup memory | 1224 | * @ingroup memory |
@@ -1242,7 +1233,7 @@ GNUNET_ntoh_double (double d); | |||
1242 | void *__x__ = ptr; \ | 1233 | void *__x__ = ptr; \ |
1243 | if (__x__ != NULL) \ | 1234 | if (__x__ != NULL) \ |
1244 | { \ | 1235 | { \ |
1245 | GNUNET_free (__x__); \ | 1236 | GNUNET_free(__x__); \ |
1246 | } \ | 1237 | } \ |
1247 | } while (0) | 1238 | } while (0) |
1248 | 1239 | ||
@@ -1254,7 +1245,7 @@ GNUNET_ntoh_double (double d); | |||
1254 | * @param a pointer to a zero-terminated string | 1245 | * @param a pointer to a zero-terminated string |
1255 | * @return a copy of the string including zero-termination | 1246 | * @return a copy of the string including zero-termination |
1256 | */ | 1247 | */ |
1257 | #define GNUNET_strdup(a) GNUNET_xstrdup_ (a, __FILE__, __LINE__) | 1248 | #define GNUNET_strdup(a) GNUNET_xstrdup_(a, __FILE__, __LINE__) |
1258 | 1249 | ||
1259 | /** | 1250 | /** |
1260 | * @ingroup memory | 1251 | * @ingroup memory |
@@ -1266,7 +1257,7 @@ GNUNET_ntoh_double (double d); | |||
1266 | * @return a partial copy of the string including zero-termination | 1257 | * @return a partial copy of the string including zero-termination |
1267 | */ | 1258 | */ |
1268 | #define GNUNET_strndup(a, length) \ | 1259 | #define GNUNET_strndup(a, length) \ |
1269 | GNUNET_xstrndup_ (a, length, __FILE__, __LINE__) | 1260 | GNUNET_xstrndup_(a, length, __FILE__, __LINE__) |
1270 | 1261 | ||
1271 | /** | 1262 | /** |
1272 | * @ingroup memory | 1263 | * @ingroup memory |
@@ -1304,12 +1295,12 @@ GNUNET_ntoh_double (double d); | |||
1304 | * free the vector (then, arr will be NULL afterwards). | 1295 | * free the vector (then, arr will be NULL afterwards). |
1305 | */ | 1296 | */ |
1306 | #define GNUNET_array_grow(arr, size, tsize) \ | 1297 | #define GNUNET_array_grow(arr, size, tsize) \ |
1307 | GNUNET_xgrow_ ((void **) &(arr), \ | 1298 | GNUNET_xgrow_((void **)&(arr), \ |
1308 | sizeof ((arr)[0]), \ | 1299 | sizeof((arr)[0]), \ |
1309 | &size, \ | 1300 | &size, \ |
1310 | tsize, \ | 1301 | tsize, \ |
1311 | __FILE__, \ | 1302 | __FILE__, \ |
1312 | __LINE__) | 1303 | __LINE__) |
1313 | 1304 | ||
1314 | /** | 1305 | /** |
1315 | * @ingroup memory | 1306 | * @ingroup memory |
@@ -1327,7 +1318,7 @@ GNUNET_ntoh_double (double d); | |||
1327 | #define GNUNET_array_append(arr, size, element) \ | 1318 | #define GNUNET_array_append(arr, size, element) \ |
1328 | do \ | 1319 | do \ |
1329 | { \ | 1320 | { \ |
1330 | GNUNET_array_grow (arr, size, size + 1); \ | 1321 | GNUNET_array_grow(arr, size, size + 1); \ |
1331 | (arr)[size - 1] = element; \ | 1322 | (arr)[size - 1] = element; \ |
1332 | } while (0) | 1323 | } while (0) |
1333 | 1324 | ||
@@ -1342,7 +1333,7 @@ GNUNET_ntoh_double (double d); | |||
1342 | * @return number of bytes written to buf or negative value on error | 1333 | * @return number of bytes written to buf or negative value on error |
1343 | */ | 1334 | */ |
1344 | int | 1335 | int |
1345 | GNUNET_snprintf (char *buf, size_t size, const char *format, ...); | 1336 | GNUNET_snprintf(char *buf, size_t size, const char *format, ...); |
1346 | 1337 | ||
1347 | 1338 | ||
1348 | /** | 1339 | /** |
@@ -1355,7 +1346,7 @@ GNUNET_snprintf (char *buf, size_t size, const char *format, ...); | |||
1355 | * @return number of bytes in "*buf" excluding 0-termination | 1346 | * @return number of bytes in "*buf" excluding 0-termination |
1356 | */ | 1347 | */ |
1357 | int | 1348 | int |
1358 | GNUNET_asprintf (char **buf, const char *format, ...); | 1349 | GNUNET_asprintf(char **buf, const char *format, ...); |
1359 | 1350 | ||
1360 | 1351 | ||
1361 | /* ************** internal implementations, use macros above! ************** */ | 1352 | /* ************** internal implementations, use macros above! ************** */ |
@@ -1372,7 +1363,7 @@ GNUNET_asprintf (char **buf, const char *format, ...); | |||
1372 | * @return allocated memory, never NULL | 1363 | * @return allocated memory, never NULL |
1373 | */ | 1364 | */ |
1374 | void * | 1365 | void * |
1375 | GNUNET_xmalloc_ (size_t size, const char *filename, int linenumber); | 1366 | GNUNET_xmalloc_(size_t size, const char *filename, int linenumber); |
1376 | 1367 | ||
1377 | 1368 | ||
1378 | /** | 1369 | /** |
@@ -1390,11 +1381,11 @@ GNUNET_xmalloc_ (size_t size, const char *filename, int linenumber); | |||
1390 | * @return allocated memory, never NULL | 1381 | * @return allocated memory, never NULL |
1391 | */ | 1382 | */ |
1392 | void ** | 1383 | void ** |
1393 | GNUNET_xnew_array_2d_ (size_t n, | 1384 | GNUNET_xnew_array_2d_(size_t n, |
1394 | size_t m, | 1385 | size_t m, |
1395 | size_t elementSize, | 1386 | size_t elementSize, |
1396 | const char *filename, | 1387 | const char *filename, |
1397 | int linenumber); | 1388 | int linenumber); |
1398 | 1389 | ||
1399 | 1390 | ||
1400 | /** | 1391 | /** |
@@ -1413,12 +1404,12 @@ GNUNET_xnew_array_2d_ (size_t n, | |||
1413 | * @return allocated memory, never NULL | 1404 | * @return allocated memory, never NULL |
1414 | */ | 1405 | */ |
1415 | void *** | 1406 | void *** |
1416 | GNUNET_xnew_array_3d_ (size_t n, | 1407 | GNUNET_xnew_array_3d_(size_t n, |
1417 | size_t m, | 1408 | size_t m, |
1418 | size_t o, | 1409 | size_t o, |
1419 | size_t elementSize, | 1410 | size_t elementSize, |
1420 | const char *filename, | 1411 | const char *filename, |
1421 | int linenumber); | 1412 | int linenumber); |
1422 | 1413 | ||
1423 | 1414 | ||
1424 | /** | 1415 | /** |
@@ -1433,10 +1424,10 @@ GNUNET_xnew_array_3d_ (size_t n, | |||
1433 | * @return allocated memory, never NULL | 1424 | * @return allocated memory, never NULL |
1434 | */ | 1425 | */ |
1435 | void * | 1426 | void * |
1436 | GNUNET_xmemdup_ (const void *buf, | 1427 | GNUNET_xmemdup_(const void *buf, |
1437 | size_t size, | 1428 | size_t size, |
1438 | const char *filename, | 1429 | const char *filename, |
1439 | int linenumber); | 1430 | int linenumber); |
1440 | 1431 | ||
1441 | 1432 | ||
1442 | /** | 1433 | /** |
@@ -1452,7 +1443,7 @@ GNUNET_xmemdup_ (const void *buf, | |||
1452 | * @return pointer to size bytes of memory, NULL if we do not have enough memory | 1443 | * @return pointer to size bytes of memory, NULL if we do not have enough memory |
1453 | */ | 1444 | */ |
1454 | void * | 1445 | void * |
1455 | GNUNET_xmalloc_unchecked_ (size_t size, const char *filename, int linenumber); | 1446 | GNUNET_xmalloc_unchecked_(size_t size, const char *filename, int linenumber); |
1456 | 1447 | ||
1457 | 1448 | ||
1458 | /** | 1449 | /** |
@@ -1460,7 +1451,7 @@ GNUNET_xmalloc_unchecked_ (size_t size, const char *filename, int linenumber); | |||
1460 | * memory is available. | 1451 | * memory is available. |
1461 | */ | 1452 | */ |
1462 | void * | 1453 | void * |
1463 | GNUNET_xrealloc_ (void *ptr, size_t n, const char *filename, int linenumber); | 1454 | GNUNET_xrealloc_(void *ptr, size_t n, const char *filename, int linenumber); |
1464 | 1455 | ||
1465 | 1456 | ||
1466 | /** | 1457 | /** |
@@ -1473,7 +1464,7 @@ GNUNET_xrealloc_ (void *ptr, size_t n, const char *filename, int linenumber); | |||
1473 | * @param linenumber line where this call is being made (for debugging) | 1464 | * @param linenumber line where this call is being made (for debugging) |
1474 | */ | 1465 | */ |
1475 | void | 1466 | void |
1476 | GNUNET_xfree_ (void *ptr, const char *filename, int linenumber); | 1467 | GNUNET_xfree_(void *ptr, const char *filename, int linenumber); |
1477 | 1468 | ||
1478 | 1469 | ||
1479 | /** | 1470 | /** |
@@ -1484,7 +1475,7 @@ GNUNET_xfree_ (void *ptr, const char *filename, int linenumber); | |||
1484 | * @return the duplicated string | 1475 | * @return the duplicated string |
1485 | */ | 1476 | */ |
1486 | char * | 1477 | char * |
1487 | GNUNET_xstrdup_ (const char *str, const char *filename, int linenumber); | 1478 | GNUNET_xstrdup_(const char *str, const char *filename, int linenumber); |
1488 | 1479 | ||
1489 | /** | 1480 | /** |
1490 | * Dup partially a string. Don't call GNUNET_xstrndup_ directly. Use the #GNUNET_strndup macro. | 1481 | * Dup partially a string. Don't call GNUNET_xstrndup_ directly. Use the #GNUNET_strndup macro. |
@@ -1496,10 +1487,10 @@ GNUNET_xstrdup_ (const char *str, const char *filename, int linenumber); | |||
1496 | * @return the duplicated string | 1487 | * @return the duplicated string |
1497 | */ | 1488 | */ |
1498 | char * | 1489 | char * |
1499 | GNUNET_xstrndup_ (const char *str, | 1490 | GNUNET_xstrndup_(const char *str, |
1500 | size_t len, | 1491 | size_t len, |
1501 | const char *filename, | 1492 | const char *filename, |
1502 | int linenumber); | 1493 | int linenumber); |
1503 | 1494 | ||
1504 | /** | 1495 | /** |
1505 | * Grow an array, the new elements are zeroed out. | 1496 | * Grow an array, the new elements are zeroed out. |
@@ -1517,12 +1508,12 @@ GNUNET_xstrndup_ (const char *str, | |||
1517 | * @param linenumber line where this call is being made (for debugging) | 1508 | * @param linenumber line where this call is being made (for debugging) |
1518 | */ | 1509 | */ |
1519 | void | 1510 | void |
1520 | GNUNET_xgrow_ (void **old, | 1511 | GNUNET_xgrow_(void **old, |
1521 | size_t elementSize, | 1512 | size_t elementSize, |
1522 | unsigned int *oldCount, | 1513 | unsigned int *oldCount, |
1523 | unsigned int newCount, | 1514 | unsigned int newCount, |
1524 | const char *filename, | 1515 | const char *filename, |
1525 | int linenumber); | 1516 | int linenumber); |
1526 | 1517 | ||
1527 | 1518 | ||
1528 | /** | 1519 | /** |
@@ -1533,7 +1524,7 @@ GNUNET_xgrow_ (void **old, | |||
1533 | * @return duplicate of the message | 1524 | * @return duplicate of the message |
1534 | */ | 1525 | */ |
1535 | struct GNUNET_MessageHeader * | 1526 | struct GNUNET_MessageHeader * |
1536 | GNUNET_copy_message (const struct GNUNET_MessageHeader *msg); | 1527 | GNUNET_copy_message(const struct GNUNET_MessageHeader *msg); |
1537 | 1528 | ||
1538 | 1529 | ||
1539 | /** | 1530 | /** |
@@ -1543,8 +1534,8 @@ GNUNET_copy_message (const struct GNUNET_MessageHeader *msg); | |||
1543 | * @param old_scope[out] location to save the old scope | 1534 | * @param old_scope[out] location to save the old scope |
1544 | */ | 1535 | */ |
1545 | void | 1536 | void |
1546 | GNUNET_async_scope_enter (const struct GNUNET_AsyncScopeId *aid, | 1537 | GNUNET_async_scope_enter(const struct GNUNET_AsyncScopeId *aid, |
1547 | struct GNUNET_AsyncScopeSave *old_scope); | 1538 | struct GNUNET_AsyncScopeSave *old_scope); |
1548 | 1539 | ||
1549 | 1540 | ||
1550 | /** | 1541 | /** |
@@ -1553,7 +1544,7 @@ GNUNET_async_scope_enter (const struct GNUNET_AsyncScopeId *aid, | |||
1553 | * @param old_scope scope to restore | 1544 | * @param old_scope scope to restore |
1554 | */ | 1545 | */ |
1555 | void | 1546 | void |
1556 | GNUNET_async_scope_restore (struct GNUNET_AsyncScopeSave *old_scope); | 1547 | GNUNET_async_scope_restore(struct GNUNET_AsyncScopeSave *old_scope); |
1557 | 1548 | ||
1558 | 1549 | ||
1559 | /** | 1550 | /** |
@@ -1562,7 +1553,7 @@ GNUNET_async_scope_restore (struct GNUNET_AsyncScopeSave *old_scope); | |||
1562 | * @param[out] scope_ret pointer to where the result is stored | 1553 | * @param[out] scope_ret pointer to where the result is stored |
1563 | */ | 1554 | */ |
1564 | void | 1555 | void |
1565 | GNUNET_async_scope_get (struct GNUNET_AsyncScopeSave *scope_ret); | 1556 | GNUNET_async_scope_get(struct GNUNET_AsyncScopeSave *scope_ret); |
1566 | 1557 | ||
1567 | 1558 | ||
1568 | /** | 1559 | /** |
@@ -1571,7 +1562,7 @@ GNUNET_async_scope_get (struct GNUNET_AsyncScopeSave *scope_ret); | |||
1571 | * @param[out] aid_ret pointer to where the result is stored | 1562 | * @param[out] aid_ret pointer to where the result is stored |
1572 | */ | 1563 | */ |
1573 | void | 1564 | void |
1574 | GNUNET_async_scope_fresh (struct GNUNET_AsyncScopeId *aid_ret); | 1565 | GNUNET_async_scope_fresh(struct GNUNET_AsyncScopeId *aid_ret); |
1575 | 1566 | ||
1576 | 1567 | ||
1577 | #if __STDC_VERSION__ < 199901L | 1568 | #if __STDC_VERSION__ < 199901L |
@@ -1590,8 +1581,7 @@ GNUNET_async_scope_fresh (struct GNUNET_AsyncScopeId *aid_ret); | |||
1590 | * be in gnunet_scheduler_lib.h, but it works if we declare it here. | 1581 | * be in gnunet_scheduler_lib.h, but it works if we declare it here. |
1591 | * Naturally, logically this is part of the scheduler. | 1582 | * Naturally, logically this is part of the scheduler. |
1592 | */ | 1583 | */ |
1593 | enum GNUNET_SCHEDULER_Priority | 1584 | enum GNUNET_SCHEDULER_Priority { |
1594 | { | ||
1595 | /** | 1585 | /** |
1596 | * Run with the same priority as the current job. | 1586 | * Run with the same priority as the current job. |
1597 | */ | 1587 | */ |