"Fossies" - the Fresh Open Source Software Archive

Member "cgiwrap-4.1/debug.c" (16 Jun 2008, 2112 Bytes) of package /linux/www/old/cgiwrap-4.1.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.

    1 /* 
    2  *  CGIWrap is free software; you can redistribute it and/or modify
    3  *  it under the terms of the GNU General Public License as published by
    4  *  the Free Software Foundation; either version 2 of the License, or
    5  *  (at your option) any later version.
    6  *
    7  *  CGIWrap is distributed in the hope that it will be useful,
    8  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    9  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   10  *  GNU General Public License for more details.
   11  *
   12  *  You should have received a copy of the GNU General Public License
   13  *  along with CGIWrap; if not, write to the Free Software
   14  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   15  *
   16  *  Copyright 2003-2005, Nathan Neulinger <nneul@neulinger.org>
   17  *
   18  */
   19 
   20 /**
   21  **  File: debug.c
   22  **  Purpose: Debugging output routines
   23  **/ 
   24 
   25 #include "cgiwrap.h"    /* Headers for all CGIwrap source files */
   26 RCSID("$Id: debug.c 306 2008-06-13 14:02:02Z nneul $");
   27 
   28 /*
   29  * Global flag to turn debugging output on/off
   30  */
   31 int CONF_DEBUG;
   32 
   33 
   34 /*
   35  * Print out a debugging message if CONF_DEBUG is true
   36  */
   37 void DEBUG_Msg (char *msg)
   38 {
   39     if (CONF_DEBUG)
   40     {
   41         printf("%s\n", NullCheck(msg));
   42         fflush(stdout);
   43     }
   44 }
   45 
   46 void DEBUG_Str (char *msg, char *var)
   47 {
   48     if (CONF_DEBUG)
   49     {
   50         printf("%s '%s'\n", NullCheck(msg), NullCheck(var) );
   51         fflush(stdout);
   52     }
   53 }
   54 
   55 void DEBUG_StrStr (char *msg, char *var, char *var2)
   56 {
   57     if (CONF_DEBUG)
   58     {
   59         printf("%s '%s'-'%s'\n", NullCheck(msg), 
   60             NullCheck(var), NullCheck(var2) );
   61         fflush(stdout);
   62     }
   63 }
   64 
   65 void DEBUG_Int (char *msg, int var)
   66 {
   67     if (CONF_DEBUG)
   68     {
   69         printf("%s '%d'\n", NullCheck(msg), var );
   70         fflush(stdout);
   71     }
   72 }
   73 
   74 /*
   75  * Intended to debug a call to execv by printing the path & argv array.
   76  */
   77 void DEBUG_Exec (char *path, char **argv)
   78 {
   79     if ( CONF_DEBUG )
   80     {
   81         printf("Executing: '%s'\n", path);
   82         printf("Arguments:\n");
   83 
   84         if ( argv == NULL )
   85         {
   86             printf("  missing argv\n");
   87         }
   88         else
   89         {
   90             int i = 0;
   91             while (argv[i] != NULL) 
   92             { 
   93                 printf("\t%d: '%s'\n", i, NullCheck(argv[i]));
   94                 i++;
   95             }
   96         }
   97         printf("\n");
   98         fflush(stdout);
   99     }
  100 }
  101 
  102 
  103