Browse Source

MT#55283 add is_int() method

Change-Id: Ibcb1d1be415e85967eb5f3f87b91d79fa78eb4bb
pull/1848/head
Richard Fuchs 1 year ago
parent
commit
d007d9733a
2 changed files with 6 additions and 0 deletions
  1. +5
    -0
      daemon/control_ng.c
  2. +1
    -0
      include/control_ng.h

+ 5
- 0
daemon/control_ng.c View File

@ -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,
};


+ 1
- 0
include/control_ng.h View File

@ -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;


Loading…
Cancel
Save