X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=test-parse-options.c;h=2a79e729a4018ddb2da9ff633f4bf3b102fa8f88;hb=77d3ecee85dbf354d2059d7ef65d788d90db3efa;hp=73360d75126af2f231b3cfdad26a47e18fff0a39;hpb=1eaa541f5fbda3fc30085da4f75e99dfae4ec9b3;p=git.git diff --git a/test-parse-options.c b/test-parse-options.c index 73360d751..2a79e729a 100644 --- a/test-parse-options.c +++ b/test-parse-options.c @@ -2,9 +2,22 @@ #include "parse-options.h" static int boolean = 0; -static int integer = 0; +static unsigned long integer = 0; +static int abbrev = 7; +static int verbose = 0, dry_run = 0, quiet = 0; static char *string = NULL; +int length_callback(const struct option *opt, const char *arg, int unset) +{ + printf("Callback: \"%s\", %d\n", + (arg ? arg : "not set"), unset); + if (unset) + return 1; /* do not support unset */ + + *(unsigned long *)opt->value = strlen(arg); + return 0; +} + int main(int argc, const char **argv) { const char *usage[] = { @@ -13,15 +26,29 @@ int main(int argc, const char **argv) }; struct option options[] = { OPT_BOOLEAN('b', "boolean", &boolean, "get a boolean"), + OPT_BIT('4', "or4", &boolean, + "bitwise-or boolean with ...0100", 4), + OPT_GROUP(""), OPT_INTEGER('i', "integer", &integer, "get a integer"), OPT_INTEGER('j', NULL, &integer, "get a integer, too"), - OPT_GROUP("string options"), + OPT_SET_INT(0, "set23", &integer, "set integer to 23", 23), + OPT_DATE('t', NULL, &integer, "get timestamp of