diff options
Diffstat (limited to 'src/include/gnunet_common.h')
-rw-r--r-- | src/include/gnunet_common.h | 441 |
1 files changed, 225 insertions, 216 deletions
diff --git a/src/include/gnunet_common.h b/src/include/gnunet_common.h index 555a98eb5..4af43d857 100644 --- a/src/include/gnunet_common.h +++ b/src/include/gnunet_common.h | |||
@@ -113,7 +113,7 @@ extern "C" { | |||
113 | /** | 113 | /** |
114 | * wrap va_arg for enums | 114 | * wrap va_arg for enums |
115 | */ | 115 | */ |
116 | #define GNUNET_VA_ARG_ENUM(va, X) ((enum X)va_arg(va, int)) | 116 | #define GNUNET_VA_ARG_ENUM(va, X) ((enum X) va_arg (va, int)) |
117 | 117 | ||
118 | 118 | ||
119 | /** | 119 | /** |
@@ -130,36 +130,36 @@ extern "C" { | |||
130 | */ | 130 | */ |
131 | 131 | ||
132 | #if __BYTE_ORDER == __LITTLE_ENDIAN | 132 | #if __BYTE_ORDER == __LITTLE_ENDIAN |
133 | #define GNUNET_htobe16(x) __bswap_16(x) | 133 | #define GNUNET_htobe16(x) __bswap_16 (x) |
134 | #define GNUNET_htole16(x) (x) | 134 | #define GNUNET_htole16(x) (x) |
135 | #define GNUNET_be16toh(x) __bswap_16(x) | 135 | #define GNUNET_be16toh(x) __bswap_16 (x) |
136 | #define GNUNET_le16toh(x) (x) | 136 | #define GNUNET_le16toh(x) (x) |
137 | 137 | ||
138 | #define GNUNET_htobe32(x) __bswap_32(x) | 138 | #define GNUNET_htobe32(x) __bswap_32 (x) |
139 | #define GNUNET_htole32(x) (x) | 139 | #define GNUNET_htole32(x) (x) |
140 | #define GNUNET_be32toh(x) __bswap_32(x) | 140 | #define GNUNET_be32toh(x) __bswap_32 (x) |
141 | #define GNUNET_le32toh(x) (x) | 141 | #define GNUNET_le32toh(x) (x) |
142 | 142 | ||
143 | #define GNUNET_htobe64(x) __bswap_64(x) | 143 | #define GNUNET_htobe64(x) __bswap_64 (x) |
144 | #define GNUNET_htole64(x) (x) | 144 | #define GNUNET_htole64(x) (x) |
145 | #define GNUNET_be64toh(x) __bswap_64(x) | 145 | #define GNUNET_be64toh(x) __bswap_64 (x) |
146 | #define GNUNET_le64toh(x) (x) | 146 | #define GNUNET_le64toh(x) (x) |
147 | #endif | 147 | #endif |
148 | #if __BYTE_ORDER == __BIG_ENDIAN | 148 | #if __BYTE_ORDER == __BIG_ENDIAN |
149 | #define GNUNET_htobe16(x) (x) | 149 | #define GNUNET_htobe16(x) (x) |
150 | #define GNUNET_htole16(x) __bswap_16(x) | 150 | #define GNUNET_htole16(x) __bswap_16 (x) |
151 | #define GNUNET_be16toh(x) (x) | 151 | #define GNUNET_be16toh(x) (x) |
152 | #define GNUNET_le16toh(x) __bswap_16(x) | 152 | #define GNUNET_le16toh(x) __bswap_16 (x) |
153 | 153 | ||
154 | #define GNUNET_htobe32(x) (x) | 154 | #define GNUNET_htobe32(x) (x) |
155 | #define GNUNET_htole32(x) __bswap_32(x) | 155 | #define GNUNET_htole32(x) __bswap_32 (x) |
156 | #define GNUNET_be32toh(x) (x) | 156 | #define GNUNET_be32toh(x) (x) |
157 | #define GNUNET_le32toh(x) __bswap_32(x) | 157 | #define GNUNET_le32toh(x) __bswap_32 (x) |
158 | 158 | ||
159 | #define GNUNET_htobe64(x) (x) | 159 | #define GNUNET_htobe64(x) (x) |
160 | #define GNUNET_htole64(x) __bswap_64(x) | 160 | #define GNUNET_htole64(x) __bswap_64 (x) |
161 | #define GNUNET_be64toh(x) (x) | 161 | #define GNUNET_be64toh(x) (x) |
162 | #define GNUNET_le64toh(x) __bswap_64(x) | 162 | #define GNUNET_le64toh(x) __bswap_64 (x) |
163 | #endif | 163 | #endif |
164 | 164 | ||
165 | 165 | ||
@@ -175,7 +175,7 @@ extern "C" { | |||
175 | * on the stack with a variable-length that might be zero, write | 175 | * on the stack with a variable-length that might be zero, write |
176 | * "int[GNUNET_NZL(n)] x;" instead of "int[n] x". | 176 | * "int[GNUNET_NZL(n)] x;" instead of "int[n] x". |
177 | */ | 177 | */ |
178 | #define GNUNET_NZL(l) GNUNET_MAX(1, l) | 178 | #define GNUNET_NZL(l) GNUNET_MAX (1, l) |
179 | 179 | ||
180 | 180 | ||
181 | /** | 181 | /** |
@@ -194,9 +194,9 @@ extern "C" { | |||
194 | * bug #33594. | 194 | * bug #33594. |
195 | */ | 195 | */ |
196 | #ifdef __BIGGEST_ALIGNMENT__ | 196 | #ifdef __BIGGEST_ALIGNMENT__ |
197 | #define GNUNET_ALIGN __attribute__ ((aligned(__BIGGEST_ALIGNMENT__))) | 197 | #define GNUNET_ALIGN __attribute__ ((aligned (__BIGGEST_ALIGNMENT__))) |
198 | #else | 198 | #else |
199 | #define GNUNET_ALIGN __attribute__ ((aligned(8))) | 199 | #define GNUNET_ALIGN __attribute__ ((aligned (8))) |
200 | #endif | 200 | #endif |
201 | 201 | ||
202 | /** | 202 | /** |
@@ -226,7 +226,8 @@ GNUNET_NETWORK_STRUCT_BEGIN | |||
226 | /** | 226 | /** |
227 | * @brief A 512-bit hashcode. These are the default length for GNUnet, using SHA-512. | 227 | * @brief A 512-bit hashcode. These are the default length for GNUnet, using SHA-512. |
228 | */ | 228 | */ |
229 | struct GNUNET_HashCode { | 229 | struct GNUNET_HashCode |
230 | { | ||
230 | uint32_t bits[512 / 8 / sizeof(uint32_t)]; /* = 16 */ | 231 | uint32_t bits[512 / 8 / sizeof(uint32_t)]; /* = 16 */ |
231 | }; | 232 | }; |
232 | 233 | ||
@@ -235,7 +236,8 @@ struct GNUNET_HashCode { | |||
235 | * @brief A 256-bit hashcode. Used under special conditions, like when space | 236 | * @brief A 256-bit hashcode. Used under special conditions, like when space |
236 | * is critical and security is not impacted by it. | 237 | * is critical and security is not impacted by it. |
237 | */ | 238 | */ |
238 | struct GNUNET_ShortHashCode { | 239 | struct GNUNET_ShortHashCode |
240 | { | ||
239 | uint32_t bits[256 / 8 / sizeof(uint32_t)]; /* = 8 */ | 241 | uint32_t bits[256 / 8 / sizeof(uint32_t)]; /* = 8 */ |
240 | }; | 242 | }; |
241 | 243 | ||
@@ -243,7 +245,8 @@ struct GNUNET_ShortHashCode { | |||
243 | /** | 245 | /** |
244 | * A UUID, a 128 bit random value. | 246 | * A UUID, a 128 bit random value. |
245 | */ | 247 | */ |
246 | struct GNUNET_Uuid { | 248 | struct GNUNET_Uuid |
249 | { | ||
247 | /** | 250 | /** |
248 | * 128 random bits. | 251 | * 128 random bits. |
249 | */ | 252 | */ |
@@ -254,7 +257,8 @@ struct GNUNET_Uuid { | |||
254 | /** | 257 | /** |
255 | * Header for all communications. | 258 | * Header for all communications. |
256 | */ | 259 | */ |
257 | struct GNUNET_MessageHeader { | 260 | struct GNUNET_MessageHeader |
261 | { | ||
258 | /** | 262 | /** |
259 | * The length of the struct (in bytes, including the length field itself), | 263 | * The length of the struct (in bytes, including the length field itself), |
260 | * in big-endian format. | 264 | * in big-endian format. |
@@ -271,7 +275,8 @@ struct GNUNET_MessageHeader { | |||
271 | /** | 275 | /** |
272 | * Answer from service to client about last operation. | 276 | * Answer from service to client about last operation. |
273 | */ | 277 | */ |
274 | struct GNUNET_OperationResultMessage { | 278 | struct GNUNET_OperationResultMessage |
279 | { | ||
275 | struct GNUNET_MessageHeader header; | 280 | struct GNUNET_MessageHeader header; |
276 | 281 | ||
277 | uint32_t reserved GNUNET_PACKED; | 282 | uint32_t reserved GNUNET_PACKED; |
@@ -293,7 +298,8 @@ struct GNUNET_OperationResultMessage { | |||
293 | /** | 298 | /** |
294 | * Identifier for an asynchronous execution context. | 299 | * Identifier for an asynchronous execution context. |
295 | */ | 300 | */ |
296 | struct GNUNET_AsyncScopeId { | 301 | struct GNUNET_AsyncScopeId |
302 | { | ||
297 | uint32_t bits[16 / sizeof(uint32_t)]; /* = 16 bytes */ | 303 | uint32_t bits[16 / sizeof(uint32_t)]; /* = 16 bytes */ |
298 | }; | 304 | }; |
299 | 305 | ||
@@ -303,7 +309,8 @@ GNUNET_NETWORK_STRUCT_END | |||
303 | /** | 309 | /** |
304 | * Saved async scope identifier or root scope. | 310 | * Saved async scope identifier or root scope. |
305 | */ | 311 | */ |
306 | struct GNUNET_AsyncScopeSave { | 312 | struct GNUNET_AsyncScopeSave |
313 | { | ||
307 | /** | 314 | /** |
308 | * Saved scope. Unused if 'have_scope==GNUNET_NO'. | 315 | * Saved scope. Unused if 'have_scope==GNUNET_NO'. |
309 | */ | 316 | */ |
@@ -360,7 +367,8 @@ typedef void (*GNUNET_ResultCallback) (void *cls, | |||
360 | * @ingroup logging | 367 | * @ingroup logging |
361 | * Types of errors. | 368 | * Types of errors. |
362 | */ | 369 | */ |
363 | enum GNUNET_ErrorType { | 370 | enum GNUNET_ErrorType |
371 | { | ||
364 | GNUNET_ERROR_TYPE_UNSPECIFIED = -1, | 372 | GNUNET_ERROR_TYPE_UNSPECIFIED = -1, |
365 | GNUNET_ERROR_TYPE_NONE = 0, | 373 | GNUNET_ERROR_TYPE_NONE = 0, |
366 | GNUNET_ERROR_TYPE_ERROR = 1, | 374 | GNUNET_ERROR_TYPE_ERROR = 1, |
@@ -400,16 +408,16 @@ typedef void (*GNUNET_Logger) (void *cls, | |||
400 | * @return number of log calls to be ignored | 408 | * @return number of log calls to be ignored |
401 | */ | 409 | */ |
402 | int | 410 | int |
403 | GNUNET_get_log_skip(void); | 411 | GNUNET_get_log_skip (void); |
404 | 412 | ||
405 | 413 | ||
406 | #if !defined(GNUNET_CULL_LOGGING) | 414 | #if ! defined(GNUNET_CULL_LOGGING) |
407 | int | 415 | int |
408 | GNUNET_get_log_call_status(int caller_level, | 416 | GNUNET_get_log_call_status (int caller_level, |
409 | const char *comp, | 417 | const char *comp, |
410 | const char *file, | 418 | const char *file, |
411 | const char *function, | 419 | const char *function, |
412 | int line); | 420 | int line); |
413 | #endif | 421 | #endif |
414 | 422 | ||
415 | 423 | ||
@@ -422,28 +430,28 @@ GNUNET_get_log_call_status(int caller_level, | |||
422 | * @param ... arguments for format string | 430 | * @param ... arguments for format string |
423 | */ | 431 | */ |
424 | void | 432 | void |
425 | GNUNET_log_nocheck(enum GNUNET_ErrorType kind, const char *message, ...) | 433 | GNUNET_log_nocheck (enum GNUNET_ErrorType kind, const char *message, ...) |
426 | __attribute__ ((format(printf, 2, 3))); | 434 | __attribute__ ((format (printf, 2, 3))); |
427 | 435 | ||
428 | /* from glib */ | 436 | /* from glib */ |
429 | #if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__) | 437 | #if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__) |
430 | #define _GNUNET_BOOLEAN_EXPR(expr) \ | 438 | #define _GNUNET_BOOLEAN_EXPR(expr) \ |
431 | __extension__({ \ | 439 | __extension__ ({ \ |
432 | int _gnunet_boolean_var_; \ | 440 | int _gnunet_boolean_var_; \ |
433 | if (expr) \ | 441 | if (expr) \ |
434 | _gnunet_boolean_var_ = 1; \ | 442 | _gnunet_boolean_var_ = 1; \ |
435 | else \ | 443 | else \ |
436 | _gnunet_boolean_var_ = 0; \ | 444 | _gnunet_boolean_var_ = 0; \ |
437 | _gnunet_boolean_var_; \ | 445 | _gnunet_boolean_var_; \ |
438 | }) | 446 | }) |
439 | #define GN_LIKELY(expr) (__builtin_expect(_GNUNET_BOOLEAN_EXPR(expr), 1)) | 447 | #define GN_LIKELY(expr) (__builtin_expect (_GNUNET_BOOLEAN_EXPR (expr), 1)) |
440 | #define GN_UNLIKELY(expr) (__builtin_expect(_GNUNET_BOOLEAN_EXPR(expr), 0)) | 448 | #define GN_UNLIKELY(expr) (__builtin_expect (_GNUNET_BOOLEAN_EXPR (expr), 0)) |
441 | #else | 449 | #else |
442 | #define GN_LIKELY(expr) (expr) | 450 | #define GN_LIKELY(expr) (expr) |
443 | #define GN_UNLIKELY(expr) (expr) | 451 | #define GN_UNLIKELY(expr) (expr) |
444 | #endif | 452 | #endif |
445 | 453 | ||
446 | #if !defined(GNUNET_LOG_CALL_STATUS) | 454 | #if ! defined(GNUNET_LOG_CALL_STATUS) |
447 | #define GNUNET_LOG_CALL_STATUS -1 | 455 | #define GNUNET_LOG_CALL_STATUS -1 |
448 | #endif | 456 | #endif |
449 | 457 | ||
@@ -459,12 +467,12 @@ __attribute__ ((format(printf, 2, 3))); | |||
459 | * @param ... arguments for format string | 467 | * @param ... arguments for format string |
460 | */ | 468 | */ |
461 | void | 469 | void |
462 | GNUNET_log_from_nocheck(enum GNUNET_ErrorType kind, | 470 | GNUNET_log_from_nocheck (enum GNUNET_ErrorType kind, |
463 | const char *comp, | 471 | const char *comp, |
464 | const char *message, | 472 | const char *message, |
465 | ...); | 473 | ...); |
466 | 474 | ||
467 | #if !defined(GNUNET_CULL_LOGGING) | 475 | #if ! defined(GNUNET_CULL_LOGGING) |
468 | #define GNUNET_log_from(kind, comp, ...) \ | 476 | #define GNUNET_log_from(kind, comp, ...) \ |
469 | do \ | 477 | do \ |
470 | { \ | 478 | { \ |
@@ -472,21 +480,21 @@ GNUNET_log_from_nocheck(enum GNUNET_ErrorType kind, | |||
472 | if ((GNUNET_EXTRA_LOGGING > 0) || \ | 480 | if ((GNUNET_EXTRA_LOGGING > 0) || \ |
473 | ((GNUNET_ERROR_TYPE_DEBUG & (kind)) == 0)) \ | 481 | ((GNUNET_ERROR_TYPE_DEBUG & (kind)) == 0)) \ |
474 | { \ | 482 | { \ |
475 | if (GN_UNLIKELY(log_call_enabled == -1)) \ | 483 | if (GN_UNLIKELY (log_call_enabled == -1)) \ |
476 | log_call_enabled = \ | 484 | log_call_enabled = \ |
477 | GNUNET_get_log_call_status ((kind) & (~GNUNET_ERROR_TYPE_BULK), \ | 485 | GNUNET_get_log_call_status ((kind) & (~GNUNET_ERROR_TYPE_BULK), \ |
478 | (comp), \ | 486 | (comp), \ |
479 | __FILE__, \ | 487 | __FILE__, \ |
480 | __FUNCTION__, \ | 488 | __FUNCTION__, \ |
481 | __LINE__); \ | 489 | __LINE__); \ |
482 | if (GN_UNLIKELY(GNUNET_get_log_skip() > 0)) \ | 490 | if (GN_UNLIKELY (GNUNET_get_log_skip () > 0)) \ |
483 | { \ | 491 | { \ |
484 | GNUNET_log_skip(-1, GNUNET_NO); \ | 492 | GNUNET_log_skip (-1, GNUNET_NO); \ |
485 | } \ | 493 | } \ |
486 | else \ | 494 | else \ |
487 | { \ | 495 | { \ |
488 | if (GN_UNLIKELY(log_call_enabled)) \ | 496 | if (GN_UNLIKELY (log_call_enabled)) \ |
489 | GNUNET_log_from_nocheck ((kind), comp, __VA_ARGS__); \ | 497 | GNUNET_log_from_nocheck ((kind), comp, __VA_ARGS__); \ |
490 | } \ | 498 | } \ |
491 | } \ | 499 | } \ |
492 | } while (0) | 500 | } while (0) |
@@ -498,21 +506,21 @@ GNUNET_log_from_nocheck(enum GNUNET_ErrorType kind, | |||
498 | if ((GNUNET_EXTRA_LOGGING > 0) || \ | 506 | if ((GNUNET_EXTRA_LOGGING > 0) || \ |
499 | ((GNUNET_ERROR_TYPE_DEBUG & (kind)) == 0)) \ | 507 | ((GNUNET_ERROR_TYPE_DEBUG & (kind)) == 0)) \ |
500 | { \ | 508 | { \ |
501 | if (GN_UNLIKELY(log_call_enabled == -1)) \ | 509 | if (GN_UNLIKELY (log_call_enabled == -1)) \ |
502 | log_call_enabled = \ | 510 | log_call_enabled = \ |
503 | GNUNET_get_log_call_status ((kind) & (~GNUNET_ERROR_TYPE_BULK), \ | 511 | GNUNET_get_log_call_status ((kind) & (~GNUNET_ERROR_TYPE_BULK), \ |
504 | NULL, \ | 512 | NULL, \ |
505 | __FILE__, \ | 513 | __FILE__, \ |
506 | __FUNCTION__, \ | 514 | __FUNCTION__, \ |
507 | __LINE__); \ | 515 | __LINE__); \ |
508 | if (GN_UNLIKELY(GNUNET_get_log_skip() > 0)) \ | 516 | if (GN_UNLIKELY (GNUNET_get_log_skip () > 0)) \ |
509 | { \ | 517 | { \ |
510 | GNUNET_log_skip(-1, GNUNET_NO); \ | 518 | GNUNET_log_skip (-1, GNUNET_NO); \ |
511 | } \ | 519 | } \ |
512 | else \ | 520 | else \ |
513 | { \ | 521 | { \ |
514 | if (GN_UNLIKELY(log_call_enabled)) \ | 522 | if (GN_UNLIKELY (log_call_enabled)) \ |
515 | GNUNET_log_nocheck ((kind), __VA_ARGS__); \ | 523 | GNUNET_log_nocheck ((kind), __VA_ARGS__); \ |
516 | } \ | 524 | } \ |
517 | } \ | 525 | } \ |
518 | } while (0) | 526 | } while (0) |
@@ -531,9 +539,9 @@ GNUNET_log_from_nocheck(enum GNUNET_ErrorType kind, | |||
531 | * @param option name of missing option | 539 | * @param option name of missing option |
532 | */ | 540 | */ |
533 | void | 541 | void |
534 | GNUNET_log_config_missing(enum GNUNET_ErrorType kind, | 542 | GNUNET_log_config_missing (enum GNUNET_ErrorType kind, |
535 | const char *section, | 543 | const char *section, |
536 | const char *option); | 544 | const char *option); |
537 | 545 | ||
538 | 546 | ||
539 | /** | 547 | /** |
@@ -546,10 +554,10 @@ GNUNET_log_config_missing(enum GNUNET_ErrorType kind, | |||
546 | * @param required what is required that is invalid about the option | 554 | * @param required what is required that is invalid about the option |
547 | */ | 555 | */ |
548 | void | 556 | void |
549 | GNUNET_log_config_invalid(enum GNUNET_ErrorType kind, | 557 | GNUNET_log_config_invalid (enum GNUNET_ErrorType kind, |
550 | const char *section, | 558 | const char *section, |
551 | const char *option, | 559 | const char *option, |
552 | const char *required); | 560 | const char *required); |
553 | 561 | ||
554 | 562 | ||
555 | /** | 563 | /** |
@@ -559,7 +567,7 @@ GNUNET_log_config_invalid(enum GNUNET_ErrorType kind, | |||
559 | * first log the location of the failure. | 567 | * first log the location of the failure. |
560 | */ | 568 | */ |
561 | void | 569 | void |
562 | GNUNET_abort_(void) GNUNET_NORETURN; | 570 | GNUNET_abort_ (void) GNUNET_NORETURN; |
563 | 571 | ||
564 | 572 | ||
565 | /** | 573 | /** |
@@ -570,7 +578,7 @@ GNUNET_abort_(void) GNUNET_NORETURN; | |||
570 | * @param check_reset #GNUNET_YES to assert that the log skip counter is currently zero | 578 | * @param check_reset #GNUNET_YES to assert that the log skip counter is currently zero |
571 | */ | 579 | */ |
572 | void | 580 | void |
573 | GNUNET_log_skip(int n, int check_reset); | 581 | GNUNET_log_skip (int n, int check_reset); |
574 | 582 | ||
575 | 583 | ||
576 | /** | 584 | /** |
@@ -583,7 +591,7 @@ GNUNET_log_skip(int n, int check_reset); | |||
583 | * @return #GNUNET_OK on success, #GNUNET_SYSERR if logfile could not be opened | 591 | * @return #GNUNET_OK on success, #GNUNET_SYSERR if logfile could not be opened |
584 | */ | 592 | */ |
585 | int | 593 | int |
586 | GNUNET_log_setup(const char *comp, const char *loglevel, const char *logfile); | 594 | GNUNET_log_setup (const char *comp, const char *loglevel, const char *logfile); |
587 | 595 | ||
588 | 596 | ||
589 | /** | 597 | /** |
@@ -597,7 +605,7 @@ GNUNET_log_setup(const char *comp, const char *loglevel, const char *logfile); | |||
597 | * @param logger_cls closure for @a logger | 605 | * @param logger_cls closure for @a logger |
598 | */ | 606 | */ |
599 | void | 607 | void |
600 | GNUNET_logger_add(GNUNET_Logger logger, void *logger_cls); | 608 | GNUNET_logger_add (GNUNET_Logger logger, void *logger_cls); |
601 | 609 | ||
602 | 610 | ||
603 | /** | 611 | /** |
@@ -608,7 +616,7 @@ GNUNET_logger_add(GNUNET_Logger logger, void *logger_cls); | |||
608 | * @param logger_cls closure for @a logger | 616 | * @param logger_cls closure for @a logger |
609 | */ | 617 | */ |
610 | void | 618 | void |
611 | GNUNET_logger_remove(GNUNET_Logger logger, void *logger_cls); | 619 | GNUNET_logger_remove (GNUNET_Logger logger, void *logger_cls); |
612 | 620 | ||
613 | 621 | ||
614 | /** | 622 | /** |
@@ -621,7 +629,7 @@ GNUNET_logger_remove(GNUNET_Logger logger, void *logger_cls); | |||
621 | * @return string | 629 | * @return string |
622 | */ | 630 | */ |
623 | const char * | 631 | const char * |
624 | GNUNET_sh2s(const struct GNUNET_ShortHashCode *shc); | 632 | GNUNET_sh2s (const struct GNUNET_ShortHashCode *shc); |
625 | 633 | ||
626 | 634 | ||
627 | /** | 635 | /** |
@@ -634,7 +642,7 @@ GNUNET_sh2s(const struct GNUNET_ShortHashCode *shc); | |||
634 | * @return string | 642 | * @return string |
635 | */ | 643 | */ |
636 | const char * | 644 | const char * |
637 | GNUNET_uuid2s(const struct GNUNET_Uuid *uuid); | 645 | GNUNET_uuid2s (const struct GNUNET_Uuid *uuid); |
638 | 646 | ||
639 | 647 | ||
640 | /** | 648 | /** |
@@ -647,7 +655,7 @@ GNUNET_uuid2s(const struct GNUNET_Uuid *uuid); | |||
647 | * @return string | 655 | * @return string |
648 | */ | 656 | */ |
649 | const char * | 657 | const char * |
650 | GNUNET_h2s(const struct GNUNET_HashCode *hc); | 658 | GNUNET_h2s (const struct GNUNET_HashCode *hc); |
651 | 659 | ||
652 | 660 | ||
653 | /** | 661 | /** |
@@ -662,7 +670,7 @@ GNUNET_h2s(const struct GNUNET_HashCode *hc); | |||
662 | * @return string | 670 | * @return string |
663 | */ | 671 | */ |
664 | const char * | 672 | const char * |
665 | GNUNET_h2s2(const struct GNUNET_HashCode *hc); | 673 | GNUNET_h2s2 (const struct GNUNET_HashCode *hc); |
666 | 674 | ||
667 | 675 | ||
668 | /** | 676 | /** |
@@ -676,7 +684,7 @@ GNUNET_h2s2(const struct GNUNET_HashCode *hc); | |||
676 | * @return string | 684 | * @return string |
677 | */ | 685 | */ |
678 | const char * | 686 | const char * |
679 | GNUNET_h2s_full(const struct GNUNET_HashCode *hc); | 687 | GNUNET_h2s_full (const struct GNUNET_HashCode *hc); |
680 | 688 | ||
681 | 689 | ||
682 | /** | 690 | /** |
@@ -701,7 +709,7 @@ struct GNUNET_CRYPTO_EcdhePublicKey; | |||
701 | * @return string | 709 | * @return string |
702 | */ | 710 | */ |
703 | const char * | 711 | const char * |
704 | GNUNET_p2s(const struct GNUNET_CRYPTO_EddsaPublicKey *p); | 712 | GNUNET_p2s (const struct GNUNET_CRYPTO_EddsaPublicKey *p); |
705 | 713 | ||
706 | 714 | ||
707 | /** | 715 | /** |
@@ -714,7 +722,7 @@ GNUNET_p2s(const struct GNUNET_CRYPTO_EddsaPublicKey *p); | |||
714 | * @return string | 722 | * @return string |
715 | */ | 723 | */ |
716 | const char * | 724 | const char * |
717 | GNUNET_p2s2(const struct GNUNET_CRYPTO_EddsaPublicKey *p); | 725 | GNUNET_p2s2 (const struct GNUNET_CRYPTO_EddsaPublicKey *p); |
718 | 726 | ||
719 | 727 | ||
720 | /** | 728 | /** |
@@ -727,7 +735,7 @@ GNUNET_p2s2(const struct GNUNET_CRYPTO_EddsaPublicKey *p); | |||
727 | * @return string | 735 | * @return string |
728 | */ | 736 | */ |
729 | const char * | 737 | const char * |
730 | GNUNET_e2s(const struct GNUNET_CRYPTO_EcdhePublicKey *p); | 738 | GNUNET_e2s (const struct GNUNET_CRYPTO_EcdhePublicKey *p); |
731 | 739 | ||
732 | 740 | ||
733 | /** | 741 | /** |
@@ -740,7 +748,7 @@ GNUNET_e2s(const struct GNUNET_CRYPTO_EcdhePublicKey *p); | |||
740 | * @return string | 748 | * @return string |
741 | */ | 749 | */ |
742 | const char * | 750 | const char * |
743 | GNUNET_e2s2(const struct GNUNET_CRYPTO_EcdhePublicKey *p); | 751 | GNUNET_e2s2 (const struct GNUNET_CRYPTO_EcdhePublicKey *p); |
744 | 752 | ||
745 | 753 | ||
746 | /** | 754 | /** |
@@ -754,7 +762,7 @@ GNUNET_e2s2(const struct GNUNET_CRYPTO_EcdhePublicKey *p); | |||
754 | * call to #GNUNET_i2s(). | 762 | * call to #GNUNET_i2s(). |
755 | */ | 763 | */ |
756 | const char * | 764 | const char * |
757 | GNUNET_i2s(const struct GNUNET_PeerIdentity *pid); | 765 | GNUNET_i2s (const struct GNUNET_PeerIdentity *pid); |
758 | 766 | ||
759 | 767 | ||
760 | /** | 768 | /** |
@@ -770,7 +778,7 @@ GNUNET_i2s(const struct GNUNET_PeerIdentity *pid); | |||
770 | * call to #GNUNET_i2s(). | 778 | * call to #GNUNET_i2s(). |
771 | */ | 779 | */ |
772 | const char * | 780 | const char * |
773 | GNUNET_i2s2(const struct GNUNET_PeerIdentity *pid); | 781 | GNUNET_i2s2 (const struct GNUNET_PeerIdentity *pid); |
774 | 782 | ||
775 | 783 | ||
776 | /** | 784 | /** |
@@ -784,7 +792,7 @@ GNUNET_i2s2(const struct GNUNET_PeerIdentity *pid); | |||
784 | * call to #GNUNET_i2s_full(). | 792 | * call to #GNUNET_i2s_full(). |
785 | */ | 793 | */ |
786 | const char * | 794 | const char * |
787 | GNUNET_i2s_full(const struct GNUNET_PeerIdentity *pid); | 795 | GNUNET_i2s_full (const struct GNUNET_PeerIdentity *pid); |
788 | 796 | ||
789 | 797 | ||
790 | /** | 798 | /** |
@@ -799,7 +807,7 @@ GNUNET_i2s_full(const struct GNUNET_PeerIdentity *pid); | |||
799 | * will be overwritten by next call to #GNUNET_a2s(). | 807 | * will be overwritten by next call to #GNUNET_a2s(). |
800 | */ | 808 | */ |
801 | const char * | 809 | const char * |
802 | GNUNET_a2s(const struct sockaddr *addr, socklen_t addrlen); | 810 | GNUNET_a2s (const struct sockaddr *addr, socklen_t addrlen); |
803 | 811 | ||
804 | 812 | ||
805 | /** | 813 | /** |
@@ -810,7 +818,7 @@ GNUNET_a2s(const struct sockaddr *addr, socklen_t addrlen); | |||
810 | * @return string corresponding to the type | 818 | * @return string corresponding to the type |
811 | */ | 819 | */ |
812 | const char * | 820 | const char * |
813 | GNUNET_error_type_to_string(enum GNUNET_ErrorType kind); | 821 | GNUNET_error_type_to_string (enum GNUNET_ErrorType kind); |
814 | 822 | ||
815 | 823 | ||
816 | /** | 824 | /** |
@@ -820,13 +828,13 @@ GNUNET_error_type_to_string(enum GNUNET_ErrorType kind); | |||
820 | #define GNUNET_assert(cond) \ | 828 | #define GNUNET_assert(cond) \ |
821 | do \ | 829 | do \ |
822 | { \ | 830 | { \ |
823 | if (!(cond)) \ | 831 | if (! (cond)) \ |
824 | { \ | 832 | { \ |
825 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, \ | 833 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, \ |
826 | _("Assertion failed at %s:%d. Aborting.\n"), \ | 834 | _ ("Assertion failed at %s:%d. Aborting.\n"), \ |
827 | __FILE__, \ | 835 | __FILE__, \ |
828 | __LINE__); \ | 836 | __LINE__); \ |
829 | GNUNET_abort_(); \ | 837 | GNUNET_abort_ (); \ |
830 | } \ | 838 | } \ |
831 | } while (0) | 839 | } while (0) |
832 | 840 | ||
@@ -838,13 +846,13 @@ GNUNET_error_type_to_string(enum GNUNET_ErrorType kind); | |||
838 | #define GNUNET_assert_at(cond, f, l) \ | 846 | #define GNUNET_assert_at(cond, f, l) \ |
839 | do \ | 847 | do \ |
840 | { \ | 848 | { \ |
841 | if (!(cond)) \ | 849 | if (! (cond)) \ |
842 | { \ | 850 | { \ |
843 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, \ | 851 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, \ |
844 | _("Assertion failed at %s:%d. Aborting.\n"), \ | 852 | _ ("Assertion failed at %s:%d. Aborting.\n"), \ |
845 | f, \ | 853 | f, \ |
846 | l); \ | 854 | l); \ |
847 | GNUNET_abort_(); \ | 855 | GNUNET_abort_ (); \ |
848 | } \ | 856 | } \ |
849 | } while (0) | 857 | } while (0) |
850 | 858 | ||
@@ -859,14 +867,14 @@ GNUNET_error_type_to_string(enum GNUNET_ErrorType kind); | |||
859 | #define GNUNET_assert_from(cond, comp) \ | 867 | #define GNUNET_assert_from(cond, comp) \ |
860 | do \ | 868 | do \ |
861 | { \ | 869 | { \ |
862 | if (!(cond)) \ | 870 | if (! (cond)) \ |
863 | { \ | 871 | { \ |
864 | GNUNET_log_from(GNUNET_ERROR_TYPE_ERROR, \ | 872 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, \ |
865 | comp, \ | 873 | comp, \ |
866 | _("Assertion failed at %s:%d. Aborting.\n"), \ | 874 | _ ("Assertion failed at %s:%d. Aborting.\n"), \ |
867 | __FILE__, \ | 875 | __FILE__, \ |
868 | __LINE__); \ | 876 | __LINE__); \ |
869 | GNUNET_abort_(); \ | 877 | GNUNET_abort_ (); \ |
870 | } \ | 878 | } \ |
871 | } while (0) | 879 | } while (0) |
872 | 880 | ||
@@ -879,12 +887,12 @@ GNUNET_error_type_to_string(enum GNUNET_ErrorType kind); | |||
879 | #define GNUNET_break(cond) \ | 887 | #define GNUNET_break(cond) \ |
880 | do \ | 888 | do \ |
881 | { \ | 889 | { \ |
882 | if (!(cond)) \ | 890 | if (! (cond)) \ |
883 | { \ | 891 | { \ |
884 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, \ | 892 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, \ |
885 | _("Assertion failed at %s:%d.\n"), \ | 893 | _ ("Assertion failed at %s:%d.\n"), \ |
886 | __FILE__, \ | 894 | __FILE__, \ |
887 | __LINE__); \ | 895 | __LINE__); \ |
888 | } \ | 896 | } \ |
889 | } while (0) | 897 | } while (0) |
890 | 898 | ||
@@ -901,12 +909,12 @@ GNUNET_error_type_to_string(enum GNUNET_ErrorType kind); | |||
901 | #define GNUNET_break_op(cond) \ | 909 | #define GNUNET_break_op(cond) \ |
902 | do \ | 910 | do \ |
903 | { \ | 911 | { \ |
904 | if (!(cond)) \ | 912 | if (! (cond)) \ |
905 | { \ | 913 | { \ |
906 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK, \ | 914 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK, \ |
907 | _("External protocol violation detected at %s:%d.\n"), \ | 915 | _ ("External protocol violation detected at %s:%d.\n"), \ |
908 | __FILE__, \ | 916 | __FILE__, \ |
909 | __LINE__); \ | 917 | __LINE__); \ |
910 | } \ | 918 | } \ |
911 | } while (0) | 919 | } while (0) |
912 | 920 | ||
@@ -920,12 +928,12 @@ GNUNET_error_type_to_string(enum GNUNET_ErrorType kind); | |||
920 | #define GNUNET_log_strerror(level, cmd) \ | 928 | #define GNUNET_log_strerror(level, cmd) \ |
921 | do \ | 929 | do \ |
922 | { \ | 930 | { \ |
923 | GNUNET_log(level, \ | 931 | GNUNET_log (level, \ |
924 | _("`%s' failed at %s:%d with error: %s\n"), \ | 932 | _ ("`%s' failed at %s:%d with error: %s\n"), \ |
925 | cmd, \ | 933 | cmd, \ |
926 | __FILE__, \ | 934 | __FILE__, \ |
927 | __LINE__, \ | 935 | __LINE__, \ |
928 | strerror(errno)); \ | 936 | strerror (errno)); \ |
929 | } while (0) | 937 | } while (0) |
930 | 938 | ||
931 | 939 | ||
@@ -938,13 +946,13 @@ GNUNET_error_type_to_string(enum GNUNET_ErrorType kind); | |||
938 | #define GNUNET_log_from_strerror(level, component, cmd) \ | 946 | #define GNUNET_log_from_strerror(level, component, cmd) \ |
939 | do \ | 947 | do \ |
940 | { \ | 948 | { \ |
941 | GNUNET_log_from(level, \ | 949 | GNUNET_log_from (level, \ |
942 | component, \ | 950 | component, \ |
943 | _("`%s' failed at %s:%d with error: %s\n"), \ | 951 | _ ("`%s' failed at %s:%d with error: %s\n"), \ |
944 | cmd, \ | 952 | cmd, \ |
945 | __FILE__, \ | 953 | __FILE__, \ |
946 | __LINE__, \ | 954 | __LINE__, \ |
947 | strerror(errno)); \ | 955 | strerror (errno)); \ |
948 | } while (0) | 956 | } while (0) |
949 | 957 | ||
950 | 958 | ||
@@ -957,13 +965,13 @@ GNUNET_error_type_to_string(enum GNUNET_ErrorType kind); | |||
957 | #define GNUNET_log_strerror_file(level, cmd, filename) \ | 965 | #define GNUNET_log_strerror_file(level, cmd, filename) \ |
958 | do \ | 966 | do \ |
959 | { \ | 967 | { \ |
960 | GNUNET_log(level, \ | 968 | GNUNET_log (level, \ |
961 | _("`%s' failed on file `%s' at %s:%d with error: %s\n"), \ | 969 | _ ("`%s' failed on file `%s' at %s:%d with error: %s\n"), \ |
962 | cmd, \ | 970 | cmd, \ |
963 | filename, \ | 971 | filename, \ |
964 | __FILE__, \ | 972 | __FILE__, \ |
965 | __LINE__, \ | 973 | __LINE__, \ |
966 | strerror(errno)); \ | 974 | strerror (errno)); \ |
967 | } while (0) | 975 | } while (0) |
968 | 976 | ||
969 | 977 | ||
@@ -976,14 +984,14 @@ GNUNET_error_type_to_string(enum GNUNET_ErrorType kind); | |||
976 | #define GNUNET_log_from_strerror_file(level, component, cmd, filename) \ | 984 | #define GNUNET_log_from_strerror_file(level, component, cmd, filename) \ |
977 | do \ | 985 | do \ |
978 | { \ | 986 | { \ |
979 | GNUNET_log_from(level, \ | 987 | GNUNET_log_from (level, \ |
980 | component, \ | 988 | component, \ |
981 | _("`%s' failed on file `%s' at %s:%d with error: %s\n"), \ | 989 | _ ("`%s' failed on file `%s' at %s:%d with error: %s\n"), \ |
982 | cmd, \ | 990 | cmd, \ |
983 | filename, \ | 991 | filename, \ |
984 | __FILE__, \ | 992 | __FILE__, \ |
985 | __LINE__, \ | 993 | __LINE__, \ |
986 | strerror(errno)); \ | 994 | strerror (errno)); \ |
987 | } while (0) | 995 | } while (0) |
988 | 996 | ||
989 | /* ************************* endianess conversion ****************** */ | 997 | /* ************************* endianess conversion ****************** */ |
@@ -997,7 +1005,7 @@ GNUNET_error_type_to_string(enum GNUNET_ErrorType kind); | |||
997 | * @return The same value in network byte order. | 1005 | * @return The same value in network byte order. |
998 | */ | 1006 | */ |
999 | uint64_t | 1007 | uint64_t |
1000 | GNUNET_htonll(uint64_t n); | 1008 | GNUNET_htonll (uint64_t n); |
1001 | 1009 | ||
1002 | 1010 | ||
1003 | /** | 1011 | /** |
@@ -1009,7 +1017,7 @@ GNUNET_htonll(uint64_t n); | |||
1009 | * @return The same value in host byte order. | 1017 | * @return The same value in host byte order. |
1010 | */ | 1018 | */ |
1011 | uint64_t | 1019 | uint64_t |
1012 | GNUNET_ntohll(uint64_t n); | 1020 | GNUNET_ntohll (uint64_t n); |
1013 | 1021 | ||
1014 | 1022 | ||
1015 | /** | 1023 | /** |
@@ -1021,7 +1029,7 @@ GNUNET_ntohll(uint64_t n); | |||
1021 | * @return The same value in network byte order. | 1029 | * @return The same value in network byte order. |
1022 | */ | 1030 | */ |
1023 | double | 1031 | double |
1024 | GNUNET_hton_double(double d); | 1032 | GNUNET_hton_double (double d); |
1025 | 1033 | ||
1026 | 1034 | ||
1027 | /** | 1035 | /** |
@@ -1033,7 +1041,7 @@ GNUNET_hton_double(double d); | |||
1033 | * @return The same value in host byte order. | 1041 | * @return The same value in host byte order. |
1034 | */ | 1042 | */ |
1035 | double | 1043 | double |
1036 | GNUNET_ntoh_double(double d); | 1044 | GNUNET_ntoh_double (double d); |
1037 | 1045 | ||
1038 | 1046 | ||
1039 | /* ************************* allocation functions ****************** */ | 1047 | /* ************************* allocation functions ****************** */ |
@@ -1052,7 +1060,7 @@ GNUNET_ntoh_double(double d); | |||
1052 | * | 1060 | * |
1053 | * @param type name of the struct or union, i.e. pass 'struct Foo'. | 1061 | * @param type name of the struct or union, i.e. pass 'struct Foo'. |
1054 | */ | 1062 | */ |
1055 | #define GNUNET_new(type) (type *)GNUNET_malloc(sizeof(type)) | 1063 | #define GNUNET_new(type) (type *) GNUNET_malloc (sizeof(type)) |
1056 | 1064 | ||
1057 | 1065 | ||
1058 | /** | 1066 | /** |
@@ -1063,7 +1071,7 @@ GNUNET_ntoh_double(double d); | |||
1063 | ({ \ | 1071 | ({ \ |
1064 | const typeof (*b) * _a = (a); \ | 1072 | const typeof (*b) * _a = (a); \ |
1065 | const typeof (*a) * _b = (b); \ | 1073 | const typeof (*a) * _b = (b); \ |
1066 | memcmp(_a, _b, sizeof(*a)); \ | 1074 | memcmp (_a, _b, sizeof(*a)); \ |
1067 | }) | 1075 | }) |
1068 | 1076 | ||
1069 | 1077 | ||
@@ -1076,7 +1084,7 @@ GNUNET_ntoh_double(double d); | |||
1076 | #define GNUNET_is_zero(a) \ | 1084 | #define GNUNET_is_zero(a) \ |
1077 | ({ \ | 1085 | ({ \ |
1078 | static const typeof (*a) _z; \ | 1086 | static const typeof (*a) _z; \ |
1079 | memcmp((a), &_z, sizeof(_z)); \ | 1087 | memcmp ((a), &_z, sizeof(_z)); \ |
1080 | }) | 1088 | }) |
1081 | 1089 | ||
1082 | 1090 | ||
@@ -1094,7 +1102,7 @@ GNUNET_ntoh_double(double d); | |||
1094 | { \ | 1102 | { \ |
1095 | if (0 != n) \ | 1103 | if (0 != n) \ |
1096 | { \ | 1104 | { \ |
1097 | (void)memcpy(dst, src, n); \ | 1105 | (void) memcpy (dst, src, n); \ |
1098 | } \ | 1106 | } \ |
1099 | } while (0) | 1107 | } while (0) |
1100 | 1108 | ||
@@ -1108,7 +1116,7 @@ GNUNET_ntoh_double(double d); | |||
1108 | * @param n number of elements in the array | 1116 | * @param n number of elements in the array |
1109 | * @param type name of the struct or union, i.e. pass 'struct Foo'. | 1117 | * @param type name of the struct or union, i.e. pass 'struct Foo'. |
1110 | */ | 1118 | */ |
1111 | #define GNUNET_new_array(n, type) (type *)GNUNET_malloc((n) * sizeof(type)) | 1119 | #define GNUNET_new_array(n, type) (type *) GNUNET_malloc ((n) * sizeof(type)) |
1112 | 1120 | ||
1113 | /** | 1121 | /** |
1114 | * @ingroup memory | 1122 | * @ingroup memory |
@@ -1120,7 +1128,7 @@ GNUNET_ntoh_double(double d); | |||
1120 | * @param type name of the struct or union, i.e. pass 'struct Foo'. | 1128 | * @param type name of the struct or union, i.e. pass 'struct Foo'. |
1121 | */ | 1129 | */ |
1122 | #define GNUNET_new_array_2d(n, m, type) \ | 1130 | #define GNUNET_new_array_2d(n, m, type) \ |
1123 | (type **)GNUNET_xnew_array_2d_(n, m, sizeof(type), __FILE__, __LINE__) | 1131 | (type **) GNUNET_xnew_array_2d_ (n, m, sizeof(type), __FILE__, __LINE__) |
1124 | 1132 | ||
1125 | /** | 1133 | /** |
1126 | * @ingroup memory | 1134 | * @ingroup memory |
@@ -1133,7 +1141,7 @@ GNUNET_ntoh_double(double d); | |||
1133 | * @param type name of the struct or union, i.e. pass 'struct Foo'. | 1141 | * @param type name of the struct or union, i.e. pass 'struct Foo'. |
1134 | */ | 1142 | */ |
1135 | #define GNUNET_new_array_3d(n, m, o, type) \ | 1143 | #define GNUNET_new_array_3d(n, m, o, type) \ |
1136 | (type ***)GNUNET_xnew_array_3d_(n, m, o, sizeof(type), __FILE__, __LINE__) | 1144 | (type ***) GNUNET_xnew_array_3d_ (n, m, o, sizeof(type), __FILE__, __LINE__) |
1137 | 1145 | ||
1138 | /** | 1146 | /** |
1139 | * @ingroup memory | 1147 | * @ingroup memory |
@@ -1144,7 +1152,7 @@ GNUNET_ntoh_double(double d); | |||
1144 | * smaller than 40 MB. | 1152 | * smaller than 40 MB. |
1145 | * @return pointer to size bytes of memory, never NULL (!) | 1153 | * @return pointer to size bytes of memory, never NULL (!) |
1146 | */ | 1154 | */ |
1147 | #define GNUNET_malloc(size) GNUNET_xmalloc_(size, __FILE__, __LINE__) | 1155 | #define GNUNET_malloc(size) GNUNET_xmalloc_ (size, __FILE__, __LINE__) |
1148 | 1156 | ||
1149 | /** | 1157 | /** |
1150 | * @ingroup memory | 1158 | * @ingroup memory |
@@ -1154,7 +1162,7 @@ GNUNET_ntoh_double(double d); | |||
1154 | * @param size the number of bytes in buf (and size of the allocation) | 1162 | * @param size the number of bytes in buf (and size of the allocation) |
1155 | * @return pointer to size bytes of memory, never NULL (!) | 1163 | * @return pointer to size bytes of memory, never NULL (!) |
1156 | */ | 1164 | */ |
1157 | #define GNUNET_memdup(buf, size) GNUNET_xmemdup_(buf, size, __FILE__, __LINE__) | 1165 | #define GNUNET_memdup(buf, size) GNUNET_xmemdup_ (buf, size, __FILE__, __LINE__) |
1158 | 1166 | ||
1159 | /** | 1167 | /** |
1160 | * @ingroup memory | 1168 | * @ingroup memory |
@@ -1165,7 +1173,7 @@ GNUNET_ntoh_double(double d); | |||
1165 | * @return pointer to size bytes of memory, NULL if we do not have enough memory | 1173 | * @return pointer to size bytes of memory, NULL if we do not have enough memory |
1166 | */ | 1174 | */ |
1167 | #define GNUNET_malloc_large(size) \ | 1175 | #define GNUNET_malloc_large(size) \ |
1168 | GNUNET_xmalloc_unchecked_(size, __FILE__, __LINE__) | 1176 | GNUNET_xmalloc_unchecked_ (size, __FILE__, __LINE__) |
1169 | 1177 | ||
1170 | /** | 1178 | /** |
1171 | * @ingroup memory | 1179 | * @ingroup memory |
@@ -1177,7 +1185,7 @@ GNUNET_ntoh_double(double d); | |||
1177 | * @return pointer to size bytes of memory | 1185 | * @return pointer to size bytes of memory |
1178 | */ | 1186 | */ |
1179 | #define GNUNET_realloc(ptr, size) \ | 1187 | #define GNUNET_realloc(ptr, size) \ |
1180 | GNUNET_xrealloc_(ptr, size, __FILE__, __LINE__) | 1188 | GNUNET_xrealloc_ (ptr, size, __FILE__, __LINE__) |
1181 | 1189 | ||
1182 | /** | 1190 | /** |
1183 | * @ingroup memory | 1191 | * @ingroup memory |
@@ -1188,7 +1196,7 @@ GNUNET_ntoh_double(double d); | |||
1188 | * @param ptr location where to free the memory. ptr must have | 1196 | * @param ptr location where to free the memory. ptr must have |
1189 | * been returned by #GNUNET_strdup, #GNUNET_strndup, #GNUNET_malloc or #GNUNET_array_grow earlier. | 1197 | * been returned by #GNUNET_strdup, #GNUNET_strndup, #GNUNET_malloc or #GNUNET_array_grow earlier. |
1190 | */ | 1198 | */ |
1191 | #define GNUNET_free(ptr) GNUNET_xfree_(ptr, __FILE__, __LINE__) | 1199 | #define GNUNET_free(ptr) GNUNET_xfree_ (ptr, __FILE__, __LINE__) |
1192 | 1200 | ||
1193 | /** | 1201 | /** |
1194 | * @ingroup memory | 1202 | * @ingroup memory |
@@ -1203,7 +1211,7 @@ GNUNET_ntoh_double(double d); | |||
1203 | void *__x__ = ptr; \ | 1211 | void *__x__ = ptr; \ |
1204 | if (__x__ != NULL) \ | 1212 | if (__x__ != NULL) \ |
1205 | { \ | 1213 | { \ |
1206 | GNUNET_free(__x__); \ | 1214 | GNUNET_free (__x__); \ |
1207 | } \ | 1215 | } \ |
1208 | } while (0) | 1216 | } while (0) |
1209 | 1217 | ||
@@ -1215,7 +1223,7 @@ GNUNET_ntoh_double(double d); | |||
1215 | * @param a pointer to a zero-terminated string | 1223 | * @param a pointer to a zero-terminated string |
1216 | * @return a copy of the string including zero-termination | 1224 | * @return a copy of the string including zero-termination |
1217 | */ | 1225 | */ |
1218 | #define GNUNET_strdup(a) GNUNET_xstrdup_(a, __FILE__, __LINE__) | 1226 | #define GNUNET_strdup(a) GNUNET_xstrdup_ (a, __FILE__, __LINE__) |
1219 | 1227 | ||
1220 | /** | 1228 | /** |
1221 | * @ingroup memory | 1229 | * @ingroup memory |
@@ -1227,7 +1235,7 @@ GNUNET_ntoh_double(double d); | |||
1227 | * @return a partial copy of the string including zero-termination | 1235 | * @return a partial copy of the string including zero-termination |
1228 | */ | 1236 | */ |
1229 | #define GNUNET_strndup(a, length) \ | 1237 | #define GNUNET_strndup(a, length) \ |
1230 | GNUNET_xstrndup_(a, length, __FILE__, __LINE__) | 1238 | GNUNET_xstrndup_ (a, length, __FILE__, __LINE__) |
1231 | 1239 | ||
1232 | /** | 1240 | /** |
1233 | * @ingroup memory | 1241 | * @ingroup memory |
@@ -1265,12 +1273,12 @@ GNUNET_ntoh_double(double d); | |||
1265 | * free the vector (then, arr will be NULL afterwards). | 1273 | * free the vector (then, arr will be NULL afterwards). |
1266 | */ | 1274 | */ |
1267 | #define GNUNET_array_grow(arr, size, tsize) \ | 1275 | #define GNUNET_array_grow(arr, size, tsize) \ |
1268 | GNUNET_xgrow_((void **)&(arr), \ | 1276 | GNUNET_xgrow_ ((void **) &(arr), \ |
1269 | sizeof((arr)[0]), \ | 1277 | sizeof((arr)[0]), \ |
1270 | &size, \ | 1278 | &size, \ |
1271 | tsize, \ | 1279 | tsize, \ |
1272 | __FILE__, \ | 1280 | __FILE__, \ |
1273 | __LINE__) | 1281 | __LINE__) |
1274 | 1282 | ||
1275 | /** | 1283 | /** |
1276 | * @ingroup memory | 1284 | * @ingroup memory |
@@ -1288,8 +1296,8 @@ GNUNET_ntoh_double(double d); | |||
1288 | #define GNUNET_array_append(arr, size, element) \ | 1296 | #define GNUNET_array_append(arr, size, element) \ |
1289 | do \ | 1297 | do \ |
1290 | { \ | 1298 | { \ |
1291 | GNUNET_array_grow(arr, size, size + 1); \ | 1299 | GNUNET_array_grow (arr, size, size + 1); \ |
1292 | (arr)[size - 1] = element; \ | 1300 | (arr) [size - 1] = element; \ |
1293 | } while (0) | 1301 | } while (0) |
1294 | 1302 | ||
1295 | /** | 1303 | /** |
@@ -1303,7 +1311,7 @@ GNUNET_ntoh_double(double d); | |||
1303 | * @return number of bytes written to buf or negative value on error | 1311 | * @return number of bytes written to buf or negative value on error |
1304 | */ | 1312 | */ |
1305 | int | 1313 | int |
1306 | GNUNET_snprintf(char *buf, size_t size, const char *format, ...); | 1314 | GNUNET_snprintf (char *buf, size_t size, const char *format, ...); |
1307 | 1315 | ||
1308 | 1316 | ||
1309 | /** | 1317 | /** |
@@ -1316,7 +1324,7 @@ GNUNET_snprintf(char *buf, size_t size, const char *format, ...); | |||
1316 | * @return number of bytes in "*buf" excluding 0-termination | 1324 | * @return number of bytes in "*buf" excluding 0-termination |
1317 | */ | 1325 | */ |
1318 | int | 1326 | int |
1319 | GNUNET_asprintf(char **buf, const char *format, ...); | 1327 | GNUNET_asprintf (char **buf, const char *format, ...); |
1320 | 1328 | ||
1321 | 1329 | ||
1322 | /* ************** internal implementations, use macros above! ************** */ | 1330 | /* ************** internal implementations, use macros above! ************** */ |
@@ -1333,7 +1341,7 @@ GNUNET_asprintf(char **buf, const char *format, ...); | |||
1333 | * @return allocated memory, never NULL | 1341 | * @return allocated memory, never NULL |
1334 | */ | 1342 | */ |
1335 | void * | 1343 | void * |
1336 | GNUNET_xmalloc_(size_t size, const char *filename, int linenumber); | 1344 | GNUNET_xmalloc_ (size_t size, const char *filename, int linenumber); |
1337 | 1345 | ||
1338 | 1346 | ||
1339 | /** | 1347 | /** |
@@ -1351,11 +1359,11 @@ GNUNET_xmalloc_(size_t size, const char *filename, int linenumber); | |||
1351 | * @return allocated memory, never NULL | 1359 | * @return allocated memory, never NULL |
1352 | */ | 1360 | */ |
1353 | void ** | 1361 | void ** |
1354 | GNUNET_xnew_array_2d_(size_t n, | 1362 | GNUNET_xnew_array_2d_ (size_t n, |
1355 | size_t m, | 1363 | size_t m, |
1356 | size_t elementSize, | 1364 | size_t elementSize, |
1357 | const char *filename, | 1365 | const char *filename, |
1358 | int linenumber); | 1366 | int linenumber); |
1359 | 1367 | ||
1360 | 1368 | ||
1361 | /** | 1369 | /** |
@@ -1374,12 +1382,12 @@ GNUNET_xnew_array_2d_(size_t n, | |||
1374 | * @return allocated memory, never NULL | 1382 | * @return allocated memory, never NULL |
1375 | */ | 1383 | */ |
1376 | void *** | 1384 | void *** |
1377 | GNUNET_xnew_array_3d_(size_t n, | 1385 | GNUNET_xnew_array_3d_ (size_t n, |
1378 | size_t m, | 1386 | size_t m, |
1379 | size_t o, | 1387 | size_t o, |
1380 | size_t elementSize, | 1388 | size_t elementSize, |
1381 | const char *filename, | 1389 | const char *filename, |
1382 | int linenumber); | 1390 | int linenumber); |
1383 | 1391 | ||
1384 | 1392 | ||
1385 | /** | 1393 | /** |
@@ -1394,10 +1402,10 @@ GNUNET_xnew_array_3d_(size_t n, | |||
1394 | * @return allocated memory, never NULL | 1402 | * @return allocated memory, never NULL |
1395 | */ | 1403 | */ |
1396 | void * | 1404 | void * |
1397 | GNUNET_xmemdup_(const void *buf, | 1405 | GNUNET_xmemdup_ (const void *buf, |
1398 | size_t size, | 1406 | size_t size, |
1399 | const char *filename, | 1407 | const char *filename, |
1400 | int linenumber); | 1408 | int linenumber); |
1401 | 1409 | ||
1402 | 1410 | ||
1403 | /** | 1411 | /** |
@@ -1413,7 +1421,7 @@ GNUNET_xmemdup_(const void *buf, | |||
1413 | * @return pointer to size bytes of memory, NULL if we do not have enough memory | 1421 | * @return pointer to size bytes of memory, NULL if we do not have enough memory |
1414 | */ | 1422 | */ |
1415 | void * | 1423 | void * |
1416 | GNUNET_xmalloc_unchecked_(size_t size, const char *filename, int linenumber); | 1424 | GNUNET_xmalloc_unchecked_ (size_t size, const char *filename, int linenumber); |
1417 | 1425 | ||
1418 | 1426 | ||
1419 | /** | 1427 | /** |
@@ -1421,7 +1429,7 @@ GNUNET_xmalloc_unchecked_(size_t size, const char *filename, int linenumber); | |||
1421 | * memory is available. | 1429 | * memory is available. |
1422 | */ | 1430 | */ |
1423 | void * | 1431 | void * |
1424 | GNUNET_xrealloc_(void *ptr, size_t n, const char *filename, int linenumber); | 1432 | GNUNET_xrealloc_ (void *ptr, size_t n, const char *filename, int linenumber); |
1425 | 1433 | ||
1426 | 1434 | ||
1427 | /** | 1435 | /** |
@@ -1434,7 +1442,7 @@ GNUNET_xrealloc_(void *ptr, size_t n, const char *filename, int linenumber); | |||
1434 | * @param linenumber line where this call is being made (for debugging) | 1442 | * @param linenumber line where this call is being made (for debugging) |
1435 | */ | 1443 | */ |
1436 | void | 1444 | void |
1437 | GNUNET_xfree_(void *ptr, const char *filename, int linenumber); | 1445 | GNUNET_xfree_ (void *ptr, const char *filename, int linenumber); |
1438 | 1446 | ||
1439 | 1447 | ||
1440 | /** | 1448 | /** |
@@ -1445,7 +1453,7 @@ GNUNET_xfree_(void *ptr, const char *filename, int linenumber); | |||
1445 | * @return the duplicated string | 1453 | * @return the duplicated string |
1446 | */ | 1454 | */ |
1447 | char * | 1455 | char * |
1448 | GNUNET_xstrdup_(const char *str, const char *filename, int linenumber); | 1456 | GNUNET_xstrdup_ (const char *str, const char *filename, int linenumber); |
1449 | 1457 | ||
1450 | /** | 1458 | /** |
1451 | * Dup partially a string. Don't call GNUNET_xstrndup_ directly. Use the #GNUNET_strndup macro. | 1459 | * Dup partially a string. Don't call GNUNET_xstrndup_ directly. Use the #GNUNET_strndup macro. |
@@ -1457,10 +1465,10 @@ GNUNET_xstrdup_(const char *str, const char *filename, int linenumber); | |||
1457 | * @return the duplicated string | 1465 | * @return the duplicated string |
1458 | */ | 1466 | */ |
1459 | char * | 1467 | char * |
1460 | GNUNET_xstrndup_(const char *str, | 1468 | GNUNET_xstrndup_ (const char *str, |
1461 | size_t len, | 1469 | size_t len, |
1462 | const char *filename, | 1470 | const char *filename, |
1463 | int linenumber); | 1471 | int linenumber); |
1464 | 1472 | ||
1465 | /** | 1473 | /** |
1466 | * Grow an array, the new elements are zeroed out. | 1474 | * Grow an array, the new elements are zeroed out. |
@@ -1478,12 +1486,12 @@ GNUNET_xstrndup_(const char *str, | |||
1478 | * @param linenumber line where this call is being made (for debugging) | 1486 | * @param linenumber line where this call is being made (for debugging) |
1479 | */ | 1487 | */ |
1480 | void | 1488 | void |
1481 | GNUNET_xgrow_(void **old, | 1489 | GNUNET_xgrow_ (void **old, |
1482 | size_t elementSize, | 1490 | size_t elementSize, |
1483 | unsigned int *oldCount, | 1491 | unsigned int *oldCount, |
1484 | unsigned int newCount, | 1492 | unsigned int newCount, |
1485 | const char *filename, | 1493 | const char *filename, |
1486 | int linenumber); | 1494 | int linenumber); |
1487 | 1495 | ||
1488 | 1496 | ||
1489 | /** | 1497 | /** |
@@ -1494,7 +1502,7 @@ GNUNET_xgrow_(void **old, | |||
1494 | * @return duplicate of the message | 1502 | * @return duplicate of the message |
1495 | */ | 1503 | */ |
1496 | struct GNUNET_MessageHeader * | 1504 | struct GNUNET_MessageHeader * |
1497 | GNUNET_copy_message(const struct GNUNET_MessageHeader *msg); | 1505 | GNUNET_copy_message (const struct GNUNET_MessageHeader *msg); |
1498 | 1506 | ||
1499 | 1507 | ||
1500 | /** | 1508 | /** |
@@ -1504,8 +1512,8 @@ GNUNET_copy_message(const struct GNUNET_MessageHeader *msg); | |||
1504 | * @param old_scope[out] location to save the old scope | 1512 | * @param old_scope[out] location to save the old scope |
1505 | */ | 1513 | */ |
1506 | void | 1514 | void |
1507 | GNUNET_async_scope_enter(const struct GNUNET_AsyncScopeId *aid, | 1515 | GNUNET_async_scope_enter (const struct GNUNET_AsyncScopeId *aid, |
1508 | struct GNUNET_AsyncScopeSave *old_scope); | 1516 | struct GNUNET_AsyncScopeSave *old_scope); |
1509 | 1517 | ||
1510 | 1518 | ||
1511 | /** | 1519 | /** |
@@ -1514,7 +1522,7 @@ GNUNET_async_scope_enter(const struct GNUNET_AsyncScopeId *aid, | |||
1514 | * @param old_scope scope to restore | 1522 | * @param old_scope scope to restore |
1515 | */ | 1523 | */ |
1516 | void | 1524 | void |
1517 | GNUNET_async_scope_restore(struct GNUNET_AsyncScopeSave *old_scope); | 1525 | GNUNET_async_scope_restore (struct GNUNET_AsyncScopeSave *old_scope); |
1518 | 1526 | ||
1519 | 1527 | ||
1520 | /** | 1528 | /** |
@@ -1523,7 +1531,7 @@ GNUNET_async_scope_restore(struct GNUNET_AsyncScopeSave *old_scope); | |||
1523 | * @param[out] scope_ret pointer to where the result is stored | 1531 | * @param[out] scope_ret pointer to where the result is stored |
1524 | */ | 1532 | */ |
1525 | void | 1533 | void |
1526 | GNUNET_async_scope_get(struct GNUNET_AsyncScopeSave *scope_ret); | 1534 | GNUNET_async_scope_get (struct GNUNET_AsyncScopeSave *scope_ret); |
1527 | 1535 | ||
1528 | 1536 | ||
1529 | /** | 1537 | /** |
@@ -1532,7 +1540,7 @@ GNUNET_async_scope_get(struct GNUNET_AsyncScopeSave *scope_ret); | |||
1532 | * @param[out] aid_ret pointer to where the result is stored | 1540 | * @param[out] aid_ret pointer to where the result is stored |
1533 | */ | 1541 | */ |
1534 | void | 1542 | void |
1535 | GNUNET_async_scope_fresh(struct GNUNET_AsyncScopeId *aid_ret); | 1543 | GNUNET_async_scope_fresh (struct GNUNET_AsyncScopeId *aid_ret); |
1536 | 1544 | ||
1537 | 1545 | ||
1538 | #if __STDC_VERSION__ < 199901L | 1546 | #if __STDC_VERSION__ < 199901L |
@@ -1551,7 +1559,8 @@ GNUNET_async_scope_fresh(struct GNUNET_AsyncScopeId *aid_ret); | |||
1551 | * be in gnunet_scheduler_lib.h, but it works if we declare it here. | 1559 | * be in gnunet_scheduler_lib.h, but it works if we declare it here. |
1552 | * Naturally, logically this is part of the scheduler. | 1560 | * Naturally, logically this is part of the scheduler. |
1553 | */ | 1561 | */ |
1554 | enum GNUNET_SCHEDULER_Priority { | 1562 | enum GNUNET_SCHEDULER_Priority |
1563 | { | ||
1555 | /** | 1564 | /** |
1556 | * Run with the same priority as the current job. | 1565 | * Run with the same priority as the current job. |
1557 | */ | 1566 | */ |