1181834Sroberto
2181834Sroberto/*
3181834Sroberto *  $Id: numeric.c,v 4.11 2007/02/04 17:44:12 bkorb Exp $
4181834Sroberto *  Time-stamp:      "2007-01-13 10:28:20 bkorb"
5181834Sroberto */
6181834Sroberto
7181834Sroberto/*
8181834Sroberto *  Automated Options copyright 1992-2007 Bruce Korb
9181834Sroberto *
10181834Sroberto *  Automated Options is free software.
11181834Sroberto *  You may redistribute it and/or modify it under the terms of the
12181834Sroberto *  GNU General Public License, as published by the Free Software
13181834Sroberto *  Foundation; either version 2, or (at your option) any later version.
14181834Sroberto *
15181834Sroberto *  Automated Options is distributed in the hope that it will be useful,
16181834Sroberto *  but WITHOUT ANY WARRANTY; without even the implied warranty of
17181834Sroberto *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18181834Sroberto *  GNU General Public License for more details.
19181834Sroberto *
20181834Sroberto *  You should have received a copy of the GNU General Public License
21181834Sroberto *  along with Automated Options.  See the file "COPYING".  If not,
22181834Sroberto *  write to:  The Free Software Foundation, Inc.,
23181834Sroberto *             51 Franklin Street, Fifth Floor,
24181834Sroberto *             Boston, MA  02110-1301, USA.
25181834Sroberto *
26181834Sroberto * As a special exception, Bruce Korb gives permission for additional
27181834Sroberto * uses of the text contained in his release of AutoOpts.
28181834Sroberto *
29181834Sroberto * The exception is that, if you link the AutoOpts library with other
30181834Sroberto * files to produce an executable, this does not by itself cause the
31181834Sroberto * resulting executable to be covered by the GNU General Public License.
32181834Sroberto * Your use of that executable is in no way restricted on account of
33181834Sroberto * linking the AutoOpts library code into it.
34181834Sroberto *
35181834Sroberto * This exception does not however invalidate any other reasons why
36181834Sroberto * the executable file might be covered by the GNU General Public License.
37181834Sroberto *
38181834Sroberto * This exception applies only to the code released by Bruce Korb under
39181834Sroberto * the name AutoOpts.  If you copy code from other sources under the
40181834Sroberto * General Public License into a copy of AutoOpts, as the General Public
41181834Sroberto * License permits, the exception does not apply to the code that you add
42181834Sroberto * in this way.  To avoid misleading anyone as to the status of such
43181834Sroberto * modified files, you must delete this exception notice from them.
44181834Sroberto *
45181834Sroberto * If you write modifications of your own for AutoOpts, it is your choice
46181834Sroberto * whether to permit this exception to apply to your modifications.
47181834Sroberto * If you do not wish that, delete this exception notice.
48181834Sroberto */
49181834Sroberto
50181834Sroberto/*=export_func  optionNumericVal
51181834Sroberto * private:
52181834Sroberto *
53181834Sroberto * what:  Decipher a boolean value
54181834Sroberto * arg:   + tOptions* + pOpts    + program options descriptor +
55181834Sroberto * arg:   + tOptDesc* + pOptDesc + the descriptor for this arg +
56181834Sroberto *
57181834Sroberto * doc:
58181834Sroberto *  Decipher a numeric value.
59181834Sroberto=*/
60181834Srobertovoid
61181834SrobertooptionNumericVal( tOptions* pOpts, tOptDesc* pOD )
62181834Sroberto{
63181834Sroberto    char* pz;
64181834Sroberto    long  val;
65181834Sroberto
66181834Sroberto    /*
67181834Sroberto     *  Numeric options may have a range associated with it.
68181834Sroberto     *  If it does, the usage procedure requests that it be
69181834Sroberto     *  emitted by passing a NULL pOD pointer.
70181834Sroberto     */
71181834Sroberto    if ((pOD == NULL) || (pOD->optArg.argString == NULL))
72181834Sroberto        return;
73181834Sroberto
74181834Sroberto    val = strtol( pOD->optArg.argString, &pz, 0 );
75181834Sroberto    if (*pz != NUL) {
76181834Sroberto        fprintf( stderr, zNotNumber, pOpts->pzProgName, pOD->optArg.argString );
77181834Sroberto        (*(pOpts->pUsageProc))(pOpts, EXIT_FAILURE);
78181834Sroberto    }
79181834Sroberto
80181834Sroberto    if (pOD->fOptState & OPTST_ALLOC_ARG) {
81181834Sroberto        AGFREE(pOD->optArg.argString);
82181834Sroberto        pOD->fOptState &= ~OPTST_ALLOC_ARG;
83181834Sroberto    }
84181834Sroberto
85181834Sroberto    pOD->optArg.argInt = val;
86181834Sroberto}
87181834Sroberto/*
88181834Sroberto * Local Variables:
89181834Sroberto * mode: C
90181834Sroberto * c-file-style: "stroustrup"
91181834Sroberto * indent-tabs-mode: nil
92181834Sroberto * End:
93181834Sroberto * end of autoopts/numeric.c */
94