5 * Id: boolean.c,v 4.10 2007/02/04 17:44:12 bkorb Exp
6 * Time-stamp: "2007-01-13 10:10:39 bkorb"
8 * Automated Options Paged Usage module.
10 * This routine will run run-on options through a pager so the
11 * user may examine, print or edit them at their leisure.
15 * Automated Options copyright 1992-2007 Bruce Korb
17 * Automated Options is free software.
18 * You may redistribute it and/or modify it under the terms of the
19 * GNU General Public License, as published by the Free Software
20 * Foundation; either version 2, or (at your option) any later version.
22 * Automated Options is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
27 * You should have received a copy of the GNU General Public License
28 * along with Automated Options. See the file "COPYING". If not,
29 * write to: The Free Software Foundation, Inc.,
30 * 51 Franklin Street, Fifth Floor,
31 * Boston, MA 02110-1301, USA.
33 * As a special exception, Bruce Korb gives permission for additional
34 * uses of the text contained in his release of AutoOpts.
36 * The exception is that, if you link the AutoOpts library with other
37 * files to produce an executable, this does not by itself cause the
38 * resulting executable to be covered by the GNU General Public License.
39 * Your use of that executable is in no way restricted on account of
40 * linking the AutoOpts library code into it.
42 * This exception does not however invalidate any other reasons why
43 * the executable file might be covered by the GNU General Public License.
45 * This exception applies only to the code released by Bruce Korb under
46 * the name AutoOpts. If you copy code from other sources under the
47 * General Public License into a copy of AutoOpts, as the General Public
48 * License permits, the exception does not apply to the code that you add
49 * in this way. To avoid misleading anyone as to the status of such
50 * modified files, you must delete this exception notice from them.
52 * If you write modifications of your own for AutoOpts, it is your choice
53 * whether to permit this exception to apply to your modifications.
54 * If you do not wish that, delete this exception notice.
57 /*=export_func optionBooleanVal
60 * what: Decipher a boolean value
61 * arg: + tOptions* + pOpts + program options descriptor +
62 * arg: + tOptDesc* + pOptDesc + the descriptor for this arg +
65 * Decipher a true or false value for a boolean valued option argument.
66 * The value is true, unless it starts with 'n' or 'f' or "#f" or
67 * it is an empty string or it is a number that evaluates to zero.
70 optionBooleanVal( tOptions
* pOpts
, tOptDesc
* pOD
)
73 ag_bool res
= AG_TRUE
;
75 switch (*(pOD
->optArg
.argString
)) {
78 long val
= strtol( pOD
->optArg
.argString
, &pz
, 0 );
79 if ((val
!= 0) || (*pz
!= NUL
))
91 if (pOD
->optArg
.argString
[1] != 'f')
96 if (pOD
->fOptState
& OPTST_ALLOC_ARG
) {
97 AGFREE(pOD
->optArg
.argString
);
98 pOD
->fOptState
&= ~OPTST_ALLOC_ARG
;
100 pOD
->optArg
.argBool
= res
;
105 * c-file-style: "stroustrup"
106 * indent-tabs-mode: nil
108 * end of autoopts/boolean.c */