2 * ERROR.C - error reporting functions.
10 * 27-Jul-1998 (John P Price <linux-guru@gcfl.net>)
11 * added config.h include
13 * 24-Jan-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
16 * 02-Feb-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
17 * Use FormatMessage() for error reports.
30 #define INVALID_SWITCH _T("Invalid switch - /%c\n")
31 #define TOO_MANY_PARAMETERS _T("Too many parameters - %s\n")
32 #define PATH_NOT_FOUND _T("Path not found\n")
33 #define FILE_NOT_FOUND _T("File not found\n")
34 #define REQ_PARAM_MISSING _T("Required parameter missing\n")
35 #define INVALID_DRIVE _T("Invalid drive specification\n")
36 #define INVALID_PARAM_FORMAT _T("Invalid parameter format - %s\n")
37 #define BADCOMMAND _T("Bad command or filename\n")
38 #define OUT_OF_MEMORY _T("Out of memory error.\n")
39 #define CANNOTPIPE _T("Error! Cannot pipe! Cannot open temporary file!\n")
41 #define D_PAUSEMSG _T("Press any key to continue . . .")
45 VOID ErrorMessage (DWORD dwErrorCode, LPTSTR szFormat, ...)
47 TCHAR szMessage[1024];
51 if (dwErrorCode == ERROR_SUCCESS)
54 va_start (arg_ptr, szFormat);
55 _vstprintf (szMessage, szFormat, arg_ptr);
60 if (FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER,
61 NULL, dwErrorCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
62 (LPTSTR)&szError, 0, NULL))
64 ConErrPrintf (_T("%s %s\n"), szError, szMessage);
70 ConErrPrintf (_T("Unknown error! Error code: 0x%lx\n"), dwErrorCode);
78 case ERROR_FILE_NOT_FOUND:
79 szError = _T("File not found --");
82 case ERROR_PATH_NOT_FOUND:
83 szError = _T("Path not found --");
87 ConErrPrintf (_T("Unknown error! Error code: 0x%lx\n"), dwErrorCode);
91 ConErrPrintf (_T("%s %s\n"), szError, szMessage);
97 VOID error_invalid_switch (TCHAR ch)
99 ConErrPrintf (INVALID_SWITCH, ch);
103 VOID error_too_many_parameters (LPTSTR s)
105 ConErrPrintf (TOO_MANY_PARAMETERS, s);
109 VOID error_path_not_found (VOID)
111 ConErrPrintf (PATH_NOT_FOUND);
115 VOID error_file_not_found (VOID)
117 ConErrPrintf (FILE_NOT_FOUND);
121 VOID error_sfile_not_found (LPTSTR f)
123 ConErrPrintf (FILE_NOT_FOUND _T(" - %s\n"), f);
127 VOID error_req_param_missing (VOID)
129 ConErrPrintf (REQ_PARAM_MISSING);
133 VOID error_invalid_drive (VOID)
135 ConErrPrintf (INVALID_DRIVE);
139 VOID error_bad_command (VOID)
141 ConErrPrintf (BADCOMMAND);
145 VOID error_no_pipe (VOID)
147 ConErrPrintf (CANNOTPIPE);
151 VOID error_out_of_memory (VOID)
153 ConErrPrintf (OUT_OF_MEMORY);
157 VOID error_invalid_parameter_format (LPTSTR s)
159 ConErrPrintf (INVALID_PARAM_FORMAT, s);
163 VOID error_syntax (LPTSTR s)
166 ConErrPrintf (_T("Syntax error - %s\n"), s);
168 ConErrPrintf (_T("Syntax error.\n"));
172 VOID msg_pause (VOID)
174 ConOutPuts (D_PAUSEMSG);