1
0

numeric.c 3.1 KB

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