]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
[Core] SWITCH_STACK_NODUP flag is deprecated and will be soon removed. Introduce... 1856/head
authorAndrey Volk <andywolk@gmail.com>
Mon, 31 Oct 2022 14:49:17 +0000 (17:49 +0300)
committerAndrey Volk <andywolk@gmail.com>
Mon, 7 Nov 2022 22:17:08 +0000 (01:17 +0300)
src/include/switch_event.h
src/mod/event_handlers/mod_erlang_event/handle_msg.c
src/mod/event_handlers/mod_kazoo/kazoo_cdr.c
src/mod/event_handlers/mod_kazoo/kazoo_node.c
src/switch_core.c
src/switch_event.c

index f2ac381ee84a79738ecdf99dbed825b49c8132d2..10841f469c70308091cbfafad9edbec5317d41ad 100644 (file)
@@ -206,6 +206,7 @@ SWITCH_DECLARE(switch_status_t) switch_event_set_subclass_name(switch_event_t *e
   \return SWITCH_STATUS_SUCCESS if the header was added
 */
 SWITCH_DECLARE(switch_status_t) switch_event_add_header_string(switch_event_t *event, switch_stack_t stack, const char *header_name, const char *data);
+SWITCH_DECLARE(switch_status_t) switch_event_add_header_string_nodup(switch_event_t *event, switch_stack_t stack, const char *header_name, const char *data);
 
 SWITCH_DECLARE(switch_status_t) switch_event_del_header_val(switch_event_t *event, const char *header_name, const char *val);
 #define switch_event_del_header(_e, _h) switch_event_del_header_val(_e, _h, NULL)
index 292134d716ddf3d54154d00047e8eb9e5fb14652..aad45a4986114ae9bfaf964d061fc8f6c3630422 100644 (file)
@@ -836,7 +836,7 @@ static switch_status_t handle_msg_sendevent(listener_t *listener, int arity, ei_
                                                switch_safe_free(event->body);
                                                event->body = value;
                                        } else if (!fail)  {
-                                               switch_event_add_header_string(event, SWITCH_STACK_BOTTOM | SWITCH_STACK_NODUP, key, value);
+                                               switch_event_add_header_string_nodup(event, SWITCH_STACK_BOTTOM, key, value);
                                        }
 
                                        /* Do not free malloc here! The above commands utilize the raw allocated memory and skip any copying/duplication. Faster. */
@@ -901,7 +901,7 @@ static switch_status_t handle_msg_sendmsg(listener_t *listener, int arity, ei_x_
                                        }
 
                                        if (!fail) {
-                                               switch_event_add_header_string(event, SWITCH_STACK_BOTTOM | SWITCH_STACK_NODUP, key, value);
+                                               switch_event_add_header_string_nodup(event, SWITCH_STACK_BOTTOM, key, value);
                                        }
                                }
 
