blob: 2faf63a00f8c86083376c7a749c6e1e25bbf9eff (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
/*
* Copyright (C) Igor Sysoev
*/
#include <ngx_config.h>
#include <ngx_core.h>
#if (HAVE_STRERROR_R)
ngx_int_t ngx_strerror_r(int err, char *errstr, size_t size)
{
size_t len;
if (size == 0) {
return 0;
}
errstr[0] = '\0';
strerror_r(err, errstr, size);
for (len = 0; len < size; len++) {
if (errstr[len] == '\0') {
break;
}
}
return len;
}
#elif (HAVE_GNU_STRERROR_R)
/* Linux strerror_r() */
ngx_int_t ngx_strerror_r(int err, char *errstr, size_t size)
{
char *str;
size_t len;
if (size == 0) {
return 0;
}
errstr[0] = '\0';
str = strerror_r(err, errstr, size);
if (str != errstr) {
return ngx_cpystrn((u_char *) errstr, (u_char *) str, size)
- (u_char *) errstr;
}
for (len = 0; len < size; len++) {
if (errstr[len] == '\0') {
break;
}
}
return len;
}
#endif
|