Mercurial > hg > nginx-quic
annotate src/os/win32/ngx_errno.c @ 2305:9f48105ba999
release-0.7.21 tag
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Tue, 11 Nov 2008 20:04:59 +0000 |
parents | 8e8f3af115b5 |
children | 3d8ab5957202 |
rev | line source |
---|---|
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1 |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
2 /* |
444
42d11f017717
nginx-0.1.0-2004-09-29-20:00:49 import; remove years from copyright
Igor Sysoev <igor@sysoev.ru>
parents:
441
diff
changeset
|
3 * Copyright (C) Igor Sysoev |
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
186
diff
changeset
|
4 */ |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
186
diff
changeset
|
5 |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
186
diff
changeset
|
6 |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
186
diff
changeset
|
7 /* |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
186
diff
changeset
|
8 * TODO: |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
186
diff
changeset
|
9 * add WSA error messages for NT and 98 |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
186
diff
changeset
|
10 * test for English only messages |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
186
diff
changeset
|
11 */ |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
12 |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
13 #include <ngx_config.h> |
98
c9b243802a17
nginx-0.0.1-2003-05-30-18:27:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
0
diff
changeset
|
14 #include <ngx_core.h> |
c9b243802a17
nginx-0.0.1-2003-05-30-18:27:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
0
diff
changeset
|
15 |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
16 |
186
c1f3a3c7c5db
nginx-0.0.1-2003-11-17-00:49:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
107
diff
changeset
|
17 static ngx_str_t wsa_errors[] = { |
461 | 18 ngx_string("An invalid argument was supplied"), /* WSAEINVAL 10022 */ |
19 ngx_string("Too many open sockets"), /* WSAEMFILE 10023 */ | |
20 | |
21 ngx_null_string, /* 10024 */ | |
22 ngx_null_string, /* 10025 */ | |
23 ngx_null_string, /* 10026 */ | |
24 ngx_null_string, /* 10027 */ | |
25 ngx_null_string, /* 10028 */ | |
26 ngx_null_string, /* 10029 */ | |
27 ngx_null_string, /* 10030 */ | |
28 ngx_null_string, /* 10031 */ | |
29 ngx_null_string, /* 10032 */ | |
30 ngx_null_string, /* 10033 */ | |
31 ngx_null_string, /* 10034 */ | |
32 | |
33 /* WSAEWOULDBLOCK 10035 */ | |
34 ngx_string("A non-blocking socket operation could not be completed " | |
35 "immediately"), | |
36 | |
37 ngx_null_string, /* 10036 */ | |
38 ngx_null_string, /* 10037 */ | |
39 | |
40 /* WSAENOTSOCK 10038 */ | |
41 ngx_string("An operation was attempted on something that is not a socket"), | |
42 | |
43 ngx_null_string, /* 10039 */ | |
44 ngx_null_string, /* 10040 */ | |
45 ngx_null_string, /* 10041 */ | |
473 | 46 |
47 /* WSAENOPROTOOPT 10042 */ | |
48 ngx_string("An unknown, invalid, or unsupported option or level was " | |
49 "specified in a getsockopt or setsockopt call"), | |
50 | |
461 | 51 ngx_null_string, /* 10043 */ |
52 ngx_null_string, /* 10044 */ | |
53 ngx_null_string, /* 10045 */ | |
54 ngx_null_string, /* 10046 */ | |
55 ngx_null_string, /* 10047 */ | |
56 ngx_null_string, /* 10048 */ | |
57 ngx_null_string, /* 10049 */ | |
58 ngx_null_string, /* 10050 */ | |
59 ngx_null_string, /* 10051 */ | |
60 ngx_null_string, /* 10052 */ | |
61 ngx_null_string, /* 10053 */ | |
62 | |
63 /* WSAECONNRESET 10054 */ | |
64 ngx_string("An existing connection was forcibly closed by the remote host"), | |
65 | |
66 /* WSAENOBUFS 10055 */ | |
67 ngx_string("An operation on a socket could not be performed because " | |
68 "the system lacked sufficient buffer space or " | |
69 "because a queue was full"), | |
70 | |
71 /* WSAEISCONN 10056 */ | |
72 ngx_string("A connect request was made on an already connected socket"), | |
73 | |
74 /* WSAENOTCONN 10057 */ | |
75 ngx_string("A request to send or receive data was disallowed because" | |
76 "the socket is not connected and (when sending on a datagram " | |
77 "socket using a sendto call) no address was supplied"), | |
78 | |
79 ngx_null_string, /* 10058 */ | |
80 ngx_null_string, /* 10059 */ | |
81 | |
82 /* WSAETIMEDOUT 10060 */ | |
83 ngx_string("A connection attempt failed because the connected party " | |
84 "did not properly respond after a period of time, " | |
85 "or established connection failed because connected host " | |
86 "has failed to respond"), | |
87 | |
88 /* WSAECONNREFUSED 10061 */ | |
89 ngx_string("No connection could be made because the target machine " | |
90 "actively refused it") | |
103
6dfda4cf5200
nginx-0.0.1-2003-06-11-19:28:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
98
diff
changeset
|
91 }; |
6dfda4cf5200
nginx-0.0.1-2003-06-11-19:28:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
98
diff
changeset
|
92 |
6dfda4cf5200
nginx-0.0.1-2003-06-11-19:28:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
98
diff
changeset
|
93 |
461 | 94 u_char *ngx_strerror_r(ngx_err_t err, u_char *errstr, size_t size) |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
95 { |
103
6dfda4cf5200
nginx-0.0.1-2003-06-11-19:28:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
98
diff
changeset
|
96 int n; |
6dfda4cf5200
nginx-0.0.1-2003-06-11-19:28:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
98
diff
changeset
|
97 u_int len; |
6dfda4cf5200
nginx-0.0.1-2003-06-11-19:28:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
98
diff
changeset
|
98 ngx_err_t format_error; |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
99 |
461 | 100 if (size == 0) { |
101 return errstr; | |
102 } | |
103 | |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
104 len = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
107
b5be4b0448d3
nginx-0.0.1-2003-07-01-19:00:03 import
Igor Sysoev <igor@sysoev.ru>
parents:
103
diff
changeset
|
105 |FORMAT_MESSAGE_IGNORE_INSERTS, |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
106 NULL, err, |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
107 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), |
461 | 108 (char *) errstr, size, NULL); |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
109 |
103
6dfda4cf5200
nginx-0.0.1-2003-06-11-19:28:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
98
diff
changeset
|
110 if (len == 0) { |
6dfda4cf5200
nginx-0.0.1-2003-06-11-19:28:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
98
diff
changeset
|
111 format_error = GetLastError(); |
6dfda4cf5200
nginx-0.0.1-2003-06-11-19:28:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
98
diff
changeset
|
112 |
6dfda4cf5200
nginx-0.0.1-2003-06-11-19:28:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
98
diff
changeset
|
113 if (format_error == ERROR_MR_MID_NOT_FOUND) { |
461 | 114 n = err - WSAEINVAL; |
103
6dfda4cf5200
nginx-0.0.1-2003-06-11-19:28:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
98
diff
changeset
|
115 |
461 | 116 if (n >= 0 && n <= WSAECONNREFUSED - WSAEINVAL) { |
103
6dfda4cf5200
nginx-0.0.1-2003-06-11-19:28:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
98
diff
changeset
|
117 len = wsa_errors[n].len; |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
118 |
103
6dfda4cf5200
nginx-0.0.1-2003-06-11-19:28:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
98
diff
changeset
|
119 if (len) { |
6dfda4cf5200
nginx-0.0.1-2003-06-11-19:28:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
98
diff
changeset
|
120 if (len > size) { |
6dfda4cf5200
nginx-0.0.1-2003-06-11-19:28:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
98
diff
changeset
|
121 len = size; |
6dfda4cf5200
nginx-0.0.1-2003-06-11-19:28:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
98
diff
changeset
|
122 } |
6dfda4cf5200
nginx-0.0.1-2003-06-11-19:28:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
98
diff
changeset
|
123 |
6dfda4cf5200
nginx-0.0.1-2003-06-11-19:28:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
98
diff
changeset
|
124 ngx_memcpy(errstr, wsa_errors[n].data, len); |
461 | 125 |
126 return errstr + len; | |
103
6dfda4cf5200
nginx-0.0.1-2003-06-11-19:28:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
98
diff
changeset
|
127 } |
6dfda4cf5200
nginx-0.0.1-2003-06-11-19:28:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
98
diff
changeset
|
128 } |
6dfda4cf5200
nginx-0.0.1-2003-06-11-19:28:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
98
diff
changeset
|
129 } |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
130 |
461 | 131 return ngx_snprintf(errstr, size, |
132 "FormatMessage() error:(%d)", format_error); | |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
133 } |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
134 |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
135 /* remove ".\r\n\0" */ |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
136 while (errstr[len] == '\0' || errstr[len] == CR |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
137 || errstr[len] == LF || errstr[len] == '.') |
461 | 138 { |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
139 --len; |
461 | 140 } |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
141 |
461 | 142 return &errstr[++len]; |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
143 } |