index f7b0d53df617e4fd72998332de11d6eebfb72aec..fef66f8be3427681f97103f8c98a6a0fd2658236 100644 (file)
@@ -196,7 +196,7 @@ static switch_status_t kz_report_channel_flaws(switch_core_session_t *session, s
        kz_switch_ivr_set_json_call_flaws(callStats, session, SWITCH_MEDIA_TYPE_AUDIO);
        kz_switch_ivr_set_json_call_flaws(callStats, session, SWITCH_MEDIA_TYPE_VIDEO);
 
-       switch_event_add_header_string(cdr_event, SWITCH_STACK_BOTTOM | SWITCH_STACK_NODUP, "_json_channel_media_errors", cJSON_PrintUnformatted(callStats));
+       switch_event_add_header_string_nodup(cdr_event, SWITCH_STACK_BOTTOM, "_json_channel_media_errors", cJSON_PrintUnformatted(callStats));
 
        cJSON_Delete(callStats);
 
@@ -210,7 +210,7 @@ static switch_status_t kz_report_channel_stats(switch_core_session_t *session, s
        kz_switch_ivr_set_json_call_stats(callStats, session, SWITCH_MEDIA_TYPE_AUDIO);
        kz_switch_ivr_set_json_call_stats(callStats, session, SWITCH_MEDIA_TYPE_VIDEO);
 
-       switch_event_add_header_string(cdr_event, SWITCH_STACK_BOTTOM | SWITCH_STACK_NODUP, "_json_channel_stats", cJSON_PrintUnformatted(callStats));
+       switch_event_add_header_string_nodup(cdr_event, SWITCH_STACK_BOTTOM, "_json_channel_stats", cJSON_PrintUnformatted(callStats));
 
        cJSON_Delete(callStats);
 
@@ -237,7 +237,7 @@ static switch_status_t kz_report_app_log(switch_core_session_t *session, switch_
                cJSON_AddItemToArray(j_apps, j_application);
        }
 
-       switch_event_add_header_string(cdr_event, SWITCH_STACK_BOTTOM | SWITCH_STACK_NODUP, "_json_application_log", cJSON_PrintUnformatted(j_apps));
+       switch_event_add_header_string_nodup(cdr_event, SWITCH_STACK_BOTTOM, "_json_application_log", cJSON_PrintUnformatted(j_apps));
 
        cJSON_Delete(j_apps);
 
@@ -381,7 +381,7 @@ static switch_status_t kz_report_callflow(switch_core_session_t *session, switch
                caller_profile = caller_profile->next;
        }
 
-       switch_event_add_header_string(cdr_event, SWITCH_STACK_BOTTOM | SWITCH_STACK_NODUP, "_json_callflow", cJSON_PrintUnformatted(j_callflow));
+       switch_event_add_header_string_nodup(cdr_event, SWITCH_STACK_BOTTOM, "_json_callflow", cJSON_PrintUnformatted(j_callflow));
 
        cJSON_Delete(j_callflow);
 
@@ -435,7 +435,7 @@ static switch_status_t kz_report_originated_legs(switch_core_session_t *session,
                idx++;
        }
 
-       switch_event_add_header_string(cdr_event, SWITCH_STACK_BOTTOM | SWITCH_STACK_NODUP, "_json_originated_legs", cJSON_PrintUnformatted(j_originated));
+       switch_event_add_header_string_nodup(cdr_event, SWITCH_STACK_BOTTOM, "_json_originated_legs", cJSON_PrintUnformatted(j_originated));
 
        cJSON_Delete(j_originated);
 
@@ -526,10 +526,10 @@ static switch_status_t kz_report_transfer_history(switch_core_session_t *session
                for(n=0; n < argc; n++) {
                        kz_report_transfer_history_item(argv[n], j_transfer);
                }
-               switch_event_add_header_string(cdr_event, SWITCH_STACK_BOTTOM | SWITCH_STACK_NODUP, event_header, cJSON_PrintUnformatted(j_transfer));
+               switch_event_add_header_string_nodup(cdr_event, SWITCH_STACK_BOTTOM, event_header, cJSON_PrintUnformatted(j_transfer));
        } else if (strchr(history, HST_ITEM_DELIM)) {
                kz_report_transfer_history_item(history, j_transfer);
-               switch_event_add_header_string(cdr_event, SWITCH_STACK_BOTTOM | SWITCH_STACK_NODUP, event_header, cJSON_PrintUnformatted(j_transfer));
+               switch_event_add_header_string_nodup(cdr_event, SWITCH_STACK_BOTTOM, event_header, cJSON_PrintUnformatted(j_transfer));
        }
        cJSON_Delete(j_transfer);
        switch_safe_free(tmp_history);
index fae09bee2fbc851478bd0b56e6626d8a5b537849..feb8970a86411ebee9c9d1d193e0b5196c173d8b 100644 (file)
@@ -512,7 +512,7 @@ static switch_status_t build_event(switch_event_t *event, ei_x_buff * buf) {
                                        }
                                }
                        }
-                       switch_event_add_header_string(event, SWITCH_STACK_BOTTOM | SWITCH_STACK_NODUP, key, value);
+                       switch_event_add_header_string_nodup(event, SWITCH_STACK_BOTTOM, key, value);
                }
                n++;
        }
index b9b92f40c77c73354f64a86a12f3a47ea6b50718..83db2fc0d9c7c39237687603bc65d890d4ca9d85 100644 (file)
@@ -482,7 +482,7 @@ SWITCH_DECLARE(switch_bool_t) switch_core_set_var_conditional(const char *varnam
                if (value) {
                        char *v = strdup(value);
                        switch_string_var_check(v, SWITCH_TRUE);
-                       switch_event_add_header_string(runtime.global_vars, SWITCH_STACK_BOTTOM | SWITCH_STACK_NODUP, varname, v);
+                       switch_event_add_header_string_nodup(runtime.global_vars, SWITCH_STACK_BOTTOM, varname, v);
                } else {
                        switch_event_del_header(runtime.global_vars, varname);
                }
index 4cc60fa60c0f6cc9e85a93588952701f490427b1..a8ba532d19acb96bd524ab504a96eb1948b7dd03 100644 (file)
@@ -1235,6 +1235,14 @@ SWITCH_DECLARE(switch_status_t) switch_event_set_subclass_name(switch_event_t *e
        return SWITCH_STATUS_SUCCESS;
 }
 
+SWITCH_DECLARE(switch_status_t) switch_event_add_header_string_nodup(switch_event_t *event, switch_stack_t stack, const char *header_name, const char *data)
+{
+       if (data) {
+               return switch_event_base_add_header(event, stack, header_name, (char *)data);
+       }
+       return SWITCH_STATUS_GENERR;
+}
+
 SWITCH_DECLARE(switch_status_t) switch_event_add_header_string(switch_event_t *event, switch_stack_t stack, const char *header_name, const char *data)
 {
        if (data) {