// copyright Min Zhong, cs838 proj2, April, 2000 #include #include "proj2.h" struct debugMsg debugMsgs[] = { {DEBUG_READ, "(DEBUG_READ) "}, {DEBUG_UI, "(DEBUG_UI) "}, {DEBUG_Q, "(DEBUG_Q) "}, {DEBUG_INTP, "(DEBUG_INTP) "}, {DEBUG_STAGE, "(DEBUG_STAGE) "} }; /* curtesy of Jerome Heckenkamp * proj debug function * sample use: mdebug("nodeId: %i\n", nodeId); */ void mdebug(int debugtype, const char *fmt, ...) { #if DEBUG if (debugtype == DEBUG_Q || debugtype == DEBUG_STAGE || debugtype == DEBUG_INTP) { va_list ap; char print_buf[10000]; va_start(ap,fmt); strcpy(print_buf, debugMsgs[debugtype].dstring); vsprintf(print_buf + strlen(debugMsgs[debugtype].dstring), fmt, ap); va_end(ap); printf(print_buf); fflush(stdout); } #endif }