If OCSP revocation data are invalid or too old set appropriate verification flags.
[gnutls.git] / src / libopts / boolean.c
blobf0e5498a88b7641089236527e5916191b0fecd24
2 /**
3 * \file boolean.c
5 * Time-stamp: "2012-03-31 13:46:19 bkorb"
7 * Automated Options Paged Usage module.
9 * This routine will run run-on options through a pager so the
10 * user may examine, print or edit them at their leisure.
12 * This file is part of AutoOpts, a companion to AutoGen.
13 * AutoOpts is free software.
14 * AutoOpts is Copyright (c) 1992-2012 by Bruce Korb - all rights reserved
16 * AutoOpts is available under any one of two licenses. The license
17 * in use must be one of these two and the choice is under the control
18 * of the user of the license.
20 * The GNU Lesser General Public License, version 3 or later
21 * See the files "COPYING.lgplv3" and "COPYING.gplv3"
23 * The Modified Berkeley Software Distribution License
24 * See the file "COPYING.mbsd"
26 * These files have the following md5sums:
28 * 43b91e8ca915626ed3818ffb1b71248b pkg/libopts/COPYING.gplv3
29 * 06a1a2e4760c90ea5e1dad8dfaac4d39 pkg/libopts/COPYING.lgplv3
30 * 66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd
33 /*=export_func optionBooleanVal
34 * private:
36 * what: Decipher a boolean value
37 * arg: + tOptions* + pOpts + program options descriptor +
38 * arg: + tOptDesc* + pOptDesc + the descriptor for this arg +
40 * doc:
41 * Decipher a true or false value for a boolean valued option argument.
42 * The value is true, unless it starts with 'n' or 'f' or "#f" or
43 * it is an empty string or it is a number that evaluates to zero.
44 =*/
45 void
46 optionBooleanVal(tOptions * pOpts, tOptDesc * pOD )
48 char* pz;
49 bool res = true;
51 (void)pOpts;
53 if ((pOD->fOptState & OPTST_RESET) != 0)
54 return;
56 if (pOD->optArg.argString == NULL) {
57 pOD->optArg.argBool = false;
58 return;
61 switch (*(pOD->optArg.argString)) {
62 case '0':
64 long val = strtol( pOD->optArg.argString, &pz, 0 );
65 if ((val != 0) || (*pz != NUL))
66 break;
67 /* FALLTHROUGH */
69 case 'N':
70 case 'n':
71 case 'F':
72 case 'f':
73 case NUL:
74 res = false;
75 break;
76 case '#':
77 if (pOD->optArg.argString[1] != 'f')
78 break;
79 res = false;
82 if (pOD->fOptState & OPTST_ALLOC_ARG) {
83 AGFREE(pOD->optArg.argString);
84 pOD->fOptState &= ~OPTST_ALLOC_ARG;
86 pOD->optArg.argBool = res;
89 * Local Variables:
90 * mode: C
91 * c-file-style: "stroustrup"
92 * indent-tabs-mode: nil
93 * End:
94 * end of autoopts/boolean.c */