MT#55283 add abstract .dict_add_str_dup

Change-Id: I8b5e34379e49819f5050e3460e4398706fe20749
pull/1848/head
Richard Fuchs 1 year ago
parent 8f6b8b206b
commit b1a0aebab5

@ -2353,7 +2353,7 @@ static void ng_stats_endpoint(const ng_parser_t *parser, bencode_item_t *dict, c
if (!ep->address.family)
return;
parser->dict_add_string(dict, "family", ep->address.family->name);
bencode_dictionary_add_str_dup(dict, "address", &STR(sockaddr_print_buf(&ep->address)));
parser->dict_add_str_dup(dict, "address", &STR(sockaddr_print_buf(&ep->address)));
parser->dict_add_int(dict, "port", ep->port);
}
@ -2393,7 +2393,7 @@ static void ng_stats_stream(const ng_parser_t *parser, bencode_item_t *list, con
if (ps->selected_sfd) {
parser->dict_add_int(dict, "local port", ps->selected_sfd->socket.local.port);
bencode_dictionary_add_str_dup(dict, "local address",
parser->dict_add_str_dup(dict, "local address",
&STR(sockaddr_print_buf(&ps->selected_sfd->socket.local.address)));
parser->dict_add_string(dict, "family", ps->selected_sfd->socket.local.address.family->name);
}
@ -2457,7 +2457,7 @@ static void ng_stats_media(const ng_parser_t *parser, bencode_item_t *list, cons
if (m->protocol)
parser->dict_add_string(dict, "protocol", m->protocol->name);
if (rtp_pt)
bencode_dictionary_add_str_dup(dict, "codec", &rtp_pt->encoding_with_params);
parser->dict_add_str_dup(dict, "codec", &rtp_pt->encoding_with_params);
streams = parser->dict_add_list(dict, "streams");
@ -3754,7 +3754,7 @@ const char *call_subscribe_request_ng(ng_parser_ctx_t *ctx) {
if (srms.length == 1) {
struct media_subscription *ms = srms.head->data;
struct call_monologue *source_ml = ms->monologue;
bencode_dictionary_add_str_dup(output, "from-tag", &source_ml->tag);
ctx->parser->dict_add_str_dup(output, "from-tag", &source_ml->tag);
}
bencode_item_t *tag_medias = NULL, *media_labels = NULL;
if (flags.siprec) {
@ -3796,7 +3796,7 @@ const char *call_subscribe_request_ng(ng_parser_ctx_t *ctx) {
}
}
bencode_dictionary_add_str_dup(output, "to-tag", &dest_ml->tag);
ctx->parser->dict_add_str_dup(output, "to-tag", &dest_ml->tag);
dequeue_sdp_fragments(dest_ml);

@ -148,6 +148,7 @@ const ng_parser_t ng_parser_native = {
.dict_add = bencode_dictionary_add,
.dict_add_string = bencode_dictionary_add_string,
.dict_add_str = bencode_dictionary_add_str,
.dict_add_str_dup = bencode_dictionary_add_str_dup,
.dict_add_int = bencode_dictionary_add_integer,
.dict_add_dict = bencode_dictionary_add_dictionary,
.dict_add_list = bencode_dictionary_add_list,
@ -170,6 +171,7 @@ const ng_parser_t ng_parser_json = {
.dict_add = bencode_dictionary_add,
.dict_add_string = bencode_dictionary_add_string,
.dict_add_str = bencode_dictionary_add_str,
.dict_add_str_dup = bencode_dictionary_add_str_dup,
.dict_add_int = bencode_dictionary_add_integer,
.dict_add_dict = bencode_dictionary_add_dictionary,
.dict_add_list = bencode_dictionary_add_list,

@ -971,10 +971,10 @@ const char *statistics_ng(ng_parser_ctx_t *ctx) {
ctx->parser->dict_add_int(dict, bencode_strdup(buf, m->label),
m->int_value);
else if (m->value_raw)
bencode_dictionary_add_str_dup(dict, bencode_strdup(buf, m->label),
ctx->parser->dict_add_str_dup(dict, bencode_strdup(buf, m->label),
&STR(m->value_raw));
else
bencode_dictionary_add_str_dup(dict, bencode_strdup(buf, m->label),
ctx->parser->dict_add_str_dup(dict, bencode_strdup(buf, m->label),
&STR(m->value_short));
continue;
}

@ -126,6 +126,7 @@ struct ng_parser {
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_str_dup)(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 *);

Loading…
Cancel
Save