"Fossies" - the Fresh Open Source Software Archive

Member "authforce-0.9.9/src/debug.c" (13 May 2007, 1465 Bytes) of package /linux/www/old/authforce-0.9.9.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "debug.c" see the Fossies "Dox" file reference documentation.

    1 /* $Id: debug.c,v 1.1 2001/04/28 20:32:47 kapheine Exp $ */
    2 
    3 #include <config.h>
    4 #include <stdio.h>
    5 #include <stdarg.h>
    6 #ifdef MEMWATCH
    7 #include "memwatch.h"
    8 #endif /* MEMWATCH*/
    9 #include "extern.h"
   10 
   11 
   12 /* debug_level: print debugging messages of this level and lower, based on
   13  * the following table
   14  *
   15  * 0 - no debugging
   16  * 1 - most important messages
   17  * 2 - important but ignorable in certain situations
   18  * 3 - usually for functions reporting what they are doing
   19  * 4 - functions reporting what they are doing, with greater detail
   20  * 5 - more than you usually want to know, can site specific values of variables
   21  */
   22 
   23 /*
   24  * debug: called to print debug messages to stderr
   25  * parameters: debug level, printf-style arguments
   26  * returns: n/a
   27  */
   28 
   29 void debug(int level, char *arguments, ...)
   30 {
   31     char *str;
   32     va_list ap;
   33 
   34     str = (char*)malloc_w(384);
   35     
   36     if (level < 0)
   37         warning("debug level less than 0\n");
   38 
   39     if (level > 5)
   40         warning("debug level greater than 5\n");
   41 
   42     if (level <= debug_level) {
   43         va_start(ap, *arguments);
   44         vsnprintf(str, 384, arguments, ap);
   45         va_end(ap);
   46         printf("debug[%i]: %s", level, str);
   47     }
   48 
   49     free(str);
   50 }
   51 
   52 /*
   53  * warning: called to print warning messages to stdout
   54  * parameters: printf-style arguments
   55  * returns: n/a
   56  */
   57 
   58 void warning(char *arguments, ...)
   59 {
   60     char *str;
   61     va_list ap;
   62 
   63     str = (char*)malloc_w(384);
   64 
   65     va_start(ap, *arguments);
   66     vsnprintf(str, 384, arguments, ap);
   67     va_end(ap);
   68 
   69     printf("warning: %s", str);
   70 
   71     free(str);
   72 }
   73