diff --git a/daemon/control_ng.c b/daemon/control_ng.c index 14bc6b322..1752428e9 100644 --- a/daemon/control_ng.c +++ b/daemon/control_ng.c @@ -130,6 +130,9 @@ static long long bencode_get_int(bencode_item_t *arg) { static bencode_item_t *__bencode_dict(ng_parser_ctx_t *ctx) { return bencode_dictionary(&ctx->ngbuf->buffer); } +static bencode_item_t *__bencode_list(ng_parser_ctx_t *ctx) { + return bencode_list(&ctx->ngbuf->buffer); +} const ng_parser_t ng_parser_native = { .collapse = bencode_collapse_str, @@ -142,11 +145,14 @@ const ng_parser_t ng_parser_native = { .get_int = bencode_get_int, .dict = __bencode_dict, .dict_get_str = bencode_dictionary_get_str, + .dict_add = bencode_dictionary_add, .dict_add_string = bencode_dictionary_add_string, .dict_add_str = bencode_dictionary_add_str, .dict_add_int = bencode_dictionary_add_integer, .dict_add_dict = bencode_dictionary_add_dictionary, .dict_add_list = bencode_dictionary_add_list, + .list = __bencode_list, + .list_add = bencode_list_add, .list_add_dict = bencode_list_add_dictionary, .list_add_string = bencode_list_add_string, }; @@ -161,11 +167,14 @@ const ng_parser_t ng_parser_json = { .get_int = bencode_get_int, .dict = __bencode_dict, .dict_get_str = bencode_dictionary_get_str, + .dict_add = bencode_dictionary_add, .dict_add_string = bencode_dictionary_add_string, .dict_add_str = bencode_dictionary_add_str, .dict_add_int = bencode_dictionary_add_integer, .dict_add_dict = bencode_dictionary_add_dictionary, .dict_add_list = bencode_dictionary_add_list, + .list = __bencode_list, + .list_add = bencode_list_add, .list_add_dict = bencode_list_add_dictionary, .list_add_string = bencode_list_add_string, }; diff --git a/daemon/statistics.c b/daemon/statistics.c index 613a6e488..dd6d81f37 100644 --- a/daemon/statistics.c +++ b/daemon/statistics.c @@ -998,17 +998,17 @@ const char *statistics_ng(ng_parser_ctx_t *ctx) { if (m->is_brace) sub = ctx->parser->dict(ctx); else - sub = bencode_list(buf); + sub = ctx->parser->list(ctx); assert(sub != NULL); // is this a dictionary? if (dict->type == BENCODE_DICTIONARY) { assert(sub_label != NULL); - bencode_dictionary_add(dict, bencode_strdup(buf, sub_label), sub); + ctx->parser->dict_add(dict, bencode_strdup(buf, sub_label), sub); } else if (ctx->parser->is_list(dict)) - bencode_list_add(dict, sub); + ctx->parser->list_add(dict, sub); else abort(); diff --git a/include/control_ng.h b/include/control_ng.h index 15766e7f0..b814a097f 100644 --- a/include/control_ng.h +++ b/include/control_ng.h @@ -123,11 +123,14 @@ struct ng_parser { long long (*get_int)(bencode_item_t *); bencode_item_t *(*dict)(ng_parser_ctx_t *); char *(*dict_get_str)(bencode_item_t *, const char *, str *); + bencode_item_t *(*dict_add)(bencode_item_t *, const char *, bencode_item_t *); void (*dict_add_string)(bencode_item_t *, const char *, const char *); void (*dict_add_str)(bencode_item_t *, const char *, const str *); void (*dict_add_int)(bencode_item_t *, const char *, long long); bencode_item_t *(*dict_add_dict)(bencode_item_t *, const char *); bencode_item_t *(*dict_add_list)(bencode_item_t *, const char *); + bencode_item_t *(*list)(ng_parser_ctx_t *); + bencode_item_t *(*list_add)(bencode_item_t *, bencode_item_t *); bencode_item_t *(*list_add_dict)(bencode_item_t *); void (*list_add_string)(bencode_item_t *, const char *); };