From: hno <> Date: Mon, 3 Mar 2003 05:20:31 +0000 (+0000) Subject: added a xstrerr(errno) function, to be used when the errno value is known X-Git-Tag: SQUID_3_0_PRE1~292 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=02e640fe4210a1aec94a6f58cdada3750a97e157;p=thirdparty%2Fsquid.git added a xstrerr(errno) function, to be used when the errno value is known and not taken from errno --- diff --git a/include/util.h b/include/util.h index 5239d1a365..73a5be55a0 100644 --- a/include/util.h +++ b/include/util.h @@ -1,5 +1,5 @@ /* - * $Id: util.h,v 1.69 2003/02/02 22:04:13 robertc Exp $ + * $Id: util.h,v 1.70 2003/03/02 22:20:31 hno Exp $ * * AUTHOR: Harvest Derived * @@ -71,6 +71,7 @@ SQUIDCEXTERN const char *mkrfc1123(time_t); SQUIDCEXTERN char *uudecode(const char *); SQUIDCEXTERN char *xstrdup(const char *); SQUIDCEXTERN char *xstrndup(const char *, size_t); +SQUIDCEXTERN const char *xstrerr(int xerrno); SQUIDCEXTERN const char *xstrerror(void); SQUIDCEXTERN int tvSubMsec(struct timeval, struct timeval); SQUIDCEXTERN int tvSubUsec(struct timeval, struct timeval); diff --git a/lib/util.c b/lib/util.c index c56f4f31e1..0c8467707c 100644 --- a/lib/util.c +++ b/lib/util.c @@ -1,6 +1,6 @@ /* - * $Id: util.c,v 1.89 2003/01/23 00:37:02 robertc Exp $ + * $Id: util.c,v 1.90 2003/03/02 22:20:31 hno Exp $ * * DEBUG: * AUTHOR: Harvest Derived @@ -645,20 +645,26 @@ xstrndup(const char *s, size_t n) * xstrerror() - strerror() wrapper */ const char * -xstrerror(void) +xstrerr(int error) { static char xstrerror_buf[BUFSIZ]; static char strerror_buf[BUFSIZ]; - snprintf(strerror_buf, BUFSIZ, "%s", strerror(errno)); + snprintf(strerror_buf, BUFSIZ, "%s", strerror(error)); if (strerror_buf) - snprintf(xstrerror_buf, BUFSIZ, "(%d) %s", errno, strerror_buf); + snprintf(xstrerror_buf, BUFSIZ, "(%d) %s", error, strerror_buf); else - snprintf(xstrerror_buf, BUFSIZ, "(%d) Unknown", errno); + snprintf(xstrerror_buf, BUFSIZ, "(%d) Unknown", error); return xstrerror_buf; } +const char * +xstrerror(void) +{ + return xstrerr(errno); +} + void Tolower(char *q) {