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