]> granicus.if.org Git - sudo/commitdiff
strerror() for systems w/o it
authorTodd C. Miller <Todd.Miller@courtesan.com>
Thu, 15 Jul 1999 14:20:28 +0000 (14:20 +0000)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Thu, 15 Jul 1999 14:20:28 +0000 (14:20 +0000)
strerror.c [new file with mode: 0644]

diff --git a/strerror.c b/strerror.c
new file mode 100644 (file)
index 0000000..9d14353
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ *  CU sudo version 1.6
+ *  Copyright (c) 1999 Todd C. Miller <Todd.Miller@courtesan.com>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 1, or (at your option)
+ *  any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ *  Please send bugs, changes, problems to sudo-bugs@courtesan.com
+ *
+ *******************************************************************
+ *
+ *  This module emulates strerror(3) for those systems that lack it.
+ */
+
+#include <stdio.h>
+#include <errno.h>
+
+#include "config.h"
+
+#ifndef HAVE_STRERROR
+
+#ifndef lint
+static const char rcsid[] = "$Sudo$";
+#endif /* lint */
+
+/*
+ * Map errno -> error string.
+ */
+char *
+strerror(n)
+    int n;
+{
+    extern int sys_nerr;
+    extern char *sys_errlist[];
+
+    if (n > 0 && n < sys_nerr)
+       return(sys_errlist[n]);
+    else
+       return("Unknown error");
+}
+
+#endif /* HAVE_STRERROR */