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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [newlib-1.10.0/] [newlib/] [libc/] [stdio/] [perror.c] - Blame information for rev 1773

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1010 ivang
/*
2
FUNCTION
3
<<perror>>---print an error message on standard error
4
 
5
INDEX
6
        perror
7
INDEX
8
        _perror_r
9
 
10
ANSI_SYNOPSIS
11
        #include <stdio.h>
12
        void perror(char *<[prefix]>);
13
 
14
        void _perror_r(void *<[reent]>, char *<[prefix]>);
15
 
16
TRAD_SYNOPSIS
17
        #include <stdio.h>
18
        void perror(<[prefix]>)
19
        char *<[prefix]>;
20
 
21
        void _perror_r(<[reent]>, <[prefix]>)
22
        char *<[reent]>;
23
        char *<[prefix]>;
24
 
25
DESCRIPTION
26
Use <<perror>> to print (on standard error) an error message
27
corresponding to the current value of the global variable <<errno>>.
28
Unless you use <<NULL>> as the value of the argument <[prefix]>, the
29
error message will begin with the string at <[prefix]>, followed by a
30
colon and a space (<<: >>). The remainder of the error message is one
31
of the strings described for <<strerror>>.
32
 
33
The alternate function <<_perror_r>> is a reentrant version.  The
34
extra argument <[reent]> is a pointer to a reentrancy structure.
35
 
36
 
37
RETURNS
38
<<perror>> returns no result.
39
 
40
PORTABILITY
41
ANSI C requires <<perror>>, but the strings issued vary from one
42
implementation to another.
43
 
44
Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
45
<<lseek>>, <<read>>, <<sbrk>>, <<write>>.
46
*/
47
 
48
#include <stddef.h>
49
#include <stdio.h>
50
#include <string.h>
51
 
52
void
53
_DEFUN (_perror_r, (ptr, s),
54
        struct _reent *ptr _AND
55
        _CONST char *s)
56
{
57
  char *error;
58
 
59
  if (s != NULL && *s != '\0')
60
    {
61
      fputs (s, _stderr_r (ptr));
62
      fputs (": ", _stderr_r (ptr));
63
    }
64
 
65
  if ((error = strerror (ptr->_errno)) != NULL)
66
    fputs (error, _stderr_r (ptr));
67
 
68
  fputc ('\n', _stderr_r (ptr));
69
}
70
 
71
#ifndef _REENT_ONLY
72
 
73
void
74
_DEFUN (perror, (s),
75
        _CONST char *s)
76
{
77
  _perror_r (_REENT, s);
78
}
79
 
80
#endif

powered by: WebSVN 2.1.0

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