xref: /freebsd/contrib/ntp/libntp/bsd_strerror.c (revision f5f40dd63bc7acbb5312b26ac1ea1103c12352a6)
12b15cb3dSCy Schubert #include <config.h>
22b15cb3dSCy Schubert 
32b15cb3dSCy Schubert #if !HAVE_STRERROR
42b15cb3dSCy Schubert /*
52b15cb3dSCy Schubert  * Copyright (c) 1988 Regents of the University of California.
62b15cb3dSCy Schubert  * All rights reserved.
72b15cb3dSCy Schubert  *
82b15cb3dSCy Schubert  * Redistribution and use in source and binary forms are permitted
92b15cb3dSCy Schubert  * provided that the above copyright notice and this paragraph are
102b15cb3dSCy Schubert  * duplicated in all such forms and that any documentation,
112b15cb3dSCy Schubert  * advertising materials, and other materials related to such
122b15cb3dSCy Schubert  * distribution and use acknowledge that the software was developed
132b15cb3dSCy Schubert  * by the University of California, Berkeley.  The name of the
142b15cb3dSCy Schubert  * University may not be used to endorse or promote products derived
152b15cb3dSCy Schubert  * from this software without specific prior written permission.
162b15cb3dSCy Schubert  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
172b15cb3dSCy Schubert  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
182b15cb3dSCy Schubert  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
192b15cb3dSCy Schubert  */
202b15cb3dSCy Schubert 
212b15cb3dSCy Schubert #if defined(LIBC_SCCS) && !defined(lint)
222b15cb3dSCy Schubert static const char sccsid[] = "@(#)strerror.c	5.1 (Berkeley) 4/9/89";
232b15cb3dSCy Schubert #endif /* LIBC_SCCS and not lint */
242b15cb3dSCy Schubert 
252b15cb3dSCy Schubert #include <sys/types.h>
262b15cb3dSCy Schubert 
272b15cb3dSCy Schubert #include <stdio.h>
282b15cb3dSCy Schubert #include <string.h>
292b15cb3dSCy Schubert 
302b15cb3dSCy Schubert #include "l_stdlib.h"
312b15cb3dSCy Schubert 
322b15cb3dSCy Schubert char *
332b15cb3dSCy Schubert strerror(
342b15cb3dSCy Schubert 	int errnum
352b15cb3dSCy Schubert 	)
362b15cb3dSCy Schubert {
372b15cb3dSCy Schubert 	extern int sys_nerr;
382b15cb3dSCy Schubert 	extern char *sys_errlist[];
392b15cb3dSCy Schubert 	static char ebuf[20];
402b15cb3dSCy Schubert 
412b15cb3dSCy Schubert 	if ((unsigned int)errnum < sys_nerr)
422b15cb3dSCy Schubert 		return sys_errlist[errnum];
432b15cb3dSCy Schubert 	snprintf(ebuf, sizeof(ebuf), "Unknown error: %d", errnum);
442b15cb3dSCy Schubert 
452b15cb3dSCy Schubert 	return ebuf;
462b15cb3dSCy Schubert }
472b15cb3dSCy Schubert #else
48*f5f40dd6SCy Schubert NONEMPTY_TRANSLATION_UNIT
492b15cb3dSCy Schubert #endif
50