|
|
1.1 ! root 1: /* ! 2: debug.c ! 3: ! 4: debugging menu support ! 5: ! 6: Debug level info is in WIN.INI in the [debug] section: ! 7: ! 8: [debug] ! 9: App=0 level for App ! 10: ! 11: */ ! 12: ! 13: #include <stdio.h> ! 14: #include <windows.h> ! 15: #include "PlaySnd.h" ! 16: #include <stdarg.h> ! 17: ! 18: #ifdef MEDIA_DEBUG ! 19: ! 20: extern void winmmSetDebugLevel(int level); ! 21: ! 22: void dDbgSetDebugMenuLevel(int i) ! 23: { ! 24: HMENU hMenu; ! 25: UINT m; ! 26: ! 27: if ((i < 0) || (i > 4)) i = 4; ! 28: hMenu = GetMenu(ghwndMain); ! 29: ! 30: for (m=IDM_DEBUG0; m<=IDM_DEBUG4; m++) { ! 31: CheckMenuItem(hMenu, m, MF_UNCHECKED); ! 32: } ! 33: ! 34: CheckMenuItem(hMenu, (i + IDM_DEBUG0), MF_CHECKED); ! 35: __iDebugLevel = i; ! 36: dprintf3("Debug level set to %d", i); ! 37: ! 38: // ! 39: // set the winmm dll debug level to be the same ! 40: // ! 41: ! 42: winmmSetDebugLevel(i); ! 43: } ! 44: ! 45: /*************************************************************************** ! 46: ! 47: @doc INTERNAL ! 48: ! 49: @api void | dDbgOut | This function sends output to the current ! 50: debug output device. ! 51: ! 52: @parm LPSTR | lpszFormat | Pointer to a printf style format string. ! 53: @parm ??? | ... | Args. ! 54: ! 55: @rdesc There is no return value. ! 56: ! 57: ****************************************************************************/ ! 58: ! 59: void dDbgOut(LPSTR lpszFormat, ...) ! 60: { ! 61: int i; ! 62: char buf[256]; ! 63: va_list va; ! 64: ! 65: sprintf(buf, "%s: ", szAppName); ! 66: OutputDebugString(buf); ! 67: ! 68: va_start(va, lpszFormat); ! 69: i = vsprintf(buf, lpszFormat, va); ! 70: va_end(va); ! 71: ! 72: OutputDebugString(buf); ! 73: ! 74: OutputDebugString("\n"); ! 75: } ! 76: ! 77: /*************************************************************************** ! 78: ! 79: @doc INTERNAL ! 80: ! 81: @api int | dDbgGetLevel | This function gets the current debug level ! 82: for a module. ! 83: ! 84: @parm LPSTR | lpszModule | The name of the module. ! 85: ! 86: @rdesc The return value is the current debug level. ! 87: ! 88: @comm The information is kept in the [debug] section of WIN.INI ! 89: ! 90: ****************************************************************************/ ! 91: ! 92: int dDbgGetLevel(LPSTR lpszAppName) ! 93: { ! 94: #ifdef MEDIA_DEBUG ! 95: return GetProfileInt("MMDEBUG", lpszAppName, 4); ! 96: #else ! 97: return GetProfileInt("MMDEBUG", lpszAppName, 1); ! 98: #endif ! 99: } ! 100: ! 101: /*************************************************************************** ! 102: ! 103: @doc INTERNAL ! 104: ! 105: @api int | dDbgSaveLevel | This function saves the current debug level ! 106: for a module. ! 107: ! 108: @parm LPSTR | lpszModule | The name of the module. ! 109: @parm int | iLevel | The value to save. ! 110: ! 111: @rdesc There is no return value. ! 112: ! 113: @comm The information is kept in the [debug] section of WIN.INI ! 114: ! 115: ****************************************************************************/ ! 116: ! 117: void dDbgSaveLevel(LPSTR lpszAppName, int iLevel) ! 118: { ! 119: char buf[80]; ! 120: ! 121: sprintf(buf, "%d", iLevel); ! 122: WriteProfileString("MMDEBUG", lpszAppName, buf); ! 123: } ! 124: ! 125: /*************************************************************************** ! 126: ! 127: @doc INTERNAL ! 128: ! 129: @api void | dDbgAssert | This function shows an assert message box. ! 130: ! 131: @parm LPSTR | exp | Pointer to the expression string. ! 132: @parm LPSTR | file | Pointer to the file name. ! 133: @parm int | line | The line number. ! 134: ! 135: @rdesc There is no return value. ! 136: ! 137: @comm We try to use the current active window as the parent. If ! 138: this fails we use the desktop window. The box is system ! 139: modal to avoid any trouble. ! 140: ! 141: ****************************************************************************/ ! 142: ! 143: void dDbgAssert(LPSTR exp, LPSTR file, int line) ! 144: { ! 145: char bufTmp[256]; ! 146: int iResponse; ! 147: HWND hWnd; ! 148: ! 149: sprintf(bufTmp, ! 150: "Expression: %s\nFile: %s, Line: %d\n\nAbort: Exit Process\nRetry: Enter Debugger\nIgnore: Continue", ! 151: exp, file, line); ! 152: ! 153: // try to use the active window, but NULL is ok if there ! 154: // isn't one. ! 155: ! 156: hWnd = GetActiveWindow(); ! 157: ! 158: iResponse = MessageBox(hWnd, ! 159: bufTmp, ! 160: "Assertion Failure - continue?", ! 161: MB_TASKMODAL ! 162: | MB_ICONEXCLAMATION ! 163: | MB_DEFBUTTON3 ! 164: | MB_OKCANCEL); ! 165: ! 166: switch (iResponse) { ! 167: case 0: ! 168: dprintf1("Assert message box failed"); ! 169: dprintf2(" Expression: %s", exp); ! 170: dprintf2(" File: %s, Line: %d", file, line); ! 171: break; ! 172: case IDCANCEL: ! 173: ExitProcess(1); ! 174: break; ! 175: case IDOK: ! 176: break; ! 177: default: ! 178: dprintf1("Assert message box failed"); ! 179: dprintf2(" Expression: %s", exp); ! 180: dprintf2(" File: %s, Line: %d", file, line); ! 181: break; ! 182: } ! 183: } ! 184: ! 185: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.