summaryrefslogtreecommitdiffstats
path: root/sendmail/libsm/strerror.c
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>2008-08-28 02:25:51 +0000
committerpeter <peter@FreeBSD.org>2008-08-28 02:25:51 +0000
commitea50d71feb02a78d4d5fa746a26ca7ddc6e8cb19 (patch)
treedaf40952cf309641cc6c7d987989fd2abce2d758 /sendmail/libsm/strerror.c
parenta2b986fa722f9860a6c56bb5cc724b7e2937d1b7 (diff)
downloadFreeBSD-src-ea50d71feb02a78d4d5fa746a26ca7ddc6e8cb19.zip
FreeBSD-src-ea50d71feb02a78d4d5fa746a26ca7ddc6e8cb19.tar.gz
Stage 1 of sendmail dist tree flattening. contrib/sendmail/contrib
prevents doing this in one pass.
Diffstat (limited to 'sendmail/libsm/strerror.c')
-rw-r--r--sendmail/libsm/strerror.c60
1 files changed, 60 insertions, 0 deletions
diff --git a/sendmail/libsm/strerror.c b/sendmail/libsm/strerror.c
new file mode 100644
index 0000000..ffdfb21
--- /dev/null
+++ b/sendmail/libsm/strerror.c
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2000-2001 Sendmail, Inc. and its suppliers.
+ * All rights reserved.
+ * Copyright (c) 1983, 1995-1997 Eric P. Allman. All rights reserved.
+ * Copyright (c) 1988, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * By using this file, you agree to the terms and conditions set
+ * forth in the LICENSE file which can be found at the top level of
+ * the sendmail distribution.
+ *
+ */
+
+#include <sm/gen.h>
+SM_RCSID("@(#)$Id: strerror.c,v 1.23 2001/09/11 04:04:49 gshapiro Exp $")
+
+/*
+** define strerror for platforms that lack it.
+*/
+
+#include <errno.h>
+#include <stdio.h> /* sys_errlist, on some platforms */
+
+#include <sm/io.h> /* sm_snprintf */
+#include <sm/string.h>
+#include <sm/conf.h>
+#include <sm/errstring.h>
+
+#if !defined(ERRLIST_PREDEFINED)
+extern char *sys_errlist[];
+extern int sys_nerr;
+#endif /* !defined(ERRLIST_PREDEFINED) */
+
+#if !HASSTRERROR
+
+/*
+** STRERROR -- return error message string corresponding to an error number.
+**
+** Parameters:
+** err -- error number.
+**
+** Returns:
+** Error string (might be pointer to static buffer).
+*/
+
+char *
+strerror(err)
+ int err;
+{
+ static char buf[64];
+
+ if (err >= 0 && err < sys_nerr)
+ return (char *) sys_errlist[err];
+ else
+ {
+ (void) sm_snprintf(buf, sizeof(buf), "Error %d", err);
+ return buf;
+ }
+}
+#endif /* !HASSTRERROR */
OpenPOWER on IntegriCloud