Mercurial > hg > nginx
annotate src/os/unix/ngx_errno.c @ 2631:73571521c2eb
add debug logging
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Wed, 01 Apr 2009 13:01:50 +0000 |
parents | 3d8ab5957202 |
children | e294f37401c0 |
rev | line source |
---|---|
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:
305
diff
changeset
|
1 |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
305
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:
305
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:
305
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:
305
diff
changeset
|
6 |
210
00cafae0bdf1
nginx-0.0.1-2003-12-14-23:10:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
7 #include <ngx_config.h> |
00cafae0bdf1
nginx-0.0.1-2003-12-14-23:10:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
8 #include <ngx_core.h> |
00cafae0bdf1
nginx-0.0.1-2003-12-14-23:10:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
9 |
00cafae0bdf1
nginx-0.0.1-2003-12-14-23:10:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
10 |
469 | 11 #if (NGX_HAVE_STRERROR_R) |
211
fd9fecc4193f
nginx-0.0.1-2003-12-15-16:57:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
210
diff
changeset
|
12 |
2335
3d8ab5957202
ngx_strerror_r() style and size == 0 bug fix
Igor Sysoev <igor@sysoev.ru>
parents:
501
diff
changeset
|
13 u_char * |
3d8ab5957202
ngx_strerror_r() style and size == 0 bug fix
Igor Sysoev <igor@sysoev.ru>
parents:
501
diff
changeset
|
14 ngx_strerror_r(int err, u_char *errstr, size_t size) |
210
00cafae0bdf1
nginx-0.0.1-2003-12-14-23:10:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
15 { |
00cafae0bdf1
nginx-0.0.1-2003-12-14-23:10:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
16 if (size == 0) { |
2335
3d8ab5957202
ngx_strerror_r() style and size == 0 bug fix
Igor Sysoev <igor@sysoev.ru>
parents:
501
diff
changeset
|
17 return errstr; |
210
00cafae0bdf1
nginx-0.0.1-2003-12-14-23:10:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
18 } |
00cafae0bdf1
nginx-0.0.1-2003-12-14-23:10:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
19 |
00cafae0bdf1
nginx-0.0.1-2003-12-14-23:10:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
20 errstr[0] = '\0'; |
00cafae0bdf1
nginx-0.0.1-2003-12-14-23:10:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
21 |
461 | 22 strerror_r(err, (char *) errstr, size); |
210
00cafae0bdf1
nginx-0.0.1-2003-12-14-23:10:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
23 |
461 | 24 while (*errstr && size) { |
25 errstr++; | |
26 size--; | |
210
00cafae0bdf1
nginx-0.0.1-2003-12-14-23:10:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
27 } |
00cafae0bdf1
nginx-0.0.1-2003-12-14-23:10:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
28 |
461 | 29 return errstr; |
210
00cafae0bdf1
nginx-0.0.1-2003-12-14-23:10:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
30 } |
211
fd9fecc4193f
nginx-0.0.1-2003-12-15-16:57:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
210
diff
changeset
|
31 |
469 | 32 #elif (NGX_HAVE_GNU_STRERROR_R) |
256
8e39cab6abd5
nginx-0.0.2-2004-02-10-19:23:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
211
diff
changeset
|
33 |
8e39cab6abd5
nginx-0.0.2-2004-02-10-19:23:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
211
diff
changeset
|
34 /* Linux strerror_r() */ |
8e39cab6abd5
nginx-0.0.2-2004-02-10-19:23:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
211
diff
changeset
|
35 |
2335
3d8ab5957202
ngx_strerror_r() style and size == 0 bug fix
Igor Sysoev <igor@sysoev.ru>
parents:
501
diff
changeset
|
36 u_char * |
3d8ab5957202
ngx_strerror_r() style and size == 0 bug fix
Igor Sysoev <igor@sysoev.ru>
parents:
501
diff
changeset
|
37 ngx_strerror_r(int err, u_char *errstr, size_t size) |
256
8e39cab6abd5
nginx-0.0.2-2004-02-10-19:23:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
211
diff
changeset
|
38 { |
501 | 39 char *str; |
256
8e39cab6abd5
nginx-0.0.2-2004-02-10-19:23:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
211
diff
changeset
|
40 |
8e39cab6abd5
nginx-0.0.2-2004-02-10-19:23:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
211
diff
changeset
|
41 if (size == 0) { |
2335
3d8ab5957202
ngx_strerror_r() style and size == 0 bug fix
Igor Sysoev <igor@sysoev.ru>
parents:
501
diff
changeset
|
42 return errstr; |
256
8e39cab6abd5
nginx-0.0.2-2004-02-10-19:23:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
211
diff
changeset
|
43 } |
8e39cab6abd5
nginx-0.0.2-2004-02-10-19:23:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
211
diff
changeset
|
44 |
8e39cab6abd5
nginx-0.0.2-2004-02-10-19:23:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
211
diff
changeset
|
45 errstr[0] = '\0'; |
8e39cab6abd5
nginx-0.0.2-2004-02-10-19:23:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
211
diff
changeset
|
46 |
461 | 47 str = strerror_r(err, (char *) errstr, size); |
256
8e39cab6abd5
nginx-0.0.2-2004-02-10-19:23:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
211
diff
changeset
|
48 |
461 | 49 if (str != (char *) errstr) { |
50 return ngx_cpystrn(errstr, (u_char *) str, size); | |
256
8e39cab6abd5
nginx-0.0.2-2004-02-10-19:23:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
211
diff
changeset
|
51 } |
8e39cab6abd5
nginx-0.0.2-2004-02-10-19:23:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
211
diff
changeset
|
52 |
461 | 53 while (*errstr && size) { |
54 errstr++; | |
55 size--; | |
256
8e39cab6abd5
nginx-0.0.2-2004-02-10-19:23:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
211
diff
changeset
|
56 } |
8e39cab6abd5
nginx-0.0.2-2004-02-10-19:23:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
211
diff
changeset
|
57 |
461 | 58 return errstr; |
256
8e39cab6abd5
nginx-0.0.2-2004-02-10-19:23:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
211
diff
changeset
|
59 } |
8e39cab6abd5
nginx-0.0.2-2004-02-10-19:23:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
211
diff
changeset
|
60 |
211
fd9fecc4193f
nginx-0.0.1-2003-12-15-16:57:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
210
diff
changeset
|
61 #endif |