Merge branch 'master' into smgmaster

Conflicts:
	src/switch_console.c
This commit is contained in:
Moises Silva
2011-05-22 17:53:14 -04:00
296 changed files with 11586 additions and 7566 deletions
+4
View File
@@ -240,6 +240,7 @@ struct switch_runtime {
uint32_t debug_level;
uint32_t runlevel;
uint32_t tipping_point;
uint32_t microseconds_per_tick;
int32_t timer_affinity;
switch_profile_timer_t *profile_timer;
double profile_time;
@@ -248,9 +249,12 @@ struct switch_runtime {
int max_sql_buffer_len;
switch_dbtype_t odbc_dbtype;
char hostname[256];
char *switchname;
int multiple_registrations;
uint32_t max_db_handles;
uint32_t db_handle_timeout;
int curl_count;
int ssl_count;
};
extern struct switch_runtime runtime;
+10
View File
@@ -56,6 +56,15 @@
#include <switch.h>
SWITCH_BEGIN_EXTERN_C
typedef struct profile_node_s {
char *var;
char *val;
struct profile_node_s *next;
} profile_node_t;
/*! \brief Call Specific Data
*/
struct switch_caller_profile {
@@ -110,6 +119,7 @@ SWITCH_BEGIN_EXTERN_C
switch_memory_pool_t *pool;
struct switch_caller_profile *next;
switch_call_direction_t direction;
profile_node_t *soft;
};
/*! \brief An Abstract Representation of a dialplan Application */
+2 -1
View File
@@ -49,6 +49,7 @@ SWITCH_BEGIN_EXTERN_C struct switch_channel_timetable {
switch_time_t hungup;
switch_time_t transferred;
switch_time_t resurrected;
switch_time_t bridged;
struct switch_channel_timetable *next;
};
@@ -597,7 +598,7 @@ SWITCH_DECLARE(int) switch_channel_test_app_flag_key(const char *app, switch_cha
#define switch_channel_clear_app_flag(_c, _f) switch_channel_clear_app_flag_key(__FILE__, _c, _f)
#define switch_channel_test_app_flag(_c, _f) switch_channel_test_app_flag_key(__FILE__, _c, _f)
SWITCH_DECLARE(void) switch_channel_set_bridge_time(switch_channel_t *channel);
SWITCH_DECLARE(void) switch_channel_set_hangup_time(switch_channel_t *channel);
SWITCH_DECLARE(switch_call_direction_t) switch_channel_direction(switch_channel_t *channel);
SWITCH_DECLARE(switch_core_session_t *) switch_channel_get_session(switch_channel_t *channel);
+6
View File
@@ -57,6 +57,7 @@ SWITCH_BEGIN_EXTERN_C
struct switch_app_log {
char *app;
char *arg;
switch_time_t stamp;
struct switch_app_log *next;
};
@@ -434,6 +435,9 @@ SWITCH_DECLARE(void) switch_core_session_rwunlock(_In_ switch_core_session_t *se
*/
SWITCH_DECLARE(int) switch_core_add_state_handler(_In_ const switch_state_handler_table_t *state_handler);
SWITCH_DECLARE(int) switch_core_curl_count(int *val);
SWITCH_DECLARE(int) switch_core_ssl_count(int *val);
/*!
\brief Remove a global state handler
\param state_handler the state handler to remove
@@ -762,6 +766,7 @@ SWITCH_DECLARE(char *) switch_core_get_variable(_In_z_ const char *varname);
SWITCH_DECLARE(char *) switch_core_get_variable_dup(_In_z_ const char *varname);
SWITCH_DECLARE(char *) switch_core_get_variable_pdup(_In_z_ const char *varname, switch_memory_pool_t *pool);
SWITCH_DECLARE(const char *) switch_core_get_hostname(void);
SWITCH_DECLARE(const char *) switch_core_get_switchname(void);
/*!
\brief Add a global variable to the core
@@ -2205,6 +2210,7 @@ SWITCH_DECLARE(switch_bool_t) switch_cache_db_test_reactive(switch_cache_db_hand
SWITCH_DECLARE(switch_status_t) switch_cache_db_persistant_execute(switch_cache_db_handle_t *dbh, const char *sql, uint32_t retries);
SWITCH_DECLARE(switch_status_t) switch_cache_db_persistant_execute_trans(switch_cache_db_handle_t *dbh, char *sql, uint32_t retries);
SWITCH_DECLARE(void) switch_core_set_signal_handlers(void);
SWITCH_DECLARE(uint32_t) switch_core_debug_level(void);
SWITCH_DECLARE(void) switch_cache_db_flush_handles(void);
SWITCH_DECLARE(const char *) switch_core_banner(void);
+81
View File
@@ -0,0 +1,81 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
*
* The Initial Developer of the Original Code is
* Anthony Minessale II <anthm@freeswitch.org>
* Portions created by the Initial Developer are Copyright (C)
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
*
* switch_curl.h
*
*/
#ifndef __SWITCH_CURL_H
#define __SWITCH_CURL_H
#include <curl/curl.h>
#include <switch_ssl.h>
static inline void switch_curl_init(void)
{
int curl_count = switch_core_curl_count(NULL);
if (curl_count == 0) {
curl_global_init(CURL_GLOBAL_ALL);
#if defined(HAVE_OPENSSL)
switch_ssl_init_ssl_locks();
#endif
}
curl_count++;
switch_core_curl_count(&curl_count);
}
static inline void switch_curl_destroy()
{
int curl_count = switch_core_curl_count(NULL);
curl_count--;
if (curl_count == 0) {
#if defined(HAVE_OPENSSL)
switch_ssl_destroy_ssl_locks();
#endif
curl_global_cleanup();
}
switch_core_curl_count(&curl_count);
}
#endif
/* For Emacs:
* Local Variables:
* mode:c
* indent-tabs-mode:t
* tab-width:4
* c-basic-offset:4
* End:
* For VIM:
* vim:set softtabstop=4 shiftwidth=4 tabstop=4:
*/
+1 -1
View File
@@ -285,7 +285,7 @@ SWITCH_DECLARE(switch_status_t) switch_event_free_subclass_detailed(const char *
SWITCH_DECLARE(switch_status_t) switch_event_serialize(switch_event_t *event, char **str, switch_bool_t encode);
SWITCH_DECLARE(switch_status_t) switch_event_serialize_json(switch_event_t *event, char **str);
SWITCH_DECLARE(switch_status_t) switch_event_create_json(switch_event_t **event, const char *json);
SWITCH_DECLARE(switch_status_t) switch_event_create_brackets(char *data, char a, char b, char c, switch_event_t **event, char **new_data);
SWITCH_DECLARE(switch_status_t) switch_event_create_brackets(char *data, char a, char b, char c, switch_event_t **event, char **new_data, switch_bool_t dup);
#ifndef SWIG
/*!
+4 -4
View File
@@ -223,15 +223,15 @@ typedef intptr_t switch_ssize_t;
#ifdef WIN32
#ifdef WIN64
#define SWITCH_SSIZE_T_FMT "I64d"
#define SWITCH_SIZE_T_FMT "I64d"
#define SWITCH_SSIZE_T_FMT "lld"
#define SWITCH_SIZE_T_FMT "lld"
#else
#define SWITCH_SSIZE_T_FMT "d"
#define SWITCH_SIZE_T_FMT "d"
#endif
#define SWITCH_INT64_T_FMT "I64d"
#define SWITCH_UINT64_T_FMT "I64u"
#define SWITCH_INT64_T_FMT "lld"
#define SWITCH_UINT64_T_FMT "llu"
#ifndef TIME_T_FMT
#define TIME_T_FMT SWITCH_INT64_T_FMT
+107
View File
@@ -0,0 +1,107 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
*
* The Initial Developer of the Original Code is
* Anthony Minessale II <anthm@freeswitch.org>
* Portions created by the Initial Developer are Copyright (C)
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
*
* switch_ssl.h
*
*/
#ifndef __SWITCH_SSL_H
#define __SWITCH_SSL_H
#if defined(HAVE_OPENSSL)
#include <openssl/crypto.h>
static switch_mutex_t **ssl_mutexes;
static switch_memory_pool_t *ssl_pool = NULL;
static inline void switch_ssl_ssl_lock_callback(int mode, int type, char *file, int line)
{
if (mode & CRYPTO_LOCK) {
switch_mutex_lock(ssl_mutexes[type]);
}
else {
switch_mutex_unlock(ssl_mutexes[type]);
}
}
static inline unsigned long switch_ssl_ssl_thread_id(void)
{
return (unsigned long) switch_thread_self();
}
static inline void switch_ssl_init_ssl_locks(void)
{
int ssl_count = switch_core_ssl_count(NULL);
int i, num;
if (ssl_count == 0) {
num = CRYPTO_num_locks();
ssl_mutexes = OPENSSL_malloc(CRYPTO_num_locks() * sizeof(switch_mutex_t*));
switch_assert(ssl_mutexes != NULL);
switch_core_new_memory_pool(&ssl_pool);
for (i = 0; i < num; i++) {
switch_mutex_init(&(ssl_mutexes[i]), SWITCH_MUTEX_NESTED, ssl_pool);
switch_assert(ssl_mutexes[i] != NULL);
}
CRYPTO_set_id_callback(switch_ssl_ssl_thread_id);
CRYPTO_set_locking_callback((void (*)(int, int, const char*, int))switch_ssl_ssl_lock_callback);
}
ssl_count++;
switch_core_ssl_count(&ssl_count);
}
static inline void switch_ssl_destroy_ssl_locks()
{
int i;
int ssl_count = switch_core_ssl_count(NULL);
ssl_count--;
if (ssl_count == 0) {
CRYPTO_set_locking_callback(NULL);
for (i = 0; i < CRYPTO_num_locks(); i++) {
switch_mutex_destroy(ssl_mutexes[i]);
}
OPENSSL_free(ssl_mutexes);
}
switch_core_ssl_count(&ssl_count);
}
#else
static inline void switch_ssl_init_ssl_locks(void) { return; }
static inline void switch_ssl_destroy_ssl_locks(void) { return; }
#endif
#endif
+2
View File
@@ -136,6 +136,7 @@ SWITCH_BEGIN_EXTERN_C
#define SWITCH_CHANNEL_EXECUTE_ON_MEDIA_VARIABLE "execute_on_media"
#define SWITCH_CHANNEL_API_ON_ANSWER_VARIABLE "api_on_answer"
#define SWITCH_CHANNEL_EXECUTE_ON_RING_VARIABLE "execute_on_ring"
#define SWITCH_CHANNEL_EXECUTE_ON_TONE_DETECT_VARIABLE "execute_on_tone_detect"
#define SWITCH_CALL_TIMEOUT_VARIABLE "call_timeout"
#define SWITCH_HOLDING_UUID_VARIABLE "holding_uuid"
#define SWITCH_SOFT_HOLDING_UUID_VARIABLE "soft_holding_uuid"
@@ -488,6 +489,7 @@ typedef struct {
switch_size_t dtmf_packet_count;
switch_size_t cng_packet_count;
switch_size_t flush_packet_count;
switch_size_t largest_jb_size;
} switch_rtp_numbers_t;
+39 -17
View File
@@ -239,20 +239,23 @@ SWITCH_DECLARE(switch_size_t) switch_fd_read_line(int fd, char *buf, switch_size
SWITCH_DECLARE(switch_status_t) switch_frame_alloc(switch_frame_t **frame, switch_size_t size);
SWITCH_DECLARE(switch_status_t) switch_frame_dup(switch_frame_t *orig, switch_frame_t **clone);
SWITCH_DECLARE(switch_status_t) switch_frame_free(switch_frame_t **frame);
SWITCH_DECLARE(switch_bool_t) switch_is_number(const char *str);
/*!
\brief Evaluate the truthfullness of a string expression
\param expr a string expression
\return true or false
*/
#define switch_true(expr)\
((expr && ( !strcasecmp(expr, "yes") ||\
!strcasecmp(expr, "on") ||\
!strcasecmp(expr, "true") ||\
!strcasecmp(expr, "enabled") ||\
!strcasecmp(expr, "active") ||\
!strcasecmp(expr, "allow") ||\
(switch_is_number(expr) && atoi(expr)))) ? SWITCH_TRUE : SWITCH_FALSE)
static inline int switch_true(const char *expr)
{
return ((expr && ( !strcasecmp(expr, "yes") ||
!strcasecmp(expr, "on") ||
!strcasecmp(expr, "true") ||
!strcasecmp(expr, "enabled") ||
!strcasecmp(expr, "active") ||
!strcasecmp(expr, "allow") ||
(switch_is_number(expr) && atoi(expr)))) ? SWITCH_TRUE : SWITCH_FALSE);
}
#define switch_true_buf(expr)\
((( !strcasecmp(expr, "yes") ||\
@@ -268,14 +271,16 @@ SWITCH_DECLARE(switch_status_t) switch_frame_free(switch_frame_t **frame);
\param expr a string expression
\return true or false
*/
#define switch_false(expr)\
((expr && ( !strcasecmp(expr, "no") ||\
!strcasecmp(expr, "off") ||\
!strcasecmp(expr, "false") ||\
!strcasecmp(expr, "disabled") ||\
!strcasecmp(expr, "inactive") ||\
!strcasecmp(expr, "disallow") ||\
(switch_is_number(expr) && !atoi(expr)))) ? SWITCH_TRUE : SWITCH_FALSE)
static inline int switch_false(const char *expr)
{
return ((expr && ( !strcasecmp(expr, "no") ||
!strcasecmp(expr, "off") ||
!strcasecmp(expr, "false") ||
!strcasecmp(expr, "disabled") ||
!strcasecmp(expr, "inactive") ||
!strcasecmp(expr, "disallow") ||
(switch_is_number(expr) && !atoi(expr)))) ? SWITCH_TRUE : SWITCH_FALSE);
}
SWITCH_DECLARE(switch_status_t) switch_resolve_host(const char *host, char *buf, size_t buflen);
@@ -500,6 +505,23 @@ static inline char *switch_clean_string(char *s)
}
static inline char *switch_clean_name_string(char *s)
{
char *p;
for (p = s; p && *p; p++) {
uint8_t x = (uint8_t) * p;
if ((x < 32) || x == '\'' || x == '"' || x == '<' || x == '>' || x == '\\' || x == ':' || x == '@' || x == '/') {
*p = ' ';
}
if ( (p == s) && (*p == ' ') ) {
s++;
}
}
return s;
}
/*!
\brief Free a pointer and set it to NULL unless it already is NULL
@@ -653,7 +675,7 @@ SWITCH_DECLARE(switch_time_t) switch_str_time(const char *in);
SWITCH_DECLARE(unsigned int) switch_separate_string(_In_ char *buf, char delim, _Post_count_(return) char **array, unsigned int arraylen);
SWITCH_DECLARE(unsigned int) switch_separate_string_string(char *buf, char *delim, _Post_count_(return) char **array, unsigned int arraylen);
SWITCH_DECLARE(switch_bool_t) switch_is_number(const char *str);
SWITCH_DECLARE(char *) switch_strip_spaces(char *str, switch_bool_t dup);
SWITCH_DECLARE(char *) switch_strip_whitespace(const char *str);
SWITCH_DECLARE(char *) switch_strip_commas(char *in, char *out, switch_size_t len);
+2
View File
@@ -417,6 +417,8 @@ SWITCH_DECLARE(switch_xml_section_t) switch_xml_parse_section_string(_In_opt_z_
SWITCH_DECLARE(int) switch_xml_std_datetime_check(switch_xml_t xcond);
SWITCH_DECLARE(switch_status_t) switch_xml_locate_language(switch_xml_t *root, switch_xml_t *node, switch_event_t *params, switch_xml_t *language, switch_xml_t *phrases, switch_xml_t *macros, const char *str_language);
SWITCH_END_EXTERN_C
///\}
#endif // _SWITCH_XML_H