diff --git a/daemon/call_interfaces.c b/daemon/call_interfaces.c index 0356539e5..4da60ebfd 100644 --- a/daemon/call_interfaces.c +++ b/daemon/call_interfaces.c @@ -2298,18 +2298,18 @@ const char *call_delete_ng(ng_parser_ctx_t *ctx) { ctx->parser->dict_get_str(input, "to-tag", &totag); ctx->parser->dict_get_str(input, "via-branch", &viabranch); - flags = bencode_dictionary_get_expect(input, "flags", BENCODE_LIST); + flags = ctx->parser->dict_get_expect(input, "flags", BENCODE_LIST); if (flags) { for (it = flags->child; it; it = it->sibling) { - if (!bencode_strcmp(it, "fatal")) + if (!ctx->parser->strcmp(it, "fatal")) fatal = true; - else if (!bencode_strcmp(it, "discard-recording")) + else if (!ctx->parser->strcmp(it, "discard-recording")) discard = true; } } - delete_delay = bencode_dictionary_get_int_str(input, "delete-delay", -1); + delete_delay = ctx->parser->dict_get_int_str(input, "delete-delay", -1); if (delete_delay == -1) - delete_delay = bencode_dictionary_get_int_str(input, "delete delay", -1); + delete_delay = ctx->parser->dict_get_int_str(input, "delete delay", -1); call_t *c = call_get(&callid); if (!c) @@ -2785,7 +2785,7 @@ const char *call_list_ng(ng_parser_ctx_t *ctx) { bencode_item_t *input = ctx->req; bencode_item_t *output = ctx->resp; - limit = bencode_dictionary_get_int_str(input, "limit", 32); + limit = ctx->parser->dict_get_int_str(input, "limit", 32); if (limit < 0) { return "invalid limit, must be >= 0"; @@ -2863,7 +2863,7 @@ static void stop_recording_fn(ng_parser_ctx_t *ctx, call_t *call) { } } // ... or `flags=[pause]` - bencode_item_t *item = bencode_dictionary_get_expect(input, "flags", BENCODE_LIST); + bencode_item_t *item = ctx->parser->dict_get_expect(input, "flags", BENCODE_LIST); if (item) { for (bencode_item_t *child = item->child; child; child = child->sibling) { if (bencode_strcmp(child, "pause") == 0) { diff --git a/daemon/control_ng.c b/daemon/control_ng.c index 179e36d2e..a0fdb12a9 100644 --- a/daemon/control_ng.c +++ b/daemon/control_ng.c @@ -145,12 +145,15 @@ const ng_parser_t ng_parser_native = { .is_list = bencode_is_list, .list_iter = bencode_list_iter, .get_str = bencode_get_str, + .strcmp = bencode_strcmp, .get_int_str = bencode_get_integer_str, .is_int = bencode_is_int, .get_int = bencode_get_int, .is_dict = bencode_is_dict, .dict = __bencode_dict, .dict_get_str = bencode_dictionary_get_str, + .dict_get_int_str = bencode_dictionary_get_int_str, + .dict_get_expect = bencode_dictionary_get_expect, .dict_add = bencode_dictionary_add, .dict_add_string = bencode_dictionary_add_string, .dict_add_str = bencode_dictionary_add_str, @@ -170,12 +173,15 @@ const ng_parser_t ng_parser_json = { .is_list = bencode_is_list, .list_iter = bencode_list_iter, .get_str = bencode_get_str, + .strcmp = bencode_strcmp, .get_int_str = bencode_get_integer_str, .is_int = bencode_is_int, .get_int = bencode_get_int, .is_dict = bencode_is_dict, .dict = __bencode_dict, .dict_get_str = bencode_dictionary_get_str, + .dict_get_int_str = bencode_dictionary_get_int_str, + .dict_get_expect = bencode_dictionary_get_expect, .dict_add = bencode_dictionary_add, .dict_add_string = bencode_dictionary_add_string, .dict_add_str = bencode_dictionary_add_str, diff --git a/include/control_ng.h b/include/control_ng.h index db0145057..aa7a35989 100644 --- a/include/control_ng.h +++ b/include/control_ng.h @@ -122,12 +122,15 @@ struct ng_parser { void (*item_callback)(ng_parser_ctx_t *, bencode_item_t *, helper_arg), helper_arg); str *(*get_str)(bencode_item_t *, str *s); + int (*strcmp)(bencode_item_t *, const char *); long long (*get_int_str)(bencode_item_t *, long long def); bool (*is_int)(bencode_item_t *); long long (*get_int)(bencode_item_t *); bool (*is_dict)(bencode_item_t *); bencode_item_t *(*dict)(ng_parser_ctx_t *); char *(*dict_get_str)(bencode_item_t *, const char *, str *); + long long (*dict_get_int_str)(bencode_item_t *, const char *, long long def); + bencode_item_t *(*dict_get_expect)(bencode_item_t *, const char *, bencode_type_t); 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 *);