summaryrefslogtreecommitdiff
path: root/src/util/common_logging.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/common_logging.c')
-rw-r--r--src/util/common_logging.c1083
1 files changed, 546 insertions, 537 deletions
diff --git a/src/util/common_logging.c b/src/util/common_logging.c
index d3666ae7d..4c7a5291f 100644
--- a/src/util/common_logging.c
+++ b/src/util/common_logging.c
@@ -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 util/common_logging.c 22 * @file util/common_logging.c
@@ -77,8 +77,7 @@
77/** 77/**
78 * Linked list of active loggers. 78 * Linked list of active loggers.
79 */ 79 */
80struct CustomLogger 80struct CustomLogger {
81{
82 /** 81 /**
83 * This is a linked list. 82 * This is a linked list.
84 */ 83 */
@@ -167,8 +166,7 @@ static FILE *GNUNET_stderr;
167/** 166/**
168 * Represents a single logging definition 167 * Represents a single logging definition
169 */ 168 */
170struct LogDef 169struct LogDef {
171{
172 /** 170 /**
173 * Component name regex 171 * Component name regex
174 */ 172 */
@@ -211,7 +209,7 @@ struct LogDef
211}; 209};
212 210
213 211
214#if ! defined(GNUNET_CULL_LOGGING) 212#if !defined(GNUNET_CULL_LOGGING)
215/** 213/**
216 * Dynamic array of logging definitions 214 * Dynamic array of logging definitions
217 */ 215 */
@@ -259,21 +257,21 @@ static LARGE_INTEGER performance_frequency;
259 * @return GNUNET_GE_INVALID if log does not parse 257 * @return GNUNET_GE_INVALID if log does not parse
260 */ 258 */
261static enum GNUNET_ErrorType 259static enum GNUNET_ErrorType
262get_type (const char *log) 260get_type(const char *log)
263{ 261{
264 if (NULL == log) 262 if (NULL == log)
265 return GNUNET_ERROR_TYPE_UNSPECIFIED; 263 return GNUNET_ERROR_TYPE_UNSPECIFIED;
266 if (0 == strcasecmp (log, _ ("DEBUG"))) 264 if (0 == strcasecmp(log, _("DEBUG")))
267 return GNUNET_ERROR_TYPE_DEBUG; 265 return GNUNET_ERROR_TYPE_DEBUG;
268 if (0 == strcasecmp (log, _ ("INFO"))) 266 if (0 == strcasecmp(log, _("INFO")))
269 return GNUNET_ERROR_TYPE_INFO; 267 return GNUNET_ERROR_TYPE_INFO;
270 if (0 == strcasecmp (log, _ ("MESSAGE"))) 268 if (0 == strcasecmp(log, _("MESSAGE")))
271 return GNUNET_ERROR_TYPE_MESSAGE; 269 return GNUNET_ERROR_TYPE_MESSAGE;
272 if (0 == strcasecmp (log, _ ("WARNING"))) 270 if (0 == strcasecmp(log, _("WARNING")))
273 return GNUNET_ERROR_TYPE_WARNING; 271 return GNUNET_ERROR_TYPE_WARNING;
274 if (0 == strcasecmp (log, _ ("ERROR"))) 272 if (0 == strcasecmp(log, _("ERROR")))
275 return GNUNET_ERROR_TYPE_ERROR; 273 return GNUNET_ERROR_TYPE_ERROR;
276 if (0 == strcasecmp (log, _ ("NONE"))) 274 if (0 == strcasecmp(log, _("NONE")))
277 return GNUNET_ERROR_TYPE_NONE; 275 return GNUNET_ERROR_TYPE_NONE;
278 return GNUNET_ERROR_TYPE_INVALID; 276 return GNUNET_ERROR_TYPE_INVALID;
279} 277}
@@ -283,35 +281,35 @@ get_type (const char *log)
283 * Abort the process, generate a core dump if possible. 281 * Abort the process, generate a core dump if possible.
284 */ 282 */
285void 283void
286GNUNET_abort_ () 284GNUNET_abort_()
287{ 285{
288#if WINDOWS 286#if WINDOWS
289 DebugBreak (); 287 DebugBreak();
290#endif 288#endif
291 abort (); 289 abort();
292} 290}
293 291
294 292
295#if ! defined(GNUNET_CULL_LOGGING) 293#if !defined(GNUNET_CULL_LOGGING)
296/** 294/**
297 * Utility function - reallocates logdefs array to be twice as large. 295 * Utility function - reallocates logdefs array to be twice as large.
298 */ 296 */
299static void 297static void
300resize_logdefs () 298resize_logdefs()
301{ 299{
302 logdefs_size = (logdefs_size + 1) * 2; 300 logdefs_size = (logdefs_size + 1) * 2;
303 logdefs = GNUNET_realloc (logdefs, logdefs_size * sizeof (struct LogDef)); 301 logdefs = GNUNET_realloc(logdefs, logdefs_size * sizeof(struct LogDef));
304} 302}
305 303
306 304
307#if ! TALER_WALLET_ONLY 305#if !TALER_WALLET_ONLY
308/** 306/**
309 * Rotate logs, deleting the oldest log. 307 * Rotate logs, deleting the oldest log.
310 * 308 *
311 * @param new_name new name to add to the rotation 309 * @param new_name new name to add to the rotation
312 */ 310 */
313static void 311static void
314log_rotate (const char *new_name) 312log_rotate(const char *new_name)
315{ 313{
316 static char *rotation[ROTATION_KEEP]; 314 static char *rotation[ROTATION_KEEP];
317 static unsigned int rotation_off; 315 static unsigned int rotation_off;
@@ -321,13 +319,13 @@ log_rotate (const char *new_name)
321 return; /* not a real log file name */ 319 return; /* not a real log file name */
322 discard = rotation[rotation_off % ROTATION_KEEP]; 320 discard = rotation[rotation_off % ROTATION_KEEP];
323 if (NULL != discard) 321 if (NULL != discard)
324 { 322 {
325 /* Note: can't log errors during logging (recursion!), so this 323 /* Note: can't log errors during logging (recursion!), so this
326 operation MUST silently fail... */ 324 operation MUST silently fail... */
327 (void) unlink (discard); 325 (void)unlink(discard);
328 GNUNET_free (discard); 326 GNUNET_free(discard);
329 } 327 }
330 rotation[rotation_off % ROTATION_KEEP] = GNUNET_strdup (new_name); 328 rotation[rotation_off % ROTATION_KEEP] = GNUNET_strdup(new_name);
331 rotation_off++; 329 rotation_off++;
332} 330}
333 331
@@ -339,7 +337,7 @@ log_rotate (const char *new_name)
339 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error 337 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
340 */ 338 */
341static int 339static int
342setup_log_file (const struct tm *tm) 340setup_log_file(const struct tm *tm)
343{ 341{
344 static char last_fn[PATH_MAX + 1]; 342 static char last_fn[PATH_MAX + 1];
345 char fn[PATH_MAX + 1]; 343 char fn[PATH_MAX + 1];
@@ -350,68 +348,68 @@ setup_log_file (const struct tm *tm)
350 348
351 if (NULL == log_file_name) 349 if (NULL == log_file_name)
352 return GNUNET_SYSERR; 350 return GNUNET_SYSERR;
353 if (0 == strftime (fn, sizeof (fn), log_file_name, tm)) 351 if (0 == strftime(fn, sizeof(fn), log_file_name, tm))
354 return GNUNET_SYSERR; 352 return GNUNET_SYSERR;
355 leftsquare = strrchr (fn, '['); 353 leftsquare = strrchr(fn, '[');
356 if ((NULL != leftsquare) && (']' == leftsquare[1])) 354 if ((NULL != leftsquare) && (']' == leftsquare[1]))
357 { 355 {
358 char *logfile_copy = GNUNET_strdup (fn); 356 char *logfile_copy = GNUNET_strdup(fn);
359 357
360 logfile_copy[leftsquare - fn] = '\0'; 358 logfile_copy[leftsquare - fn] = '\0';
361 logfile_copy[leftsquare - fn + 1] = '\0'; 359 logfile_copy[leftsquare - fn + 1] = '\0';
362 snprintf (fn, 360 snprintf(fn,
363 PATH_MAX, 361 PATH_MAX,
364 "%s%d%s", 362 "%s%d%s",
365 logfile_copy, 363 logfile_copy,
366 getpid (), 364 getpid(),
367 &logfile_copy[leftsquare - fn + 2]); 365 &logfile_copy[leftsquare - fn + 2]);
368 GNUNET_free (logfile_copy); 366 GNUNET_free(logfile_copy);
369 } 367 }
370 if (0 == strcmp (fn, last_fn)) 368 if (0 == strcmp(fn, last_fn))
371 return GNUNET_OK; /* no change */ 369 return GNUNET_OK; /* no change */
372 log_rotate (last_fn); 370 log_rotate(last_fn);
373 strcpy (last_fn, fn); 371 strcpy(last_fn, fn);
374 if (GNUNET_SYSERR == GNUNET_DISK_directory_create_for_file (fn)) 372 if (GNUNET_SYSERR == GNUNET_DISK_directory_create_for_file(fn))
375 { 373 {
376 fprintf (stderr, 374 fprintf(stderr,
377 "Failed to create directory for `%s': %s\n", 375 "Failed to create directory for `%s': %s\n",
378 fn, 376 fn,
379 strerror (errno)); 377 strerror(errno));
380 return GNUNET_SYSERR; 378 return GNUNET_SYSERR;
381 } 379 }
382#if WINDOWS 380#if WINDOWS
383 altlog_fd = 381 altlog_fd =
384 open (fn, O_APPEND | O_BINARY | O_WRONLY | O_CREAT, _S_IREAD | _S_IWRITE); 382 open(fn, O_APPEND | O_BINARY | O_WRONLY | O_CREAT, _S_IREAD | _S_IWRITE);
385#else 383#else
386 altlog_fd = open (fn, 384 altlog_fd = open(fn,
387 O_APPEND | O_WRONLY | O_CREAT, 385 O_APPEND | O_WRONLY | O_CREAT,
388 S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); 386 S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
389#endif 387#endif
390 if (-1 != altlog_fd) 388 if (-1 != altlog_fd)
391 {
392 if (NULL != GNUNET_stderr)
393 fclose (GNUNET_stderr);
394 dup_return = dup2 (altlog_fd, 2);
395 (void) close (altlog_fd);
396 if (-1 != dup_return)
397 { 389 {
398 altlog = fdopen (2, "ab"); 390 if (NULL != GNUNET_stderr)
399 if (NULL == altlog) 391 fclose(GNUNET_stderr);
400 { 392 dup_return = dup2(altlog_fd, 2);
401 (void) close (2); 393 (void)close(altlog_fd);
402 altlog_fd = -1; 394 if (-1 != dup_return)
403 } 395 {
396 altlog = fdopen(2, "ab");
397 if (NULL == altlog)
398 {
399 (void)close(2);
400 altlog_fd = -1;
401 }
402 }
403 else
404 {
405 altlog_fd = -1;
406 }
404 } 407 }
405 else 408 if (-1 == altlog_fd)
406 { 409 {
407 altlog_fd = -1; 410 GNUNET_log_strerror_file(GNUNET_ERROR_TYPE_ERROR, "open", fn);
411 return GNUNET_SYSERR;
408 } 412 }
409 }
410 if (-1 == altlog_fd)
411 {
412 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "open", fn);
413 return GNUNET_SYSERR;
414 }
415 GNUNET_stderr = altlog; 413 GNUNET_stderr = altlog;
416 return GNUNET_OK; 414 return GNUNET_OK;
417} 415}
@@ -431,44 +429,44 @@ setup_log_file (const struct tm *tm)
431 * @return 0 on success, regex-specific error otherwise 429 * @return 0 on success, regex-specific error otherwise
432 */ 430 */
433static int 431static int
434add_definition (const char *component, 432add_definition(const char *component,
435 const char *file, 433 const char *file,
436 const char *function, 434 const char *function,
437 int from_line, 435 int from_line,
438 int to_line, 436 int to_line,
439 int level, 437 int level,
440 int force) 438 int force)
441{ 439{
442 struct LogDef n; 440 struct LogDef n;
443 int r; 441 int r;
444 442
445 if (logdefs_size == logdefs_len) 443 if (logdefs_size == logdefs_len)
446 resize_logdefs (); 444 resize_logdefs();
447 memset (&n, 0, sizeof (n)); 445 memset(&n, 0, sizeof(n));
448 if (0 == strlen (component)) 446 if (0 == strlen(component))
449 component = (char *) ".*"; 447 component = (char *)".*";
450 r = regcomp (&n.component_regex, (const char *) component, REG_NOSUB); 448 r = regcomp(&n.component_regex, (const char *)component, REG_NOSUB);
451 if (0 != r) 449 if (0 != r)
452 { 450 {
453 return r; 451 return r;
454 } 452 }
455 if (0 == strlen (file)) 453 if (0 == strlen(file))
456 file = (char *) ".*"; 454 file = (char *)".*";
457 r = regcomp (&n.file_regex, (const char *) file, REG_NOSUB); 455 r = regcomp(&n.file_regex, (const char *)file, REG_NOSUB);
458 if (0 != r) 456 if (0 != r)
459 { 457 {
460 regfree (&n.component_regex); 458 regfree(&n.component_regex);
461 return r; 459 return r;
462 } 460 }
463 if ((NULL == function) || (0 == strlen (function))) 461 if ((NULL == function) || (0 == strlen(function)))
464 function = (char *) ".*"; 462 function = (char *)".*";
465 r = regcomp (&n.function_regex, (const char *) function, REG_NOSUB); 463 r = regcomp(&n.function_regex, (const char *)function, REG_NOSUB);
466 if (0 != r) 464 if (0 != r)
467 { 465 {
468 regfree (&n.component_regex); 466 regfree(&n.component_regex);
469 regfree (&n.file_regex); 467 regfree(&n.file_regex);
470 return r; 468 return r;
471 } 469 }
472 n.from_line = from_line; 470 n.from_line = from_line;
473 n.to_line = to_line; 471 n.to_line = to_line;
474 n.level = level; 472 n.level = level;
@@ -492,11 +490,11 @@ add_definition (const char *component,
492 * @return 0 to disallow the call, 1 to allow it 490 * @return 0 to disallow the call, 1 to allow it
493 */ 491 */
494int 492int
495GNUNET_get_log_call_status (int caller_level, 493GNUNET_get_log_call_status(int caller_level,
496 const char *comp, 494 const char *comp,
497 const char *file, 495 const char *file,
498 const char *function, 496 const char *function,
499 int line) 497 int line)
500{ 498{
501 struct LogDef *ld; 499 struct LogDef *ld;
502 int i; 500 int i;
@@ -515,18 +513,18 @@ GNUNET_get_log_call_status (int caller_level,
515 /* Only look for forced definitions? */ 513 /* Only look for forced definitions? */
516 force_only = min_level >= 0; 514 force_only = min_level >= 0;
517 for (i = 0; i < logdefs_len; i++) 515 for (i = 0; i < logdefs_len; i++)
518 {
519 ld = &logdefs[i];
520 if (((! force_only) || ld->force) &&
521 (line >= ld->from_line && line <= ld->to_line) &&
522 (0 == regexec (&ld->component_regex, comp, 0, NULL, 0)) &&
523 (0 == regexec (&ld->file_regex, file, 0, NULL, 0)) &&
524 (0 == regexec (&ld->function_regex, function, 0, NULL, 0)))
525 { 516 {
526 /* We're finished */ 517 ld = &logdefs[i];
527 return caller_level <= ld->level; 518 if (((!force_only) || ld->force) &&
519 (line >= ld->from_line && line <= ld->to_line) &&
520 (0 == regexec(&ld->component_regex, comp, 0, NULL, 0)) &&
521 (0 == regexec(&ld->file_regex, file, 0, NULL, 0)) &&
522 (0 == regexec(&ld->function_regex, function, 0, NULL, 0)))
523 {
524 /* We're finished */
525 return caller_level <= ld->level;
526 }
528 } 527 }
529 }
530 /* No matches - use global level, if defined */ 528 /* No matches - use global level, if defined */
531 if (min_level >= 0) 529 if (min_level >= 0)
532 return caller_level <= min_level; 530 return caller_level <= min_level;
@@ -562,7 +560,7 @@ GNUNET_get_log_call_status (int caller_level,
562 * @return number of added definitions 560 * @return number of added definitions
563 */ 561 */
564static int 562static int
565parse_definitions (const char *constname, int force) 563parse_definitions(const char *constname, int force)
566{ 564{
567 char *def; 565 char *def;
568 const char *tmp; 566 const char *tmp;
@@ -578,108 +576,116 @@ parse_definitions (const char *constname, int force)
578 int counter = 0; 576 int counter = 0;
579 int keep_looking = 1; 577 int keep_looking = 1;
580 578
581 tmp = getenv (constname); 579 tmp = getenv(constname);
582 if (NULL == tmp) 580 if (NULL == tmp)
583 return 0; 581 return 0;
584 def = GNUNET_strdup (tmp); 582 def = GNUNET_strdup(tmp);
585 from_line = 0; 583 from_line = 0;
586 to_line = INT_MAX; 584 to_line = INT_MAX;
587 for (p = def, state = 0, start = def; keep_looking; p++) 585 for (p = def, state = 0, start = def; keep_looking; p++)
588 {
589 switch (p[0])
590 { 586 {
591 case ';': /* found a field separator */ 587 switch (p[0])
592 p[0] = '\0';
593 switch (state)
594 {
595 case 0: /* within a component name */
596 comp = start;
597 break;
598 case 1: /* within a file name */
599 file = start;
600 break;
601 case 2: /* within a function name */
602 /* after a file name there must be a function name */
603 function = start;
604 break;
605 case 3: /* within a from-to line range */
606 if (strlen (start) > 0)
607 { 588 {
608 errno = 0; 589 case ';': /* found a field separator */
609 from_line = strtol (start, &t, 10); 590 p[0] = '\0';
610 if ((0 != errno) || (from_line < 0)) 591 switch (state)
611 {
612 GNUNET_free (def);
613 return counter;
614 }
615 if ((t < p) && ('-' == t[0]))
616 {
617 errno = 0;
618 start = t + 1;
619 to_line = strtol (start, &t, 10);
620 if ((0 != errno) || (to_line < 0) || (t != p))
621 { 592 {
622 GNUNET_free (def); 593 case 0: /* within a component name */
623 return counter; 594 comp = start;
595 break;
596
597 case 1: /* within a file name */
598 file = start;
599 break;
600
601 case 2: /* within a function name */
602 /* after a file name there must be a function name */
603 function = start;
604 break;
605
606 case 3: /* within a from-to line range */
607 if (strlen(start) > 0)
608 {
609 errno = 0;
610 from_line = strtol(start, &t, 10);
611 if ((0 != errno) || (from_line < 0))
612 {
613 GNUNET_free(def);
614 return counter;
615 }
616 if ((t < p) && ('-' == t[0]))
617 {
618 errno = 0;
619 start = t + 1;
620 to_line = strtol(start, &t, 10);
621 if ((0 != errno) || (to_line < 0) || (t != p))
622 {
623 GNUNET_free(def);
624 return counter;
625 }
626 }
627 else /* one number means "match this line only" */
628 to_line = from_line;
629 }
630 else /* default to 0-max */
631 {
632 from_line = 0;
633 to_line = INT_MAX;
634 }
635 break;
636
637 default:
638 fprintf(
639 stderr,
640 _("ERROR: Unable to parse log definition: Syntax error at `%s'.\n"),
641 p);
642 break;
624 } 643 }
625 } 644 start = p + 1;
626 else /* one number means "match this line only" */ 645 state++;
627 to_line = from_line; 646 break;
628 } 647
629 else /* default to 0-max */ 648 case '\0': /* found EOL */
630 { 649 keep_looking = 0;
631 from_line = 0; 650
632 to_line = INT_MAX; 651 /* fall through to '/' */
633 } 652 case '/': /* found a definition separator */
634 break; 653 switch (state)
635 default: 654 {
636 fprintf ( 655 case 4: /* within a log level */
637 stderr, 656 p[0] = '\0';
638 _ ("ERROR: Unable to parse log definition: Syntax error at `%s'.\n"), 657 state = 0;
639 p); 658 level = get_type((const char *)start);
640 break; 659 if ((GNUNET_ERROR_TYPE_INVALID == level) ||
641 } 660 (GNUNET_ERROR_TYPE_UNSPECIFIED == level) ||
642 start = p + 1; 661 (0 != add_definition(comp,
643 state++; 662 file,
644 break; 663 function,
645 case '\0': /* found EOL */ 664 from_line,
646 keep_looking = 0; 665 to_line,
647 /* fall through to '/' */ 666 level,
648 case '/': /* found a definition separator */ 667 force)))
649 switch (state) 668 {
650 { 669 GNUNET_free(def);
651 case 4: /* within a log level */ 670 return counter;
652 p[0] = '\0'; 671 }
653 state = 0; 672 counter++;
654 level = get_type ((const char *) start); 673 start = p + 1;
655 if ((GNUNET_ERROR_TYPE_INVALID == level) || 674 break;
656 (GNUNET_ERROR_TYPE_UNSPECIFIED == level) || 675
657 (0 != add_definition (comp, 676 default:
658 file, 677 fprintf(
659 function, 678 stderr,
660 from_line, 679 _("ERROR: Unable to parse log definition: Syntax error at `%s'.\n"),
661 to_line, 680 p);
662 level, 681 break;
663 force))) 682 }
664 { 683
665 GNUNET_free (def); 684 default:
666 return counter; 685 break;
667 } 686 }
668 counter++;
669 start = p + 1;
670 break;
671 default:
672 fprintf (
673 stderr,
674 _ ("ERROR: Unable to parse log definition: Syntax error at `%s'.\n"),
675 p);
676 break;
677 }
678 default:
679 break;
680 } 687 }
681 } 688 GNUNET_free(def);
682 GNUNET_free (def);
683 return counter; 689 return counter;
684} 690}
685 691
@@ -688,15 +694,15 @@ parse_definitions (const char *constname, int force)
688 * Utility function - parses GNUNET_LOG and GNUNET_FORCE_LOG. 694 * Utility function - parses GNUNET_LOG and GNUNET_FORCE_LOG.
689 */ 695 */
690static void 696static void
691parse_all_definitions () 697parse_all_definitions()
692{ 698{
693 if (GNUNET_NO == gnunet_force_log_parsed) 699 if (GNUNET_NO == gnunet_force_log_parsed)
694 gnunet_force_log_present = 700 gnunet_force_log_present =
695 parse_definitions ("GNUNET_FORCE_LOG", 1) > 0 ? GNUNET_YES : GNUNET_NO; 701 parse_definitions("GNUNET_FORCE_LOG", 1) > 0 ? GNUNET_YES : GNUNET_NO;
696 gnunet_force_log_parsed = GNUNET_YES; 702 gnunet_force_log_parsed = GNUNET_YES;
697 703
698 if (GNUNET_NO == gnunet_log_parsed) 704 if (GNUNET_NO == gnunet_log_parsed)
699 parse_definitions ("GNUNET_LOG", 0); 705 parse_definitions("GNUNET_LOG", 0);
700 gnunet_log_parsed = GNUNET_YES; 706 gnunet_log_parsed = GNUNET_YES;
701} 707}
702#endif 708#endif
@@ -711,43 +717,43 @@ parse_all_definitions ()
711 * @return #GNUNET_OK on success 717 * @return #GNUNET_OK on success
712 */ 718 */
713int 719int
714GNUNET_log_setup (const char *comp, const char *loglevel, const char *logfile) 720GNUNET_log_setup(const char *comp, const char *loglevel, const char *logfile)
715{ 721{
716 const char *env_logfile; 722 const char *env_logfile;
717 723
718 min_level = get_type (loglevel); 724 min_level = get_type(loglevel);
719#if ! defined(GNUNET_CULL_LOGGING) 725#if !defined(GNUNET_CULL_LOGGING)
720 parse_all_definitions (); 726 parse_all_definitions();
721#endif 727#endif
722#ifdef WINDOWS 728#ifdef WINDOWS
723 QueryPerformanceFrequency (&performance_frequency); 729 QueryPerformanceFrequency(&performance_frequency);
724#endif 730#endif
725 GNUNET_free_non_null (component); 731 GNUNET_free_non_null(component);
726 GNUNET_asprintf (&component, "%s-%d", comp, getpid ()); 732 GNUNET_asprintf(&component, "%s-%d", comp, getpid());
727 GNUNET_free_non_null (component_nopid); 733 GNUNET_free_non_null(component_nopid);
728 component_nopid = GNUNET_strdup (comp); 734 component_nopid = GNUNET_strdup(comp);
729 735
730 env_logfile = getenv ("GNUNET_FORCE_LOGFILE"); 736 env_logfile = getenv("GNUNET_FORCE_LOGFILE");
731 if ((NULL != env_logfile) && (strlen (env_logfile) > 0)) 737 if ((NULL != env_logfile) && (strlen(env_logfile) > 0))
732 logfile = env_logfile; 738 logfile = env_logfile;
733 if (NULL == logfile) 739 if (NULL == logfile)
734 return GNUNET_OK; 740 return GNUNET_OK;
735 GNUNET_free_non_null (log_file_name); 741 GNUNET_free_non_null(log_file_name);
736 log_file_name = GNUNET_STRINGS_filename_expand (logfile); 742 log_file_name = GNUNET_STRINGS_filename_expand(logfile);
737 if (NULL == log_file_name) 743 if (NULL == log_file_name)
738 return GNUNET_SYSERR; 744 return GNUNET_SYSERR;
739#if TALER_WALLET_ONLY || defined(GNUNET_CULL_LOGGING) 745#if TALER_WALLET_ONLY || defined(GNUNET_CULL_LOGGING)
740 /* log file option not allowed for wallet logic */ 746 /* log file option not allowed for wallet logic */
741 GNUNET_assert (NULL == logfile); 747 GNUNET_assert(NULL == logfile);
742 return GNUNET_OK; 748 return GNUNET_OK;
743#else 749#else
744 { 750 {
745 time_t t; 751 time_t t;
746 const struct tm *tm; 752 const struct tm *tm;
747 753
748 t = time (NULL); 754 t = time(NULL);
749 tm = gmtime (&t); 755 tm = gmtime(&t);
750 return setup_log_file (tm); 756 return setup_log_file(tm);
751 } 757 }
752#endif 758#endif
753} 759}
@@ -763,11 +769,11 @@ GNUNET_log_setup (const char *comp, const char *loglevel, const char *logfile)
763 * @param logger_cls closure for @a logger 769 * @param logger_cls closure for @a logger
764 */ 770 */
765void 771void
766GNUNET_logger_add (GNUNET_Logger logger, void *logger_cls) 772GNUNET_logger_add(GNUNET_Logger logger, void *logger_cls)
767{ 773{
768 struct CustomLogger *entry; 774 struct CustomLogger *entry;
769 775
770 entry = GNUNET_new (struct CustomLogger); 776 entry = GNUNET_new(struct CustomLogger);
771 entry->logger = logger; 777 entry->logger = logger;
772 entry->logger_cls = logger_cls; 778 entry->logger_cls = logger_cls;
773 entry->next = loggers; 779 entry->next = loggers;
@@ -782,7 +788,7 @@ GNUNET_logger_add (GNUNET_Logger logger, void *logger_cls)
782 * @param logger_cls closure for @a logger 788 * @param logger_cls closure for @a logger
783 */ 789 */
784void 790void
785GNUNET_logger_remove (GNUNET_Logger logger, void *logger_cls) 791GNUNET_logger_remove(GNUNET_Logger logger, void *logger_cls)
786{ 792{
787 struct CustomLogger *pos; 793 struct CustomLogger *pos;
788 struct CustomLogger *prev; 794 struct CustomLogger *prev;
@@ -791,16 +797,16 @@ GNUNET_logger_remove (GNUNET_Logger logger, void *logger_cls)
791 pos = loggers; 797 pos = loggers;
792 while ((NULL != pos) && 798 while ((NULL != pos) &&
793 ((pos->logger != logger) || (pos->logger_cls != logger_cls))) 799 ((pos->logger != logger) || (pos->logger_cls != logger_cls)))
794 { 800 {
795 prev = pos; 801 prev = pos;
796 pos = pos->next; 802 pos = pos->next;
797 } 803 }
798 GNUNET_assert (NULL != pos); 804 GNUNET_assert(NULL != pos);
799 if (NULL == prev) 805 if (NULL == prev)
800 loggers = pos->next; 806 loggers = pos->next;
801 else 807 else
802 prev->next = pos->next; 808 prev->next = pos->next;
803 GNUNET_free (pos); 809 GNUNET_free(pos);
804} 810}
805 811
806#if WINDOWS 812#if WINDOWS
@@ -817,72 +823,72 @@ CRITICAL_SECTION output_message_cs;
817 * @param msg the actual message 823 * @param msg the actual message
818 */ 824 */
819static void 825static void
820output_message (enum GNUNET_ErrorType kind, 826output_message(enum GNUNET_ErrorType kind,
821 const char *comp, 827 const char *comp,
822 const char *datestr, 828 const char *datestr,
823 const char *msg) 829 const char *msg)
824{ 830{
825 struct CustomLogger *pos; 831 struct CustomLogger *pos;
826 832
827#if WINDOWS 833#if WINDOWS
828 EnterCriticalSection (&output_message_cs); 834 EnterCriticalSection(&output_message_cs);
829#endif 835#endif
830 /* only use the standard logger if no custom loggers are present */ 836 /* only use the standard logger if no custom loggers are present */
831 if ((NULL != GNUNET_stderr) && (NULL == loggers)) 837 if ((NULL != GNUNET_stderr) && (NULL == loggers))
832 {
833 if (kind == GNUNET_ERROR_TYPE_MESSAGE)
834 { 838 {
835 /* The idea here is to produce "normal" output messages 839 if (kind == GNUNET_ERROR_TYPE_MESSAGE)
836 * for end users while still having the power of the 840 {
837 * logging engine for developer needs. So ideally this 841 /* The idea here is to produce "normal" output messages
838 * is what it should look like when CLI tools are used 842 * for end users while still having the power of the
839 * interactively, yet the same message shouldn't look 843 * logging engine for developer needs. So ideally this
840 * this way if the output is going to logfiles or robots 844 * is what it should look like when CLI tools are used
841 * instead. 845 * interactively, yet the same message shouldn't look
842 */ 846 * this way if the output is going to logfiles or robots
843 fprintf (GNUNET_stderr, "* %s", msg); 847 * instead.
844 } 848 */
845 else if (GNUNET_YES == current_async_scope.have_scope) 849 fprintf(GNUNET_stderr, "* %s", msg);
846 { 850 }
847 static GNUNET_THREAD_LOCAL char id_buf[27]; 851 else if (GNUNET_YES == current_async_scope.have_scope)
848 char *end; 852 {
849 853 static GNUNET_THREAD_LOCAL char id_buf[27];
850 /* We're logging, so skip_log must be currently 0. */ 854 char *end;
851 skip_log = 100; 855
852 end = GNUNET_STRINGS_data_to_string (&current_async_scope.scope_id, 856 /* We're logging, so skip_log must be currently 0. */
853 sizeof (struct GNUNET_AsyncScopeId), 857 skip_log = 100;
854 id_buf, 858 end = GNUNET_STRINGS_data_to_string(&current_async_scope.scope_id,
855 sizeof (id_buf) - 1); 859 sizeof(struct GNUNET_AsyncScopeId),
856 GNUNET_assert (NULL != end); 860 id_buf,
857 *end = '\0'; 861 sizeof(id_buf) - 1);
858 skip_log = 0; 862 GNUNET_assert(NULL != end);
859 fprintf (GNUNET_stderr, 863 *end = '\0';
860 "%s %s(%s) %s %s", 864 skip_log = 0;
861 datestr, 865 fprintf(GNUNET_stderr,
862 comp, 866 "%s %s(%s) %s %s",
863 id_buf, 867 datestr,
864 GNUNET_error_type_to_string (kind), 868 comp,
865 msg); 869 id_buf,
866 } 870 GNUNET_error_type_to_string(kind),
867 else 871 msg);
868 { 872 }
869 fprintf (GNUNET_stderr, 873 else
870 "%s %s %s %s", 874 {
871 datestr, 875 fprintf(GNUNET_stderr,
872 comp, 876 "%s %s %s %s",
873 GNUNET_error_type_to_string (kind), 877 datestr,
874 msg); 878 comp,
879 GNUNET_error_type_to_string(kind),
880 msg);
881 }
882 fflush(GNUNET_stderr);
875 } 883 }
876 fflush (GNUNET_stderr);
877 }
878 pos = loggers; 884 pos = loggers;
879 while (NULL != pos) 885 while (NULL != pos)
880 { 886 {
881 pos->logger (pos->logger_cls, kind, comp, datestr, msg); 887 pos->logger(pos->logger_cls, kind, comp, datestr, msg);
882 pos = pos->next; 888 pos = pos->next;
883 } 889 }
884#if WINDOWS 890#if WINDOWS
885 LeaveCriticalSection (&output_message_cs); 891 LeaveCriticalSection(&output_message_cs);
886#endif 892#endif
887} 893}
888 894
@@ -893,7 +899,7 @@ output_message (enum GNUNET_ErrorType kind,
893 * @param datestr our current timestamp 899 * @param datestr our current timestamp
894 */ 900 */
895static void 901static void
896flush_bulk (const char *datestr) 902flush_bulk(const char *datestr)
897{ 903{
898 char msg[DATE_STR_SIZE + BULK_TRACK_SIZE + 256]; 904 char msg[DATE_STR_SIZE + BULK_TRACK_SIZE + 256];
899 int rev; 905 int rev;
@@ -903,31 +909,31 @@ flush_bulk (const char *datestr)
903 if ((0 == last_bulk_time.abs_value_us) || (0 == last_bulk_repeat)) 909 if ((0 == last_bulk_time.abs_value_us) || (0 == last_bulk_repeat))
904 return; 910 return;
905 rev = 0; 911 rev = 0;
906 last = memchr (last_bulk, '\0', BULK_TRACK_SIZE); 912 last = memchr(last_bulk, '\0', BULK_TRACK_SIZE);
907 if (last == NULL) 913 if (last == NULL)
908 last = &last_bulk[BULK_TRACK_SIZE - 1]; 914 last = &last_bulk[BULK_TRACK_SIZE - 1];
909 else if (last != last_bulk) 915 else if (last != last_bulk)
910 last--; 916 last--;
911 if (last[0] == '\n') 917 if (last[0] == '\n')
912 { 918 {
913 rev = 1; 919 rev = 1;
914 last[0] = '\0'; 920 last[0] = '\0';
915 } 921 }
916 ft = 922 ft =
917 GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_duration ( 923 GNUNET_STRINGS_relative_time_to_string(GNUNET_TIME_absolute_get_duration(
918 last_bulk_time), 924 last_bulk_time),
919 GNUNET_YES); 925 GNUNET_YES);
920 snprintf (msg, 926 snprintf(msg,
921 sizeof (msg), 927 sizeof(msg),
922 _ ("Message `%.*s' repeated %u times in the last %s\n"), 928 _("Message `%.*s' repeated %u times in the last %s\n"),
923 BULK_TRACK_SIZE, 929 BULK_TRACK_SIZE,
924 last_bulk, 930 last_bulk,
925 last_bulk_repeat, 931 last_bulk_repeat,
926 ft); 932 ft);
927 if (rev == 1) 933 if (rev == 1)
928 last[0] = '\n'; 934 last[0] = '\n';
929 output_message (last_bulk_kind, last_bulk_comp, datestr, msg); 935 output_message(last_bulk_kind, last_bulk_comp, datestr, msg);
930 last_bulk_time = GNUNET_TIME_absolute_get (); 936 last_bulk_time = GNUNET_TIME_absolute_get();
931 last_bulk_repeat = 0; 937 last_bulk_repeat = 0;
932} 938}
933 939
@@ -939,21 +945,21 @@ flush_bulk (const char *datestr)
939 * @param check_reset #GNUNET_YES to assert that the log skip counter is currently zero 945 * @param check_reset #GNUNET_YES to assert that the log skip counter is currently zero
940 */ 946 */
941void 947void
942GNUNET_log_skip (int n, int check_reset) 948GNUNET_log_skip(int n, int check_reset)
943{ 949{
944 int ok; 950 int ok;
945 951
946 if (0 == n) 952 if (0 == n)
947 { 953 {
948 ok = (0 == skip_log); 954 ok = (0 == skip_log);
949 skip_log = 0; 955 skip_log = 0;
950 if (check_reset) 956 if (check_reset)
951 GNUNET_break (ok); 957 GNUNET_break(ok);
952 } 958 }
953 else 959 else
954 { 960 {
955 skip_log += n; 961 skip_log += n;
956 } 962 }
957} 963}
958 964
959 965
@@ -963,7 +969,7 @@ GNUNET_log_skip (int n, int check_reset)
963 * @return number of log calls to be ignored 969 * @return number of log calls to be ignored
964 */ 970 */
965int 971int
966GNUNET_get_log_skip () 972GNUNET_get_log_skip()
967{ 973{
968 return skip_log; 974 return skip_log;
969} 975}
@@ -978,10 +984,10 @@ GNUNET_get_log_skip ()
978 * @param va arguments to the format string "message" 984 * @param va arguments to the format string "message"
979 */ 985 */
980static void 986static void
981mylog (enum GNUNET_ErrorType kind, 987mylog(enum GNUNET_ErrorType kind,
982 const char *comp, 988 const char *comp,
983 const char *message, 989 const char *message,
984 va_list va) 990 va_list va)
985{ 991{
986 char date[DATE_STR_SIZE]; 992 char date[DATE_STR_SIZE];
987 char date2[DATE_STR_SIZE]; 993 char date2[DATE_STR_SIZE];
@@ -989,11 +995,11 @@ mylog (enum GNUNET_ErrorType kind,
989 size_t size; 995 size_t size;
990 va_list vacp; 996 va_list vacp;
991 997
992 va_copy (vacp, va); 998 va_copy(vacp, va);
993 size = vsnprintf (NULL, 0, message, vacp) + 1; 999 size = vsnprintf(NULL, 0, message, vacp) + 1;
994 GNUNET_assert (0 != size); 1000 GNUNET_assert(0 != size);
995 va_end (vacp); 1001 va_end(vacp);
996 memset (date, 0, DATE_STR_SIZE); 1002 memset(date, 0, DATE_STR_SIZE);
997 { 1003 {
998 char buf[size]; 1004 char buf[size];
999 long long offset; 1005 long long offset;
@@ -1001,92 +1007,92 @@ mylog (enum GNUNET_ErrorType kind,
1001 LARGE_INTEGER pc; 1007 LARGE_INTEGER pc;
1002 time_t timetmp; 1008 time_t timetmp;
1003 1009
1004 offset = GNUNET_TIME_get_offset (); 1010 offset = GNUNET_TIME_get_offset();
1005 time (&timetmp); 1011 time(&timetmp);
1006 timetmp += offset / 1000; 1012 timetmp += offset / 1000;
1007 tmptr = localtime (&timetmp); 1013 tmptr = localtime(&timetmp);
1008 pc.QuadPart = 0; 1014 pc.QuadPart = 0;
1009 QueryPerformanceCounter (&pc); 1015 QueryPerformanceCounter(&pc);
1010 if (NULL == tmptr) 1016 if (NULL == tmptr)
1011 { 1017 {
1012 strcpy (date, "localtime error"); 1018 strcpy(date, "localtime error");
1013 } 1019 }
1014 else 1020 else
1015 { 1021 {
1016 if (0 == 1022 if (0 ==
1017 strftime (date2, DATE_STR_SIZE, "%b %d %H:%M:%S-%%020llu", tmptr)) 1023 strftime(date2, DATE_STR_SIZE, "%b %d %H:%M:%S-%%020llu", tmptr))
1018 abort (); 1024 abort();
1019 if (0 > snprintf (date, 1025 if (0 > snprintf(date,
1020 sizeof (date), 1026 sizeof(date),
1021 date2, 1027 date2,
1022 (long long) (pc.QuadPart / 1028 (long long)(pc.QuadPart /
1023 (performance_frequency.QuadPart / 1000)))) 1029 (performance_frequency.QuadPart / 1000))))
1024 abort (); 1030 abort();
1025 } 1031 }
1026#else 1032#else
1027 struct timeval timeofday; 1033 struct timeval timeofday;
1028 1034
1029 gettimeofday (&timeofday, NULL); 1035 gettimeofday(&timeofday, NULL);
1030 offset = GNUNET_TIME_get_offset (); 1036 offset = GNUNET_TIME_get_offset();
1031 if (offset > 0) 1037 if (offset > 0)
1032 {
1033 timeofday.tv_sec += offset / 1000LL;
1034 timeofday.tv_usec += (offset % 1000LL) * 1000LL;
1035 if (timeofday.tv_usec > 1000000LL)
1036 { 1038 {
1037 timeofday.tv_usec -= 1000000LL; 1039 timeofday.tv_sec += offset / 1000LL;
1038 timeofday.tv_sec++; 1040 timeofday.tv_usec += (offset % 1000LL) * 1000LL;
1041 if (timeofday.tv_usec > 1000000LL)
1042 {
1043 timeofday.tv_usec -= 1000000LL;
1044 timeofday.tv_sec++;
1045 }
1039 } 1046 }
1040 }
1041 else 1047 else
1042 {
1043 timeofday.tv_sec += offset / 1000LL;
1044 if (timeofday.tv_usec > -(offset % 1000LL) * 1000LL)
1045 { 1048 {
1046 timeofday.tv_usec += (offset % 1000LL) * 1000LL; 1049 timeofday.tv_sec += offset / 1000LL;
1050 if (timeofday.tv_usec > -(offset % 1000LL) * 1000LL)
1051 {
1052 timeofday.tv_usec += (offset % 1000LL) * 1000LL;
1053 }
1054 else
1055 {
1056 timeofday.tv_usec += 1000000LL + (offset % 1000LL) * 1000LL;
1057 timeofday.tv_sec--;
1058 }
1047 } 1059 }
1048 else 1060 tmptr = localtime(&timeofday.tv_sec);
1061 if (NULL == tmptr)
1049 { 1062 {
1050 timeofday.tv_usec += 1000000LL + (offset % 1000LL) * 1000LL; 1063 strcpy(date, "localtime error");
1051 timeofday.tv_sec--;
1052 } 1064 }
1053 }
1054 tmptr = localtime (&timeofday.tv_sec);
1055 if (NULL == tmptr)
1056 {
1057 strcpy (date, "localtime error");
1058 }
1059 else 1065 else
1060 { 1066 {
1061 if (0 == strftime (date2, DATE_STR_SIZE, "%b %d %H:%M:%S-%%06u", tmptr)) 1067 if (0 == strftime(date2, DATE_STR_SIZE, "%b %d %H:%M:%S-%%06u", tmptr))
1062 abort (); 1068 abort();
1063 if (0 > snprintf (date, sizeof (date), date2, timeofday.tv_usec)) 1069 if (0 > snprintf(date, sizeof(date), date2, timeofday.tv_usec))
1064 abort (); 1070 abort();
1065 } 1071 }
1066#endif 1072#endif
1067 vsnprintf (buf, size, message, va); 1073 vsnprintf(buf, size, message, va);
1068#if ! (defined(GNUNET_CULL_LOGGING) || TALER_WALLET_ONLY) 1074#if !(defined(GNUNET_CULL_LOGGING) || TALER_WALLET_ONLY)
1069 if (NULL != tmptr) 1075 if (NULL != tmptr)
1070 (void) setup_log_file (tmptr); 1076 (void)setup_log_file(tmptr);
1071#endif 1077#endif
1072 if ((0 != (kind & GNUNET_ERROR_TYPE_BULK)) && 1078 if ((0 != (kind & GNUNET_ERROR_TYPE_BULK)) &&
1073 (0 != last_bulk_time.abs_value_us) && 1079 (0 != last_bulk_time.abs_value_us) &&
1074 (0 == strncmp (buf, last_bulk, sizeof (last_bulk)))) 1080 (0 == strncmp(buf, last_bulk, sizeof(last_bulk))))
1075 { 1081 {
1076 last_bulk_repeat++; 1082 last_bulk_repeat++;
1077 if ((GNUNET_TIME_absolute_get_duration (last_bulk_time).rel_value_us > 1083 if ((GNUNET_TIME_absolute_get_duration(last_bulk_time).rel_value_us >
1078 BULK_DELAY_THRESHOLD) || 1084 BULK_DELAY_THRESHOLD) ||
1079 (last_bulk_repeat > BULK_REPEAT_THRESHOLD)) 1085 (last_bulk_repeat > BULK_REPEAT_THRESHOLD))
1080 flush_bulk (date); 1086 flush_bulk(date);
1081 return; 1087 return;
1082 } 1088 }
1083 flush_bulk (date); 1089 flush_bulk(date);
1084 GNUNET_strlcpy (last_bulk, buf, sizeof (last_bulk)); 1090 GNUNET_strlcpy(last_bulk, buf, sizeof(last_bulk));
1085 last_bulk_repeat = 0; 1091 last_bulk_repeat = 0;
1086 last_bulk_kind = kind; 1092 last_bulk_kind = kind;
1087 last_bulk_time = GNUNET_TIME_absolute_get (); 1093 last_bulk_time = GNUNET_TIME_absolute_get();
1088 GNUNET_strlcpy (last_bulk_comp, comp, sizeof (last_bulk_comp)); 1094 GNUNET_strlcpy(last_bulk_comp, comp, sizeof(last_bulk_comp));
1089 output_message (kind, comp, date, buf); 1095 output_message(kind, comp, date, buf);
1090 } 1096 }
1091} 1097}
1092 1098
@@ -1099,13 +1105,13 @@ mylog (enum GNUNET_ErrorType kind,
1099 * @param ... arguments for format string 1105 * @param ... arguments for format string
1100 */ 1106 */
1101void 1107void
1102GNUNET_log_nocheck (enum GNUNET_ErrorType kind, const char *message, ...) 1108GNUNET_log_nocheck(enum GNUNET_ErrorType kind, const char *message, ...)
1103{ 1109{
1104 va_list va; 1110 va_list va;
1105 1111
1106 va_start (va, message); 1112 va_start(va, message);
1107 mylog (kind, component, message, va); 1113 mylog(kind, component, message, va);
1108 va_end (va); 1114 va_end(va);
1109} 1115}
1110 1116
1111 1117
@@ -1119,10 +1125,10 @@ GNUNET_log_nocheck (enum GNUNET_ErrorType kind, const char *message, ...)
1119 * @param ... arguments for format string 1125 * @param ... arguments for format string
1120 */ 1126 */
1121void 1127void
1122GNUNET_log_from_nocheck (enum GNUNET_ErrorType kind, 1128GNUNET_log_from_nocheck(enum GNUNET_ErrorType kind,
1123 const char *comp, 1129 const char *comp,
1124 const char *message, 1130 const char *message,
1125 ...) 1131 ...)
1126{ 1132{
1127 va_list va; 1133 va_list va;
1128 char comp_w_pid[128]; 1134 char comp_w_pid[128];
@@ -1130,10 +1136,10 @@ GNUNET_log_from_nocheck (enum GNUNET_ErrorType kind,
1130 if (comp == NULL) 1136 if (comp == NULL)
1131 comp = component_nopid; 1137 comp = component_nopid;
1132 1138
1133 va_start (va, message); 1139 va_start(va, message);
1134 GNUNET_snprintf (comp_w_pid, sizeof (comp_w_pid), "%s-%d", comp, getpid ()); 1140 GNUNET_snprintf(comp_w_pid, sizeof(comp_w_pid), "%s-%d", comp, getpid());
1135 mylog (kind, comp_w_pid, message, va); 1141 mylog(kind, comp_w_pid, message, va);
1136 va_end (va); 1142 va_end(va);
1137} 1143}
1138 1144
1139 1145
@@ -1144,21 +1150,21 @@ GNUNET_log_from_nocheck (enum GNUNET_ErrorType kind,
1144 * @return string corresponding to the type 1150 * @return string corresponding to the type
1145 */ 1151 */
1146const char * 1152const char *
1147GNUNET_error_type_to_string (enum GNUNET_ErrorType kind) 1153GNUNET_error_type_to_string(enum GNUNET_ErrorType kind)
1148{ 1154{
1149 if ((kind & GNUNET_ERROR_TYPE_ERROR) > 0) 1155 if ((kind & GNUNET_ERROR_TYPE_ERROR) > 0)
1150 return _ ("ERROR"); 1156 return _("ERROR");
1151 if ((kind & GNUNET_ERROR_TYPE_WARNING) > 0) 1157 if ((kind & GNUNET_ERROR_TYPE_WARNING) > 0)
1152 return _ ("WARNING"); 1158 return _("WARNING");
1153 if ((kind & GNUNET_ERROR_TYPE_MESSAGE) > 0) 1159 if ((kind & GNUNET_ERROR_TYPE_MESSAGE) > 0)
1154 return _ ("MESSAGE"); 1160 return _("MESSAGE");
1155 if ((kind & GNUNET_ERROR_TYPE_INFO) > 0) 1161 if ((kind & GNUNET_ERROR_TYPE_INFO) > 0)
1156 return _ ("INFO"); 1162 return _("INFO");
1157 if ((kind & GNUNET_ERROR_TYPE_DEBUG) > 0) 1163 if ((kind & GNUNET_ERROR_TYPE_DEBUG) > 0)
1158 return _ ("DEBUG"); 1164 return _("DEBUG");
1159 if ((kind & ~GNUNET_ERROR_TYPE_BULK) == 0) 1165 if ((kind & ~GNUNET_ERROR_TYPE_BULK) == 0)
1160 return _ ("NONE"); 1166 return _("NONE");
1161 return _ ("INVALID"); 1167 return _("INVALID");
1162} 1168}
1163 1169
1164 1170
@@ -1169,13 +1175,13 @@ GNUNET_error_type_to_string (enum GNUNET_ErrorType kind)
1169 * @return string form; will be overwritten by next call to GNUNET_h2s. 1175 * @return string form; will be overwritten by next call to GNUNET_h2s.
1170 */ 1176 */
1171const char * 1177const char *
1172GNUNET_h2s (const struct GNUNET_HashCode *hc) 1178GNUNET_h2s(const struct GNUNET_HashCode *hc)
1173{ 1179{
1174 static GNUNET_THREAD_LOCAL struct GNUNET_CRYPTO_HashAsciiEncoded ret; 1180 static GNUNET_THREAD_LOCAL struct GNUNET_CRYPTO_HashAsciiEncoded ret;
1175 1181
1176 GNUNET_CRYPTO_hash_to_enc (hc, &ret); 1182 GNUNET_CRYPTO_hash_to_enc(hc, &ret);
1177 ret.encoding[8] = '\0'; 1183 ret.encoding[8] = '\0';
1178 return (const char *) ret.encoding; 1184 return (const char *)ret.encoding;
1179} 1185}
1180 1186
1181 1187
@@ -1190,13 +1196,13 @@ GNUNET_h2s (const struct GNUNET_HashCode *hc)
1190 * @return string form; will be overwritten by next call to GNUNET_h2s. 1196 * @return string form; will be overwritten by next call to GNUNET_h2s.
1191 */ 1197 */
1192const char * 1198const char *
1193GNUNET_h2s2 (const struct GNUNET_HashCode *hc) 1199GNUNET_h2s2(const struct GNUNET_HashCode *hc)
1194{ 1200{
1195 static struct GNUNET_CRYPTO_HashAsciiEncoded ret; 1201 static struct GNUNET_CRYPTO_HashAsciiEncoded ret;
1196 1202
1197 GNUNET_CRYPTO_hash_to_enc (hc, &ret); 1203 GNUNET_CRYPTO_hash_to_enc(hc, &ret);
1198 ret.encoding[8] = '\0'; 1204 ret.encoding[8] = '\0';
1199 return (const char *) ret.encoding; 1205 return (const char *)ret.encoding;
1200} 1206}
1201 1207
1202 1208
@@ -1210,15 +1216,15 @@ GNUNET_h2s2 (const struct GNUNET_HashCode *hc)
1210 * @return string 1216 * @return string
1211 */ 1217 */
1212const char * 1218const char *
1213GNUNET_p2s (const struct GNUNET_CRYPTO_EddsaPublicKey *p) 1219GNUNET_p2s(const struct GNUNET_CRYPTO_EddsaPublicKey *p)
1214{ 1220{
1215 static struct GNUNET_CRYPTO_HashAsciiEncoded ret; 1221 static struct GNUNET_CRYPTO_HashAsciiEncoded ret;
1216 struct GNUNET_HashCode hc; 1222 struct GNUNET_HashCode hc;
1217 1223
1218 GNUNET_CRYPTO_hash (p, sizeof (*p), &hc); 1224 GNUNET_CRYPTO_hash(p, sizeof(*p), &hc);
1219 GNUNET_CRYPTO_hash_to_enc (&hc, &ret); 1225 GNUNET_CRYPTO_hash_to_enc(&hc, &ret);
1220 ret.encoding[6] = '\0'; 1226 ret.encoding[6] = '\0';
1221 return (const char *) ret.encoding; 1227 return (const char *)ret.encoding;
1222} 1228}
1223 1229
1224 1230
@@ -1232,15 +1238,15 @@ GNUNET_p2s (const struct GNUNET_CRYPTO_EddsaPublicKey *p)
1232 * @return string 1238 * @return string
1233 */ 1239 */
1234const char * 1240const char *
1235GNUNET_p2s2 (const struct GNUNET_CRYPTO_EddsaPublicKey *p) 1241GNUNET_p2s2(const struct GNUNET_CRYPTO_EddsaPublicKey *p)
1236{ 1242{
1237 static struct GNUNET_CRYPTO_HashAsciiEncoded ret; 1243 static struct GNUNET_CRYPTO_HashAsciiEncoded ret;
1238 struct GNUNET_HashCode hc; 1244 struct GNUNET_HashCode hc;
1239 1245
1240 GNUNET_CRYPTO_hash (p, sizeof (*p), &hc); 1246 GNUNET_CRYPTO_hash(p, sizeof(*p), &hc);
1241 GNUNET_CRYPTO_hash_to_enc (&hc, &ret); 1247 GNUNET_CRYPTO_hash_to_enc(&hc, &ret);
1242 ret.encoding[6] = '\0'; 1248 ret.encoding[6] = '\0';
1243 return (const char *) ret.encoding; 1249 return (const char *)ret.encoding;
1244} 1250}
1245 1251
1246 1252
@@ -1254,15 +1260,15 @@ GNUNET_p2s2 (const struct GNUNET_CRYPTO_EddsaPublicKey *p)
1254 * @return string 1260 * @return string
1255 */ 1261 */
1256const char * 1262const char *
1257GNUNET_e2s (const struct GNUNET_CRYPTO_EcdhePublicKey *p) 1263GNUNET_e2s(const struct GNUNET_CRYPTO_EcdhePublicKey *p)
1258{ 1264{
1259 static struct GNUNET_CRYPTO_HashAsciiEncoded ret; 1265 static struct GNUNET_CRYPTO_HashAsciiEncoded ret;
1260 struct GNUNET_HashCode hc; 1266 struct GNUNET_HashCode hc;
1261 1267
1262 GNUNET_CRYPTO_hash (p, sizeof (*p), &hc); 1268 GNUNET_CRYPTO_hash(p, sizeof(*p), &hc);
1263 GNUNET_CRYPTO_hash_to_enc (&hc, &ret); 1269 GNUNET_CRYPTO_hash_to_enc(&hc, &ret);
1264 ret.encoding[6] = '\0'; 1270 ret.encoding[6] = '\0';
1265 return (const char *) ret.encoding; 1271 return (const char *)ret.encoding;
1266} 1272}
1267 1273
1268 1274
@@ -1276,15 +1282,15 @@ GNUNET_e2s (const struct GNUNET_CRYPTO_EcdhePublicKey *p)
1276 * @return string 1282 * @return string
1277 */ 1283 */
1278const char * 1284const char *
1279GNUNET_e2s2 (const struct GNUNET_CRYPTO_EcdhePublicKey *p) 1285GNUNET_e2s2(const struct GNUNET_CRYPTO_EcdhePublicKey *p)
1280{ 1286{
1281 static struct GNUNET_CRYPTO_HashAsciiEncoded ret; 1287 static struct GNUNET_CRYPTO_HashAsciiEncoded ret;
1282 struct GNUNET_HashCode hc; 1288 struct GNUNET_HashCode hc;
1283 1289
1284 GNUNET_CRYPTO_hash (p, sizeof (*p), &hc); 1290 GNUNET_CRYPTO_hash(p, sizeof(*p), &hc);
1285 GNUNET_CRYPTO_hash_to_enc (&hc, &ret); 1291 GNUNET_CRYPTO_hash_to_enc(&hc, &ret);
1286 ret.encoding[6] = '\0'; 1292 ret.encoding[6] = '\0';
1287 return (const char *) ret.encoding; 1293 return (const char *)ret.encoding;
1288} 1294}
1289 1295
1290 1296
@@ -1298,13 +1304,13 @@ GNUNET_e2s2 (const struct GNUNET_CRYPTO_EcdhePublicKey *p)
1298 * @return string 1304 * @return string
1299 */ 1305 */
1300const char * 1306const char *
1301GNUNET_sh2s (const struct GNUNET_ShortHashCode *shc) 1307GNUNET_sh2s(const struct GNUNET_ShortHashCode *shc)
1302{ 1308{
1303 static char buf[64]; 1309 static char buf[64];
1304 1310
1305 GNUNET_STRINGS_data_to_string (shc, sizeof (*shc), buf, sizeof (buf)); 1311 GNUNET_STRINGS_data_to_string(shc, sizeof(*shc), buf, sizeof(buf));
1306 buf[6] = '\0'; 1312 buf[6] = '\0';
1307 return (const char *) buf; 1313 return (const char *)buf;
1308} 1314}
1309 1315
1310 1316
@@ -1318,13 +1324,13 @@ GNUNET_sh2s (const struct GNUNET_ShortHashCode *shc)
1318 * @return string 1324 * @return string
1319 */ 1325 */
1320const char * 1326const char *
1321GNUNET_uuid2s (const struct GNUNET_Uuid *uuid) 1327GNUNET_uuid2s(const struct GNUNET_Uuid *uuid)
1322{ 1328{
1323 static char buf[32]; 1329 static char buf[32];
1324 1330
1325 GNUNET_STRINGS_data_to_string (uuid, sizeof (*uuid), buf, sizeof (buf)); 1331 GNUNET_STRINGS_data_to_string(uuid, sizeof(*uuid), buf, sizeof(buf));
1326 buf[6] = '\0'; 1332 buf[6] = '\0';
1327 return (const char *) buf; 1333 return (const char *)buf;
1328} 1334}
1329 1335
1330 1336
@@ -1337,13 +1343,13 @@ GNUNET_uuid2s (const struct GNUNET_Uuid *uuid)
1337 * @return string form; will be overwritten by next call to GNUNET_h2s_full. 1343 * @return string form; will be overwritten by next call to GNUNET_h2s_full.
1338 */ 1344 */
1339const char * 1345const char *
1340GNUNET_h2s_full (const struct GNUNET_HashCode *hc) 1346GNUNET_h2s_full(const struct GNUNET_HashCode *hc)
1341{ 1347{
1342 static struct GNUNET_CRYPTO_HashAsciiEncoded ret; 1348 static struct GNUNET_CRYPTO_HashAsciiEncoded ret;
1343 1349
1344 GNUNET_CRYPTO_hash_to_enc (hc, &ret); 1350 GNUNET_CRYPTO_hash_to_enc(hc, &ret);
1345 ret.encoding[sizeof (ret) - 1] = '\0'; 1351 ret.encoding[sizeof(ret) - 1] = '\0';
1346 return (const char *) ret.encoding; 1352 return (const char *)ret.encoding;
1347} 1353}
1348 1354
1349 1355
@@ -1355,16 +1361,16 @@ GNUNET_h2s_full (const struct GNUNET_HashCode *hc)
1355 * call to #GNUNET_i2s. 1361 * call to #GNUNET_i2s.
1356 */ 1362 */
1357const char * 1363const char *
1358GNUNET_i2s (const struct GNUNET_PeerIdentity *pid) 1364GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
1359{ 1365{
1360 static GNUNET_THREAD_LOCAL char buf[5]; 1366 static GNUNET_THREAD_LOCAL char buf[5];
1361 char *ret; 1367 char *ret;
1362 1368
1363 if (NULL == pid) 1369 if (NULL == pid)
1364 return "NULL"; 1370 return "NULL";
1365 ret = GNUNET_CRYPTO_eddsa_public_key_to_string (&pid->public_key); 1371 ret = GNUNET_CRYPTO_eddsa_public_key_to_string(&pid->public_key);
1366 GNUNET_strlcpy (buf, ret, sizeof (buf)); 1372 GNUNET_strlcpy(buf, ret, sizeof(buf));
1367 GNUNET_free (ret); 1373 GNUNET_free(ret);
1368 return buf; 1374 return buf;
1369} 1375}
1370 1376
@@ -1380,16 +1386,16 @@ GNUNET_i2s (const struct GNUNET_PeerIdentity *pid)
1380 * call to #GNUNET_i2s. 1386 * call to #GNUNET_i2s.
1381 */ 1387 */
1382const char * 1388const char *
1383GNUNET_i2s2 (const struct GNUNET_PeerIdentity *pid) 1389GNUNET_i2s2(const struct GNUNET_PeerIdentity *pid)
1384{ 1390{
1385 static GNUNET_THREAD_LOCAL char buf[5]; 1391 static GNUNET_THREAD_LOCAL char buf[5];
1386 char *ret; 1392 char *ret;
1387 1393
1388 if (NULL == pid) 1394 if (NULL == pid)
1389 return "NULL"; 1395 return "NULL";
1390 ret = GNUNET_CRYPTO_eddsa_public_key_to_string (&pid->public_key); 1396 ret = GNUNET_CRYPTO_eddsa_public_key_to_string(&pid->public_key);
1391 GNUNET_strlcpy (buf, ret, sizeof (buf)); 1397 GNUNET_strlcpy(buf, ret, sizeof(buf));
1392 GNUNET_free (ret); 1398 GNUNET_free(ret);
1393 return buf; 1399 return buf;
1394} 1400}
1395 1401
@@ -1402,14 +1408,14 @@ GNUNET_i2s2 (const struct GNUNET_PeerIdentity *pid)
1402 * call to #GNUNET_i2s_full. 1408 * call to #GNUNET_i2s_full.
1403 */ 1409 */
1404const char * 1410const char *
1405GNUNET_i2s_full (const struct GNUNET_PeerIdentity *pid) 1411GNUNET_i2s_full(const struct GNUNET_PeerIdentity *pid)
1406{ 1412{
1407 static GNUNET_THREAD_LOCAL char buf[256]; 1413 static GNUNET_THREAD_LOCAL char buf[256];
1408 char *ret; 1414 char *ret;
1409 1415
1410 ret = GNUNET_CRYPTO_eddsa_public_key_to_string (&pid->public_key); 1416 ret = GNUNET_CRYPTO_eddsa_public_key_to_string(&pid->public_key);
1411 strcpy (buf, ret); 1417 strcpy(buf, ret);
1412 GNUNET_free (ret); 1418 GNUNET_free(ret);
1413 return buf; 1419 return buf;
1414} 1420}
1415 1421
@@ -1425,12 +1431,12 @@ GNUNET_i2s_full (const struct GNUNET_PeerIdentity *pid)
1425 * will be overwritten by next call to #GNUNET_a2s. 1431 * will be overwritten by next call to #GNUNET_a2s.
1426 */ 1432 */
1427const char * 1433const char *
1428GNUNET_a2s (const struct sockaddr *addr, socklen_t addrlen) 1434GNUNET_a2s(const struct sockaddr *addr, socklen_t addrlen)
1429{ 1435{
1430#ifndef WINDOWS 1436#ifndef WINDOWS
1431#define LEN \ 1437#define LEN \
1432 GNUNET_MAX ((INET6_ADDRSTRLEN + 8), \ 1438 GNUNET_MAX((INET6_ADDRSTRLEN + 8), \
1433 (1 + sizeof (struct sockaddr_un) - sizeof (sa_family_t))) 1439 (1 + sizeof(struct sockaddr_un) - sizeof(sa_family_t)))
1434#else 1440#else
1435#define LEN (INET6_ADDRSTRLEN + 8) 1441#define LEN (INET6_ADDRSTRLEN + 8)
1436#endif 1442#endif
@@ -1443,50 +1449,53 @@ GNUNET_a2s (const struct sockaddr *addr, socklen_t addrlen)
1443 unsigned int off; 1449 unsigned int off;
1444 1450
1445 if (addr == NULL) 1451 if (addr == NULL)
1446 return _ ("unknown address"); 1452 return _("unknown address");
1447 switch (addr->sa_family) 1453 switch (addr->sa_family)
1448 { 1454 {
1449 case AF_INET: 1455 case AF_INET:
1450 if (addrlen != sizeof (struct sockaddr_in)) 1456 if (addrlen != sizeof(struct sockaddr_in))
1451 return "<invalid v4 address>"; 1457 return "<invalid v4 address>";
1452 v4 = (const struct sockaddr_in *) addr; 1458 v4 = (const struct sockaddr_in *)addr;
1453 inet_ntop (AF_INET, &v4->sin_addr, buf, INET_ADDRSTRLEN); 1459 inet_ntop(AF_INET, &v4->sin_addr, buf, INET_ADDRSTRLEN);
1454 if (0 == ntohs (v4->sin_port)) 1460 if (0 == ntohs(v4->sin_port))
1461 return buf;
1462 strcat(buf, ":");
1463 GNUNET_snprintf(b2, sizeof(b2), "%u", ntohs(v4->sin_port));
1464 strcat(buf, b2);
1455 return buf; 1465 return buf;
1456 strcat (buf, ":"); 1466
1457 GNUNET_snprintf (b2, sizeof (b2), "%u", ntohs (v4->sin_port)); 1467 case AF_INET6:
1458 strcat (buf, b2); 1468 if (addrlen != sizeof(struct sockaddr_in6))
1459 return buf; 1469 return "<invalid v4 address>";
1460 case AF_INET6: 1470 v6 = (const struct sockaddr_in6 *)addr;
1461 if (addrlen != sizeof (struct sockaddr_in6)) 1471 buf[0] = '[';
1462 return "<invalid v4 address>"; 1472 inet_ntop(AF_INET6, &v6->sin6_addr, &buf[1], INET6_ADDRSTRLEN);
1463 v6 = (const struct sockaddr_in6 *) addr; 1473 if (0 == ntohs(v6->sin6_port))
1464 buf[0] = '['; 1474 return &buf[1];
1465 inet_ntop (AF_INET6, &v6->sin6_addr, &buf[1], INET6_ADDRSTRLEN); 1475 strcat(buf, "]:");
1466 if (0 == ntohs (v6->sin6_port)) 1476 GNUNET_snprintf(b2, sizeof(b2), "%u", ntohs(v6->sin6_port));
1467 return &buf[1]; 1477 strcat(buf, b2);
1468 strcat (buf, "]:"); 1478 return buf;
1469 GNUNET_snprintf (b2, sizeof (b2), "%u", ntohs (v6->sin6_port)); 1479
1470 strcat (buf, b2); 1480 case AF_UNIX:
1471 return buf; 1481 if (addrlen <= sizeof(sa_family_t))
1472 case AF_UNIX: 1482 return "<unbound UNIX client>";
1473 if (addrlen <= sizeof (sa_family_t)) 1483 un = (const struct sockaddr_un *)addr;
1474 return "<unbound UNIX client>"; 1484 off = 0;
1475 un = (const struct sockaddr_un *) addr; 1485 if ('\0' == un->sun_path[0])
1476 off = 0; 1486 off++;
1477 if ('\0' == un->sun_path[0]) 1487 memset(buf, 0, sizeof(buf));
1478 off++; 1488 GNUNET_snprintf(buf,
1479 memset (buf, 0, sizeof (buf)); 1489 sizeof(buf),
1480 GNUNET_snprintf (buf, 1490 "%s%.*s",
1481 sizeof (buf), 1491 (1 == off) ? "@" : "",
1482 "%s%.*s", 1492 (int)(addrlen - sizeof(sa_family_t) - off),
1483 (1 == off) ? "@" : "", 1493 &un->sun_path[off]);
1484 (int) (addrlen - sizeof (sa_family_t) - off), 1494 return buf;
1485 &un->sun_path[off]); 1495
1486 return buf; 1496 default:
1487 default: 1497 return _("invalid address");
1488 return _ ("invalid address"); 1498 }
1489 }
1490} 1499}
1491 1500
1492 1501
@@ -1498,15 +1507,15 @@ GNUNET_a2s (const struct sockaddr *addr, socklen_t addrlen)
1498 * @param option name of missing option 1507 * @param option name of missing option
1499 */ 1508 */
1500void 1509void
1501GNUNET_log_config_missing (enum GNUNET_ErrorType kind, 1510GNUNET_log_config_missing(enum GNUNET_ErrorType kind,
1502 const char *section, 1511 const char *section,
1503 const char *option) 1512 const char *option)
1504{ 1513{
1505 GNUNET_log (kind, 1514 GNUNET_log(kind,
1506 _ ( 1515 _(
1507 "Configuration fails to specify option `%s' in section `%s'!\n"), 1516 "Configuration fails to specify option `%s' in section `%s'!\n"),
1508 option, 1517 option,
1509 section); 1518 section);
1510} 1519}
1511 1520
1512 1521
@@ -1519,14 +1528,14 @@ GNUNET_log_config_missing (enum GNUNET_ErrorType kind,
1519 * @param required what is required that is invalid about the option 1528 * @param required what is required that is invalid about the option
1520 */ 1529 */
1521void 1530void
1522GNUNET_log_config_invalid (enum GNUNET_ErrorType kind, 1531GNUNET_log_config_invalid(enum GNUNET_ErrorType kind,
1523 const char *section, 1532 const char *section,
1524 const char *option, 1533 const char *option,
1525 const char *required) 1534 const char *required)
1526{ 1535{
1527 GNUNET_log ( 1536 GNUNET_log(
1528 kind, 1537 kind,
1529 _ ( 1538 _(
1530 "Configuration specifies invalid value for option `%s' in section `%s': %s\n"), 1539 "Configuration specifies invalid value for option `%s' in section `%s': %s\n"),
1531 option, 1540 option,
1532 section, 1541 section,
@@ -1541,8 +1550,8 @@ GNUNET_log_config_invalid (enum GNUNET_ErrorType kind,
1541 * @param old_scope[out] location to save the old scope 1550 * @param old_scope[out] location to save the old scope
1542 */ 1551 */
1543void 1552void
1544GNUNET_async_scope_enter (const struct GNUNET_AsyncScopeId *aid, 1553GNUNET_async_scope_enter(const struct GNUNET_AsyncScopeId *aid,
1545 struct GNUNET_AsyncScopeSave *old_scope) 1554 struct GNUNET_AsyncScopeSave *old_scope)
1546{ 1555{
1547 *old_scope = current_async_scope; 1556 *old_scope = current_async_scope;
1548 current_async_scope.have_scope = GNUNET_YES; 1557 current_async_scope.have_scope = GNUNET_YES;
@@ -1556,7 +1565,7 @@ GNUNET_async_scope_enter (const struct GNUNET_AsyncScopeId *aid,
1556 * @param old_scope scope to restore 1565 * @param old_scope scope to restore
1557 */ 1566 */
1558void 1567void
1559GNUNET_async_scope_restore (struct GNUNET_AsyncScopeSave *old_scope) 1568GNUNET_async_scope_restore(struct GNUNET_AsyncScopeSave *old_scope)
1560{ 1569{
1561 current_async_scope = *old_scope; 1570 current_async_scope = *old_scope;
1562} 1571}
@@ -1568,11 +1577,11 @@ GNUNET_async_scope_restore (struct GNUNET_AsyncScopeSave *old_scope)
1568 * @param[out] aid_ret pointer to where the result is stored 1577 * @param[out] aid_ret pointer to where the result is stored
1569 */ 1578 */
1570void 1579void
1571GNUNET_async_scope_fresh (struct GNUNET_AsyncScopeId *aid_ret) 1580GNUNET_async_scope_fresh(struct GNUNET_AsyncScopeId *aid_ret)
1572{ 1581{
1573 GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, 1582 GNUNET_CRYPTO_random_block(GNUNET_CRYPTO_QUALITY_WEAK,
1574 aid_ret, 1583 aid_ret,
1575 sizeof (struct GNUNET_AsyncScopeId)); 1584 sizeof(struct GNUNET_AsyncScopeId));
1576} 1585}
1577 1586
1578 1587
@@ -1582,7 +1591,7 @@ GNUNET_async_scope_fresh (struct GNUNET_AsyncScopeId *aid_ret)
1582 * @param[out] scope_ret pointer to where the result is stored 1591 * @param[out] scope_ret pointer to where the result is stored
1583 */ 1592 */
1584void 1593void
1585GNUNET_async_scope_get (struct GNUNET_AsyncScopeSave *scope_ret) 1594GNUNET_async_scope_get(struct GNUNET_AsyncScopeSave *scope_ret)
1586{ 1595{
1587 *scope_ret = current_async_scope; 1596 *scope_ret = current_async_scope;
1588} 1597}
@@ -1591,15 +1600,15 @@ GNUNET_async_scope_get (struct GNUNET_AsyncScopeSave *scope_ret)
1591/** 1600/**
1592 * Initializer 1601 * Initializer
1593 */ 1602 */
1594void __attribute__ ((constructor)) GNUNET_util_cl_init () 1603void __attribute__ ((constructor)) GNUNET_util_cl_init()
1595{ 1604{
1596 GNUNET_stderr = stderr; 1605 GNUNET_stderr = stderr;
1597#ifdef MINGW 1606#ifdef MINGW
1598 GNInitWinEnv (NULL); 1607 GNInitWinEnv(NULL);
1599#endif 1608#endif
1600#if WINDOWS 1609#if WINDOWS
1601 if (! InitializeCriticalSectionAndSpinCount (&output_message_cs, 0x00000400)) 1610 if (!InitializeCriticalSectionAndSpinCount(&output_message_cs, 0x00000400))
1602 GNUNET_abort_ (); 1611 GNUNET_abort_();
1603#endif 1612#endif
1604} 1613}
1605 1614
@@ -1607,13 +1616,13 @@ void __attribute__ ((constructor)) GNUNET_util_cl_init ()
1607/** 1616/**
1608 * Destructor 1617 * Destructor
1609 */ 1618 */
1610void __attribute__ ((destructor)) GNUNET_util_cl_fini () 1619void __attribute__ ((destructor)) GNUNET_util_cl_fini()
1611{ 1620{
1612#if WINDOWS 1621#if WINDOWS
1613 DeleteCriticalSection (&output_message_cs); 1622 DeleteCriticalSection(&output_message_cs);
1614#endif 1623#endif
1615#ifdef MINGW 1624#ifdef MINGW
1616 GNShutdownWinEnv (); 1625 GNShutdownWinEnv();
1617#endif 1626#endif
1618} 1627}
1619 1628