Mercurial > hg > nginx
annotate src/os/win32/ngx_errno.c @ 2898:a3501111378c
Win32 returns ERROR_PATH_NOT_FOUND instead of ERROR_FILE_NOT_FOUND
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Thu, 28 May 2009 15:32:22 +0000 |
parents | e70ac6e13f31 |
children | e294f37401c0 |
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 |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
7 #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
|
8 #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
|
9 |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
10 |
2335
3d8ab5957202
ngx_strerror_r() style and size == 0 bug fix
Igor Sysoev <igor@sysoev.ru>
parents:
473
diff
changeset
|
11 u_char * |
3d8ab5957202
ngx_strerror_r() style and size == 0 bug fix
Igor Sysoev <igor@sysoev.ru>
parents:
473
diff
changeset
|
12 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
|
13 { |
2770
e70ac6e13f31
fallback to neutral language in FormatMessage()
Igor Sysoev <igor@sysoev.ru>
parents:
2766
diff
changeset
|
14 u_int len; |
e70ac6e13f31
fallback to neutral language in FormatMessage()
Igor Sysoev <igor@sysoev.ru>
parents:
2766
diff
changeset
|
15 static u_long lang = MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US); |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
16 |
461 | 17 if (size == 0) { |
18 return errstr; | |
19 } | |
20 | |
2770
e70ac6e13f31
fallback to neutral language in FormatMessage()
Igor Sysoev <igor@sysoev.ru>
parents:
2766
diff
changeset
|
21 len = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, |
e70ac6e13f31
fallback to neutral language in FormatMessage()
Igor Sysoev <igor@sysoev.ru>
parents:
2766
diff
changeset
|
22 NULL, err, lang, (char *) errstr, size, NULL); |
e70ac6e13f31
fallback to neutral language in FormatMessage()
Igor Sysoev <igor@sysoev.ru>
parents:
2766
diff
changeset
|
23 |
e70ac6e13f31
fallback to neutral language in FormatMessage()
Igor Sysoev <igor@sysoev.ru>
parents:
2766
diff
changeset
|
24 if (len == 0 && lang && GetLastError() == ERROR_RESOURCE_LANG_NOT_FOUND) { |
e70ac6e13f31
fallback to neutral language in FormatMessage()
Igor Sysoev <igor@sysoev.ru>
parents:
2766
diff
changeset
|
25 |
e70ac6e13f31
fallback to neutral language in FormatMessage()
Igor Sysoev <igor@sysoev.ru>
parents:
2766
diff
changeset
|
26 /* |
e70ac6e13f31
fallback to neutral language in FormatMessage()
Igor Sysoev <igor@sysoev.ru>
parents:
2766
diff
changeset
|
27 * Try to use English messages first and fallback to a language, |
e70ac6e13f31
fallback to neutral language in FormatMessage()
Igor Sysoev <igor@sysoev.ru>
parents:
2766
diff
changeset
|
28 * based on locale: non-English Windows have no English messages |
e70ac6e13f31
fallback to neutral language in FormatMessage()
Igor Sysoev <igor@sysoev.ru>
parents:
2766
diff
changeset
|
29 * at all. This way allows to use English messages at least on |
e70ac6e13f31
fallback to neutral language in FormatMessage()
Igor Sysoev <igor@sysoev.ru>
parents:
2766
diff
changeset
|
30 * Windows with MUI. |
e70ac6e13f31
fallback to neutral language in FormatMessage()
Igor Sysoev <igor@sysoev.ru>
parents:
2766
diff
changeset
|
31 */ |
e70ac6e13f31
fallback to neutral language in FormatMessage()
Igor Sysoev <igor@sysoev.ru>
parents:
2766
diff
changeset
|
32 |
e70ac6e13f31
fallback to neutral language in FormatMessage()
Igor Sysoev <igor@sysoev.ru>
parents:
2766
diff
changeset
|
33 lang = 0; |
e70ac6e13f31
fallback to neutral language in FormatMessage()
Igor Sysoev <igor@sysoev.ru>
parents:
2766
diff
changeset
|
34 |
e70ac6e13f31
fallback to neutral language in FormatMessage()
Igor Sysoev <igor@sysoev.ru>
parents:
2766
diff
changeset
|
35 len = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, |
e70ac6e13f31
fallback to neutral language in FormatMessage()
Igor Sysoev <igor@sysoev.ru>
parents:
2766
diff
changeset
|
36 NULL, err, lang, (char *) errstr, size, NULL); |
e70ac6e13f31
fallback to neutral language in FormatMessage()
Igor Sysoev <igor@sysoev.ru>
parents:
2766
diff
changeset
|
37 } |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
38 |
103
6dfda4cf5200
nginx-0.0.1-2003-06-11-19:28:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
98
diff
changeset
|
39 if (len == 0) { |
461 | 40 return ngx_snprintf(errstr, size, |
2740
e5a4be07c3eb
axe incomplete support of Winsock error descriptions on NT
Igor Sysoev <igor@sysoev.ru>
parents:
2739
diff
changeset
|
41 "FormatMessage() error:(%d)", GetLastError()); |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
42 } |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
43 |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
44 /* remove ".\r\n\0" */ |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
45 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
|
46 || errstr[len] == LF || errstr[len] == '.') |
461 | 47 { |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
48 --len; |
461 | 49 } |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
50 |
461 | 51 return &errstr[++len]; |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
52 } |