2004-09-28 16:34:51 +08:00
|
|
|
|
|
|
|
/*
|
2004-09-30 00:00:49 +08:00
|
|
|
* Copyright (C) Igor Sysoev
|
2004-09-28 16:34:51 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2003-12-15 04:10:27 +08:00
|
|
|
#include <ngx_config.h>
|
|
|
|
#include <ngx_core.h>
|
|
|
|
|
|
|
|
|
2004-11-26 00:17:31 +08:00
|
|
|
#if (NGX_HAVE_STRERROR_R)
|
2003-12-15 21:57:13 +08:00
|
|
|
|
2004-11-11 22:07:14 +08:00
|
|
|
u_char *ngx_strerror_r(int err, u_char *errstr, size_t size)
|
2003-12-15 04:10:27 +08:00
|
|
|
{
|
|
|
|
if (size == 0) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
errstr[0] = '\0';
|
|
|
|
|
2004-11-11 22:07:14 +08:00
|
|
|
strerror_r(err, (char *) errstr, size);
|
2003-12-15 04:10:27 +08:00
|
|
|
|
2004-11-11 22:07:14 +08:00
|
|
|
while (*errstr && size) {
|
|
|
|
errstr++;
|
|
|
|
size--;
|
2003-12-15 04:10:27 +08:00
|
|
|
}
|
|
|
|
|
2004-11-11 22:07:14 +08:00
|
|
|
return errstr;
|
2003-12-15 04:10:27 +08:00
|
|
|
}
|
2003-12-15 21:57:13 +08:00
|
|
|
|
2004-11-26 00:17:31 +08:00
|
|
|
#elif (NGX_HAVE_GNU_STRERROR_R)
|
2004-02-11 00:23:38 +08:00
|
|
|
|
|
|
|
/* Linux strerror_r() */
|
|
|
|
|
2004-11-11 22:07:14 +08:00
|
|
|
u_char *ngx_strerror_r(int err, u_char *errstr, size_t size)
|
2004-02-11 00:23:38 +08:00
|
|
|
{
|
2005-03-19 20:38:37 +08:00
|
|
|
char *str;
|
2004-02-11 00:23:38 +08:00
|
|
|
|
|
|
|
if (size == 0) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
errstr[0] = '\0';
|
|
|
|
|
2004-11-11 22:07:14 +08:00
|
|
|
str = strerror_r(err, (char *) errstr, size);
|
2004-02-11 00:23:38 +08:00
|
|
|
|
2004-11-11 22:07:14 +08:00
|
|
|
if (str != (char *) errstr) {
|
|
|
|
return ngx_cpystrn(errstr, (u_char *) str, size);
|
2004-02-11 00:23:38 +08:00
|
|
|
}
|
|
|
|
|
2004-11-11 22:07:14 +08:00
|
|
|
while (*errstr && size) {
|
|
|
|
errstr++;
|
|
|
|
size--;
|
2004-02-11 00:23:38 +08:00
|
|
|
}
|
|
|
|
|
2004-11-11 22:07:14 +08:00
|
|
|
return errstr;
|
2004-02-11 00:23:38 +08:00
|
|
|
}
|
|
|
|
|
2003-12-15 21:57:13 +08:00
|
|
|
#endif
|