#include <switch.h>
Include dependency graph for switch_core.h:
This graph shows which files directly or indirectly include this file:
Go to the source code of this file.
Data Structures | |
| struct | switch_core_time_duration |
| struct | switch_app_log |
| struct | switch_core_session_message |
| A message object designed to allow unlike technologies to exchange data. More... | |
| struct | switch_core_thread_session |
| A generic object to pass as a thread's session object to allow mutiple arguements and a pool. More... | |
| union | switch_cache_db_native_handle_t |
| struct | switch_cache_db_core_db_options_t |
| struct | switch_cache_db_odbc_options_t |
| union | switch_cache_db_connection_options_t |
Defines | |
| #define | SWITCH_MAX_CORE_THREAD_SESSION_OBJS 128 |
| #define | SWITCH_MAX_STREAMS 128 |
| #define | MESSAGE_STAMP_FFL(_m) _m->_file = __FILE__; _m->_func = __SWITCH_FUNC__; _m->_line = __LINE__ |
| #define | MESSAGE_STRING_ARG_MAX 10 |
| #define | switch_core_session_get_name(_s) switch_channel_get_name(switch_core_session_get_channel(_s)) |
| #define | switch_core_media_bug_remove_all(_s) switch_core_media_bug_remove_all_function(_s, NULL) |
| #define | switch_core_new_memory_pool(p) switch_core_perform_new_memory_pool(p, __FILE__, __SWITCH_FUNC__, __LINE__) |
| Create a new sub memory pool from the core's master pool. | |
| #define | switch_core_destroy_memory_pool(p) switch_core_perform_destroy_memory_pool(p, __FILE__, __SWITCH_FUNC__, __LINE__) |
| Returns a subpool back to the main pool. | |
| #define | switch_core_permanent_alloc(_memory) switch_core_perform_permanent_alloc(_memory, __FILE__, __SWITCH_FUNC__, __LINE__) |
| Allocate memory from the main pool with no intention of returning it. | |
| #define | switch_core_alloc(_pool, _mem) switch_core_perform_alloc(_pool, _mem, __FILE__, __SWITCH_FUNC__, __LINE__) |
| Allocate memory directly from a memory pool. | |
| #define | switch_core_session_alloc(_session, _memory) switch_core_perform_session_alloc(_session, _memory, __FILE__, __SWITCH_FUNC__, __LINE__) |
| Allocate memory from a session's pool. | |
| #define | switch_core_permanent_strdup(_todup) switch_core_perform_permanent_strdup(_todup, __FILE__, __SWITCH_FUNC__, __LINE__) |
| Copy a string using permanent memory allocation. | |
| #define | switch_core_session_strdup(_session, _todup) switch_core_perform_session_strdup(_session, _todup, __FILE__, __SWITCH_FUNC__, __LINE__) |
| Copy a string using memory allocation from a session's pool. | |
| #define | switch_core_strdup(_pool, _todup) switch_core_perform_strdup(_pool, _todup, __FILE__, __SWITCH_FUNC__, __LINE__) |
| Copy a string using memory allocation from a given pool. | |
| #define | switch_core_session_request(_ep, _d, _f, _p) switch_core_session_request_uuid(_ep, _d, _f, _p, NULL) |
| #define | switch_core_session_destroy(session) switch_core_session_perform_destroy(session, __FILE__, __SWITCH_FUNC__, __LINE__) |
| Destroy a session and return the memory pool to the core. | |
| #define | switch_core_session_execute_application(_a, _b, _c) switch_core_session_execute_application_get_flags(_a, _b, _c, NULL) |
| Execute an application on a session. | |
| #define | switch_core_service_session(_s) switch_core_service_session_av(_s, SWITCH_TRUE, SWITCH_FALSE) |
| #define | switch_core_session_receive_message(_session, _message) |
| #define | switch_core_session_kill_channel(session, sig) switch_core_session_perform_kill_channel(session, __FILE__, __SWITCH_FUNC__, __LINE__, sig) |
| Send a signal to a channel. | |
| #define | switch_core_hash_init(_hash, _pool) switch_core_hash_init_case(_hash, _pool, SWITCH_TRUE) |
| #define | switch_core_hash_init_nocase(_hash, _pool) switch_core_hash_init_case(_hash, _pool, SWITCH_FALSE) |
| #define | switch_core_codec_init(_codec, _codec_name, _fmtp, _rate, _ms, _channels, _flags, _codec_settings, _pool) switch_core_codec_init_with_bitrate(_codec, _codec_name, _fmtp, _rate, _ms, _channels, 0, _flags, _codec_settings, _pool) |
| Initialize a codec handle. | |
| #define | switch_core_file_open(_fh, _file_path, _channels, _rate, _flags, _pool) switch_core_perform_file_open(__FILE__, __SWITCH_FUNC__, __LINE__, _fh, _file_path, _channels, _rate, _flags, _pool) |
| Open a media file using file format modules. | |
| #define | switch_check_network_list_ip(_ip_str, _list_name) switch_check_network_list_ip_token(_ip_str, _list_name, NULL) |
| #define | CACHE_DB_LEN 256 |
| #define | switch_cache_db_get_db_handle(_a, _b, _c) _switch_cache_db_get_db_handle(_a, _b, _c, __FILE__, __SWITCH_FUNC__, __LINE__) |
| #define | switch_core_db_handle(_a) _switch_core_db_handle(_a, __FILE__, __SWITCH_FUNC__, __LINE__) |
Typedefs | |
| typedef switch_cache_db_handle | switch_cache_db_handle_t |
Enumerations | |
| enum | cache_db_flag_t { CDF_INUSE = (1 << 0), CDF_PRUNE = (1 << 1) } |
| enum | switch_cache_db_handle_type_t { SCDB_TYPE_CORE_DB, SCDB_TYPE_ODBC } |
Functions | |
| void | switch_core_session_sched_heartbeat (switch_core_session_t *session, uint32_t seconds) |
| void | switch_core_session_unsched_heartbeat (switch_core_session_t *session) |
| void | switch_core_session_enable_heartbeat (switch_core_session_t *session, uint32_t seconds) |
| void | switch_core_session_disable_heartbeat (switch_core_session_t *session) |
| switch_status_t | switch_core_media_bug_pop (switch_core_session_t *orig_session, const char *function, switch_media_bug_t **pop) |
| switch_status_t | switch_core_media_bug_exec_all (switch_core_session_t *orig_session, const char *function, switch_media_bug_exec_cb_t cb, void *user_data) |
| uint32_t | switch_core_media_bug_count (switch_core_session_t *orig_session, const char *function) |
| switch_status_t | switch_core_media_bug_add (_In_ switch_core_session_t *session, _In_ const char *function, _In_ const char *target, _In_ switch_media_bug_callback_t callback, _In_opt_ void *user_data, _In_ time_t stop_time, _In_ switch_media_bug_flag_t flags, _Out_ switch_media_bug_t **new_bug) |
| Add a media bug to the session. | |
| void | switch_core_media_bug_pause (switch_core_session_t *session) |
| Pause a media bug on the session. | |
| void | switch_core_media_bug_resume (switch_core_session_t *session) |
| Resume a media bug on the session. | |
| void | switch_core_media_bug_inuse (switch_media_bug_t *bug, switch_size_t *readp, switch_size_t *writep) |
| void * | switch_core_media_bug_get_user_data (_In_ switch_media_bug_t *bug) |
| Obtain private data from a media bug. | |
| switch_frame_t * | switch_core_media_bug_get_write_replace_frame (_In_ switch_media_bug_t *bug) |
| Obtain a replace frame from a media bug. | |
| void | switch_core_media_bug_set_write_replace_frame (_In_ switch_media_bug_t *bug, _In_ switch_frame_t *frame) |
| Set a return replace frame. | |
| switch_frame_t * | switch_core_media_bug_get_read_replace_frame (_In_ switch_media_bug_t *bug) |
| Obtain a replace frame from a media bug. | |
| void | switch_core_media_bug_set_read_demux_frame (_In_ switch_media_bug_t *bug, _In_ switch_frame_t *frame) |
| switch_core_session_t * | switch_core_media_bug_get_session (_In_ switch_media_bug_t *bug) |
| Obtain the session from a media bug. | |
| uint32_t | switch_core_media_bug_test_flag (_In_ switch_media_bug_t *bug, _In_ uint32_t flag) |
| Test for the existance of a flag on an media bug. | |
| uint32_t | switch_core_media_bug_set_flag (_In_ switch_media_bug_t *bug, _In_ uint32_t flag) |
| uint32_t | switch_core_media_bug_clear_flag (_In_ switch_media_bug_t *bug, _In_ uint32_t flag) |
| void | switch_core_media_bug_set_read_replace_frame (_In_ switch_media_bug_t *bug, _In_ switch_frame_t *frame) |
| Set a return replace frame. | |
| uint32_t | switch_core_cpu_count (void) |
| switch_status_t | switch_core_media_bug_remove (_In_ switch_core_session_t *session, _Inout_ switch_media_bug_t **bug) |
| Remove a media bug from the session. | |
| uint32_t | switch_core_media_bug_prune (switch_core_session_t *session) |
| switch_status_t | switch_core_media_bug_remove_callback (switch_core_session_t *session, switch_media_bug_callback_t callback) |
| Remove media bug callback. | |
| switch_status_t | switch_core_media_bug_close (_Inout_ switch_media_bug_t **bug) |
| Close and destroy a media bug. | |
| switch_status_t | switch_core_media_bug_remove_all_function (_In_ switch_core_session_t *session, const char *function) |
| Remove all media bugs from the session. | |
| switch_status_t | switch_core_media_bug_enumerate (switch_core_session_t *session, switch_stream_handle_t *stream) |
| switch_status_t | switch_core_media_bug_transfer_recordings (switch_core_session_t *orig_session, switch_core_session_t *new_session) |
| switch_status_t | switch_core_media_bug_read (_In_ switch_media_bug_t *bug, _In_ switch_frame_t *frame, switch_bool_t fill) |
| Read a frame from the bug. | |
| void | switch_core_media_bug_flush (_In_ switch_media_bug_t *bug) |
| Flush the read and write buffers for the bug. | |
| switch_status_t | switch_core_media_bug_flush_all (_In_ switch_core_session_t *session) |
| Flush the read/write buffers for all media bugs on the session. | |
| switch_status_t | switch_core_media_bug_set_pre_buffer_framecount (switch_media_bug_t *bug, uint32_t framecount) |
| switch_status_t | switch_core_port_allocator_new (_In_ switch_port_t start, _In_ switch_port_t end, _In_ switch_port_flag_t flags, _Out_ switch_core_port_allocator_t **new_allocator) |
| Initilize the port allocator. | |
| switch_status_t | switch_core_port_allocator_request_port (_In_ switch_core_port_allocator_t *alloc, _Out_ switch_port_t *port_ptr) |
| Get a port from the port allocator. | |
| switch_status_t | switch_core_port_allocator_free_port (_In_ switch_core_port_allocator_t *alloc, _In_ switch_port_t port) |
| Return unused port to the port allocator. | |
| void | switch_core_port_allocator_destroy (_Inout_ switch_core_port_allocator_t **alloc) |
| destroythe port allocator | |
| switch_status_t | switch_core_init (_In_ switch_core_flag_t flags, _In_ switch_bool_t console, _Out_ const char **err) |
| Initilize the core. | |
| switch_status_t | switch_core_init_and_modload (_In_ switch_core_flag_t flags, _In_ switch_bool_t console, _Out_ const char **err) |
| Initilize the core and load modules. | |
| uint32_t | switch_core_session_limit (_In_ uint32_t new_limit) |
| Set/Get Session Limit. | |
| uint32_t | switch_core_sessions_per_second (_In_ uint32_t new_limit) |
| Set/Get Session Rate Limit. | |
| switch_status_t | switch_core_destroy (void) |
| Destroy the core. | |
| switch_status_t | switch_core_session_io_read_lock (switch_core_session_t *session) |
| switch_status_t | switch_core_session_io_write_lock (switch_core_session_t *session) |
| switch_status_t | switch_core_session_io_rwunlock (switch_core_session_t *session) |
| switch_status_t | switch_core_session_read_lock (_In_ switch_core_session_t *session) |
| Acquire a read lock on the session. | |
| switch_status_t | switch_core_session_read_lock_hangup (_In_ switch_core_session_t *session) |
| Acquire a read lock on the session. | |
| void | switch_core_session_write_lock (_In_ switch_core_session_t *session) |
| Acquire a write lock on the session. | |
| void | switch_core_session_rwunlock (_In_ switch_core_session_t *session) |
| Unlock a read or write lock on as given session. | |
| int | switch_core_add_state_handler (_In_ const switch_state_handler_table_t *state_handler) |
| Add a global state handler. | |
| void | switch_core_remove_state_handler (_In_ const switch_state_handler_table_t *state_handler) |
| Remove a global state handler. | |
| const switch_state_handler_table_t * | switch_core_get_state_handler (_In_ int index) |
| Access a state handler. | |
| void | switch_core_memory_pool_tag (switch_memory_pool_t *pool, const char *tag) |
| switch_status_t | switch_core_perform_new_memory_pool (_Out_ switch_memory_pool_t **pool, _In_z_ const char *file, _In_z_ const char *func, _In_ int line) |
| int | switch_core_session_sync_clock (void) |
| switch_status_t | switch_core_perform_destroy_memory_pool (_Inout_ switch_memory_pool_t **pool, _In_z_ const char *file, _In_z_ const char *func, _In_ int line) |
| void | switch_core_memory_pool_set_data (switch_memory_pool_t *pool, const char *key, void *data) |
| void * | switch_core_memory_pool_get_data (switch_memory_pool_t *pool, const char *key) |
| void | switch_core_session_run (_In_ switch_core_session_t *session) |
| Start the session's state machine. | |
| unsigned int | switch_core_session_running (_In_ switch_core_session_t *session) |
| determine if the session's state machine is running | |
| unsigned int | switch_core_session_started (_In_ switch_core_session_t *session) |
| void * | switch_core_perform_permanent_alloc (_In_ switch_size_t memory, _In_z_ const char *file, _In_z_ const char *func, _In_ int line) |
| void * | switch_core_perform_alloc (_In_ switch_memory_pool_t *pool, _In_ switch_size_t memory, _In_z_ const char *file, _In_z_ const char *func, _In_ int line) |
| _Ret_ void * | switch_core_perform_session_alloc (_In_ switch_core_session_t *session, _In_ switch_size_t memory, const char *file, const char *func, int line) |
| char * | switch_core_perform_permanent_strdup (_In_z_ const char *todup, _In_z_ const char *file, _In_z_ const char *func, _In_ int line) |
| char * | switch_core_perform_session_strdup (_In_ switch_core_session_t *session, _In_z_ const char *todup, _In_z_ const char *file, _In_z_ const char *func, _In_ int line) |
| char * | switch_core_perform_strdup (_In_ switch_memory_pool_t *pool, _In_z_ const char *todup, _In_z_ const char *file, _In_z_ const char *func, _In_ int line) |
| char * | switch_core_session_sprintf (_In_ switch_core_session_t *session, _In_z_ _Printf_format_string_ const char *fmt,...) |
| printf-style style printing routine. The data is output to a string allocated from the session | |
| char * | switch_core_session_vsprintf (switch_core_session_t *session, const char *fmt, va_list ap) |
| printf-style style printing routine. The data is output to a string allocated from the session | |
| char * | switch_core_sprintf (_In_ switch_memory_pool_t *pool, _In_z_ _Printf_format_string_ const char *fmt,...) |
| printf-style style printing routine. The data is output to a string allocated from the pool | |
| char * | switch_core_vsprintf (switch_memory_pool_t *pool, _In_z_ _Printf_format_string_ const char *fmt, va_list ap) |
| printf-style style printing routine. The data is output to a string allocated from the pool | |
| switch_memory_pool_t * | switch_core_session_get_pool (_In_ switch_core_session_t *session) |
| Retrieve the memory pool from a session. | |
| switch_core_session_t * | switch_core_session_request_xml (switch_endpoint_interface_t *endpoint_interface, switch_memory_pool_t **pool, switch_xml_t xml) |
| switch_core_session_t * | switch_core_session_request_uuid (_In_ switch_endpoint_interface_t *endpoint_interface, _In_ switch_call_direction_t direction, switch_originate_flag_t originate_flags, _Inout_opt_ switch_memory_pool_t **pool, _In_opt_z_ const char *use_uuid) |
| Allocate and return a new session from the core. | |
| switch_status_t | switch_core_session_set_uuid (_In_ switch_core_session_t *session, _In_z_ const char *use_uuid) |
| void | switch_core_session_perform_destroy (_Inout_ switch_core_session_t **session, _In_z_ const char *file, _In_z_ const char *func, _In_ int line) |
| void | switch_core_session_destroy_state (switch_core_session_t *session) |
| void | switch_core_session_reporting_state (switch_core_session_t *session) |
| void | switch_core_session_hangup_state (switch_core_session_t *session, switch_bool_t force) |
| uint32_t | switch_core_session_count (void) |
| Provide the total number of sessions. | |
| switch_size_t | switch_core_session_get_id (_In_ switch_core_session_t *session) |
| switch_size_t | switch_core_session_id (void) |
| Provide the current session_id. | |
| switch_core_session_t * | switch_core_session_request_by_name (_In_z_ const char *endpoint_name, _In_ switch_call_direction_t direction, _Inout_ switch_memory_pool_t **pool) |
| Allocate and return a new session from the core based on a given endpoint module name. | |
| switch_status_t | switch_core_session_thread_launch (_In_ switch_core_session_t *session) |
| Launch the session thread (state machine) on a given session. | |
| _Ret_ switch_channel_t * | switch_core_session_get_channel (_In_ switch_core_session_t *session) |
| Retrieve a pointer to the channel object associated with a given session. | |
| switch_status_t | switch_core_session_wake_session_thread (_In_ switch_core_session_t *session) |
| Signal a session's state machine thread that a state change has occured. | |
| void | switch_core_session_signal_state_change (_In_ switch_core_session_t *session) |
| char * | switch_core_session_get_uuid (_In_ switch_core_session_t *session) |
| Retrieve the unique identifier from a session. | |
| switch_status_t | switch_core_session_set_loglevel (switch_core_session_t *session, switch_log_level_t loglevel) |
| Sets the log level for a session. | |
| switch_log_level_t | switch_core_session_get_loglevel (switch_core_session_t *session) |
| Get the log level for a session. | |
| void | switch_core_session_soft_lock (switch_core_session_t *session, uint32_t sec) |
| void | switch_core_session_soft_unlock (switch_core_session_t *session) |
| void | switch_core_session_set_dmachine (switch_core_session_t *session, switch_ivr_dmachine_t *dmachine, switch_digit_action_target_t target) |
| switch_ivr_dmachine_t * | switch_core_session_get_dmachine (switch_core_session_t *session, switch_digit_action_target_t target) |
| switch_digit_action_target_t | switch_ivr_dmachine_get_target (switch_ivr_dmachine_t *dmachine) |
| void | switch_ivr_dmachine_set_target (switch_ivr_dmachine_t *dmachine, switch_digit_action_target_t target) |
| switch_status_t | switch_core_session_set_codec_slin (switch_core_session_t *session, switch_slin_data_t *data) |
| char * | switch_core_get_uuid (void) |
| Retrieve the unique identifier from the core. | |
| switch_core_session_t * | switch_core_session_locate (_In_z_ const char *uuid_str) |
| Locate a session based on it's uuid. | |
| switch_core_session_t * | switch_core_session_force_locate (_In_z_ const char *uuid_str) |
| Locate a session based on it's uuid even if the channel is not ready. | |
| char * | switch_core_get_variable (_In_z_ const char *varname) |
| Retrieve a global variable from the core. | |
| char * | switch_core_get_variable_dup (_In_z_ const char *varname) |
| char * | switch_core_get_variable_pdup (_In_z_ const char *varname, switch_memory_pool_t *pool) |
| const char * | switch_core_get_hostname (void) |
| const char * | switch_core_get_switchname (void) |
| void | switch_core_set_variable (_In_z_ const char *varname, _In_opt_z_ const char *value) |
| Add a global variable to the core. | |
| switch_bool_t | switch_core_set_var_conditional (_In_z_ const char *varname, _In_opt_z_ const char *value, _In_opt_z_ const char *val2) |
| Conditionally add a global variable to the core. | |
| void | switch_core_dump_variables (_In_ switch_stream_handle_t *stream) |
| void | switch_core_session_hupall (_In_ switch_call_cause_t cause) |
| Hangup all sessions. | |
| void | switch_core_session_hupall_matching_var (_In_ const char *var_name, _In_ const char *var_val, _In_ switch_call_cause_t cause) |
| Hangup all sessions which match a specific channel variable. | |
| void | switch_core_session_hupall_endpoint (const switch_endpoint_interface_t *endpoint_interface, switch_call_cause_t cause) |
| Hangup all sessions that belong to an endpoint. | |
| switch_status_t | switch_core_session_get_partner (switch_core_session_t *session, switch_core_session_t **partner) |
| Get the session's partner (the session its bridged to). | |
| switch_status_t | switch_core_session_message_send (_In_z_ const char *uuid_str, _In_ switch_core_session_message_t *message) |
| Send a message to another session using it's uuid. | |
| switch_status_t | switch_core_session_queue_message (_In_ switch_core_session_t *session, _In_ switch_core_session_message_t *message) |
| Queue a message on a session. | |
| void | switch_core_session_free_message (switch_core_session_message_t **message) |
| switch_status_t | switch_core_session_queue_signal_data (switch_core_session_t *session, void *signal_data) |
| switch_status_t | switch_core_session_dequeue_signal_data (switch_core_session_t *session, void **signal_data) |
| switch_status_t | switch_core_session_pass_indication (_In_ switch_core_session_t *session, _In_ switch_core_session_message_types_t indication) |
| pass an indication message on a session | |
| switch_status_t | switch_core_session_queue_indication (_In_ switch_core_session_t *session, _In_ switch_core_session_message_types_t indication) |
| Queue an indication message on a session. | |
| switch_status_t | switch_core_session_dequeue_message (_In_ switch_core_session_t *session, _Out_ switch_core_session_message_t **message) |
| DE-Queue an message on a given session. | |
| switch_status_t | switch_core_session_flush_message (_In_ switch_core_session_t *session) |
| Flush a message queue on a given session. | |
| switch_status_t | switch_core_session_event_send (_In_z_ const char *uuid_str, _Inout_ switch_event_t **event) |
| Queue an event on another session using its uuid. | |
| switch_app_log_t * | switch_core_session_get_app_log (_In_ switch_core_session_t *session) |
| switch_status_t | switch_core_session_exec (_In_ switch_core_session_t *session, _In_ const switch_application_interface_t *application_interface, _In_opt_z_ const char *arg) |
| Execute an application on a session. | |
| switch_status_t | switch_core_session_execute_application_get_flags (_In_ switch_core_session_t *session, _In_ const char *app, _In_opt_z_ const char *arg, _Out_opt_ int32_t *flags) |
| Execute an application on a session. | |
| switch_status_t | switch_core_session_execute_application_async (switch_core_session_t *session, const char *app, const char *arg) |
| switch_status_t | switch_core_session_get_app_flags (const char *app, int32_t *flags) |
| switch_status_t | switch_core_session_execute_exten (_In_ switch_core_session_t *session, _In_z_ const char *exten, _In_opt_z_ const char *dialplan, _In_opt_z_ const char *context) |
| Run a dialplan and execute an extension. | |
| switch_status_t | switch_core_session_receive_event (_In_ switch_core_session_t *session, _Inout_ switch_event_t **event) |
| Send an event to a session translating it to it's native message format. | |
| void * | switch_core_session_get_private (_In_ switch_core_session_t *session) |
| Retrieve private user data from a session. | |
| switch_status_t | switch_core_session_set_private (_In_ switch_core_session_t *session, _In_ void *private_info) |
| Add private user data to a session. | |
| int | switch_core_session_add_stream (_In_ switch_core_session_t *session, _In_opt_ void *private_info) |
| Add a logical stream to a session. | |
| void * | switch_core_session_get_stream (_In_ switch_core_session_t *session, _In_ int index) |
| Retreive a logical stream from a session. | |
| int | switch_core_session_get_stream_count (_In_ switch_core_session_t *session) |
| Determine the number of logical streams a session has. | |
| void | switch_core_session_launch_thread (_In_ switch_core_session_t *session, _In_ void *(*func)(switch_thread_t *, void *), _In_opt_ void *obj) |
| Launch a thread designed to exist within the scope of a given session. | |
| void | switch_core_thread_session_end (_In_ switch_core_session_t *session) |
| Signal a thread using a thread session to terminate. | |
| void | switch_core_service_session_av (_In_ switch_core_session_t *session, switch_bool_t audio, switch_bool_t video) |
| Launch a service thread on a session to drop inbound data. | |
| switch_call_cause_t | switch_core_session_outgoing_channel (_In_opt_ switch_core_session_t *session, _In_opt_ switch_event_t *var_event, _In_z_ const char *endpoint_name, _In_ switch_caller_profile_t *caller_profile, _Inout_ switch_core_session_t **new_session, _Inout_ switch_memory_pool_t **pool, _In_ switch_originate_flag_t flags, switch_call_cause_t *cancel_cause) |
| Request an outgoing session spawned from an existing session using a desired endpoing module. | |
| switch_call_cause_t | switch_core_session_resurrect_channel (_In_z_ const char *endpoint_name, _Inout_ switch_core_session_t **new_session, _Inout_ switch_memory_pool_t **pool, _In_ void *data) |
| switch_status_t | switch_core_session_perform_receive_message (_In_ switch_core_session_t *session, _In_ switch_core_session_message_t *message, const char *file, const char *func, int line) |
| Receive a message on a given session. | |
| switch_status_t | switch_core_session_queue_event (_In_ switch_core_session_t *session, _Inout_ switch_event_t **event) |
| Queue an event on a given session. | |
| uint32_t | switch_core_session_event_count (_In_ switch_core_session_t *session) |
| Indicate the number of waiting events on a session. | |
| uint32_t | switch_core_session_messages_waiting (switch_core_session_t *session) |
| switch_status_t | switch_core_session_dequeue_event (_In_ switch_core_session_t *session, _Out_ switch_event_t **event, switch_bool_t force) |
| DE-Queue an event on a given session. | |
| switch_status_t | switch_core_session_queue_private_event (_In_ switch_core_session_t *session, _Inout_ switch_event_t **event, switch_bool_t priority) |
| Queue a private event on a given session. | |
| uint32_t | switch_core_session_private_event_count (_In_ switch_core_session_t *session) |
| Indicate the number of waiting private events on a session. | |
| switch_status_t | switch_core_session_dequeue_private_event (_In_ switch_core_session_t *session, _Out_ switch_event_t **event) |
| DE-Queue a private event on a given session. | |
| uint32_t | switch_core_session_flush_private_events (switch_core_session_t *session) |
| Flush the private event queue of a session. | |
| switch_status_t | switch_core_session_read_frame (_In_ switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags, int stream_id) |
| Read a frame from a session. | |
| switch_status_t | switch_core_session_read_video_frame (_In_ switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags, int stream_id) |
| Read a video frame from a session. | |
| switch_status_t | switch_core_session_write_video_frame (_In_ switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags, int stream_id) |
| Write a video frame to a session. | |
| switch_status_t | switch_core_session_set_read_impl (switch_core_session_t *session, const switch_codec_implementation_t *impp) |
| switch_status_t | switch_core_session_set_write_impl (switch_core_session_t *session, const switch_codec_implementation_t *impp) |
| switch_status_t | switch_core_session_set_video_read_impl (switch_core_session_t *session, const switch_codec_implementation_t *impp) |
| switch_status_t | switch_core_session_set_video_write_impl (switch_core_session_t *session, const switch_codec_implementation_t *impp) |
| void | switch_core_session_reset (_In_ switch_core_session_t *session, switch_bool_t flush_dtmf, switch_bool_t reset_read_codec) |
| Reset the buffers and resampler on a session. | |
| switch_status_t | switch_core_session_write_frame (_In_ switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags, int stream_id) |
| Write a frame to a session. | |
| switch_status_t | switch_core_session_perform_kill_channel (_In_ switch_core_session_t *session, const char *file, const char *func, int line, switch_signal_t sig) |
| switch_status_t | switch_core_session_send_dtmf (_In_ switch_core_session_t *session, const switch_dtmf_t *dtmf) |
| Send DTMF to a session. | |
| switch_status_t | switch_core_session_send_dtmf_string (switch_core_session_t *session, const char *dtmf_string) |
| Send DTMF to a session. | |
| switch_status_t | switch_core_session_recv_dtmf (_In_ switch_core_session_t *session, const switch_dtmf_t *dtmf) |
| RECV DTMF on a session. | |
| switch_status_t | switch_core_hash_init_case (_Out_ switch_hash_t **hash, _In_ switch_memory_pool_t *pool, switch_bool_t case_sensitive) |
| Initialize a hash table. | |
| switch_status_t | switch_core_hash_destroy (_Inout_ switch_hash_t **hash) |
| Destroy an existing hash table. | |
| switch_status_t | switch_core_hash_insert (_In_ switch_hash_t *hash, _In_z_ const char *key, _In_opt_ const void *data) |
| Insert data into a hash. | |
| switch_status_t | switch_core_hash_insert_locked (_In_ switch_hash_t *hash, _In_z_ const char *key, _In_opt_ const void *data, _In_opt_ switch_mutex_t *mutex) |
| Insert data into a hash. | |
| switch_status_t | switch_core_hash_insert_wrlock (switch_hash_t *hash, const char *key, const void *data, switch_thread_rwlock_t *rwlock) |
| Retrieve data from a given hash. | |
| switch_status_t | switch_core_hash_delete (_In_ switch_hash_t *hash, _In_z_ const char *key) |
| Delete data from a hash based on desired key. | |
| switch_status_t | switch_core_hash_delete_locked (_In_ switch_hash_t *hash, _In_z_ const char *key, _In_opt_ switch_mutex_t *mutex) |
| Delete data from a hash based on desired key. | |
| switch_status_t | switch_core_hash_delete_wrlock (_In_ switch_hash_t *hash, _In_z_ const char *key, _In_opt_ switch_thread_rwlock_t *rwlock) |
| Delete data from a hash based on desired key. | |
| switch_status_t | switch_core_hash_delete_multi (_In_ switch_hash_t *hash, _In_ switch_hash_delete_callback_t callback, _In_opt_ void *pData) |
| Delete data from a hash based on callback function. | |
| void * | switch_core_hash_find (_In_ switch_hash_t *hash, _In_z_ const char *key) |
| Retrieve data from a given hash. | |
| void * | switch_core_hash_find_locked (_In_ switch_hash_t *hash, _In_z_ const char *key, _In_ switch_mutex_t *mutex) |
| Retrieve data from a given hash. | |
| void * | switch_core_hash_find_rdlock (_In_ switch_hash_t *hash, _In_z_ const char *key, _In_ switch_thread_rwlock_t *rwlock) |
| Retrieve data from a given hash. | |
| switch_hash_index_t * | switch_hash_first (char *deprecate_me, _In_ switch_hash_t *hash) |
| Gets the first element of a hashtable. | |
| switch_hash_index_t * | switch_hash_next (_In_ switch_hash_index_t *hi) |
| Gets the next element of a hashtable. | |
| void | switch_hash_this (_In_ switch_hash_index_t *hi, _Out_opt_ptrdiff_cap_(klen) const void **key, _Out_opt_ switch_ssize_t *klen, _Out_ void **val) |
| Gets the key and value of the current hash element. | |
| switch_status_t | switch_core_timer_init (switch_timer_t *timer, const char *timer_name, int interval, int samples, switch_memory_pool_t *pool) |
| Request a timer handle using given time module. | |
| void | switch_time_calibrate_clock (void) |
| switch_status_t | switch_core_timer_next (switch_timer_t *timer) |
| Wait for one cycle on an existing timer. | |
| switch_status_t | switch_core_timer_step (switch_timer_t *timer) |
| Step the timer one step. | |
| switch_status_t | switch_core_timer_sync (switch_timer_t *timer) |
| switch_status_t | switch_core_timer_check (switch_timer_t *timer, switch_bool_t step) |
| Check if the current step has been exceeded. | |
| switch_status_t | switch_core_timer_destroy (switch_timer_t *timer) |
| Destroy an allocated timer. | |
| switch_status_t | switch_core_codec_init_with_bitrate (switch_codec_t *codec, const char *codec_name, const char *fmtp, uint32_t rate, int ms, int channels, uint32_t bitrate, uint32_t flags, const switch_codec_settings_t *codec_settings, switch_memory_pool_t *pool) |
| switch_status_t | switch_core_codec_copy (switch_codec_t *codec, switch_codec_t *new_codec, switch_memory_pool_t *pool) |
| switch_status_t | switch_core_codec_parse_fmtp (const char *codec_name, const char *fmtp, uint32_t rate, switch_codec_fmtp_t *codec_fmtp) |
| switch_status_t | switch_core_codec_reset (switch_codec_t *codec) |
| switch_status_t | switch_core_codec_encode (switch_codec_t *codec, switch_codec_t *other_codec, void *decoded_data, uint32_t decoded_data_len, uint32_t decoded_rate, void *encoded_data, uint32_t *encoded_data_len, uint32_t *encoded_rate, unsigned int *flag) |
| Encode data using a codec handle. | |
| switch_status_t | switch_core_codec_decode (switch_codec_t *codec, switch_codec_t *other_codec, void *encoded_data, uint32_t encoded_data_len, uint32_t encoded_rate, void *decoded_data, uint32_t *decoded_data_len, uint32_t *decoded_rate, unsigned int *flag) |
| Decode data using a codec handle. | |
| switch_status_t | switch_core_codec_destroy (switch_codec_t *codec) |
| Destroy an initalized codec handle. | |
| switch_status_t | switch_core_session_set_read_codec (_In_ switch_core_session_t *session, switch_codec_t *codec) |
| Assign the read codec to a given session. | |
| switch_status_t | switch_core_session_set_real_read_codec (_In_ switch_core_session_t *session, switch_codec_t *codec) |
| Assign the original read codec to a given session. This is the read codec used by an endpoint. | |
| void | switch_core_session_unset_read_codec (_In_ switch_core_session_t *session) |
| void | switch_core_session_unset_write_codec (_In_ switch_core_session_t *session) |
| void | switch_core_session_lock_codec_write (_In_ switch_core_session_t *session) |
| void | switch_core_session_unlock_codec_write (_In_ switch_core_session_t *session) |
| void | switch_core_session_lock_codec_read (_In_ switch_core_session_t *session) |
| void | switch_core_session_unlock_codec_read (_In_ switch_core_session_t *session) |
| switch_status_t | switch_core_session_get_read_impl (switch_core_session_t *session, switch_codec_implementation_t *impp) |
| switch_status_t | switch_core_session_get_real_read_impl (switch_core_session_t *session, switch_codec_implementation_t *impp) |
| switch_status_t | switch_core_session_get_write_impl (switch_core_session_t *session, switch_codec_implementation_t *impp) |
| switch_status_t | switch_core_session_get_video_read_impl (switch_core_session_t *session, switch_codec_implementation_t *impp) |
| switch_status_t | switch_core_session_get_video_write_impl (switch_core_session_t *session, switch_codec_implementation_t *impp) |
| switch_codec_t * | switch_core_session_get_read_codec (_In_ switch_core_session_t *session) |
| Retrieve the read codec from a given session. | |
| switch_codec_t * | switch_core_session_get_effective_read_codec (_In_ switch_core_session_t *session) |
| Retrieve the effevtive read codec from a given session. | |
| switch_status_t | switch_core_session_set_write_codec (_In_ switch_core_session_t *session, switch_codec_t *codec) |
| Assign the write codec to a given session. | |
| switch_codec_t * | switch_core_session_get_write_codec (_In_ switch_core_session_t *session) |
| Retrieve the write codec from a given session. | |
| switch_codec_t * | switch_core_session_get_effective_write_codec (_In_ switch_core_session_t *session) |
| Retrieve the effevtive write codec from a given session. | |
| switch_status_t | switch_core_session_set_video_read_codec (_In_ switch_core_session_t *session, switch_codec_t *codec) |
| Assign the video_read codec to a given session. | |
| switch_codec_t * | switch_core_session_get_video_read_codec (_In_ switch_core_session_t *session) |
| Retrieve the video_read codec from a given session. | |
| switch_status_t | switch_core_session_set_video_write_codec (_In_ switch_core_session_t *session, switch_codec_t *codec) |
| Assign the video_write codec to a given session. | |
| switch_codec_t * | switch_core_session_get_video_write_codec (_In_ switch_core_session_t *session) |
| Retrieve the video_write codec from a given session. | |
| switch_core_db_t * | switch_core_db_open_file (const char *filename) |
| Open a core db (SQLite) file. | |
| switch_status_t | switch_core_db_persistant_execute (switch_core_db_t *db, char *sql, uint32_t retries) |
| Execute a sql stmt until it is accepted. | |
| switch_status_t | switch_core_db_persistant_execute_trans (switch_core_db_t *db, char *sql, uint32_t retries) |
| void | switch_core_db_test_reactive (switch_core_db_t *db, char *test_sql, char *drop_sql, char *reactive_sql) |
| perform a test query then perform a reactive query if the first one fails | |
| switch_status_t | switch_core_perform_file_open (const char *file, const char *func, int line, _In_ switch_file_handle_t *fh, _In_opt_z_ const char *file_path, _In_ uint8_t channels, _In_ uint32_t rate, _In_ unsigned int flags, _In_opt_ switch_memory_pool_t *pool) |
| switch_status_t | switch_core_file_read (_In_ switch_file_handle_t *fh, void *data, switch_size_t *len) |
| Read media from a file handle. | |
| switch_status_t | switch_core_file_write (_In_ switch_file_handle_t *fh, void *data, switch_size_t *len) |
| Write media to a file handle. | |
| switch_status_t | switch_core_file_seek (_In_ switch_file_handle_t *fh, unsigned int *cur_pos, int64_t samples, int whence) |
| Seek a position in a file. | |
| switch_status_t | switch_core_file_set_string (_In_ switch_file_handle_t *fh, switch_audio_col_t col, const char *string) |
| Set metadata to the desired string. | |
| switch_status_t | switch_core_file_get_string (_In_ switch_file_handle_t *fh, switch_audio_col_t col, const char **string) |
| get metadata of the desired string | |
| switch_status_t | switch_core_file_close (_In_ switch_file_handle_t *fh) |
| Close an open file handle. | |
| switch_status_t | switch_core_file_truncate (switch_file_handle_t *fh, int64_t offset) |
| switch_status_t | switch_core_speech_open (_In_ switch_speech_handle_t *sh, const char *module_name, const char *voice_name, _In_ unsigned int rate, _In_ unsigned int interval, switch_speech_flag_t *flags, _In_opt_ switch_memory_pool_t *pool) |
| Open a speech handle. | |
| switch_status_t | switch_core_speech_feed_tts (switch_speech_handle_t *sh, char *text, switch_speech_flag_t *flags) |
| Feed text to the TTS module. | |
| void | switch_core_speech_flush_tts (switch_speech_handle_t *sh) |
| Flush TTS audio on a given handle. | |
| void | switch_core_speech_text_param_tts (switch_speech_handle_t *sh, char *param, const char *val) |
| Set a text parameter on a TTS handle. | |
| void | switch_core_speech_numeric_param_tts (switch_speech_handle_t *sh, char *param, int val) |
| Set a numeric parameter on a TTS handle. | |
| void | switch_core_speech_float_param_tts (switch_speech_handle_t *sh, char *param, double val) |
| Set a float parameter on a TTS handle. | |
| switch_status_t | switch_core_speech_read_tts (switch_speech_handle_t *sh, void *data, switch_size_t *datalen, switch_speech_flag_t *flags) |
| Read rendered audio from the TTS module. | |
| switch_status_t | switch_core_speech_close (switch_speech_handle_t *sh, switch_speech_flag_t *flags) |
| Close an open speech handle. | |
| switch_status_t | switch_core_asr_open (switch_asr_handle_t *ah, const char *module_name, const char *codec, int rate, const char *dest, switch_asr_flag_t *flags, switch_memory_pool_t *pool) |
| Open an asr handle. | |
| switch_status_t | switch_core_asr_close (switch_asr_handle_t *ah, switch_asr_flag_t *flags) |
| Close an asr handle. | |
| switch_status_t | switch_core_asr_feed (switch_asr_handle_t *ah, void *data, unsigned int len, switch_asr_flag_t *flags) |
| Feed audio data to an asr handle. | |
| switch_status_t | switch_core_asr_feed_dtmf (switch_asr_handle_t *ah, const switch_dtmf_t *dtmf, switch_asr_flag_t *flags) |
| Feed DTMF to an asr handle. | |
| switch_status_t | switch_core_asr_check_results (switch_asr_handle_t *ah, switch_asr_flag_t *flags) |
| Check an asr handle for results. | |
| switch_status_t | switch_core_asr_get_results (switch_asr_handle_t *ah, char **xmlstr, switch_asr_flag_t *flags) |
| Get results from an asr handle. | |
| switch_status_t | switch_core_asr_load_grammar (switch_asr_handle_t *ah, const char *grammar, const char *name) |
| Load a grammar to an asr handle. | |
| switch_status_t | switch_core_asr_unload_grammar (switch_asr_handle_t *ah, const char *name) |
| Unload a grammar from an asr handle. | |
| switch_status_t | switch_core_asr_enable_grammar (switch_asr_handle_t *ah, const char *name) |
| Enable a grammar from an asr handle. | |
| switch_status_t | switch_core_asr_disable_grammar (switch_asr_handle_t *ah, const char *name) |
| Disable a grammar from an asr handle. | |
| switch_status_t | switch_core_asr_disable_all_grammars (switch_asr_handle_t *ah) |
| Disable all grammars from an asr handle. | |
| switch_status_t | switch_core_asr_pause (switch_asr_handle_t *ah) |
| Pause detection on an asr handle. | |
| switch_status_t | switch_core_asr_resume (switch_asr_handle_t *ah) |
| Resume detection on an asr handle. | |
| switch_status_t | switch_core_asr_start_input_timers (switch_asr_handle_t *ah) |
| Start input timers on an asr handle. | |
| void | switch_core_asr_text_param (switch_asr_handle_t *ah, char *param, const char *val) |
| Set a text parameter on an asr handle. | |
| void | switch_core_asr_numeric_param (switch_asr_handle_t *ah, char *param, int val) |
| Set a numeric parameter on an asr handle. | |
| void | switch_core_asr_float_param (switch_asr_handle_t *ah, char *param, double val) |
| Set a float parameter on an asr handle. | |
| switch_status_t | switch_core_directory_open (switch_directory_handle_t *dh, char *module_name, char *source, char *dsn, char *passwd, switch_memory_pool_t *pool) |
| Open a directory handle. | |
| switch_status_t | switch_core_directory_query (switch_directory_handle_t *dh, char *base, char *query) |
| Query a directory handle. | |
| switch_status_t | switch_core_directory_next (switch_directory_handle_t *dh) |
| Obtain the next record in a lookup. | |
| switch_status_t | switch_core_directory_next_pair (switch_directory_handle_t *dh, char **var, char **val) |
| Obtain the next name/value pair in the current record. | |
| switch_status_t | switch_core_directory_close (switch_directory_handle_t *dh) |
| Close an open directory handle. | |
| FILE * | switch_core_data_channel (switch_text_channel_t channel) |
| Retrieve a FILE stream of a given text channel name. | |
| switch_bool_t | switch_core_ready (void) |
| Determines if the core is ready to take calls. | |
| switch_bool_t | switch_core_ready_inbound (void) |
| Determines if the core is ready to take inbound calls. | |
| switch_bool_t | switch_core_ready_outbound (void) |
| Determines if the core is ready to place outbound calls. | |
| switch_core_flag_t | switch_core_flags (void) |
| return core flags | |
| switch_status_t | switch_core_management_exec (char *relative_oid, switch_management_action_t action, char *data, switch_size_t datalen) |
| Execute a management operation. | |
| int32_t | set_normal_priority (void) |
| Set the maximum priority the process can obtain. | |
| int32_t | set_auto_priority (void) |
| int32_t | set_realtime_priority (void) |
| int32_t | set_low_priority (void) |
| int32_t | change_user_group (const char *user, const char *group) |
| Change user and/or group of the running process. | |
| void | switch_core_runtime_loop (int bg) |
| Run endlessly until the system is shutdown. | |
| switch_status_t | switch_core_set_console (const char *console) |
| Set the output console to the desired file. | |
| void | switch_core_measure_time (switch_time_t total_ms, switch_core_time_duration_t *duration) |
| Breakdown a number of milliseconds into various time spec. | |
| switch_time_t | switch_core_uptime (void) |
| Number of microseconds the system has been up. | |
| int32_t | switch_core_session_ctl (switch_session_ctl_t cmd, void *val) |
| send a control message to the core | |
| FILE * | switch_core_get_console (void) |
| Get the output console. | |
| switch_thread_t * | switch_core_launch_thread (void *(SWITCH_THREAD_FUNC *func)(switch_thread_t *, void *), void *obj, switch_memory_pool_t *pool) |
| Launch a thread. | |
| void | switch_core_set_globals (void) |
| Initiate Globals. | |
| uint8_t | switch_core_session_compare (switch_core_session_t *a, switch_core_session_t *b) |
| Checks if 2 sessions are using the same endpoint module. | |
| uint8_t | switch_core_session_check_interface (switch_core_session_t *session, const switch_endpoint_interface_t *endpoint_interface) |
| Checks if a session is using a specific endpoint. | |
| switch_hash_index_t * | switch_core_mime_index (void) |
| const char * | switch_core_mime_ext2type (const char *ext) |
| switch_status_t | switch_core_mime_add_type (const char *type, const char *ext) |
| switch_loadable_module_interface_t * | switch_loadable_module_create_module_interface (switch_memory_pool_t *pool, const char *name) |
| void * | switch_loadable_module_create_interface (switch_loadable_module_interface_t *mod, switch_module_interface_name_t iname) |
| switch_time_t | switch_micro_time_now (void) |
| Get the current epoch time in microseconds. | |
| void | switch_core_memory_reclaim (void) |
| void | switch_core_memory_reclaim_events (void) |
| void | switch_core_memory_reclaim_logger (void) |
| void | switch_core_memory_reclaim_all (void) |
| void | switch_core_setrlimits (void) |
| switch_time_t | switch_time_ref (void) |
| void | switch_time_sync (void) |
| time_t | switch_epoch_time_now (time_t *t) |
| Get the current epoch time. | |
| switch_status_t | switch_strftime_tz (const char *tz, const char *format, char *date, size_t len, switch_time_t thetime) |
| switch_status_t | switch_time_exp_tz_name (const char *tz, switch_time_exp_t *tm, switch_time_t thetime) |
| void | switch_load_network_lists (switch_bool_t reload) |
| switch_bool_t | switch_check_network_list_ip_token (const char *ip_str, const char *list_name, const char **token) |
| void | switch_time_set_monotonic (switch_bool_t enable) |
| void | switch_time_set_timerfd (switch_bool_t enable) |
| void | switch_time_set_nanosleep (switch_bool_t enable) |
| void | switch_time_set_matrix (switch_bool_t enable) |
| void | switch_time_set_cond_yield (switch_bool_t enable) |
| uint32_t | switch_core_min_dtmf_duration (uint32_t duration) |
| uint32_t | switch_core_max_dtmf_duration (uint32_t duration) |
| double | switch_core_min_idle_cpu (double new_limit) |
| double | switch_core_idle_cpu (void) |
| uint32_t | switch_core_default_dtmf_duration (uint32_t duration) |
| switch_status_t | switch_console_set_complete (const char *string) |
| switch_status_t | switch_console_set_alias (const char *string) |
| int | switch_system (const char *cmd, switch_bool_t wait) |
| int | switch_stream_system (const char *cmd, switch_stream_handle_t *stream) |
| void | switch_cond_yield (switch_interval_time_t t) |
| void | switch_cond_next (void) |
| switch_status_t | switch_core_chat_send_args (const char *dest_proto, const char *proto, const char *from, const char *to, const char *subject, const char *body, const char *type, const char *hint) |
| switch_status_t | switch_core_chat_send (const char *dest_proto, switch_event_t *message_event) |
| switch_status_t | switch_core_chat_deliver (const char *dest_proto, switch_event_t **message_event) |
| switch_status_t | switch_ivr_preprocess_session (switch_core_session_t *session, const char *cmds) |
| static const char * | switch_cache_db_type_name (switch_cache_db_handle_type_t type) |
| switch_cache_db_handle_type_t | switch_cache_db_get_type (switch_cache_db_handle_t *dbh) |
| void | switch_cache_db_dismiss_db_handle (switch_cache_db_handle_t **dbh) |
| Returns the handle to the pool, immediately available for other threads to use. | |
| void | switch_cache_db_release_db_handle (switch_cache_db_handle_t **dbh) |
| Returns the handle to the pool, handle is NOT available to other threads until the allocating thread actually terminates. | |
| switch_status_t | _switch_cache_db_get_db_handle (switch_cache_db_handle_t **dbh, switch_cache_db_handle_type_t type, switch_cache_db_connection_options_t *connection_options, const char *file, const char *func, int line) |
| Gets a new cached handle from the pool, potentially creating a new connection. The connection is bound to the thread until it (the thread) terminates unless you dismiss rather than release. | |
| char * | switch_cache_db_execute_sql2str (switch_cache_db_handle_t *dbh, char *sql, char *str, size_t len, char **err) |
| Executes the sql and returns the result as a string. | |
| switch_status_t | switch_cache_db_execute_sql (switch_cache_db_handle_t *dbh, char *sql, char **err) |
| Executes the sql. | |
| switch_status_t | switch_cache_db_execute_sql_callback (switch_cache_db_handle_t *dbh, const char *sql, switch_core_db_callback_func_t callback, void *pdata, char **err) |
| Executes the sql and uses callback for row-by-row processing. | |
| int | switch_cache_db_affected_rows (switch_cache_db_handle_t *dbh) |
| Get the affected rows of the last performed query. | |
| void | switch_cache_db_status (switch_stream_handle_t *stream) |
| Provides some feedback as to the status of the db connection pool. | |
| switch_status_t | _switch_core_db_handle (switch_cache_db_handle_t **dbh, const char *file, const char *func, int line) |
| Open the default system database. | |
| switch_bool_t | switch_cache_db_test_reactive (switch_cache_db_handle_t *db, const char *test_sql, const char *drop_sql, const char *reactive_sql) |
| switch_status_t | switch_cache_db_persistant_execute (switch_cache_db_handle_t *dbh, const char *sql, uint32_t retries) |
| switch_status_t | switch_cache_db_persistant_execute_trans (switch_cache_db_handle_t *dbh, char *sql, uint32_t retries) |
| void | switch_core_set_signal_handlers (void) |
| uint32_t | switch_core_debug_level (void) |
| void | switch_cache_db_flush_handles (void) |
| const char * | switch_core_banner (void) |
| switch_bool_t | switch_core_session_in_thread (switch_core_session_t *session) |
| uint32_t | switch_default_ptime (const char *name, uint32_t number) |
| switch_status_t | switch_core_add_registration (const char *user, const char *realm, const char *token, const char *url, uint32_t expires, const char *network_ip, const char *network_port, const char *network_proto) |
| Add user registration. | |
| switch_status_t | switch_core_del_registration (const char *user, const char *realm, const char *token) |
| Delete user registration. | |
| switch_status_t | switch_core_expire_registration (int force) |
| Expire user registrations. | |
| char * | switch_say_file_handle_get_variable (switch_say_file_handle_t *sh, const char *var) |
| char * | switch_say_file_handle_get_path (switch_say_file_handle_t *sh) |
| char * | switch_say_file_handle_detach_path (switch_say_file_handle_t *sh) |
| void | switch_say_file_handle_destroy (switch_say_file_handle_t **sh) |
| switch_status_t | switch_say_file_handle_create (switch_say_file_handle_t **sh, const char *ext, switch_event_t **var_event) |
| void | switch_say_file (switch_say_file_handle_t *sh, const char *fmt,...) |
| int | switch_max_file_desc (void) |
| void | switch_close_extra_files (int *keep, int keep_ttl) |
| switch_status_t | switch_core_thread_set_cpu_affinity (int cpu) |
| void | switch_os_yield (void) |
This module is the main core library and is the intended location of all fundamental operations.
Definition in file switch_core.h.
| #define CACHE_DB_LEN 256 |
Definition at line 2157 of file switch_core.h.
Referenced by _switch_cache_db_get_db_handle(), and switch_cache_db_status().
| #define MESSAGE_STAMP_FFL | ( | _m | ) | _m->_file = __FILE__; _m->_func = __SWITCH_FUNC__; _m->_line = __LINE__ |
| #define MESSAGE_STRING_ARG_MAX 10 |
| #define switch_cache_db_get_db_handle | ( | _a, | |||
| _b, | |||||
| _c | ) | _switch_cache_db_get_db_handle(_a, _b, _c, __FILE__, __SWITCH_FUNC__, __LINE__) |
Definition at line 2237 of file switch_core.h.
| #define switch_core_db_handle | ( | _a | ) | _switch_core_db_handle(_a, __FILE__, __SWITCH_FUNC__, __LINE__) |
Definition at line 2279 of file switch_core.h.
Referenced by switch_console_complete(), switch_console_expand_alias(), switch_console_list_uuid(), switch_console_set_alias(), switch_console_set_complete(), switch_core_sql_thread(), and switch_core_sqldb_start().
| #define SWITCH_MAX_CORE_THREAD_SESSION_OBJS 128 |
Definition at line 45 of file switch_core.h.
| #define SWITCH_MAX_STREAMS 128 |
Definition at line 46 of file switch_core.h.
| typedef struct switch_cache_db_handle switch_cache_db_handle_t |
Definition at line 2189 of file switch_core.h.
| enum cache_db_flag_t |
Definition at line 2158 of file switch_core.h.
02158 { 02159 CDF_INUSE = (1 << 0), 02160 CDF_PRUNE = (1 << 1) 02161 } cache_db_flag_t;
Definition at line 2163 of file switch_core.h.
02163 { 02164 SCDB_TYPE_CORE_DB, 02165 SCDB_TYPE_ODBC 02166 } switch_cache_db_handle_type_t;
| switch_status_t _switch_cache_db_get_db_handle | ( | switch_cache_db_handle_t ** | dbh, | |
| switch_cache_db_handle_type_t | type, | |||
| switch_cache_db_connection_options_t * | connection_options, | |||
| const char * | file, | |||
| const char * | func, | |||
| int | line | |||
| ) |
Gets a new cached handle from the pool, potentially creating a new connection. The connection is bound to the thread until it (the thread) terminates unless you dismiss rather than release.
| [out] | dbh | The handle |
| [in] | type | - ODBC or SQLLITE |
| [in] | connection_options | (userid, password, etc) |
Definition at line 322 of file switch_core_sqldb.c.
References add_handle(), CACHE_DB_LEN, switch_cache_db_native_handle_t::core_db_dbh, create_handle(), switch_runtime::db_handle_timeout, get_handle(), switch_cache_db_handle::last_used, switch_runtime::max_db_handles, switch_cache_db_handle::name, switch_cache_db_handle::native_handle, switch_cache_db_native_handle_t::odbc_dbh, runtime, SCDB_TYPE_CORE_DB, SCDB_TYPE_ODBC, sql_manager, switch_cache_db_type_name(), SWITCH_CHANNEL_ID_LOG, SWITCH_CHANNEL_LOG, switch_core_db_open_file(), switch_epoch_time_now(), SWITCH_LOG_CRIT, SWITCH_LOG_DEBUG10, SWITCH_LOG_ERROR, switch_log_printf(), SWITCH_LOG_WARNING, switch_odbc_available(), switch_odbc_handle_connect(), switch_odbc_handle_destroy(), switch_odbc_handle_new(), SWITCH_ODBC_SUCCESS, SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, switch_thread_self(), switch_yield, and switch_cache_db_handle::type.
Referenced by _switch_core_db_handle().
00326 { 00327 switch_thread_id_t self = switch_thread_self(); 00328 char thread_str[CACHE_DB_LEN] = ""; 00329 char db_str[CACHE_DB_LEN] = ""; 00330 char db_callsite_str[CACHE_DB_LEN] = ""; 00331 switch_cache_db_handle_t *new_dbh = NULL; 00332 int waiting = 0; 00333 uint32_t yield_len = 100000, total_yield = 0; 00334 00335 const char *db_name = NULL; 00336 const char *db_user = NULL; 00337 const char *db_pass = NULL; 00338 00339 while(runtime.max_db_handles && sql_manager.total_handles >= runtime.max_db_handles && sql_manager.total_used_handles >= sql_manager.total_handles) { 00340 if (!waiting++) { 00341 switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_WARNING, "Max handles %u exceeded, blocking....\n", 00342 runtime.max_db_handles); 00343 } 00344 00345 switch_yield(yield_len); 00346 total_yield += yield_len; 00347 00348 if (runtime.db_handle_timeout && total_yield > runtime.db_handle_timeout) { 00349 switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_ERROR, "Error connecting\n"); 00350 *dbh = NULL; 00351 return SWITCH_STATUS_FALSE; 00352 } 00353 } 00354 00355 switch (type) { 00356 case SCDB_TYPE_ODBC: 00357 { 00358 db_name = connection_options->odbc_options.dsn; 00359 db_user = connection_options->odbc_options.user; 00360 db_pass = connection_options->odbc_options.pass; 00361 } 00362 break; 00363 case SCDB_TYPE_CORE_DB: 00364 { 00365 db_name = connection_options->core_db_options.db_path; 00366 db_user = ""; 00367 db_pass = ""; 00368 } 00369 break; 00370 } 00371 00372 if (!db_name) { 00373 return SWITCH_STATUS_FALSE; 00374 } 00375 00376 00377 snprintf(db_str, sizeof(db_str) - 1, "db=\"%s\";user=\"%s\";pass=\"%s\"", db_name, db_user, db_pass); 00378 snprintf(db_callsite_str, sizeof(db_callsite_str) - 1, "%s:%d", file, line); 00379 snprintf(thread_str, sizeof(thread_str) - 1, "thread=\"%lu\"", (unsigned long) (intptr_t) self); 00380 00381 if ((new_dbh = get_handle(db_str, db_callsite_str, thread_str))) { 00382 switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_DEBUG10, 00383 "Reuse Unused Cached DB handle %s [%s]\n", new_dbh->name, switch_cache_db_type_name(new_dbh->type)); 00384 } else { 00385 switch_core_db_t *db = NULL; 00386 switch_odbc_handle_t *odbc_dbh = NULL; 00387 00388 switch (type) { 00389 case SCDB_TYPE_ODBC: 00390 { 00391 00392 if (!switch_odbc_available()) { 00393 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Failure! ODBC NOT AVAILABLE! Can't connect to DSN %s\n", connection_options->odbc_options.dsn); 00394 goto end; 00395 } 00396 00397 if ((odbc_dbh = switch_odbc_handle_new(connection_options->odbc_options.dsn, 00398 connection_options->odbc_options.user, connection_options->odbc_options.pass))) { 00399 if (switch_odbc_handle_connect(odbc_dbh) != SWITCH_ODBC_SUCCESS) { 00400 switch_odbc_handle_destroy(&odbc_dbh); 00401 } 00402 } 00403 00404 00405 } 00406 break; 00407 case SCDB_TYPE_CORE_DB: 00408 { 00409 db = switch_core_db_open_file(connection_options->core_db_options.db_path); 00410 } 00411 break; 00412 00413 default: 00414 goto end; 00415 } 00416 00417 if (!db && !odbc_dbh) { 00418 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Failure to connect to %s %s!\n", db?"SQLITE":"ODBC", db?connection_options->core_db_options.db_path:connection_options->odbc_options.dsn); 00419 goto end; 00420 } 00421 00422 switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_DEBUG10, 00423 "Create Cached DB handle %s [%s] %s:%d\n", new_dbh->name, switch_cache_db_type_name(type), file, line); 00424 00425 new_dbh = create_handle(type); 00426 00427 if (db) { 00428 new_dbh->native_handle.core_db_dbh = db; 00429 } else { 00430 new_dbh->native_handle.odbc_dbh = odbc_dbh; 00431 } 00432 00433 add_handle(new_dbh, db_str, db_callsite_str, thread_str); 00434 } 00435 00436 end: 00437 00438 if (new_dbh) { 00439 new_dbh->last_used = switch_epoch_time_now(NULL); 00440 } 00441 00442 *dbh = new_dbh; 00443 00444 return *dbh ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_FALSE; 00445 }
| switch_status_t _switch_core_db_handle | ( | switch_cache_db_handle_t ** | dbh, | |
| const char * | file, | |||
| const char * | func, | |||
| int | line | |||
| ) |
Open the default system database.
Definition at line 182 of file switch_core_sqldb.c.
References _switch_cache_db_get_db_handle(), switch_cache_db_connection_options_t::core_db_options, switch_cache_db_core_db_options_t::db_path, switch_runtime::dbname, switch_cache_db_odbc_options_t::dsn, switch_runtime::odbc_dsn, switch_cache_db_connection_options_t::odbc_options, switch_runtime::odbc_pass, switch_runtime::odbc_user, switch_cache_db_odbc_options_t::pass, runtime, SCDB_TYPE_CORE_DB, SCDB_TYPE_ODBC, SCF_CORE_ODBC_REQ, sql_manager, SWITCH_CORE_DB, SWITCH_STATUS_FALSE, switch_test_flag, switch_cache_db_odbc_options_t::user, and zstr.
00183 { 00184 switch_cache_db_connection_options_t options = { {0} }; 00185 switch_status_t r; 00186 00187 if (!sql_manager.manage) { 00188 return SWITCH_STATUS_FALSE; 00189 } 00190 00191 if (zstr(runtime.odbc_dsn)) { 00192 if (switch_test_flag((&runtime), SCF_CORE_ODBC_REQ)) { 00193 return SWITCH_STATUS_FALSE; 00194 } 00195 00196 if (runtime.dbname) { 00197 options.core_db_options.db_path = runtime.dbname; 00198 } else { 00199 options.core_db_options.db_path = SWITCH_CORE_DB; 00200 } 00201 r = _switch_cache_db_get_db_handle(dbh, SCDB_TYPE_CORE_DB, &options, file, func, line); 00202 00203 } else { 00204 options.odbc_options.dsn = runtime.odbc_dsn; 00205 options.odbc_options.user = runtime.odbc_user; 00206 options.odbc_options.pass = runtime.odbc_pass; 00207 00208 r = _switch_cache_db_get_db_handle(dbh, SCDB_TYPE_ODBC, &options, file, func, line); 00209 } 00210 00211 /* I *think* we can do without this now, if not let me know 00212 if (r == SWITCH_STATUS_SUCCESS && !(*dbh)->io_mutex) { 00213 (*dbh)->io_mutex = sql_manager.io_mutex; 00214 } 00215 */ 00216 00217 return r; 00218 }
| int switch_cache_db_affected_rows | ( | switch_cache_db_handle_t * | dbh | ) |
Get the affected rows of the last performed query.
| [in] | dbh | The handle |
| [out] | the | number of affected rows |
Definition at line 600 of file switch_core_sqldb.c.
References SCDB_TYPE_CORE_DB, SCDB_TYPE_ODBC, switch_core_db_changes(), and switch_odbc_handle_affected_rows().
00601 { 00602 switch (dbh->type) { 00603 case SCDB_TYPE_CORE_DB: 00604 { 00605 return switch_core_db_changes(dbh->native_handle.core_db_dbh); 00606 } 00607 break; 00608 case SCDB_TYPE_ODBC: 00609 { 00610 return switch_odbc_handle_affected_rows(dbh->native_handle.odbc_dbh); 00611 } 00612 break; 00613 } 00614 return 0; 00615 }
| void switch_cache_db_dismiss_db_handle | ( | switch_cache_db_handle_t ** | dbh | ) |
Returns the handle to the pool, immediately available for other threads to use.
| [in] | The | handle |
Definition at line 316 of file switch_core_sqldb.c.
References switch_cache_db_release_db_handle().
00317 { 00318 switch_cache_db_release_db_handle(dbh); 00319 }
| switch_status_t switch_cache_db_execute_sql | ( | switch_cache_db_handle_t * | dbh, | |
| char * | sql, | |||
| char ** | err | |||
| ) |
Executes the sql.
| [in] | dbh | The handle |
| [in] | sql | - sql to run |
| [out] | err | - Error if it exists |
Definition at line 578 of file switch_core_sqldb.c.
References io_mutex, switch_cache_db_execute_sql_chunked(), switch_mutex_lock(), switch_mutex_unlock(), and SWITCH_STATUS_FALSE.
Referenced by switch_cache_db_persistant_execute_trans(), switch_cache_db_test_reactive(), switch_core_sql_thread(), and switch_core_sqldb_start().
00579 { 00580 switch_status_t status = SWITCH_STATUS_FALSE; 00581 switch_mutex_t *io_mutex = dbh->io_mutex; 00582 00583 if (io_mutex) switch_mutex_lock(io_mutex); 00584 00585 switch (dbh->type) { 00586 default: 00587 { 00588 status = switch_cache_db_execute_sql_chunked(dbh, (char *) sql, 32768, err); 00589 } 00590 break; 00591 } 00592 00593 if (io_mutex) switch_mutex_unlock(io_mutex); 00594 00595 return status; 00596 00597 }
| char* switch_cache_db_execute_sql2str | ( | switch_cache_db_handle_t * | dbh, | |
| char * | sql, | |||
| char * | str, | |||
| size_t | len, | |||
| char ** | err | |||
| ) |
Executes the sql and returns the result as a string.
| [in] | dbh | The handle |
| [in] | sql | - sql to run |
| [out] | str | - buffer for result |
| [in] | len | - length of str buffer |
| [out] | err | - Error if it exists |
Definition at line 618 of file switch_core_sqldb.c.
References io_mutex, running, SCDB_TYPE_CORE_DB, SCDB_TYPE_ODBC, SWITCH_CHANNEL_LOG, switch_cond_next(), switch_copy_string(), SWITCH_CORE_DB_BUSY, switch_core_db_column_count(), switch_core_db_column_text(), switch_core_db_finalize(), switch_core_db_prepare(), SWITCH_CORE_DB_ROW, switch_core_db_step(), SWITCH_LOG_ERROR, switch_log_printf(), switch_mutex_lock(), switch_mutex_unlock(), switch_odbc_handle_exec_string(), SWITCH_STATUS_FALSE, and SWITCH_STATUS_SUCCESS.
00619 { 00620 switch_status_t status = SWITCH_STATUS_FALSE; 00621 switch_mutex_t *io_mutex = dbh->io_mutex; 00622 00623 if (io_mutex) switch_mutex_lock(io_mutex); 00624 00625 memset(str, 0, len); 00626 00627 switch (dbh->type) { 00628 case SCDB_TYPE_CORE_DB: 00629 { 00630 switch_core_db_stmt_t *stmt; 00631 00632 if (switch_core_db_prepare(dbh->native_handle.core_db_dbh, sql, -1, &stmt, 0)) { 00633 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Statement Error [%s]!\n", sql); 00634 goto end; 00635 } else { 00636 int running = 1; 00637 int colcount; 00638 00639 while (running < 5000) { 00640 int result = switch_core_db_step(stmt); 00641 const unsigned char *txt; 00642 00643 if (result == SWITCH_CORE_DB_ROW) { 00644 if ((colcount = switch_core_db_column_count(stmt)) > 0) { 00645 if ((txt = switch_core_db_column_text(stmt, 0))) { 00646 switch_copy_string(str, (char *) txt, len); 00647 status = SWITCH_STATUS_SUCCESS; 00648 } else { 00649 goto end; 00650 } 00651 } 00652 break; 00653 } else if (result == SWITCH_CORE_DB_BUSY) { 00654 running++; 00655 switch_cond_next(); 00656 continue; 00657 } 00658 break; 00659 } 00660 00661 switch_core_db_finalize(stmt); 00662 } 00663 } 00664 break; 00665 case SCDB_TYPE_ODBC: 00666 { 00667 status = switch_odbc_handle_exec_string(dbh->native_handle.odbc_dbh, sql, str, len, err); 00668 } 00669 break; 00670 } 00671 00672 end: 00673 00674 if (io_mutex) switch_mutex_unlock(io_mutex); 00675 00676 return status == SWITCH_STATUS_SUCCESS ? str : NULL; 00677 00678 }
| switch_status_t switch_cache_db_execute_sql_callback | ( | switch_cache_db_handle_t * | dbh, | |
| const char * | sql, | |||
| switch_core_db_callback_func_t | callback, | |||
| void * | pdata, | |||
| char ** | err | |||
| ) |
Executes the sql and uses callback for row-by-row processing.
| [in] | dbh | The handle |
| [in] | sql | - sql to run |
| [in] | callback | - function pointer to callback |
| [in] | pdata | - data to pass to callback |
| [out] | err | - Error if it exists |
Definition at line 851 of file switch_core_sqldb.c.
References io_mutex, SCDB_TYPE_CORE_DB, SCDB_TYPE_ODBC, SQL_CACHE_TIMEOUT, SWITCH_CHANNEL_LOG, SWITCH_CORE_DB_ABORT, switch_core_db_exec(), switch_core_db_free(), SWITCH_CORE_DB_OK, switch_epoch_time_now(), SWITCH_LOG_ERROR, switch_log_printf(), switch_mutex_lock(), switch_mutex_unlock(), switch_odbc_handle_callback_exec, SWITCH_STATUS_FALSE, and SWITCH_STATUS_SUCCESS.
Referenced by switch_console_complete(), switch_console_expand_alias(), and switch_console_list_uuid().
00853 { 00854 switch_status_t status = SWITCH_STATUS_FALSE; 00855 char *errmsg = NULL; 00856 switch_mutex_t *io_mutex = dbh->io_mutex; 00857 00858 if (err) { 00859 *err = NULL; 00860 } 00861 00862 if (io_mutex) switch_mutex_lock(io_mutex); 00863 00864 00865 switch (dbh->type) { 00866 case SCDB_TYPE_ODBC: 00867 { 00868 status = switch_odbc_handle_callback_exec(dbh->native_handle.odbc_dbh, sql, callback, pdata, err); 00869 } 00870 break; 00871 case SCDB_TYPE_CORE_DB: 00872 { 00873 int ret = switch_core_db_exec(dbh->native_handle.core_db_dbh, sql, callback, pdata, &errmsg); 00874 00875 if (ret == SWITCH_CORE_DB_OK || ret == SWITCH_CORE_DB_ABORT) { 00876 status = SWITCH_STATUS_SUCCESS; 00877 } 00878 00879 if (errmsg) { 00880 dbh->last_used = switch_epoch_time_now(NULL) - (SQL_CACHE_TIMEOUT * 2); 00881 if (!strstr(errmsg, "query abort")) { 00882 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "SQL ERR: [%s] %s\n", sql, errmsg); 00883 } 00884 switch_core_db_free(errmsg); 00885 } 00886 } 00887 break; 00888 } 00889 00890 if (io_mutex) switch_mutex_unlock(io_mutex); 00891 00892 return status; 00893 }
| void switch_cache_db_flush_handles | ( | void | ) |
Definition at line 289 of file switch_core_sqldb.c.
References SQL_CACHE_TIMEOUT, sql_close(), and switch_epoch_time_now().
Referenced by switch_core_session_ctl(), and switch_core_sqldb_stop().
00290 { 00291 sql_close(switch_epoch_time_now(NULL) + SQL_CACHE_TIMEOUT + 1); 00292 }
| switch_cache_db_handle_type_t switch_cache_db_get_type | ( | switch_cache_db_handle_t * | dbh | ) |
Definition at line 284 of file switch_core_sqldb.c.
Referenced by switch_console_complete(), switch_console_expand_alias(), switch_console_set_alias(), and switch_console_set_complete().
00285 { 00286 return dbh->type; 00287 }
| switch_status_t switch_cache_db_persistant_execute | ( | switch_cache_db_handle_t * | dbh, | |
| const char * | sql, | |||
| uint32_t | retries | |||
| ) |
Definition at line 680 of file switch_core_sqldb.c.
References io_mutex, switch_cache_db_execute_sql_real(), SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, switch_log_printf(), switch_mutex_lock(), switch_mutex_unlock(), switch_safe_free, SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, and switch_yield.
Referenced by switch_console_set_alias(), and switch_console_set_complete().
00681 { 00682 char *errmsg = NULL; 00683 switch_status_t status = SWITCH_STATUS_FALSE; 00684 uint8_t forever = 0; 00685 switch_mutex_t *io_mutex = dbh->io_mutex; 00686 00687 if (!retries) { 00688 forever = 1; 00689 retries = 1000; 00690 } 00691 00692 while (retries > 0) { 00693 00694 if (io_mutex) switch_mutex_lock(io_mutex); 00695 switch_cache_db_execute_sql_real(dbh, sql, &errmsg); 00696 if (io_mutex) switch_mutex_unlock(io_mutex); 00697 00698 00699 if (errmsg) { 00700 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "SQL ERR [%s]\n", errmsg); 00701 switch_safe_free(errmsg); 00702 switch_yield(100000); 00703 retries--; 00704 if (retries == 0 && forever) { 00705 retries = 1000; 00706 continue; 00707 } 00708 } else { 00709 status = SWITCH_STATUS_SUCCESS; 00710 break; 00711 } 00712 } 00713 00714 return status; 00715 }
| switch_status_t switch_cache_db_persistant_execute_trans | ( | switch_cache_db_handle_t * | dbh, | |
| char * | sql, | |||
| uint32_t | retries | |||
| ) |
Definition at line 718 of file switch_core_sqldb.c.
References switch_runtime::core_db_inner_post_trans_execute, switch_runtime::core_db_inner_pre_trans_execute, switch_runtime::core_db_post_trans_execute, switch_runtime::core_db_pre_trans_execute, DBTYPE_DEFAULT, io_mutex, switch_runtime::odbc_dbtype, runtime, switch_cache_db_execute_sql(), switch_cache_db_execute_sql_real(), SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, SWITCH_LOG_DEBUG, SWITCH_LOG_ERROR, switch_log_printf(), switch_mutex_lock(), switch_mutex_unlock(), switch_odbc_SQLEndTran(), switch_odbc_SQLSetAutoCommitAttr(), SWITCH_ODBC_SUCCESS, switch_snprintfv(), SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, switch_yield, and zstr.
Referenced by switch_core_sql_thread().
00719 { 00720 char *errmsg = NULL; 00721 switch_status_t status = SWITCH_STATUS_FALSE; 00722 uint8_t forever = 0; 00723 unsigned begin_retries = 100; 00724 uint8_t again = 0; 00725 switch_mutex_t *io_mutex = dbh->io_mutex; 00726 00727 if (!retries) { 00728 forever = 1; 00729 retries = 1000; 00730 } 00731 00732 if (io_mutex) switch_mutex_lock(io_mutex); 00733 00734 if (!zstr(runtime.core_db_pre_trans_execute)) { 00735 switch_cache_db_execute_sql_real(dbh, runtime.core_db_pre_trans_execute, &errmsg); 00736 if (errmsg) { 00737 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "SQL PRE TRANS EXEC %s [%s]\n", runtime.core_db_pre_trans_execute, errmsg); 00738 free(errmsg); 00739 } 00740 } 00741 00742 again: 00743 00744 while (begin_retries > 0) { 00745 again = 0; 00746 00747 if (runtime.odbc_dbtype == DBTYPE_DEFAULT) { 00748 switch_cache_db_execute_sql_real(dbh, "BEGIN", &errmsg); 00749 } else { 00750 switch_odbc_status_t result; 00751 00752 if ((result = switch_odbc_SQLSetAutoCommitAttr(dbh->native_handle.odbc_dbh, 0)) != SWITCH_ODBC_SUCCESS) { 00753 char tmp[100]; 00754 switch_snprintfv(tmp, sizeof(tmp), "%q-%i", "Unable to Set AutoCommit Off", result); 00755 errmsg = strdup(tmp); 00756 } 00757 } 00758 00759 if (errmsg) { 00760 begin_retries--; 00761 if (strstr(errmsg, "cannot start a transaction within a transaction")) { 00762 again = 1; 00763 } else { 00764 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "SQL Retry [%s]\n", errmsg); 00765 } 00766 free(errmsg); 00767 errmsg = NULL; 00768 00769 if (again) { 00770 if (runtime.odbc_dbtype == DBTYPE_DEFAULT) { 00771 switch_cache_db_execute_sql_real(dbh, "COMMIT", NULL); 00772 } else { 00773 switch_odbc_SQLEndTran(dbh->native_handle.odbc_dbh, 1); 00774 switch_odbc_SQLSetAutoCommitAttr(dbh->native_handle.odbc_dbh, 1); 00775 } 00776 00777 goto again; 00778 } 00779 00780 switch_yield(100000); 00781 00782 if (begin_retries == 0) { 00783 goto done; 00784 } 00785 00786 continue; 00787 } 00788 00789 break; 00790 } 00791 00792 00793 if (!zstr(runtime.core_db_inner_pre_trans_execute)) { 00794 switch_cache_db_execute_sql_real(dbh, runtime.core_db_inner_pre_trans_execute, &errmsg); 00795 if (errmsg) { 00796 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "SQL PRE TRANS EXEC %s [%s]\n", runtime.core_db_inner_pre_trans_execute, errmsg); 00797 free(errmsg); 00798 } 00799 } 00800 00801 while (retries > 0) { 00802 00803 switch_cache_db_execute_sql(dbh, sql, &errmsg); 00804 00805 if (errmsg) { 00806 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "SQL ERR [%s]\n", errmsg); 00807 free(errmsg); 00808 errmsg = NULL; 00809 switch_yield(100000); 00810 retries--; 00811 if (retries == 0 && forever) { 00812 retries = 1000; 00813 continue; 00814 } 00815 } else { 00816 status = SWITCH_STATUS_SUCCESS; 00817 break; 00818 } 00819 } 00820 00821 if (!zstr(runtime.core_db_inner_post_trans_execute)) { 00822 switch_cache_db_execute_sql_real(dbh, runtime.core_db_inner_post_trans_execute, &errmsg); 00823 if (errmsg) { 00824 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "SQL POST TRANS EXEC %s [%s]\n", runtime.core_db_inner_post_trans_execute, errmsg); 00825 free(errmsg); 00826 } 00827 } 00828 00829 done: 00830 00831 if (runtime.odbc_dbtype == DBTYPE_DEFAULT) { 00832 switch_cache_db_execute_sql_real(dbh, "COMMIT", NULL); 00833 } else { 00834 switch_odbc_SQLEndTran(dbh->native_handle.odbc_dbh, 1); 00835 switch_odbc_SQLSetAutoCommitAttr(dbh->native_handle.odbc_dbh, 1); 00836 } 00837 00838 if (!zstr(runtime.core_db_post_trans_execute)) { 00839 switch_cache_db_execute_sql_real(dbh, runtime.core_db_post_trans_execute, &errmsg); 00840 if (errmsg) { 00841 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "SQL POST TRANS EXEC %s [%s]\n", runtime.core_db_post_trans_execute, errmsg); 00842 free(errmsg); 00843 } 00844 } 00845 00846 if (io_mutex) switch_mutex_unlock(io_mutex); 00847 00848 return status; 00849 }
| void switch_cache_db_release_db_handle | ( | switch_cache_db_handle_t ** | dbh | ) |
Returns the handle to the pool, handle is NOT available to other threads until the allocating thread actually terminates.
| [in] | The | handle |
Definition at line 295 of file switch_core_sqldb.c.
References sql_manager, switch_epoch_time_now(), switch_mutex_lock(), and switch_mutex_unlock().
Referenced by switch_cache_db_dismiss_db_handle(), switch_console_expand_alias(), switch_console_list_uuid(), switch_console_set_alias(), switch_console_set_complete(), switch_core_sql_thread(), and switch_core_sqldb_start().
00296 { 00297 if (dbh && *dbh) { 00298 switch_mutex_lock(sql_manager.dbh_mutex); 00299 (*dbh)->last_used = switch_epoch_time_now(NULL); 00300 00301 (*dbh)->io_mutex = NULL; 00302 00303 if ((*dbh)->use_count) { 00304 if (--(*dbh)->use_count == 0) { 00305 (*dbh)->thread_hash = 1; 00306 } 00307 } 00308 switch_mutex_unlock((*dbh)->mutex); 00309 sql_manager.total_used_handles--; 00310 *dbh = NULL; 00311 switch_mutex_unlock(sql_manager.dbh_mutex); 00312 } 00313 }
| void switch_cache_db_status | ( | switch_stream_handle_t * | stream | ) |
Provides some feedback as to the status of the db connection pool.
| [in] | stream | stream for status |
Definition at line 2147 of file switch_core_sqldb.c.
References CACHE_DB_LEN, switch_cache_db_handle::creator, switch_cache_db_handle::last_used, switch_cache_db_handle::last_user, switch_cache_db_handle::mutex, switch_cache_db_handle::name, switch_cache_db_handle::next, sql_manager, switch_cache_db_type_name(), switch_epoch_time_now(), SWITCH_FALSE, switch_mutex_lock(), switch_mutex_trylock(), switch_mutex_unlock(), SWITCH_STATUS_SUCCESS, SWITCH_TRUE, switch_cache_db_handle::type, and switch_cache_db_handle::use_count.
02148 { 02149 /* return some status info suitable for the cli */ 02150 switch_cache_db_handle_t *dbh = NULL; 02151 switch_bool_t locked = SWITCH_FALSE; 02152 time_t now = switch_epoch_time_now(NULL); 02153 char cleankey_str[CACHE_DB_LEN]; 02154 char *pos1 = NULL; 02155 char *pos2 = NULL; 02156 int count = 0, used = 0; 02157 02158 switch_mutex_lock(sql_manager.dbh_mutex); 02159 02160 for (dbh = sql_manager.handle_pool; dbh; dbh = dbh->next) { 02161 char *needle = "pass=\""; 02162 time_t diff = 0; 02163 02164 diff = now - dbh->last_used; 02165 02166 if (switch_mutex_trylock(dbh->mutex) == SWITCH_STATUS_SUCCESS) { 02167 switch_mutex_unlock(dbh->mutex); 02168 locked = SWITCH_FALSE; 02169 } else { 02170 locked = SWITCH_TRUE; 02171 } 02172 02173 /* sanitize password */ 02174 memset(cleankey_str, 0, sizeof(cleankey_str)); 02175 pos1 = strstr(dbh->name, needle) + strlen(needle); 02176 pos2 = strstr(pos1, "\""); 02177 strncpy(cleankey_str, dbh->name, pos1 - dbh->name); 02178 strcpy(&cleankey_str[pos1 - dbh->name], pos2); 02179 02180 count++; 02181 02182 if (dbh->use_count) { 02183 used++; 02184 } 02185 02186 stream->write_function(stream, "%s\n\tType: %s\n\tLast used: %d\n\tFlags: %s, %s(%d)\n" 02187 "\tCreator: %s\n\tLast User: %s\n", 02188 cleankey_str, 02189 switch_cache_db_type_name(dbh->type), 02190 diff, 02191 locked ? "Locked" : "Unlocked", 02192 dbh->use_count ? "Attached" : "Detached", dbh->use_count, dbh->creator, dbh->last_user); 02193 } 02194 02195 stream->write_function(stream, "%d total. %d in use.\n", count, used); 02196 02197 switch_mutex_unlock(sql_manager.dbh_mutex); 02198 }
| switch_bool_t switch_cache_db_test_reactive | ( | switch_cache_db_handle_t * | db, | |
| const char * | test_sql, | |||
| const char * | drop_sql, | |||
| const char * | reactive_sql | |||
| ) |
Definition at line 895 of file switch_core_sqldb.c.
References io_mutex, runtime, SCDB_TYPE_CORE_DB, SCDB_TYPE_ODBC, SCF_AUTO_SCHEMAS, SCF_CLEAR_SQL, switch_cache_db_execute_sql(), SWITCH_CHANNEL_LOG, switch_core_db_exec(), switch_core_db_free(), SWITCH_FALSE, SWITCH_LOG_DEBUG, switch_log_printf(), switch_mutex_lock(), switch_mutex_unlock(), switch_odbc_handle_exec(), SWITCH_ODBC_SUCCESS, switch_test_flag, and SWITCH_TRUE.
Referenced by switch_core_sqldb_start().
00897 { 00898 char *errmsg; 00899 switch_bool_t r = SWITCH_TRUE; 00900 switch_mutex_t *io_mutex = dbh->io_mutex; 00901 00902 if (!switch_test_flag((&runtime), SCF_CLEAR_SQL)) { 00903 return SWITCH_TRUE; 00904 } 00905 00906 if (!switch_test_flag((&runtime), SCF_AUTO_SCHEMAS)) { 00907 switch_cache_db_execute_sql(dbh, (char *)test_sql, NULL); 00908 return SWITCH_TRUE; 00909 } 00910 00911 if (io_mutex) switch_mutex_lock(io_mutex); 00912 00913 switch (dbh->type) { 00914 case SCDB_TYPE_ODBC: 00915 { 00916 if (switch_odbc_handle_exec(dbh->native_handle.odbc_dbh, test_sql, NULL, NULL) != SWITCH_ODBC_SUCCESS) { 00917 r = SWITCH_FALSE; 00918 if (drop_sql) { 00919 switch_odbc_handle_exec(dbh->native_handle.odbc_dbh, drop_sql, NULL, NULL); 00920 } 00921 switch_odbc_handle_exec(dbh->native_handle.odbc_dbh, reactive_sql, NULL, NULL); 00922 } 00923 } 00924 break; 00925 case SCDB_TYPE_CORE_DB: 00926 { 00927 if (test_sql) { 00928 switch_core_db_exec(dbh->native_handle.core_db_dbh, test_sql, NULL, NULL, &errmsg); 00929 00930 if (errmsg) { 00931 r = SWITCH_FALSE; 00932 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "SQL ERR [%s]\n[%s]\nAuto Generating Table!\n", errmsg, test_sql); 00933 switch_core_db_free(errmsg); 00934 errmsg = NULL; 00935 if (drop_sql) { 00936 switch_core_db_exec(dbh->native_handle.core_db_dbh, drop_sql, NULL, NULL, &errmsg); 00937 } 00938 if (errmsg) { 00939 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "SQL ERR [%s]\n[%s]\n", errmsg, drop_sql); 00940 switch_core_db_free(errmsg); 00941 errmsg = NULL; 00942 } 00943 switch_core_db_exec(dbh->native_handle.core_db_dbh, reactive_sql, NULL, NULL, &errmsg); 00944 if (errmsg) { 00945 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "SQL ERR [%s]\n[%s]\n", errmsg, reactive_sql); 00946 switch_core_db_free(errmsg); 00947 errmsg = NULL; 00948 } 00949 } 00950 } 00951 } 00952 break; 00953 } 00954 00955 00956 if (io_mutex) switch_mutex_unlock(io_mutex); 00957 00958 return r; 00959 }
| static const char* switch_cache_db_type_name | ( | switch_cache_db_handle_type_t | type | ) | [inline, static] |
Definition at line 2191 of file switch_core.h.
References SCDB_TYPE_CORE_DB, and SCDB_TYPE_ODBC.
Referenced by _switch_cache_db_get_db_handle(), and switch_cache_db_status().
02192 { 02193 const char *type_str = "INVALID"; 02194 02195 switch (type) { 02196 case SCDB_TYPE_ODBC: 02197 { 02198 type_str = "ODBC"; 02199 } 02200 break; 02201 case SCDB_TYPE_CORE_DB: 02202 { 02203 type_str = "CORE_DB"; 02204 } 02205 break; 02206 } 02207 02208 return type_str; 02209 }
| void switch_close_extra_files | ( | int * | keep, | |
| int | keep_ttl | |||
| ) |
Definition at line 2521 of file switch_core.c.
References skip(), and switch_max_file_desc().
Referenced by preprocess_exec(), switch_stream_system_fork(), and switch_system_fork().
02522 { 02523 int open_max = switch_max_file_desc(); 02524 int i, j; 02525 02526 for (i = 3; i < open_max; i++) { 02527 if (keep) { 02528 for (j = 0; j < keep_ttl; j++) { 02529 if (i == keep[j]) { 02530 goto skip; 02531 } 02532 } 02533 } 02534 02535 close(i); 02536 02537 skip: 02538 02539 continue; 02540 02541 } 02542 }
| switch_status_t switch_core_add_registration | ( | const char * | user, | |
| const char * | realm, | |||
| const char * | token, | |||
| const char * | url, | |||
| uint32_t | expires, | |||
| const char * | network_ip, | |||
| const char * | network_port, | |||
| const char * | network_proto | |||
| ) |
Add user registration.
| [in] | user | |
| [in] | realm | |
| [in] | token | |
| [in] | url | - a freeswitch dial string |
| [in] | expires | |
| [in] | network_ip | |
| [in] | network_port | |
| [in] | network_proto | - one of tls, tcp, udp |
| [out] | err | - Error if it exists |
Definition at line 1845 of file switch_core_sqldb.c.
References switch_runtime::multiple_registrations, runtime, SCF_USE_SQL, sql_manager, switch_core_get_switchname(), switch_mprintf(), switch_queue_push(), SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, switch_str_nil, and switch_test_flag.
01847 { 01848 char *sql; 01849 01850 if (!switch_test_flag((&runtime), SCF_USE_SQL)) { 01851 return SWITCH_STATUS_FALSE; 01852 } 01853 01854 if (runtime.multiple_registrations) { 01855 sql = switch_mprintf("delete from registrations where hostname='%q' and (url='%q' or token='%q')", 01856 switch_core_get_switchname(), url, switch_str_nil(token)); 01857 } else { 01858 sql = switch_mprintf("delete from registrations where reg_user='%q' and realm='%q' and hostname='%q'", 01859 user, realm, switch_core_get_switchname()); 01860 } 01861 01862 switch_queue_push(sql_manager.sql_queue[0], sql); 01863 01864 sql = switch_mprintf("insert into registrations (reg_user,realm,token,url,expires,network_ip,network_port,network_proto,hostname) " 01865 "values ('%q','%q','%q','%q',%ld,'%q','%q','%q','%q')", 01866 switch_str_nil(user), 01867 switch_str_nil(realm), 01868 switch_str_nil(token), 01869 switch_str_nil(url), 01870 expires, 01871 switch_str_nil(network_ip), 01872 switch_str_nil(network_port), 01873 switch_str_nil(network_proto), 01874 switch_core_get_switchname() 01875 ); 01876 01877 01878 switch_queue_push(sql_manager.sql_queue[0], sql); 01879 01880 return SWITCH_STATUS_SUCCESS; 01881 }
| const char* switch_core_banner | ( | void | ) |
Definition at line 1884 of file switch_core.c.
Referenced by switch_core_init_and_modload().
01885 { 01886 01887 01888 return ("\n" 01889 " _____ ______ _____ _____ ____ _ _ \n" 01890 " | ___| __ ___ ___/ ___\\ \\ / /_ _|_ _/ ___| | | | \n" 01891 " | |_ | '__/ _ \\/ _ \\___ \\\\ \\ /\\ / / | | | || | | |_| | \n" 01892 " | _|| | | __/ __/___) |\\ V V / | | | || |___| _ | \n" 01893 " |_| |_| \\___|\\___|____/ \\_/\\_/ |___| |_| \\____|_| |_| \n" 01894 "\n" 01895 "************************************************************\n" 01896 "* Anthony Minessale II, Michael Jerris, Brian West, Others *\n" 01897 "* FreeSWITCH (http://www.freeswitch.org) *\n" 01898 "* Paypal Donations Appreciated: paypal@freeswitch.org *\n" 01899 "* Brought to you by ClueCon http://www.cluecon.com/ *\n" "************************************************************\n" "\n"); 01900 }
| uint32_t switch_core_debug_level | ( | void | ) |
Definition at line 2040 of file switch_core.c.
References switch_runtime::debug_level, and runtime.
02041 { 02042 return runtime.debug_level; 02043 }
| switch_status_t switch_core_del_registration | ( | const char * | user, | |
| const char * | realm, | |||
| const char * | token | |||
| ) |
Delete user registration.
| [in] | user | |
| [in] | realm | |
| [in] | token | |
| [out] | err | - Error if it exists |
Definition at line 1883 of file switch_core_sqldb.c.
References switch_runtime::multiple_registrations, runtime, SCF_USE_SQL, sql_manager, switch_core_get_switchname(), switch_mprintf(), switch_queue_push(), SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, switch_test_flag, and zstr.
01884 { 01885 01886 char *sql; 01887 01888 if (!switch_test_flag((&runtime), SCF_USE_SQL)) { 01889 return SWITCH_STATUS_FALSE; 01890 } 01891 01892 if (!zstr(token) && runtime.multiple_registrations) { 01893 sql = switch_mprintf("delete from registrations where reg_user='%q' and realm='%q' and hostname='%q' and token='%q'", user, realm, switch_core_get_switchname(), token); 01894 } else { 01895 sql = switch_mprintf("delete from registrations where reg_user='%q' and realm='%q' and hostname='%q'", user, realm, switch_core_get_switchname()); 01896 } 01897 01898 switch_queue_push(sql_manager.sql_queue[0], sql); 01899 01900 return SWITCH_STATUS_SUCCESS; 01901 }
| switch_status_t switch_core_expire_registration | ( | int | force | ) |
Expire user registrations.
| [in] | force | delete all registrations |
| [out] | err | - Error if it exists |
Definition at line 1903 of file switch_core_sqldb.c.
References runtime, SCF_USE_SQL, sql_manager, switch_core_get_switchname(), switch_epoch_time_now(), switch_mprintf(), switch_queue_push(), SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, and switch_test_flag.
Referenced by switch_core_sql_db_thread().
01904 { 01905 01906 char *sql; 01907 time_t now; 01908 01909 if (!switch_test_flag((&runtime), SCF_USE_SQL)) { 01910 return SWITCH_STATUS_FALSE; 01911 } 01912 01913 now = switch_epoch_time_now(NULL); 01914 01915 if (force) { 01916 sql = switch_mprintf("delete from registrations where hostname='%q'", switch_core_get_switchname()); 01917 } else { 01918 sql = switch_mprintf("delete from registrations where expires > 0 and expires <= %ld and hostname='%q'", now, switch_core_get_switchname()); 01919 } 01920 01921 switch_queue_push(sql_manager.sql_queue[0], sql); 01922 01923 return SWITCH_STATUS_SUCCESS; 01924 01925 }
| switch_bool_t switch_core_session_in_thread | ( | switch_core_session_t * | session | ) |
Definition at line 1392 of file switch_core_session.c.
References SWITCH_FALSE, switch_thread_equal(), switch_thread_self(), and SWITCH_TRUE.
Referenced by switch_channel_check_signal(), switch_channel_state_change_pending(), and switch_ivr_nomedia().
01393 { 01394 return switch_thread_equal(switch_thread_self(), session->thread_id) ? SWITCH_TRUE : SWITCH_FALSE; 01395 }
| void switch_core_set_signal_handlers | ( | void | ) |
Definition at line 2008 of file switch_core.c.
References handle_SIGCHLD(), handle_SIGHUP(), runtime, SCF_THREADED_SYSTEM_EXEC, and switch_test_flag.
Referenced by switch_core_init_and_modload(), switch_loadable_module_load_file(), and switch_system_fork().
02009 { 02010 /* set signal handlers */ 02011 signal(SIGINT, SIG_IGN); 02012 #ifndef WIN32 02013 if (switch_test_flag((&runtime), SCF_THREADED_SYSTEM_EXEC)) { 02014 signal(SIGCHLD, SIG_DFL); 02015 } else { 02016 signal(SIGCHLD, handle_SIGCHLD); 02017 } 02018 #endif 02019 #ifdef SIGPIPE 02020 signal(SIGPIPE, SIG_IGN); 02021 #endif 02022 #ifdef SIGQUIT 02023 signal(SIGQUIT, SIG_IGN); 02024 #endif 02025 #ifdef SIGPOLL 02026 signal(SIGPOLL, SIG_IGN); 02027 #endif 02028 #ifdef SIGIO 02029 signal(SIGIO, SIG_IGN); 02030 #endif 02031 #ifdef TRAP_BUS 02032 signal(SIGBUS, handle_SIGBUS); 02033 #endif 02034 #ifdef SIGUSR1 02035 signal(SIGUSR1, handle_SIGHUP); 02036 #endif 02037 signal(SIGHUP, handle_SIGHUP); 02038 }
| switch_status_t switch_core_thread_set_cpu_affinity | ( | int | cpu | ) |
Definition at line 1328 of file switch_core.c.
References SWITCH_STATUS_FALSE, and SWITCH_STATUS_SUCCESS.
Referenced by SWITCH_MODULE_RUNTIME_FUNCTION().
01329 { 01330 switch_status_t status = SWITCH_STATUS_FALSE; 01331 01332 if (cpu > -1) { 01333 01334 #ifdef HAVE_CPU_SET_MACROS 01335 cpu_set_t set; 01336 01337 CPU_ZERO(&set); 01338 CPU_SET(cpu, &set); 01339 01340 if (!sched_setaffinity(0, sizeof(set), &set)) { 01341 status = SWITCH_STATUS_SUCCESS; 01342 } 01343 01344 #else 01345 #if WIN32 01346 if (SetThreadAffinityMask(GetCurrentThread(), (DWORD_PTR) cpu)) { 01347 status = SWITCH_STATUS_SUCCESS; 01348 } 01349 #endif 01350 #endif 01351 } 01352 01353 return status; 01354 }
| uint32_t switch_default_ptime | ( | const char * | name, | |
| uint32_t | number | |||
| ) |
Definition at line 1615 of file switch_core.c.
References switch_runtime::ptimes, runtime, and switch_core_hash_find().
Referenced by switch_loadable_module_get_codecs(), and switch_loadable_module_get_codecs_sorted().
01616 { 01617 uint32_t *p; 01618 01619 if ((p = switch_core_hash_find(runtime.ptimes, name))) { 01620 return *p; 01621 } 01622 01623 return 20; 01624 }
| int switch_max_file_desc | ( | void | ) |
Definition at line 2505 of file switch_core.c.
Referenced by switch_close_extra_files().
02506 { 02507 int max = 0; 02508 02509 #ifndef WIN32 02510 #if defined(HAVE_GETDTABLESIZE) 02511 max = getdtablesize(); 02512 #else 02513 max = sysconf(_SC_OPEN_MAX); 02514 #endif 02515 #endif 02516 02517 return max; 02518 02519 }
| void switch_os_yield | ( | void | ) |
Definition at line 143 of file switch_time.c.
Referenced by switch_cond_next(), SWITCH_MODULE_RUNTIME_FUNCTION(), and timer_next().
00144 { 00145 #if defined(WIN32) 00146 SwitchToThread(); 00147 #else 00148 sched_yield(); 00149 #endif 00150 }
| void switch_say_file | ( | switch_say_file_handle_t * | sh, | |
| const char * | fmt, | |||
| ... | ||||
| ) |
Definition at line 2443 of file switch_loadable_module.c.
References buf, and switch_vsnprintf().
02444 { 02445 char buf[256] = ""; 02446 int ret; 02447 va_list ap; 02448 02449 va_start(ap, fmt); 02450 02451 if ((ret = switch_vsnprintf(buf, sizeof(buf), fmt, ap)) > 0) { 02452 if (!sh->cnt++) { 02453 sh->stream.write_function(&sh->stream, "file_string://%s.%s", buf, sh->ext); 02454 } else { 02455 sh->stream.write_function(&sh->stream, "!%s.%s", buf, sh->ext); 02456 } 02457 02458 } 02459 02460 va_end(ap); 02461 }
| switch_status_t switch_say_file_handle_create | ( | switch_say_file_handle_t ** | sh, | |
| const char * | ext, | |||
| switch_event_t ** | var_event | |||
| ) |
Definition at line 2420 of file switch_loadable_module.c.
References switch_assert, SWITCH_STANDARD_STREAM, SWITCH_STATUS_SUCCESS, and zstr.
02421 { 02422 switch_assert(sh); 02423 02424 if (zstr(ext)) { 02425 ext = "wav"; 02426 } 02427 02428 *sh = malloc(sizeof(**sh)); 02429 memset(*sh, 0, sizeof(**sh)); 02430 02431 SWITCH_STANDARD_STREAM((*sh)->stream); 02432 02433 if (var_event) { 02434 (*sh)->param_event = *var_event; 02435 *var_event = NULL; 02436 } 02437 02438 (*sh)->ext = strdup(ext); 02439 02440 return SWITCH_STATUS_SUCCESS; 02441 }
| void switch_say_file_handle_destroy | ( | switch_say_file_handle_t ** | sh | ) |
Definition at line 2406 of file switch_loadable_module.c.
References switch_assert, switch_event_destroy(), and switch_safe_free.
02407 { 02408 switch_assert(sh); 02409 02410 switch_safe_free((*sh)->stream.data); 02411 switch_safe_free((*sh)->ext); 02412 02413 if ((*sh)->param_event) { 02414 switch_event_destroy(&(*sh)->param_event); 02415 } 02416 free(*sh); 02417 *sh = NULL; 02418 }
| char* switch_say_file_handle_detach_path | ( | switch_say_file_handle_t * | sh | ) |
Definition at line 2395 of file switch_loadable_module.c.
References switch_assert.
02396 { 02397 char *path; 02398 02399 switch_assert(sh); 02400 path = (char *) sh->stream.data; 02401 sh->stream.data = NULL; 02402 return path; 02403 }
| char* switch_say_file_handle_get_path | ( | switch_say_file_handle_t * | sh | ) |
| char* switch_say_file_handle_get_variable | ( | switch_say_file_handle_t * | sh, | |
| const char * | var | |||
| ) |
Definition at line 2378 of file switch_loadable_module.c.
References switch_event_get_header.
02379 { 02380 char *ret = NULL; 02381 02382 if (sh->param_event) { 02383 ret = switch_event_get_header(sh->param_event, var); 02384 } 02385 02386 return ret; 02387 02388 }
1.4.7