Browse Source

MT#55283 add extra methods

Change-Id: If6aa0894c92b276b005d19a67f72bf59539354aa
pull/1848/head
Richard Fuchs 1 year ago
parent
commit
6c8a5ec99a
3 changed files with 16 additions and 7 deletions
  1. +7
    -7
      daemon/call_interfaces.c
  2. +6
    -0
      daemon/control_ng.c
  3. +3
    -0
      include/control_ng.h

+ 7
- 7
daemon/call_interfaces.c View File

@ -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, "to-tag", &totag);
ctx->parser->dict_get_str(input, "via-branch", &viabranch); 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) { if (flags) {
for (it = flags->child; it; it = it->sibling) { for (it = flags->child; it; it = it->sibling) {
if (!bencode_strcmp(it, "fatal"))
if (!ctx->parser->strcmp(it, "fatal"))
fatal = true; fatal = true;
else if (!bencode_strcmp(it, "discard-recording"))
else if (!ctx->parser->strcmp(it, "discard-recording"))
discard = true; 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) 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); call_t *c = call_get(&callid);
if (!c) 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 *input = ctx->req;
bencode_item_t *output = ctx->resp; 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) { if (limit < 0) {
return "invalid limit, must be >= 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]` // ... 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) { if (item) {
for (bencode_item_t *child = item->child; child; child = child->sibling) { for (bencode_item_t *child = item->child; child; child = child->sibling) {
if (bencode_strcmp(child, "pause") == 0) { if (bencode_strcmp(child, "pause") == 0) {


+ 6
- 0
daemon/control_ng.c View File

@ -145,12 +145,15 @@ const ng_parser_t ng_parser_native = {
.is_list = bencode_is_list, .is_list = bencode_is_list,
.list_iter = bencode_list_iter, .list_iter = bencode_list_iter,
.get_str = bencode_get_str, .get_str = bencode_get_str,
.strcmp = bencode_strcmp,
.get_int_str = bencode_get_integer_str, .get_int_str = bencode_get_integer_str,
.is_int = bencode_is_int, .is_int = bencode_is_int,
.get_int = bencode_get_int, .get_int = bencode_get_int,
.is_dict = bencode_is_dict, .is_dict = bencode_is_dict,
.dict = __bencode_dict, .dict = __bencode_dict,
.dict_get_str = bencode_dictionary_get_str, .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 = bencode_dictionary_add,
.dict_add_string = bencode_dictionary_add_string, .dict_add_string = bencode_dictionary_add_string,
.dict_add_str = bencode_dictionary_add_str, .dict_add_str = bencode_dictionary_add_str,
@ -170,12 +173,15 @@ const ng_parser_t ng_parser_json = {
.is_list = bencode_is_list, .is_list = bencode_is_list,
.list_iter = bencode_list_iter, .list_iter = bencode_list_iter,
.get_str = bencode_get_str, .get_str = bencode_get_str,
.strcmp = bencode_strcmp,
.get_int_str = bencode_get_integer_str, .get_int_str = bencode_get_integer_str,
.is_int = bencode_is_int, .is_int = bencode_is_int,
.get_int = bencode_get_int, .get_int = bencode_get_int,
.is_dict = bencode_is_dict, .is_dict = bencode_is_dict,
.dict = __bencode_dict, .dict = __bencode_dict,
.dict_get_str = bencode_dictionary_get_str, .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 = bencode_dictionary_add,
.dict_add_string = bencode_dictionary_add_string, .dict_add_string = bencode_dictionary_add_string,
.dict_add_str = bencode_dictionary_add_str, .dict_add_str = bencode_dictionary_add_str,


+ 3
- 0
include/control_ng.h View File

@ -122,12 +122,15 @@ struct ng_parser {
void (*item_callback)(ng_parser_ctx_t *, bencode_item_t *, helper_arg), void (*item_callback)(ng_parser_ctx_t *, bencode_item_t *, helper_arg),
helper_arg); helper_arg);
str *(*get_str)(bencode_item_t *, str *s); 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); long long (*get_int_str)(bencode_item_t *, long long def);
bool (*is_int)(bencode_item_t *); bool (*is_int)(bencode_item_t *);
long long (*get_int)(bencode_item_t *); long long (*get_int)(bencode_item_t *);
bool (*is_dict)(bencode_item_t *); bool (*is_dict)(bencode_item_t *);
bencode_item_t *(*dict)(ng_parser_ctx_t *); bencode_item_t *(*dict)(ng_parser_ctx_t *);
char *(*dict_get_str)(bencode_item_t *, const char *, str *); 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 *); 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_string)(bencode_item_t *, const char *, const char *);
void (*dict_add_str)(bencode_item_t *, const char *, const str *); void (*dict_add_str)(bencode_item_t *, const char *, const str *);


Loading…
Cancel
Save