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