summaryrefslogtreecommitdiff
path: root/src/lib/libc/string/strerror_r.c
diff options
context:
space:
mode:
authormarc <>2002-11-21 20:45:05 +0000
committermarc <>2002-11-21 20:45:05 +0000
commita5b4134ef006a2be508ba3af1cfa90305c508e24 (patch)
treeed0b4084b8195b16382831ffc19e2cb68ba7588a /src/lib/libc/string/strerror_r.c
parent835bcf7be2030a2ecb03922fd3a821fe06474356 (diff)
downloadopenbsd-a5b4134ef006a2be508ba3af1cfa90305c508e24.tar.gz
openbsd-a5b4134ef006a2be508ba3af1cfa90305c508e24.tar.bz2
openbsd-a5b4134ef006a2be508ba3af1cfa90305c508e24.zip
Add strerror_r and functions versions of getchar_unlocked and
putchar_unlocked. Crank the minor on related libs. OK fgs@, deraadt@
Diffstat (limited to 'src/lib/libc/string/strerror_r.c')
-rw-r--r--src/lib/libc/string/strerror_r.c30
1 files changed, 30 insertions, 0 deletions
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 @@
1/* $OpenBSD: strerror_r.c,v 1.1 2002/11/21 20:45:05 marc Exp $ */
2/* Public Domain <marc@snafu.org> */
3
4#if defined(LIBC_SCCS) && !defined(lint)
5static char *rcsid = "$OpenBSD: strerror_r.c,v 1.1 2002/11/21 20:45:05 marc Exp $";
6#endif /* LIBC_SCCS and not lint */
7
8#include <errno.h>
9#include <limits.h>
10#include <string.h>
11
12extern char *__strerror(int, char *);
13
14int
15strerror_r(int errnum, char *strerrbuf, size_t buflen)
16{
17 int save_errno;
18 int ret_errno;
19 char buf[NL_TEXTMAX];
20
21 save_errno = errno;
22 errno = 0;
23 __strerror(errnum, buf);
24 if (strlcpy(strerrbuf, buf, buflen) >= buflen)
25 errno = ERANGE;
26 ret_errno = errno;
27 errno = save_errno;
28
29 return (ret_errno);
30}