Last change
on this file since 559 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 | |
---|
6 | int |
---|
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.