From a5b4134ef006a2be508ba3af1cfa90305c508e24 Mon Sep 17 00:00:00 2001 From: marc <> Date: Thu, 21 Nov 2002 20:45:05 +0000 Subject: Add strerror_r and functions versions of getchar_unlocked and putchar_unlocked. Crank the minor on related libs. OK fgs@, deraadt@ --- src/lib/libc/string/strerror_r.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/lib/libc/string/strerror_r.c (limited to 'src/lib/libc/string/strerror_r.c') diff --git a/src/lib/libc/string/strerror_r.c b/src/lib/libc/string/strerror_r.c new file mode 100644 index 0000000000..aab6db5303 --- /dev/null +++ b/src/lib/libc/string/strerror_r.c @@ -0,0 +1,30 @@ +/* $OpenBSD: strerror_r.c,v 1.1 2002/11/21 20:45:05 marc Exp $ */ +/* Public Domain */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char *rcsid = "$OpenBSD: strerror_r.c,v 1.1 2002/11/21 20:45:05 marc Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include +#include +#include + +extern char *__strerror(int, char *); + +int +strerror_r(int errnum, char *strerrbuf, size_t buflen) +{ + int save_errno; + int ret_errno; + char buf[NL_TEXTMAX]; + + save_errno = errno; + errno = 0; + __strerror(errnum, buf); + if (strlcpy(strerrbuf, buf, buflen) >= buflen) + errno = ERANGE; + ret_errno = errno; + errno = save_errno; + + return (ret_errno); +} -- cgit v1.2.3-55-g6feb