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)
16 * 02-Feb-1999 (Eric Kohl)
17 * Use FormatMessage() for error reports.
19 * 28-Apr-2005 (Magnus Olsen <magnus@greatlord.com>)
20 * Remove all hardcoded strings in En.rc
26 VOID
ErrorMessage (DWORD dwErrorCode
, LPTSTR szFormat
, ...)
28 TCHAR szMsg
[RC_STRING_MAX_SIZE
];
29 TCHAR szMessage
[1024];
33 if (dwErrorCode
== ERROR_SUCCESS
)
40 va_start(arg_ptr
, szFormat
);
41 _vstprintf(szMessage
, szFormat
, arg_ptr
);
45 if (FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM
| FORMAT_MESSAGE_ALLOCATE_BUFFER
,
46 NULL
, dwErrorCode
, MAKELANGID(LANG_NEUTRAL
, SUBLANG_DEFAULT
),
47 (LPTSTR
)&szError
, 0, NULL
))
49 ConErrPrintf(_T("%s %s\n"), szError
, szMessage
);
55 /* Fall back just in case the error is not defined */
57 ConErrPrintf(_T("%s -- %s\n"), szMsg
, szMessage
);
59 ConErrPrintf(_T("%s\n"), szMsg
);
62 VOID
error_parameter_format(TCHAR ch
)
64 ConErrResPrintf(STRING_ERROR_PARAMETERF_ERROR
, ch
);
69 VOID
error_invalid_switch (TCHAR ch
)
71 ConErrResPrintf(STRING_ERROR_INVALID_SWITCH
, ch
);
76 VOID
error_too_many_parameters (LPTSTR s
)
78 ConErrResPrintf(STRING_ERROR_TOO_MANY_PARAMETERS
, s
);
83 VOID
error_path_not_found (VOID
)
85 ConErrResPuts(STRING_ERROR_PATH_NOT_FOUND
);
90 VOID
error_file_not_found (VOID
)
92 ConErrResPuts(STRING_ERROR_FILE_NOT_FOUND
);
97 VOID
error_sfile_not_found (LPTSTR f
)
99 TCHAR szMsg
[RC_STRING_MAX_SIZE
];
101 LoadString(CMD_ModuleHandle
, STRING_ERROR_FILE_NOT_FOUND
, szMsg
, ARRAYSIZE(szMsg
));
102 ConErrPrintf(_T("%s - %s\n"), szMsg
, f
);
107 VOID
error_req_param_missing (VOID
)
109 ConErrResPuts(STRING_ERROR_REQ_PARAM_MISSING
);
114 VOID
error_invalid_drive (VOID
)
116 ConErrResPuts(STRING_ERROR_INVALID_DRIVE
);
121 VOID
error_bad_command (LPTSTR s
)
123 ConErrResPrintf(STRING_ERROR_BADCOMMAND
, s
);
128 VOID
error_no_pipe (VOID
)
130 ConErrResPuts(STRING_ERROR_CANNOTPIPE
);
135 VOID
error_out_of_memory (VOID
)
137 ConErrResPuts(STRING_ERROR_OUT_OF_MEMORY
);
142 VOID
error_invalid_parameter_format (LPTSTR s
)
144 ConErrResPrintf(STRING_ERROR_INVALID_PARAM_FORMAT
, s
);
149 VOID
error_syntax (LPTSTR s
)
151 TCHAR szMsg
[RC_STRING_MAX_SIZE
];
153 LoadString(CMD_ModuleHandle
, STRING_ERROR_ERROR2
, szMsg
, ARRAYSIZE(szMsg
));
156 ConErrPrintf(_T("%s - %s\n"), szMsg
, s
);
158 ConErrPrintf(_T("%s.\n"), szMsg
);
164 VOID
msg_pause (VOID
)
166 ConOutResPuts(STRING_ERROR_D_PAUSEMSG
);