123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305 |
- #ifndef ARGTABLE3
- #define ARGTABLE3
- #include <stdio.h> /* FILE */
- #include <time.h> /* struct tm */
- #ifdef __cplusplus
- extern "C" {
- #endif
- #define ARG_REX_ICASE 1
-
- enum
- {
- ARG_TERMINATOR=0x1,
- ARG_HASVALUE=0x2,
- ARG_HASOPTVALUE=0x4
- };
- typedef void (arg_resetfn)(void *parent);
- typedef int (arg_scanfn)(void *parent, const char *argval);
- typedef int (arg_checkfn)(void *parent);
- typedef void (arg_errorfn)(void *parent, FILE *fp, int error, const char *argval, const char *progname);
- struct arg_hdr
- {
- char flag;
- const char *shortopts;
- const char *longopts;
- const char *datatype;
- const char *glossary;
- int mincount;
- int maxcount;
- void *parent;
- arg_resetfn *resetfn;
- arg_scanfn *scanfn;
- arg_checkfn *checkfn;
- arg_errorfn *errorfn;
- void *priv;
- };
- struct arg_rem
- {
- struct arg_hdr hdr;
- };
- struct arg_lit
- {
- struct arg_hdr hdr;
- int count;
- };
- struct arg_int
- {
- struct arg_hdr hdr;
- int count;
- int *ival;
- };
- struct arg_dbl
- {
- struct arg_hdr hdr;
- int count;
- double *dval;
- };
- struct arg_str
- {
- struct arg_hdr hdr;
- int count;
- const char **sval;
- };
- struct arg_rex
- {
- struct arg_hdr hdr;
- int count;
- const char **sval;
- };
- struct arg_file
- {
- struct arg_hdr hdr;
- int count;
- const char **filename;
- const char **basename;
- const char **extension;
- };
- struct arg_date
- {
- struct arg_hdr hdr;
- const char *format;
- int count;
- struct tm *tmval;
- };
- enum {ARG_ELIMIT=1, ARG_EMALLOC, ARG_ENOMATCH, ARG_ELONGOPT, ARG_EMISSARG};
- struct arg_end
- {
- struct arg_hdr hdr;
- int count;
- int *error;
- void **parent;
- const char **argval;
- };
- struct arg_rem* arg_rem(const char* datatype, const char* glossary);
- struct arg_lit* arg_lit0(const char* shortopts,
- const char* longopts,
- const char* glossary);
- struct arg_lit* arg_lit1(const char* shortopts,
- const char* longopts,
- const char *glossary);
- struct arg_lit* arg_litn(const char* shortopts,
- const char* longopts,
- int mincount,
- int maxcount,
- const char *glossary);
- struct arg_key* arg_key0(const char* keyword,
- int flags,
- const char* glossary);
- struct arg_key* arg_key1(const char* keyword,
- int flags,
- const char* glossary);
- struct arg_key* arg_keyn(const char* keyword,
- int flags,
- int mincount,
- int maxcount,
- const char* glossary);
- struct arg_int* arg_int0(const char* shortopts,
- const char* longopts,
- const char* datatype,
- const char* glossary);
- struct arg_int* arg_int1(const char* shortopts,
- const char* longopts,
- const char* datatype,
- const char *glossary);
- struct arg_int* arg_intn(const char* shortopts,
- const char* longopts,
- const char *datatype,
- int mincount,
- int maxcount,
- const char *glossary);
- struct arg_dbl* arg_dbl0(const char* shortopts,
- const char* longopts,
- const char* datatype,
- const char* glossary);
- struct arg_dbl* arg_dbl1(const char* shortopts,
- const char* longopts,
- const char* datatype,
- const char *glossary);
- struct arg_dbl* arg_dbln(const char* shortopts,
- const char* longopts,
- const char *datatype,
- int mincount,
- int maxcount,
- const char *glossary);
- struct arg_str* arg_str0(const char* shortopts,
- const char* longopts,
- const char* datatype,
- const char* glossary);
- struct arg_str* arg_str1(const char* shortopts,
- const char* longopts,
- const char* datatype,
- const char *glossary);
- struct arg_str* arg_strn(const char* shortopts,
- const char* longopts,
- const char* datatype,
- int mincount,
- int maxcount,
- const char *glossary);
- struct arg_rex* arg_rex0(const char* shortopts,
- const char* longopts,
- const char* pattern,
- const char* datatype,
- int flags,
- const char* glossary);
- struct arg_rex* arg_rex1(const char* shortopts,
- const char* longopts,
- const char* pattern,
- const char* datatype,
- int flags,
- const char *glossary);
- struct arg_rex* arg_rexn(const char* shortopts,
- const char* longopts,
- const char* pattern,
- const char* datatype,
- int mincount,
- int maxcount,
- int flags,
- const char *glossary);
- struct arg_file* arg_file0(const char* shortopts,
- const char* longopts,
- const char* datatype,
- const char* glossary);
- struct arg_file* arg_file1(const char* shortopts,
- const char* longopts,
- const char* datatype,
- const char *glossary);
- struct arg_file* arg_filen(const char* shortopts,
- const char* longopts,
- const char* datatype,
- int mincount,
- int maxcount,
- const char *glossary);
- struct arg_date* arg_date0(const char* shortopts,
- const char* longopts,
- const char* format,
- const char* datatype,
- const char* glossary);
- struct arg_date* arg_date1(const char* shortopts,
- const char* longopts,
- const char* format,
- const char* datatype,
- const char *glossary);
- struct arg_date* arg_daten(const char* shortopts,
- const char* longopts,
- const char* format,
- const char* datatype,
- int mincount,
- int maxcount,
- const char *glossary);
- struct arg_end* arg_end(int maxerrors);
- int arg_nullcheck(void **argtable);
- int arg_parse(int argc, char **argv, void **argtable);
- void arg_print_option(FILE *fp, const char *shortopts, const char *longopts, const char *datatype, const char *suffix);
- void arg_print_syntax(FILE *fp, void **argtable, const char *suffix);
- void arg_print_syntaxv(FILE *fp, void **argtable, const char *suffix);
- void arg_print_glossary(FILE *fp, void **argtable, const char *format);
- void arg_print_glossary_gnu(FILE *fp, void **argtable);
- void arg_print_errors(FILE* fp, struct arg_end* end, const char* progname);
- void arg_freetable(void **argtable, size_t n);
- void arg_free(void **argtable);
- #ifdef __cplusplus
- }
- #endif
- #endif
|