diff options
author | Willy Tarreau <willy@wtap.(none)> | 2006-07-26 10:46:55 +0200 |
---|---|---|
committer | Willy Tarreau <willy@wtap.(none)> | 2006-07-26 10:46:55 +0200 |
commit | fcb250efba23ae522c4c8cb03c47dd40edcf9603 (patch) | |
tree | 3756bd1748842a3f1049d857e8412f148a8741b9 /flx/arg.h | |
parent | Initial commit (diff) | |
download | flxutils-fcb250efba23ae522c4c8cb03c47dd40edcf9603.tar.xz |
[RELEASE] flxutils-0.1.4.2v0.1.4.2
Diffstat (limited to 'flx/arg.h')
-rw-r--r-- | flx/arg.h | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/flx/arg.h b/flx/arg.h new file mode 100644 index 0000000..d1180d2 --- /dev/null +++ b/flx/arg.h @@ -0,0 +1,49 @@ +#ifndef __ARG_H__ +#define __ARG_H__ + +#include <stdio.h> + +typedef struct p_param t_param; + +struct p_param { + char shortopt; + char *longopt; + int optnum; + int minarg; + char *help; +}; + +extern char *Progname ; + +/* example: use of t_param +t_param sample_poptions[] = { + { 'h', "help", 0xFFFF, 0, "this help" }, + { 0, NULL, 0, 0} +}; + +int sample_pfct(int opt, t_param *param, char **flag, char **argv) { + if (opt == 0xFFFF) arg_usage(sample_poptions, NULL); + return (param ? param->minarg : 0); +} + +int main(int argc, char **argv) { + int ret; + + ret = arg_init(argc, argv, sample_poptions, sample_pfct); + if (ret <= 0) return (1); + argc -= ret; argv += ret; + + ... +} + +*/ + +int arg_init(int argc, char **argv, t_param *paramoptions, int (*paramfct)()) ; +char *progname(char *); +void arg_usage(t_param *p, char *message, ...); + + +#endif /* __ARG_H__ */ + + + |