1: /*
   2:  * Copyright (c) 1990 Michael A. Cooper.
   3:  * This software may be freely distributed provided it is not sold for
   4:  * profit and the author is credited appropriately.
   5:  */
   6: 
   7: /*
   8:  * $Header: RCS/options.h,v 1.7.1 96/3/23 18:13:30 sms Exp $
   9:  *
  10:  * $Log:	options.h,v $
  11:  * Revision 1.7  90/12/15  18:13:30  mcooper
  12:  * Add copywrite notice.
  13:  *
  14:  * Revision 1.6  90/11/13  15:28:39  mcooper
  15:  * Add OptBool cvtarg routine.
  16:  *
  17:  * Revision 1.5  90/10/29  19:34:03  mcooper
  18:  * Fixed comment for NoArg.
  19:  *
  20:  * Revision 1.4  90/10/29  18:48:43  mcooper
  21:  * Cleanup some comments.
  22:  *
  23:  * Revision 1.3  90/10/29  14:47:29  mcooper
  24:  * UsageString is now a real function.
  25:  *
  26:  * Revision 1.2  90/10/26  15:55:44  mcooper
  27:  * Add defines for "__" and ArgHidden.
  28:  *
  29:  * Revision 1.1  90/10/26  14:42:53  mcooper
  30:  * Initial revision
  31:  *
  32:  */
  33: 
  34: 
  35: #include <stdio.h>
  36: #include <sys/types.h>
  37: #include <sys/errno.h>
  38: 
  39: #define Num_Opts(o) (sizeof(o)/sizeof(OptionDescRec))
  40: #define HELPSTR     "-help"
  41: #define __      (caddr_t)
  42: 
  43: #ifndef TRUE
  44: #define TRUE    1
  45: #endif
  46: #ifndef FALSE
  47: #define FALSE   0
  48: #endif
  49: 
  50: /*
  51:  * Values for OptionDescRec.flags.
  52:  */
  53: #define NoArg       0x001   /* No argument for this option.  Use
  54: 				   OptionDescRec.value. */
  55: #define IsArg       0x002   /* Value is the option string itself */
  56: #define SepArg      0x004   /* Value is in next argument in argv */
  57: #define StickyArg   0x008   /* Value is characters immediately following
  58: 				   option */
  59: #define SkipArg     0x010   /* Ignore this option and the next argument in
  60: 				   argv */
  61: #define SkipLine    0x020   /* Ignore this option and the rest of argv */
  62: #define SkipNArgs   0x040   /* Ignore this option and the next
  63: 				   OptionDescRes.value arguments in argv */
  64: #define ArgHidden   0x080   /* Don't show in usage or help messages */
  65: 
  66: /*
  67:  * Option description record.
  68:  */
  69: typedef struct {
  70:     char    *option;        /* Option string in argv	    */
  71:     int      flags;         /* Flag bits			    */
  72:     int     (*cvtarg)();        /* Function to convert argument     */
  73:     caddr_t  valp;          /* Variable to set		    */
  74:     caddr_t  value;         /* Default value to provide	    */
  75:     char    *usage;         /* Usage message		    */
  76:     char    *desc;          /* Description message		    */
  77: } OptionDescRec, *OptionDescList;
  78: 
  79: void UsageOptions();
  80: void HelpOptions();
  81: void UserError();
  82: int ParseOptions();
  83: OptionDescRec *FindOption();
  84: 
  85: int OptBool();
  86: int OptInt();
  87: int OptLong();
  88: int OptShort();
  89: int OptStr();
  90: 
  91: extern char *OptionChars;
  92: extern int errno;
  93: extern char *sys_errlist[];
  94: extern long strtol();
  95: extern char *malloc();
  96: extern char *strcpy();

Defined macros

ArgHidden defined in line 64; used 6 times
FALSE defined in line 47; used 29 times
HELPSTR defined in line 40; used 2 times
IsArg defined in line 55; used 1 times
NoArg defined in line 53; used 21 times
Num_Opts defined in line 39; used 1 times
SepArg defined in line 56; used 6 times
SkipArg defined in line 59; used 1 times
SkipLine defined in line 61; used 1 times
SkipNArgs defined in line 62; used 1 times
StickyArg defined in line 57; used 6 times
TRUE defined in line 44; used 21 times
__ defined in line 41; used 3 times

Usage of this include

Last modified: 1996-03-23
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 3274
Valid CSS Valid XHTML 1.0 Strict