/*********************************************************** * * args.h * * Args is a simple command line arguement processing * package for UNIX. It is a table driven package that * does most of the work for argument processing. The * user of this package constructs a table that describes * the arguments that can be passed to the program. This * table contains the name of the argument, its value type, * and a pointer to the location where the argument's * value is stored. This package makes the following * assumptions about command line arguments: * * 1) a command argument consists of a flag and optionally * a value * * 2) the flag consists of a + or - followed by one or * more alphabetic characters * * 3) the value can be a character string, an integer, or * floating point number * * 4) in the case of character string values there must * be a space between the flag and the value, for * numeric values the space is optional * * 5) an argument that doesn't have a flag is assumed to * be a file name or some other character string that * shouldn't be processed by the argument package. * * * There is one user callable procedure in this package, * process_arguments(). This procedure is called with an * argument description table, and the values of argc and * argv passed to the program. It processes all the arguments * a returns a pointer to arguments that don't have flags. * ************************************************************/ /* * The following three constants are used to specify the * type of argument value. These values are stored in * the type field of the arg_table_entry struct. */ #define ARG_STRING 1 #define ARG_INT 2 #define ARG_FLOAT 3 /* * The following struct is used for the argument table entries. * Each entry in the argument table has a flag, a argument value * type and a pointer to where the argument value should be * stored. The calling program passes an array of these * structs to the process_arguments() procedure. The argument * table is terminated by a zero entry. */ struct arg_table_entry { char* flag; int type; void* value; }; typedef struct arg_table_entry Arg; char** process_arguments(Arg *, int, char **);