2006-02-16 23:23:37 +00:00
|
|
|
/*
|
|
|
|
* ERROR.C - error reporting functions.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* History:
|
|
|
|
*
|
|
|
|
* 07/12/98 (Rob Lake)
|
|
|
|
* started
|
|
|
|
*
|
|
|
|
* 27-Jul-1998 (John P Price <linux-guru@gcfl.net>)
|
|
|
|
* added config.h include
|
|
|
|
*
|
2007-05-05 11:32:25 +00:00
|
|
|
* 24-Jan-1999 (Eric Kohl)
|
2006-02-16 23:23:37 +00:00
|
|
|
* Redirection safe!
|
|
|
|
*
|
2007-05-05 11:32:25 +00:00
|
|
|
* 02-Feb-1999 (Eric Kohl)
|
2006-02-16 23:23:37 +00:00
|
|
|
* Use FormatMessage() for error reports.
|
|
|
|
*
|
2013-06-30 13:23:30 +00:00
|
|
|
* 28-Apr-2005 (Magnus Olsen <magnus@greatlord.com>)
|
2013-06-30 00:08:43 +00:00
|
|
|
* Remove all hardcoded strings in En.rc
|
2006-02-16 23:23:37 +00:00
|
|
|
*/
|
|
|
|
|
2013-01-24 23:00:42 +00:00
|
|
|
#include "precomp.h"
|
2006-02-16 23:23:37 +00:00
|
|
|
|
|
|
|
|
|
|
|
VOID ErrorMessage (DWORD dwErrorCode, LPTSTR szFormat, ...)
|
|
|
|
{
|
2013-06-30 00:08:43 +00:00
|
|
|
TCHAR szMsg[RC_STRING_MAX_SIZE];
|
|
|
|
TCHAR szMessage[1024];
|
|
|
|
LPTSTR szError;
|
|
|
|
va_list arg_ptr;
|
|
|
|
|
|
|
|
if (dwErrorCode == ERROR_SUCCESS)
|
|
|
|
return;
|
|
|
|
|
|
|
|
nErrorLevel = 1;
|
|
|
|
|
|
|
|
if (szFormat)
|
|
|
|
{
|
2013-06-30 23:58:48 +00:00
|
|
|
va_start(arg_ptr, szFormat);
|
|
|
|
_vstprintf(szMessage, szFormat, arg_ptr);
|
|
|
|
va_end(arg_ptr);
|
2013-06-30 00:08:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER,
|
|
|
|
NULL, dwErrorCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
|
|
|
(LPTSTR)&szError, 0, NULL))
|
|
|
|
{
|
2013-07-02 23:07:15 +00:00
|
|
|
ConErrPrintf(_T("%s %s\n"), szError, szMessage);
|
2013-06-30 16:10:54 +00:00
|
|
|
if (szError)
|
2013-06-30 00:08:43 +00:00
|
|
|
LocalFree (szError);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Fall back just in case the error is not defined */
|
|
|
|
if (szFormat)
|
2013-07-02 23:07:15 +00:00
|
|
|
ConErrPrintf(_T("%s -- %s\n"), szMsg, szMessage);
|
2013-06-30 00:08:43 +00:00
|
|
|
else
|
2013-07-02 23:07:15 +00:00
|
|
|
ConErrPrintf(_T("%s\n"), szMsg);
|
2006-02-16 23:23:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
VOID error_parameter_format(TCHAR ch)
|
|
|
|
{
|
2013-06-30 00:08:43 +00:00
|
|
|
ConErrResPrintf(STRING_ERROR_PARAMETERF_ERROR, ch);
|
|
|
|
nErrorLevel = 1;
|
2006-02-16 23:23:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
VOID error_invalid_switch (TCHAR ch)
|
|
|
|
{
|
2013-06-30 00:08:43 +00:00
|
|
|
ConErrResPrintf(STRING_ERROR_INVALID_SWITCH, ch);
|
|
|
|
nErrorLevel = 1;
|
2006-02-16 23:23:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
VOID error_too_many_parameters (LPTSTR s)
|
|
|
|
{
|
2013-06-30 00:08:43 +00:00
|
|
|
ConErrResPrintf(STRING_ERROR_TOO_MANY_PARAMETERS, s);
|
|
|
|
nErrorLevel = 1;
|
2006-02-16 23:23:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
VOID error_path_not_found (VOID)
|
|
|
|
{
|
2013-06-30 00:08:43 +00:00
|
|
|
ConErrResPuts(STRING_ERROR_PATH_NOT_FOUND);
|
|
|
|
nErrorLevel = 1;
|
2006-02-16 23:23:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
VOID error_file_not_found (VOID)
|
|
|
|
{
|
2013-06-30 00:08:43 +00:00
|
|
|
ConErrResPuts(STRING_ERROR_FILE_NOT_FOUND);
|
|
|
|
nErrorLevel = 1;
|
2006-02-16 23:23:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
VOID error_sfile_not_found (LPTSTR f)
|
|
|
|
{
|
2013-06-30 00:08:43 +00:00
|
|
|
TCHAR szMsg[RC_STRING_MAX_SIZE];
|
2006-02-16 23:23:37 +00:00
|
|
|
|
2013-06-30 00:08:43 +00:00
|
|
|
LoadString(CMD_ModuleHandle, STRING_ERROR_FILE_NOT_FOUND, szMsg, RC_STRING_MAX_SIZE);
|
|
|
|
ConErrPrintf(_T("%s - %s\n"), szMsg, f);
|
|
|
|
nErrorLevel = 1;
|
2006-02-16 23:23:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
VOID error_req_param_missing (VOID)
|
|
|
|
{
|
2013-06-30 00:08:43 +00:00
|
|
|
ConErrResPuts(STRING_ERROR_REQ_PARAM_MISSING);
|
|
|
|
nErrorLevel = 1;
|
2006-02-16 23:23:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
VOID error_invalid_drive (VOID)
|
|
|
|
{
|
2013-06-30 00:08:43 +00:00
|
|
|
ConErrResPuts(STRING_ERROR_INVALID_DRIVE);
|
|
|
|
nErrorLevel = 1;
|
2006-02-16 23:23:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-03-13 01:26:08 +00:00
|
|
|
VOID error_bad_command (LPTSTR s)
|
2006-02-16 23:23:37 +00:00
|
|
|
{
|
2013-06-30 00:08:43 +00:00
|
|
|
ConErrResPrintf(STRING_ERROR_BADCOMMAND, s);
|
|
|
|
nErrorLevel = 9009;
|
2006-02-16 23:23:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
VOID error_no_pipe (VOID)
|
|
|
|
{
|
2013-06-30 00:08:43 +00:00
|
|
|
ConErrResPuts(STRING_ERROR_CANNOTPIPE);
|
|
|
|
nErrorLevel = 1;
|
2006-02-16 23:23:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
VOID error_out_of_memory (VOID)
|
|
|
|
{
|
2013-06-30 00:08:43 +00:00
|
|
|
ConErrResPuts(STRING_ERROR_OUT_OF_MEMORY);
|
|
|
|
nErrorLevel = 1;
|
2006-02-16 23:23:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
VOID error_invalid_parameter_format (LPTSTR s)
|
|
|
|
{
|
2013-06-30 00:08:43 +00:00
|
|
|
ConErrResPrintf(STRING_ERROR_INVALID_PARAM_FORMAT, s);
|
|
|
|
nErrorLevel = 1;
|
2006-02-16 23:23:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
VOID error_syntax (LPTSTR s)
|
|
|
|
{
|
2013-06-30 00:08:43 +00:00
|
|
|
TCHAR szMsg[RC_STRING_MAX_SIZE];
|
2006-02-16 23:23:37 +00:00
|
|
|
|
2013-06-30 00:08:43 +00:00
|
|
|
LoadString(CMD_ModuleHandle, STRING_ERROR_ERROR2, szMsg, RC_STRING_MAX_SIZE);
|
2006-02-16 23:23:37 +00:00
|
|
|
|
2013-06-30 00:08:43 +00:00
|
|
|
if (s)
|
|
|
|
ConErrPrintf(_T("%s - %s\n"), szMsg, s);
|
|
|
|
else
|
|
|
|
ConErrPrintf(_T("%s.\n"), szMsg);
|
2006-02-16 23:23:37 +00:00
|
|
|
|
2013-06-30 00:08:43 +00:00
|
|
|
nErrorLevel = 1;
|
2006-02-16 23:23:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
VOID msg_pause (VOID)
|
|
|
|
{
|
2013-06-30 00:08:43 +00:00
|
|
|
ConOutResPuts(STRING_ERROR_D_PAUSEMSG);
|
2006-02-16 23:23:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* EOF */
|