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