home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / pp / pp-6.0 / h / argh.h < prev    next >
Encoding:
C/C++ Source or Header  |  1991-12-18  |  3.3 KB  |  105 lines

  1. /* argh.h: Used by the mu program */
  2.  
  3. /*
  4.  * @(#) $Header: /xtel/pp/pp-beta/h/RCS/argh.h,v 6.0 1991/12/18 20:42:44 jpo Rel $
  5.  *
  6.  * $Log: argh.h,v $
  7.  * Revision 6.0  1991/12/18  20:42:44  jpo
  8.  * Release 6.0
  9.  *
  10.  *
  11.  */
  12.  
  13.  
  14.  
  15. #ifndef _H_ARGH
  16. #define _H_ARGH
  17.  
  18.  
  19.  
  20. #define ARGHVER         "argh v. 1.1"   /* Version number */
  21. #define MAXARGS         100     /* Maximum argument instances provided for */
  22. #define MAXFLAGS        50      /* Maximum number of flags
  23.                    needed to size sorting array argsort[] */
  24. #define FLAGCHAR        '-'     /* introduces a flag on command line */
  25. #define EQUCHAR         '='     /* to separate a partial but
  26.                    unambiguous flag from its value */
  27. #define MAXFLAGLEN      30                      /* max flag length */
  28. #define VALIDTYPES      "0123456789amnz?"       /* allowed flag types */
  29. #define ADJARGS         TRUE                    /* allow adjacent args */
  30. #define ONECHARARGS     FALSE                   /* allow unambiguous one-byte flags without EQUCHAR */
  31. #define ZEROCHECK       FALSE                   /* test type '0' against next arg */
  32.  
  33. int     flagcount;      /* Count from calling-program-specific table */
  34. int     argcpi;         /* Current parameter index */
  35. int     argsource;      /* Current argument source */
  36.  
  37. void    add_link();
  38. void    take_next();
  39. void    arg_error();
  40. void    show_args();
  41. void    call_args();
  42. void    list_args();
  43. void    quick_string();
  44. void    qs_string();
  45.  
  46. int     scan_args();
  47. int     prep_args();
  48. int     count_to_flag();
  49.  
  50. char    *next_arg();
  51. char    *nextc_arg();
  52. char    *digit_word();
  53.  
  54. struct  arginst {               /* instance of one argument type */
  55.     char    *argcp;         /* character pointer */
  56.     int     argci;          /* argument counter e.g. argv[ai->argci] */
  57.     int     argoi;          /* offset e.g. argv[ai->argci][ai->argoi] */
  58.     int     argn;           /* instance in this run */
  59.     int     argof;          /* ... of total instances in this run */
  60.     int     argsrc;         /* source - i.e. which call to scan_args */
  61.     int     argused;        /* used marker TRUE -> has been used */
  62.     struct  arginst *next;  /* linked list */
  63. };
  64.  
  65. struct  argdef {                /* user supplied flag list */
  66.     char    *flag;          /* see below */
  67.     void    (*function)();
  68.     char    type;
  69.     int     match;
  70. };
  71.  
  72. struct  argfull {               /* argument ( flag ) definitions */
  73.  
  74. /*      char    flag[MAXFLAGLEN];       character(s) to follow '-' */
  75.     char    *flag;          /* character(s) to follow '-' */
  76.  
  77.     void    (*function)();  /* to hold pointer to function */
  78.  
  79.     char    type;           /*      a : valued : adjacent to flag
  80.                     n : valued : next argument
  81.                     0 : lone ( no assoc. value )
  82.                     1 : valued : adjacent or next
  83.                     2 : as v but takes 2 args
  84.                     3 : as v but takes 3 args
  85.                     ... etc. (up to 9)
  86.                     m : 1 or more ( up to next flag )
  87.                     z : as m but zero args allowed */
  88.  
  89.     int     match;          /* Minimum length for unambiguous
  90.                    matching. These can be calculated
  91.                   >0 indicates length to use
  92.                    0 indicates calculation reqd.
  93.                   -1 indicates exact match reqd.
  94.                    If matching allowed, type a is not.
  95.                    nor v(adjacent) less than
  96.                    strlen(flag) unless EQUCHAR used */
  97.  
  98.     int     length;         /* length of flag */
  99.     int     count;                  /* how many instances */
  100.     struct  arginst *first,*last;   /* pointers to first, last instance */
  101. };
  102.  
  103.  
  104. #endif
  105.