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.
20 #define WIN32_LEAN_AND_MEAN
31 #define INVALID_SWITCH _T("Invalid switch - /%c\n")
32 #define TOO_MANY_PARAMETERS _T("Too many parameters - %s\n")
33 #define PATH_NOT_FOUND _T("Path not found\n")
34 #define FILE_NOT_FOUND _T("File not found")
35 #define REQ_PARAM_MISSING _T("Required parameter missing\n")
36 #define INVALID_DRIVE _T("Invalid drive specification\n")
37 #define INVALID_PARAM_FORMAT _T("Invalid parameter format - %s\n")
38 #define BADCOMMAND _T("Bad command or filename\n")
39 #define OUT_OF_MEMORY _T("Out of memory error.\n")
40 #define CANNOTPIPE _T("Error! Cannot pipe! Cannot open temporary file!\n")
42 #define D_PAUSEMSG _T("Press any key to continue . . .")
46 VOID
ErrorMessage (DWORD dwErrorCode
, LPTSTR szFormat
, ...)
48 TCHAR szMessage
[1024];
52 if (dwErrorCode
== ERROR_SUCCESS
)
55 va_start (arg_ptr
, szFormat
);
56 wvsprintf (szMessage
, szFormat
, arg_ptr
);
61 if (FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM
| FORMAT_MESSAGE_ALLOCATE_BUFFER
,
62 NULL
, dwErrorCode
, MAKELANGID(LANG_NEUTRAL
, SUBLANG_DEFAULT
),
63 (LPTSTR
)&szError
, 0, NULL
))
65 ConErrPrintf (_T("%s %s\n"), szError
, szMessage
);
71 ConErrPrintf (_T("Unknown error! Error code: 0x%lx\n"), dwErrorCode
);
72 // ConErrPrintf (_T("No error message available!\n"));
80 case ERROR_FILE_NOT_FOUND
:
81 szError
= _T("File not found --");
84 case ERROR_PATH_NOT_FOUND
:
85 szError
= _T("Path not found --");
89 ConErrPrintf (_T("Unknown error! Error code: 0x%lx\n"), dwErrorCode
);
93 ConErrPrintf (_T("%s %s\n"), szError
, szMessage
);
99 VOID
error_invalid_switch (TCHAR ch
)
101 ConErrPrintf (INVALID_SWITCH
, ch
);
105 VOID
error_too_many_parameters (LPTSTR s
)
107 ConErrPrintf (TOO_MANY_PARAMETERS
, s
);
111 VOID
error_path_not_found (VOID
)
113 ConErrPrintf (PATH_NOT_FOUND
);
117 VOID
error_file_not_found (VOID
)
119 ConErrPrintf (FILE_NOT_FOUND
);
123 VOID
error_sfile_not_found (LPTSTR f
)
125 ConErrPrintf (FILE_NOT_FOUND
_T(" - %s\n"), f
);
129 VOID
error_req_param_missing (VOID
)
131 ConErrPrintf (REQ_PARAM_MISSING
);
135 VOID
error_invalid_drive (VOID
)
137 ConErrPrintf (INVALID_DRIVE
);
141 VOID
error_bad_command (VOID
)
143 ConErrPrintf (BADCOMMAND
);
147 VOID
error_no_pipe (VOID
)
149 ConErrPrintf (CANNOTPIPE
);
153 VOID
error_out_of_memory (VOID
)
155 ConErrPrintf (OUT_OF_MEMORY
);
159 VOID
error_invalid_parameter_format (LPTSTR s
)
161 ConErrPrintf (INVALID_PARAM_FORMAT
, s
);
165 VOID
error_syntax (LPTSTR s
)
168 ConErrPrintf (_T("Syntax error - %s\n"), s
);
170 ConErrPrintf (_T("Syntax error.\n"));
174 VOID
msg_pause (VOID
)
176 ConOutPuts (D_PAUSEMSG
);