sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
* All rights reserved.
|
sl@0
|
4 |
* This component and the accompanying materials are made available
|
sl@0
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
sl@0
|
6 |
* which accompanies this distribution, and is available
|
sl@0
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
*
|
sl@0
|
9 |
* Initial Contributors:
|
sl@0
|
10 |
* Nokia Corporation - initial contribution.
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* Contributors:
|
sl@0
|
13 |
*
|
sl@0
|
14 |
* Description:
|
sl@0
|
15 |
* FUNCTION
|
sl@0
|
16 |
* <<perror>>---print an error message on standard error
|
sl@0
|
17 |
* INDEX
|
sl@0
|
18 |
* perror
|
sl@0
|
19 |
* INDEX
|
sl@0
|
20 |
* _perror_r
|
sl@0
|
21 |
* ANSI_SYNOPSIS
|
sl@0
|
22 |
* #include <stdio.h>
|
sl@0
|
23 |
* void perror(char *<[prefix]>);
|
sl@0
|
24 |
* void _perror_r(void *<[reent]>, char *<[prefix]>);
|
sl@0
|
25 |
* TRAD_SYNOPSIS
|
sl@0
|
26 |
* #include <stdio.h>
|
sl@0
|
27 |
* void perror(<[prefix]>)
|
sl@0
|
28 |
* char *<[prefix]>;
|
sl@0
|
29 |
* void _perror_r(<[reent]>, <[prefix]>)
|
sl@0
|
30 |
* char *<[reent]>;
|
sl@0
|
31 |
* char *<[prefix]>;
|
sl@0
|
32 |
* Use <<perror>> to print (on standard error) an error message
|
sl@0
|
33 |
* corresponding to the current value of the global variable <<errno>>.
|
sl@0
|
34 |
* Unless you use <<NULL>> as the value of the argument <[prefix]>, the
|
sl@0
|
35 |
* error message will begin with the string at <[prefix]>, followed by a
|
sl@0
|
36 |
* colon and a space (<<: >>). The remainder of the error message is one
|
sl@0
|
37 |
* of the strings described for <<strerror>>.
|
sl@0
|
38 |
* The alternate function <<_perror_r>> is a reentrant version. The
|
sl@0
|
39 |
* extra argument <[reent]> is a pointer to a reentrancy structure.
|
sl@0
|
40 |
* RETURNS
|
sl@0
|
41 |
* <<perror>> returns no result.
|
sl@0
|
42 |
* PORTABILITY
|
sl@0
|
43 |
* ANSI C requires <<perror>>, but the strings issued vary from one
|
sl@0
|
44 |
* implementation to another.
|
sl@0
|
45 |
* Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
|
sl@0
|
46 |
* <<lseek>>, <<read>>, <<sbrk>>, <<write>>.
|
sl@0
|
47 |
*
|
sl@0
|
48 |
*
|
sl@0
|
49 |
*/
|
sl@0
|
50 |
|
sl@0
|
51 |
|
sl@0
|
52 |
|
sl@0
|
53 |
#include <stddef.h>
|
sl@0
|
54 |
#include <stdio_r.h>
|
sl@0
|
55 |
#include <string.h>
|
sl@0
|
56 |
|
sl@0
|
57 |
/**
|
sl@0
|
58 |
A reentrant version of perror().
|
sl@0
|
59 |
*/
|
sl@0
|
60 |
EXPORT_C void
|
sl@0
|
61 |
_perror_r (struct _reent *ptr, const char *s)
|
sl@0
|
62 |
{
|
sl@0
|
63 |
char *error;
|
sl@0
|
64 |
FILE *efp = _stderr_r(ptr);
|
sl@0
|
65 |
|
sl@0
|
66 |
if (s != NULL && *s != '\0')
|
sl@0
|
67 |
{
|
sl@0
|
68 |
fputs (s, efp);
|
sl@0
|
69 |
fputs (": ", efp);
|
sl@0
|
70 |
}
|
sl@0
|
71 |
|
sl@0
|
72 |
error = strerror (ptr->_errno);
|
sl@0
|
73 |
if (*error == '\0')
|
sl@0
|
74 |
fprintf (efp, "error %d\n", ptr->_errno);
|
sl@0
|
75 |
else
|
sl@0
|
76 |
{
|
sl@0
|
77 |
fputs (error, efp);
|
sl@0
|
78 |
fputc ('\n', efp);
|
sl@0
|
79 |
}
|
sl@0
|
80 |
}
|
sl@0
|
81 |
|
sl@0
|
82 |
#ifndef _REENT_ONLY
|
sl@0
|
83 |
|
sl@0
|
84 |
EXPORT_C void
|
sl@0
|
85 |
perror (const char *s)
|
sl@0
|
86 |
{
|
sl@0
|
87 |
_perror_r (_REENT, s);
|
sl@0
|
88 |
}
|
sl@0
|
89 |
|
sl@0
|
90 |
#endif
|