opt.h
1 #define FLAG_NONE 0 2 #define OPT_GOOD 0 3 #define OPT_FAIL 1 4 #define OPT_SKIP 2 5 #define OPT_LAST 3 6 7 #define ERROR(...) { fprintf(stderr, __VA_ARGS__); return OPT_FAIL; } 8 9 #define USAGE \ 10 "Usage: %s [-i] [-p] [-o DIR] [-b URL] [-c DIR] REPO [REPO2 [...]]" "\n" \ 11 " -i: generate index file" "\n" \ 12 " -p: generate repository pages" "\n" \ 13 " -o: specify output dir" "\n" \ 14 " -b: specify base url" "\n" \ 15 " -c: specify cache dir" "\n" \ 16 "\n" 17 18 #define PRINT_USAGE(argv0) fprintf(stderr, USAGE, argv0); 19 20 21 typedef struct _ { 22 int index; /* 0 or 1 */ 23 int pages; /* 0 or 1 */ 24 25 const char *cache; 26 const char *out_dir; 27 const char *base_url; 28 29 int repo_count; 30 const char **repo_dirs; 31 } Opt; 32 33 int parse_opts(Opt *opt, int argc, const char *argv[]);