OpenCores
URL https://opencores.org/ocsvn/scarts/scarts/trunk

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-newlib/] [newlib-1.17.0/] [newlib/] [libc/] [string/] [strerror_r.c] - Blame information for rev 9

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 9 jlechner
/*
2
FUNCTION
3
        <<strerror_r>>---convert error number to string and copy to buffer
4
 
5
INDEX
6
        strerror_r
7
 
8
ANSI_SYNOPSIS
9
        #include <string.h>
10
        char *strerror_r(int <[errnum]>, char *<[buffer]>, size_t <[n]>);
11
 
12
TRAD_SYNOPSIS
13
        #include <string.h>
14
        char *strerror_r(<[errnum]>, <[buffer]>, <[n]>)
15
        int <[errnum]>;
16
        char *<[buffer]>;
17
        size_t <[n]>;
18
 
19
DESCRIPTION
20
<<strerror_r>> converts the error number <[errnum]> into a
21
string and copies the result into the supplied <[buffer]> for
22
a length up to <[n]>, including the NUL terminator. The value of
23
<[errnum]> is usually a copy of <<errno>>.  If <<errnum>> is not a known
24
error number, the result is the empty string.
25
 
26
See <<strerror>> for how strings are mapped to <<errnum>>.
27
 
28
RETURNS
29
This function returns a pointer to a string.  Your application must
30
not modify that string.
31
 
32
PORTABILITY
33
<<strerror_r>> is a GNU extension.
34
 
35
<<strerror_r>> requires no supporting OS subroutines.
36
 
37
*/
38
 
39
#undef __STRICT_ANSI__
40
#include <errno.h>
41
#include <string.h>
42
 
43
char *
44
_DEFUN (strerror_r, (errnum, buffer, n),
45
        int errnum _AND
46
        char *buffer _AND
47
        size_t n)
48
{
49
  char *error;
50
  error = strerror (errnum);
51
 
52
  return strncpy (buffer, (const char *)error, n);
53
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.