mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 05:12:45 +01:00
libplugin: add u16_option parsing
A couple of the fields for liquidity_ads are u16
This commit is contained in:
parent
f668e72dd6
commit
c934fe095b
@ -925,6 +925,25 @@ char *u32_option(const char *arg, u32 *i)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *u16_option(const char *arg, u16 *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 *bool_option(const char *arg, bool *i)
|
char *bool_option(const char *arg, bool *i)
|
||||||
{
|
{
|
||||||
if (!streq(arg, "true") && !streq(arg, "false"))
|
if (!streq(arg, "true") && !streq(arg, "false"))
|
||||||
|
@ -277,6 +277,7 @@ void plugin_notify_progress(struct command *cmd,
|
|||||||
/* 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 *u32_option(const char *arg, u32 *i);
|
||||||
|
char *u16_option(const char *arg, u16 *i);
|
||||||
char *bool_option(const char *arg, bool *i);
|
char *bool_option(const char *arg, bool *i);
|
||||||
char *charp_option(const char *arg, char **p);
|
char *charp_option(const char *arg, char **p);
|
||||||
char *flag_option(const char *arg, bool *i);
|
char *flag_option(const char *arg, bool *i);
|
||||||
|
Loading…
Reference in New Issue
Block a user