mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-03 10:46:58 +01:00
libplugin: allow u32 options
This commit is contained in:
parent
8a3295b6a8
commit
902edf56e6
2 changed files with 20 additions and 0 deletions
|
@ -797,6 +797,25 @@ char *u64_option(const char *arg, u64 *i)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *u32_option(const char *arg, u32 *i)
|
||||||
|
{
|
||||||
|
char *endp;
|
||||||
|
u64 n;
|
||||||
|
|
||||||
|
errno = 0;
|
||||||
|
n = strtoul(arg, &endp, 0);
|
||||||
|
if (*endp || !arg[0])
|
||||||
|
return tal_fmt(NULL, "'%s' is not a number", arg);
|
||||||
|
if (errno)
|
||||||
|
return tal_fmt(NULL, "'%s' is out of range", arg);
|
||||||
|
|
||||||
|
*i = n;
|
||||||
|
if (*i != n)
|
||||||
|
return tal_fmt(NULL, "'%s' is too large (overflow)", arg);
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
char *charp_option(const char *arg, char **p)
|
char *charp_option(const char *arg, char **p)
|
||||||
{
|
{
|
||||||
*p = tal_strdup(NULL, arg);
|
*p = tal_strdup(NULL, arg);
|
||||||
|
|
|
@ -234,6 +234,7 @@ void plugin_log(struct plugin *p, enum log_level l, const char *fmt, ...) PRINTF
|
||||||
|
|
||||||
/* Standard helpers */
|
/* Standard helpers */
|
||||||
char *u64_option(const char *arg, u64 *i);
|
char *u64_option(const char *arg, u64 *i);
|
||||||
|
char *u32_option(const char *arg, u32 *i);
|
||||||
char *charp_option(const char *arg, char **p);
|
char *charp_option(const char *arg, char **p);
|
||||||
|
|
||||||
/* The main plugin runner: append with 0 or more plugin_option(), then NULL. */
|
/* The main plugin runner: append with 0 or more plugin_option(), then NULL. */
|
||||||
|
|
Loading…
Add table
Reference in a new issue