mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-21 14:24:09 +01:00
ccan: retrieve last updates to opt/
Co-authored-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
84e3fa39b3
commit
2b57cfcc59
2 changed files with 26 additions and 0 deletions
|
@ -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;
|
||||
|
|
|
@ -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…
Add table
Reference in a new issue