X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Fopt%2Fopt.c;fp=ccan%2Fopt%2Fopt.c;h=d4601dfbb230a3076edfa64d8b5232996f4d59d2;hb=c36444e062622d97e4368670f5c50f0c482a3a95;hp=0514dc8702dfc8ef2327d892f7cbd7606dec2b06;hpb=a1f9c169fec59ea257256ef5d18ccba05635e7ac;p=ccan diff --git a/ccan/opt/opt.c b/ccan/opt/opt.c index 0514dc87..d4601dfb 100644 --- a/ccan/opt/opt.c +++ b/ccan/opt/opt.c @@ -176,6 +176,23 @@ void _opt_register(const char *names, enum opt_type type, add_opt(&opt); } +bool opt_unregister(const char *names) +{ + int found = -1, i; + + for (i = 0; i < opt_count; i++) { + if (opt_table[i].type == OPT_SUBTABLE) + continue; + if (strcmp(opt_table[i].names, names) == 0) + found = i; + } + if (found == -1) + return false; + opt_count--; + memmove(&opt_table[found], &opt_table[found+1], opt_count - found); + return true; +} + void opt_register_table(const struct opt_table entry[], const char *desc) { unsigned int i, start = opt_count;