34 char *arch_strerror(
unsigned int ErrorCode)
36 static char ErrorMessageBuffer[2048];
41 n = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS
42 | FORMAT_MESSAGE_MAX_WIDTH_MASK,
45 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
46 (LPTSTR) &ErrorMessageBuffer,
47 sizeof(ErrorMessageBuffer)-1,
52 ErrorMessageBuffer[n] = 0;
54 return ErrorMessageBuffer;
73 void arch_error(
int AUnused,
unsigned int ErrorCode,
const char *Format, ...)
76 char ErrorMessageBuffer[2048];
77 char ErrorMessageBuffer2[2048];
78 char *errorText = NULL;
80 UNREFERENCED_PARAMETER(AUnused);
84 if (Format && *Format)
88 _vsnprintf(ErrorMessageBuffer2,
sizeof(ErrorMessageBuffer2), Format, ap);
94 ErrorMessageBuffer2[
sizeof(ErrorMessageBuffer2) - 1] = 0;
101 errorText = arch_strerror(ErrorCode);
108 _snprintf(ErrorMessageBuffer,
sizeof(ErrorMessageBuffer),
"%s: %s", ErrorMessageBuffer2, errorText);
110 ErrorMessageBuffer[
sizeof(ErrorMessageBuffer)-1] = 0;
114 assert(
sizeof(ErrorMessageBuffer) >=
sizeof(ErrorMessageBuffer2));
116 strcpy(ErrorMessageBuffer, ErrorMessageBuffer2);
119 fprintf(stderr,
"%s\n", ErrorMessageBuffer);
124 int n = strlen(ErrorMessageBuffer);
126 if (n ==
sizeof(ErrorMessageBuffer))
129 ErrorMessageBuffer[n] =
'\n';
130 ErrorMessageBuffer[n+1] = 0;
131 OutputDebugString(ErrorMessageBuffer);
Define makros and functions which account for differences between the different architectures.