blob: a3addf00cd147808d4101cf19d80edf469ec5f1d (
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
|
/*
* Copyright (C) Igor Sysoev
*/
#include <ngx_config.h>
#include <ngx_core.h>
#if (NGX_HAVE_STRERROR_R)
u_char *ngx_strerror_r(int err, u_char *errstr, size_t size)
{
if (size == 0) {
return 0;
}
errstr[0] = '\0';
strerror_r(err, (char *) errstr, size);
while (*errstr && size) {
errstr++;
size--;
}
return errstr;
}
#elif (NGX_HAVE_GNU_STRERROR_R)
/* Linux strerror_r() */
u_char *ngx_strerror_r(int err, u_char *errstr, size_t size)
{
char *str;
if (size == 0) {
return 0;
}
errstr[0] = '\0';
str = strerror_r(err, (char *) errstr, size);
if (str != (char *) errstr) {
return ngx_cpystrn(errstr, (u_char *) str, size);
}
while (*errstr && size) {
errstr++;
size--;
}
return errstr;
}
#endif
|