1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * Copyright (c) 2000-2001 Sendmail, Inc. and its suppliers.
3*7c478bd9Sstevel@tonic-gate  *	All rights reserved.
4*7c478bd9Sstevel@tonic-gate  * Copyright (c) 1983, 1995-1997 Eric P. Allman.  All rights reserved.
5*7c478bd9Sstevel@tonic-gate  * Copyright (c) 1988, 1993
6*7c478bd9Sstevel@tonic-gate  *	The Regents of the University of California.  All rights reserved.
7*7c478bd9Sstevel@tonic-gate  *
8*7c478bd9Sstevel@tonic-gate  * By using this file, you agree to the terms and conditions set
9*7c478bd9Sstevel@tonic-gate  * forth in the LICENSE file which can be found at the top level of
10*7c478bd9Sstevel@tonic-gate  * the sendmail distribution.
11*7c478bd9Sstevel@tonic-gate  *
12*7c478bd9Sstevel@tonic-gate  */
13*7c478bd9Sstevel@tonic-gate 
14*7c478bd9Sstevel@tonic-gate #include <sm/gen.h>
15*7c478bd9Sstevel@tonic-gate SM_RCSID("@(#)$Id: strerror.c,v 1.21 2001/06/17 21:31:41 ca Exp $")
16*7c478bd9Sstevel@tonic-gate 
17*7c478bd9Sstevel@tonic-gate /*
18*7c478bd9Sstevel@tonic-gate **  define strerror for platforms that lack it.
19*7c478bd9Sstevel@tonic-gate */
20*7c478bd9Sstevel@tonic-gate 
21*7c478bd9Sstevel@tonic-gate #include <errno.h>
22*7c478bd9Sstevel@tonic-gate #include <stdio.h>	/* sys_errlist, on some platforms */
23*7c478bd9Sstevel@tonic-gate 
24*7c478bd9Sstevel@tonic-gate #include <sm/io.h>	/* sm_snprintf */
25*7c478bd9Sstevel@tonic-gate #include <sm/string.h>
26*7c478bd9Sstevel@tonic-gate #include <sm/conf.h>
27*7c478bd9Sstevel@tonic-gate #include <sm/errstring.h>
28*7c478bd9Sstevel@tonic-gate 
29*7c478bd9Sstevel@tonic-gate #if !defined(ERRLIST_PREDEFINED)
30*7c478bd9Sstevel@tonic-gate extern char *sys_errlist[];
31*7c478bd9Sstevel@tonic-gate extern int sys_nerr;
32*7c478bd9Sstevel@tonic-gate #endif /* !defined(ERRLIST_PREDEFINED) */
33*7c478bd9Sstevel@tonic-gate 
34*7c478bd9Sstevel@tonic-gate #if !HASSTRERROR
35*7c478bd9Sstevel@tonic-gate 
36*7c478bd9Sstevel@tonic-gate /*
37*7c478bd9Sstevel@tonic-gate **  STRERROR -- return error message string corresponding to an error number.
38*7c478bd9Sstevel@tonic-gate **
39*7c478bd9Sstevel@tonic-gate **	Parameters:
40*7c478bd9Sstevel@tonic-gate **		err -- error number.
41*7c478bd9Sstevel@tonic-gate **
42*7c478bd9Sstevel@tonic-gate **	Returns:
43*7c478bd9Sstevel@tonic-gate **		Error string (might be pointer to static buffer).
44*7c478bd9Sstevel@tonic-gate */
45*7c478bd9Sstevel@tonic-gate 
46*7c478bd9Sstevel@tonic-gate char *
strerror(err)47*7c478bd9Sstevel@tonic-gate strerror(err)
48*7c478bd9Sstevel@tonic-gate 	int err;
49*7c478bd9Sstevel@tonic-gate {
50*7c478bd9Sstevel@tonic-gate 	static char buf[64];
51*7c478bd9Sstevel@tonic-gate 
52*7c478bd9Sstevel@tonic-gate 	if (err >= 0 && err < sys_nerr)
53*7c478bd9Sstevel@tonic-gate 		return (char *) sys_errlist[err];
54*7c478bd9Sstevel@tonic-gate 	else
55*7c478bd9Sstevel@tonic-gate 	{
56*7c478bd9Sstevel@tonic-gate 		(void) sm_snprintf(buf, sizeof(buf), "Error %d", err);
57*7c478bd9Sstevel@tonic-gate 		return buf;
58*7c478bd9Sstevel@tonic-gate 	}
59*7c478bd9Sstevel@tonic-gate }
60*7c478bd9Sstevel@tonic-gate #endif /* !HASSTRERROR */
61