Browse Source

ccan: retrieve last updates to opt/

Co-authored-by: Rusty Russell <rusty@rustcorp.com.au>
travis-debug
darosior 5 years ago
committed by Rusty Russell
parent
commit
2b57cfcc59
  1. 17
      ccan/ccan/opt/opt.c
  2. 9
      ccan/ccan/opt/opt.h

17
ccan/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;

9
ccan/ccan/opt/opt.h

@ -228,6 +228,15 @@ void opt_register_table(const struct opt_table *table, const char *desc);
_opt_register((names), OPT_CB_ARG((cb), OPT_EARLY, (show),(arg)), \
(arg), (desc))
/**
* opt_unregister - unregister an option.
* @names: the names it was registered with.
*
* This undoes opt_register[_early]_[no]arg. Returns true if the option was
* found, otherwise false.
*/
bool opt_unregister(const char *names);
/**
* opt_parse - parse arguments.
* @argc: pointer to argc

Loading…
Cancel
Save