xref: /freebsd/contrib/ntp/libntp/bsd_strerror.c (revision f39bffc62c1395bde25d152c7f68fdf7cbaab414)
1 #include <config.h>
2 
3 #if !HAVE_STRERROR
4 /*
5  * Copyright (c) 1988 Regents of the University of California.
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms are permitted
9  * provided that the above copyright notice and this paragraph are
10  * duplicated in all such forms and that any documentation,
11  * advertising materials, and other materials related to such
12  * distribution and use acknowledge that the software was developed
13  * by the University of California, Berkeley.  The name of the
14  * University may not be used to endorse or promote products derived
15  * from this software without specific prior written permission.
16  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
17  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
18  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19  */
20 
21 #if defined(LIBC_SCCS) && !defined(lint)
22 static const char sccsid[] = "@(#)strerror.c	5.1 (Berkeley) 4/9/89";
23 #endif /* LIBC_SCCS and not lint */
24 
25 #include <sys/types.h>
26 
27 #include <stdio.h>
28 #include <string.h>
29 
30 #include "l_stdlib.h"
31 
32 char *
33 strerror(
34 	int errnum
35 	)
36 {
37 	extern int sys_nerr;
38 	extern char *sys_errlist[];
39 	static char ebuf[20];
40 
41 	if ((unsigned int)errnum < sys_nerr)
42 		return sys_errlist[errnum];
43 	snprintf(ebuf, sizeof(ebuf), "Unknown error: %d", errnum);
44 
45 	return ebuf;
46 }
47 #else
48 int strerror_bs;
49 #endif
50