Browse Source

MT#55283 add abstract .dict_add_str_dup

Change-Id: I8b5e34379e49819f5050e3460e4398706fe20749
pull/1848/head
Richard Fuchs 1 year ago
parent
commit
b1a0aebab5
4 changed files with 10 additions and 7 deletions
  1. +5
    -5
      daemon/call_interfaces.c
  2. +2
    -0
      daemon/control_ng.c
  3. +2
    -2
      daemon/statistics.c
  4. +1
    -0
      include/control_ng.h

+ 5
- 5
daemon/call_interfaces.c View File

@ -2353,7 +2353,7 @@ static void ng_stats_endpoint(const ng_parser_t *parser, bencode_item_t *dict, c
if (!ep->address.family) if (!ep->address.family)
return; return;
parser->dict_add_string(dict, "family", ep->address.family->name); 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); 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) { if (ps->selected_sfd) {
parser->dict_add_int(dict, "local port", ps->selected_sfd->socket.local.port); 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))); &STR(sockaddr_print_buf(&ps->selected_sfd->socket.local.address)));
parser->dict_add_string(dict, "family", ps->selected_sfd->socket.local.address.family->name); 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) if (m->protocol)
parser->dict_add_string(dict, "protocol", m->protocol->name); parser->dict_add_string(dict, "protocol", m->protocol->name);
if (rtp_pt) 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"); 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) { if (srms.length == 1) {
struct media_subscription *ms = srms.head->data; struct media_subscription *ms = srms.head->data;
struct call_monologue *source_ml = ms->monologue; 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; bencode_item_t *tag_medias = NULL, *media_labels = NULL;
if (flags.siprec) { 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); dequeue_sdp_fragments(dest_ml);


+ 2
- 0
daemon/control_ng.c View File

@ -148,6 +148,7 @@ const ng_parser_t ng_parser_native = {
.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,
.dict_add_str_dup = bencode_dictionary_add_str_dup,
.dict_add_int = bencode_dictionary_add_integer, .dict_add_int = bencode_dictionary_add_integer,
.dict_add_dict = bencode_dictionary_add_dictionary, .dict_add_dict = bencode_dictionary_add_dictionary,
.dict_add_list = bencode_dictionary_add_list, .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 = 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,
.dict_add_str_dup = bencode_dictionary_add_str_dup,
.dict_add_int = bencode_dictionary_add_integer, .dict_add_int = bencode_dictionary_add_integer,
.dict_add_dict = bencode_dictionary_add_dictionary, .dict_add_dict = bencode_dictionary_add_dictionary,
.dict_add_list = bencode_dictionary_add_list, .dict_add_list = bencode_dictionary_add_list,


+ 2
- 2
daemon/statistics.c View File

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


+ 1
- 0
include/control_ng.h View File

@ -126,6 +126,7 @@ struct ng_parser {
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 *);
void (*dict_add_str_dup)(bencode_item_t *, const char *, const str *);
void (*dict_add_int)(bencode_item_t *, const char *, long long); 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_dict)(bencode_item_t *, const char *);
bencode_item_t *(*dict_add_list)(bencode_item_t *, const char *); bencode_item_t *(*dict_add_list)(bencode_item_t *, const char *);


Loading…
Cancel
Save