mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 07:04:22 +01:00
common/json.c: Implement json_to_u32.
This commit is contained in:
committed by
Christian Decker
parent
fb7c006187
commit
44e8256338
@@ -105,6 +105,21 @@ bool json_to_u16(const char *buffer, const jsmntok_t *tok,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool json_to_u32(const char *buffer, const jsmntok_t *tok,
|
||||
uint32_t *num)
|
||||
{
|
||||
uint64_t u64;
|
||||
|
||||
if (!json_to_u64(buffer, tok, &u64))
|
||||
return false;
|
||||
*num = u64;
|
||||
|
||||
/* Just in case it doesn't fit. */
|
||||
if (*num != u64)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool json_to_int(const char *buffer, const jsmntok_t *tok, int *num)
|
||||
{
|
||||
char *end;
|
||||
|
||||
@@ -37,6 +37,10 @@ bool json_to_number(const char *buffer, const jsmntok_t *tok,
|
||||
bool json_to_u64(const char *buffer, const jsmntok_t *tok,
|
||||
uint64_t *num);
|
||||
|
||||
/* Extract number from this (may be a string, or a number literal) */
|
||||
bool json_to_u32(const char *buffer, const jsmntok_t *tok,
|
||||
uint32_t *num);
|
||||
|
||||
/* Extract number from this (may be a string, or a number literal) */
|
||||
bool json_to_u16(const char *buffer, const jsmntok_t *tok,
|
||||
uint16_t *num);
|
||||
|
||||
Reference in New Issue
Block a user