From d007d9733a749cd7febe47a4e78083b20051953b Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Fri, 26 Jul 2024 11:11:50 -0400 Subject: [PATCH] MT#55283 add is_int() method Change-Id: Ibcb1d1be415e85967eb5f3f87b91d79fa78eb4bb --- daemon/control_ng.c | 5 +++++ include/control_ng.h | 1 + 2 files changed, 6 insertions(+) diff --git a/daemon/control_ng.c b/daemon/control_ng.c index 8ae15c2a1..dcb3fb0fe 100644 --- a/daemon/control_ng.c +++ b/daemon/control_ng.c @@ -101,6 +101,9 @@ static void bencode_dict_iter(ng_parser_ctx_t *ctx, bencode_item_t *input, static bool bencode_is_list(bencode_item_t *arg) { return arg->type == BENCODE_LIST; } +static bool bencode_is_int(bencode_item_t *arg) { + return arg->type == BENCODE_INTEGER; +} static void bencode_list_iter(ng_parser_ctx_t *ctx, bencode_item_t *list, void (*str_callback)(ng_parser_ctx_t *, str *key, helper_arg), void (*item_callback)(ng_parser_ctx_t *, bencode_item_t *, helper_arg), @@ -126,6 +129,7 @@ const ng_parser_t ng_parser_native = { .list_iter = bencode_list_iter, .get_str = bencode_get_str, .get_int_str = bencode_get_integer_str, + .is_int = bencode_is_int, }; const ng_parser_t ng_parser_json = { .collapse = bencode_collapse_str_json, @@ -134,6 +138,7 @@ const ng_parser_t ng_parser_json = { .list_iter = bencode_list_iter, .get_str = bencode_get_str, .get_int_str = bencode_get_integer_str, + .is_int = bencode_is_int, }; diff --git a/include/control_ng.h b/include/control_ng.h index 12f19401b..29fe3809b 100644 --- a/include/control_ng.h +++ b/include/control_ng.h @@ -116,6 +116,7 @@ struct ng_parser { helper_arg); str *(*get_str)(bencode_item_t *, str *s); long long (*get_int_str)(bencode_item_t *, long long def); + bool (*is_int)(bencode_item_t *); }; struct ng_parser_ctx { const ng_parser_t *parser;