aboutsummaryrefslogtreecommitdiff
path: root/src/util/common_logging.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-11-29 20:47:18 +0000
committerChristian Grothoff <christian@grothoff.org>2011-11-29 20:47:18 +0000
commit71ea5bd2d05058008e604ffd42993be9c7250e04 (patch)
treea5074671ddfaa9d1621a4182fc95a91a98b3d536 /src/util/common_logging.c
parentb335777fd435142c16eb05e86c8a64a4b1a45447 (diff)
downloadgnunet-71ea5bd2d05058008e604ffd42993be9c7250e04.tar.gz
gnunet-71ea5bd2d05058008e604ffd42993be9c7250e04.zip
-fixing indentation
Diffstat (limited to 'src/util/common_logging.c')
-rw-r--r--src/util/common_logging.c209
1 files changed, 104 insertions, 105 deletions
diff --git a/src/util/common_logging.c b/src/util/common_logging.c
index ded410e3d..22901bf26 100644
--- a/src/util/common_logging.c
+++ b/src/util/common_logging.c
@@ -268,9 +268,9 @@ void
268GNUNET_abort () 268GNUNET_abort ()
269{ 269{
270#if WINDOWS 270#if WINDOWS
271 DebugBreak(); 271 DebugBreak ();
272#endif 272#endif
273 abort(); 273 abort ();
274} 274}
275 275
276 276
@@ -292,6 +292,7 @@ add_definition (char *component, char *file, char *function, int from_line,
292{ 292{
293 struct LogDef n; 293 struct LogDef n;
294 int r; 294 int r;
295
295 if (logdefs_size == logdefs_len) 296 if (logdefs_size == logdefs_len)
296 resize_logdefs (); 297 resize_logdefs ();
297 memset (&n, 0, sizeof (n)); 298 memset (&n, 0, sizeof (n));
@@ -299,27 +300,26 @@ add_definition (char *component, char *file, char *function, int from_line,
299 component = (char *) ".*"; 300 component = (char *) ".*";
300 r = regcomp (&n.component_regex, (const char *) component, REG_NOSUB); 301 r = regcomp (&n.component_regex, (const char *) component, REG_NOSUB);
301 if (r != 0) 302 if (r != 0)
302 { 303 {
303 return r; 304 return r;
304 } 305 }
305 if (strlen (file) == 0) 306 if (strlen (file) == 0)
306 file = (char *) ".*"; 307 file = (char *) ".*";
307 r = regcomp (&n.file_regex, (const char *) file, REG_NOSUB); 308 r = regcomp (&n.file_regex, (const char *) file, REG_NOSUB);
308 if (r != 0) 309 if (r != 0)
309 { 310 {
310 regfree (&n.component_regex); 311 regfree (&n.component_regex);
311 return r; 312 return r;
312 } 313 }
313 if ( (NULL == function) || 314 if ((NULL == function) || (strlen (function) == 0))
314 (strlen (function) == 0))
315 function = (char *) ".*"; 315 function = (char *) ".*";
316 r = regcomp (&n.function_regex, (const char *) function, REG_NOSUB); 316 r = regcomp (&n.function_regex, (const char *) function, REG_NOSUB);
317 if (r != 0) 317 if (r != 0)
318 { 318 {
319 regfree (&n.component_regex); 319 regfree (&n.component_regex);
320 regfree (&n.file_regex); 320 regfree (&n.file_regex);
321 return r; 321 return r;
322 } 322 }
323 n.from_line = from_line; 323 n.from_line = from_line;
324 n.to_line = to_line; 324 n.to_line = to_line;
325 n.level = level; 325 n.level = level;
@@ -364,16 +364,16 @@ GNUNET_get_log_call_status (int caller_level, const char *comp,
364 force_only = min_level >= 0; 364 force_only = min_level >= 0;
365 for (i = 0; i < logdefs_len; i++) 365 for (i = 0; i < logdefs_len; i++)
366 { 366 {
367 ld = &logdefs[i]; 367 ld = &logdefs[i];
368 if ((!force_only || ld->force) && 368 if ((!force_only || ld->force) &&
369 (line >= ld->from_line && line <= ld->to_line) && 369 (line >= ld->from_line && line <= ld->to_line) &&
370 (regexec (&ld->component_regex, comp, 0, NULL, 0) == 0) && 370 (regexec (&ld->component_regex, comp, 0, NULL, 0) == 0) &&
371 (regexec (&ld->file_regex, file, 0, NULL, 0) == 0) && 371 (regexec (&ld->file_regex, file, 0, NULL, 0) == 0) &&
372 (regexec (&ld->function_regex, function, 0, NULL, 0) == 0)) 372 (regexec (&ld->function_regex, function, 0, NULL, 0) == 0))
373 { 373 {
374 /* We're finished */ 374 /* We're finished */
375 return caller_level <= ld->level; 375 return caller_level <= ld->level;
376 } 376 }
377 } 377 }
378 /* No matches - use global level, if defined */ 378 /* No matches - use global level, if defined */
379 if (min_level >= 0) 379 if (min_level >= 0)
@@ -434,83 +434,83 @@ parse_definitions (const char *constname, int force)
434 to_line = INT_MAX; 434 to_line = INT_MAX;
435 for (p = def, state = 0, start = def; keep_looking; p++) 435 for (p = def, state = 0, start = def; keep_looking; p++)
436 { 436 {
437 switch (p[0]) 437 switch (p[0])
438 { 438 {
439 case ';': /* found a field separator */ 439 case ';': /* found a field separator */
440 p[0] = '\0'; 440 p[0] = '\0';
441 switch (state) 441 switch (state)
442 { 442 {
443 case 0: /* within a component name */ 443 case 0: /* within a component name */
444 comp = start; 444 comp = start;
445 break; 445 break;
446 case 1: /* within a file name */ 446 case 1: /* within a file name */
447 file = start; 447 file = start;
448 break; 448 break;
449 case 2: /* within a function name */ 449 case 2: /* within a function name */
450 /* after a file name there must be a function name */ 450 /* after a file name there must be a function name */
451 function = start; 451 function = start;
452 break; 452 break;
453 case 3: /* within a from-to line range */ 453 case 3: /* within a from-to line range */
454 if (strlen (start) > 0) 454 if (strlen (start) > 0)
455 { 455 {
456 errno = 0; 456 errno = 0;
457 from_line = strtol (start, &t, 10); 457 from_line = strtol (start, &t, 10);
458 if (errno != 0 || from_line < 0) 458 if (errno != 0 || from_line < 0)
459 { 459 {
460 free (def); 460 free (def);
461 return counter; 461 return counter;
462 } 462 }
463 if (t < p && t[0] == '-') 463 if (t < p && t[0] == '-')
464 { 464 {
465 errno = 0; 465 errno = 0;
466 start = t + 1; 466 start = t + 1;
467 to_line = strtol (start, &t, 10); 467 to_line = strtol (start, &t, 10);
468 if (errno != 0 || to_line < 0 || t != p) 468 if (errno != 0 || to_line < 0 || t != p)
469 { 469 {
470 free (def); 470 free (def);
471 return counter; 471 return counter;
472 } 472 }
473 } 473 }
474 else /* one number means "match this line only" */ 474 else /* one number means "match this line only" */
475 to_line = from_line; 475 to_line = from_line;
476 } 476 }
477 else /* default to 0-max */ 477 else /* default to 0-max */
478 { 478 {
479 from_line = 0; 479 from_line = 0;
480 to_line = INT_MAX; 480 to_line = INT_MAX;
481 } 481 }
482 break; 482 break;
483 } 483 }
484 start = p + 1; 484 start = p + 1;
485 state += 1; 485 state += 1;
486 break; 486 break;
487 case '\0': /* found EOL */ 487 case '\0': /* found EOL */
488 keep_looking = 0; 488 keep_looking = 0;
489 /* fall through to '/' */ 489 /* fall through to '/' */
490 case '/': /* found a definition separator */ 490 case '/': /* found a definition separator */
491 switch (state) 491 switch (state)
492 { 492 {
493 case 4: /* within a log level */ 493 case 4: /* within a log level */
494 p[0] = '\0'; 494 p[0] = '\0';
495 state = 0; 495 state = 0;
496 level = get_type ((const char *) start); 496 level = get_type ((const char *) start);
497 if (level == GNUNET_ERROR_TYPE_INVALID 497 if (level == GNUNET_ERROR_TYPE_INVALID ||
498 || level == GNUNET_ERROR_TYPE_UNSPECIFIED 498 level == GNUNET_ERROR_TYPE_UNSPECIFIED ||
499 || 0 != add_definition (comp, file, function, from_line, 499 0 != add_definition (comp, file, function, from_line, to_line,
500 to_line, level, force)) 500 level, force))
501 { 501 {
502 free (def); 502 free (def);
503 return counter; 503 return counter;
504 } 504 }
505 counter += 1; 505 counter += 1;
506 start = p + 1; 506 start = p + 1;
507 break; 507 break;
508 default: 508 default:
509 break; 509 break;
510 } 510 }
511 default: 511 default:
512 break; 512 break;
513 } 513 }
514 } 514 }
515 free (def); 515 free (def);
516 return counter; 516 return counter;
@@ -560,8 +560,7 @@ GNUNET_log_setup (const char *comp, const char *loglevel, const char *logfile)
560 component_nopid = GNUNET_strdup (comp); 560 component_nopid = GNUNET_strdup (comp);
561 561
562 env_logfile = getenv ("GNUNET_FORCE_LOGFILE"); 562 env_logfile = getenv ("GNUNET_FORCE_LOGFILE");
563 if ( (env_logfile != NULL) && 563 if ((env_logfile != NULL) && (strlen (env_logfile) > 0))
564 (strlen (env_logfile) > 0) )
565 logfile = env_logfile; 564 logfile = env_logfile;
566 565
567 if (logfile == NULL) 566 if (logfile == NULL)