1 /* 2 * Copyright (c) 2000-2001 Proofpoint, 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 #include <sm/gen.h> 15 SM_RCSID("@(#)$Id: strerror.c,v 1.24 2013-11-22 20:51:43 ca Exp $") 16 17 /* 18 ** define strerror for platforms that lack it. 19 */ 20 21 #include <errno.h> 22 #include <stdio.h> /* sys_errlist, on some platforms */ 23 24 #include <sm/io.h> /* sm_snprintf */ 25 #include <sm/string.h> 26 #include <sm/conf.h> 27 #include <sm/errstring.h> 28 29 #if !defined(ERRLIST_PREDEFINED) 30 extern char *sys_errlist[]; 31 extern int sys_nerr; 32 #endif /* !defined(ERRLIST_PREDEFINED) */ 33 34 #if !HASSTRERROR 35 36 /* 37 ** STRERROR -- return error message string corresponding to an error number. 38 ** 39 ** Parameters: 40 ** err -- error number. 41 ** 42 ** Returns: 43 ** Error string (might be pointer to static buffer). 44 */ 45 46 char * 47 strerror(err) 48 int err; 49 { 50 static char buf[64]; 51 52 if (err >= 0 && err < sys_nerr) 53 return (char *) sys_errlist[err]; 54 else 55 { 56 (void) sm_snprintf(buf, sizeof(buf), "Error %d", err); 57 return buf; 58 } 59 } 60 #endif /* !HASSTRERROR */ 61