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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.18.0/] [newlib/] [libc/] [stdio/] [perror.c] - Blame information for rev 207

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 207 jeremybenn
/*
2
 * Copyright (c) 1990 The Regents of the University of California.
3
 * All rights reserved.
4
 *
5
 * Redistribution and use in source and binary forms are permitted
6
 * provided that the above copyright notice and this paragraph are
7
 * duplicated in all such forms and that any documentation,
8
 * advertising materials, and other materials related to such
9
 * distribution and use acknowledge that the software was developed
10
 * by the University of California, Berkeley.  The name of the
11
 * University may not be used to endorse or promote products derived
12
 * from this software without specific prior written permission.
13
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14
 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
16
 */
17
 
18
/*
19
FUNCTION
20
<<perror>>---print an error message on standard error
21
 
22
INDEX
23
        perror
24
INDEX
25
        _perror_r
26
 
27
ANSI_SYNOPSIS
28
        #include <stdio.h>
29
        void perror(char *<[prefix]>);
30
 
31
        void _perror_r(struct _reent *<[reent]>, char *<[prefix]>);
32
 
33
TRAD_SYNOPSIS
34
        #include <stdio.h>
35
        void perror(<[prefix]>)
36
        char *<[prefix]>;
37
 
38
        void _perror_r(<[reent]>, <[prefix]>)
39
        struct _reent *<[reent]>;
40
        char *<[prefix]>;
41
 
42
DESCRIPTION
43
Use <<perror>> to print (on standard error) an error message
44
corresponding to the current value of the global variable <<errno>>.
45
Unless you use <<NULL>> as the value of the argument <[prefix]>, the
46
error message will begin with the string at <[prefix]>, followed by a
47
colon and a space (<<: >>). The remainder of the error message is one
48
of the strings described for <<strerror>>.
49
 
50
The alternate function <<_perror_r>> is a reentrant version.  The
51
extra argument <[reent]> is a pointer to a reentrancy structure.
52
 
53
RETURNS
54
<<perror>> returns no result.
55
 
56
PORTABILITY
57
ANSI C requires <<perror>>, but the strings issued vary from one
58
implementation to another.
59
 
60
Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
61
<<lseek>>, <<read>>, <<sbrk>>, <<write>>.
62
*/
63
 
64
#include <_ansi.h>
65
#include <reent.h>
66
#include <stdio.h>
67
#include <string.h>
68
#include "local.h"
69
 
70
_VOID
71
_DEFUN(_perror_r, (ptr, s),
72
       struct _reent *ptr _AND
73
       _CONST char *s)
74
{
75
  char *error;
76
 
77
  _REENT_SMALL_CHECK_INIT (ptr);
78
  if (s != NULL && *s != '\0')
79
    {
80
      fputs (s, _stderr_r (ptr));
81
      fputs (": ", _stderr_r (ptr));
82
    }
83
 
84
  if ((error = strerror (ptr->_errno)) != NULL)
85
    fputs (error, _stderr_r (ptr));
86
 
87
  fputc ('\n', _stderr_r (ptr));
88
}
89
 
90
#ifndef _REENT_ONLY
91
 
92
_VOID
93
_DEFUN(perror, (s),
94
       _CONST char *s)
95
{
96
  _perror_r (_REENT, s);
97
}
98
 
99
#endif

powered by: WebSVN 2.1.0

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