2002-08-07 00:39:45 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
TODO:
|
2003-05-30 22:27:59 +08:00
|
|
|
add WSA error messages for NT and 98
|
2002-08-07 00:39:45 +08:00
|
|
|
test for English only messages
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <ngx_config.h>
|
2003-05-30 22:27:59 +08:00
|
|
|
#include <ngx_core.h>
|
|
|
|
|
2002-08-07 00:39:45 +08:00
|
|
|
|
|
|
|
int ngx_strerror_r(ngx_err_t err, char *errstr, size_t size)
|
|
|
|
{
|
|
|
|
int len;
|
|
|
|
|
|
|
|
len = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM
|
|
|
|
| FORMAT_MESSAGE_IGNORE_INSERTS,
|
|
|
|
NULL, err,
|
|
|
|
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
|
|
|
errstr, size, NULL);
|
|
|
|
|
|
|
|
/* add WSA error messages */
|
|
|
|
|
|
|
|
if (len == 0) {
|
|
|
|
|
|
|
|
len = ngx_snprintf(errstr, size,
|
|
|
|
"FormatMessage error:(%d)", GetLastError());
|
|
|
|
return len;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* remove ".\r\n\0" */
|
|
|
|
while (errstr[len] == '\0' || errstr[len] == CR
|
|
|
|
|| errstr[len] == LF || errstr[len] == '.')
|
|
|
|
--len;
|
|
|
|
|
|
|
|
return ++len;
|
|
|
|
}
|