Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libplugin: use json stream helpers and add sanity tests #3480

Merged
merged 10 commits into from
Feb 9, 2020
17 changes: 17 additions & 0 deletions ccan/ccan/opt/opt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 9 additions & 0 deletions ccan/ccan/opt/opt.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, CCAN updates should be done via "make update-ccan" (optional: CCAN_NEW="". Assumes that ccan you want is in ../ccan.

Easy to fix this post, however.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did it this way then withdrawn it because of the huge diff, will fix!


/**
* opt_parse - parse arguments.
* @argc: pointer to argc
Expand Down