bsd_strerror.c revision 285612
119026Sjulian#include <config.h>
267627Sasmodai
319026Sjulian#if !HAVE_STRERROR
419026Sjulian/*
519026Sjulian * Copyright (c) 1988 Regents of the University of California.
619026Sjulian * All rights reserved.
719026Sjulian *
819026Sjulian * Redistribution and use in source and binary forms are permitted
919026Sjulian * provided that the above copyright notice and this paragraph are
1019026Sjulian * duplicated in all such forms and that any documentation,
1119026Sjulian * advertising materials, and other materials related to such
1219026Sjulian * distribution and use acknowledge that the software was developed
1319026Sjulian * by the University of California, Berkeley.  The name of the
1419026Sjulian * University may not be used to endorse or promote products derived
1519026Sjulian * from this software without specific prior written permission.
1619026Sjulian * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
1719026Sjulian * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
1819026Sjulian * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
1919026Sjulian */
2019026Sjulian
2119026Sjulian#if defined(LIBC_SCCS) && !defined(lint)
2219026Sjulianstatic const char sccsid[] = "@(#)strerror.c	5.1 (Berkeley) 4/9/89";
2319026Sjulian#endif /* LIBC_SCCS and not lint */
2419026Sjulian
2519026Sjulian#include <sys/types.h>
2650476Speter
2720920Swosch#include <stdio.h>
28289924Smav#include <string.h>
2940431Sken
3079538Sru#include "l_stdlib.h"
315884Sdg
3240431Skenchar *
3375670Srustrerror(
345884Sdg	int errnum
3556460Sasmodai	)
365884Sdg{
375884Sdg	extern int sys_nerr;
3868962Sru	extern char *sys_errlist[];
3940431Sken	static char ebuf[20];
4013484Swollman
4140431Sken	if ((unsigned int)errnum < sys_nerr)
4240431Sken		return sys_errlist[errnum];
4340431Sken	snprintf(ebuf, sizeof(ebuf), "Unknown error: %d", errnum);
4440431Sken
4540431Sken	return ebuf;
4640431Sken}
475884Sdg#else
4813484Swollmanint strerror_bs;
4913484Swollman#endif
5040431Sken