1
/* $Id: strerror.c,v 1.3 1999/05/13 16:35:58 karls Exp $ */
5
#endif /* HAVE_CONFIG_H */
12
* Copyright (c) 1988 Regents of the University of California.
13
* All rights reserved.
15
* Redistribution and use in source and binary forms, with or without
16
* modification, are permitted provided that the following conditions
18
* 1. Redistributions of source code must retain the above copyright
19
* notice, this list of conditions and the following disclaimer.
20
* 2. Redistributions in binary form must reproduce the above copyright
21
* notice, this list of conditions and the following disclaimer in the
22
* documentation and/or other materials provided with the distribution.
23
* 3. All advertising materials mentioning features or use of this software
24
* must display the following acknowledgement:
25
* This product includes software developed by the University of
26
* California, Berkeley and its contributors.
27
* 4. Neither the name of the University nor the names of its contributors
28
* may be used to endorse or promote products derived from this software
29
* without specific prior written permission.
31
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
32
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
33
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
34
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
35
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
39
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
40
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
44
#if defined(LIBC_SCCS) && !defined(lint)
45
static char *rcsid = "$OpenBSD: __strerror.c,v 1.6 1996/09/25 08:17:30 deraadt Exp $";
46
#endif /* LIBC_SCCS and not lint */
49
#define NL_TEXTMAX 255
50
#endif /* !NL_TEXTMAX */
63
static char *itoa(num)
66
static char buffer[11];
71
*--p = (num % 10) + '0';
74
*p = (num % 10) + '0';
79
* Since perror() is not allowed to change the contents of strerror()'s
80
* static buffer, both functions supply their own buffers to the
81
* internal function __strerror().
89
#define UPREFIX "Unknown error: "
90
register unsigned int errnum;
93
errnum = num; /* convert to unsigned */
94
if (errnum < sys_nerr) {
95
return(sys_errlist[errnum]);
98
strncat(buf, itoa(errnum), NL_TEXTMAX-strlen(buf)-1);
105
* Copyright (c) 1988 Regents of the University of California.
106
* All rights reserved.
108
* Redistribution and use in source and binary forms, with or without
109
* modification, are permitted provided that the following conditions
111
* 1. Redistributions of source code must retain the above copyright
112
* notice, this list of conditions and the following disclaimer.
113
* 2. Redistributions in binary form must reproduce the above copyright
114
* notice, this list of conditions and the following disclaimer in the
115
* documentation and/or other materials provided with the distribution.
116
* 3. All advertising materials mentioning features or use of this software
117
* must display the following acknowledgement:
118
* This product includes software developed by the University of
119
* California, Berkeley and its contributors.
120
* 4. Neither the name of the University nor the names of its contributors
121
* may be used to endorse or promote products derived from this software
122
* without specific prior written permission.
124
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
125
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
126
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
127
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
128
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
129
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
130
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
131
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
132
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
133
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
137
#if defined(LIBC_SCCS) && !defined(lint)
138
static char *rcsid = "$OpenBSD: strerror.c,v 1.2 1996/08/19 08:34:17 tholo Exp $";
139
#endif /* LIBC_SCCS and not lint */
147
* Since perror() is not allowed to change the contents of strerror()'s
148
* static buffer, both functions supply their own buffers to the
149
* internal function __strerror().
156
static char buf[NL_TEXTMAX];
157
return __strerror(num, buf);
160
static void avoid_error __P((void));
161
static void avoid_error()
165
#endif /* HAVE_STRERROR */