5 * Id: numeric.c,v 4.11 2007/02/04 17:44:12 bkorb Exp
6 * Time-stamp: "2007-01-13 10:28:20 bkorb"
10 * Automated Options copyright 1992-2007 Bruce Korb
12 * Automated Options is free software.
13 * You may redistribute it and/or modify it under the terms of the
14 * GNU General Public License, as published by the Free Software
15 * Foundation; either version 2, or (at your option) any later version.
17 * Automated Options is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with Automated Options. See the file "COPYING". If not,
24 * write to: The Free Software Foundation, Inc.,
25 * 51 Franklin Street, Fifth Floor,
26 * Boston, MA 02110-1301, USA.
28 * As a special exception, Bruce Korb gives permission for additional
29 * uses of the text contained in his release of AutoOpts.
31 * The exception is that, if you link the AutoOpts library with other
32 * files to produce an executable, this does not by itself cause the
33 * resulting executable to be covered by the GNU General Public License.
34 * Your use of that executable is in no way restricted on account of
35 * linking the AutoOpts library code into it.
37 * This exception does not however invalidate any other reasons why
38 * the executable file might be covered by the GNU General Public License.
40 * This exception applies only to the code released by Bruce Korb under
41 * the name AutoOpts. If you copy code from other sources under the
42 * General Public License into a copy of AutoOpts, as the General Public
43 * License permits, the exception does not apply to the code that you add
44 * in this way. To avoid misleading anyone as to the status of such
45 * modified files, you must delete this exception notice from them.
47 * If you write modifications of your own for AutoOpts, it is your choice
48 * whether to permit this exception to apply to your modifications.
49 * If you do not wish that, delete this exception notice.
52 /*=export_func optionNumericVal
55 * what: Decipher a boolean value
56 * arg: + tOptions* + pOpts + program options descriptor +
57 * arg: + tOptDesc* + pOptDesc + the descriptor for this arg +
60 * Decipher a numeric value.
63 optionNumericVal( tOptions
* pOpts
, tOptDesc
* pOD
)
69 * Numeric options may have a range associated with it.
70 * If it does, the usage procedure requests that it be
71 * emitted by passing a NULL pOD pointer.
73 if ((pOD
== NULL
) || (pOD
->optArg
.argString
== NULL
))
76 val
= strtol( pOD
->optArg
.argString
, &pz
, 0 );
78 fprintf( stderr
, zNotNumber
, pOpts
->pzProgName
, pOD
->optArg
.argString
);
79 (*(pOpts
->pUsageProc
))(pOpts
, EXIT_FAILURE
);
82 if (pOD
->fOptState
& OPTST_ALLOC_ARG
) {
83 AGFREE(pOD
->optArg
.argString
);
84 pOD
->fOptState
&= ~OPTST_ALLOC_ARG
;
87 pOD
->optArg
.argInt
= val
;
92 * c-file-style: "stroustrup"
93 * indent-tabs-mode: nil
95 * end of autoopts/numeric.c */