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