Collaboration diagram for Eventing Engine:
Data Structures | |
| struct | switch_event_header |
| An event Header. More... | |
| struct | switch_event |
| Representation of an event. More... | |
Defines | |
| #define | SWITCH_EVENT_SUBCLASS_ANY NULL |
| #define | switch_event_create_subclass(_e, _eid, _sn) switch_event_create_subclass_detailed(__FILE__, (const char * )__SWITCH_FUNC__, __LINE__, _e, _eid, _sn) |
| #define | switch_event_get_header(_e, _h) switch_event_get_header_idx(_e, _h, -1) |
| #define | switch_event_get_header_nil(e, h) switch_str_nil(switch_event_get_header(e,h)) |
| #define | switch_event_del_header(_e, _h) switch_event_del_header_val(_e, _h, NULL) |
| #define | switch_event_safe_destroy(_event) if (_event) switch_event_destroy(_event) |
| #define | switch_event_prep_for_delivery(_event) switch_event_prep_for_delivery_detailed(__FILE__, (const char * )__SWITCH_FUNC__, __LINE__, _event) |
| #define | switch_event_expand_headers(_event, _in) switch_event_expand_headers_check(_event, _in, NULL, NULL, 0) |
| #define | switch_event_create_pres_in(event) |
| #define | switch_event_reserve_subclass(subclass_name) switch_event_reserve_subclass_detailed(__FILE__, subclass_name) |
| Reserve a subclass assuming the owner string is the current filename. | |
| #define | switch_event_free_subclass(subclass_name) switch_event_free_subclass_detailed(__FILE__, subclass_name) |
| #define | switch_event_create(event, id) switch_event_create_subclass(event, id, SWITCH_EVENT_SUBCLASS_ANY) |
| Create a new event assuming it will not be custom event and therefore hiding the unused parameters. | |
| #define | switch_event_fire(event) switch_event_fire_detailed(__FILE__, (const char * )__SWITCH_FUNC__, __LINE__, event, NULL) |
| Fire an event filling in most of the arguements with obvious values. | |
| #define | switch_event_fire_data(event, data) switch_event_fire_detailed(__FILE__, (const char * )__SWITCH_FUNC__, __LINE__, event, data) |
| Fire an event filling in most of the arguements with obvious values and allowing user_data to be sent. | |
Enumerations | |
| enum | switch_event_flag_t { EF_UNIQ_HEADERS = (1 << 0), EF_NO_CHAT_EXEC = (1 << 1), EF_DEFAULT_ALLOW = (1 << 2) } |
Functions | |
| switch_status_t | switch_event_init (switch_memory_pool_t *pool) |
| Start the eventing system. | |
| switch_status_t | switch_event_shutdown (void) |
| Stop the eventing system. | |
| switch_status_t | switch_event_create_subclass_detailed (const char *file, const char *func, int line, switch_event_t **event, switch_event_types_t event_id, const char *subclass_name) |
| Create an event. | |
| switch_status_t | switch_event_set_priority (switch_event_t *event, switch_priority_t priority) |
| Set the priority of an event. | |
| switch_event_header_t * | switch_event_get_header_ptr (switch_event_t *event, const char *header_name) |
| Retrieve a header value from an event. | |
| _Ret_opt_z_ char * | switch_event_get_header_idx (switch_event_t *event, const char *header_name, int idx) |
| switch_status_t | switch_event_rename_header (switch_event_t *event, const char *header_name, const char *new_header_name) |
| char * | switch_event_get_body (switch_event_t *event) |
| Retrieve the body value from an event. | |
| switch_status_t | switch_event_add_header (switch_event_t *event, switch_stack_t stack, const char *header_name, const char *fmt,...) PRINTF_FUNCTION(4 |
| Add a header to an event. | |
| switch_status_t switch_status_t | switch_event_set_subclass_name (switch_event_t *event, const char *subclass_name) |
| switch_status_t | switch_event_add_header_string (switch_event_t *event, switch_stack_t stack, const char *header_name, const char *data) |
| Add a string header to an event. | |
| switch_status_t | switch_event_del_header_val (switch_event_t *event, const char *header_name, const char *val) |
| int | switch_event_add_array (switch_event_t *event, const char *var, const char *val) |
| void | switch_event_destroy (switch_event_t **event) |
| Destroy an event. | |
| switch_status_t | switch_event_dup (switch_event_t **event, switch_event_t *todup) |
| Duplicate an event. | |
| void | switch_event_merge (switch_event_t *event, switch_event_t *tomerge) |
| switch_status_t | switch_event_dup_reply (switch_event_t **event, switch_event_t *todup) |
| switch_status_t | switch_event_fire_detailed (const char *file, const char *func, int line, switch_event_t **event, void *user_data) |
| Fire an event with full arguement list. | |
| void | switch_event_prep_for_delivery_detailed (const char *file, const char *func, int line, switch_event_t *event) |
| switch_status_t | switch_event_bind (const char *id, switch_event_types_t event, const char *subclass_name, switch_event_callback_t callback, void *user_data) |
| Bind an event callback to a specific event. | |
| switch_status_t | switch_event_bind_removable (const char *id, switch_event_types_t event, const char *subclass_name, switch_event_callback_t callback, void *user_data, switch_event_node_t **node) |
| Bind an event callback to a specific event. | |
| switch_status_t | switch_event_unbind (switch_event_node_t **node) |
| Unbind a bound event consumer. | |
| switch_status_t | switch_event_unbind_callback (switch_event_callback_t callback) |
| const char * | switch_event_name (switch_event_types_t event) |
| Render the name of an event id enumeration. | |
| switch_status_t | switch_name_event (const char *name, switch_event_types_t *type) |
| return the event id that matches a given event name | |
| switch_status_t | switch_event_reserve_subclass_detailed (const char *owner, const char *subclass_name) |
| Reserve a subclass name for private use with a custom event. | |
| switch_status_t | switch_event_free_subclass_detailed (const char *owner, const char *subclass_name) |
| switch_status_t | switch_event_serialize (switch_event_t *event, char **str, switch_bool_t encode) |
| Render a string representation of an event sutable for printing or network transport. | |
| switch_status_t | switch_event_serialize_json (switch_event_t *event, char **str) |
| switch_status_t | switch_event_create_json (switch_event_t **event, const char *json) |
| switch_status_t | switch_event_create_brackets (char *data, char a, char b, char c, switch_event_t **event, char **new_data, switch_bool_t dup) |
| switch_xml_t | switch_event_xmlize (switch_event_t *event, const char *fmt,...) PRINTF_FUNCTION(2 |
| Render a XML representation of an event sutable for printing or network transport. | |
| switch_xml_t switch_status_t | switch_event_running (void) |
| Determine if the event system has been initilized. | |
| switch_status_t | switch_event_add_body (switch_event_t *event, const char *fmt,...) PRINTF_FUNCTION(2 |
| Add a body to an event. | |
| switch_status_t switch_status_t | switch_event_set_body (switch_event_t *event, const char *body) |
| char * | switch_event_expand_headers_check (switch_event_t *event, const char *in, switch_event_t *var_list, switch_event_t *api_list, uint32_t recur) |
| switch_status_t | switch_event_create_pres_in_detailed (_In_z_ char *file, _In_z_ char *func, _In_ int line, _In_z_ const char *proto, _In_z_ const char *login, _In_z_ const char *from, _In_z_ const char *from_domain, _In_z_ const char *status, _In_z_ const char *event_type, _In_z_ const char *alt_event_type, _In_ int event_count, _In_z_ const char *unique_id, _In_z_ const char *channel_state, _In_z_ const char *answer_state, _In_z_ const char *call_direction) |
| static switch_status_t | switch_event_create_plain (switch_event_t **event, switch_event_types_t event_id) |
| void | switch_event_deliver (switch_event_t **event) |
| Deliver an event to all of the registered event listeners. | |
| char * | switch_event_build_param_string (switch_event_t *event, const char *prefix, switch_hash_t *vars_map) |
| int | switch_event_check_permission_list (switch_event_t *list, const char *name) |
| void | switch_event_add_presence_data_cols (switch_channel_t *channel, switch_event_t *event, const char *prefix) |
| #define switch_event_create | ( | event, | |||
| id | ) | switch_event_create_subclass(event, id, SWITCH_EVENT_SUBCLASS_ANY) |
Create a new event assuming it will not be custom event and therefore hiding the unused parameters.
| event | a NULL pointer on which to create the event | |
| id | the event id enumeration of the desired event |
Definition at line 363 of file switch_event.h.
Referenced by __switch_xml_open_root(), check_ip(), generate_on_dtmf(), handle_SIGHUP(), hanguphook(), record_callback(), rtp_common_write(), send_heartbeat(), signal_bridge_on_hangup(), signal_bridge_on_hibernate(), speech_thread(), switch_api_execute(), switch_channel_dequeue_dtmf(), switch_channel_flip_cid(), switch_channel_mark_hold(), switch_channel_perform_hangup(), switch_channel_perform_mark_answered(), switch_channel_perform_mark_pre_answered(), switch_channel_perform_mark_ring_ready_value(), switch_channel_perform_presence(), switch_channel_perform_set_callstate(), switch_console_printf(), switch_core_chat_send_args(), switch_core_destroy(), switch_core_init_and_modload(), switch_core_media_bug_add(), switch_core_media_bug_destroy(), switch_core_session_exec(), switch_core_session_execute_application_async(), switch_core_session_outgoing_channel(), switch_core_session_perform_destroy(), switch_core_session_reporting_state(), switch_core_session_run(), switch_core_session_set_read_codec(), switch_core_session_set_real_read_codec(), switch_core_session_set_uuid(), switch_core_session_set_video_read_codec(), switch_core_session_set_video_write_codec(), switch_core_session_set_write_codec(), switch_core_session_thread(), switch_event_create_json(), switch_event_create_plain(), switch_event_import_xml(), switch_ivr_broadcast(), switch_ivr_check_presence_mapping(), switch_ivr_multi_threaded_bridge(), switch_ivr_park(), switch_ivr_phrase_macro_event(), switch_ivr_play_file(), switch_ivr_record_file(), switch_ivr_say(), switch_ivr_say_string(), switch_ivr_signal_bridge(), switch_load_network_lists(), switch_loadable_module_process(), switch_loadable_module_unprocess(), switch_log_vprintf(), switch_nat_add_mapping_internal(), switch_nat_del_mapping(), switch_nat_multicast_runtime(), switch_rtp_add_crypto_key(), switch_scheduler_add_task(), switch_scheduler_del_task_group(), switch_scheduler_del_task_id(), switch_scheduler_execute(), SWITCH_STANDARD_SCHED_FUNC(), switch_xml_locate_domain(), switch_xml_locate_group(), switch_xml_locate_user(), and uuid_bridge_on_soft_execute().
| #define switch_event_create_pres_in | ( | event | ) |
Value:
switch_event_create_pres_in_detailed(__FILE__, (const char * )__SWITCH_FUNC__, __LINE__, \ proto, login, from, from_domain, status, event_type, alt_event_type, event_count, \ unique_id, channel_state, answer_state, call_direction)
Definition at line 343 of file switch_event.h.
| #define switch_event_create_subclass | ( | _e, | |||
| _eid, | |||||
| _sn | ) | switch_event_create_subclass_detailed(__FILE__, (const char * )__SWITCH_FUNC__, __LINE__, _e, _eid, _sn) |
Definition at line 139 of file switch_event.h.
Referenced by Event::Event(), switch_core_hash_delete_multi(), switch_event_create_pres_in_detailed(), switch_event_dup(), switch_event_dup_reply(), and switch_limit_fire_event().
| #define switch_event_del_header | ( | _e, | |||
| _h | ) | switch_event_del_header_val(_e, _h, NULL) |
Definition at line 197 of file switch_event.h.
Referenced by Event::delHeader(), switch_channel_add_variable_var_check(), switch_channel_process_export(), switch_channel_set_variable_printf(), switch_channel_set_variable_var_check(), switch_core_session_outgoing_channel(), switch_core_set_var_conditional(), switch_core_set_variable(), switch_event_base_add_header(), switch_event_create_json(), and switch_event_set_subclass_name().
| #define switch_event_expand_headers | ( | _event, | |||
| _in | ) | switch_event_expand_headers_check(_event, _in, NULL, NULL, 0) |
Definition at line 334 of file switch_event.h.
Referenced by api_hook(), switch_core_execute_chat_app(), and switch_ivr_phrase_macro_event().
| #define switch_event_fire | ( | event | ) | switch_event_fire_detailed(__FILE__, (const char * )__SWITCH_FUNC__, __LINE__, event, NULL) |
Fire an event filling in most of the arguements with obvious values.
| event | the event to send (will be nulled on success) |
Definition at line 392 of file switch_event.h.
Referenced by __switch_xml_open_root(), check_ip(), do_chat_send(), Event::fire(), generate_on_dtmf(), handle_SIGHUP(), hanguphook(), record_callback(), rtp_common_write(), send_heartbeat(), signal_bridge_on_hangup(), signal_bridge_on_hibernate(), speech_thread(), switch_api_execute(), switch_channel_dequeue_dtmf(), switch_channel_flip_cid(), switch_channel_mark_hold(), switch_channel_perform_hangup(), switch_channel_perform_mark_answered(), switch_channel_perform_mark_pre_answered(), switch_channel_perform_mark_ring_ready_value(), switch_channel_perform_presence(), switch_channel_perform_set_callstate(), switch_console_printf(), switch_core_destroy(), switch_core_init_and_modload(), switch_core_media_bug_add(), switch_core_media_bug_destroy(), switch_core_session_exec(), switch_core_session_outgoing_channel(), switch_core_session_perform_destroy(), switch_core_session_reporting_state(), switch_core_session_run(), switch_core_session_set_read_codec(), switch_core_session_set_real_read_codec(), switch_core_session_set_uuid(), switch_core_session_set_video_read_codec(), switch_core_session_set_video_write_codec(), switch_core_session_set_write_codec(), switch_ivr_multi_threaded_bridge(), switch_ivr_park(), switch_ivr_parse_next_event(), switch_ivr_play_file(), switch_ivr_record_file(), switch_ivr_signal_bridge(), switch_limit_fire_event(), switch_loadable_module_process(), switch_loadable_module_unprocess(), switch_log_vprintf(), switch_nat_add_mapping_internal(), switch_nat_del_mapping(), switch_nat_multicast_runtime(), switch_rtp_add_crypto_key(), switch_scheduler_add_task(), switch_scheduler_del_task_group(), switch_scheduler_del_task_id(), switch_scheduler_execute(), SWITCH_STANDARD_SCHED_FUNC(), and uuid_bridge_on_soft_execute().
| #define switch_event_fire_data | ( | event, | |||
| data | ) | switch_event_fire_detailed(__FILE__, (const char * )__SWITCH_FUNC__, __LINE__, event, data) |
Fire an event filling in most of the arguements with obvious values and allowing user_data to be sent.
| event | the event to send (will be nulled on success) | |
| data | user data to send to the event handlers |
Definition at line 401 of file switch_event.h.
| #define switch_event_free_subclass | ( | subclass_name | ) | switch_event_free_subclass_detailed(__FILE__, subclass_name) |
Definition at line 355 of file switch_event.h.
| #define switch_event_get_header | ( | _e, | |||
| _h | ) | switch_event_get_header_idx(_e, _h, -1) |
Definition at line 158 of file switch_event.h.
Referenced by Event::chat_send(), core_event_handler(), do_chat_send(), find_user_in_tag(), Event::getHeader(), parse_presence_data_cols(), play_and_detect_input_callback(), switch_channel_event_set_extended_data(), switch_channel_get_scope_variables(), switch_core_get_variable(), switch_core_get_variable_dup(), switch_core_get_variable_pdup(), switch_core_session_outgoing_channel(), switch_core_set_var_conditional(), switch_core_set_variable(), switch_event_check_permission_list(), switch_events_match(), switch_ivr_eavesdrop_session(), switch_ivr_originate(), switch_ivr_parse_event(), switch_say_file_handle_get_variable(), and switch_xml_config_parse_event().
| #define switch_event_get_header_nil | ( | e, | |||
| h | ) | switch_str_nil(switch_event_get_header(e,h)) |
Definition at line 160 of file switch_event.h.
Referenced by core_event_handler(), and parse_presence_data_cols().
| #define switch_event_prep_for_delivery | ( | _event | ) | switch_event_prep_for_delivery_detailed(__FILE__, (const char * )__SWITCH_FUNC__, __LINE__, _event) |
Definition at line 228 of file switch_event.h.
| #define switch_event_reserve_subclass | ( | subclass_name | ) | switch_event_reserve_subclass_detailed(__FILE__, subclass_name) |
Reserve a subclass assuming the owner string is the current filename.
| subclass_name | the subclass name to reserve |
Definition at line 354 of file switch_event.h.
Referenced by switch_limit_init().
| #define switch_event_safe_destroy | ( | _event | ) | if (_event) switch_event_destroy(_event) |
Definition at line 204 of file switch_event.h.
| #define SWITCH_EVENT_SUBCLASS_ANY NULL |
Definition at line 114 of file switch_event.h.
Referenced by switch_core_sqldb_start(), and switch_event_create_pres_in_detailed().
| enum switch_event_flag_t |
Definition at line 105 of file switch_event.h.
00105 { 00106 EF_UNIQ_HEADERS = (1 << 0), 00107 EF_NO_CHAT_EXEC = (1 << 1), 00108 EF_DEFAULT_ALLOW = (1 << 2) 00109 } switch_event_flag_t;
| int switch_event_add_array | ( | switch_event_t * | event, | |
| const char * | var, | |||
| const char * | val | |||
| ) |
Definition at line 872 of file switch_event.c.
References switch_assert, switch_event_add_header_string(), switch_separate_string_string(), and SWITCH_STACK_PUSH.
Referenced by switch_event_base_add_header().
00873 { 00874 char *data; 00875 char **array; 00876 int max = 0; 00877 int len; 00878 const char *p; 00879 int i; 00880 00881 if (strlen(val) < 8) { 00882 return -1; 00883 } 00884 00885 p = val + 7; 00886 00887 max = 1; 00888 00889 while((p = strstr(p, "|:"))) { 00890 max++; 00891 p += 2; 00892 } 00893 00894 if (!max) { 00895 return -2; 00896 } 00897 00898 data = strdup(val + 7); 00899 00900 len = (sizeof(char *) * max) + 1; 00901 switch_assert(len); 00902 00903 array = malloc(len); 00904 memset(array, 0, len); 00905 00906 switch_separate_string_string(data, "|:", array, max); 00907 00908 for(i = 0; i < max; i++) { 00909 switch_event_add_header_string(event, SWITCH_STACK_PUSH, var, array[i]); 00910 } 00911 00912 free(array); 00913 free(data); 00914 00915 return 0; 00916 }
| switch_status_t switch_event_add_body | ( | switch_event_t * | event, | |
| const char * | fmt, | |||
| ... | ||||
| ) |
Add a body to an event.
| event | the event to add to body to | |
| fmt | optional body of the event (varargs see standard sprintf family) |
Referenced by Event::addBody(), speech_thread(), switch_core_chat_send_args(), switch_core_session_reporting_state(), and switch_event_create_json().
| switch_status_t switch_event_add_header | ( | switch_event_t * | event, | |
| switch_stack_t | stack, | |||
| const char * | header_name, | |||
| const char * | fmt, | |||
| ... | ||||
| ) |
Add a header to an event.
| event | the event to add the header to | |
| stack | the stack sense (stack it on the top or on the bottom) | |
| header_name | the name of the header to add | |
| fmt | the value of the header (varargs see standard sprintf family) |
Referenced by check_ip(), generate_on_dtmf(), handle_SIGHUP(), send_heartbeat(), switch_caller_profile_event_set_data(), switch_channel_dequeue_dtmf(), switch_channel_event_set_basic_data(), switch_channel_perform_presence(), switch_channel_perform_set_callstate(), switch_console_printf(), switch_core_destroy(), switch_core_init_and_modload(), switch_core_media_bug_add(), switch_core_media_bug_destroy(), switch_core_session_set_read_codec(), switch_core_session_set_real_read_codec(), switch_core_session_set_video_read_codec(), switch_core_session_set_video_write_codec(), switch_core_session_set_write_codec(), switch_event_create_pres_in_detailed(), switch_event_prep_for_delivery_detailed(), switch_ivr_broadcast(), switch_limit_fire_event(), switch_log_vprintf(), switch_nat_add_mapping_internal(), switch_nat_del_mapping(), switch_rtp_add_crypto_key(), switch_scheduler_add_task(), switch_scheduler_del_task_group(), switch_scheduler_del_task_id(), and switch_scheduler_execute().
| switch_status_t switch_event_add_header_string | ( | switch_event_t * | event, | |
| switch_stack_t | stack, | |||
| const char * | header_name, | |||
| const char * | data | |||
| ) |
Add a string header to an event.
| event | the event to add the header to | |
| stack | the stack sense (stack it on the top or on the bottom) | |
| header_name | the name of the header to add | |
| data | the value of the header |
Definition at line 1126 of file switch_event.c.
References DUP, switch_event_base_add_header(), SWITCH_STACK_NODUP, and SWITCH_STATUS_GENERR.
Referenced by add_playback_vars_to_event(), Event::addHeader(), check_ip(), do_chat_send(), generate_on_dtmf(), record_callback(), signal_bridge_on_hangup(), signal_bridge_on_hibernate(), speech_thread(), switch_api_execute(), switch_caller_profile_event_set_data(), switch_channel_add_variable_var_check(), switch_channel_event_set_basic_data(), switch_channel_event_set_extended_data(), switch_channel_flip_cid(), switch_channel_get_scope_variables(), switch_channel_perform_hangup(), switch_channel_perform_presence(), switch_channel_perform_set_callstate(), switch_channel_process_export(), switch_channel_set_variable_var_check(), switch_console_printf(), switch_core_chat_deliver(), switch_core_chat_send(), switch_core_chat_send_args(), switch_core_hash_delete_multi(), switch_core_session_exec(), switch_core_session_execute_application_async(), switch_core_session_reporting_state(), switch_core_session_set_read_codec(), switch_core_session_set_real_read_codec(), switch_core_session_set_uuid(), switch_core_session_set_video_read_codec(), switch_core_session_set_video_write_codec(), switch_core_session_set_write_codec(), switch_core_set_var_conditional(), switch_core_set_variable(), switch_event_add_array(), switch_event_add_presence_data_cols(), switch_event_create_brackets(), switch_event_create_json(), switch_event_create_pres_in_detailed(), switch_event_create_subclass_detailed(), switch_event_dup(), switch_event_dup_reply(), switch_event_import_xml(), switch_event_merge(), switch_event_prep_for_delivery_detailed(), switch_event_set_priority(), switch_event_set_subclass_name(), switch_ivr_broadcast(), switch_ivr_check_presence_mapping(), switch_ivr_create_message_reply(), switch_ivr_enterprise_originate(), switch_ivr_multi_threaded_bridge(), switch_ivr_phrase_macro_event(), switch_ivr_play_file(), switch_ivr_record_file(), switch_ivr_say(), switch_ivr_say_string(), switch_ivr_signal_bridge(), switch_limit_fire_event(), switch_load_network_lists(), switch_loadable_module_process(), switch_loadable_module_unprocess(), switch_log_vprintf(), switch_nat_add_mapping_internal(), switch_nat_del_mapping(), switch_nat_multicast_runtime(), switch_regex_set_event_header_callback(), switch_rtp_add_crypto_key(), switch_scheduler_add_task(), switch_scheduler_del_task_group(), switch_scheduler_del_task_id(), switch_scheduler_execute(), switch_xml_locate_domain(), switch_xml_locate_group(), switch_xml_locate_user(), and uuid_bridge_on_soft_execute().
01127 { 01128 if (data) { 01129 return switch_event_base_add_header(event, stack, header_name, (stack & SWITCH_STACK_NODUP) ? (char *)data : DUP(data)); 01130 } 01131 return SWITCH_STATUS_GENERR; 01132 }
| void switch_event_add_presence_data_cols | ( | switch_channel_t * | channel, | |
| switch_event_t * | event, | |||
| const char * | prefix | |||
| ) |
Definition at line 2394 of file switch_event.c.
References switch_channel_get_variable, switch_event_add_header_string(), switch_safe_free, switch_snprintf(), switch_split, and SWITCH_STACK_BOTTOM.
Referenced by signal_bridge_on_hangup(), signal_bridge_on_hibernate(), switch_channel_event_set_basic_data(), and switch_ivr_multi_threaded_bridge().
02395 { 02396 const char *data; 02397 02398 if (!prefix) prefix = ""; 02399 02400 if ((data = switch_channel_get_variable(channel, "presence_data_cols"))) { 02401 char *cols[128] = { 0 }; 02402 char header_name[128] = ""; 02403 int col_count = 0, i = 0; 02404 char *data_copy = NULL; 02405 02406 data_copy = strdup(data); 02407 02408 col_count = switch_split(data_copy, ':', cols); 02409 02410 for (i = 0; i < col_count; i++) { 02411 const char *val = NULL; 02412 switch_snprintf(header_name, sizeof(header_name), "%s%s", prefix, cols[i]); 02413 02414 val = switch_channel_get_variable(channel, cols[i]); 02415 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, val); 02416 } 02417 02418 switch_safe_free(data_copy); 02419 } 02420 02421 }
| switch_status_t switch_event_bind | ( | const char * | id, | |
| switch_event_types_t | event, | |||
| const char * | subclass_name, | |||
| switch_event_callback_t | callback, | |||
| void * | user_data | |||
| ) |
Bind an event callback to a specific event.
| id | an identifier token of the binder | |
| event | the event enumeration to bind to | |
| subclass_name | the event subclass to bind to in the case if SWITCH_EVENT_CUSTOM | |
| callback | the callback functon to bind | |
| user_data | optional user specific data to pass whenever the callback is invoked |
Definition at line 1870 of file switch_event.c.
References switch_event_bind_removable().
01872 { 01873 return switch_event_bind_removable(id, event, subclass_name, callback, user_data, NULL); 01874 }
| switch_status_t switch_event_bind_removable | ( | const char * | id, | |
| switch_event_types_t | event, | |||
| const char * | subclass_name, | |||
| switch_event_callback_t | callback, | |||
| void * | user_data, | |||
| switch_event_node_t ** | node | |||
| ) |
Bind an event callback to a specific event.
| id | an identifier token of the binder | |
| event | the event enumeration to bind to | |
| subclass_name | the event subclass to bind to in the case if SWITCH_EVENT_CUSTOM | |
| callback | the callback functon to bind | |
| user_data | optional user specific data to pass whenever the callback is invoked | |
| node | bind handle to later remove the binding. |
Definition at line 1812 of file switch_event.c.
References switch_event_subclass::bind, BLOCK, CUSTOM_HASH, DUP, event_node, EVENT_NODES, RUNTIME_POOL, RWLOCK, switch_assert, SWITCH_CHANNEL_LOG, switch_core_hash_find(), SWITCH_EVENT_ALL, switch_event_reserve_subclass_detailed(), SWITCH_LOG_ERROR, switch_log_printf(), switch_mutex_lock(), switch_mutex_unlock(), SWITCH_STATUS_FALSE, SWITCH_STATUS_MEMERR, SWITCH_STATUS_SUCCESS, switch_thread_rwlock_unlock(), switch_thread_rwlock_wrlock(), and switch_zmalloc.
Referenced by EventConsumer::bind(), switch_core_sqldb_start(), switch_event_bind(), and SWITCH_MODULE_LOAD_FUNCTION().
01814 { 01815 switch_event_node_t *event_node; 01816 switch_event_subclass_t *subclass = NULL; 01817 01818 switch_assert(BLOCK != NULL); 01819 switch_assert(RUNTIME_POOL != NULL); 01820 01821 if (node) { 01822 *node = NULL; 01823 } 01824 01825 if (subclass_name) { 01826 if (!(subclass = switch_core_hash_find(CUSTOM_HASH, subclass_name))) { 01827 switch_event_reserve_subclass_detailed(id, subclass_name); 01828 subclass = switch_core_hash_find(CUSTOM_HASH, subclass_name); 01829 subclass->bind = 1; 01830 } 01831 if (!subclass) { 01832 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not reserve subclass. '%s'\n", subclass_name); 01833 return SWITCH_STATUS_FALSE; 01834 } 01835 } 01836 01837 if (event <= SWITCH_EVENT_ALL) { 01838 switch_zmalloc(event_node, sizeof(*event_node)); 01839 switch_thread_rwlock_wrlock(RWLOCK); 01840 switch_mutex_lock(BLOCK); 01841 /* <LOCKED> ----------------------------------------------- */ 01842 event_node->id = DUP(id); 01843 event_node->event_id = event; 01844 if (subclass_name) { 01845 event_node->subclass_name = DUP(subclass_name); 01846 } 01847 event_node->callback = callback; 01848 event_node->user_data = user_data; 01849 01850 if (EVENT_NODES[event]) { 01851 event_node->next = EVENT_NODES[event]; 01852 } 01853 01854 EVENT_NODES[event] = event_node; 01855 switch_mutex_unlock(BLOCK); 01856 switch_thread_rwlock_unlock(RWLOCK); 01857 /* </LOCKED> ----------------------------------------------- */ 01858 01859 if (node) { 01860 *node = event_node; 01861 } 01862 01863 return SWITCH_STATUS_SUCCESS; 01864 } 01865 01866 return SWITCH_STATUS_MEMERR; 01867 }
| char* switch_event_build_param_string | ( | switch_event_t * | event, | |
| const char * | prefix, | |||
| switch_hash_t * | vars_map | |||
| ) |
Definition at line 2280 of file switch_event.c.
References switch_stream_handle::data, switch_event_header::name, switch_event_header::next, switch_assert, switch_core_hash_find(), switch_safe_free, SWITCH_STANDARD_STREAM, switch_url_encode(), switch_event_header::value, switch_stream_handle::write_function, and zstr.
02281 { 02282 switch_stream_handle_t stream = { 0 }; 02283 switch_size_t encode_len = 1024, new_len = 0; 02284 char *encode_buf = NULL; 02285 const char *prof[12] = { 0 }, *prof_names[12] = { 02286 0}; 02287 char *e = NULL; 02288 switch_event_header_t *hi; 02289 uint32_t x = 0; 02290 void *data = NULL; 02291 02292 SWITCH_STANDARD_STREAM(stream); 02293 02294 if (prefix) { 02295 stream.write_function(&stream, "%s&", prefix); 02296 } 02297 02298 encode_buf = malloc(encode_len); 02299 switch_assert(encode_buf); 02300 02301 02302 02303 for (x = 0; prof[x]; x++) { 02304 if (zstr(prof[x])) { 02305 continue; 02306 } 02307 new_len = (strlen(prof[x]) * 3) + 1; 02308 if (encode_len < new_len) { 02309 char *tmp; 02310 02311 encode_len = new_len; 02312 02313 if (!(tmp = realloc(encode_buf, encode_len))) { 02314 abort(); 02315 } 02316 02317 encode_buf = tmp; 02318 } 02319 switch_url_encode(prof[x], encode_buf, encode_len); 02320 stream.write_function(&stream, "%s=%s&", prof_names[x], encode_buf); 02321 } 02322 02323 if (event) { 02324 if ((hi = event->headers)) { 02325 02326 for (; hi; hi = hi->next) { 02327 char *var = hi->name; 02328 char *val = hi->value; 02329 02330 if (vars_map != NULL) { 02331 if ((data = switch_core_hash_find(vars_map, var)) == NULL || strcasecmp(((char *) data), "enabled")) 02332 continue; 02333 02334 } 02335 02336 new_len = (strlen((char *) var) * 3) + 1; 02337 if (encode_len < new_len) { 02338 char *tmp; 02339 02340 encode_len = new_len; 02341 02342 tmp = realloc(encode_buf, encode_len); 02343 switch_assert(tmp); 02344 encode_buf = tmp; 02345 } 02346 02347 switch_url_encode((char *) val, encode_buf, encode_len); 02348 stream.write_function(&stream, "%s=%s&", (char *) var, encode_buf); 02349 02350 } 02351 } 02352 } 02353 02354 e = (char *) stream.data + (strlen((char *) stream.data) - 1); 02355 02356 if (e && *e == '&') { 02357 *e = '\0'; 02358 } 02359 02360 switch_safe_free(encode_buf); 02361 02362 return stream.data; 02363 }
| int switch_event_check_permission_list | ( | switch_event_t * | list, | |
| const char * | name | |||
| ) |
Definition at line 2365 of file switch_event.c.
References EF_DEFAULT_ALLOW, switch_event_get_header, and switch_test_flag.
Referenced by switch_channel_expand_variables_check(), and switch_event_expand_headers_check().
02366 { 02367 const char *v; 02368 int r = 0; 02369 int default_allow = 0; 02370 02371 if (!list) { 02372 return 1; 02373 } 02374 02375 default_allow = switch_test_flag(list, EF_DEFAULT_ALLOW); 02376 02377 if (!list->headers) { 02378 return default_allow; 02379 } 02380 02381 if ((v = switch_event_get_header(list, name))) { 02382 if (*v == 'd') { 02383 r = 0; 02384 } else { 02385 r = 1; 02386 } 02387 } else { 02388 r = default_allow; 02389 } 02390 02391 return r; 02392 }
| switch_status_t switch_event_create_brackets | ( | char * | data, | |
| char | a, | |||
| char | b, | |||
| char | c, | |||
| switch_event_t ** | event, | |||
| char ** | new_data, | |||
| switch_bool_t | dup | |||
| ) |
Definition at line 1445 of file switch_event.c.
References SWITCH_CHANNEL_LOG, switch_event_add_header_string(), SWITCH_EVENT_CHANNEL_DATA, switch_event_create_plain(), switch_find_end_paren(), SWITCH_LOG_DEBUG, switch_log_printf(), switch_separate_string(), SWITCH_STACK_BOTTOM, SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, and switch_strchr_strict().
Referenced by switch_core_session_exec(), switch_ivr_enterprise_originate(), and switch_ivr_originate().
01446 { 01447 char *vdata, *vdatap = NULL; 01448 char *end, *check_a, *check_b; 01449 switch_event_t *e = *event; 01450 char *var_array[1024] = { 0 }; 01451 int var_count = 0; 01452 char *next = NULL, *vnext = NULL; 01453 01454 if (dup) { 01455 vdatap = strdup(data); 01456 vdata = vdatap; 01457 } else { 01458 vdata = data; 01459 } 01460 01461 end = switch_find_end_paren(vdata, a, b); 01462 01463 check_a = end; 01464 01465 while (check_a && (check_b = switch_strchr_strict(check_a, a, " "))) { 01466 if ((check_b = switch_find_end_paren(check_b, a, b))) { 01467 check_a = check_b; 01468 } 01469 } 01470 01471 if (check_a) end = check_a; 01472 01473 if (end) { 01474 next = end; 01475 vdata++; 01476 *end++ = '\0'; 01477 } else { 01478 if (dup) { 01479 free(vdatap); 01480 } 01481 return SWITCH_STATUS_FALSE; 01482 } 01483 01484 if (!e) { 01485 switch_event_create_plain(&e, SWITCH_EVENT_CHANNEL_DATA); 01486 } 01487 01488 01489 for (;;) { 01490 if (next) { 01491 char *pnext; 01492 01493 *next++ = '\0'; 01494 01495 if ((pnext = switch_strchr_strict(next, a, " "))) { 01496 next = pnext + 1; 01497 } 01498 01499 vnext = switch_find_end_paren(next, a, b); 01500 next = NULL; 01501 } 01502 01503 01504 if (vdata) { 01505 if (*vdata == '^' && *(vdata + 1) == '^') { 01506 vdata += 2; 01507 c = *vdata++; 01508 } 01509 } 01510 01511 if ((var_count = switch_separate_string(vdata, c, var_array, (sizeof(var_array) / sizeof(var_array[0]))))) { 01512 int x = 0; 01513 for (x = 0; x < var_count; x++) { 01514 char *inner_var_array[2] = { 0 }; 01515 int inner_var_count; 01516 01517 if ((inner_var_count = switch_separate_string(var_array[x], '=', 01518 inner_var_array, (sizeof(inner_var_array) / sizeof(inner_var_array[0])))) == 2) { 01519 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Parsing variable [%s]=[%s]\n", inner_var_array[0], inner_var_array[1]); 01520 switch_event_add_header_string(e, SWITCH_STACK_BOTTOM, inner_var_array[0], inner_var_array[1]); 01521 } 01522 } 01523 } 01524 01525 if (vnext) { 01526 vdata = vnext; 01527 } else { 01528 break; 01529 } 01530 01531 } 01532 01533 *event = e; 01534 01535 if (dup) { 01536 *new_data = strdup(end); 01537 free(vdatap); 01538 } else { 01539 *new_data = end; 01540 } 01541 01542 return SWITCH_STATUS_SUCCESS; 01543 01544 }
| switch_status_t switch_event_create_json | ( | switch_event_t ** | event, | |
| const char * | json | |||
| ) |
Definition at line 1548 of file switch_event.c.
References cJSON_Delete(), cJSON_GetArrayItem(), cJSON_GetArraySize(), cJSON_Parse(), switch_event::event_id, switch_event_add_body(), switch_event_add_header_string(), SWITCH_EVENT_CLONE, switch_event_create, switch_event_del_header, switch_name_event(), SWITCH_STACK_BOTTOM, SWITCH_STACK_PUSH, SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, and SWITCH_VA_NONE.
Referenced by Event::Event().
01549 { 01550 switch_event_t *new_event; 01551 cJSON *cj, *cjp; 01552 01553 01554 if (!(cj = cJSON_Parse(json))) { 01555 return SWITCH_STATUS_FALSE; 01556 } 01557 01558 if (switch_event_create(&new_event, SWITCH_EVENT_CLONE) != SWITCH_STATUS_SUCCESS) { 01559 cJSON_Delete(cj); 01560 return SWITCH_STATUS_FALSE; 01561 } 01562 01563 for (cjp = cj->child; cjp; cjp = cjp->next) { 01564 char *name = cjp->string; 01565 char *value = cjp->valuestring; 01566 01567 if (name && value) { 01568 if (!strcasecmp(name, "_body")) { 01569 switch_event_add_body(new_event, value, SWITCH_VA_NONE); 01570 } else { 01571 if (!strcasecmp(name, "event-name")) { 01572 switch_event_del_header(new_event, "event-name"); 01573 switch_name_event(value, &new_event->event_id); 01574 } 01575 01576 switch_event_add_header_string(new_event, SWITCH_STACK_BOTTOM, name, value); 01577 } 01578 01579 } else if (name) { 01580 if (cjp->type == cJSON_Array) { 01581 int i, x = cJSON_GetArraySize(cjp); 01582 01583 for (i = 0; i < x; i++) { 01584 cJSON *item = cJSON_GetArrayItem(cjp, i); 01585 01586 if (item && item->type == cJSON_String && item->valuestring) { 01587 switch_event_add_header_string(new_event, SWITCH_STACK_PUSH, name, item->valuestring); 01588 } 01589 } 01590 } 01591 } 01592 } 01593 01594 cJSON_Delete(cj); 01595 *event = new_event; 01596 return SWITCH_STATUS_SUCCESS; 01597 }
| static switch_status_t switch_event_create_plain | ( | switch_event_t ** | event, | |
| switch_event_types_t | event_id | |||
| ) | [inline, static] |
Definition at line 365 of file switch_event.h.
References EF_UNIQ_HEADERS, SWITCH_EVENT_CHANNEL_DATA, SWITCH_EVENT_CLONE, switch_event_create, SWITCH_EVENT_REQUEST_PARAMS, and SWITCH_STATUS_SUCCESS.
Referenced by switch_channel_alloc(), switch_channel_get_scope_variables(), switch_core_init(), switch_core_unset_variables(), switch_event_create_brackets(), switch_ivr_enterprise_originate(), and switch_ivr_originate().
00366 { 00367 switch_status_t status = switch_event_create(event, SWITCH_EVENT_CLONE); 00368 if (status == SWITCH_STATUS_SUCCESS) { 00369 (*event)->event_id = event_id; 00370 00371 if (event_id == SWITCH_EVENT_REQUEST_PARAMS || event_id == SWITCH_EVENT_CHANNEL_DATA) { 00372 (*event)->flags |= EF_UNIQ_HEADERS; 00373 } 00374 } 00375 00376 return status; 00377 }
| switch_status_t switch_event_create_pres_in_detailed | ( | _In_z_ char * | file, | |
| _In_z_ char * | func, | |||
| _In_ int | line, | |||
| _In_z_ const char * | proto, | |||
| _In_z_ const char * | login, | |||
| _In_z_ const char * | from, | |||
| _In_z_ const char * | from_domain, | |||
| _In_z_ const char * | status, | |||
| _In_z_ const char * | event_type, | |||
| _In_z_ const char * | alt_event_type, | |||
| _In_ int | event_count, | |||
| _In_z_ const char * | unique_id, | |||
| _In_z_ const char * | channel_state, | |||
| _In_z_ const char * | answer_state, | |||
| _In_z_ const char * | call_direction | |||
| ) |
| switch_status_t switch_event_create_subclass_detailed | ( | const char * | file, | |
| const char * | func, | |||
| int | line, | |||
| switch_event_t ** | event, | |||
| switch_event_types_t | event_id, | |||
| const char * | subclass_name | |||
| ) |
Create an event.
| event | a NULL pointer on which to create the event | |
| event_id | the event id enumeration of the desired event | |
| subclass_name | the subclass name for custom event (only valid when event_id is SWITCH_EVENT_CUSTOM) |
Definition at line 668 of file switch_event.c.
References ALLOC, DUP, EF_UNIQ_HEADERS, switch_assert, switch_event_add_header_string(), SWITCH_EVENT_CHANNEL_DATA, SWITCH_EVENT_CLONE, SWITCH_EVENT_CUSTOM, SWITCH_EVENT_MESSAGE, switch_event_prep_for_delivery_detailed(), SWITCH_EVENT_REQUEST_PARAMS, switch_queue_trypop(), SWITCH_STACK_BOTTOM, SWITCH_STATUS_GENERR, and SWITCH_STATUS_SUCCESS.
00670 { 00671 #ifdef SWITCH_EVENT_RECYCLE 00672 void *pop; 00673 #endif 00674 00675 *event = NULL; 00676 00677 if ((event_id != SWITCH_EVENT_CLONE && event_id != SWITCH_EVENT_CUSTOM) && subclass_name) { 00678 return SWITCH_STATUS_GENERR; 00679 } 00680 #ifdef SWITCH_EVENT_RECYCLE 00681 if (EVENT_RECYCLE_QUEUE && switch_queue_trypop(EVENT_RECYCLE_QUEUE, &pop) == SWITCH_STATUS_SUCCESS && pop) { 00682 *event = (switch_event_t *) pop; 00683 } else { 00684 #endif 00685 *event = ALLOC(sizeof(switch_event_t)); 00686 switch_assert(*event); 00687 #ifdef SWITCH_EVENT_RECYCLE 00688 } 00689 #endif 00690 00691 memset(*event, 0, sizeof(switch_event_t)); 00692 00693 if (event_id == SWITCH_EVENT_REQUEST_PARAMS || event_id == SWITCH_EVENT_CHANNEL_DATA || event_id == SWITCH_EVENT_MESSAGE) { 00694 (*event)->flags |= EF_UNIQ_HEADERS; 00695 } 00696 00697 if (event_id != SWITCH_EVENT_CLONE) { 00698 (*event)->event_id = event_id; 00699 switch_event_prep_for_delivery_detailed(file, func, line, *event); 00700 } 00701 00702 if (subclass_name) { 00703 (*event)->subclass_name = DUP(subclass_name); 00704 switch_event_add_header_string(*event, SWITCH_STACK_BOTTOM, "Event-Subclass", subclass_name); 00705 } 00706 00707 return SWITCH_STATUS_SUCCESS; 00708 }
| switch_status_t switch_event_del_header_val | ( | switch_event_t * | event, | |
| const char * | header_name, | |||
| const char * | val | |||
| ) |
Definition at line 793 of file switch_event.c.
References switch_event_header::array, FREE, switch_event_header::hash, switch_event_header::idx, switch_event_header::name, switch_event_header::next, switch_assert, switch_ci_hashfunc_default(), switch_queue_trypush(), SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, switch_event_header::value, and zstr.
00794 { 00795 switch_event_header_t *hp, *lp = NULL, *tp; 00796 switch_status_t status = SWITCH_STATUS_FALSE; 00797 int x = 0; 00798 switch_ssize_t hlen = -1; 00799 unsigned long hash = 0; 00800 00801 tp = event->headers; 00802 while (tp) { 00803 hp = tp; 00804 tp = tp->next; 00805 00806 x++; 00807 switch_assert(x < 1000000); 00808 hash = switch_ci_hashfunc_default(header_name, &hlen); 00809 00810 if ((!hp->hash || hash == hp->hash) && !strcasecmp(header_name, hp->name) && (zstr(val) || !strcmp(hp->value, val))) { 00811 if (lp) { 00812 lp->next = hp->next; 00813 } else { 00814 event->headers = hp->next; 00815 } 00816 if (hp == event->last_header || !hp->next) { 00817 event->last_header = lp; 00818 } 00819 FREE(hp->name); 00820 00821 if (hp->idx) { 00822 int i = 0; 00823 00824 for (i = 0; i < hp->idx; i++) { 00825 FREE(hp->array[i]); 00826 } 00827 FREE(hp->array); 00828 } 00829 00830 FREE(hp->value); 00831 00832 memset(hp, 0, sizeof(*hp)); 00833 #ifdef SWITCH_EVENT_RECYCLE 00834 if (switch_queue_trypush(EVENT_HEADER_RECYCLE_QUEUE, hp) != SWITCH_STATUS_SUCCESS) { 00835 FREE(hp); 00836 } 00837 #else 00838 FREE(hp); 00839 #endif 00840 status = SWITCH_STATUS_SUCCESS; 00841 } else { 00842 lp = hp; 00843 } 00844 } 00845 00846 return status; 00847 }
| void switch_event_deliver | ( | switch_event_t ** | event | ) |
Deliver an event to all of the registered event listeners.
| event | the event to send (will be nulled) |
Definition at line 358 of file switch_event.c.
References switch_event_node::callback, EVENT_NODES, switch_event_node::next, RWLOCK, SWITCH_EVENT_ALL, switch_event_destroy(), switch_events_match(), switch_thread_rwlock_rdlock(), switch_thread_rwlock_unlock(), SYSTEM_RUNNING, and switch_event_node::user_data.
Referenced by switch_event_dispatch_thread().
00359 { 00360 switch_event_types_t e; 00361 switch_event_node_t *node; 00362 00363 if (SYSTEM_RUNNING) { 00364 switch_thread_rwlock_rdlock(RWLOCK); 00365 for (e = (*event)->event_id;; e = SWITCH_EVENT_ALL) { 00366 for (node = EVENT_NODES[e]; node; node = node->next) { 00367 if (switch_events_match(*event, node)) { 00368 (*event)->bind_user_data = node->user_data; 00369 node->callback(*event); 00370 } 00371 } 00372 00373 if (e == SWITCH_EVENT_ALL) { 00374 break; 00375 } 00376 } 00377 switch_thread_rwlock_unlock(RWLOCK); 00378 } 00379 00380 switch_event_destroy(event); 00381 }
| void switch_event_destroy | ( | switch_event_t ** | event | ) |
Destroy an event.
| event | pointer to the pointer to event to destroy |
Definition at line 1168 of file switch_event.c.
References switch_event::body, FREE, switch_event::headers, switch_event_header::next, switch_event::subclass_name, switch_queue_trypush(), and SWITCH_STATUS_SUCCESS.
Referenced by __switch_xml_open_root(), audio_bridge_thread(), chat_process_event(), Event::fire(), CoreSession::flushEvents(), switch_channel_api_on(), switch_channel_del_variable_prefix(), switch_channel_execute_on(), switch_channel_set_scope_variables(), switch_channel_uninit(), switch_core_destroy(), switch_core_hash_delete_multi(), switch_core_session_receive_event(), switch_core_session_thread(), switch_core_unset_variables(), switch_event_deliver(), switch_event_fire_detailed(), switch_event_shutdown(), switch_ivr_check_presence_mapping(), switch_ivr_collect_digits_callback(), switch_ivr_eavesdrop_session(), switch_ivr_enterprise_originate(), switch_ivr_gentones(), switch_ivr_park(), switch_ivr_phrase_macro_event(), switch_ivr_play_file(), switch_ivr_record_file(), switch_ivr_say(), switch_ivr_say_string(), switch_ivr_session_echo(), switch_ivr_sleep(), switch_ivr_speak_text_handle(), switch_ivr_transfer_variable(), switch_load_network_lists(), switch_say_file_handle_destroy(), switch_xml_config_parse(), switch_xml_locate_domain(), switch_xml_locate_group(), switch_xml_locate_user(), and Event::~Event().
01169 { 01170 switch_event_t *ep = *event; 01171 switch_event_header_t *hp, *this; 01172 01173 if (ep) { 01174 for (hp = ep->headers; hp;) { 01175 this = hp; 01176 hp = hp->next; 01177 FREE(this->name); 01178 01179 if (this->idx) { 01180 int i = 0; 01181 01182 for (i = 0; i < this->idx; i++) { 01183 FREE(this->array[i]); 01184 } 01185 FREE(this->array); 01186 } 01187 01188 FREE(this->value); 01189 01190 01191 #ifdef SWITCH_EVENT_RECYCLE 01192 if (switch_queue_trypush(EVENT_HEADER_RECYCLE_QUEUE, this) != SWITCH_STATUS_SUCCESS) { 01193 FREE(this); 01194 } 01195 #else 01196 FREE(this); 01197 #endif 01198 01199 01200 } 01201 FREE(ep->body); 01202 FREE(ep->subclass_name); 01203 #ifdef SWITCH_EVENT_RECYCLE 01204 if (switch_queue_trypush(EVENT_RECYCLE_QUEUE, ep) != SWITCH_STATUS_SUCCESS) { 01205 FREE(ep); 01206 } 01207 #else 01208 FREE(ep); 01209 #endif 01210 01211 } 01212 *event = NULL; 01213 }
| switch_status_t switch_event_dup | ( | switch_event_t ** | event, | |
| switch_event_t * | todup | |||
| ) |
Duplicate an event.
| event | a NULL pointer on which to duplicate the event | |
| todup | an event to duplicate |
Definition at line 1235 of file switch_event.c.
References switch_event_header::array, DUP, switch_event_header::idx, switch_event_header::name, switch_event_header::next, switch_event_add_header_string(), SWITCH_EVENT_CLONE, switch_event_create_subclass, SWITCH_STACK_BOTTOM, SWITCH_STACK_PUSH, SWITCH_STATUS_GENERR, SWITCH_STATUS_SUCCESS, and switch_event_header::value.
Referenced by do_chat_send(), event_handler(), Event::fire(), CoreSession::sendEvent(), speech_thread(), switch_channel_get_variables(), switch_core_chat_send(), and switch_ivr_enterprise_originate().
01236 { 01237 switch_event_header_t *hp; 01238 01239 if (switch_event_create_subclass(event, SWITCH_EVENT_CLONE, todup->subclass_name) != SWITCH_STATUS_SUCCESS) { 01240 return SWITCH_STATUS_GENERR; 01241 } 01242 01243 (*event)->event_id = todup->event_id; 01244 (*event)->event_user_data = todup->event_user_data; 01245 (*event)->bind_user_data = todup->bind_user_data; 01246 (*event)->flags = todup->flags; 01247 for (hp = todup->headers; hp; hp = hp->next) { 01248 if (todup->subclass_name && !strcmp(hp->name, "Event-Subclass")) { 01249 continue; 01250 } 01251 01252 if (hp->idx) { 01253 int i; 01254 for (i = 0; i < hp->idx; i++) { 01255 switch_event_add_header_string(*event, SWITCH_STACK_PUSH, hp->name, hp->array[i]); 01256 } 01257 } else { 01258 switch_event_add_header_string(*event, SWITCH_STACK_BOTTOM, hp->name, hp->value); 01259 } 01260 } 01261 01262 if (todup->body) { 01263 (*event)->body = DUP(todup->body); 01264 } 01265 01266 (*event)->key = todup->key; 01267 01268 return SWITCH_STATUS_SUCCESS; 01269 }
| switch_status_t switch_event_dup_reply | ( | switch_event_t ** | event, | |
| switch_event_t * | todup | |||
| ) |
Definition at line 1272 of file switch_event.c.
References switch_event_header::array, switch_event_header::idx, switch_event_header::name, switch_event_header::next, switch_event_add_header_string(), SWITCH_EVENT_CLONE, switch_event_create_subclass, switch_snprintf(), SWITCH_STACK_BOTTOM, SWITCH_STACK_PUSH, SWITCH_STATUS_GENERR, SWITCH_STATUS_SUCCESS, and switch_event_header::value.
Referenced by switch_ivr_create_message_reply().
01273 { 01274 switch_event_header_t *hp; 01275 char hname[1024] = ""; 01276 char *p; 01277 01278 if (switch_event_create_subclass(event, SWITCH_EVENT_CLONE, todup->subclass_name) != SWITCH_STATUS_SUCCESS) { 01279 return SWITCH_STATUS_GENERR; 01280 } 01281 01282 (*event)->event_id = todup->event_id; 01283 (*event)->event_user_data = todup->event_user_data; 01284 (*event)->bind_user_data = todup->bind_user_data; 01285 (*event)->flags = todup->flags; 01286 01287 for (hp = todup->headers; hp; hp = hp->next) { 01288 char *name = hp->name, *value = hp->value; 01289 01290 if (todup->subclass_name && !strcmp(hp->name, "Event-Subclass")) { 01291 continue; 01292 } 01293 01294 if (!strncasecmp(hp->name, "from_", 5)) { 01295 p = hp->name + 5; 01296 switch_snprintf(hname, sizeof(hname), "to_%s", p); 01297 name = hname; 01298 } else if (!strncasecmp(hp->name, "to_", 3)) { 01299 p = hp->name + 3; 01300 switch_snprintf(hname, sizeof(hname), "from_%s", p); 01301 name = hname; 01302 } else if (!strcasecmp(name, "to")) { 01303 name = "from"; 01304 } else if (!strcasecmp(name, "from")) { 01305 name = "to"; 01306 } 01307 01308 if (hp->idx) { 01309 int i; 01310 for (i = 0; i < hp->idx; i++) { 01311 switch_event_add_header_string(*event, SWITCH_STACK_PUSH, name, hp->array[i]); 01312 } 01313 } else { 01314 switch_event_add_header_string(*event, SWITCH_STACK_BOTTOM, name, value); 01315 } 01316 } 01317 01318 switch_event_add_header_string(*event, SWITCH_STACK_BOTTOM, "replying", "true"); 01319 01320 if (todup->body) { 01321 switch_event_add_header_string(*event, SWITCH_STACK_BOTTOM, "orig_body", todup->body); 01322 } 01323 01324 (*event)->key = todup->key; 01325 01326 return SWITCH_STATUS_SUCCESS; 01327 }
| char* switch_event_expand_headers_check | ( | switch_event_t * | event, | |
| const char * | in, | |||
| switch_event_t * | var_list, | |||
| switch_event_t * | api_list, | |||
| uint32_t | recur | |||
| ) |
Definition at line 1994 of file switch_event.c.
References switch_stream_handle::data, end_of_p, resize, switch_api_execute(), switch_assert, SWITCH_CHANNEL_LOG, switch_core_get_variable_dup(), switch_event_check_permission_list(), switch_event_expand_headers_check(), switch_event_get_header_idx(), SWITCH_LOG_CRIT, switch_log_printf(), switch_safe_free, SWITCH_STANDARD_STREAM, SWITCH_STATUS_SUCCESS, switch_string_has_escaped_data(), switch_string_var_check_const(), and zstr.
Referenced by switch_event_expand_headers_check().
01995 { 01996 char *p, *c = NULL; 01997 char *data, *indup, *endof_indup; 01998 size_t sp = 0, len = 0, olen = 0, vtype = 0, br = 0, cpos, block = 128; 01999 const char *sub_val = NULL; 02000 char *cloned_sub_val = NULL, *expanded_sub_val = NULL; 02001 char *func_val = NULL; 02002 int nv = 0; 02003 char *gvar = NULL, *sb = NULL; 02004 02005 if (recur > 100) { 02006 return (char *) in; 02007 } 02008 02009 if (zstr(in)) { 02010 return (char *) in; 02011 } 02012 02013 nv = switch_string_var_check_const(in) || switch_string_has_escaped_data(in); 02014 02015 if (!nv) { 02016 return (char *) in; 02017 } 02018 02019 nv = 0; 02020 olen = strlen(in) + 1; 02021 indup = strdup(in); 02022 endof_indup = end_of_p(indup) + 1; 02023 02024 if ((data = malloc(olen))) { 02025 memset(data, 0, olen); 02026 c = data; 02027 for (p = indup; p && p < endof_indup && *p; p++) { 02028 vtype = 0; 02029 02030 if (*p == '\\') { 02031 if (*(p + 1) == '$') { 02032 nv = 1; 02033 p++; 02034 } else if (*(p + 1) == '\'') { 02035 p++; 02036 continue; 02037 } else if (*(p + 1) == '\\') { 02038 *c++ = *p++; 02039 len++; 02040 continue; 02041 } 02042 } 02043 02044 if (*p == '$' && !nv) { 02045 if (*(p + 1)) { 02046 if (*(p + 1) == '{') { 02047 vtype = 1; 02048 } else { 02049 nv = 1; 02050 } 02051 } else { 02052 nv = 1; 02053 } 02054 } 02055 02056 if (nv) { 02057 *c++ = *p; 02058 len++; 02059 nv = 0; 02060 continue; 02061 } 02062 02063 if (vtype) { 02064 char *s = p, *e, *vname, *vval = NULL; 02065 size_t nlen; 02066 02067 s++; 02068 02069 if (vtype == 1 && *s == '{') { 02070 br = 1; 02071 s++; 02072 } 02073 02074 e = s; 02075 vname = s; 02076 while (*e) { 02077 if (br == 1 && *e == '}') { 02078 br = 0; 02079 *e++ = '\0'; 02080 break; 02081 } 02082 02083 if (br > 0) { 02084 if (e != s && *e == '{') { 02085 br++; 02086 } else if (br > 1 && *e == '}') { 02087 br--; 02088 } 02089 } 02090 02091 e++; 02092 } 02093 p = e > endof_indup ? endof_indup : e; 02094 02095 vval = NULL; 02096 for(sb = vname; sb && *sb; sb++) { 02097 if (*sb == ' ') { 02098 vval = sb; 02099 break; 02100 } else if (*sb == '(') { 02101 vval = sb; 02102 br = 1; 02103 break; 02104 } 02105 } 02106 02107 if (vval) { 02108 e = vval - 1; 02109 *vval++ = '\0'; 02110 02111 while (*e == ' ') { 02112 *e-- = '\0'; 02113 } 02114 e = vval; 02115 02116 while (e && *e) { 02117 if (*e == '(') { 02118 br++; 02119 } else if (br > 1 && *e == ')') { 02120 br--; 02121 } else if (br == 1 && *e == ')') { 02122 *e = '\0'; 02123 break; 02124 } 02125 e++; 02126 } 02127 02128 vtype = 2; 02129 } 02130 02131 if (vtype == 1) { 02132 char *expanded = NULL; 02133 int offset = 0; 02134 int ooffset = 0; 02135 char *ptr; 02136 int idx = -1; 02137 02138 if ((expanded = switch_event_expand_headers_check(event, (char *) vname, var_list, api_list, recur+1)) == vname) { 02139 expanded = NULL; 02140 } else { 02141 vname = expanded; 02142 } 02143 if ((ptr = strchr(vname, ':'))) { 02144 *ptr++ = '\0'; 02145 offset = atoi(ptr); 02146 if ((ptr = strchr(ptr, ':'))) { 02147 ptr++; 02148 ooffset = atoi(ptr); 02149 } 02150 } 02151 02152 if ((ptr = strchr(vname, '[')) && strchr(ptr, ']')) { 02153 *ptr++ = '\0'; 02154 idx = atoi(ptr); 02155 } 02156 02157 if (!(sub_val = switch_event_get_header_idx(event, vname, idx))) { 02158 switch_safe_free(gvar); 02159 if ((gvar = switch_core_get_variable_dup(vname))) { 02160 sub_val = gvar; 02161 } 02162 02163 if (var_list && !switch_event_check_permission_list(var_list, vname)) { 02164 sub_val = "INVALID"; 02165 } 02166 02167 02168 if ((expanded_sub_val = switch_event_expand_headers_check(event, sub_val, var_list, api_list, recur+1)) == sub_val) { 02169 expanded_sub_val = NULL; 02170 } else { 02171 sub_val = expanded_sub_val; 02172 } 02173 } 02174 02175 if (offset || ooffset) { 02176 cloned_sub_val = strdup(sub_val); 02177 switch_assert(cloned_sub_val); 02178 sub_val = cloned_sub_val; 02179 } 02180 02181 if (offset >= 0) { 02182 sub_val += offset; 02183 } else if ((size_t) abs(offset) <= strlen(sub_val)) { 02184 sub_val = cloned_sub_val + (strlen(cloned_sub_val) + offset); 02185 } 02186 02187 if (ooffset > 0 && (size_t) ooffset < strlen(sub_val)) { 02188 if ((ptr = (char *) sub_val + ooffset)) { 02189 *ptr = '\0'; 02190 } 02191 } 02192 02193 02194 switch_safe_free(expanded); 02195 } else { 02196 switch_stream_handle_t stream = { 0 }; 02197 char *expanded = NULL; 02198 02199 SWITCH_STANDARD_STREAM(stream); 02200 02201 if (stream.data) { 02202 char *expanded_vname = NULL; 02203 02204 if ((expanded_vname = switch_event_expand_headers_check(event, (char *) vname, var_list, api_list, recur+1)) == vname) { 02205 expanded_vname = NULL; 02206 } else { 02207 vname = expanded_vname; 02208 } 02209 02210 if ((expanded = switch_event_expand_headers_check(event, vval, var_list, api_list, recur+1)) == vval) { 02211 expanded = NULL; 02212 } else { 02213 vval = expanded; 02214 } 02215 02216 if (api_list && !switch_event_check_permission_list(api_list, vname)) { 02217 func_val = "INVALID"; 02218 sub_val = "INVALID"; 02219 } else { 02220 if (switch_api_execute(vname, vval, NULL, &stream) == SWITCH_STATUS_SUCCESS) { 02221 func_val = stream.data; 02222 sub_val = func_val; 02223 } else { 02224 free(stream.data); 02225 } 02226 } 02227 02228 switch_safe_free(expanded); 02229 switch_safe_free(expanded_vname); 02230 02231 } else { 02232 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n"); 02233 free(data); 02234 free(indup); 02235 return (char *) in; 02236 } 02237 } 02238 if ((nlen = sub_val ? strlen(sub_val) : 0)) { 02239 if (len + nlen >= olen) { 02240 resize(nlen); 02241 } 02242 02243 len += nlen; 02244 strcat(c, sub_val); 02245 c += nlen; 02246 } 02247 02248 switch_safe_free(func_val); 02249 switch_safe_free(cloned_sub_val); 02250 switch_safe_free(expanded_sub_val); 02251 sub_val = NULL; 02252 vname = NULL; 02253 vtype = 0; 02254 br = 0; 02255 } 02256 if (len + 1 >= olen) { 02257 resize(1); 02258 } 02259 02260 if (sp) { 02261 *c++ = ' '; 02262 sp = 0; 02263 len++; 02264 } 02265 02266 if (*p == '$') { 02267 p--; 02268 } else { 02269 *c++ = *p; 02270 len++; 02271 } 02272 } 02273 } 02274 free(indup); 02275 switch_safe_free(gvar); 02276 02277 return data; 02278 }
| switch_status_t switch_event_fire_detailed | ( | const char * | file, | |
| const char * | func, | |||
| int | line, | |||
| switch_event_t ** | event, | |||
| void * | user_data | |||
| ) |
Fire an event with full arguement list.
| file | the calling file | |
| func | the calling function | |
| line | the calling line number | |
| event | the event to send (will be nulled on success) | |
| user_data | optional private data to pass to the event handlers |
Definition at line 1767 of file switch_event.c.
References BLOCK, EVENT_QUEUE, EVENT_QUEUE_MUTEX, EVENT_QUEUE_THREADS, POOL_COUNT_MAX, RUNTIME_POOL, switch_assert, SWITCH_CHANNEL_LOG, switch_event_destroy(), switch_event_thread(), SWITCH_LOG_CRIT, switch_log_printf(), switch_queue_create(), switch_queue_trypush(), SWITCH_STATUS_SUCCESS, switch_thread_create(), SWITCH_THREAD_STACKSIZE, switch_threadattr_create(), switch_threadattr_priority_increase(), switch_threadattr_stacksize_set(), switch_yield, SYSTEM_RUNNING, and THRUNTIME_POOL.
Referenced by switch_event_create_pres_in_detailed().
01768 { 01769 01770 switch_assert(BLOCK != NULL); 01771 switch_assert(RUNTIME_POOL != NULL); 01772 switch_assert(EVENT_QUEUE_MUTEX != NULL); 01773 switch_assert(RUNTIME_POOL != NULL); 01774 01775 if (SYSTEM_RUNNING <= 0) { 01776 /* sorry we're closed */ 01777 switch_event_destroy(event); 01778 return SWITCH_STATUS_SUCCESS; 01779 } 01780 01781 if (user_data) { 01782 (*event)->event_user_data = user_data; 01783 } 01784 01785 if (!EVENT_QUEUE_THREADS[(*event)->priority] && (*event)->priority < 3) { 01786 switch_threadattr_t *thd_attr; 01787 01788 switch_queue_create(&EVENT_QUEUE[(*event)->priority], POOL_COUNT_MAX + 10, THRUNTIME_POOL); 01789 switch_threadattr_create(&thd_attr, THRUNTIME_POOL); 01790 switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE); 01791 switch_threadattr_priority_increase(thd_attr); 01792 switch_thread_create(&EVENT_QUEUE_THREADS[(*event)->priority], thd_attr, switch_event_thread, EVENT_QUEUE[(*event)->priority], RUNTIME_POOL); 01793 } 01794 01795 for (;;) { 01796 if (switch_queue_trypush(EVENT_QUEUE[(*event)->priority], *event) == SWITCH_STATUS_SUCCESS) { 01797 goto end; 01798 } 01799 01800 01801 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Event queue is full!\n"); 01802 switch_yield(100000); 01803 } 01804 01805 end: 01806 01807 *event = NULL; 01808 01809 return SWITCH_STATUS_SUCCESS; 01810 }
| switch_status_t switch_event_free_subclass_detailed | ( | const char * | owner, | |
| const char * | subclass_name | |||
| ) |
Definition at line 412 of file switch_event.c.
References switch_event_subclass::bind, CUSTOM_HASH, FREE, switch_event_subclass::name, switch_event_subclass::owner, RUNTIME_POOL, RWLOCK, switch_assert, SWITCH_CHANNEL_LOG, switch_core_hash_delete(), switch_core_hash_find(), SWITCH_LOG_NOTICE, switch_log_printf(), SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, switch_thread_rwlock_unlock(), and switch_thread_rwlock_wrlock().
00413 { 00414 switch_event_subclass_t *subclass; 00415 switch_status_t status = SWITCH_STATUS_FALSE; 00416 00417 switch_assert(RUNTIME_POOL != NULL); 00418 switch_assert(CUSTOM_HASH != NULL); 00419 00420 if ((subclass = switch_core_hash_find(CUSTOM_HASH, subclass_name))) { 00421 if (!strcmp(owner, subclass->owner)) { 00422 switch_thread_rwlock_wrlock(RWLOCK); 00423 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Subclass reservation deleted for %s:%s\n", owner, subclass_name); 00424 switch_core_hash_delete(CUSTOM_HASH, subclass_name); 00425 FREE(subclass->owner); 00426 FREE(subclass->name); 00427 FREE(subclass); 00428 status = SWITCH_STATUS_SUCCESS; 00429 switch_thread_rwlock_unlock(RWLOCK); 00430 } else { 00431 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Subclass reservation %s inuse by listeners, detaching..\n", subclass_name); 00432 subclass->bind = 1; 00433 } 00434 } 00435 00436 return status; 00437 }
| char* switch_event_get_body | ( | switch_event_t * | event | ) |
Retrieve the body value from an event.
| event | the event to read the body from |
Definition at line 788 of file switch_event.c.
Referenced by Event::getBody(), play_and_detect_input_callback(), and switch_ivr_parse_event().
00789 { 00790 return (event ? event->body : NULL); 00791 }
| _Ret_opt_z_ char* switch_event_get_header_idx | ( | switch_event_t * | event, | |
| const char * | header_name, | |||
| int | idx | |||
| ) |
Definition at line 767 of file switch_event.c.
References switch_event_header::array, switch_event_get_header_ptr(), and switch_event_header::value.
Referenced by switch_channel_get_variable_dup(), and switch_event_expand_headers_check().
00768 { 00769 switch_event_header_t *hp; 00770 00771 if ((hp = switch_event_get_header_ptr(event, header_name))) { 00772 if (idx > -1) { 00773 if (idx < hp->idx) { 00774 return hp->array[idx]; 00775 } else { 00776 return NULL; 00777 } 00778 } 00779 00780 return hp->value; 00781 } else if (!strcmp(header_name, "_body")) { 00782 return event->body; 00783 } 00784 00785 return NULL; 00786 }
| switch_event_header_t* switch_event_get_header_ptr | ( | switch_event_t * | event, | |
| const char * | header_name | |||
| ) |
Retrieve a header value from an event.
| event | the event to read the header from | |
| header_name | the name of the header to read |
Definition at line 746 of file switch_event.c.
References switch_event_header::hash, switch_event_header::name, switch_event_header::next, switch_assert, and switch_ci_hashfunc_default().
Referenced by switch_event_base_add_header(), and switch_event_get_header_idx().
00747 { 00748 switch_event_header_t *hp; 00749 switch_ssize_t hlen = -1; 00750 unsigned long hash = 0; 00751 00752 switch_assert(event); 00753 00754 if (!header_name) 00755 return NULL; 00756 00757 hash = switch_ci_hashfunc_default(header_name, &hlen); 00758 00759 for (hp = event->headers; hp; hp = hp->next) { 00760 if ((!hp->hash || hash == hp->hash) && !strcasecmp(hp->name, header_name)) { 00761 return hp; 00762 } 00763 } 00764 return NULL; 00765 }
| switch_status_t switch_event_init | ( | switch_memory_pool_t * | pool | ) |
Start the eventing system.
| pool | the memory pool to use for the event system (creates a new one if NULL) |
Definition at line 608 of file switch_event.c.
References BLOCK, CUSTOM_HASH, DISPATCH_QUEUE_LEN, EVENT_QUEUE_MUTEX, guess_ip_v4, guess_ip_v6, launch_dispatch_threads(), MAX_DISPATCH, POOL_LOCK, RUNTIME_POOL, RWLOCK, switch_assert, SWITCH_CHANNEL_LOG, switch_cond_next(), switch_core_cpu_count(), switch_core_hash_init, switch_find_local_ip(), SWITCH_LOG_INFO, switch_log_printf(), switch_mutex_init(), switch_mutex_lock(), SWITCH_MUTEX_NESTED, switch_mutex_unlock(), switch_queue_create(), SWITCH_STATUS_SUCCESS, switch_thread_rwlock_create(), SYSTEM_RUNNING, THREAD_COUNT, and THRUNTIME_POOL.
Referenced by switch_core_init().
00609 { 00610 //switch_threadattr_t *thd_attr; 00611 00612 /* 00613 This statement doesn't do anything commenting it out for now. 00614 00615 switch_assert(switch_arraylen(EVENT_NAMES) == SWITCH_EVENT_ALL + 1); 00616 */ 00617 00618 /* don't need any more dispatch threads than we have CPU's*/ 00619 MAX_DISPATCH = switch_core_cpu_count() + 1; 00620 00621 00622 switch_assert(pool != NULL); 00623 THRUNTIME_POOL = RUNTIME_POOL = pool; 00624 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Activate Eventing Engine.\n"); 00625 switch_thread_rwlock_create(&RWLOCK, RUNTIME_POOL); 00626 switch_mutex_init(&BLOCK, SWITCH_MUTEX_NESTED, RUNTIME_POOL); 00627 switch_mutex_init(&POOL_LOCK, SWITCH_MUTEX_NESTED, RUNTIME_POOL); 00628 switch_mutex_init(&EVENT_QUEUE_MUTEX, SWITCH_MUTEX_NESTED, RUNTIME_POOL); 00629 switch_core_hash_init(&CUSTOM_HASH, RUNTIME_POOL); 00630 00631 switch_mutex_lock(EVENT_QUEUE_MUTEX); 00632 SYSTEM_RUNNING = -1; 00633 switch_mutex_unlock(EVENT_QUEUE_MUTEX); 00634 00635 //switch_threadattr_create(&thd_attr, pool); 00636 switch_find_local_ip(guess_ip_v4, sizeof(guess_ip_v4), NULL, AF_INET); 00637 switch_find_local_ip(guess_ip_v6, sizeof(guess_ip_v6), NULL, AF_INET6); 00638 00639 00640 //switch_queue_create(&EVENT_QUEUE[0], POOL_COUNT_MAX + 10, THRUNTIME_POOL); 00641 //switch_queue_create(&EVENT_QUEUE[1], POOL_COUNT_MAX + 10, THRUNTIME_POOL); 00642 //switch_queue_create(&EVENT_QUEUE[2], POOL_COUNT_MAX + 10, THRUNTIME_POOL); 00643 #ifdef SWITCH_EVENT_RECYCLE 00644 switch_queue_create(&EVENT_RECYCLE_QUEUE, 250000, THRUNTIME_POOL); 00645 switch_queue_create(&EVENT_HEADER_RECYCLE_QUEUE, 250000, THRUNTIME_POOL); 00646 #endif 00647 00648 //switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE); 00649 //switch_threadattr_priority_increase(thd_attr); 00650 00651 launch_dispatch_threads(1, DISPATCH_QUEUE_LEN, RUNTIME_POOL); 00652 //switch_thread_create(&EVENT_QUEUE_THREADS[0], thd_attr, switch_event_thread, EVENT_QUEUE[0], RUNTIME_POOL); 00653 //switch_thread_create(&EVENT_QUEUE_THREADS[1], thd_attr, switch_event_thread, EVENT_QUEUE[1], RUNTIME_POOL); 00654 //switch_thread_create(&EVENT_QUEUE_THREADS[2], thd_attr, switch_event_thread, EVENT_QUEUE[2], RUNTIME_POOL); 00655 00656 while (!THREAD_COUNT) { 00657 switch_cond_next(); 00658 } 00659 00660 00661 switch_mutex_lock(EVENT_QUEUE_MUTEX); 00662 SYSTEM_RUNNING = 1; 00663 switch_mutex_unlock(EVENT_QUEUE_MUTEX); 00664 00665 return SWITCH_STATUS_SUCCESS; 00666 }
| void switch_event_merge | ( | switch_event_t * | event, | |
| switch_event_t * | tomerge | |||
| ) |
Definition at line 1216 of file switch_event.c.
References switch_event_header::array, switch_event_header::idx, switch_event_header::name, switch_event_header::next, switch_assert, switch_event_add_header_string(), SWITCH_STACK_BOTTOM, SWITCH_STACK_PUSH, and switch_event_header::value.
01217 { 01218 switch_event_header_t *hp; 01219 01220 switch_assert(tomerge && event); 01221 01222 for (hp = tomerge->headers; hp; hp = hp->next) { 01223 if (hp->idx) { 01224 int i; 01225 01226 for(i = 0; i < hp->idx; i++) { 01227 switch_event_add_header_string(event, SWITCH_STACK_PUSH, hp->name, hp->array[i]); 01228 } 01229 } else { 01230 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, hp->name, hp->value); 01231 } 01232 } 01233 }
| const char* switch_event_name | ( | switch_event_types_t | event | ) |
Render the name of an event id enumeration.
| event | the event id to render the name of |
Definition at line 388 of file switch_event.c.
References BLOCK, EVENT_NAMES, RUNTIME_POOL, and switch_assert.
Referenced by Event::getType(), switch_event_prep_for_delivery_detailed(), switch_event_unbind(), and switch_event_unbind_callback().
00389 { 00390 switch_assert(BLOCK != NULL); 00391 switch_assert(RUNTIME_POOL != NULL); 00392 00393 return EVENT_NAMES[event]; 00394 }
| void switch_event_prep_for_delivery_detailed | ( | const char * | file, | |
| const char * | func, | |||
| int | line, | |||
| switch_event_t * | event | |||
| ) |
Definition at line 1734 of file switch_event.c.
References EVENT_QUEUE_MUTEX, EVENT_SEQUENCE_NR, guess_ip_v4, guess_ip_v6, switch_core_get_hostname(), switch_core_get_switchname(), switch_core_get_uuid(), switch_cut_path(), switch_event_add_header(), switch_event_add_header_string(), switch_event_name(), switch_micro_time_now(), switch_mutex_lock(), switch_mutex_unlock(), switch_rfc822_date(), SWITCH_STACK_BOTTOM, switch_strftime_nocheck(), switch_time_exp_lt(), and SWITCH_UINT64_T_FMT.
Referenced by switch_event_create_subclass_detailed().
01735 { 01736 switch_time_exp_t tm; 01737 char date[80] = ""; 01738 switch_size_t retsize; 01739 switch_time_t ts = switch_micro_time_now(); 01740 01741 switch_mutex_lock(EVENT_QUEUE_MUTEX); 01742 EVENT_SEQUENCE_NR++; 01743 switch_mutex_unlock(EVENT_QUEUE_MUTEX); 01744 01745 01746 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Event-Name", switch_event_name(event->event_id)); 01747 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Core-UUID", switch_core_get_uuid()); 01748 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FreeSWITCH-Hostname", switch_core_get_hostname()); 01749 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FreeSWITCH-Switchname", switch_core_get_switchname()); 01750 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FreeSWITCH-IPv4", guess_ip_v4); 01751 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FreeSWITCH-IPv6", guess_ip_v6); 01752 01753 switch_time_exp_lt(&tm, ts); 01754 switch_strftime_nocheck(date, &retsize, sizeof(date), "%Y-%m-%d %T", &tm); 01755 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Event-Date-Local", date); 01756 switch_rfc822_date(date, ts); 01757 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Event-Date-GMT", date); 01758 switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Event-Date-Timestamp", "%" SWITCH_UINT64_T_FMT, (uint64_t) ts); 01759 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Event-Calling-File", switch_cut_path(file)); 01760 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Event-Calling-Function", func); 01761 switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Event-Calling-Line-Number", "%d", line); 01762 switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Event-Sequence", "%" SWITCH_UINT64_T_FMT, (uint64_t) EVENT_SEQUENCE_NR); 01763 01764 01765 }
| switch_status_t switch_event_rename_header | ( | switch_event_t * | event, | |
| const char * | header_name, | |||
| const char * | new_header_name | |||
| ) |
Definition at line 717 of file switch_event.c.
References DUP, FREE, switch_event_header::hash, switch_event_header::name, switch_event_header::next, switch_assert, switch_ci_hashfunc_default(), SWITCH_STATUS_FALSE, and SWITCH_STATUS_SUCCESS.
00718 { 00719 switch_event_header_t *hp; 00720 switch_ssize_t hlen = -1; 00721 unsigned long hash = 0; 00722 int x = 0; 00723 00724 switch_assert(event); 00725 00726 if (!header_name) { 00727 return SWITCH_STATUS_FALSE; 00728 } 00729 00730 hash = switch_ci_hashfunc_default(header_name, &hlen); 00731 00732 for (hp = event->headers; hp; hp = hp->next) { 00733 if ((!hp->hash || hash == hp->hash) && !strcasecmp(hp->name, header_name)) { 00734 FREE(hp->name); 00735 hp->name = DUP(new_header_name); 00736 hlen = -1; 00737 hp->hash = switch_ci_hashfunc_default(hp->name, &hlen); 00738 x++; 00739 } 00740 } 00741 00742 return x ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_FALSE; 00743 }
| switch_status_t switch_event_reserve_subclass_detailed | ( | const char * | owner, | |
| const char * | subclass_name | |||
| ) |
Reserve a subclass name for private use with a custom event.
| owner | the owner of the event name | |
| subclass_name | the name to reserve |
Definition at line 439 of file switch_event.c.
References switch_event_subclass::bind, CUSTOM_HASH, DUP, RUNTIME_POOL, switch_assert, switch_core_hash_find(), switch_core_hash_insert(), SWITCH_STATUS_INUSE, SWITCH_STATUS_SUCCESS, and switch_zmalloc.
Referenced by switch_event_bind_removable().
00440 { 00441 switch_event_subclass_t *subclass; 00442 00443 switch_assert(RUNTIME_POOL != NULL); 00444 switch_assert(CUSTOM_HASH != NULL); 00445 00446 if ((subclass = switch_core_hash_find(CUSTOM_HASH, subclass_name))) { 00447 /* a listener reserved it for us, now we can lock it so nobody else can have it */ 00448 if (subclass->bind) { 00449 subclass->bind = 0; 00450 return SWITCH_STATUS_SUCCESS; 00451 } 00452 return SWITCH_STATUS_INUSE; 00453 } 00454 00455 switch_zmalloc(subclass, sizeof(*subclass)); 00456 00457 subclass->owner = DUP(owner); 00458 subclass->name = DUP(subclass_name); 00459 00460 switch_core_hash_insert(CUSTOM_HASH, subclass->name, subclass); 00461 00462 return SWITCH_STATUS_SUCCESS; 00463 }
| switch_xml_t switch_status_t switch_event_running | ( | void | ) |
Determine if the event system has been initilized.
Definition at line 383 of file switch_event.c.
References SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, and SYSTEM_RUNNING.
Referenced by switch_console_printf(), and switch_log_vprintf().
00384 { 00385 return SYSTEM_RUNNING ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_FALSE; 00386 }
| switch_status_t switch_event_serialize | ( | switch_event_t * | event, | |
| char ** | str, | |||
| switch_bool_t | encode | |||
| ) |
Render a string representation of an event sutable for printing or network transport.
| event | the event to render | |
| str | a string pointer to point at the allocated data | |
| encode | url encode the headers |
Definition at line 1329 of file switch_event.c.
References switch_event_header::array, buf, switch_event_header::idx, switch_event_header::name, switch_event_header::next, switch_safe_free, switch_snprintf(), SWITCH_STATUS_SUCCESS, switch_url_encode(), and switch_event_header::value.
Referenced by Event::serialize(), and switch_core_session_thread().
01330 { 01331 switch_size_t len = 0; 01332 switch_event_header_t *hp; 01333 switch_size_t llen = 0, dlen = 0, blocksize = 512, encode_len = 1536, new_len = 0; 01334 char *buf; 01335 char *encode_buf = NULL; /* used for url encoding of variables to make sure unsafe things stay out of the serialized copy */ 01336 01337 *str = NULL; 01338 01339 dlen = blocksize * 2; 01340 01341 if (!(buf = malloc(dlen))) { 01342 abort(); 01343 } 01344 01345 /* go ahead and give ourselves some space to work with, should save a few reallocs */ 01346 if (!(encode_buf = malloc(encode_len))) { 01347 abort(); 01348 } 01349 01350 /* switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "hit serialized!.\n"); */ 01351 for (hp = event->headers; hp; hp = hp->next) { 01352 /* 01353 * grab enough memory to store 3x the string (url encode takes one char and turns it into %XX) 01354 * so we could end up with a string that is 3 times the originals length, unlikely but rather 01355 * be safe than destroy the string, also add one for the null. And try to be smart about using 01356 * the memory, allocate and only reallocate if we need more. This avoids an alloc, free CPU 01357 * destroying loop. 01358 */ 01359 01360 if (hp->idx) { 01361 int i; 01362 new_len = 0; 01363 for(i = 0; i < hp->idx; i++) { 01364 new_len += (strlen(hp->array[i]) * 3) + 1; 01365 } 01366 } else { 01367 new_len = (strlen(hp->value) * 3) + 1; 01368 } 01369 01370 if (encode_len < new_len) { 01371 char *tmp; 01372 01373 /* keep track of the size of our allocation */ 01374 encode_len = new_len; 01375 01376 if (!(tmp = realloc(encode_buf, encode_len))) { 01377 abort(); 01378 } 01379 01380 encode_buf = tmp; 01381 } 01382 01383 /* handle any bad things in the string like newlines : etc that screw up the serialized format */ 01384 01385 01386 if (encode) { 01387 switch_url_encode(hp->value, encode_buf, encode_len); 01388 } else { 01389 switch_snprintf(encode_buf, encode_len, "[%s]", hp->value); 01390 } 01391 01392 01393 llen = strlen(hp->name) + strlen(encode_buf) + 8; 01394 01395 if ((len + llen) > dlen) { 01396 char *m = buf; 01397 dlen += (blocksize + (len + llen)); 01398 if (!(buf = realloc(buf, dlen))) { 01399 buf = m; 01400 abort(); 01401 } 01402 } 01403 01404 switch_snprintf(buf + len, dlen - len, "%s: %s\n", hp->name, *encode_buf == '\0' ? "_undef_" : encode_buf); 01405 len = strlen(buf); 01406 } 01407 01408 /* we are done with the memory we used for encoding, give it back */ 01409 switch_safe_free(encode_buf); 01410 01411 if (event->body) { 01412 int blen = (int) strlen(event->body); 01413 llen = blen; 01414 01415 if (blen) { 01416 llen += 25; 01417 } else { 01418 llen += 5; 01419 } 01420 01421 if ((len + llen) > dlen) { 01422 char *m = buf; 01423 dlen += (blocksize + (len + llen)); 01424 if (!(buf = realloc(buf, dlen))) { 01425 buf = m; 01426 abort(); 01427 } 01428 } 01429 01430 if (blen) { 01431 switch_snprintf(buf + len, dlen - len, "Content-Length: %d\n\n%s", blen, event->body); 01432 } else { 01433 switch_snprintf(buf + len, dlen - len, "\n"); 01434 } 01435 } else { 01436 switch_snprintf(buf + len, dlen - len, "\n"); 01437 } 01438 01439 *str = buf; 01440 01441 return SWITCH_STATUS_SUCCESS; 01442 }
| switch_status_t switch_event_serialize_json | ( | switch_event_t * | event, | |
| char ** | str | |||
| ) |
Definition at line 1599 of file switch_event.c.
References switch_event_header::array, cJSON_AddItemToArray(), cJSON_AddItemToObject(), cJSON_CreateArray(), cJSON_CreateObject(), cJSON_CreateString(), cJSON_Delete(), cJSON_Print(), switch_event_header::idx, switch_event_header::name, switch_event_header::next, switch_snprintf(), SWITCH_STATUS_SUCCESS, and switch_event_header::value.
Referenced by Event::serialize().
01600 { 01601 switch_event_header_t *hp; 01602 cJSON *cj; 01603 01604 *str = NULL; 01605 01606 cj = cJSON_CreateObject(); 01607 01608 for (hp = event->headers; hp; hp = hp->next) { 01609 if (hp->idx) { 01610 cJSON *a = cJSON_CreateArray(); 01611 int i; 01612 01613 for(i = 0; i < hp->idx; i++) { 01614 cJSON_AddItemToArray(a, cJSON_CreateString(hp->array[i])); 01615 } 01616 01617 cJSON_AddItemToObject(cj, hp->name, a); 01618 01619 } else { 01620 cJSON_AddItemToObject(cj, hp->name, cJSON_CreateString(hp->value)); 01621 } 01622 } 01623 01624 if (event->body) { 01625 int blen = (int) strlen(event->body); 01626 char tmp[25]; 01627 01628 switch_snprintf(tmp, sizeof(tmp), "%d", blen); 01629 01630 cJSON_AddItemToObject(cj, "Content-Length", cJSON_CreateString(tmp)); 01631 cJSON_AddItemToObject(cj, "_body", cJSON_CreateString(event->body)); 01632 } 01633 01634 *str = cJSON_Print(cj); 01635 cJSON_Delete(cj); 01636 01637 return SWITCH_STATUS_SUCCESS; 01638 }
| switch_status_t switch_status_t switch_event_set_body | ( | switch_event_t * | event, | |
| const char * | body | |||
| ) |
Definition at line 1134 of file switch_event.c.
References DUP, switch_safe_free, and SWITCH_STATUS_SUCCESS.
Referenced by switch_event_base_add_header().
01135 { 01136 switch_safe_free(event->body); 01137 01138 if (body) { 01139 event->body = DUP(body); 01140 } 01141 01142 return SWITCH_STATUS_SUCCESS; 01143 }
| switch_status_t switch_event_set_priority | ( | switch_event_t * | event, | |
| switch_priority_t | priority | |||
| ) |
Set the priority of an event.
| event | the event to set the priority on | |
| priority | the event priority |
Definition at line 710 of file switch_event.c.
References switch_event_add_header_string(), switch_priority_name(), SWITCH_STACK_TOP, and SWITCH_STATUS_SUCCESS.
Referenced by Event::setPriority().
00711 { 00712 event->priority = priority; 00713 switch_event_add_header_string(event, SWITCH_STACK_TOP, "priority", switch_priority_name(priority)); 00714 return SWITCH_STATUS_SUCCESS; 00715 }
| switch_status_t switch_status_t switch_event_set_subclass_name | ( | switch_event_t * | event, | |
| const char * | subclass_name | |||
| ) |
Definition at line 1114 of file switch_event.c.
References DUP, switch_event_add_header_string(), switch_event_del_header, switch_safe_free, SWITCH_STACK_BOTTOM, SWITCH_STATUS_GENERR, and SWITCH_STATUS_SUCCESS.
01115 { 01116 if (!event || !subclass_name) 01117 return SWITCH_STATUS_GENERR; 01118 01119 switch_safe_free(event->subclass_name); 01120 event->subclass_name = DUP(subclass_name); 01121 switch_event_del_header(event, "Event-Subclass"); 01122 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Event-Subclass", event->subclass_name); 01123 return SWITCH_STATUS_SUCCESS; 01124 }
| switch_status_t switch_event_shutdown | ( | void | ) |
Stop the eventing system.
Definition at line 490 of file switch_event.c.
References CUSTOM_HASH, EVENT_DISPATCH_QUEUE, EVENT_DISPATCH_QUEUE_THREADS, EVENT_QUEUE, EVENT_QUEUE_MUTEX, EVENT_QUEUE_THREADS, FREE, NUMBER_OF_QUEUES, SOFT_MAX_DISPATCH, SWITCH_CHANNEL_LOG, switch_cond_next(), switch_core_hash_destroy(), switch_core_memory_reclaim_events(), switch_event_destroy(), switch_hash_first(), switch_hash_next(), switch_hash_this(), SWITCH_LOG_CONSOLE, switch_log_printf(), switch_mutex_lock(), switch_mutex_unlock(), switch_queue_interrupt_all(), switch_queue_trypop(), switch_queue_trypush(), SWITCH_STATUS_SUCCESS, switch_thread_join(), SYSTEM_RUNNING, and THREAD_COUNT.
Referenced by switch_core_destroy().
00491 { 00492 uint32_t x = 0; 00493 int last = 0; 00494 switch_hash_index_t *hi; 00495 const void *var; 00496 void *val; 00497 00498 switch_mutex_lock(EVENT_QUEUE_MUTEX); 00499 SYSTEM_RUNNING = 0; 00500 switch_mutex_unlock(EVENT_QUEUE_MUTEX); 00501 00502 for (x = 0; x < 3; x++) { 00503 if (EVENT_QUEUE[x]) { 00504 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Stopping event queue %d\n", x); 00505 switch_queue_trypush(EVENT_QUEUE[x], NULL); 00506 switch_queue_interrupt_all(EVENT_QUEUE[x]); 00507 } 00508 } 00509 00510 for (x = 0; x < SOFT_MAX_DISPATCH; x++) { 00511 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Stopping dispatch queue %d\n", x); 00512 switch_queue_trypush(EVENT_DISPATCH_QUEUE[x], NULL); 00513 switch_queue_interrupt_all(EVENT_DISPATCH_QUEUE[x]); 00514 } 00515 00516 while (x < 10000 && THREAD_COUNT) { 00517 switch_cond_next(); 00518 if (THREAD_COUNT == last) { 00519 x++; 00520 } 00521 last = THREAD_COUNT; 00522 } 00523 00524 for (x = 0; x < SOFT_MAX_DISPATCH; x++) { 00525 void *pop = NULL; 00526 switch_event_t *event = NULL; 00527 switch_status_t st; 00528 00529 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Stopping dispatch thread %d\n", x); 00530 switch_thread_join(&st, EVENT_DISPATCH_QUEUE_THREADS[x]); 00531 00532 while (switch_queue_trypop(EVENT_DISPATCH_QUEUE[x], &pop) == SWITCH_STATUS_SUCCESS && pop) { 00533 event = (switch_event_t *) pop; 00534 switch_event_destroy(&event); 00535 } 00536 } 00537 00538 for (x = 0; x < NUMBER_OF_QUEUES; x++) { 00539 void *pop = NULL; 00540 switch_event_t *event = NULL; 00541 switch_status_t st; 00542 00543 if (EVENT_QUEUE_THREADS[x]) { 00544 00545 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Stopping queue thread %d\n", x); 00546 switch_thread_join(&st, EVENT_QUEUE_THREADS[x]); 00547 00548 while (switch_queue_trypop(EVENT_QUEUE[x], &pop) == SWITCH_STATUS_SUCCESS && pop) { 00549 event = (switch_event_t *) pop; 00550 switch_event_destroy(&event); 00551 } 00552 } 00553 } 00554 00555 for (hi = switch_hash_first(NULL, CUSTOM_HASH); hi; hi = switch_hash_next(hi)) { 00556 switch_event_subclass_t *subclass; 00557 switch_hash_this(hi, &var, NULL, &val); 00558 if ((subclass = (switch_event_subclass_t *) val)) { 00559 FREE(subclass->name); 00560 FREE(subclass->owner); 00561 FREE(subclass); 00562 } 00563 } 00564 00565 switch_core_hash_destroy(&CUSTOM_HASH); 00566 switch_core_memory_reclaim_events(); 00567 00568 return SWITCH_STATUS_SUCCESS; 00569 }
| switch_status_t switch_event_unbind | ( | switch_event_node_t ** | node | ) |
Unbind a bound event consumer.
| node | node to unbind |
Definition at line 1918 of file switch_event.c.
References BLOCK, switch_event_node::event_id, EVENT_NODES, FREE, switch_event_node::id, switch_event_node::next, RWLOCK, switch_event_node::subclass_name, SWITCH_CHANNEL_LOG, switch_event_name(), SWITCH_LOG_NOTICE, switch_log_printf(), switch_mutex_lock(), switch_mutex_unlock(), SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, switch_thread_rwlock_unlock(), and switch_thread_rwlock_wrlock().
Referenced by switch_core_sqldb_stop(), SWITCH_MODULE_SHUTDOWN_FUNCTION(), and EventConsumer::~EventConsumer().
01919 { 01920 switch_event_node_t *n, *np, *lnp = NULL; 01921 switch_status_t status = SWITCH_STATUS_FALSE; 01922 01923 n = *node; 01924 01925 if (!n) { 01926 return status; 01927 } 01928 01929 switch_thread_rwlock_wrlock(RWLOCK); 01930 switch_mutex_lock(BLOCK); 01931 /* <LOCKED> ----------------------------------------------- */ 01932 for (np = EVENT_NODES[n->event_id]; np; np = np->next) { 01933 if (np == n) { 01934 if (lnp) { 01935 lnp->next = n->next; 01936 } else { 01937 EVENT_NODES[n->event_id] = n->next; 01938 } 01939 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Event Binding deleted for %s:%s\n", n->id, switch_event_name(n->event_id)); 01940 FREE(n->subclass_name); 01941 FREE(n->id); 01942 FREE(n); 01943 *node = NULL; 01944 status = SWITCH_STATUS_SUCCESS; 01945 break; 01946 } 01947 lnp = np; 01948 } 01949 switch_mutex_unlock(BLOCK); 01950 switch_thread_rwlock_unlock(RWLOCK); 01951 /* </LOCKED> ----------------------------------------------- */ 01952 01953 return status; 01954 }
| switch_status_t switch_event_unbind_callback | ( | switch_event_callback_t | callback | ) |
Definition at line 1877 of file switch_event.c.
References BLOCK, switch_event_node::callback, switch_event_node::event_id, EVENT_NODES, FREE, switch_event_node::id, switch_event_node::next, RWLOCK, switch_event_node::subclass_name, SWITCH_CHANNEL_LOG, SWITCH_EVENT_ALL, switch_event_name(), SWITCH_LOG_NOTICE, switch_log_printf(), switch_mutex_lock(), SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, and switch_thread_rwlock_wrlock().
01878 { 01879 switch_event_node_t *n, *np, *lnp = NULL; 01880 switch_status_t status = SWITCH_STATUS_FALSE; 01881 int id; 01882 01883 switch_thread_rwlock_wrlock(RWLOCK); 01884 switch_mutex_lock(BLOCK); 01885 /* <LOCKED> ----------------------------------------------- */ 01886 for (id = 0; id <= SWITCH_EVENT_ALL; id++) { 01887 lnp = NULL; 01888 01889 for (np = EVENT_NODES[id]; np;) { 01890 n = np; 01891 np = np->next; 01892 if (n->callback == callback) { 01893 if (lnp) { 01894 lnp->next = n->next; 01895 } else { 01896 EVENT_NODES[n->event_id] = n->next; 01897 } 01898 01899 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Event Binding deleted for %s:%s\n", n->id, switch_event_name(n->event_id)); 01900 FREE(n->subclass_name); 01901 FREE(n->id); 01902 FREE(n); 01903 status = SWITCH_STATUS_SUCCESS; 01904 } else { 01905 lnp = n; 01906 } 01907 } 01908 } 01909 switch_mutex_unlock(BLOCK); 01910 switch_thread_rwlock_unlock(RWLOCK); 01911 /* </LOCKED> ----------------------------------------------- */ 01912 01913 return status; 01914 }
| switch_xml_t switch_event_xmlize | ( | switch_event_t * | event, | |
| const char * | fmt, | |||
| ... | ||||
| ) |
Render a XML representation of an event sutable for printing or network transport.
| event | the event to render | |
| fmt | optional body of the event (varargs see standard sprintf family) |
Referenced by Event::serialize().
| switch_status_t switch_name_event | ( | const char * | name, | |
| switch_event_types_t * | type | |||
| ) |
return the event id that matches a given event name
| name | the name of the event | |
| type | the event id to return |
Definition at line 396 of file switch_event.c.
References BLOCK, EVENT_NAMES, RUNTIME_POOL, switch_assert, SWITCH_EVENT_ALL, SWITCH_STATUS_FALSE, and SWITCH_STATUS_SUCCESS.
Referenced by EventConsumer::bind(), Event::Event(), and switch_event_create_json().
00397 { 00398 switch_event_types_t x; 00399 switch_assert(BLOCK != NULL); 00400 switch_assert(RUNTIME_POOL != NULL); 00401 00402 for (x = 0; x <= SWITCH_EVENT_ALL; x++) { 00403 if ((strlen(name) > 13 && !strcasecmp(name + 13, EVENT_NAMES[x])) || !strcasecmp(name, EVENT_NAMES[x])) { 00404 *type = x; 00405 return SWITCH_STATUS_SUCCESS; 00406 } 00407 } 00408 00409 return SWITCH_STATUS_FALSE; 00410 }
1.4.7