From f47def63fc43c3efc6f87f735bebd2718d288a9f Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Thu, 15 Jul 1999 14:20:28 +0000 Subject: [PATCH] strerror() for systems w/o it --- strerror.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 strerror.c diff --git a/strerror.c b/strerror.c new file mode 100644 index 000000000..9d143539c --- /dev/null +++ b/strerror.c @@ -0,0 +1,53 @@ +/* + * CU sudo version 1.6 + * Copyright (c) 1999 Todd C. Miller + * + * 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 +#include + +#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 */ -- 2.40.0