Welcome to mirror list, hosted at ThFree Co, Russian Federation.

strerror_r.c « string « libc « newlib - cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 956a1f48557f3cc9c5da0a8d91571082e2f4b4bb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*
FUNCTION
	<<strerror_r>>---convert error number to string and copy to buffer

INDEX
	strerror_r

ANSI_SYNOPSIS
	#include <string.h>
	char *strerror_r(int <[errnum]>, char *<[buffer]>, size_t <[n]>);

TRAD_SYNOPSIS
	#include <string.h>
	char *strerror_r(<[errnum]>, <[buffer]>, <[n]>)
	int <[errnum]>;
	char *<[buffer]>;
	size_t <[n]>;

DESCRIPTION
<<strerror_r>> 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 <<errno>>.  If <<errnum>> is not a known 
error number, the result is the empty string.

See <<strerror>> for how strings are mapped to <<errnum>>.

RETURNS
This function returns a pointer to a string.  Your application must
not modify that string.

PORTABILITY
<<strerror_r>> is a gnu extension.

<<strerror_r>> requires no supporting OS subroutines.

*/

#undef __STRICT_ANSI__
#include <errno.h>
#include <string.h>

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);
}