From d29587b4789426217ace96c1dccb249e3682eaf8 Mon Sep 17 00:00:00 2001 From: Jeff Johnston Date: Fri, 24 May 2002 23:44:39 +0000 Subject: 2002-05-24 Jeff Johnston * libc/include/string.h: Add strnlen and strerror_r prototypes. * libc/string/Makefile.am: Add strnlen.c and strerror_r.c support. * libc/string/Makefile.in: Regenerated. * libc/string/strerror_r.c: New file. * libc/string/strnlen.c: New file. * libc/sys/linux/Makefile.am: Add rename.c. * libc/sys/linux/Makefile.in: Regenerated. * libc/sys/linux/rename.c: New file to override default rename. --- newlib/libc/string/strerror_r.c | 53 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 newlib/libc/string/strerror_r.c (limited to 'newlib/libc/string/strerror_r.c') diff --git a/newlib/libc/string/strerror_r.c b/newlib/libc/string/strerror_r.c new file mode 100644 index 000000000..956a1f485 --- /dev/null +++ b/newlib/libc/string/strerror_r.c @@ -0,0 +1,53 @@ +/* +FUNCTION + <>---convert error number to string and copy to buffer + +INDEX + strerror_r + +ANSI_SYNOPSIS + #include + char *strerror_r(int <[errnum]>, char *<[buffer]>, size_t <[n]>); + +TRAD_SYNOPSIS + #include + char *strerror_r(<[errnum]>, <[buffer]>, <[n]>) + int <[errnum]>; + char *<[buffer]>; + size_t <[n]>; + +DESCRIPTION +<> converts the error number <[errnum]> into a +string and copies the result into the supplied <[buffer]> for +a length up to <[n]>, including the NUL terminator. The value of +<[errnum]> is usually a copy of <>. If <> is not a known +error number, the result is the empty string. + +See <> for how strings are mapped to <>. + +RETURNS +This function returns a pointer to a string. Your application must +not modify that string. + +PORTABILITY +<> is a gnu extension. + +<> requires no supporting OS subroutines. + +*/ + +#undef __STRICT_ANSI__ +#include +#include + +char * +_DEFUN (strerror_r, (errnum, buffer, n), + int errnum _AND + char *buffer _AND + size_t n) +{ + char *error; + error = strerror (errnum); + + return strncpy (buffer, (const char *)error, n); +} -- cgit v1.2.3