/* debug.h - helpful debug routines Copyright (C) 2010, IBM Corporation, Eric Van Hensbergen (bergevan@us.ibm.com) */ static int vflag = 0; static int debugfd = 2; static void _dprint(ulong dlevel, char *fmt, ...) { va_list args; char *p; int len; char s[255]; char *newfmt; if(vflag>16, getpid(), fmt); if(p != nil){ p = strchr(newfmt, '\n'); *p = ' '; } va_start(args, fmt); len = vsnprint(s, sizeof s - 1, newfmt, args); va_end(args); if (newfmt != nil) free(newfmt); s[len]=0; fprint(debugfd, "%s", s); } #define DPRINT if(!vflag){} else _dprint