comparison src/os/win32/ngx_errno.c @ 103:6dfda4cf5200

nginx-0.0.1-2003-06-11-19:28:34 import
author Igor Sysoev <igor@sysoev.ru>
date Wed, 11 Jun 2003 15:28:34 +0000
parents c9b243802a17
children b5be4b0448d3
comparison
equal deleted inserted replaced
102:7e86d028d8f0 103:6dfda4cf5200
7 7
8 #include <ngx_config.h> 8 #include <ngx_config.h>
9 #include <ngx_core.h> 9 #include <ngx_core.h>
10 10
11 11
12 ngx_str_t wsa_errors[] = {
13 ngx_string("Invalid argument"), /* 10022 */
14 ngx_null_string, /* 10023 */
15 ngx_null_string, /* 10024 */
16 ngx_null_string, /* 10025 */
17 ngx_null_string, /* 10026 */
18 ngx_null_string, /* 10027 */
19 ngx_null_string, /* 10028 */
20 ngx_null_string, /* 10029 */
21 ngx_null_string, /* 10030 */
22 ngx_null_string, /* 10031 */
23 ngx_null_string, /* 10032 */
24 ngx_null_string, /* 10033 */
25 ngx_null_string, /* 10034 */
26 ngx_string("Resource temporarily unavailable") /* 10035 */
27 };
28
29
12 int ngx_strerror_r(ngx_err_t err, char *errstr, size_t size) 30 int ngx_strerror_r(ngx_err_t err, char *errstr, size_t size)
13 { 31 {
14 int len; 32 int n;
33 u_int len;
34 ngx_err_t format_error;
15 35
16 len = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM 36 len = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM
17 | FORMAT_MESSAGE_IGNORE_INSERTS, 37 | FORMAT_MESSAGE_IGNORE_INSERTS,
18 NULL, err, 38 NULL, err,
19 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), 39 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
20 errstr, size, NULL); 40 errstr, size, NULL);
21 41
22 /* add WSA error messages */ 42 if (len == 0) {
43 format_error = GetLastError();
23 44
24 if (len == 0) { 45 if (format_error == ERROR_MR_MID_NOT_FOUND) {
46 n = err - WSABASEERR - 22;
47
48 if (n >= 0 && n < 14) {
49 len = wsa_errors[n].len;
50
51 if (len) {
52 if (len > size) {
53 len = size;
54 }
55
56 ngx_memcpy(errstr, wsa_errors[n].data, len);
57 return len;
58 }
59 }
60 }
25 61
26 len = ngx_snprintf(errstr, size, 62 len = ngx_snprintf(errstr, size,
27 "FormatMessage error:(%d)", GetLastError()); 63 "FormatMessage() error:(%d)", format_error);
28 return len; 64 return len;
29 65
30 } 66 }
31 67
32 /* remove ".\r\n\0" */ 68 /* remove ".\r\n\0" */