source: trunk/libs/newlib/src/newlib/libc/string/xpg_strerror_r.c @ 444

Last change on this file since 444 was 444, checked in by satin@…, 6 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 475 bytes
Line 
1/* POSIX variant of strerror_r. */
2#undef __STRICT_ANSI__
3#include <errno.h>
4#include <string.h>
5
6int
7__xpg_strerror_r (int errnum,
8        char *buffer,
9        size_t n)
10{
11  char *error;
12  int result = 0;
13
14  if (!n)
15    return ERANGE;
16  error = _strerror_r (_REENT, errnum, 1, &result);
17  if (strlen (error) >= n)
18    {
19      memcpy (buffer, error, n - 1);
20      buffer[n - 1] = '\0';
21      return ERANGE;
22    }
23  strcpy (buffer, error);
24  return (result || *error) ? result : EINVAL;
25}
Note: See TracBrowser for help on using the repository browser.