home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume4 / rolodex / part3 / toolsdir / args.h < prev    next >
Encoding:
C/C++ Source or Header  |  1986-11-30  |  2.3 KB  |  97 lines

  1. /* You must include "basics.h" to use this */
  2.  
  3. /* To use this package, first call get_args, then call the various other */
  4. /* routines to see which options were given, etc. */
  5.  
  6. #define NIL 0                          /* null pointer  */
  7.  
  8. #define ARG_ERROR -1
  9. #define NO_ARGS 0
  10. #define ARGS_PRESENT 1
  11.  
  12. #define MAX_OPTIONS 52                 /* a-z A-Z */
  13. #define NO_OPTION -1
  14.  
  15. /* an argument and the option it is associated with */
  16.  
  17. typedef struct argument {
  18.         char *option;
  19.         int option_index;
  20.         struct argument *next;
  21. } Cmd_Arg, *Ptr_Cmd_Arg;
  22.  
  23. /* all the arguments (in a list) and a toggle for every possible option */
  24.  
  25. typedef struct {
  26.         Ptr_Cmd_Arg non_dash_arg_list; 
  27.         int dash_options[MAX_OPTIONS];
  28. } Cmd_Line, *Ptr_Cmd_Line;
  29.  
  30. /*--------------------------------------------------------------------------*/
  31.         
  32. extern char *malloc();
  33.  
  34. extern int get_args();
  35.  
  36.         /* int argc; char **argv; Bool dup_error; Bool print_msg; */
  37.         /* returns one of ARG_ERROR, NO_ARGS, or ARGS_PRESENT */
  38.         /* if dup_error, then having two identical options on the command */
  39.         /* line will cause an error.  If print_msg, then  any error that */
  40.         /* is noticed is printed out to stderr.  If !dup_error then */
  41.         /* 'foo -a 3 4 -b -a 5' is equivalent to 'foo -a 3 4 5 -b' */
  42.         
  43.         
  44. extern Bool any_option_present();
  45.  
  46.         /* no arguments */
  47.  
  48. extern Bool option_present();
  49.  
  50.         /* char achar; */
  51.  
  52. extern char * option_arg();
  53.  
  54.         /* char achar; int n; */
  55.  
  56. extern char * non_option_arg();
  57.  
  58.         /* int n; */
  59.  
  60. extern int n_option_args();
  61.  
  62.         /* char achar; */
  63.  
  64. extern int n_non_option_args();
  65.  
  66.         /* no arguments */
  67.  
  68. extern int n_non_dash_args();
  69.  
  70.         /* no arguments */
  71.  
  72. extern Bool check_option_args();        
  73.  
  74.         /* char achar; int min; int max; */
  75.  
  76. #define ALL_LEGAL 0
  77.  
  78. extern char legal_options();
  79.  
  80.         /* char *legaloptions; */
  81.         /* legaloptions should be a string of characters all in the range */
  82.         /* a-zA-Z.   Returns ALL_LEGAL if every option parsed in included */
  83.         /* in the legaloptions string, otherwise returns the first option */
  84.         /* character not in the string. */
  85.  
  86. extern set_option();
  87.  
  88.         /* char achar */
  89.  
  90. extern error_message();
  91.  
  92.         /* char *progname; char **argv; int index; char *usage; */
  93.  
  94. extern print_args();
  95.  
  96.         /* debugging routine */
  97.