comparison src/os/win32/ngx_errno.c @ 0:4eff17414a43

nginx-0.0.1-2002-08-06-20:39:45 import The first code that uses "ngx_" prefix, the previous one used "gx_" prefix. At that point the code is not yet usable. The first draft ideas are dated back to 23.10.2001.
author Igor Sysoev <igor@sysoev.ru>
date Tue, 06 Aug 2002 16:39:45 +0000
parents
children c9b243802a17
comparison
equal deleted inserted replaced
-1:000000000000 0:4eff17414a43
1
2 /*
3 TODO:
4 add WSA error messages
5 test for English only messages
6 */
7
8 #include <ngx_config.h>
9 #include <ngx_string.h>
10 #include <ngx_errno.h>
11
12 int ngx_strerror_r(ngx_err_t err, char *errstr, size_t size)
13 {
14 int len;
15
16 len = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM
17 | FORMAT_MESSAGE_IGNORE_INSERTS,
18 NULL, err,
19 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
20 errstr, size, NULL);
21
22 /* add WSA error messages */
23
24 if (len == 0) {
25
26 len = ngx_snprintf(errstr, size,
27 "FormatMessage error:(%d)", GetLastError());
28 return len;
29
30 }
31
32 /* remove ".\r\n\0" */
33 while (errstr[len] == '\0' || errstr[len] == CR
34 || errstr[len] == LF || errstr[len] == '.')
35 --len;
36
37 return ++len;
38 }