| 72 | } |
| 73 | |
| 74 | void vdebug(const char *msg, va_list ap) |
| 75 | { |
| 76 | char *buf = new char[MAX_DEBUG_LENGTH]; |
| 77 | _vsnprintf(buf, MAX_DEBUG_LENGTH, msg, ap); |
| 78 | if (g_debugOutputFlags&DBG_WCHAROUTPUT) { |
| 79 | wdebug(L"%hs", buf); |
| 80 | } |
| 81 | |
| 82 | if (g_debugOutputFlags&DBG_LOGFILE) { |
| 83 | WaitForSingleObject(g_log_mutex, INFINITE); |
| 84 | FILE *f= fopen(g_logfilename, "a+"); |
| 85 | fputs(buf, f); |
| 86 | fclose(f); |
| 87 | ReleaseMutex(g_log_mutex); |
| 88 | } |
| 89 | |
| 90 | if (g_debugOutputFlags&DBG_OUTPUTDEBUGSTRING) { |
| 91 | int len= (int)strlen(buf); |
| 92 | for (int i= 0 ; i<len ; i+=512) |
| 93 | { |
| 94 | char smallbuf[513]; |
| 95 | strncpy(smallbuf, buf+i, 512); |
| 96 | smallbuf[512]= 0; |
| 97 | OutputDebugString(smallbuf); |
| 98 | } |
| 99 | } |
| 100 | if (g_debugOutputFlags&DBG_MESSAGEBOX) { |
| 101 | MessageBox(0,buf,"debug",0); |
| 102 | } |
| 103 | if (g_debugOutputFlags&DBG_DEBUGWINDOW) { |
| 104 | g_debugWindow->appendString(buf); |
| 105 | } |
| 106 | delete[] buf; |
| 107 | } |
| 108 | |
| 109 | void debug(const char *msg, ...) |
| 110 | { |
no test coverage detected