home *** CD-ROM | disk | FTP | other *** search
/ back2roots/padua / padua.7z / padua / uucp / uupoll068.lha / source / dbg.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-08-03  |  614 b   |  36 lines

  1.  
  2. #include <stdio.h>
  3. #include <stdarg.h>
  4.  
  5. #include "defines.h"
  6.  
  7. int dbglevel = 0;
  8. FILE *dbghandle = NULL;
  9.  
  10. void dbg(int wLevel, char *cpFmtstr, ...)
  11. {
  12.     va_list pArg;
  13.     FILE *fpHandle;
  14.     char caTmp[RANGE_8BIT];
  15.     char *cp;
  16.     int i;
  17.  
  18.     if (dbglevel >= wLevel) {
  19.         va_start(pArg, cpFmtstr);
  20.         fpHandle = (dbghandle) ? dbghandle : stderr;
  21.         cp = caTmp;
  22.         cp += sprintf(cp, "%s[%1d]%s ",
  23.                         ANSICTL_YELLOW_FOREGROUND,
  24.                         wLevel,
  25.                         ANSICTL_NORMAL_DISPLAY        );
  26.         for (i = 0; i < wLevel; i++)
  27.             *cp++ = SP;
  28.         vsprintf(cp, cpFmtstr, pArg);
  29.         fprintf(fpHandle, caTmp);
  30.         fflush(fpHandle);
  31.         va_end(pArg);
  32.     }
  33.     return;
  34. }
  35.  
  36.