home *** CD-ROM | disk | FTP | other *** search
- /*------------------------------------------------------------
- *
- * getargs.h
- *
- * defs for getargs()
- *
- * by J. Alan Eldridge
- *
- * this code is placed in the public domain
- *
- * jae ??? created
- * jae 07/28/89 added ARG_FOUND bitmask
- * jae 04/09/90 added multi-char options, validation functions
- *
- *----------------------------------------------------------*/
-
- #ifndef __GETARGS__
-
- #define __GETARGS__
-
- /* ARGUMENT TYPES */
-
- #define ARG_BOOL 0x01 /* arg is boolean */
- #define ARG_INT 0x02 /* arg is integer */
- #define ARG_STR 0x04 /* arg is string */
-
- /* FLAGS */
-
- #define ARG_FOUND 0x40 /* internal, so each args occurs <= 1 time */
- #define ARG_REQD 0x80 /* says arg must be found or it's an error */
-
- #define ARG_IP(vp) ((int*)(vp))
- #define ARG_CPP(vp) ((char**)(vp))
-
- typedef int (*ARG_FUNC)();
-
- typedef struct {
- char *optstr; /* option string e.g., -pr (case sens.) */
- int argtype; /* type of arg: bool, int, or string */
- /* may have ARG_REQD or'ed in to indicate */
- /* that the arg's absence is an error */
- void *ptr; /* pointer to loc'n to recieve value */
- /* for ints & bools, ptr to int ... */
- /* for strings, ptr to ptr to char */
- ARG_FUNC valfun; /* validation function, 0 == OK, -1 == error */
- } CMD_ARG;
-
- #define ARG_CNT(arg_arr) (sizeof(arg_arr)/sizeof(CMD_ARG))
-
- #define ARG_NOFUNC ((ARG_FUNC)0)
-
- #ifndef NO_PROTO
-
- int getargs(
- int *argc_ptr,
- char **argv_ptr,
- int num_args,
- CMD_ARG arg_list[]);
-
- int _getargs(
- int *argc_ptr,
- char **argv_ptr,
- int num_args,
- CMD_ARG arg_list[],
- int ignorebad);
-
- int show_txt_w_pause(
- char **msg_arr,
- int nlines);
-
- void usage(
- char **msg_arr,
- int nlines,
- int ecode);
-
- int argfound(
- CMD_ARG *arr,
- int nopts,
- char *opt);
-
- void argfixbl(
- char *str,
- int c);
-
- #endif
-
- #endif
-