Changeset 551 for trunk/dll/error.c
- Timestamp:
- Feb 28, 2007, 2:33:51 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/dll/error.c
r452 r551 43 43 //== Win_Error: report Win...() error using passed message string === 44 44 45 VOID Win_Error(HWND hwndErr, HWND hwndOwner, PCSZ pszFileName, ULONG ulLineNo, PCSZ pszFmt,...) 45 VOID Win_Error(HWND hwndErr, HWND hwndOwner, PCSZ pszFileName, ULONG ulLineNo, 46 PCSZ pszFmt, ...) 46 47 { 47 48 PERRINFO pErrInfoBlk; /* Pointer to ERRINFO structure filled … … 55 56 56 57 if (hwndErr == NULLHANDLE) 57 hab = (HAB) 0;58 hab = (HAB) 0; 58 59 else 59 60 hab = WinQueryAnchorBlock(hwndErr); … … 65 66 66 67 if (strchr(szMsg, ' ') == NULL) 67 strcat(szMsg, " failed."); 68 strcat(szMsg, " failed."); // Assume simple function name 68 69 69 70 // Append file name and line number 70 71 sprintf(szMsg + strlen(szMsg), 71 GetPString(IDS_GENERR1TEXT), 72 pszFileName, ulLineNo, " "); 72 GetPString(IDS_GENERR1TEXT), pszFileName, ulLineNo, " "); 73 73 74 74 // Get last PM error for the current thread … … 84 84 Assume 1 message - fixme? 85 85 */ 86 pszOffset = ((PSZ) pErrInfoBlk) + pErrInfoBlk ->offaoffszMsg;86 pszOffset = ((PSZ) pErrInfoBlk) + pErrInfoBlk->offaoffszMsg; 87 87 /* Address error message in array of messages and 88 88 append error message to source code linenumber 89 89 */ 90 90 psz = szMsg + strlen(szMsg); 91 sprintf(psz, "#0x%04x \"", ERRORIDERROR(pErrInfoBlk ->idError));91 sprintf(psz, "#0x%04x \"", ERRORIDERROR(pErrInfoBlk->idError)); 92 92 psz += strlen(psz); 93 strcpy(psz, ((PSZ) pErrInfoBlk) + *(PSHORT)pszOffset);93 strcpy(psz, ((PSZ) pErrInfoBlk) + *(PSHORT) pszOffset); 94 94 psz += strlen(psz); 95 95 strcpy(psz, "\""); … … 97 97 } 98 98 99 showMsg(MB_ENTER | MB_ICONEXCLAMATION, 100 hwndOwner, 101 GetPString(IDS_GENERR2TEXT), // Titlebar message 99 showMsg(MB_ENTER | MB_ICONEXCLAMATION, hwndOwner, GetPString(IDS_GENERR2TEXT), // Titlebar message 102 100 szMsg); // Formatted message 103 101 104 } 102 } // Win_Error 105 103 106 104 //== Win_Error2: report Win...() error using passed message id === 107 105 108 VOID Win_Error2(HWND hwndErr, HWND hwndOwner, PCSZ pszFileName, ULONG ulLineNo, UINT idMsg) 106 VOID Win_Error2(HWND hwndErr, HWND hwndOwner, PCSZ pszFileName, 107 ULONG ulLineNo, UINT idMsg) 109 108 { 110 109 Win_Error(hwndErr, hwndOwner, pszFileName, ulLineNo, GetPString(idMsg)); 111 110 112 } 111 } // Win_Error2 113 112 114 113 //== Dos_Error: report Dos...() error using passed message string === 115 114 116 115 INT Dos_Error(ULONG mb_type, ULONG ulRC, HWND hwndOwner, PCSZ pszFileName, 117 ULONG ulLineNo, PCSZ pszFmt, ...)116 ULONG ulLineNo, PCSZ pszFmt, ...) 118 117 { 119 118 CHAR szMsg[4096]; … … 135 134 136 135 if (strchr(szMsg, ' ') == NULL) 137 strcat(szMsg, " failed."); 136 strcat(szMsg, " failed."); // Assume simple function name 138 137 139 138 DosErrClass(ulRC, &Class, &action, &Locus); … … 149 148 pszMsgStart = szMsg + strlen(szMsg) + 1; 150 149 // Get message leaving space for NL separator 151 if (!DosGetMessage(NULL, 0L, (PCHAR)pszMsgStart + 1, 1024, ulRC, "OSO001.MSG", &ulMsgLen) || 152 !DosGetMessage(NULL, 0L, (PCHAR)pszMsgStart + 1, 1024, ulRC, "OSO001H.MSG", &ulMsgLen)) 153 { 150 if (!DosGetMessage 151 (NULL, 0L, (PCHAR) pszMsgStart + 1, 1024, ulRC, "OSO001.MSG", &ulMsgLen) 152 || !DosGetMessage(NULL, 0L, (PCHAR) pszMsgStart + 1, 1024, ulRC, 153 "OSO001H.MSG", &ulMsgLen)) { 154 154 // Got message 155 155 pszMsgStart[ulMsgLen + 1] = 0; // Terminate … … 160 160 // Chop trailing NL CR TAB 161 161 while (*psz && 162 (*psz == '\r' || *psz == '\n' || *psz == ' ' || *psz == '\t')) 163 { 162 (*psz == '\r' || *psz == '\n' || *psz == ' ' || *psz == '\t')) { 164 163 *psz-- = 0; 165 164 } … … 168 167 // Convert CR and NL combos to single space 169 168 psz = pszMsgStart; 170 while (*psz) 171 { 172 if (*psz == '\n' || *psz == '\r') 173 { 169 while (*psz) { 170 if (*psz == '\n' || *psz == '\r') { 174 171 while (*(psz + 1) == '\n' || *(psz + 1) == '\r') 175 172 memmove(psz, psz + 1, strlen(psz)); … … 181 178 } 182 179 183 return showMsg(mb_type | MB_ICONEXCLAMATION, 184 hwndOwner, 185 GetPString(IDS_DOSERR2TEXT), // Title 180 return showMsg(mb_type | MB_ICONEXCLAMATION, hwndOwner, GetPString(IDS_DOSERR2TEXT), // Title 186 181 szMsg); 187 182 188 } 183 } // Dos_Error 189 184 190 185 //== Dos_Error2: report Dos...() error using passed message id === 191 186 192 187 INT Dos_Error2(ULONG mb_type, ULONG ulRC, HWND hwndOwner, PCSZ pszFileName, 193 ULONG ulLineNo, UINT idMsg)194 { 195 return Dos_Error(mb_type, ulRC, hwndOwner, pszFileName, ulLineNo,196 197 } 188 ULONG ulLineNo, UINT idMsg) 189 { 190 return Dos_Error(mb_type, ulRC, hwndOwner, pszFileName, ulLineNo, 191 GetPString(idMsg)); 192 } // Dos_Error2 198 193 199 194 //== Runtime_Error: report runtime library error using passed message string === 200 195 201 VOID Runtime_Error(PCSZ pszSrcFile, UINT uSrcLineNo, PCSZ pszFmt, ...)196 VOID Runtime_Error(PCSZ pszSrcFile, UINT uSrcLineNo, PCSZ pszFmt, ...) 202 197 { 203 198 CHAR szMsg[4096]; … … 211 206 212 207 if (strchr(szMsg, ' ') == NULL) 213 strcat(szMsg, " failed."); 208 strcat(szMsg, " failed."); // Assume simple function name 214 209 215 210 sprintf(szMsg + strlen(szMsg), 216 211 // GetPString(IDS_DOSERR1TEXT), fixme 217 "\nModule: %s\nLinenumber: %u", 218 pszSrcFile, 219 uSrcLineNo); 220 221 showMsg(MB_ICONEXCLAMATION,HWND_DESKTOP,DEBUG_STRING,szMsg); 222 223 } // Runtime_Error 212 "\nModule: %s\nLinenumber: %u", pszSrcFile, uSrcLineNo); 213 214 showMsg(MB_ICONEXCLAMATION, HWND_DESKTOP, DEBUG_STRING, szMsg); 215 216 } // Runtime_Error 224 217 225 218 //== Runtime_Error2: report runtime library error using passed message id === … … 229 222 Runtime_Error(pszSrcFile, uSrcLineNo, GetPString(idMsg)); 230 223 231 } 224 } // Runtime_Error2 232 225 233 226 // fixme to be rename to Misc_Error … … 235 228 //=== saymsg: report misc error using passed message === 236 229 237 APIRET saymsg(ULONG mb_type, HWND hwnd, PCSZ pszTitle, PCSZ pszFmt, ...)238 { 239 CHAR szMsg[4096]; 240 va_list va; 241 242 va_start(va, pszFmt); 243 vsprintf(szMsg, pszFmt, va); 244 va_end(va); 245 246 return showMsg(mb_type, hwnd,pszTitle,szMsg);247 248 } 230 APIRET saymsg(ULONG mb_type, HWND hwnd, PCSZ pszTitle, PCSZ pszFmt, ...) 231 { 232 CHAR szMsg[4096]; 233 va_list va; 234 235 va_start(va, pszFmt); 236 vsprintf(szMsg, pszFmt, va); 237 va_end(va); 238 239 return showMsg(mb_type, hwnd, pszTitle, szMsg); 240 241 } // saymsg 249 242 250 243 //=== showMsg: display error popup === … … 252 245 static APIRET showMsg(ULONG mb_type, HWND hwnd, PCSZ pszTitle, PCSZ pszMsg) 253 246 { 254 if ((mb_type & (MB_YESNO | MB_YESNOCANCEL)) == 0) 255 { 247 if ((mb_type & (MB_YESNO | MB_YESNOCANCEL)) == 0) { 256 248 fputs(pszMsg, stderr); 257 249 fputc('\n', stderr); … … 262 254 hwnd = HWND_DESKTOP; 263 255 264 DosBeep(250, 100);256 DosBeep(250, 100); 265 257 266 258 return WinMessageBox(HWND_DESKTOP, // Parent 267 259 hwnd, // Owner 268 (PSZ)pszMsg, 269 (PSZ)pszTitle, 270 0, // help id 260 (PSZ) pszMsg, (PSZ) pszTitle, 0, // help id 271 261 mb_type | MB_MOVEABLE); 272 } 262 } // showMsg
Note:
See TracChangeset
for help on using the changeset viewer.