diff --git a/common/json_parse_simple.c b/common/json_parse_simple.c index 7f9c630ebeb2..a40cb02fbfe4 100644 --- a/common/json_parse_simple.c +++ b/common/json_parse_simple.c @@ -33,11 +33,6 @@ bool json_tok_strneq(const char *buffer, const jsmntok_t *tok, return memeq(buffer + tok->start, tok->end - tok->start, str, len); } -bool json_tok_streq(const char *buffer, const jsmntok_t *tok, const char *str) -{ - return json_tok_strneq(buffer, tok, str, strlen(str)); -} - bool json_tok_startswith(const char *buffer, const jsmntok_t *tok, const char *prefix) { @@ -217,12 +212,6 @@ const jsmntok_t *json_get_membern(const char *buffer, return NULL; } -const jsmntok_t *json_get_member(const char *buffer, const jsmntok_t tok[], - const char *label) -{ - return json_get_membern(buffer, tok, label, strlen(label)); -} - const jsmntok_t *json_get_arr(const jsmntok_t tok[], size_t index) { const jsmntok_t *t; diff --git a/common/json_parse_simple.h b/common/json_parse_simple.h index 710520d6f327..eb7a70d59023 100644 --- a/common/json_parse_simple.h +++ b/common/json_parse_simple.h @@ -14,13 +14,17 @@ const char *json_tok_full(const char *buffer, const jsmntok_t *t); /* Include " if it's a string. */ int json_tok_full_len(const jsmntok_t *t); -/* Is this a string equal to str? */ -bool json_tok_streq(const char *buffer, const jsmntok_t *tok, const char *str); - /* Is this a string equal to str of length len? */ bool json_tok_strneq(const char *buffer, const jsmntok_t *tok, const char *str, size_t len); +/* Is this a string equal to str? */ +static inline bool json_tok_streq(const char *buffer, const jsmntok_t *tok, + const char *str) +{ + return json_tok_strneq(buffer, tok, str, strlen(str)); +} + /* Does this string token start with prefix? */ bool json_tok_startswith(const char *buffer, const jsmntok_t *tok, const char *prefix); @@ -66,8 +70,12 @@ const jsmntok_t *json_get_membern(const char *buffer, const char *label, size_t len); /* Get top-level member. */ -const jsmntok_t *json_get_member(const char *buffer, const jsmntok_t tok[], - const char *label); +static inline const jsmntok_t *json_get_member(const char *buffer, + const jsmntok_t tok[], + const char *label) +{ + return json_get_membern(buffer, tok, label, strlen(label)); +} /* Get index'th array member. */ const jsmntok_t *json_get_arr(const jsmntok_t tok[], size_t index); diff --git a/plugins/bkpr/test/run-bkpr_db.c b/plugins/bkpr/test/run-bkpr_db.c index 10ba59aea78f..13801dcab638 100644 --- a/plugins/bkpr/test/run-bkpr_db.c +++ b/plugins/bkpr/test/run-bkpr_db.c @@ -112,10 +112,11 @@ bool is_asterix_notification(const char *notification_name UNNEEDED, const char *json_get_id(const tal_t *ctx UNNEEDED, const char *buffer UNNEEDED, const jsmntok_t *obj UNNEEDED) { fprintf(stderr, "json_get_id called!\n"); abort(); } -/* Generated stub for json_get_member */ -const jsmntok_t *json_get_member(const char *buffer UNNEEDED, const jsmntok_t tok[] UNNEEDED, - const char *label UNNEEDED) -{ fprintf(stderr, "json_get_member called!\n"); abort(); } +/* Generated stub for json_get_membern */ +const jsmntok_t *json_get_membern(const char *buffer UNNEEDED, + const jsmntok_t tok[] UNNEEDED, + const char *label UNNEEDED, size_t len UNNEEDED) +{ fprintf(stderr, "json_get_membern called!\n"); abort(); } /* Generated stub for json_next */ const jsmntok_t *json_next(const jsmntok_t *tok UNNEEDED) { fprintf(stderr, "json_next called!\n"); abort(); } @@ -194,9 +195,10 @@ int json_tok_full_len(const jsmntok_t *t UNNEEDED) void json_tok_remove(jsmntok_t **tokens UNNEEDED, jsmntok_t *obj_or_array UNNEEDED, const jsmntok_t *tok UNNEEDED, size_t num UNNEEDED) { fprintf(stderr, "json_tok_remove called!\n"); abort(); } -/* Generated stub for json_tok_streq */ -bool json_tok_streq(const char *buffer UNNEEDED, const jsmntok_t *tok UNNEEDED, const char *str UNNEEDED) -{ fprintf(stderr, "json_tok_streq called!\n"); abort(); } +/* Generated stub for json_tok_strneq */ +bool json_tok_strneq(const char *buffer UNNEEDED, const jsmntok_t *tok UNNEEDED, + const char *str UNNEEDED, size_t len UNNEEDED) +{ fprintf(stderr, "json_tok_strneq called!\n"); abort(); } /* Generated stub for last_fee_state */ enum htlc_state last_fee_state(enum side opener UNNEEDED) { fprintf(stderr, "last_fee_state called!\n"); abort(); } diff --git a/plugins/bkpr/test/run-recorder.c b/plugins/bkpr/test/run-recorder.c index 16cd8e9b7877..351d4d267f5a 100644 --- a/plugins/bkpr/test/run-recorder.c +++ b/plugins/bkpr/test/run-recorder.c @@ -118,10 +118,11 @@ bool is_asterix_notification(const char *notification_name UNNEEDED, const char *json_get_id(const tal_t *ctx UNNEEDED, const char *buffer UNNEEDED, const jsmntok_t *obj UNNEEDED) { fprintf(stderr, "json_get_id called!\n"); abort(); } -/* Generated stub for json_get_member */ -const jsmntok_t *json_get_member(const char *buffer UNNEEDED, const jsmntok_t tok[] UNNEEDED, - const char *label UNNEEDED) -{ fprintf(stderr, "json_get_member called!\n"); abort(); } +/* Generated stub for json_get_membern */ +const jsmntok_t *json_get_membern(const char *buffer UNNEEDED, + const jsmntok_t tok[] UNNEEDED, + const char *label UNNEEDED, size_t len UNNEEDED) +{ fprintf(stderr, "json_get_membern called!\n"); abort(); } /* Generated stub for json_next */ const jsmntok_t *json_next(const jsmntok_t *tok UNNEEDED) { fprintf(stderr, "json_next called!\n"); abort(); } @@ -200,9 +201,10 @@ int json_tok_full_len(const jsmntok_t *t UNNEEDED) void json_tok_remove(jsmntok_t **tokens UNNEEDED, jsmntok_t *obj_or_array UNNEEDED, const jsmntok_t *tok UNNEEDED, size_t num UNNEEDED) { fprintf(stderr, "json_tok_remove called!\n"); abort(); } -/* Generated stub for json_tok_streq */ -bool json_tok_streq(const char *buffer UNNEEDED, const jsmntok_t *tok UNNEEDED, const char *str UNNEEDED) -{ fprintf(stderr, "json_tok_streq called!\n"); abort(); } +/* Generated stub for json_tok_strneq */ +bool json_tok_strneq(const char *buffer UNNEEDED, const jsmntok_t *tok UNNEEDED, + const char *str UNNEEDED, size_t len UNNEEDED) +{ fprintf(stderr, "json_tok_strneq called!\n"); abort(); } /* Generated stub for last_fee_state */ enum htlc_state last_fee_state(enum side opener UNNEEDED) { fprintf(stderr, "last_fee_state called!\n"); abort(); } diff --git a/plugins/test/run-route-calc.c b/plugins/test/run-route-calc.c index a0bdda823448..85ac28fd3247 100644 --- a/plugins/test/run-route-calc.c +++ b/plugins/test/run-route-calc.c @@ -160,10 +160,11 @@ void json_array_end(struct json_stream *js UNNEEDED) /* Generated stub for json_array_start */ void json_array_start(struct json_stream *js UNNEEDED, const char *fieldname UNNEEDED) { fprintf(stderr, "json_array_start called!\n"); abort(); } -/* Generated stub for json_get_member */ -const jsmntok_t *json_get_member(const char *buffer UNNEEDED, const jsmntok_t tok[] UNNEEDED, - const char *label UNNEEDED) -{ fprintf(stderr, "json_get_member called!\n"); abort(); } +/* Generated stub for json_get_membern */ +const jsmntok_t *json_get_membern(const char *buffer UNNEEDED, + const jsmntok_t tok[] UNNEEDED, + const char *label UNNEEDED, size_t len UNNEEDED) +{ fprintf(stderr, "json_get_membern called!\n"); abort(); } /* Generated stub for json_next */ const jsmntok_t *json_next(const jsmntok_t *tok UNNEEDED) { fprintf(stderr, "json_next called!\n"); abort(); } @@ -245,9 +246,10 @@ const char *json_tok_full(const char *buffer UNNEEDED, const jsmntok_t *t UNNEED /* Generated stub for json_tok_full_len */ int json_tok_full_len(const jsmntok_t *t UNNEEDED) { fprintf(stderr, "json_tok_full_len called!\n"); abort(); } -/* Generated stub for json_tok_streq */ -bool json_tok_streq(const char *buffer UNNEEDED, const jsmntok_t *tok UNNEEDED, const char *str UNNEEDED) -{ fprintf(stderr, "json_tok_streq called!\n"); abort(); } +/* Generated stub for json_tok_strneq */ +bool json_tok_strneq(const char *buffer UNNEEDED, const jsmntok_t *tok UNNEEDED, + const char *str UNNEEDED, size_t len UNNEEDED) +{ fprintf(stderr, "json_tok_strneq called!\n"); abort(); } /* Generated stub for jsonrpc_request_start_ */ struct out_req *jsonrpc_request_start_(struct command *cmd UNNEEDED, const char *method UNNEEDED, diff --git a/plugins/test/run-route-overlong.c b/plugins/test/run-route-overlong.c index da6f0a607a03..9c6d24a228e4 100644 --- a/plugins/test/run-route-overlong.c +++ b/plugins/test/run-route-overlong.c @@ -157,10 +157,11 @@ void json_array_end(struct json_stream *js UNNEEDED) /* Generated stub for json_array_start */ void json_array_start(struct json_stream *js UNNEEDED, const char *fieldname UNNEEDED) { fprintf(stderr, "json_array_start called!\n"); abort(); } -/* Generated stub for json_get_member */ -const jsmntok_t *json_get_member(const char *buffer UNNEEDED, const jsmntok_t tok[] UNNEEDED, - const char *label UNNEEDED) -{ fprintf(stderr, "json_get_member called!\n"); abort(); } +/* Generated stub for json_get_membern */ +const jsmntok_t *json_get_membern(const char *buffer UNNEEDED, + const jsmntok_t tok[] UNNEEDED, + const char *label UNNEEDED, size_t len UNNEEDED) +{ fprintf(stderr, "json_get_membern called!\n"); abort(); } /* Generated stub for json_next */ const jsmntok_t *json_next(const jsmntok_t *tok UNNEEDED) { fprintf(stderr, "json_next called!\n"); abort(); } @@ -242,9 +243,10 @@ const char *json_tok_full(const char *buffer UNNEEDED, const jsmntok_t *t UNNEED /* Generated stub for json_tok_full_len */ int json_tok_full_len(const jsmntok_t *t UNNEEDED) { fprintf(stderr, "json_tok_full_len called!\n"); abort(); } -/* Generated stub for json_tok_streq */ -bool json_tok_streq(const char *buffer UNNEEDED, const jsmntok_t *tok UNNEEDED, const char *str UNNEEDED) -{ fprintf(stderr, "json_tok_streq called!\n"); abort(); } +/* Generated stub for json_tok_strneq */ +bool json_tok_strneq(const char *buffer UNNEEDED, const jsmntok_t *tok UNNEEDED, + const char *str UNNEEDED, size_t len UNNEEDED) +{ fprintf(stderr, "json_tok_strneq called!\n"); abort(); } /* Generated stub for jsonrpc_request_start_ */ struct out_req *jsonrpc_request_start_(struct command *cmd UNNEEDED, const char *method UNNEEDED, diff --git a/wallet/test/run-wallet.c b/wallet/test/run-wallet.c index 5787f640c25f..91c070d90f38 100644 --- a/wallet/test/run-wallet.c +++ b/wallet/test/run-wallet.c @@ -579,10 +579,11 @@ void json_array_end(struct json_stream *js UNNEEDED) /* Generated stub for json_array_start */ void json_array_start(struct json_stream *js UNNEEDED, const char *fieldname UNNEEDED) { fprintf(stderr, "json_array_start called!\n"); abort(); } -/* Generated stub for json_get_member */ -const jsmntok_t *json_get_member(const char *buffer UNNEEDED, const jsmntok_t tok[] UNNEEDED, - const char *label UNNEEDED) -{ fprintf(stderr, "json_get_member called!\n"); abort(); } +/* Generated stub for json_get_membern */ +const jsmntok_t *json_get_membern(const char *buffer UNNEEDED, + const jsmntok_t tok[] UNNEEDED, + const char *label UNNEEDED, size_t len UNNEEDED) +{ fprintf(stderr, "json_get_membern called!\n"); abort(); } /* Generated stub for json_next */ const jsmntok_t *json_next(const jsmntok_t *tok UNNEEDED) { fprintf(stderr, "json_next called!\n"); abort(); } @@ -636,9 +637,10 @@ bool json_tok_channel_id(const char *buffer UNNEEDED, const jsmntok_t *tok UNNEE /* Generated stub for json_tok_full */ const char *json_tok_full(const char *buffer UNNEEDED, const jsmntok_t *t UNNEEDED) { fprintf(stderr, "json_tok_full called!\n"); abort(); } -/* Generated stub for json_tok_streq */ -bool json_tok_streq(const char *buffer UNNEEDED, const jsmntok_t *tok UNNEEDED, const char *str UNNEEDED) -{ fprintf(stderr, "json_tok_streq called!\n"); abort(); } +/* Generated stub for json_tok_strneq */ +bool json_tok_strneq(const char *buffer UNNEEDED, const jsmntok_t *tok UNNEEDED, + const char *str UNNEEDED, size_t len UNNEEDED) +{ fprintf(stderr, "json_tok_strneq called!\n"); abort(); } /* Generated stub for kill_uncommitted_channel */ void kill_uncommitted_channel(struct uncommitted_channel *uc UNNEEDED, const char *why UNNEEDED)