5 * Handle options with true/false values for arguments.
11 * This routine will run run-on options through a pager so the
12 * user may examine, print or edit them at their leisure.
14 * This file is part of AutoOpts, a companion to AutoGen.
15 * AutoOpts is free software.
16 * AutoOpts is Copyright (C) 1992-2015 by Bruce Korb - all rights reserved
18 * AutoOpts is available under any one of two licenses. The license
19 * in use must be one of these two and the choice is under the control
20 * of the user of the license.
22 * The GNU Lesser General Public License, version 3 or later
23 * See the files "COPYING.lgplv3" and "COPYING.gplv3"
25 * The Modified Berkeley Software Distribution License
26 * See the file "COPYING.mbsd"
28 * These files have the following sha256 sums:
30 * 8584710e9b04216a394078dc156b781d0b47e1729104d666658aecef8ee32e95 COPYING.gplv3
31 * 4379e7444a0e2ce2b12dd6f5a52a27a4d02d39d247901d3285c88cf0d37f477b COPYING.lgplv3
32 * 13aa749a5b0a454917a944ed8fffc530b784f5ead522b1aacaf4ec8aa55a6239 COPYING.mbsd
35 /*=export_func optionBooleanVal
38 * what: Decipher a boolean value
39 * arg: + tOptions * + opts + program options descriptor +
40 * arg: + tOptDesc * + od + the descriptor for this arg +
43 * Decipher a true or false value for a boolean valued option argument.
44 * The value is true, unless it starts with 'n' or 'f' or "#f" or
45 * it is an empty string or it is a number that evaluates to zero.
48 optionBooleanVal(tOptions * opts, tOptDesc * od)
53 if (INQUERY_CALL(opts, od))
56 if (od->optArg.argString == NULL) {
57 od->optArg.argBool = false;
61 switch (*(od->optArg.argString)) {
64 long val = strtol(od->optArg.argString, &pz, 0);
65 if ((val != 0) || (*pz != NUL))
77 if (od->optArg.argString[1] != 'f')
82 if (od->fOptState & OPTST_ALLOC_ARG) {
83 AGFREE(od->optArg.argString);
84 od->fOptState &= ~OPTST_ALLOC_ARG;
86 od->optArg.argBool = res;
92 * c-file-style: "stroustrup"
93 * indent-tabs-mode: nil
95 * end of autoopts/boolean.c */