From: Todd C. Miller Date: Sat, 20 Feb 2010 14:47:46 +0000 (-0500) Subject: Add missing source for sudo front end X-Git-Tag: SUDO_1_8_0~889 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4b88f1a7efff7fe600bef6eb43fef8890a362153;p=sudo Add missing source for sudo front end --- diff --git a/src/atobool.c b/src/atobool.c new file mode 100644 index 000000000..d8d637a1a --- /dev/null +++ b/src/atobool.c @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2010 Todd C. Miller + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include + +#include +#include + +#include +#ifdef STDC_HEADERS +# include +# include +#else +# ifdef HAVE_STDLIB_H +# include +# endif +#endif /* STDC_HEADERS */ +#ifdef HAVE_STRING_H +# if defined(HAVE_MEMORY_H) && !defined(STDC_HEADERS) +# include +# endif +# include +#else +# ifdef HAVE_STRINGS_H +# include +# endif +#endif /* HAVE_STRING_H */ + +#include "sudo.h" + +int +atobool(const char *str) +{ + if (strcasecmp(str, "true") == 0 || strcmp(str, "1") == 0) + return TRUE; + if (strcasecmp(str, "false") == 0 || strcmp(str, "0") == 0) + return FALSE; + return -1; +}