adding const qualifiers across the api as appropriate.

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@5165 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Michael Jerris 2007-05-12 14:48:14 +00:00
parent 8107c49a64
commit a4ff7e88da
32 changed files with 255 additions and 206 deletions

View File

@ -117,7 +117,7 @@ SWITCH_DECLARE(void) switch_buffer_set_loops(switch_buffer_t *buffer, int32_t lo
* \param datalen amount of data to be written * \param datalen amount of data to be written
* \return int amount of buffer used after the write, or 0 if no space available * \return int amount of buffer used after the write, or 0 if no space available
*/ */
SWITCH_DECLARE(switch_size_t) switch_buffer_write(switch_buffer_t *buffer, void *data, switch_size_t datalen); SWITCH_DECLARE(switch_size_t) switch_buffer_write(switch_buffer_t *buffer, const void *data, switch_size_t datalen);
/*! \brief Remove data from the buffer /*! \brief Remove data from the buffer
* \param buffer any buffer of type switch_buffer_t * \param buffer any buffer of type switch_buffer_t

View File

@ -128,7 +128,7 @@ struct switch_caller_extension {
\param extension_number extension number \param extension_number extension number
\return a new extension object allocated from the session's memory pool \return a new extension object allocated from the session's memory pool
*/ */
SWITCH_DECLARE(switch_caller_extension_t *) switch_caller_extension_new(switch_core_session_t *session, char *extension_name, char *extension_number); SWITCH_DECLARE(switch_caller_extension_t *) switch_caller_extension_new(switch_core_session_t *session, const char *extension_name, const char *extension_number);
/*! /*!
\brief Add an application (instruction) to the given extension \brief Add an application (instruction) to the given extension
@ -138,7 +138,7 @@ SWITCH_DECLARE(switch_caller_extension_t *) switch_caller_extension_new(switch_c
\param extra_data optional argument to the application \param extra_data optional argument to the application
*/ */
SWITCH_DECLARE(void) switch_caller_extension_add_application(switch_core_session_t *session, SWITCH_DECLARE(void) switch_caller_extension_add_application(switch_core_session_t *session,
switch_caller_extension_t *caller_extension, char *application_name, char *extra_data); switch_caller_extension_t *caller_extension, const char *application_name, const char *extra_data);
/*! /*!
@ -147,7 +147,7 @@ SWITCH_DECLARE(void) switch_caller_extension_add_application(switch_core_session
\param name the name \param name the name
\note this function is meant for situations where the name paramater is the contents of the variable \note this function is meant for situations where the name paramater is the contents of the variable
*/ */
SWITCH_DECLARE(char *) switch_caller_get_field_by_name(switch_caller_profile_t *caller_profile, char *name); SWITCH_DECLARE(char *) switch_caller_get_field_by_name(switch_caller_profile_t *caller_profile, const char *name);
/*! /*!
\brief Create a new caller profile object \brief Create a new caller profile object
@ -191,7 +191,7 @@ SWITCH_DECLARE(switch_caller_profile_t *) switch_caller_profile_clone(switch_cor
\param event the event to add the information to \param event the event to add the information to
*/ */
SWITCH_DECLARE(void) switch_caller_profile_event_set_data(switch_caller_profile_t *caller_profile, char *prefix, switch_event_t *event); SWITCH_DECLARE(void) switch_caller_profile_event_set_data(switch_caller_profile_t *caller_profile, const char *prefix, switch_event_t *event);
SWITCH_END_EXTERN_C SWITCH_END_EXTERN_C
/** @} */ /** @} */

View File

@ -89,7 +89,7 @@ SWITCH_DECLARE(switch_channel_state_t) switch_channel_perform_set_state(switch_c
\param str the string to check \param str the string to check
\return the code \return the code
*/ */
SWITCH_DECLARE(switch_call_cause_t) switch_channel_str2cause(char *str); SWITCH_DECLARE(switch_call_cause_t) switch_channel_str2cause(const char *str);
/*! /*!
\brief return the cause code for a given channel \brief return the cause code for a given channel
@ -103,7 +103,7 @@ SWITCH_DECLARE(switch_call_cause_t) switch_channel_get_cause(switch_channel_t *c
\param cause the code to check \param cause the code to check
\return the string \return the string
*/ */
SWITCH_DECLARE(char *) switch_channel_cause2str(switch_call_cause_t cause); SWITCH_DECLARE(const char *) switch_channel_cause2str(switch_call_cause_t cause);
/*! /*!
\brief View the timetable of a channel \brief View the timetable of a channel
@ -136,7 +136,7 @@ SWITCH_DECLARE(switch_status_t) switch_channel_init(switch_channel_t *channel, s
\param rpid the rpid if for the icon to use \param rpid the rpid if for the icon to use
\param status the status message \param status the status message
*/ */
SWITCH_DECLARE(void) switch_channel_presence(switch_channel_t *channel, char *rpid, char *status); SWITCH_DECLARE(void) switch_channel_presence(switch_channel_t *channel, const char *rpid, const char *status);
/*! /*!
\brief Uninitalize a channel \brief Uninitalize a channel
@ -218,7 +218,7 @@ SWITCH_DECLARE(switch_status_t) switch_channel_set_variable_nodup(switch_channel
\param varname the name of the variable \param varname the name of the variable
\return the value of the requested variable \return the value of the requested variable
*/ */
SWITCH_DECLARE(char *) switch_channel_get_variable(switch_channel_t *channel, char *varname); SWITCH_DECLARE(char *) switch_channel_get_variable(switch_channel_t *channel, const char *varname);
/*! /*!
* Start iterating over the entries in the channel variable list. * Start iterating over the entries in the channel variable list.
@ -373,7 +373,7 @@ SWITCH_DECLARE(const switch_state_handler_table_t *) switch_channel_get_state_ha
\param private_info void pointer to private data \param private_info void pointer to private data
\return SWITCH_STATUS_SUCCESS if data was set \return SWITCH_STATUS_SUCCESS if data was set
*/ */
SWITCH_DECLARE(switch_status_t) switch_channel_set_private(switch_channel_t *channel, char *key, void *private_info); SWITCH_DECLARE(switch_status_t) switch_channel_set_private(switch_channel_t *channel, const char *key, const void *private_info);
/*! /*!
\brief Retrieve private from a given channel \brief Retrieve private from a given channel
@ -381,7 +381,7 @@ SWITCH_DECLARE(switch_status_t) switch_channel_set_private(switch_channel_t *cha
\param key unique keyname to retrieve your private data \param key unique keyname to retrieve your private data
\return void pointer to channel's private data \return void pointer to channel's private data
*/ */
SWITCH_DECLARE(void *) switch_channel_get_private(switch_channel_t *channel, char *key); SWITCH_DECLARE(void *) switch_channel_get_private(switch_channel_t *channel, const char *key);
/*! /*!
\brief Assign a name to a given channel \brief Assign a name to a given channel
@ -389,7 +389,7 @@ SWITCH_DECLARE(void *) switch_channel_get_private(switch_channel_t *channel, cha
\param name name to assign \param name name to assign
\return SWITCH_STATUS_SUCCESS if name was assigned \return SWITCH_STATUS_SUCCESS if name was assigned
*/ */
SWITCH_DECLARE(switch_status_t) switch_channel_set_name(switch_channel_t *channel, char *name); SWITCH_DECLARE(switch_status_t) switch_channel_set_name(switch_channel_t *channel, const char *name);
/*! /*!
\brief Retrieve the name of a given channel \brief Retrieve the name of a given channel
@ -423,7 +423,7 @@ SWITCH_DECLARE(switch_size_t) switch_channel_has_dtmf(switch_channel_t *channel)
\param dtmf string of digits to queue \param dtmf string of digits to queue
\return SWITCH_STATUS_SUCCESS if successful \return SWITCH_STATUS_SUCCESS if successful
*/ */
SWITCH_DECLARE(switch_status_t) switch_channel_queue_dtmf(switch_channel_t *channel, char *dtmf); SWITCH_DECLARE(switch_status_t) switch_channel_queue_dtmf(switch_channel_t *channel, const char *dtmf);
/*! /*!
\brief Retrieve DTMF digits from a given channel \brief Retrieve DTMF digits from a given channel
@ -446,7 +446,7 @@ SWITCH_DECLARE(const char *) switch_channel_state_name(switch_channel_state_t st
\param name the name of the state \param name the name of the state
\return the enum value (numeric) \return the enum value (numeric)
*/ */
SWITCH_DECLARE(switch_channel_state_t) switch_channel_name_state(char *name); SWITCH_DECLARE(switch_channel_state_t) switch_channel_name_state(const char *name);
/*! /*!
\brief Add information about a given channel to an event object \brief Add information about a given channel to an event object

View File

@ -220,7 +220,7 @@ SWITCH_DECLARE(void) switch_core_port_allocator_destroy(switch_core_port_allocat
\param err a pointer to set any errors to \param err a pointer to set any errors to
\note to be called at application startup \note to be called at application startup
*/ */
SWITCH_DECLARE(switch_status_t) switch_core_init(char *console, const char **err); SWITCH_DECLARE(switch_status_t) switch_core_init(const char *console, const char **err);
/*! /*!
\brief Initilize the core and load modules \brief Initilize the core and load modules
@ -228,7 +228,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_init(char *console, const char **err
\param err a pointer to set any errors to \param err a pointer to set any errors to
\note to be called at application startup instead of switch_core_init. Includes module loading. \note to be called at application startup instead of switch_core_init. Includes module loading.
*/ */
SWITCH_DECLARE(switch_status_t) switch_core_init_and_modload(char *console, const char **err); SWITCH_DECLARE(switch_status_t) switch_core_init_and_modload(const char *console, const char **err);
/*! /*!
\brief Set/Get Session Limit \brief Set/Get Session Limit
@ -503,7 +503,7 @@ SWITCH_DECLARE(switch_core_session_t *) switch_core_session_perform_locate(char
#ifdef SWITCH_DEBUG_RWLOCKS #ifdef SWITCH_DEBUG_RWLOCKS
#define switch_core_session_locate(uuid_str) switch_core_session_perform_locate(uuid_str, __FILE__, __SWITCH_FUNC__, __LINE__) #define switch_core_session_locate(uuid_str) switch_core_session_perform_locate(uuid_str, __FILE__, __SWITCH_FUNC__, __LINE__)
#else #else
SWITCH_DECLARE(switch_core_session_t *) switch_core_session_locate(char *uuid_str); SWITCH_DECLARE(switch_core_session_t *) switch_core_session_locate(const char *uuid_str);
#endif #endif
/*! /*!
@ -511,14 +511,14 @@ SWITCH_DECLARE(switch_core_session_t *) switch_core_session_locate(char *uuid_st
\param varname the name of the variable \param varname the name of the variable
\return the value of the desired variable \return the value of the desired variable
*/ */
SWITCH_DECLARE(char *) switch_core_get_variable(char *varname); SWITCH_DECLARE(char *) switch_core_get_variable(const char *varname);
/*! /*!
\brief Add a global variable to the core \brief Add a global variable to the core
\param varname the name of the variable \param varname the name of the variable
\param value the value of the variable \param value the value of the variable
*/ */
SWITCH_DECLARE(void) switch_core_set_variable(char *varname, char *value); SWITCH_DECLARE(void) switch_core_set_variable(const char *varname, const char *value);
/*! /*!
\brief Hangup All Sessions \brief Hangup All Sessions
@ -1395,7 +1395,7 @@ SWITCH_DECLARE(void) switch_core_runtime_loop(int bg);
\brief Set the output console to the desired file \brief Set the output console to the desired file
\param console the file path \param console the file path
*/ */
SWITCH_DECLARE(switch_status_t) switch_core_set_console(char *console); SWITCH_DECLARE(switch_status_t) switch_core_set_console(const char *console);
/*! /*!
\brief Breakdown a number of milliseconds into various time spec \brief Breakdown a number of milliseconds into various time spec

View File

@ -97,21 +97,21 @@ SWITCH_DECLARE(void) switch_loadable_module_shutdown(void);
\param name the name of the endpoint \param name the name of the endpoint
\return the desired endpoint interface \return the desired endpoint interface
*/ */
SWITCH_DECLARE(switch_endpoint_interface_t *) switch_loadable_module_get_endpoint_interface(char *name); SWITCH_DECLARE(switch_endpoint_interface_t *) switch_loadable_module_get_endpoint_interface(const char *name);
/*! /*!
\brief Retrieve the codec interface by it's registered name \brief Retrieve the codec interface by it's registered name
\param name the name of the codec \param name the name of the codec
\return the desired codec interface \return the desired codec interface
*/ */
SWITCH_DECLARE(switch_codec_interface_t *) switch_loadable_module_get_codec_interface(char *name); SWITCH_DECLARE(switch_codec_interface_t *) switch_loadable_module_get_codec_interface(const char *name);
/*! /*!
\brief Retrieve the dialplan interface by it's registered name \brief Retrieve the dialplan interface by it's registered name
\param name the name of the dialplan \param name the name of the dialplan
\return the desired dialplan interface \return the desired dialplan interface
*/ */
SWITCH_DECLARE(switch_dialplan_interface_t *) switch_loadable_module_get_dialplan_interface(char *name); SWITCH_DECLARE(switch_dialplan_interface_t *) switch_loadable_module_get_dialplan_interface(const char *name);
/*! /*!
\brief build a dynamic module object and register it (for use in double embeded modules) \brief build a dynamic module object and register it (for use in double embeded modules)
@ -132,70 +132,70 @@ SWITCH_DECLARE(switch_status_t) switch_loadable_module_build_dynamic(char *filen
\param name the name of the timer \param name the name of the timer
\return the desired timer interface \return the desired timer interface
*/ */
SWITCH_DECLARE(switch_timer_interface_t *) switch_loadable_module_get_timer_interface(char *name); SWITCH_DECLARE(switch_timer_interface_t *) switch_loadable_module_get_timer_interface(const char *name);
/*! /*!
\brief Retrieve the application interface by it's registered name \brief Retrieve the application interface by it's registered name
\param name the name of the application \param name the name of the application
\return the desired application interface \return the desired application interface
*/ */
SWITCH_DECLARE(switch_application_interface_t *) switch_loadable_module_get_application_interface(char *name); SWITCH_DECLARE(switch_application_interface_t *) switch_loadable_module_get_application_interface(const char *name);
/*! /*!
\brief Retrieve the API interface by it's registered name \brief Retrieve the API interface by it's registered name
\param name the name of the API \param name the name of the API
\return the desired API interface \return the desired API interface
*/ */
SWITCH_DECLARE(switch_api_interface_t *) switch_loadable_module_get_api_interface(char *name); SWITCH_DECLARE(switch_api_interface_t *) switch_loadable_module_get_api_interface(const char *name);
/*! /*!
\brief Retrieve the file format interface by it's registered name \brief Retrieve the file format interface by it's registered name
\param name the name of the file format \param name the name of the file format
\return the desired file format interface \return the desired file format interface
*/ */
SWITCH_DECLARE(switch_file_interface_t *) switch_loadable_module_get_file_interface(char *name); SWITCH_DECLARE(switch_file_interface_t *) switch_loadable_module_get_file_interface(const char *name);
/*! /*!
\brief Retrieve the speech interface by it's registered name \brief Retrieve the speech interface by it's registered name
\param name the name of the speech interface \param name the name of the speech interface
\return the desired speech interface \return the desired speech interface
*/ */
SWITCH_DECLARE(switch_speech_interface_t *) switch_loadable_module_get_speech_interface(char *name); SWITCH_DECLARE(switch_speech_interface_t *) switch_loadable_module_get_speech_interface(const char *name);
/*! /*!
\brief Retrieve the asr interface by it's registered name \brief Retrieve the asr interface by it's registered name
\param name the name of the asr interface \param name the name of the asr interface
\return the desired asr interface \return the desired asr interface
*/ */
SWITCH_DECLARE(switch_asr_interface_t *) switch_loadable_module_get_asr_interface(char *name); SWITCH_DECLARE(switch_asr_interface_t *) switch_loadable_module_get_asr_interface(const char *name);
/*! /*!
\brief Retrieve the directory interface by it's registered name \brief Retrieve the directory interface by it's registered name
\param name the name of the directory interface \param name the name of the directory interface
\return the desired directory interface \return the desired directory interface
*/ */
SWITCH_DECLARE(switch_directory_interface_t *) switch_loadable_module_get_directory_interface(char *name); SWITCH_DECLARE(switch_directory_interface_t *) switch_loadable_module_get_directory_interface(const char *name);
/*! /*!
\brief Retrieve the chat interface by it's registered name \brief Retrieve the chat interface by it's registered name
\param name the name of the chat interface \param name the name of the chat interface
\return the desired chat interface \return the desired chat interface
*/ */
SWITCH_DECLARE(switch_chat_interface_t *) switch_loadable_module_get_chat_interface(char *name); SWITCH_DECLARE(switch_chat_interface_t *) switch_loadable_module_get_chat_interface(const char *name);
/*! /*!
\brief Retrieve the say interface by it's registered name \brief Retrieve the say interface by it's registered name
\param name the name of the say interface \param name the name of the say interface
\return the desired say interface \return the desired say interface
*/ */
SWITCH_DECLARE(switch_say_interface_t *) switch_loadable_module_get_say_interface(char *name); SWITCH_DECLARE(switch_say_interface_t *) switch_loadable_module_get_say_interface(const char *name);
/*! /*!
\brief Retrieve the management interface by it's registered name \brief Retrieve the management interface by it's registered name
\param relative_oid the relative oid of the management interface \param relative_oid the relative oid of the management interface
\return the desired management interface \return the desired management interface
*/ */
SWITCH_DECLARE(switch_management_interface_t *) switch_loadable_module_get_management_interface(char *relative_oid); SWITCH_DECLARE(switch_management_interface_t *) switch_loadable_module_get_management_interface(const char *relative_oid);
/*! /*!
\brief Retrieve the list of loaded codecs into an array \brief Retrieve the list of loaded codecs into an array
@ -226,7 +226,7 @@ SWITCH_DECLARE(int) switch_loadable_module_get_codecs_sorted(const switch_codec_
\param stream stream for output \param stream stream for output
\return the status returned by the API call \return the status returned by the API call
*/ */
SWITCH_DECLARE(switch_status_t) switch_api_execute(char *cmd, char *arg, switch_core_session_t *session, switch_stream_handle_t *stream); SWITCH_DECLARE(switch_status_t) switch_api_execute(const char *cmd, const char *arg, switch_core_session_t *session, switch_stream_handle_t *stream);
/*! /*!
\brief Load a module \brief Load a module

View File

@ -49,8 +49,8 @@ SWITCH_DECLARE(int) switch_regex_copy_substring(const char *subject, int *ovecto
SWITCH_DECLARE(void) switch_regex_free(void *data); SWITCH_DECLARE(void) switch_regex_free(void *data);
SWITCH_DECLARE(int) switch_regex_perform(char *field, char *expression, switch_regex_t **new_re, int *ovector, uint32_t olen); SWITCH_DECLARE(int) switch_regex_perform(const char *field, const char *expression, switch_regex_t **new_re, int *ovector, uint32_t olen);
SWITCH_DECLARE(void) switch_perform_substitution(switch_regex_t *re, int match_count, char *data, char *field_data, SWITCH_DECLARE(void) switch_perform_substitution(switch_regex_t *re, int match_count, const char *data, const char *field_data,
char *substituted, uint32_t len, int *ovector); char *substituted, uint32_t len, int *ovector);
/*! /*!
@ -59,7 +59,7 @@ SWITCH_DECLARE(void) switch_perform_substitution(switch_regex_t *re, int match_c
\param expression The regular expression to run against the string \param expression The regular expression to run against the string
\return Boolean if a match was found or not \return Boolean if a match was found or not
*/ */
SWITCH_DECLARE(switch_status_t) switch_regex_match(char *target, char *expression); SWITCH_DECLARE(switch_status_t) switch_regex_match(const char *target, const char *expression);
#define switch_regex_safe_free(re) if (re) {\ #define switch_regex_safe_free(re) if (re) {\
switch_regex_free(re);\ switch_regex_free(re);\

View File

@ -111,9 +111,9 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_create(switch_rtp_t **new_rtp_session
\param pool a memory pool to use for the session \param pool a memory pool to use for the session
\return the new RTP session or NULL on failure \return the new RTP session or NULL on failure
*/ */
SWITCH_DECLARE(switch_rtp_t *) switch_rtp_new(char *rx_host, SWITCH_DECLARE(switch_rtp_t *) switch_rtp_new(const char *rx_host,
switch_port_t rx_port, switch_port_t rx_port,
char *tx_host, const char *tx_host,
switch_port_t tx_port, switch_port_t tx_port,
switch_payload_t payload, switch_payload_t payload,
uint32_t samples_per_interval, uint32_t samples_per_interval,
@ -128,7 +128,7 @@ SWITCH_DECLARE(switch_rtp_t *) switch_rtp_new(char *rx_host,
\param port the remote port \param port the remote port
\param err pointer for error messages \param err pointer for error messages
*/ */
SWITCH_DECLARE(switch_status_t) switch_rtp_set_remote_address(switch_rtp_t *rtp_session, char *host, switch_port_t port, const char **err); SWITCH_DECLARE(switch_status_t) switch_rtp_set_remote_address(switch_rtp_t *rtp_session, const char *host, switch_port_t port, const char **err);
/*! /*!
\brief Assign a local address to the RTP session \brief Assign a local address to the RTP session
@ -138,7 +138,7 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_set_remote_address(switch_rtp_t *rtp_
\param err pointer for error messages \param err pointer for error messages
\note this call also binds the RTP session's socket to the new address \note this call also binds the RTP session's socket to the new address
*/ */
SWITCH_DECLARE(switch_status_t) switch_rtp_set_local_address(switch_rtp_t *rtp_session, char *host, switch_port_t port, const char **err); SWITCH_DECLARE(switch_status_t) switch_rtp_set_local_address(switch_rtp_t *rtp_session, const char *host, switch_port_t port, const char **err);
/*! /*!
\brief Kill the socket on an existing RTP session \brief Kill the socket on an existing RTP session

View File

@ -62,7 +62,7 @@ SWITCH_BEGIN_EXTERN_C
*/ */
SWITCH_DECLARE(uint32_t) switch_scheduler_add_task(time_t task_runtime, SWITCH_DECLARE(uint32_t) switch_scheduler_add_task(time_t task_runtime,
switch_scheduler_func_t func, switch_scheduler_func_t func,
char *desc, char *group, uint32_t cmd_id, void *cmd_arg, switch_scheduler_flag_t flags); const char *desc, const char *group, uint32_t cmd_id, void *cmd_arg, switch_scheduler_flag_t flags);
/*! /*!
\brief Delete a scheduled task \brief Delete a scheduled task
@ -76,7 +76,7 @@ SWITCH_DECLARE(uint32_t) switch_scheduler_del_task_id(uint32_t task_id);
\param group the group name \param group the group name
\return the number of jobs deleted \return the number of jobs deleted
*/ */
SWITCH_DECLARE(uint32_t) switch_scheduler_del_task_group(char *group); SWITCH_DECLARE(uint32_t) switch_scheduler_del_task_group(const char *group);
/*! /*!

View File

@ -1018,7 +1018,7 @@ typedef void (*switch_scheduler_func_t) (switch_scheduler_task_t *task);
typedef switch_status_t (*switch_state_handler_t) (switch_core_session_t *); typedef switch_status_t (*switch_state_handler_t) (switch_core_session_t *);
typedef struct switch_stream_handle switch_stream_handle_t; typedef struct switch_stream_handle switch_stream_handle_t;
typedef switch_status_t (*switch_stream_handle_write_function_t) (switch_stream_handle_t *handle, const char *fmt, ...); typedef switch_status_t (*switch_stream_handle_write_function_t) (switch_stream_handle_t *handle, const char *fmt, ...);
typedef switch_status_t (*switch_api_function_t) (char *in, switch_core_session_t *session, switch_stream_handle_t *stream); typedef switch_status_t (*switch_api_function_t) (const char *in, switch_core_session_t *session, switch_stream_handle_t *stream);
typedef switch_status_t (*switch_input_callback_function_t) (switch_core_session_t *session, void *input, typedef switch_status_t (*switch_input_callback_function_t) (switch_core_session_t *session, void *input,
switch_input_type_t input_type, void *buf, unsigned int buflen); switch_input_type_t input_type, void *buf, unsigned int buflen);
typedef struct switch_say_interface switch_say_interface_t; typedef struct switch_say_interface switch_say_interface_t;

View File

@ -55,7 +55,7 @@ SWITCH_BEGIN_EXTERN_C
#define switch_is_file_path(file) ((*file == '/') || strstr(file, SWITCH_URL_SEPARATOR)) #define switch_is_file_path(file) ((*file == '/') || strstr(file, SWITCH_URL_SEPARATOR))
#endif #endif
static inline switch_bool_t switch_is_digit_string(char *s) { static inline switch_bool_t switch_is_digit_string(const char *s) {
while(s && *s) { while(s && *s) {
if (*s < 48 || *s > 57) { if (*s < 48 || *s > 57) {
@ -104,7 +104,7 @@ SWITCH_DECLARE(char *) get_addr(char *buf, switch_size_t len, struct in_addr *in
\param priority the priority to get the name of \param priority the priority to get the name of
\return the printable form of the priority \return the printable form of the priority
*/ */
SWITCH_DECLARE(char *) switch_priority_name(switch_priority_t priority); SWITCH_DECLARE(const char *) switch_priority_name(switch_priority_t priority);
/*! /*!
\brief Return the RFC2833 character based on an event id \brief Return the RFC2833 character based on an event id
@ -260,7 +260,7 @@ static inline switch_bool_t switch_strstr(char *s, char *q)
\param in the string \param in the string
\return the epoch time in usec \return the epoch time in usec
*/ */
SWITCH_DECLARE(switch_time_t) switch_str_time(char *in); SWITCH_DECLARE(switch_time_t) switch_str_time(const char *in);
/*! /*!
\brief Declares a function designed to set a dymaic global string \brief Declares a function designed to set a dymaic global string
@ -288,7 +288,7 @@ SWITCH_DECLARE(unsigned int) switch_separate_string(char *buf, char delim, char
\param esc the escape character \param esc the escape character
\return the escaped string \return the escaped string
*/ */
SWITCH_DECLARE(char *) switch_escape_char(switch_memory_pool_t *pool, char *in, char *delim, char esc); SWITCH_DECLARE(char *) switch_escape_char(switch_memory_pool_t *pool, char *in, const char *delim, char esc);
/*! /*!
\brief Wait for a socket \brief Wait for a socket

View File

@ -57,7 +57,7 @@ static switch_api_interface_t sched_broadcast_api_interface;
static switch_api_interface_t sched_transfer_api_interface; static switch_api_interface_t sched_transfer_api_interface;
static switch_api_interface_t sched_hangup_api_interface; static switch_api_interface_t sched_hangup_api_interface;
static switch_status_t status_function(char *cmd, switch_core_session_t *session, switch_stream_handle_t *stream) static switch_status_t status_function(const char *cmd, switch_core_session_t *session, switch_stream_handle_t *stream)
{ {
uint8_t html = 0; uint8_t html = 0;
switch_core_time_duration_t duration; switch_core_time_duration_t duration;
@ -107,7 +107,7 @@ static switch_status_t status_function(char *cmd, switch_core_session_t *session
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
static switch_status_t ctl_function(char *data, switch_core_session_t *session, switch_stream_handle_t *stream) static switch_status_t ctl_function(const char *data, switch_core_session_t *session, switch_stream_handle_t *stream)
{ {
int argc; int argc;
char *mydata, *argv[5]; char *mydata, *argv[5];
@ -149,7 +149,7 @@ static switch_status_t ctl_function(char *data, switch_core_session_t *session,
} }
static switch_status_t load_function(char *mod, switch_core_session_t *session, switch_stream_handle_t *stream) static switch_status_t load_function(const char *mod, switch_core_session_t *session, switch_stream_handle_t *stream)
{ {
const char *err; const char *err;
@ -171,7 +171,7 @@ static switch_status_t load_function(char *mod, switch_core_session_t *session,
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
static switch_status_t unload_function(char *mod, switch_core_session_t *session, switch_stream_handle_t *stream) static switch_status_t unload_function(const char *mod, switch_core_session_t *session, switch_stream_handle_t *stream)
{ {
const char *err; const char *err;
@ -193,7 +193,7 @@ static switch_status_t unload_function(char *mod, switch_core_session_t *session
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
static switch_status_t reload_function(char *args, switch_core_session_t *session, switch_stream_handle_t *stream) static switch_status_t reload_function(const char *args, switch_core_session_t *session, switch_stream_handle_t *stream)
{ {
const char *err; const char *err;
switch_xml_t xml_root; switch_xml_t xml_root;
@ -211,7 +211,7 @@ static switch_status_t reload_function(char *args, switch_core_session_t *sessio
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
static switch_status_t kill_function(char *dest, switch_core_session_t *isession, switch_stream_handle_t *stream) static switch_status_t kill_function(const char *dest, switch_core_session_t *isession, switch_stream_handle_t *stream)
{ {
switch_core_session_t *session = NULL; switch_core_session_t *session = NULL;
@ -233,56 +233,62 @@ static switch_status_t kill_function(char *dest, switch_core_session_t *isession
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
static switch_status_t transfer_function(char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream) static switch_status_t transfer_function(const char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
{ {
switch_core_session_t *session = NULL; switch_core_session_t *session = NULL;
char *argv[4] = { 0 }; char *mycmd = NULL, *argv[4] = { 0 };
int argc = 0; int argc = 0;
if (isession) { if (isession) {
return SWITCH_STATUS_FALSE; return SWITCH_STATUS_FALSE;
} }
argc = switch_separate_string(cmd, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); if (!switch_strlen_zero(cmd) && (mycmd = strdup(cmd))) {
argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
if (argc >= 2 && argc <= 4) {
char *uuid = argv[0];
char *dest = argv[1];
char *dp = argv[2];
char *context = argv[3];
if (switch_strlen_zero(cmd) || argc < 2 || argc > 4) { if ((session = switch_core_session_locate(uuid))) {
stream->write_function(stream, "USAGE: %s\n", transfer_api_interface.syntax);
} else {
char *uuid = argv[0];
char *dest = argv[1];
char *dp = argv[2];
char *context = argv[3];
if ((session = switch_core_session_locate(uuid))) { if (switch_ivr_session_transfer(session, dest, dp, context) == SWITCH_STATUS_SUCCESS) {
stream->write_function(stream, "OK\n");
} else {
stream->write_function(stream, "ERROR\n");
}
switch_core_session_rwunlock(session);
if (switch_ivr_session_transfer(session, dest, dp, context) == SWITCH_STATUS_SUCCESS) {
stream->write_function(stream, "OK\n");
} else { } else {
stream->write_function(stream, "ERROR\n"); stream->write_function(stream, "No Such Channel!\n");
} }
goto done;
switch_core_session_rwunlock(session);
} else {
stream->write_function(stream, "No Such Channel!\n");
} }
} }
stream->write_function(stream, "USAGE: %s\n", transfer_api_interface.syntax);
done:
switch_safe_free(mycmd);
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
static switch_status_t sched_transfer_function(char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream) static switch_status_t sched_transfer_function(const char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
{ {
switch_core_session_t *session = NULL; switch_core_session_t *session = NULL;
char *argv[6] = { 0 }; char *mycmd = NULL, *argv[6] = { 0 };
int argc = 0; int argc = 0;
if (isession) { if (isession) {
return SWITCH_STATUS_FALSE; return SWITCH_STATUS_FALSE;
} }
argc = switch_separate_string(cmd, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); if (!switch_strlen_zero(cmd) && (mycmd = strdup(cmd))) {
argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
}
if (switch_strlen_zero(cmd) || argc < 2 || argc > 5) { if (switch_strlen_zero(cmd) || argc < 2 || argc > 5) {
stream->write_function(stream, "USAGE: %s\n", sched_transfer_api_interface.syntax); stream->write_function(stream, "USAGE: %s\n", sched_transfer_api_interface.syntax);
@ -308,20 +314,23 @@ static switch_status_t sched_transfer_function(char *cmd, switch_core_session_t
} }
} }
switch_safe_free(mycmd);
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
static switch_status_t sched_hangup_function(char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream) static switch_status_t sched_hangup_function(const char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
{ {
switch_core_session_t *session = NULL; switch_core_session_t *session = NULL;
char *argv[4] = { 0 }; char *mycmd = NULL, *argv[4] = { 0 };
int argc = 0; int argc = 0;
if (isession) { if (isession) {
return SWITCH_STATUS_FALSE; return SWITCH_STATUS_FALSE;
} }
argc = switch_separate_string(cmd, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); if (!switch_strlen_zero(cmd) && (mycmd = strdup(cmd))) {
argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
}
if (switch_strlen_zero(cmd) || argc < 1) { if (switch_strlen_zero(cmd) || argc < 1) {
stream->write_function(stream, "USAGE: %s\n", sched_hangup_api_interface.syntax); stream->write_function(stream, "USAGE: %s\n", sched_hangup_api_interface.syntax);
@ -350,13 +359,14 @@ static switch_status_t sched_hangup_function(char *cmd, switch_core_session_t *i
} }
} }
switch_safe_free(mycmd);
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
static switch_status_t uuid_media_function(char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream) static switch_status_t uuid_media_function(const char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
{ {
char *argv[4] = { 0 }; char *mycmd = NULL, *argv[4] = { 0 };
int argc = 0; int argc = 0;
switch_status_t status = SWITCH_STATUS_FALSE; switch_status_t status = SWITCH_STATUS_FALSE;
@ -364,7 +374,9 @@ static switch_status_t uuid_media_function(char *cmd, switch_core_session_t *ise
return status; return status;
} }
argc = switch_separate_string(cmd, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); if (!switch_strlen_zero(cmd) && (mycmd = strdup(cmd))) {
argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
}
if (switch_strlen_zero(cmd) || argc < 1) { if (switch_strlen_zero(cmd) || argc < 1) {
stream->write_function(stream, "USAGE: %s\n", media_api_interface.syntax); stream->write_function(stream, "USAGE: %s\n", media_api_interface.syntax);
@ -382,13 +394,14 @@ static switch_status_t uuid_media_function(char *cmd, switch_core_session_t *ise
stream->write_function(stream, "-ERR Operation Failed\n"); stream->write_function(stream, "-ERR Operation Failed\n");
} }
switch_safe_free(mycmd);
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
static switch_status_t uuid_broadcast_function(char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream) static switch_status_t uuid_broadcast_function(const char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
{ {
char *argv[4] = { 0 }; char *mycmd = NULL, *argv[4] = { 0 };
int argc = 0; int argc = 0;
switch_status_t status = SWITCH_STATUS_FALSE; switch_status_t status = SWITCH_STATUS_FALSE;
@ -396,7 +409,9 @@ static switch_status_t uuid_broadcast_function(char *cmd, switch_core_session_t
return status; return status;
} }
argc = switch_separate_string(cmd, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); if (!switch_strlen_zero(cmd) && (mycmd = strdup(cmd))) {
argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
}
if (switch_strlen_zero(cmd) || argc < 2) { if (switch_strlen_zero(cmd) || argc < 2) {
stream->write_function(stream, "USAGE: %s\n", broadcast_api_interface.syntax); stream->write_function(stream, "USAGE: %s\n", broadcast_api_interface.syntax);
@ -419,13 +434,14 @@ static switch_status_t uuid_broadcast_function(char *cmd, switch_core_session_t
stream->write_function(stream, "+OK Message Sent\n"); stream->write_function(stream, "+OK Message Sent\n");
} }
switch_safe_free(mycmd);
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
static switch_status_t sched_broadcast_function(char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream) static switch_status_t sched_broadcast_function(const char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
{ {
char *argv[4] = { 0 }; char *mycmd = NULL, *argv[4] = { 0 };
int argc = 0; int argc = 0;
switch_status_t status = SWITCH_STATUS_FALSE; switch_status_t status = SWITCH_STATUS_FALSE;
@ -433,7 +449,9 @@ static switch_status_t sched_broadcast_function(char *cmd, switch_core_session_t
return status; return status;
} }
argc = switch_separate_string(cmd, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); if (!switch_strlen_zero(cmd) && (mycmd = strdup(cmd))) {
argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
}
if (switch_strlen_zero(cmd) || argc < 3) { if (switch_strlen_zero(cmd) || argc < 3) {
stream->write_function(stream, "USAGE: %s\n", sched_broadcast_api_interface.syntax); stream->write_function(stream, "USAGE: %s\n", sched_broadcast_api_interface.syntax);
@ -463,12 +481,13 @@ static switch_status_t sched_broadcast_function(char *cmd, switch_core_session_t
stream->write_function(stream, "+OK Message Scheduled\n"); stream->write_function(stream, "+OK Message Scheduled\n");
} }
switch_safe_free(mycmd);
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
static switch_status_t uuid_hold_function(char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream) static switch_status_t uuid_hold_function(const char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
{ {
char *argv[4] = { 0 }; char *mycmd = NULL, *argv[4] = { 0 };
int argc = 0; int argc = 0;
switch_status_t status = SWITCH_STATUS_FALSE; switch_status_t status = SWITCH_STATUS_FALSE;
@ -476,7 +495,9 @@ static switch_status_t uuid_hold_function(char *cmd, switch_core_session_t *ises
return status; return status;
} }
argc = switch_separate_string(cmd, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); if (!switch_strlen_zero(cmd) && (mycmd = strdup(cmd))) {
argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
}
if (switch_strlen_zero(cmd) || argc < 1) { if (switch_strlen_zero(cmd) || argc < 1) {
stream->write_function(stream, "USAGE: %s\n", hold_api_interface.syntax); stream->write_function(stream, "USAGE: %s\n", hold_api_interface.syntax);
@ -494,19 +515,22 @@ static switch_status_t uuid_hold_function(char *cmd, switch_core_session_t *ises
stream->write_function(stream, "-ERR Operation Failed\n"); stream->write_function(stream, "-ERR Operation Failed\n");
} }
switch_safe_free(mycmd);
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
static switch_status_t uuid_bridge_function(char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream) static switch_status_t uuid_bridge_function(const char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
{ {
char *argv[4] = { 0 }; char *mycmd = NULL, *argv[4] = { 0 };
int argc = 0; int argc = 0;
if (isession) { if (isession) {
return SWITCH_STATUS_FALSE; return SWITCH_STATUS_FALSE;
} }
argc = switch_separate_string(cmd, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); if (!switch_strlen_zero(cmd) && (mycmd = strdup(cmd))) {
argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
}
if (switch_strlen_zero(cmd) || argc != 2) { if (switch_strlen_zero(cmd) || argc != 2) {
stream->write_function(stream, "USAGE: %s\n", uuid_bridge_api_interface.syntax); stream->write_function(stream, "USAGE: %s\n", uuid_bridge_api_interface.syntax);
@ -516,13 +540,14 @@ static switch_status_t uuid_bridge_function(char *cmd, switch_core_session_t *is
} }
} }
switch_safe_free(mycmd);
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
static switch_status_t session_record_function(char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream) static switch_status_t session_record_function(const char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
{ {
switch_core_session_t *session = NULL; switch_core_session_t *session = NULL;
char *argv[4] = { 0 }; char *mycmd = NULL, *argv[4] = { 0 };
char *uuid = NULL, *action = NULL, *path = NULL; char *uuid = NULL, *action = NULL, *path = NULL;
int argc = 0; int argc = 0;
@ -534,7 +559,11 @@ static switch_status_t session_record_function(char *cmd, switch_core_session_t
goto usage; goto usage;
} }
if ((argc = switch_separate_string(cmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) != 3) { if (!(mycmd = strdup(cmd))) {
goto usage;
}
if ((argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) != 3) {
goto usage; goto usage;
} }
@ -564,6 +593,7 @@ static switch_status_t session_record_function(char *cmd, switch_core_session_t
usage: usage:
stream->write_function(stream, "USAGE: %s\n", session_record_api_interface.syntax); stream->write_function(stream, "USAGE: %s\n", session_record_api_interface.syntax);
switch_safe_free(mycmd);
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
done: done:
@ -572,20 +602,23 @@ static switch_status_t session_record_function(char *cmd, switch_core_session_t
switch_core_session_rwunlock(session); switch_core_session_rwunlock(session);
} }
switch_safe_free(mycmd);
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
static switch_status_t pause_function(char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream) static switch_status_t pause_function(const char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
{ {
switch_core_session_t *session = NULL; switch_core_session_t *session = NULL;
char *argv[4] = { 0 }; char *mycmd = NULL, *argv[4] = { 0 };
int argc = 0; int argc = 0;
if (isession) { if (isession) {
return SWITCH_STATUS_FALSE; return SWITCH_STATUS_FALSE;
} }
argc = switch_separate_string(cmd, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); if (!switch_strlen_zero(cmd) && (mycmd = strdup(cmd))) {
argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
}
if (switch_strlen_zero(cmd) || argc < 2) { if (switch_strlen_zero(cmd) || argc < 2) {
stream->write_function(stream, "USAGE: %s\n", pause_api_interface.syntax); stream->write_function(stream, "USAGE: %s\n", pause_api_interface.syntax);
@ -609,14 +642,15 @@ static switch_status_t pause_function(char *cmd, switch_core_session_t *isession
} }
} }
switch_safe_free(mycmd);
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
static switch_status_t originate_function(char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream) static switch_status_t originate_function(const char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
{ {
switch_channel_t *caller_channel; switch_channel_t *caller_channel;
switch_core_session_t *caller_session = NULL; switch_core_session_t *caller_session = NULL;
char *argv[7] = { 0 }; char *mycmd = NULL, *argv[7] = { 0 };
int i = 0, x, argc = 0; int i = 0, x, argc = 0;
char *aleg, *exten, *dp, *context, *cid_name, *cid_num; char *aleg, *exten, *dp, *context, *cid_name, *cid_num;
uint32_t timeout = 60; uint32_t timeout = 60;
@ -628,10 +662,13 @@ static switch_status_t originate_function(char *cmd, switch_core_session_t *ises
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
argc = switch_separate_string(cmd, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); if (!switch_strlen_zero(cmd) && (mycmd = strdup(cmd))) {
argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
}
if (switch_strlen_zero(cmd) || argc < 2 || argc > 7) { if (switch_strlen_zero(cmd) || argc < 2 || argc > 7) {
stream->write_function(stream, "USAGE: %s\n", originate_api_interface.syntax); stream->write_function(stream, "USAGE: %s\n", originate_api_interface.syntax);
switch_safe_free(mycmd);
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
@ -671,6 +708,7 @@ static switch_status_t originate_function(char *cmd, switch_core_session_t *ises
} else { } else {
stream->write_function(stream, "Cannot Create Outgoing Channel! [%s] cause: %s\n", aleg, switch_channel_cause2str(cause)); stream->write_function(stream, "Cannot Create Outgoing Channel! [%s] cause: %s\n", aleg, switch_channel_cause2str(cause));
} }
switch_safe_free(mycmd);
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
@ -694,6 +732,7 @@ static switch_status_t originate_function(char *cmd, switch_core_session_t *ises
if ((extension = switch_caller_extension_new(caller_session, app_name, arg)) == 0) { if ((extension = switch_caller_extension_new(caller_session, app_name, arg)) == 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "memory error!\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "memory error!\n");
switch_channel_hangup(caller_channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); switch_channel_hangup(caller_channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
switch_safe_free(mycmd);
return SWITCH_STATUS_MEMERR; return SWITCH_STATUS_MEMERR;
} }
switch_caller_extension_add_application(caller_session, extension, app_name, arg); switch_caller_extension_add_application(caller_session, extension, app_name, arg);
@ -713,6 +752,7 @@ static switch_status_t originate_function(char *cmd, switch_core_session_t *ises
switch_core_session_rwunlock(caller_session); switch_core_session_rwunlock(caller_session);
} }
switch_safe_free(mycmd);
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
@ -735,7 +775,7 @@ static void sch_api_callback(switch_scheduler_task_t *task)
switch_safe_free(stream.data); switch_safe_free(stream.data);
} }
static switch_status_t sched_del_function(char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream) static switch_status_t sched_del_function(const char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
{ {
uint32_t cnt = 0; uint32_t cnt = 0;
@ -754,7 +794,7 @@ static switch_status_t sched_del_function(char *cmd, switch_core_session_t *ises
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
static switch_status_t xml_wrap_api_function(char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream) static switch_status_t xml_wrap_api_function(const char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
{ {
char *dcommand, *edata = NULL, *send = NULL, *command, *arg = NULL; char *dcommand, *edata = NULL, *send = NULL, *command, *arg = NULL;
switch_stream_handle_t mystream = { 0 }; switch_stream_handle_t mystream = { 0 };
@ -803,7 +843,7 @@ static switch_status_t xml_wrap_api_function(char *cmd, switch_core_session_t *i
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
static switch_status_t sched_api_function(char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream) static switch_status_t sched_api_function(const char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
{ {
char *tm = NULL, *dcmd, *group; char *tm = NULL, *dcmd, *group;
time_t when; time_t when;
@ -939,7 +979,7 @@ static int show_callback(void *pArg, int argc, char **argv, char **columnNames)
return 0; return 0;
} }
static switch_status_t show_function(char *data, switch_core_session_t *session, switch_stream_handle_t *stream) static switch_status_t show_function(const char *data, switch_core_session_t *session, switch_stream_handle_t *stream)
{ {
char sql[1024]; char sql[1024];
char *errmsg; char *errmsg;
@ -954,11 +994,8 @@ static switch_status_t show_function(char *data, switch_core_session_t *session,
return SWITCH_STATUS_FALSE; return SWITCH_STATUS_FALSE;
} }
if (data) { if (data && (mydata = strdup(data))) {
if ((mydata = strdup(data))) { argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
}
cmd = argv[0]; cmd = argv[0];
if (argv[2] && !strcasecmp(argv[1], "as")) { if (argv[2] && !strcasecmp(argv[1], "as")) {
as = argv[2]; as = argv[2];
@ -1063,7 +1100,7 @@ static switch_status_t show_function(char *data, switch_core_session_t *session,
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
static switch_status_t version_function(char *cmd, switch_core_session_t *session, switch_stream_handle_t *stream) static switch_status_t version_function(const char *cmd, switch_core_session_t *session, switch_stream_handle_t *stream)
{ {
char version_string[1024]; char version_string[1024];
snprintf(version_string, sizeof(version_string) - 1, "FreeSwitch Version %s\n", SWITCH_VERSION_FULL); snprintf(version_string, sizeof(version_string) - 1, "FreeSwitch Version %s\n", SWITCH_VERSION_FULL);
@ -1072,7 +1109,7 @@ static switch_status_t version_function(char *cmd, switch_core_session_t *sessio
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
static switch_status_t help_function(char *cmd, switch_core_session_t *session, switch_stream_handle_t *stream) static switch_status_t help_function(const char *cmd, switch_core_session_t *session, switch_stream_handle_t *stream)
{ {
char showcmd[1024]; char showcmd[1024];
int all = 0; int all = 0;

View File

@ -292,7 +292,7 @@ static uint32_t conference_stop_file(conference_obj_t * conference, file_stop_t
static switch_status_t conference_play_file(conference_obj_t * conference, char *file, uint32_t leadin, switch_channel_t *channel, uint8_t async); static switch_status_t conference_play_file(conference_obj_t * conference, char *file, uint32_t leadin, switch_channel_t *channel, uint8_t async);
static switch_status_t conference_say(conference_obj_t * conference, const char *text, uint32_t leadin); static switch_status_t conference_say(conference_obj_t * conference, const char *text, uint32_t leadin);
static void conference_list(conference_obj_t * conference, switch_stream_handle_t *stream, char *delim); static void conference_list(conference_obj_t * conference, switch_stream_handle_t *stream, char *delim);
static switch_status_t conf_api_main(char *buf, switch_core_session_t *session, switch_stream_handle_t *stream); static switch_status_t conf_api_main(const char *buf, switch_core_session_t *session, switch_stream_handle_t *stream);
static switch_status_t audio_bridge_on_ring(switch_core_session_t *session); static switch_status_t audio_bridge_on_ring(switch_core_session_t *session);
static switch_status_t conference_outcall(conference_obj_t * conference, static switch_status_t conference_outcall(conference_obj_t * conference,
char *conference_name, char *conference_name,
@ -3445,7 +3445,7 @@ switch_status_t conf_api_dispatch(conference_obj_t * conference, switch_stream_h
} }
/* API Interface Function */ /* API Interface Function */
static switch_status_t conf_api_main(char *buf, switch_core_session_t *session, switch_stream_handle_t *stream) static switch_status_t conf_api_main(const char *buf, switch_core_session_t *session, switch_stream_handle_t *stream)
{ {
char *lbuf = NULL; char *lbuf = NULL;
switch_status_t status = SWITCH_STATUS_SUCCESS; switch_status_t status = SWITCH_STATUS_SUCCESS;

View File

@ -502,7 +502,7 @@ static void strftime_function(switch_core_session_t *session, char *data)
} }
static switch_status_t strepoch_api_function(char *data, switch_core_session_t *session, switch_stream_handle_t *stream) static switch_status_t strepoch_api_function(const char *data, switch_core_session_t *session, switch_stream_handle_t *stream)
{ {
switch_time_t out; switch_time_t out;
@ -517,7 +517,7 @@ static switch_status_t strepoch_api_function(char *data, switch_core_session_t *
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
static switch_status_t strftime_api_function(char *fmt, switch_core_session_t *session, switch_stream_handle_t *stream) static switch_status_t strftime_api_function(const char *fmt, switch_core_session_t *session, switch_stream_handle_t *stream)
{ {
switch_size_t retsize; switch_size_t retsize;
@ -531,7 +531,7 @@ static switch_status_t strftime_api_function(char *fmt, switch_core_session_t *s
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
static switch_status_t presence_api_function(char *fmt, switch_core_session_t *session, switch_stream_handle_t *stream) static switch_status_t presence_api_function(const char *fmt, switch_core_session_t *session, switch_stream_handle_t *stream)
{ {
switch_event_t *event; switch_event_t *event;
char *lbuf, *argv[4]; char *lbuf, *argv[4];
@ -568,7 +568,7 @@ static switch_status_t presence_api_function(char *fmt, switch_core_session_t *s
} }
static switch_status_t chat_api_function(char *fmt, switch_core_session_t *session, switch_stream_handle_t *stream) static switch_status_t chat_api_function(const char *fmt, switch_core_session_t *session, switch_stream_handle_t *stream)
{ {
char *lbuf, *argv[4]; char *lbuf, *argv[4];
int argc = 0; int argc = 0;

View File

@ -625,7 +625,7 @@ static void enum_app_function(switch_core_session_t *session, char *data)
} }
static switch_status_t enum_function(char *data, switch_core_session_t *session, switch_stream_handle_t *stream) static switch_status_t enum_function(const char *data, switch_core_session_t *session, switch_stream_handle_t *stream)
{ {
int argc = 0; int argc = 0;
@ -649,7 +649,7 @@ static switch_status_t enum_function(char *data, switch_core_session_t *session,
dest = argv[0]; dest = argv[0];
root = argv[1] ? argv[1] : globals.root; root = argv[1] ? argv[1] : globals.root;
if (!enum_lookup(root, data, &results) == SWITCH_STATUS_SUCCESS) { if (!enum_lookup(root, dest, &results) == SWITCH_STATUS_SUCCESS) {
stream->write_function(stream, "No Match!\n"); stream->write_function(stream, "No Match!\n");
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }

View File

@ -1522,7 +1522,7 @@ static switch_status_t place_call(char **argv, int argc, switch_stream_handle_t
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
static switch_status_t pa_cmd(char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream) static switch_status_t pa_cmd(const char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
{ {
char *argv[1024] = { 0 }; char *argv[1024] = { 0 };
int argc = 0; int argc = 0;

View File

@ -191,10 +191,10 @@ SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_dialplan, globals.dialplan)
SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_codec_string, globals.codec_string) SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_codec_string, globals.codec_string)
SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_codec_rates_string, globals.codec_rates_string) SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_codec_rates_string, globals.codec_rates_string)
static switch_status_t dl_login(char *arg, switch_core_session_t *session, switch_stream_handle_t *stream); static switch_status_t dl_login(const char *arg, switch_core_session_t *session, switch_stream_handle_t *stream);
static switch_status_t dl_logout(char *profile_name, switch_core_session_t *session, switch_stream_handle_t *stream); static switch_status_t dl_logout(const char *profile_name, switch_core_session_t *session, switch_stream_handle_t *stream);
static switch_status_t dl_pres(char *profile_name, switch_core_session_t *session, switch_stream_handle_t *stream); static switch_status_t dl_pres(const char *profile_name, switch_core_session_t *session, switch_stream_handle_t *stream);
static switch_status_t dl_debug(char *profile_name, switch_core_session_t *session, switch_stream_handle_t *stream); static switch_status_t dl_debug(const char *profile_name, switch_core_session_t *session, switch_stream_handle_t *stream);
static switch_status_t channel_on_init(switch_core_session_t *session); static switch_status_t channel_on_init(switch_core_session_t *session);
static switch_status_t channel_on_hangup(switch_core_session_t *session); static switch_status_t channel_on_hangup(switch_core_session_t *session);
static switch_status_t channel_on_ring(switch_core_session_t *session); static switch_status_t channel_on_ring(switch_core_session_t *session);
@ -2028,7 +2028,7 @@ static void set_profile_val(mdl_profile_t *profile, char *var, char *val)
} }
} }
static switch_status_t dl_debug(char *tf, switch_core_session_t *session, switch_stream_handle_t *stream) static switch_status_t dl_debug(const char *tf, switch_core_session_t *session, switch_stream_handle_t *stream)
{ {
int on, cur; int on, cur;
@ -2049,7 +2049,7 @@ static switch_status_t dl_debug(char *tf, switch_core_session_t *session, switch
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
static switch_status_t dl_pres(char *profile_name, switch_core_session_t *session, switch_stream_handle_t *stream) static switch_status_t dl_pres(const char *profile_name, switch_core_session_t *session, switch_stream_handle_t *stream)
{ {
mdl_profile_t *profile; mdl_profile_t *profile;
@ -2076,7 +2076,7 @@ static switch_status_t dl_pres(char *profile_name, switch_core_session_t *sessio
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
static switch_status_t dl_logout(char *profile_name, switch_core_session_t *session, switch_stream_handle_t *stream) static switch_status_t dl_logout(const char *profile_name, switch_core_session_t *session, switch_stream_handle_t *stream)
{ {
mdl_profile_t *profile; mdl_profile_t *profile;
@ -2099,7 +2099,7 @@ static switch_status_t dl_logout(char *profile_name, switch_core_session_t *sess
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
static switch_status_t dl_login(char *arg, switch_core_session_t *session, switch_stream_handle_t *stream) static switch_status_t dl_login(const char *arg, switch_core_session_t *session, switch_stream_handle_t *stream)
{ {
char *argv[10] = { 0 }; char *argv[10] = { 0 };
int argc = 0; int argc = 0;

View File

@ -155,8 +155,8 @@ SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_dialplan, globals.dialplan)
static switch_status_t load_config(void); static switch_status_t load_config(void);
static int get_dev_by_name(char *name, int in); static int get_dev_by_name(char *name, int in);
static int get_dev_by_number(int number, int in); static int get_dev_by_number(int number, int in);
static switch_status_t pa_cmd(char *dest, switch_core_session_t *session, switch_stream_handle_t *stream); static switch_status_t pa_cmd(const char *dest, switch_core_session_t *session, switch_stream_handle_t *stream);
static switch_status_t padep(char *dest, switch_core_session_t *session, switch_stream_handle_t *stream); static switch_status_t padep(const char *dest, switch_core_session_t *session, switch_stream_handle_t *stream);
/* /*
@ -1711,13 +1711,13 @@ static switch_status_t place_call(char **argv, int argc, switch_stream_handle_t
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
static switch_status_t padep(char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream) static switch_status_t padep(const char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
{ {
stream->write_function(stream, "This command no longer exists (try 'pa help')\n"); stream->write_function(stream, "This command no longer exists (try 'pa help')\n");
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
static switch_status_t pa_cmd(char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream) static switch_status_t pa_cmd(const char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
{ {
char *argv[1024] = { 0 }; char *argv[1024] = { 0 };
int argc = 0; int argc = 0;

View File

@ -1175,7 +1175,7 @@ static switch_status_t cmd_profile(char **argv, int argc, switch_stream_handle_t
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
static switch_status_t sofia_function(char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream) static switch_status_t sofia_function(const char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
{ {
char *argv[1024] = { 0 }; char *argv[1024] = { 0 };
int argc = 0; int argc = 0;

View File

@ -90,7 +90,7 @@ class BaseCDR {
switch_time_t callenddate; switch_time_t callenddate;
switch_time_t calltransferdate; switch_time_t calltransferdate;
switch_call_cause_t hangupcause; switch_call_cause_t hangupcause;
char *hangupcause_text; const char *hangupcause_text;
char clid[80]; char clid[80];
bool originated; // Did they originate this call? bool originated; // Did they originate this call?
char dialplan[80]; char dialplan[80];

View File

@ -45,11 +45,11 @@ static int RUNNING = 0;
static CDRContainer *newcdrcontainer; static CDRContainer *newcdrcontainer;
static switch_memory_pool_t *module_pool; static switch_memory_pool_t *module_pool;
static switch_status_t my_on_hangup(switch_core_session_t *session); static switch_status_t my_on_hangup(switch_core_session_t *session);
static switch_status_t modcdr_reload(char *dest, switch_core_session_t *isession, switch_stream_handle_t *stream); static switch_status_t modcdr_reload(const char *dest, switch_core_session_t *isession, switch_stream_handle_t *stream);
static switch_status_t modcdr_queue_pause(char *dest, switch_core_session_t *isession, switch_stream_handle_t *stream); static switch_status_t modcdr_queue_pause(const char *dest, switch_core_session_t *isession, switch_stream_handle_t *stream);
static switch_status_t modcdr_queue_resume(char *dest, switch_core_session_t *isession, switch_stream_handle_t *stream); static switch_status_t modcdr_queue_resume(const char *dest, switch_core_session_t *isession, switch_stream_handle_t *stream);
static switch_status_t modcdr_show_active(char *dest, switch_core_session_t *isession, switch_stream_handle_t *stream); static switch_status_t modcdr_show_active(const char *dest, switch_core_session_t *isession, switch_stream_handle_t *stream);
static switch_status_t modcdr_show_available(char *dest, switch_core_session_t *isession, switch_stream_handle_t *stream); static switch_status_t modcdr_show_available(const char *dest, switch_core_session_t *isession, switch_stream_handle_t *stream);
static switch_thread_rwlock_t *cdr_rwlock; static switch_thread_rwlock_t *cdr_rwlock;
/* Now begins the glue that will tie this into the system. /* Now begins the glue that will tie this into the system.
@ -151,7 +151,7 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void)
return RUNNING ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_TERM; return RUNNING ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_TERM;
} }
static switch_status_t modcdr_reload(char *dest=0, switch_core_session_t *isession=0, switch_stream_handle_t *stream=0) static switch_status_t modcdr_reload(const char *dest=0, switch_core_session_t *isession=0, switch_stream_handle_t *stream=0)
{ {
#ifdef SWITCH_QUEUE_ENHANCED #ifdef SWITCH_QUEUE_ENHANCED
switch_thread_rwlock_wrlock(cdr_rwlock); switch_thread_rwlock_wrlock(cdr_rwlock);
@ -164,7 +164,7 @@ static switch_status_t modcdr_reload(char *dest=0, switch_core_session_t *isessi
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
static switch_status_t modcdr_queue_pause(char *dest=0, switch_core_session_t *isession=0, switch_stream_handle_t *stream=0) static switch_status_t modcdr_queue_pause(const char *dest=0, switch_core_session_t *isession=0, switch_stream_handle_t *stream=0)
{ {
#ifdef SWITCH_QUEUE_ENHANCED #ifdef SWITCH_QUEUE_ENHANCED
newcdrcontainer->queue_pause(stream); newcdrcontainer->queue_pause(stream);
@ -174,7 +174,7 @@ static switch_status_t modcdr_queue_pause(char *dest=0, switch_core_session_t *i
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
static switch_status_t modcdr_queue_resume(char *dest=0, switch_core_session_t *isession=0, switch_stream_handle_t *stream=0) static switch_status_t modcdr_queue_resume(const char *dest=0, switch_core_session_t *isession=0, switch_stream_handle_t *stream=0)
{ {
#ifdef SWITCH_QUEUE_ENHANCED #ifdef SWITCH_QUEUE_ENHANCED
newcdrcontainer->queue_resume(stream); newcdrcontainer->queue_resume(stream);
@ -184,13 +184,13 @@ static switch_status_t modcdr_queue_resume(char *dest=0, switch_core_session_t *
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
static switch_status_t modcdr_show_active(char *dest=0, switch_core_session_t *isession=0, switch_stream_handle_t *stream=0) static switch_status_t modcdr_show_active(const char *dest=0, switch_core_session_t *isession=0, switch_stream_handle_t *stream=0)
{ {
newcdrcontainer->active(stream); newcdrcontainer->active(stream);
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
static switch_status_t modcdr_show_available(char *dest=0, switch_core_session_t *isession=0, switch_stream_handle_t *stream=0) static switch_status_t modcdr_show_available(const char *dest=0, switch_core_session_t *isession=0, switch_stream_handle_t *stream=0)
{ {
newcdrcontainer->available(stream); newcdrcontainer->available(stream);
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;

View File

@ -161,7 +161,7 @@ static void *SWITCH_THREAD_FUNC py_thread_run(switch_thread_t *thread, void *obj
return NULL; return NULL;
} }
static switch_status_t launch_python(char *text, switch_core_session_t *session, switch_stream_handle_t *stream) static switch_status_t launch_python(const char *text, switch_core_session_t *session, switch_stream_handle_t *stream)
{ {
switch_thread_t *thread; switch_thread_t *thread;
switch_threadattr_t *thd_attr = NULL; switch_threadattr_t *thd_attr = NULL;

View File

@ -2720,7 +2720,7 @@ static void *SWITCH_THREAD_FUNC js_thread_run(switch_thread_t * thread, void *ob
static switch_memory_pool_t *module_pool = NULL; static switch_memory_pool_t *module_pool = NULL;
static void js_thread_launch(char *text) static void js_thread_launch(const char *text)
{ {
switch_thread_t *thread; switch_thread_t *thread;
switch_threadattr_t *thd_attr = NULL; switch_threadattr_t *thd_attr = NULL;
@ -2739,7 +2739,7 @@ static void js_thread_launch(char *text)
} }
static switch_status_t launch_async(char *text, switch_core_session_t *session, switch_stream_handle_t *stream) static switch_status_t launch_async(const char *text, switch_core_session_t *session, switch_stream_handle_t *stream)
{ {
if (switch_strlen_zero(text)) { if (switch_strlen_zero(text)) {

View File

@ -193,7 +193,7 @@ SWITCH_DECLARE(switch_size_t) switch_buffer_read(switch_buffer_t *buffer, void *
return reading; return reading;
} }
SWITCH_DECLARE(switch_size_t) switch_buffer_write(switch_buffer_t *buffer, void *data, switch_size_t datalen) SWITCH_DECLARE(switch_size_t) switch_buffer_write(switch_buffer_t *buffer, const void *data, switch_size_t datalen)
{ {
switch_size_t freespace, actual_freespace; switch_size_t freespace, actual_freespace;

View File

@ -92,7 +92,7 @@ SWITCH_DECLARE(switch_caller_profile_t *) switch_caller_profile_clone(switch_cor
return profile; return profile;
} }
SWITCH_DECLARE(char *) switch_caller_get_field_by_name(switch_caller_profile_t *caller_profile, char *name) SWITCH_DECLARE(char *) switch_caller_get_field_by_name(switch_caller_profile_t *caller_profile, const char *name)
{ {
if (!strcasecmp(name, "dialplan")) { if (!strcasecmp(name, "dialplan")) {
return caller_profile->dialplan; return caller_profile->dialplan;
@ -136,7 +136,7 @@ SWITCH_DECLARE(char *) switch_caller_get_field_by_name(switch_caller_profile_t *
return NULL; return NULL;
} }
SWITCH_DECLARE(void) switch_caller_profile_event_set_data(switch_caller_profile_t *caller_profile, char *prefix, switch_event_t *event) SWITCH_DECLARE(void) switch_caller_profile_event_set_data(switch_caller_profile_t *caller_profile, const char *prefix, switch_event_t *event)
{ {
char header_name[1024]; char header_name[1024];
@ -207,7 +207,7 @@ SWITCH_DECLARE(void) switch_caller_profile_event_set_data(switch_caller_profile_
} }
SWITCH_DECLARE(switch_caller_extension_t *) switch_caller_extension_new(switch_core_session_t *session, char *extension_name, char *extension_number) SWITCH_DECLARE(switch_caller_extension_t *) switch_caller_extension_new(switch_core_session_t *session, const char *extension_name, const char *extension_number)
{ {
switch_caller_extension_t *caller_extension = NULL; switch_caller_extension_t *caller_extension = NULL;
@ -222,7 +222,7 @@ SWITCH_DECLARE(switch_caller_extension_t *) switch_caller_extension_new(switch_c
SWITCH_DECLARE(void) switch_caller_extension_add_application(switch_core_session_t *session, SWITCH_DECLARE(void) switch_caller_extension_add_application(switch_core_session_t *session,
switch_caller_extension_t *caller_extension, char *application_name, char *application_data) switch_caller_extension_t *caller_extension, const char *application_name, const char *application_data)
{ {
switch_caller_application_t *caller_application = NULL; switch_caller_application_t *caller_application = NULL;

View File

@ -119,21 +119,21 @@ struct switch_channel {
}; };
SWITCH_DECLARE(char *) switch_channel_cause2str(switch_call_cause_t cause) SWITCH_DECLARE(const char *) switch_channel_cause2str(switch_call_cause_t cause)
{ {
uint8_t x; uint8_t x;
char *str = "UNKNOWN"; const char *str = "UNKNOWN";
for (x = 0; CAUSE_CHART[x].name; x++) { for (x = 0; CAUSE_CHART[x].name; x++) {
if (CAUSE_CHART[x].cause == cause) { if (CAUSE_CHART[x].cause == cause) {
str = (char *) CAUSE_CHART[x].name; str = CAUSE_CHART[x].name;
} }
} }
return str; return str;
} }
SWITCH_DECLARE(switch_call_cause_t) switch_channel_str2cause(char *str) SWITCH_DECLARE(switch_call_cause_t) switch_channel_str2cause(const char *str)
{ {
uint8_t x; uint8_t x;
switch_call_cause_t cause = SWITCH_CAUSE_UNALLOCATED; switch_call_cause_t cause = SWITCH_CAUSE_UNALLOCATED;
@ -198,12 +198,12 @@ SWITCH_DECLARE(switch_size_t) switch_channel_has_dtmf(switch_channel_t *channel)
return has; return has;
} }
SWITCH_DECLARE(switch_status_t) switch_channel_queue_dtmf(switch_channel_t *channel, char *dtmf) SWITCH_DECLARE(switch_status_t) switch_channel_queue_dtmf(switch_channel_t *channel, const char *dtmf)
{ {
switch_status_t status; switch_status_t status;
register switch_size_t len, inuse; register switch_size_t len, inuse;
switch_size_t wr = 0; switch_size_t wr = 0;
char *p; const char *p;
assert(channel != NULL); assert(channel != NULL);
@ -270,7 +270,7 @@ SWITCH_DECLARE(switch_status_t) switch_channel_init(switch_channel_t *channel, s
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
SWITCH_DECLARE(void) switch_channel_presence(switch_channel_t *channel, char *rpid, char *status) SWITCH_DECLARE(void) switch_channel_presence(switch_channel_t *channel, const char *rpid, const char *status)
{ {
char *id = switch_channel_get_variable(channel, "presence_id"); char *id = switch_channel_get_variable(channel, "presence_id");
switch_event_t *event; switch_event_t *event;
@ -302,7 +302,7 @@ SWITCH_DECLARE(void) switch_channel_presence(switch_channel_t *channel, char *rp
} }
SWITCH_DECLARE(char *) switch_channel_get_variable(switch_channel_t *channel, char *varname) SWITCH_DECLARE(char *) switch_channel_get_variable(switch_channel_t *channel, const char *varname)
{ {
char *v = NULL; char *v = NULL;
assert(channel != NULL); assert(channel != NULL);
@ -343,7 +343,7 @@ SWITCH_DECLARE(switch_hash_index_t *) switch_channel_variable_first(switch_chann
return hi; return hi;
} }
SWITCH_DECLARE(switch_status_t) switch_channel_set_private(switch_channel_t *channel, char *key, void *private_info) SWITCH_DECLARE(switch_status_t) switch_channel_set_private(switch_channel_t *channel, const char *key, const void *private_info)
{ {
assert(channel != NULL); assert(channel != NULL);
switch_mutex_lock(channel->profile_mutex); switch_mutex_lock(channel->profile_mutex);
@ -352,7 +352,7 @@ SWITCH_DECLARE(switch_status_t) switch_channel_set_private(switch_channel_t *cha
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
SWITCH_DECLARE(void *) switch_channel_get_private(switch_channel_t *channel, char *key) SWITCH_DECLARE(void *) switch_channel_get_private(switch_channel_t *channel, const char *key)
{ {
void *val; void *val;
assert(channel != NULL); assert(channel != NULL);
@ -362,7 +362,7 @@ SWITCH_DECLARE(void *) switch_channel_get_private(switch_channel_t *channel, cha
return val; return val;
} }
SWITCH_DECLARE(switch_status_t) switch_channel_set_name(switch_channel_t *channel, char *name) SWITCH_DECLARE(switch_status_t) switch_channel_set_name(switch_channel_t *channel, const char *name)
{ {
assert(channel != NULL); assert(channel != NULL);
channel->name = NULL; channel->name = NULL;
@ -532,7 +532,7 @@ SWITCH_DECLARE(const char *) switch_channel_state_name(switch_channel_state_t st
} }
SWITCH_DECLARE(switch_channel_state_t) switch_channel_name_state(char *name) SWITCH_DECLARE(switch_channel_state_t) switch_channel_name_state(const char *name)
{ {
uint32_t x = 0; uint32_t x = 0;
for (x = 0; state_names[x]; x++) { for (x = 0; state_names[x]; x++) {

View File

@ -80,7 +80,7 @@ static void heartbeat_callback(switch_scheduler_task_t *task)
} }
SWITCH_DECLARE(switch_status_t) switch_core_set_console(char *console) SWITCH_DECLARE(switch_status_t) switch_core_set_console(const char *console)
{ {
if ((runtime.console = fopen(console, "a")) == 0) { if ((runtime.console = fopen(console, "a")) == 0) {
fprintf(stderr, "Cannot open output file %s.\n", console); fprintf(stderr, "Cannot open output file %s.\n", console);
@ -135,12 +135,12 @@ SWITCH_DECLARE(const switch_state_handler_table_t *) switch_core_get_state_handl
} }
SWITCH_DECLARE(char *) switch_core_get_variable(char *varname) SWITCH_DECLARE(char *) switch_core_get_variable(const char *varname)
{ {
return (char *) switch_core_hash_find(runtime.global_vars, varname); return (char *) switch_core_hash_find(runtime.global_vars, varname);
} }
SWITCH_DECLARE(void) switch_core_set_variable(char *varname, char *value) SWITCH_DECLARE(void) switch_core_set_variable(const char *varname, const char *value)
{ {
switch_core_hash_insert(runtime.global_vars, switch_core_strdup(runtime.memory_pool, varname), switch_core_strdup(runtime.memory_pool, value)); switch_core_hash_insert(runtime.global_vars, switch_core_strdup(runtime.memory_pool, varname), switch_core_strdup(runtime.memory_pool, value));
} }
@ -392,7 +392,7 @@ SWITCH_DECLARE(void) switch_core_runtime_loop(int bg)
} }
SWITCH_DECLARE(switch_status_t) switch_core_init(char *console, const char **err) SWITCH_DECLARE(switch_status_t) switch_core_init(const char *console, const char **err)
{ {
switch_xml_t xml = NULL, cfg = NULL; switch_xml_t xml = NULL, cfg = NULL;
switch_uuid_t uuid; switch_uuid_t uuid;
@ -538,7 +538,7 @@ static void handle_SIGINT(int sig)
if (sig); if (sig);
return; return;
} }
SWITCH_DECLARE(switch_status_t) switch_core_init_and_modload(char *console, const char **err) SWITCH_DECLARE(switch_status_t) switch_core_init_and_modload(const char *console, const char **err)
{ {
switch_event_t *event; switch_event_t *event;
if (switch_core_init(console, err) != SWITCH_STATUS_SUCCESS) { if (switch_core_init(console, err) != SWITCH_STATUS_SUCCESS) {

View File

@ -45,9 +45,9 @@ static struct {
#ifdef SWITCH_DEBUG_RWLOCKS #ifdef SWITCH_DEBUG_RWLOCKS
SWITCH_DECLARE(switch_core_session_t *) switch_core_session_perform_locate(char *uuid_str, const char *file, const char *func, int line) SWITCH_DECLARE(switch_core_session_t *) switch_core_session_perform_locate(const char *uuid_str, const char *file, const char *func, int line)
#else #else
SWITCH_DECLARE(switch_core_session_t *) switch_core_session_locate(char *uuid_str) SWITCH_DECLARE(switch_core_session_t *) switch_core_session_locate(const char *uuid_str)
#endif #endif
{ {
switch_core_session_t *session = NULL; switch_core_session_t *session = NULL;

View File

@ -1110,7 +1110,7 @@ SWITCH_DECLARE(void) switch_loadable_module_shutdown(void)
} }
SWITCH_DECLARE(switch_endpoint_interface_t *) switch_loadable_module_get_endpoint_interface(char *name) SWITCH_DECLARE(switch_endpoint_interface_t *) switch_loadable_module_get_endpoint_interface(const char *name)
{ {
switch_endpoint_interface_t *ptr; switch_endpoint_interface_t *ptr;
@ -1121,7 +1121,7 @@ SWITCH_DECLARE(switch_endpoint_interface_t *) switch_loadable_module_get_endpoin
return ptr; return ptr;
} }
SWITCH_DECLARE(switch_codec_interface_t *) switch_loadable_module_get_codec_interface(char *name) SWITCH_DECLARE(switch_codec_interface_t *) switch_loadable_module_get_codec_interface(const char *name)
{ {
char altname[256] = ""; char altname[256] = "";
switch_codec_interface_t *codec; switch_codec_interface_t *codec;
@ -1143,57 +1143,57 @@ SWITCH_DECLARE(switch_codec_interface_t *) switch_loadable_module_get_codec_inte
return codec; return codec;
} }
SWITCH_DECLARE(switch_dialplan_interface_t *) switch_loadable_module_get_dialplan_interface(char *name) SWITCH_DECLARE(switch_dialplan_interface_t *) switch_loadable_module_get_dialplan_interface(const char *name)
{ {
return switch_core_hash_find_locked(loadable_modules.dialplan_hash, name, loadable_modules.mutex); return switch_core_hash_find_locked(loadable_modules.dialplan_hash, name, loadable_modules.mutex);
} }
SWITCH_DECLARE(switch_timer_interface_t *) switch_loadable_module_get_timer_interface(char *name) SWITCH_DECLARE(switch_timer_interface_t *) switch_loadable_module_get_timer_interface(const char *name)
{ {
return switch_core_hash_find_locked(loadable_modules.timer_hash, name, loadable_modules.mutex); return switch_core_hash_find_locked(loadable_modules.timer_hash, name, loadable_modules.mutex);
} }
SWITCH_DECLARE(switch_application_interface_t *) switch_loadable_module_get_application_interface(char *name) SWITCH_DECLARE(switch_application_interface_t *) switch_loadable_module_get_application_interface(const char *name)
{ {
return switch_core_hash_find_locked(loadable_modules.application_hash, name, loadable_modules.mutex); return switch_core_hash_find_locked(loadable_modules.application_hash, name, loadable_modules.mutex);
} }
SWITCH_DECLARE(switch_api_interface_t *) switch_loadable_module_get_api_interface(char *name) SWITCH_DECLARE(switch_api_interface_t *) switch_loadable_module_get_api_interface(const char *name)
{ {
return switch_core_hash_find_locked(loadable_modules.api_hash, name, loadable_modules.mutex); return switch_core_hash_find_locked(loadable_modules.api_hash, name, loadable_modules.mutex);
} }
SWITCH_DECLARE(switch_file_interface_t *) switch_loadable_module_get_file_interface(char *name) SWITCH_DECLARE(switch_file_interface_t *) switch_loadable_module_get_file_interface(const char *name)
{ {
return switch_core_hash_find_locked(loadable_modules.file_hash, name, loadable_modules.mutex); return switch_core_hash_find_locked(loadable_modules.file_hash, name, loadable_modules.mutex);
} }
SWITCH_DECLARE(switch_speech_interface_t *) switch_loadable_module_get_speech_interface(char *name) SWITCH_DECLARE(switch_speech_interface_t *) switch_loadable_module_get_speech_interface(const char *name)
{ {
return switch_core_hash_find_locked(loadable_modules.speech_hash, name, loadable_modules.mutex); return switch_core_hash_find_locked(loadable_modules.speech_hash, name, loadable_modules.mutex);
} }
SWITCH_DECLARE(switch_asr_interface_t *) switch_loadable_module_get_asr_interface(char *name) SWITCH_DECLARE(switch_asr_interface_t *) switch_loadable_module_get_asr_interface(const char *name)
{ {
return switch_core_hash_find_locked(loadable_modules.asr_hash, name, loadable_modules.mutex); return switch_core_hash_find_locked(loadable_modules.asr_hash, name, loadable_modules.mutex);
} }
SWITCH_DECLARE(switch_directory_interface_t *) switch_loadable_module_get_directory_interface(char *name) SWITCH_DECLARE(switch_directory_interface_t *) switch_loadable_module_get_directory_interface(const char *name)
{ {
return switch_core_hash_find_locked(loadable_modules.directory_hash, name, loadable_modules.mutex); return switch_core_hash_find_locked(loadable_modules.directory_hash, name, loadable_modules.mutex);
} }
SWITCH_DECLARE(switch_chat_interface_t *) switch_loadable_module_get_chat_interface(char *name) SWITCH_DECLARE(switch_chat_interface_t *) switch_loadable_module_get_chat_interface(const char *name)
{ {
return switch_core_hash_find_locked(loadable_modules.chat_hash, name, loadable_modules.mutex); return switch_core_hash_find_locked(loadable_modules.chat_hash, name, loadable_modules.mutex);
} }
SWITCH_DECLARE(switch_say_interface_t *) switch_loadable_module_get_say_interface(char *name) SWITCH_DECLARE(switch_say_interface_t *) switch_loadable_module_get_say_interface(const char *name)
{ {
return switch_core_hash_find_locked(loadable_modules.say_hash, name, loadable_modules.mutex); return switch_core_hash_find_locked(loadable_modules.say_hash, name, loadable_modules.mutex);
} }
SWITCH_DECLARE(switch_management_interface_t *) switch_loadable_module_get_management_interface(char *relative_oid) SWITCH_DECLARE(switch_management_interface_t *) switch_loadable_module_get_management_interface(const char *relative_oid)
{ {
return switch_core_hash_find_locked(loadable_modules.management_hash, relative_oid, loadable_modules.mutex); return switch_core_hash_find_locked(loadable_modules.management_hash, relative_oid, loadable_modules.mutex);
} }
@ -1319,7 +1319,7 @@ SWITCH_DECLARE(int) switch_loadable_module_get_codecs_sorted(const switch_codec_
return i; return i;
} }
SWITCH_DECLARE(switch_status_t) switch_api_execute(char *cmd, char *arg, switch_core_session_t *session, switch_stream_handle_t *stream) SWITCH_DECLARE(switch_status_t) switch_api_execute(const char *cmd, const char *arg, switch_core_session_t *session, switch_stream_handle_t *stream)
{ {
switch_api_interface_t *api; switch_api_interface_t *api;
switch_status_t status; switch_status_t status;

View File

@ -32,12 +32,19 @@
#include <switch.h> #include <switch.h>
#include <pcre.h> #include <pcre.h>
SWITCH_DECLARE(switch_regex_t *) switch_regex_compile(const char *pattern,
int options, const char **errorptr, int *erroroffset, const unsigned char *tables)
SWITCH_DECLARE(switch_regex_t *) switch_regex_compile(const char *pattern,
int options, const char **errorptr, int *erroroffset,
const unsigned char *tables)
{ {
return pcre_compile(pattern, options, errorptr, erroroffset, tables);
} return pcre_compile(pattern, options, errorptr, erroroffset, tables);
SWITCH_DECLARE(int) switch_regex_copy_substring(const char *subject, int *ovector, int stringcount, int stringnumber, char *buffer, int size)
}
SWITCH_DECLARE(int) switch_regex_copy_substring(const char *subject, int *ovector, int stringcount, int stringnumber, char *buffer, int size)
{ {
return pcre_copy_substring(subject, ovector, stringcount, stringnumber, buffer, size); return pcre_copy_substring(subject, ovector, stringcount, stringnumber, buffer, size);
} }
@ -45,7 +52,10 @@
SWITCH_DECLARE(void) switch_regex_free(void *data) SWITCH_DECLARE(void) switch_regex_free(void *data)
{ {
pcre_free(data); pcre_free(data);
} SWITCH_DECLARE(int) switch_regex_perform(char *field, char *expression, switch_regex_t **new_re, int *ovector, uint32_t olen)
}
SWITCH_DECLARE(int) switch_regex_perform(const char *field, const char *expression, switch_regex_t **new_re, int *ovector, uint32_t olen)
{ {
const char *error = NULL; const char *error = NULL;
int erroffset = 0; int erroffset = 0;
@ -87,7 +97,7 @@ SWITCH_DECLARE(void) switch_regex_free(void *data)
} }
SWITCH_DECLARE(void) switch_perform_substitution(switch_regex_t *re, int match_count, char *data, char *field_data, SWITCH_DECLARE(void) switch_perform_substitution(switch_regex_t *re, int match_count, const char *data, const char *field_data,
char *substituted, uint32_t len, int *ovector) char *substituted, uint32_t len, int *ovector)
{ {
char index[10] = ""; char index[10] = "";
@ -124,7 +134,8 @@ SWITCH_DECLARE(void) switch_perform_substitution(switch_regex_t *re, int match_c
} }
substituted[y++] = '\0'; substituted[y++] = '\0';
} }
SWITCH_DECLARE(switch_status_t) switch_regex_match(char *target, char *expression)
SWITCH_DECLARE(switch_status_t) switch_regex_match(const char *target, const char *expression)
{ {
const char *error = NULL; //Used to hold any errors const char *error = NULL; //Used to hold any errors
int error_offset = 0; //Holds the offset of an error int error_offset = 0; //Holds the offset of an error

View File

@ -319,7 +319,7 @@ SWITCH_DECLARE(switch_port_t) switch_rtp_request_port(void)
} }
SWITCH_DECLARE(switch_status_t) switch_rtp_set_local_address(switch_rtp_t *rtp_session, char *host, switch_port_t port, const char **err) SWITCH_DECLARE(switch_status_t) switch_rtp_set_local_address(switch_rtp_t *rtp_session, const char *host, switch_port_t port, const char **err)
{ {
switch_socket_t *new_sock = NULL, *old_sock = NULL; switch_socket_t *new_sock = NULL, *old_sock = NULL;
switch_status_t status = SWITCH_STATUS_FALSE; switch_status_t status = SWITCH_STATUS_FALSE;
@ -389,7 +389,7 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_set_local_address(switch_rtp_t *rtp_s
return status; return status;
} }
SWITCH_DECLARE(switch_status_t) switch_rtp_set_remote_address(switch_rtp_t *rtp_session, char *host, switch_port_t port, const char **err) SWITCH_DECLARE(switch_status_t) switch_rtp_set_remote_address(switch_rtp_t *rtp_session, const char *host, switch_port_t port, const char **err)
{ {
*err = "Success"; *err = "Success";
@ -545,9 +545,9 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_create(switch_rtp_t **new_rtp_session
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
SWITCH_DECLARE(switch_rtp_t *) switch_rtp_new(char *rx_host, SWITCH_DECLARE(switch_rtp_t *) switch_rtp_new(const char *rx_host,
switch_port_t rx_port, switch_port_t rx_port,
char *tx_host, const char *tx_host,
switch_port_t tx_port, switch_port_t tx_port,
switch_payload_t payload, switch_payload_t payload,
uint32_t samples_per_interval, uint32_t samples_per_interval,

View File

@ -149,7 +149,7 @@ static void *SWITCH_THREAD_FUNC switch_scheduler_task_thread(switch_thread_t * t
SWITCH_DECLARE(uint32_t) switch_scheduler_add_task(time_t task_runtime, SWITCH_DECLARE(uint32_t) switch_scheduler_add_task(time_t task_runtime,
switch_scheduler_func_t func, switch_scheduler_func_t func,
char *desc, char *group, uint32_t cmd_id, void *cmd_arg, switch_scheduler_flag_t flags) const char *desc, const char *group, uint32_t cmd_id, void *cmd_arg, switch_scheduler_flag_t flags)
{ {
switch_scheduler_task_container_t *container, *tp; switch_scheduler_task_container_t *container, *tp;
switch_event_t *event; switch_event_t *event;
@ -223,7 +223,7 @@ SWITCH_DECLARE(uint32_t) switch_scheduler_del_task_id(uint32_t task_id)
return delcnt; return delcnt;
} }
SWITCH_DECLARE(uint32_t) switch_scheduler_del_task_group(char *group) SWITCH_DECLARE(uint32_t) switch_scheduler_del_task_group(const char *group)
{ {
switch_scheduler_task_container_t *tp; switch_scheduler_task_container_t *tp;
switch_event_t *event; switch_event_t *event;

View File

@ -177,7 +177,7 @@ SWITCH_DECLARE(switch_status_t) switch_find_local_ip(char *buf, int len, int fam
} }
SWITCH_DECLARE(switch_time_t) switch_str_time(char *in) SWITCH_DECLARE(switch_time_t) switch_str_time(const char *in)
{ {
switch_time_exp_t tm = { 0 }; switch_time_exp_t tm = { 0 };
int proceed = 0, ovector[30]; int proceed = 0, ovector[30];
@ -229,7 +229,7 @@ SWITCH_DECLARE(switch_time_t) switch_str_time(char *in)
} }
SWITCH_DECLARE(char *) switch_priority_name(switch_priority_t priority) SWITCH_DECLARE(const char *) switch_priority_name(switch_priority_t priority)
{ {
switch (priority) { /*lol */ switch (priority) { /*lol */
case SWITCH_PRIORITY_NORMAL: case SWITCH_PRIORITY_NORMAL:
@ -284,9 +284,10 @@ SWITCH_DECLARE(unsigned char) switch_char_to_rfc2833(char key)
return '\0'; return '\0';
} }
SWITCH_DECLARE(char *) switch_escape_char(switch_memory_pool_t *pool, char *in, char *delim, char esc) SWITCH_DECLARE(char *) switch_escape_char(switch_memory_pool_t *pool, char *in, const char *delim, char esc)
{ {
char *data, *p, *d; char *data;
const char *p, *d;
int count = 1, i = 0; int count = 1, i = 0;
p = in; p = in;