home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume30 / oraperl-v2 / part04 / debug.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-07-06  |  1.3 KB  |  68 lines

  1. /* debug.c
  2.  * 
  3.  * Translate numeric debugging codes to strings, for Oraperl.
  4.  */
  5. /* Copyright 1991, 1992 Kevin Stock.
  6.  *
  7.  * You may copy this under the terms of the GNU General Public License,
  8.  * or the Artistic License, copies of which should have accompanied your
  9.  * Perl kit.
  10.  */
  11.  
  12. #include "EXTERN.h"
  13. #include "perl.h"
  14. #include "orafns.h"
  15.  
  16.  
  17. /* rules for translating numeric debugging states into strings */
  18.  
  19. struct    debug_state
  20. {
  21.     int     level;
  22.     char    *keys;
  23. } debug_states[] =
  24. {
  25.       8,    ",entry,exit,info",
  26.      32,    ",conv",
  27.     128,    ",malloc,free",
  28. };
  29.  
  30. #define    N_DEBUG_STATES    (sizeof(debug_states) / sizeof(*debug_states))
  31.  
  32.  
  33. char *
  34. convert_debug(d)
  35. int d;
  36. {
  37.     int i;
  38.     static char state[128];
  39.  
  40.     DBUG_ENTER("convert_debug");
  41.     DBUG_PRINT("entry", ("convert_debug(%d)", d));
  42.  
  43.     *state = 'd';
  44.     state[1] = '\0';
  45.  
  46.     for (i = 0 ; i < N_DEBUG_STATES ; i++)
  47.     {
  48.         if (d & debug_states[i].level)
  49.         {
  50.             strcat(state, debug_states[i].keys);
  51.             DBUG_PRINT("info", ("adding states %s for %d",
  52.                 debug_states[i].keys, debug_states[i].level));
  53.         }
  54.     }
  55.  
  56.     if (state[1] == '\0')
  57.     {
  58.         DBUG_PRINT("exit", ("no debugging states, returning NULL"));
  59.         DBUG_RETURN(NULL);
  60.     }
  61.     else
  62.     {
  63.         strcat(state, ":t:N");        /* nesting and line numbers */
  64.         DBUG_PRINT("exit", ("returning: %s", state));
  65.         DBUG_RETURN(state);
  66.     }
  67. }
  68.