diff --git a/Makefile.am b/Makefile.am index b381c219fc..30361d8164 100644 --- a/Makefile.am +++ b/Makefile.am @@ -11,6 +11,7 @@ BASE = $(switch_srcdir) OSARCH=`uname -s` LIBTOOL=`if test -z "$(VERBOSE)" ; then echo $(SHELL) $(switch_builddir)/quiet_libtool ;else echo $(switch_builddir)/libtool; fi;` +#LIBS+=> core.log || error="yes";if test -n "$(VERBOSE)" -o "$$error" = "yes";then cat core.log;fi;if test "$$error" = "yes";then exit 1;fi LTINSTALL = $(LIBTOOL) --mode=install $(INSTALL) TOUCH_TARGET=if test -f "$@" ; then touch "$@" ; fi ; @@ -26,7 +27,24 @@ src/switch_buffer.c \ src/switch_caller.c \ src/switch_channel.c \ src/switch_console.c \ +src/switch_core_media_bug.c \ +src/switch_core_timer.c \ +src/switch_core_asr.c \ +src/switch_core_event_hook.c \ +src/switch_core_speech.c \ +src/switch_core_memory.c \ +src/switch_core_codec.c \ +src/switch_core_file.c \ +src/switch_core_hash.c \ +src/switch_core_sqldb.c \ +src/switch_core_session.c \ +src/switch_core_directory.c \ +src/switch_core_state_machine.c \ +src/switch_core_io.c \ +src/switch_core_rwlock.c \ +src/switch_core_port_allocator.c \ src/switch_core.c \ +src/switch_scheduler.c \ src/switch_core_db.c\ src/switch_loadable_module.c \ src/switch_utils.c \ @@ -34,6 +52,11 @@ src/switch_event.c \ src/switch_resample.c \ src/switch_regex.c\ src/switch_rtp.c\ +src/switch_ivr_bridge.c \ +src/switch_ivr_originate.c \ +src/switch_ivr_async.c \ +src/switch_ivr_play_say.c \ +src/switch_ivr_menu.c \ src/switch_ivr.c \ src/switch_stun.c\ src/switch_log.c\ @@ -52,6 +75,8 @@ src/include/switch_buffer.h\ src/include/switch_caller.h\ src/include/switch_channel.h\ src/include/switch_console.h\ +src/include/switch_core_event_hook.h\ +src/include/switch_scheduler.h\ src/include/switch_core.h\ src/include/switch_core_db.h\ src/include/switch_event.h\ @@ -81,7 +106,6 @@ CORE_CFLAGS += -I$(switch_srcdir)/libs/pcre CORE_CFLAGS += -I$(switch_srcdir)/libs/srtp/include CORE_CFLAGS += -I$(switch_srcdir)/libs/srtp/crypto/include CORE_CFLAGS += $(RESAMPLE_CFLAGS) -CORE_CFLAGS += -I$(switch_srcdir)/libs/libteletone/src CORE_LIBS = libs/apr/libapr-1.la libs/apr-util/libaprutil-1.la CORE_LIBS += libs/sqlite/libsqlite3.la libs/pcre/libpcre.la diff --git a/build/indent_options.sh b/build/indent_options.sh index 0e55e79977..b6e23f7f49 100755 --- a/build/indent_options.sh +++ b/build/indent_options.sh @@ -1,4 +1,4 @@ #!/bin/bash -echo -n "-brs -npsl -di0 -br -ce -d0 -cli0 -npcs -nfc1 -ut -i4 -ts4 -l120 -cs -T size_t " > ../.indent.pro -grep typedef ../src/include/*.h | grep switch_ | grep -v "\*\|{" | sed -e s/struct// | perl -ne '@l = split; $l[2] =~ s/;//g ; print "-T $l[2] "' >> ../.indent.pro -grep "} switch_" ../src/include/*.h | perl -ne '@l = split; $l[1] =~ s/;//g ; print " -T $l[1] "' >> ../.indent.pro +echo -n "-brs -npsl -di0 -br -ce -d0 -cli0 -npcs -nfc1 -ut -i4 -ts4 -l160 -cs -T size_t " > ./.indent.pro +grep typedef ./src/include/*.h | grep switch_ | grep -v "\*\|{" | sed -e s/struct// | perl -ne '@l = split; $l[2] =~ s/;//g ; print "-T $l[2] "' >> ./.indent.pro +grep "} switch_" ./src/include/*.h | perl -ne '@l = split; $l[1] =~ s/;//g ; print " -T $l[1] "' >> ./.indent.pro diff --git a/configure.in b/configure.in index a844d000bf..f55bff8034 100644 --- a/configure.in +++ b/configure.in @@ -78,8 +78,8 @@ AC_SUBST(RESAMPLE_CFLAGS) AM_CONDITIONAL([USE_INTREE_RESAMPLE],[test "${enable_resample}" = "yes"]) # set defaults for use on all platforms -SWITCH_AM_CFLAGS="-I${switch_srcdir}/src/include" -SWITCH_AM_CXXFLAGS="-I${switch_srcdir}/src/include" +SWITCH_AM_CFLAGS="-I${switch_srcdir}/src/include -I${switch_srcdir}/libs/libteletone/src" +SWITCH_AM_CXXFLAGS="-I${switch_srcdir}/src/include -I${switch_srcdir}/libs/libteletone/src" SWITCH_AM_LDFLAGS="-lm -L/usr/local/lib" #set SOLINK variable based on compiler and host diff --git a/libs/libteletone/src/libteletone_detect.h b/libs/libteletone/src/libteletone_detect.h index 93ba2ee5eb..a6d0bf7c61 100644 --- a/libs/libteletone/src/libteletone_detect.h +++ b/libs/libteletone/src/libteletone_detect.h @@ -64,10 +64,12 @@ extern "C" { This module is responsible for tone detection specifics */ +#ifndef FALSE #define FALSE 0 #ifndef TRUE #define TRUE (!FALSE) #endif +#endif /* Basic DTMF specs: * diff --git a/src/include/switch.h b/src/include/switch.h index 2e1474b3fb..a7cef117f3 100644 --- a/src/include/switch.h +++ b/src/include/switch.h @@ -90,7 +90,9 @@ #include #include #include - +#include +#include +#include /** \mainpage FreeSWITCH * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application diff --git a/src/include/switch_apr.h b/src/include/switch_apr.h index d84801ed75..5d73850364 100644 --- a/src/include/switch_apr.h +++ b/src/include/switch_apr.h @@ -40,25 +40,22 @@ #define SWITCH_APR_H SWITCH_BEGIN_EXTERN_C - /* The pieces of apr we allow ppl to pass around between modules we typedef into our namespace and wrap all the functions any other apr code should be as hidden as possible. */ - /** * @defgroup switch_apr Brought To You By APR * @ingroup FREESWITCH * @{ - */ - + */ /** * @defgroup switch_memory_pool Memory Pool Functions * @ingroup switch_apr * @{ */ /** The fundamental pool type */ -typedef struct apr_pool_t switch_memory_pool_t; + typedef struct apr_pool_t switch_memory_pool_t; /** @@ -81,12 +78,12 @@ SWITCH_DECLARE(void) switch_pool_clear(switch_memory_pool_t *p); /** * Structure for referencing dynamic objects */ -typedef struct apr_dso_handle_t switch_dso_handle_t; + typedef struct apr_dso_handle_t switch_dso_handle_t; /** * Structure for referencing symbols from dynamic objects */ -typedef void * switch_dso_handle_sym_t; + typedef void *switch_dso_handle_sym_t; /** * Load a DSO library. @@ -96,8 +93,8 @@ typedef void * switch_dso_handle_sym_t; * @bug We aught to provide an alternative to RTLD_GLOBAL, which * is the only supported method of loading DSOs today. */ -SWITCH_DECLARE(switch_status_t) switch_dso_load(switch_dso_handle_t **res_handle, - const char *path, switch_memory_pool_t *ctx); +SWITCH_DECLARE(switch_status_t) switch_dso_load(switch_dso_handle_t **res_handle, + const char *path, switch_memory_pool_t *ctx); /** * Close a DSO library. @@ -111,9 +108,8 @@ SWITCH_DECLARE(switch_status_t) switch_dso_unload(switch_dso_handle_t *handle); * @param handle handle to load the symbol from. * @param symname Name of the symbol to load. */ -SWITCH_DECLARE(switch_status_t) switch_dso_sym(switch_dso_handle_sym_t *ressym, - switch_dso_handle_t *handle, - const char *symname); +SWITCH_DECLARE(switch_status_t) switch_dso_sym(switch_dso_handle_sym_t * ressym, + switch_dso_handle_t *handle, const char *symname); /** * Report more information when a DSO function fails. @@ -146,10 +142,10 @@ SWITCH_DECLARE(char *) switch_copy_string(char *dst, const char *src, switch_siz */ /** Abstract type for hash tables. */ -typedef struct apr_hash_t switch_hash_t; + typedef struct apr_hash_t switch_hash_t; /** Abstract type for scanning hash tables. */ -typedef struct apr_hash_index_t switch_hash_index_t; + typedef struct apr_hash_index_t switch_hash_index_t; /** * When passing a key to switch_hashfunc_default, this value can be @@ -208,40 +204,40 @@ SWITCH_DECLARE(switch_memory_pool_t *) switch_hash_pool_get(switch_hash_t *ht); */ /** number of microseconds since 00:00:00 january 1, 1970 UTC */ -typedef int64_t switch_time_t; + typedef int64_t switch_time_t; /** number of microseconds in the interval */ -typedef int64_t switch_interval_time_t; + typedef int64_t switch_interval_time_t; /** * a structure similar to ANSI struct tm with the following differences: * - tm_usec isn't an ANSI field * - tm_gmtoff isn't an ANSI field (it's a bsdism) */ -typedef struct switch_time_exp_t { - /** microseconds past tm_sec */ - int32_t tm_usec; - /** (0-61) seconds past tm_min */ - int32_t tm_sec; - /** (0-59) minutes past tm_hour */ - int32_t tm_min; - /** (0-23) hours past midnight */ - int32_t tm_hour; - /** (1-31) day of the month */ - int32_t tm_mday; - /** (0-11) month of the year */ - int32_t tm_mon; - /** year since 1900 */ - int32_t tm_year; - /** (0-6) days since sunday */ - int32_t tm_wday; - /** (0-365) days since jan 1 */ - int32_t tm_yday; - /** daylight saving time */ - int32_t tm_isdst; - /** seconds east of UTC */ - int32_t tm_gmtoff; -} switch_time_exp_t; + typedef struct switch_time_exp_t { + /** microseconds past tm_sec */ + int32_t tm_usec; + /** (0-61) seconds past tm_min */ + int32_t tm_sec; + /** (0-59) minutes past tm_hour */ + int32_t tm_min; + /** (0-23) hours past midnight */ + int32_t tm_hour; + /** (1-31) day of the month */ + int32_t tm_mday; + /** (0-11) month of the year */ + int32_t tm_mon; + /** year since 1900 */ + int32_t tm_year; + /** (0-6) days since sunday */ + int32_t tm_wday; + /** (0-365) days since jan 1 */ + int32_t tm_yday; + /** daylight saving time */ + int32_t tm_isdst; + /** seconds east of UTC */ + int32_t tm_gmtoff; + } switch_time_exp_t; SWITCH_DECLARE(switch_time_t) switch_time_make(switch_time_t sec, int32_t usec); @@ -268,9 +264,7 @@ SWITCH_DECLARE(switch_status_t) switch_time_exp_gmt_get(switch_time_t *result, s */ SWITCH_DECLARE(switch_status_t) switch_strftime(char *s, switch_size_t *retsize, - switch_size_t max, - const char *format, - switch_time_exp_t *tm); + switch_size_t max, const char *format, switch_time_exp_t *tm); /** * switch_rfc822_date formats dates in the RFC822 @@ -320,7 +314,7 @@ SWITCH_DECLARE(void) switch_sleep(switch_interval_time_t t); */ /** Opaque thread-local mutex structure */ -typedef struct apr_thread_mutex_t switch_mutex_t; + typedef struct apr_thread_mutex_t switch_mutex_t; /** Lock Flags */ #define SWITCH_MUTEX_DEFAULT 0x0 /**< platform-optimal lock behavior */ @@ -344,8 +338,7 @@ typedef struct apr_thread_mutex_t switch_mutex_t; * */ SWITCH_DECLARE(switch_status_t) switch_mutex_init(switch_mutex_t **lock, - unsigned int flags, - switch_memory_pool_t *pool); + unsigned int flags, switch_memory_pool_t *pool); /** @@ -385,10 +378,10 @@ SWITCH_DECLARE(switch_status_t) switch_mutex_trylock(switch_mutex_t *lock); */ /** Opaque structure used for the rwlock */ -typedef struct apr_thread_rwlock_t switch_thread_rwlock_t; + typedef struct apr_thread_rwlock_t switch_thread_rwlock_t; SWITCH_DECLARE(switch_status_t) switch_thread_rwlock_create(switch_thread_rwlock_t **rwlock, - switch_memory_pool_t *pool); + switch_memory_pool_t *pool); SWITCH_DECLARE(switch_status_t) switch_thread_rwlock_destroy(switch_thread_rwlock_t *rwlock); SWITCH_DECLARE(switch_memory_pool_t *) switch_thread_rwlock_pool_get(switch_thread_rwlock_t *rwlock); SWITCH_DECLARE(switch_status_t) switch_thread_rwlock_rdlock(switch_thread_rwlock_t *rwlock); @@ -412,7 +405,7 @@ SWITCH_DECLARE(switch_status_t) switch_thread_rwlock_unlock(switch_thread_rwlock */ /** Opaque structure for thread condition variables */ -typedef struct apr_thread_cond_t switch_thread_cond_t; + typedef struct apr_thread_cond_t switch_thread_cond_t; /** * Create and initialize a condition variable that can be used to signal @@ -453,7 +446,8 @@ SWITCH_DECLARE(switch_status_t) switch_thread_cond_wait(switch_thread_cond_t *co * will wake up before this time, otherwise the error APR_TIMEUP * is returned. */ -SWITCH_DECLARE(switch_status_t) switch_thread_cond_timedwait(switch_thread_cond_t *cond, switch_mutex_t *mutex, switch_interval_time_t timeout); +SWITCH_DECLARE(switch_status_t) switch_thread_cond_timedwait(switch_thread_cond_t *cond, switch_mutex_t *mutex, + switch_interval_time_t timeout); /** * Signals a single thread, if one exists, that is blocking on the given @@ -488,9 +482,10 @@ SWITCH_DECLARE(switch_status_t) switch_thread_cond_destroy(switch_thread_cond_t /** we represent a UUID as a block of 16 bytes. */ -typedef struct { - unsigned char data[16]; /**< the actual UUID */ -} switch_uuid_t; + typedef struct { + unsigned char data[16]; + /**< the actual UUID */ + } switch_uuid_t; /** UUIDs are formatted as: 00112233-4455-6677-8899-AABBCCDDEEFF */ #define SWITCH_UUID_FORMATTED_LENGTH 36 @@ -501,20 +496,20 @@ typedef struct { * be at least APR_UUID_FORMATTED_LENGTH + 1 bytes long to hold * the formatted UUID and a null terminator * @param uuid The UUID to format - */ + */ SWITCH_DECLARE(void) switch_uuid_format(char *buffer, const switch_uuid_t *uuid); /** * Generate and return a (new) UUID * @param uuid The resulting UUID - */ + */ SWITCH_DECLARE(void) switch_uuid_get(switch_uuid_t *uuid); /** * Parse a standard-format string into a UUID * @param uuid The resulting UUID * @param uuid_str The formatted UUID - */ + */ SWITCH_DECLARE(switch_status_t) switch_uuid_parse(switch_uuid_t *uuid, const char *uuid_str); /** @} */ @@ -526,7 +521,7 @@ SWITCH_DECLARE(switch_status_t) switch_uuid_parse(switch_uuid_t *uuid, const cha */ /** Opaque structure used for queue API */ -typedef struct apr_queue_t switch_queue_t; + typedef struct apr_queue_t switch_queue_t; /** * create a FIFO queue @@ -534,9 +529,8 @@ typedef struct apr_queue_t switch_queue_t; * @param queue_capacity maximum size of the queue * @param a pool to allocate queue from */ -SWITCH_DECLARE(switch_status_t) switch_queue_create(switch_queue_t **queue, - unsigned int queue_capacity, - switch_memory_pool_t *pool); +SWITCH_DECLARE(switch_status_t) switch_queue_create(switch_queue_t **queue, + unsigned int queue_capacity, switch_memory_pool_t *pool); /** * pop/get an object from the queue, blocking if the queue is already empty @@ -603,17 +597,17 @@ SWITCH_DECLARE(switch_status_t) switch_queue_trypush(switch_queue_t *queue, void */ /** Structure for referencing files. */ -typedef struct apr_file_t switch_file_t; + typedef struct apr_file_t switch_file_t; -typedef int32_t switch_fileperms_t; -typedef int switch_seek_where_t; + typedef int32_t switch_fileperms_t; + typedef int switch_seek_where_t; /** * @defgroup switch_file_permissions File Permissions flags * @ingroup switch_file_io * @{ */ - + #define SWITCH_FPROT_USETID 0x8000 /**< Set user id */ #define SWITCH_FPROT_UREAD 0x0400 /**< Read by user */ #define SWITCH_FPROT_UWRITE 0x0200 /**< Write by user */ @@ -690,7 +684,8 @@ typedef int switch_seek_where_t; * @remark If perm is SWITCH_FPROT_OS_DEFAULT and the file is being created, * appropriate default permissions will be used. */ -SWITCH_DECLARE(switch_status_t) switch_file_open(switch_file_t **newf, const char *fname, int32_t flag, switch_fileperms_t perm, switch_memory_pool_t *pool); +SWITCH_DECLARE(switch_status_t) switch_file_open(switch_file_t **newf, const char *fname, int32_t flag, + switch_fileperms_t perm, switch_memory_pool_t *pool); SWITCH_DECLARE(switch_status_t) switch_file_seek(switch_file_t *thefile, switch_seek_where_t where, int64_t *offset); @@ -757,16 +752,16 @@ SWITCH_DECLARE(switch_status_t) switch_file_exists(const char *filename); */ /** Opaque Thread structure. */ -typedef struct apr_thread_t switch_thread_t; + typedef struct apr_thread_t switch_thread_t; /** Opaque Thread attributes structure. */ -typedef struct apr_threadattr_t switch_threadattr_t; + typedef struct apr_threadattr_t switch_threadattr_t; /** * The prototype for any APR thread worker functions. * typedef void *(SWITCH_THREAD_FUNC *switch_thread_start_t)(switch_thread_t*, void*); */ -typedef void *(SWITCH_THREAD_FUNC *switch_thread_start_t)(switch_thread_t*, void*); + typedef void *(SWITCH_THREAD_FUNC * switch_thread_start_t) (switch_thread_t *, void *); //APR_DECLARE(apr_status_t) apr_threadattr_stacksize_set(apr_threadattr_t *attr, switch_size_t stacksize) SWITCH_DECLARE(switch_status_t) switch_threadattr_stacksize_set(switch_threadattr_t *attr, switch_size_t stacksize); @@ -793,7 +788,9 @@ SWITCH_DECLARE(switch_status_t) switch_threadattr_detach_set(switch_threadattr_t * @param data Any data to be passed to the starting function * @param cont The pool to use */ -SWITCH_DECLARE(switch_status_t) switch_thread_create(switch_thread_t **new_thread, switch_threadattr_t *attr, switch_thread_start_t func, void *data, switch_memory_pool_t *cont); +SWITCH_DECLARE(switch_status_t) switch_thread_create(switch_thread_t **new_thread, switch_threadattr_t *attr, + switch_thread_start_t func, void *data, + switch_memory_pool_t *cont); /** @} */ @@ -829,16 +826,16 @@ SWITCH_DECLARE(switch_status_t) switch_thread_create(switch_thread_t **new_threa #endif /** A structure to represent sockets */ -typedef struct apr_socket_t switch_socket_t; + typedef struct apr_socket_t switch_socket_t; /** Freeswitch's socket address type, used to ensure protocol independence */ -typedef struct apr_sockaddr_t switch_sockaddr_t; + typedef struct apr_sockaddr_t switch_sockaddr_t; -typedef enum { - SWITCH_SHUTDOWN_READ, /**< no longer allow read request */ - SWITCH_SHUTDOWN_WRITE, /**< no longer allow write requests */ - SWITCH_SHUTDOWN_READWRITE /**< no longer allow read or write requests */ -} switch_shutdown_how_e; + typedef enum { + SWITCH_SHUTDOWN_READ, /**< no longer allow read request */ + SWITCH_SHUTDOWN_WRITE, /**< no longer allow write requests */ + SWITCH_SHUTDOWN_READWRITE /**< no longer allow read or write requests */ + } switch_shutdown_how_e; /** * @defgroup IP_Proto IP Protocol Definitions for use when creating sockets @@ -859,7 +856,8 @@ typedef enum { * @param protocol The protocol of the socket (e.g., SWITCH_PROTO_TCP). * @param pool The pool to use */ -SWITCH_DECLARE(switch_status_t) switch_socket_create(switch_socket_t **new_sock, int family, int type, int protocol, switch_memory_pool_t *pool); + SWITCH_DECLARE(switch_status_t) switch_socket_create(switch_socket_t **new_sock, int family, int type, + int protocol, switch_memory_pool_t *pool); /** * Shutdown either reading, writing, or both sides of a socket. @@ -874,13 +872,13 @@ SWITCH_DECLARE(switch_status_t) switch_socket_create(switch_socket_t **new_sock, * @remark This does not actually close the socket descriptor, it just * controls which calls are still valid on the socket. */ -SWITCH_DECLARE(switch_status_t) switch_socket_shutdown(switch_socket_t *sock, switch_shutdown_how_e how); + SWITCH_DECLARE(switch_status_t) switch_socket_shutdown(switch_socket_t *sock, switch_shutdown_how_e how); /** * Close a socket. * @param sock The socket to close */ -SWITCH_DECLARE(switch_status_t) switch_socket_close(switch_socket_t *sock); + SWITCH_DECLARE(switch_status_t) switch_socket_close(switch_socket_t *sock); /** * Bind the socket to its associated port @@ -889,7 +887,7 @@ SWITCH_DECLARE(switch_status_t) switch_socket_close(switch_socket_t *sock); * @remark This may be where we will find out if there is any other process * using the selected port. */ -SWITCH_DECLARE(switch_status_t) switch_socket_bind(switch_socket_t *sock, switch_sockaddr_t *sa); + SWITCH_DECLARE(switch_status_t) switch_socket_bind(switch_socket_t *sock, switch_sockaddr_t *sa); /** * Listen to a bound socket for connections. @@ -898,7 +896,7 @@ SWITCH_DECLARE(switch_status_t) switch_socket_bind(switch_socket_t *sock, switch * listen queue. If this value is less than zero, the listen * queue size is set to zero. */ -SWITCH_DECLARE(switch_status_t) switch_socket_listen(switch_socket_t *sock, int32_t backlog); + SWITCH_DECLARE(switch_status_t) switch_socket_listen(switch_socket_t *sock, int32_t backlog); /** * Accept a new connection request @@ -908,7 +906,8 @@ SWITCH_DECLARE(switch_status_t) switch_socket_listen(switch_socket_t *sock, int3 * @param sock The socket we are listening on. * @param connection_pool The pool for the new socket. */ -SWITCH_DECLARE(switch_status_t) switch_socket_accept(switch_socket_t **new_sock, switch_socket_t *sock, switch_memory_pool_t *pool); + SWITCH_DECLARE(switch_status_t) switch_socket_accept(switch_socket_t **new_sock, switch_socket_t *sock, + switch_memory_pool_t *pool); /** * Issue a connection request to a socket either on the same machine @@ -916,12 +915,12 @@ SWITCH_DECLARE(switch_status_t) switch_socket_accept(switch_socket_t **new_sock, * @param sock The socket we wish to use for our side of the connection * @param sa The address of the machine we wish to connect to. */ -SWITCH_DECLARE(switch_status_t) switch_socket_connect(switch_socket_t *sock, switch_sockaddr_t *sa); + SWITCH_DECLARE(switch_status_t) switch_socket_connect(switch_socket_t *sock, switch_sockaddr_t *sa); -SWITCH_DECLARE(uint16_t) switch_sockaddr_get_port(switch_sockaddr_t *sa); -SWITCH_DECLARE(char *) switch_get_addr(char *buf, switch_size_t len, switch_sockaddr_t *in); -SWITCH_DECLARE(int32_t) switch_sockaddr_get_family(switch_sockaddr_t *sa); -SWITCH_DECLARE(switch_status_t) switch_sockaddr_ip_get(char **addr, switch_sockaddr_t *sa); + SWITCH_DECLARE(uint16_t) switch_sockaddr_get_port(switch_sockaddr_t *sa); + SWITCH_DECLARE(char *) switch_get_addr(char *buf, switch_size_t len, switch_sockaddr_t *in); + SWITCH_DECLARE(int32_t) switch_sockaddr_get_family(switch_sockaddr_t *sa); + SWITCH_DECLARE(switch_status_t) switch_sockaddr_ip_get(char **addr, switch_sockaddr_t *sa); /** @@ -947,7 +946,9 @@ SWITCH_DECLARE(switch_status_t) switch_sockaddr_ip_get(char **addr, switch_socka * * @param p The pool for the apr_sockaddr_t and associated storage. */ -SWITCH_DECLARE(switch_status_t) switch_sockaddr_info_get(switch_sockaddr_t **sa, const char *hostname, int32_t family, switch_port_t port, int32_t flags, switch_memory_pool_t *pool); + SWITCH_DECLARE(switch_status_t) switch_sockaddr_info_get(switch_sockaddr_t **sa, const char *hostname, + int32_t family, switch_port_t port, int32_t flags, + switch_memory_pool_t *pool); /** * Send data over a network. @@ -966,7 +967,7 @@ SWITCH_DECLARE(switch_status_t) switch_sockaddr_info_get(switch_sockaddr_t **sa, * APR_EINTR is never returned. * */ -SWITCH_DECLARE(switch_status_t) switch_socket_send(switch_socket_t *sock, const char *buf, switch_size_t *len); + SWITCH_DECLARE(switch_status_t) switch_socket_send(switch_socket_t *sock, const char *buf, switch_size_t *len); /** * @param sock The socket to send from @@ -975,7 +976,8 @@ SWITCH_DECLARE(switch_status_t) switch_socket_send(switch_socket_t *sock, const * @param buf The data to send * @param len The length of the data to send */ -SWITCH_DECLARE(switch_status_t) switch_socket_sendto(switch_socket_t *sock, switch_sockaddr_t *where, int32_t flags, const char *buf, switch_size_t *len); + SWITCH_DECLARE(switch_status_t) switch_socket_sendto(switch_socket_t *sock, switch_sockaddr_t *where, + int32_t flags, const char *buf, switch_size_t *len); /** * @param from The apr_sockaddr_t to fill in the recipient info @@ -985,11 +987,9 @@ SWITCH_DECLARE(switch_status_t) switch_socket_sendto(switch_socket_t *sock, swit * @param len The length of the available buffer * */ -SWITCH_DECLARE(switch_status_t) switch_socket_recvfrom(switch_sockaddr_t *from, - switch_socket_t *sock, - int32_t flags, - char *buf, - size_t *len); + SWITCH_DECLARE(switch_status_t) switch_socket_recvfrom(switch_sockaddr_t *from, + switch_socket_t *sock, + int32_t flags, char *buf, size_t *len); /** @@ -1011,7 +1011,7 @@ SWITCH_DECLARE(switch_status_t) switch_socket_recvfrom(switch_sockaddr_t *from, * APR_EINTR is never returned. * */ -SWITCH_DECLARE(switch_status_t) switch_socket_recv(switch_socket_t *sock, char *buf, switch_size_t *len); + SWITCH_DECLARE(switch_status_t) switch_socket_recv(switch_socket_t *sock, char *buf, switch_size_t *len); /** * Setup socket options for the specified socket @@ -1035,7 +1035,7 @@ SWITCH_DECLARE(switch_status_t) switch_socket_recv(switch_socket_t *sock, char * * * @param on Value for the option. */ -SWITCH_DECLARE(switch_status_t) switch_socket_opt_set(switch_socket_t *sock, int32_t opt, int32_t on); + SWITCH_DECLARE(switch_status_t) switch_socket_opt_set(switch_socket_t *sock, int32_t opt, int32_t on); /** * Setup socket timeout for the specified socket @@ -1048,7 +1048,7 @@ SWITCH_DECLARE(switch_status_t) switch_socket_opt_set(switch_socket_t *sock, int * t < 0 -- read and write calls block * */ -SWITCH_DECLARE(switch_status_t) switch_socket_timeout_set(switch_socket_t *sock, switch_interval_time_t t); + SWITCH_DECLARE(switch_status_t) switch_socket_timeout_set(switch_socket_t *sock, switch_interval_time_t t); /** * Join a Multicast Group @@ -1059,7 +1059,8 @@ SWITCH_DECLARE(switch_status_t) switch_socket_timeout_set(switch_socket_t *sock, * @param source Source Address to accept transmissions from (non-NULL * implies Source-Specific Multicast) */ -SWITCH_DECLARE(switch_status_t) switch_mcast_join(switch_socket_t *sock, switch_sockaddr_t *join, switch_sockaddr_t *iface, switch_sockaddr_t *source); + SWITCH_DECLARE(switch_status_t) switch_mcast_join(switch_socket_t *sock, switch_sockaddr_t *join, + switch_sockaddr_t *iface, switch_sockaddr_t *source); @@ -1071,10 +1072,10 @@ SWITCH_DECLARE(switch_status_t) switch_mcast_join(switch_socket_t *sock, switch_ * @{ */ /** Poll descriptor set. */ -typedef struct apr_pollfd_t switch_pollfd_t; + typedef struct apr_pollfd_t switch_pollfd_t; /** Opaque structure used for pollset API */ -typedef struct apr_pollset_t switch_pollset_t; + typedef struct apr_pollset_t switch_pollset_t; /** * Poll options @@ -1100,10 +1101,8 @@ typedef struct apr_pollset_t switch_pollset_t; * platforms; the apr_pollset_create() call will fail with * APR_ENOTIMPL on platforms where it is not supported. */ -SWITCH_DECLARE(switch_status_t) switch_pollset_create(switch_pollset_t **pollset, - uint32_t size, - switch_memory_pool_t *p, - uint32_t flags); + SWITCH_DECLARE(switch_status_t) switch_pollset_create(switch_pollset_t **pollset, + uint32_t size, switch_memory_pool_t *p, uint32_t flags); /** * Add a socket or file descriptor to a pollset @@ -1122,8 +1121,7 @@ SWITCH_DECLARE(switch_status_t) switch_pollset_create(switch_pollset_t **pollset * allowed for implementations where option (1) is impossible * or impractical. */ -SWITCH_DECLARE(switch_status_t) switch_pollset_add(switch_pollset_t *pollset, - const switch_pollfd_t *descriptor); + SWITCH_DECLARE(switch_status_t) switch_pollset_add(switch_pollset_t *pollset, const switch_pollfd_t *descriptor); /** * Poll the sockets in the poll structure @@ -1138,10 +1136,8 @@ SWITCH_DECLARE(switch_status_t) switch_pollset_add(switch_pollset_t *pollset, * This is a blocking call, and it will not return until either a * socket has been signalled, or the timeout has expired. */ -SWITCH_DECLARE(switch_status_t) switch_poll(switch_pollfd_t *aprset, - int32_t numsock, - int32_t *nsds, - switch_interval_time_t timeout); + SWITCH_DECLARE(switch_status_t) switch_poll(switch_pollfd_t *aprset, + int32_t numsock, int32_t *nsds, switch_interval_time_t timeout); /*! \brief Create a set of file descriptors to poll @@ -1151,9 +1147,10 @@ SWITCH_DECLARE(switch_status_t) switch_poll(switch_pollfd_t *aprset, \param pool the memory pool to use \return SWITCH_STATUS_SUCCESS when successful */ -SWITCH_DECLARE(switch_status_t) switch_socket_create_pollfd(switch_pollfd_t **poll, switch_socket_t *sock, int16_t flags, switch_memory_pool_t *pool); + SWITCH_DECLARE(switch_status_t) switch_socket_create_pollfd(switch_pollfd_t **poll, switch_socket_t *sock, + int16_t flags, switch_memory_pool_t *pool); + - /** @} */ @@ -1162,10 +1159,8 @@ SWITCH_DECLARE(switch_status_t) switch_socket_create_pollfd(switch_pollfd_t **po /** @} */ /** @} */ -SWITCH_END_EXTERN_C - + SWITCH_END_EXTERN_C #endif - /* For Emacs: * Local Variables: * mode:c diff --git a/src/include/switch_bitpack.h b/src/include/switch_bitpack.h index 3784966a2e..7e2372463f 100644 --- a/src/include/switch_bitpack.h +++ b/src/include/switch_bitpack.h @@ -36,22 +36,20 @@ #ifndef SWITCH_BITPACK_H #define SWITCH_BITPACK_H SWITCH_BEGIN_EXTERN_C - #include - #ifdef DEBUG_BITS static char bb[80] = ""; static inline char *print_bits(switch_byte_t byte, char *x) { - int i,j = 0; - x[j++] = '['; - for (i=7;i>=0;i--) { - x[j++] = (byte & (1 << i)) ? '1' : '0'; - } - x[j++] = ']'; - x[j++] = '\0'; - return x; + int i, j = 0; + x[j++] = '['; + for (i = 7; i >= 0; i--) { + x[j++] = (byte & (1 << i)) ? '1' : '0'; + } + x[j++] = ']'; + x[j++] = '\0'; + return x; } #endif @@ -63,8 +61,8 @@ static inline char *print_bits(switch_byte_t byte, char *x) \{ */ -static const uint8_t SWITCH_BITPACKED_MASKS[] = {0, 1, 3, 7, 15, 31, 63, 127, 255}; -static const uint8_t SWITCH_REVERSE_BITPACKED_MASKS[] = {255, 254, 252, 248, 240, 224, 192, 128}; +static const uint8_t SWITCH_BITPACKED_MASKS[] = { 0, 1, 3, 7, 15, 31, 63, 127, 255 }; +static const uint8_t SWITCH_REVERSE_BITPACKED_MASKS[] = { 255, 254, 252, 248, 240, 224, 192, 128 }; /*! \brief Initialize a bitpack object @@ -74,8 +72,11 @@ static const uint8_t SWITCH_REVERSE_BITPACKED_MASKS[] = {255, 254, 252, 248, 240 \param buflen the length of the storage buffer \param mode RFC3551 or AAL2 mode (curse you backwards folks) */ -DoxyDefine(void switch_bitpack_init(switch_bitpack_t *pack, int32_t bitlen, switch_byte_t *buf, uint32_t buflen, switch_bitpack_mode_t mode)) -static inline int8_t switch_bitpack_init(switch_bitpack_t *pack, switch_byte_t bitlen, switch_byte_t *buf, uint32_t buflen, switch_bitpack_mode_t mode) +DoxyDefine(void + switch_bitpack_init(switch_bitpack_t *pack, int32_t bitlen, switch_byte_t *buf, uint32_t buflen, + switch_bitpack_mode_t mode)) + static inline int8_t switch_bitpack_init(switch_bitpack_t *pack, switch_byte_t bitlen, switch_byte_t *buf, + uint32_t buflen, switch_bitpack_mode_t mode) { if (!pack || (bitlen > SWITCH_BITS_PER_BYTE) || !buf || !buflen) { return -1; @@ -94,7 +95,7 @@ static inline int8_t switch_bitpack_init(switch_bitpack_t *pack, switch_byte_t b static inline void pack_check_over(switch_bitpack_t *pack) { - switch_byte_t this_byte = pack->this_byte; + switch_byte_t this_byte = pack->this_byte; if (pack->over) { pack->bits_cur = pack->over; @@ -117,7 +118,7 @@ static inline void pack_check_over(switch_bitpack_t *pack) pack->bytes++; pack->over = pack->under = 0; - } + } } /*! @@ -125,14 +126,14 @@ static inline void pack_check_over(switch_bitpack_t *pack) \param pack the pack/unpack object */ DoxyDefine(int8_t switch_bitpack_done(switch_bitpack_t *pack)) -static inline int8_t switch_bitpack_done(switch_bitpack_t *pack) + static inline int8_t switch_bitpack_done(switch_bitpack_t *pack) { if (pack->bits_cur && pack->bits_cur < SWITCH_BITS_PER_BYTE) { pack->bytes++; if (pack->mode == SWITCH_BITPACK_MODE_AAL2) { - *pack->cur <<= SWITCH_BITS_PER_BYTE - pack->bits_cur; - } + *pack->cur <<= SWITCH_BITS_PER_BYTE - pack->bits_cur; + } } if (pack->over) { @@ -149,11 +150,11 @@ static inline int8_t switch_bitpack_done(switch_bitpack_t *pack) \return -1 if the buffer is full otherwise 0 */ DoxyDefine(int8_t switch_bitpack_out(switch_bitpack_t *unpack, switch_byte_t in)) -static inline int8_t switch_bitpack_out(switch_bitpack_t *unpack, switch_byte_t in) + static inline int8_t switch_bitpack_out(switch_bitpack_t *unpack, switch_byte_t in) { switch_byte_t this_byte; - if ((uint32_t)(unpack->cur - unpack->buf) > unpack->buflen) { + if ((uint32_t) (unpack->cur - unpack->buf) > unpack->buflen) { return -1; } @@ -163,7 +164,7 @@ static inline int8_t switch_bitpack_out(switch_bitpack_t *unpack, switch_byte_t pack_check_over(unpack); - while(unpack->bits_cur <= SWITCH_BITS_PER_BYTE) { + while (unpack->bits_cur <= SWITCH_BITS_PER_BYTE) { switch_byte_t next = unpack->bits_cur + unpack->frame_bits; switch_byte_t under_in; switch_byte_t mask; @@ -220,20 +221,20 @@ static inline int8_t switch_bitpack_out(switch_bitpack_t *unpack, switch_byte_t \return -1 if the buffer is full otherwise 0 */ DoxyDefine(int8_t switch_bitpack_in(switch_bitpack_t *pack, switch_byte_t in)) -static inline int8_t switch_bitpack_in(switch_bitpack_t *pack, switch_byte_t in) + static inline int8_t switch_bitpack_in(switch_bitpack_t *pack, switch_byte_t in) { int next = pack->bits_cur + pack->frame_bits; - if ((uint32_t)(pack->cur - pack->buf) > pack->buflen) { + if ((uint32_t) (pack->cur - pack->buf) > pack->buflen) { return -1; - } + } pack->bits_tot += pack->frame_bits; if (next > SWITCH_BITS_PER_BYTE) { switch_byte_t a = 0, b = 0, rem, nxt; rem = SWITCH_BITS_PER_BYTE - pack->bits_cur; - nxt = pack->frame_bits - rem ; + nxt = pack->frame_bits - rem; if (pack->mode == SWITCH_BITPACK_MODE_RFC3551) { a = in & SWITCH_BITPACKED_MASKS[rem]; b = in >> rem; @@ -250,7 +251,7 @@ static inline int8_t switch_bitpack_in(switch_bitpack_t *pack, switch_byte_t in) pack->cur++; *pack->cur |= b; pack->bits_cur = nxt; - + } pack->bytes++; @@ -259,14 +260,14 @@ static inline int8_t switch_bitpack_in(switch_bitpack_t *pack, switch_byte_t in) if (pack->mode == SWITCH_BITPACK_MODE_RFC3551) { in <<= pack->shiftby; *pack->cur |= in; - pack->shiftby = (switch_byte_t)(pack->shiftby + pack->frame_bits); + pack->shiftby = (switch_byte_t) (pack->shiftby + pack->frame_bits); } else { *pack->cur <<= pack->frame_bits; *pack->cur |= in; } if (next == SWITCH_BITS_PER_BYTE) { - pack->cur++; + pack->cur++; pack->bytes++; pack->bits_cur = pack->shiftby = 0; } else { @@ -276,11 +277,11 @@ static inline int8_t switch_bitpack_in(switch_bitpack_t *pack, switch_byte_t in) return 0; } + ///\} SWITCH_END_EXTERN_C #endif - /* For Emacs: * Local Variables: * mode:c diff --git a/src/include/switch_buffer.h b/src/include/switch_buffer.h index fcf59da018..ddc1d45f76 100644 --- a/src/include/switch_buffer.h +++ b/src/include/switch_buffer.h @@ -41,7 +41,6 @@ #include SWITCH_BEGIN_EXTERN_C - /** * @defgroup switch_buffer Buffer Routines * @ingroup core1 @@ -50,8 +49,7 @@ SWITCH_BEGIN_EXTERN_C * and I think it can be optimized under the hood as we go using bucket brigades and/or ring buffering techniques. * @{ */ - -struct switch_buffer; + struct switch_buffer; /*! \brief Allocate a new switch_buffer @@ -60,7 +58,8 @@ struct switch_buffer; * \param max_len length required by the buffer * \return status */ -SWITCH_DECLARE(switch_status_t) switch_buffer_create(switch_memory_pool_t *pool, switch_buffer_t **buffer, switch_size_t max_len); +SWITCH_DECLARE(switch_status_t) switch_buffer_create(switch_memory_pool_t *pool, switch_buffer_t **buffer, + switch_size_t max_len); /*! \brief Allocate a new dynamic switch_buffer * \param buffer returned pointer to the new buffer @@ -71,8 +70,7 @@ SWITCH_DECLARE(switch_status_t) switch_buffer_create(switch_memory_pool_t *pool, */ SWITCH_DECLARE(switch_status_t) switch_buffer_create_dynamic(switch_buffer_t **buffer, switch_size_t blocksize, - switch_size_t start_len, - switch_size_t max_len); + switch_size_t start_len, switch_size_t max_len); /*! \brief Get the length of a switch_buffer_t * \param buffer any buffer of type switch_buffer_t @@ -129,9 +127,7 @@ SWITCH_DECLARE(void) switch_buffer_destroy(switch_buffer_t **buffer); /** @} */ SWITCH_END_EXTERN_C - #endif - /* For Emacs: * Local Variables: * mode:c diff --git a/src/include/switch_caller.h b/src/include/switch_caller.h index 34bf55a41d..de83e756c9 100644 --- a/src/include/switch_caller.h +++ b/src/include/switch_caller.h @@ -56,10 +56,9 @@ #include SWITCH_BEGIN_EXTERN_C - /*! \brief Call Specific Data */ -struct switch_caller_profile { + struct switch_caller_profile { /*! The Call's User Name */ char *username; /*! The name of the dialplan */ @@ -129,9 +128,7 @@ struct switch_caller_extension { \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 - ); + char *extension_name, char *extension_number); /*! \brief Add an application (instruction) to the given extension @@ -142,8 +139,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_caller_extension_t *caller_extension, - char *application_name, - char *extra_data); + char *application_name, char *extra_data); /*! @@ -188,9 +184,9 @@ SWITCH_DECLARE(switch_caller_profile_t *) switch_caller_profile_new(switch_memor \param session session associated with the profile (bound by scope) \param tocopy the existing profile */ - + SWITCH_DECLARE(switch_caller_profile_t *) switch_caller_profile_clone(switch_core_session_t *session, - switch_caller_profile_t *tocopy); + switch_caller_profile_t *tocopy); /*! \brief Add headers to an existing event in regards to a specific profile @@ -199,14 +195,12 @@ SWITCH_DECLARE(switch_caller_profile_t *) switch_caller_profile_clone(switch_cor \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, char *prefix, + switch_event_t *event); SWITCH_END_EXTERN_C - /** @} */ - #endif - /* For Emacs: * Local Variables: * mode:c diff --git a/src/include/switch_channel.h b/src/include/switch_channel.h index 49b563134c..0d892f7dc4 100644 --- a/src/include/switch_channel.h +++ b/src/include/switch_channel.h @@ -40,9 +40,7 @@ #include -SWITCH_BEGIN_EXTERN_C - -struct switch_channel_timetable { +SWITCH_BEGIN_EXTERN_C struct switch_channel_timetable { switch_time_t created; switch_time_t answered; switch_time_t hungup; @@ -76,17 +74,16 @@ SWITCH_DECLARE(uint8_t) switch_channel_ready(switch_channel_t *channel); SWITCH_DECLARE(switch_channel_state_t) switch_channel_perform_set_state(switch_channel_t *channel, - const char *file, - const char *func, - int line, - switch_channel_state_t state); + const char *file, + const char *func, + int line, switch_channel_state_t state); /*! \brief Set the current state of a channel \param channel channel to set state of \param state new state \return current state of channel after application of new state -*/ +*/ #define switch_channel_set_state(channel, state) switch_channel_perform_set_state(channel, __FILE__, __SWITCH_FUNC__, __LINE__, state) /*! @@ -133,9 +130,8 @@ SWITCH_DECLARE(switch_status_t) switch_channel_alloc(switch_channel_t **channel, \param flags the initial channel flags */ SWITCH_DECLARE(switch_status_t) switch_channel_init(switch_channel_t *channel, - switch_core_session_t *session, - switch_channel_state_t state, - uint32_t flags); + switch_core_session_t *session, + switch_channel_state_t state, uint32_t flags); /*! \brief Fire A presence event for the channel @@ -156,7 +152,8 @@ SWITCH_DECLARE(void) switch_channel_uninit(switch_channel_t *channel); \param channel channel to assign the profile to \param caller_profile the profile to assign */ -SWITCH_DECLARE(void) switch_channel_set_caller_profile(switch_channel_t *channel, switch_caller_profile_t *caller_profile); +SWITCH_DECLARE(void) switch_channel_set_caller_profile(switch_channel_t *channel, + switch_caller_profile_t *caller_profile); /*! \brief Retrive the given channel's caller profile @@ -170,7 +167,8 @@ SWITCH_DECLARE(switch_caller_profile_t *) switch_channel_get_caller_profile(swit \param channel channel to assign the profile to \param caller_profile the profile to assign */ -SWITCH_DECLARE(void) switch_channel_set_originator_caller_profile(switch_channel_t *channel, switch_caller_profile_t *caller_profile); +SWITCH_DECLARE(void) switch_channel_set_originator_caller_profile(switch_channel_t *channel, + switch_caller_profile_t *caller_profile); /*! \brief Retrive the given channel's originator caller profile @@ -184,7 +182,8 @@ SWITCH_DECLARE(switch_caller_profile_t *) switch_channel_get_originator_caller_p \param channel channel to assign the profile to \param caller_profile the profile to assign */ -SWITCH_DECLARE(void) switch_channel_set_originatee_caller_profile(switch_channel_t *channel, switch_caller_profile_t *caller_profile); +SWITCH_DECLARE(void) switch_channel_set_originatee_caller_profile(switch_channel_t *channel, + switch_caller_profile_t *caller_profile); /*! \brief Retrive the given channel's originatee caller profile @@ -208,7 +207,8 @@ SWITCH_DECLARE(char *) switch_channel_get_uuid(switch_channel_t *channel); \param value the vaule of the variable \returns SWITCH_STATUS_SUCCESS if successful */ -SWITCH_DECLARE(switch_status_t) switch_channel_set_variable(switch_channel_t *channel, const char *varname, const char *value); +SWITCH_DECLARE(switch_status_t) switch_channel_set_variable(switch_channel_t *channel, const char *varname, + const char *value); /*! \brief Set a variable on a given channel, without duplicating the value from the session pool. @@ -217,7 +217,8 @@ SWITCH_DECLARE(switch_status_t) switch_channel_set_variable(switch_channel_t *ch \param value the vaule of the variable (MUST BE ALLOCATED FROM THE SESSION POOL ALREADY) \returns SWITCH_STATUS_SUCCESS if successful */ -SWITCH_DECLARE(switch_status_t) switch_channel_set_variable_nodup(switch_channel_t *channel, const char *varname, char *value); +SWITCH_DECLARE(switch_status_t) switch_channel_set_variable_nodup(switch_channel_t *channel, const char *varname, + char *value); /*! \brief Retrieve a variable from a given channel @@ -234,14 +235,16 @@ SWITCH_DECLARE(char *) switch_channel_get_variable(switch_channel_t *channel, ch * pool is NULL, then an internal, non-thread-safe iterator is used. * @remark Use switch_hash_next and switch_hash_this with this function to iterate all the channel variables */ -SWITCH_DECLARE(switch_hash_index_t *) switch_channel_variable_first(switch_channel_t *channel, switch_memory_pool_t *pool); +SWITCH_DECLARE(switch_hash_index_t *) switch_channel_variable_first(switch_channel_t *channel, + switch_memory_pool_t *pool); /*! \brief Assign a caller extension to a given channel \param channel channel to assign extension to \param caller_extension extension to assign */ -SWITCH_DECLARE(void) switch_channel_set_caller_extension(switch_channel_t *channel, switch_caller_extension_t *caller_extension); +SWITCH_DECLARE(void) switch_channel_set_caller_extension(switch_channel_t *channel, + switch_caller_extension_t *caller_extension); /*! \brief Retrieve caller extension from a given channel @@ -280,14 +283,10 @@ SWITCH_DECLARE(void) switch_channel_set_state_flag(switch_channel_t *channel, sw SWITCH_DECLARE(void) switch_channel_clear_flag(switch_channel_t *channel, switch_channel_flag_t flags); SWITCH_DECLARE(switch_status_t) switch_channel_perform_answer(switch_channel_t *channel, - const char *file, - const char *func, - int line); + const char *file, const char *func, int line); SWITCH_DECLARE(switch_status_t) switch_channel_perform_mark_answered(switch_channel_t *channel, - const char *file, - const char *func, - int line); + const char *file, const char *func, int line); /*! \brief Answer a channel (initiate/acknowledge a successful connection) @@ -311,9 +310,7 @@ SWITCH_DECLARE(switch_status_t) switch_channel_perform_mark_answered(switch_chan #define switch_channel_mark_pre_answered(channel) switch_channel_perform_mark_pre_answered(channel, __FILE__, __SWITCH_FUNC__, __LINE__) SWITCH_DECLARE(switch_status_t) switch_channel_perform_ring_ready(switch_channel_t *channel, - const char *file, - const char *func, - int line); + const char *file, const char *func, int line); /*! \brief Send Ringing message to a channel \param channel channel to ring @@ -323,32 +320,26 @@ SWITCH_DECLARE(switch_status_t) switch_channel_perform_ring_ready(switch_channel SWITCH_DECLARE(switch_status_t) switch_channel_perform_pre_answer(switch_channel_t *channel, - const char *file, - const char *func, - int line); + const char *file, const char *func, int line); SWITCH_DECLARE(switch_status_t) switch_channel_perform_mark_pre_answered(switch_channel_t *channel, - const char *file, - const char *func, - int line); + const char *file, const char *func, int line); SWITCH_DECLARE(switch_status_t) switch_channel_perform_mark_ring_ready(switch_channel_t *channel, - const char *file, - const char *func, - int line); + const char *file, const char *func, int line); /*! \brief Indicate progress on a channel to attempt early media \param channel channel to pre-answer \return SWITCH_STATUS_SUCCESS -*/ +*/ #define switch_channel_pre_answer(channel) switch_channel_perform_pre_answer(channel, __FILE__, __SWITCH_FUNC__, __LINE__) /*! \brief Indicate a channel is ready to provide ringback \param channel channel \return SWITCH_STATUS_SUCCESS -*/ +*/ #define switch_channel_mark_ring_ready(channel) switch_channel_perform_mark_ring_ready(channel, __FILE__, __SWITCH_FUNC__, __LINE__) /*! @@ -357,14 +348,16 @@ SWITCH_DECLARE(switch_status_t) switch_channel_perform_mark_ring_ready(switch_ch \param state_handler table of state handler functions \return the index number/priority of the table negative value indicates failure */ -SWITCH_DECLARE(int) switch_channel_add_state_handler(switch_channel_t *channel, const switch_state_handler_table_t *state_handler); +SWITCH_DECLARE(int) switch_channel_add_state_handler(switch_channel_t *channel, + const switch_state_handler_table_t *state_handler); /*! \brief clear a state handler table from a given channel \param channel channel from which to clear the state handler table \param state_handler table of state handler functions */ -SWITCH_DECLARE(void) switch_channel_clear_state_handler(switch_channel_t *channel, const switch_state_handler_table_t *state_handler); +SWITCH_DECLARE(void) switch_channel_clear_state_handler(switch_channel_t *channel, + const switch_state_handler_table_t *state_handler); /*! \brief Retrieve an state handler tablefrom a given channel at given index level @@ -372,7 +365,8 @@ SWITCH_DECLARE(void) switch_channel_clear_state_handler(switch_channel_t *channe \param index the index of the state handler table (start from 0) \return given channel's state handler table at given index or NULL if requested index does not exist. */ -SWITCH_DECLARE(const switch_state_handler_table_t *) switch_channel_get_state_handler(switch_channel_t *channel, int index); +SWITCH_DECLARE(const switch_state_handler_table_t *) switch_channel_get_state_handler(switch_channel_t *channel, + int index); /*! \brief Set private data on channel @@ -407,11 +401,10 @@ SWITCH_DECLARE(switch_status_t) switch_channel_set_name(switch_channel_t *channe SWITCH_DECLARE(char *) switch_channel_get_name(switch_channel_t *channel); -SWITCH_DECLARE(switch_channel_state_t) switch_channel_perform_hangup(switch_channel_t *channel, - const char *file, - const char *func, - int line, - switch_call_cause_t hangup_cause); +SWITCH_DECLARE(switch_channel_state_t) switch_channel_perform_hangup(switch_channel_t *channel, + const char *file, + const char *func, + int line, switch_call_cause_t hangup_cause); /*! \brief Hangup a channel flagging it's state machine to end @@ -478,9 +471,7 @@ SWITCH_DECLARE(char *) switch_channel_expand_variables(switch_channel_t *channel /** @} */ SWITCH_END_EXTERN_C - #endif - /* For Emacs: * Local Variables: * mode:c diff --git a/src/include/switch_config.h b/src/include/switch_config.h index bb4fddd214..66f383ee70 100644 --- a/src/include/switch_config.h +++ b/src/include/switch_config.h @@ -58,24 +58,22 @@ #include -SWITCH_BEGIN_EXTERN_C - -typedef struct switch_config switch_config_t; +SWITCH_BEGIN_EXTERN_C typedef struct switch_config switch_config_t; /*! \brief A simple file handle representing an open configuration file **/ struct switch_config { /*! FILE stream buffer to the opened file */ - FILE *file; + FILE *file; /*! path to the file */ - char *path; + char *path; /*! current category */ - char category[256]; + char category[256]; /*! current section */ - char section[256]; + char section[256]; /*! buffer of current line being read */ - char buf[1024]; + char buf[1024]; /*! current line number in file */ - int lineno; + int lineno; /*! current category number in file */ int catno; /*! current section number in file */ @@ -107,11 +105,8 @@ SWITCH_DECLARE(void) switch_config_close_file(switch_config_t *cfg); SWITCH_DECLARE(int) switch_config_next_pair(switch_config_t *cfg, char **var, char **val); SWITCH_END_EXTERN_C - /** @} */ - #endif - /* For Emacs: * Local Variables: * mode:c diff --git a/src/include/switch_console.h b/src/include/switch_console.h index d712c269a8..bea024b776 100644 --- a/src/include/switch_console.h +++ b/src/include/switch_console.h @@ -51,9 +51,6 @@ SWITCH_BEGIN_EXTERN_C s.alloc_len = SWITCH_CMD_CHUNK_LEN;\ s.alloc_chunk = SWITCH_CMD_CHUNK_LEN;\ } - - - /*! \brief A simple comand loop that reads input from the terminal */ @@ -62,16 +59,16 @@ SWITCH_DECLARE(void) switch_console_loop(void); /*! \brief A method akin to printf that allows you to redirect output to a specific console "channel" */ -SWITCH_DECLARE(void) switch_console_printf(switch_text_channel_t channel, const char *file, const char *func, int line, const char *fmt, ...) PRINTF_FUNCTION(5,6); +SWITCH_DECLARE(void) switch_console_printf(switch_text_channel_t channel, const char *file, const char *func, int line, + const char *fmt, ...) PRINTF_FUNCTION(5, 6); /*! \brief A method akin to printf for dealing with api streams */ -SWITCH_DECLARE(switch_status_t) switch_console_stream_write(switch_stream_handle_t *handle, const char *fmt, ...) PRINTF_FUNCTION(2,3); +SWITCH_DECLARE(switch_status_t) switch_console_stream_write(switch_stream_handle_t *handle, const char *fmt, + ...) PRINTF_FUNCTION(2, 3); SWITCH_END_EXTERN_C - #endif - /* For Emacs: * Local Variables: * mode:c diff --git a/src/include/switch_core.h b/src/include/switch_core.h index 9beafae833..40969da06f 100644 --- a/src/include/switch_core.h +++ b/src/include/switch_core.h @@ -41,43 +41,41 @@ #include SWITCH_BEGIN_EXTERN_C - #define SWITCH_MAX_CORE_THREAD_SESSION_OBJS 128 #define SWITCH_MAX_STREAMS 128 - -struct switch_core_time_duration { - uint32_t mms; - uint32_t ms; - uint32_t sec; - uint32_t min; - uint32_t hr; + struct switch_core_time_duration { + uint32_t mms; + uint32_t ms; + uint32_t sec; + uint32_t min; + uint32_t hr; uint32_t day; uint32_t yr; }; /*! \brief A message object designed to allow unlike technologies to exchange data */ struct switch_core_session_message { - /*! uuid of the sender (for replies)*/ + /*! uuid of the sender (for replies) */ char *from; /*! enumeration of the type of message */ switch_core_session_message_types_t message_id; - /*! optional numeric arg*/ + /*! optional numeric arg */ int numeric_arg; - /*! optional string arg*/ + /*! optional string arg */ char *string_arg; - /*! optional string arg*/ + /*! optional string arg */ switch_size_t string_arg_size; /*! optional arbitrary pointer arg */ void *pointer_arg; /*! optional arbitrary pointer arg's size */ switch_size_t pointer_arg_size; - /*! optional numeric reply*/ + /*! optional numeric reply */ int numeric_reply; - /*! optional string reply*/ + /*! optional string reply */ char *string_reply; - /*! optional string reply*/ + /*! optional string reply */ switch_size_t string_reply_size; /*! optional arbitrary pointer reply */ void *pointer_reply; @@ -96,7 +94,7 @@ struct switch_core_thread_session { /*! array of void pointers to pass mutiple data objects */ void *objs[SWITCH_MAX_CORE_THREAD_SESSION_OBJS]; /*! a pointer to a memory pool if the thread has it's own pool */ - switch_input_callback_function_t input_callback; + switch_input_callback_function_t input_callback; switch_memory_pool_t *pool; }; @@ -104,16 +102,6 @@ struct switch_core_session; struct switch_core_runtime; struct switch_core_port_allocator; -struct switch_core_scheduler_task { - time_t created; - time_t runtime; - uint32_t cmd_id; - char *group; - void *cmd_arg; - uint32_t task_id; -}; - - /*! \defgroup core1 Core Library \ingroup FREESWITCH @@ -125,47 +113,6 @@ struct switch_core_scheduler_task { ///\{ -///\defgroup sched1 Scheduler -///\ingroup core1 -///\{ - - -/*! - \brief Schedule a task in the future - \param runtime the time in epoch seconds to execute the task. - \param func the callback function to execute when the task is executed. - \param desc an arbitrary description of the task. - \param group a group id tag to link multiple tasks to a single entity. - \param cmd_id an arbitrary index number be used in the callback. - \param cmd_arg user data to be passed to the callback. - \param flags flags to alter behaviour - \return the id of the task -*/ -SWITCH_DECLARE(uint32_t) switch_core_scheduler_add_task(time_t task_runtime, - switch_core_scheduler_func_t func, - char *desc, - char *group, - uint32_t cmd_id, - void *cmd_arg, - switch_scheduler_flag_t flags); - -/*! - \brief Delete a scheduled task - \param task_id the id of the task - \return SWITCH_STATUS_SUCCESS if the task was deleted. -*/ -SWITCH_DECLARE(switch_status_t) switch_core_scheduler_del_task_id(uint32_t task_id); - -/*! - \brief Delete a scheduled task based on the group name - \param group the group name - \return SWITCH_STATUS_SUCCESS if any tasks were deleted -*/ -SWITCH_DECLARE(switch_status_t) switch_core_scheduler_del_task_group(char *group); - - -///\} - /*! \brief Add a media bug to the session \param session the session to add the bug to @@ -178,8 +125,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_scheduler_del_task_group(char *group SWITCH_DECLARE(switch_status_t) switch_core_media_bug_add(switch_core_session_t *session, switch_media_bug_callback_t callback, void *user_data, - switch_media_bug_flag_t flags, - switch_media_bug_t **new_bug); + switch_media_bug_flag_t flags, switch_media_bug_t **new_bug); /*! \brief Obtain private data from a media bug \param bug the bug to get the data from @@ -208,6 +154,12 @@ SWITCH_DECLARE(void) switch_core_media_bug_set_replace_frame(switch_media_bug_t */ SWITCH_DECLARE(switch_status_t) switch_core_media_bug_remove(switch_core_session_t *session, switch_media_bug_t **bug); +/*! + \brief Close and destroy a media bug + \param bug bug to remove + \return SWITCH_STATUS_SUCCESS if the operation was a success +*/ +SWITCH_DECLARE(switch_status_t) switch_core_media_bug_close(switch_media_bug_t **bug); /*! \brief Remove all media bugs from the session \param session the session to remove the bugs from @@ -296,9 +248,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_destroy(void); #ifdef SWITCH_DEBUG_RWLOCKS SWITCH_DECLARE(switch_status_t) switch_core_session_perform_read_lock(switch_core_session_t *session, - const char *file, - const char *func, - int line); + const char *file, const char *func, int line); #endif /*! @@ -315,9 +265,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_lock(switch_core_sessio #ifdef SWITCH_DEBUG_RWLOCKS SWITCH_DECLARE(void) switch_core_session_perform_write_lock(switch_core_session_t *session, - const char *file, - const char *func, - int line); + const char *file, const char *func, int line); #endif /*! @@ -332,9 +280,7 @@ SWITCH_DECLARE(void) switch_core_session_write_lock(switch_core_session_t *sessi #ifdef SWITCH_DEBUG_RWLOCKS SWITCH_DECLARE(void) switch_core_session_perform_rwunlock(switch_core_session_t *session, - const char *file, - const char *func, - int line); + const char *file, const char *func, int line); #endif /*! @@ -479,7 +425,8 @@ SWITCH_DECLARE(switch_memory_pool_t *) switch_core_session_get_pool(switch_core_ \param pool the pool to use for the allocation (a new one will be used if NULL) \return the newly created session */ -SWITCH_DECLARE(switch_core_session_t *) switch_core_session_request(const switch_endpoint_interface_t *endpoint_interface, switch_memory_pool_t **pool); +SWITCH_DECLARE(switch_core_session_t *) switch_core_session_request(const switch_endpoint_interface_t + *endpoint_interface, switch_memory_pool_t **pool); /*! \brief Destroy a session and return the memory pool to the core @@ -500,7 +447,8 @@ SWITCH_DECLARE(uint32_t) switch_core_session_count(void); \param pool the pool to use \return the newly created session */ -SWITCH_DECLARE(switch_core_session_t *) switch_core_session_request_by_name(char *endpoint_name, switch_memory_pool_t **pool); +SWITCH_DECLARE(switch_core_session_t *) switch_core_session_request_by_name(char *endpoint_name, + switch_memory_pool_t **pool); /*! \brief Launch the session thread (state machine) on a given session @@ -535,9 +483,8 @@ SWITCH_DECLARE(char *) switch_core_get_uuid(void); #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); + const char *file, + const char *func, int line); #endif /*! @@ -578,7 +525,8 @@ SWITCH_DECLARE(void) switch_core_session_hupall(switch_call_cause_t cause); \param message the switch_core_session_message_t object to send \return the status returned by the message handler */ -SWITCH_DECLARE (switch_status_t) switch_core_session_message_send(char *uuid_str, switch_core_session_message_t *message); +SWITCH_DECLARE(switch_status_t) switch_core_session_message_send(char *uuid_str, + switch_core_session_message_t *message); /*! \brief Queue a message on a session @@ -586,7 +534,8 @@ SWITCH_DECLARE (switch_status_t) switch_core_session_message_send(char *uuid_str \param message the message to queue \return SWITCH_STATUS_SUCCESS if the message was queued */ -SWITCH_DECLARE(switch_status_t) switch_core_session_queue_message(switch_core_session_t *session, switch_core_session_message_t *message); +SWITCH_DECLARE(switch_status_t) switch_core_session_queue_message(switch_core_session_t *session, + switch_core_session_message_t *message); /*! \brief Queue an indication message on a session @@ -594,7 +543,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_queue_message(switch_core_se \param indication the indication message to queue \return SWITCH_STATUS_SUCCESS if the message was queued */ -SWITCH_DECLARE(switch_status_t) switch_core_session_queue_indication(switch_core_session_t *session, switch_core_session_message_types_t indication); +SWITCH_DECLARE(switch_status_t) switch_core_session_queue_indication(switch_core_session_t *session, + switch_core_session_message_types_t indication); /*! \brief DE-Queue an message on a given session @@ -602,7 +552,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_queue_indication(switch_core \param message the de-queued message \return the SWITCH_STATUS_SUCCESS if the message was de-queued */ -SWITCH_DECLARE(switch_status_t) switch_core_session_dequeue_message(switch_core_session_t *session, switch_core_session_message_t **message); +SWITCH_DECLARE(switch_status_t) switch_core_session_dequeue_message(switch_core_session_t *session, + switch_core_session_message_t **message); /*! \brief Flush a message queue on a given session @@ -625,7 +576,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_event_send(char *uuid_str, s \param event the event to receive \return the status returned by the handler */ -SWITCH_DECLARE(switch_status_t) switch_core_session_receive_event(switch_core_session_t *session, switch_event_t **event); +SWITCH_DECLARE(switch_status_t) switch_core_session_receive_event(switch_core_session_t *session, + switch_event_t **event); /*! \brief Retrieve private user data from a session @@ -671,7 +623,8 @@ SWITCH_DECLARE(int) switch_core_session_get_stream_count(switch_core_session_t * \param func a function to execute in the thread \param obj an arguement */ -SWITCH_DECLARE(void) switch_core_session_launch_thread(switch_core_session_t *session, void *(*func)(switch_thread_t *, void *), void *obj); +SWITCH_DECLARE(void) switch_core_session_launch_thread(switch_core_session_t *session, + void *(*func) (switch_thread_t *, void *), void *obj); /*! \brief Signal a thread using a thread session to terminate @@ -685,7 +638,8 @@ SWITCH_DECLARE(void) switch_core_thread_session_end(switch_core_thread_session_t \param stream_id which logical media channel to use \param thread_session the thread_session to use */ -SWITCH_DECLARE(void) switch_core_service_session(switch_core_session_t *session, switch_core_thread_session_t *thread_session, int stream_id); +SWITCH_DECLARE(void) switch_core_service_session(switch_core_session_t *session, + switch_core_thread_session_t *thread_session, int stream_id); /*! \brief Request an outgoing session spawned from an existing session using a desired endpoing module @@ -715,7 +669,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_answer_channel(switch_core_s \param message the message to recieve \return the status returned by the message handler */ -SWITCH_DECLARE(switch_status_t) switch_core_session_receive_message(switch_core_session_t *session, switch_core_session_message_t *message); +SWITCH_DECLARE(switch_status_t) switch_core_session_receive_message(switch_core_session_t *session, + switch_core_session_message_t *message); /*! \brief Queue an event on a given session @@ -739,7 +694,8 @@ SWITCH_DECLARE(int32_t) switch_core_session_event_count(switch_core_session_t *s \param event the de-queued event \return the SWITCH_STATUS_SUCCESS if the event was de-queued */ -SWITCH_DECLARE(switch_status_t) switch_core_session_dequeue_event(switch_core_session_t *session, switch_event_t **event); +SWITCH_DECLARE(switch_status_t) switch_core_session_dequeue_event(switch_core_session_t *session, + switch_event_t **event); /*! \brief Queue a private event on a given session @@ -747,7 +703,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_dequeue_event(switch_core_se \param event the event to queue \return the status returned by the message handler */ -SWITCH_DECLARE(switch_status_t) switch_core_session_queue_private_event(switch_core_session_t *session, switch_event_t **event); +SWITCH_DECLARE(switch_status_t) switch_core_session_queue_private_event(switch_core_session_t *session, + switch_event_t **event); /*! @@ -763,7 +720,8 @@ SWITCH_DECLARE(int32_t) switch_core_session_private_event_count(switch_core_sess \param event the de-queued event \return the SWITCH_STATUS_SUCCESS if the event was de-queued */ -SWITCH_DECLARE(switch_status_t) switch_core_session_dequeue_private_event(switch_core_session_t *session, switch_event_t **event); +SWITCH_DECLARE(switch_status_t) switch_core_session_dequeue_private_event(switch_core_session_t *session, + switch_event_t **event); /*! @@ -774,7 +732,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_dequeue_private_event(switch \param stream_id which logical media channel to use \return SWITCH_STATUS_SUCCESS a the frame was read */ -SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_session_t *session, switch_frame_t **frame, int timeout, int stream_id); +SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_session_t *session, switch_frame_t **frame, + int timeout, int stream_id); /*! \brief Reset the buffers and resampler on a session @@ -790,14 +749,14 @@ SWITCH_DECLARE(void) switch_core_session_reset(switch_core_session_t *session); \param stream_id which logical media channel to use \return SWITCH_STATUS_SUCCESS a the frame was written */ -SWITCH_DECLARE(switch_status_t) switch_core_session_write_frame(switch_core_session_t *session, switch_frame_t *frame, int timeout, int stream_id); +SWITCH_DECLARE(switch_status_t) switch_core_session_write_frame(switch_core_session_t *session, switch_frame_t *frame, + int timeout, int stream_id); -SWITCH_DECLARE(switch_status_t) switch_core_session_perform_kill_channel(switch_core_session_t *session, - const char *file, - const char *func, - int line, - switch_signal_t sig); +SWITCH_DECLARE(switch_status_t) switch_core_session_perform_kill_channel(switch_core_session_t *session, + const char *file, + const char *func, + int line, switch_signal_t sig); /*! \brief Send a signal to a channel \param session session to send signal to @@ -813,7 +772,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_perform_kill_channel(switch_ \param stream_id which logical media channel to use \return SWITCH_STATUS_SUCCESS if data is available for read within timeframe specified */ -SWITCH_DECLARE(switch_status_t) switch_core_session_waitfor_read(switch_core_session_t *session, int timeout, int stream_id); +SWITCH_DECLARE(switch_status_t) switch_core_session_waitfor_read(switch_core_session_t *session, int timeout, + int stream_id); /*! \brief Wait for a session to be ready for output @@ -822,7 +782,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_waitfor_read(switch_core_ses \param stream_id which logical media channel to use \return SWITCH_STATUS_SUCCESS if the session is available for write within timeframe specified */ -SWITCH_DECLARE(switch_status_t) switch_core_session_waitfor_write(switch_core_session_t *session, int timeout, int stream_id); +SWITCH_DECLARE(switch_status_t) switch_core_session_waitfor_write(switch_core_session_t *session, int timeout, + int stream_id); /*! \brief Send DTMF to a session @@ -832,91 +793,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_waitfor_write(switch_core_se */ SWITCH_DECLARE(switch_status_t) switch_core_session_send_dtmf(switch_core_session_t *session, char *dtmf); -/*! - \brief Add an event hook to be executed when a session requests an outgoing extension - \param session session to bind hook to - \param outgoing_channel hook to bind - \return SWITCH_STATUS_SUCCESS on suceess -*/ -SWITCH_DECLARE(switch_status_t) switch_core_session_add_event_hook_outgoing(switch_core_session_t *session, switch_outgoing_channel_hook_t outgoing_channel); ///\} -///\defgroup shooks Session Hook Callbacks -///\ingroup core1 -///\{ -/*! - \brief Add an event hook to be executed when a session answers a channel - \param session session to bind hook to - \param answer_channel hook to bind - \return SWITCH_STATUS_SUCCESS on suceess -*/ -SWITCH_DECLARE(switch_status_t) switch_core_session_add_event_hook_answer_channel(switch_core_session_t *session, switch_answer_channel_hook_t answer_channel); - -/*! - \brief Add an event hook to be executed when a session sends a message - \param session session to bind hook to - \param receive_message hook to bind - \return SWITCH_STATUS_SUCCESS on suceess -*/ -SWITCH_DECLARE(switch_status_t) switch_core_session_add_event_hook_receive_message(switch_core_session_t *session, switch_receive_message_hook_t receive_message); - -/*! - \brief Add an event hook to be executed when a session reads a frame - \param session session to bind hook to - \param read_frame hook to bind - \return SWITCH_STATUS_SUCCESS on suceess -*/ -SWITCH_DECLARE(switch_status_t) switch_core_session_add_event_hook_read_frame(switch_core_session_t *session, switch_read_frame_hook_t read_frame); - -/*! - \brief Add an event hook to be executed when a session writes a frame - \param session session to bind hook to - \param write_frame hook to bind - \return SWITCH_STATUS_SUCCESS on suceess -*/ -SWITCH_DECLARE(switch_status_t) switch_core_session_add_event_hook_write_frame(switch_core_session_t *session, switch_write_frame_hook_t write_frame); - -/*! - \brief Add an event hook to be executed when a session kills a channel - \param session session to bind hook to - \param kill_channel hook to bind - \return SWITCH_STATUS_SUCCESS on suceess -*/ -SWITCH_DECLARE(switch_status_t) switch_core_session_add_event_hook_kill_channel(switch_core_session_t *session, switch_kill_channel_hook_t kill_channel); - -/*! - \brief Add an event hook to be executed when a session waits for a read event - \param session session to bind hook to - \param waitfor_read hook to bind - \return SWITCH_STATUS_SUCCESS on suceess -*/ -SWITCH_DECLARE(switch_status_t) switch_core_session_add_event_hook_waitfor_read(switch_core_session_t *session, switch_waitfor_read_hook_t waitfor_read); - -/*! - \brief Add an event hook to be executed when a session waits for a write event - \param session session to bind hook to - \param waitfor_write hook to bind - \return SWITCH_STATUS_SUCCESS on suceess -*/ -SWITCH_DECLARE(switch_status_t) switch_core_session_add_event_hook_waitfor_write(switch_core_session_t *session, switch_waitfor_write_hook_t waitfor_write); - -/*! - \brief Add an event hook to be executed when a session sends dtmf - \param session session to bind hook to - \param send_dtmf hook to bind - \return SWITCH_STATUS_SUCCESS on suceess -*/ -SWITCH_DECLARE(switch_status_t) switch_core_session_add_event_hook_send_dtmf(switch_core_session_t *session, switch_send_dtmf_hook_t send_dtmf); - -/*! - \brief Add an event hook to be executed when a session receives a state change signal - \param session session to bind hook to - \param state_change hook to bind - \return SWITCH_STATUS_SUCCESS on suceess -*/ -SWITCH_DECLARE(switch_status_t) switch_core_session_add_event_hook_state_change(switch_core_session_t *session, - switch_answer_channel_hook_t state_change); -///\} ///\defgroup hashf Hash Functions ///\ingroup core1 @@ -984,7 +862,8 @@ SWITCH_DECLARE(void *) switch_core_hash_find(switch_hash_t *hash, const char *ke \param pool the memory pool to use for allocation \return */ -SWITCH_DECLARE(switch_status_t) switch_core_timer_init(switch_timer_t *timer, char *timer_name, int interval, int samples, switch_memory_pool_t *pool); +SWITCH_DECLARE(switch_status_t) switch_core_timer_init(switch_timer_t *timer, char *timer_name, int interval, + int samples, switch_memory_pool_t *pool); /*! \brief Wait for one cycle on an existing timer @@ -1031,14 +910,14 @@ SWITCH_DECLARE(switch_status_t) switch_core_timer_destroy(switch_timer_t *timer) \param pool the memory pool to use \return SWITCH_STATUS_SUCCESS if the handle is allocated */ -SWITCH_DECLARE(switch_status_t) switch_core_codec_init(switch_codec_t *codec, - char *codec_name, +SWITCH_DECLARE(switch_status_t) switch_core_codec_init(switch_codec_t *codec, + char *codec_name, char *fmtp, - uint32_t rate, - int ms, - int channels, + uint32_t rate, + int ms, + int channels, uint32_t flags, - const switch_codec_settings_t *codec_settings, + const switch_codec_settings_t *codec_settings, switch_memory_pool_t *pool); /*! @@ -1056,14 +935,13 @@ SWITCH_DECLARE(switch_status_t) switch_core_codec_init(switch_codec_t *codec, \note encoded_data_len will be rewritten to the in-use size of encoded_data */ SWITCH_DECLARE(switch_status_t) switch_core_codec_encode(switch_codec_t *codec, - switch_codec_t *other_codec, - void *decoded_data, - uint32_t decoded_data_len, - uint32_t decoded_rate, - void *encoded_data, - uint32_t *encoded_data_len, - uint32_t *encoded_rate, - unsigned int *flag); + switch_codec_t *other_codec, + void *decoded_data, + uint32_t decoded_data_len, + uint32_t decoded_rate, + void *encoded_data, + uint32_t * encoded_data_len, + uint32_t * encoded_rate, unsigned int *flag); /*! \brief Decode data using a codec handle @@ -1080,14 +958,13 @@ SWITCH_DECLARE(switch_status_t) switch_core_codec_encode(switch_codec_t *codec, \note decoded_data_len will be rewritten to the in-use size of decoded_data */ SWITCH_DECLARE(switch_status_t) switch_core_codec_decode(switch_codec_t *codec, - switch_codec_t *other_codec, - void *encoded_data, - uint32_t encoded_data_len, - uint32_t encoded_rate, - void *decoded_data, - uint32_t *decoded_data_len, - uint32_t *decoded_rate, - unsigned int *flag); + switch_codec_t *other_codec, + void *encoded_data, + uint32_t encoded_data_len, + uint32_t encoded_rate, + void *decoded_data, + uint32_t * decoded_data_len, + uint32_t * decoded_rate, unsigned int *flag); /*! \brief Destroy an initalized codec handle @@ -1102,7 +979,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_codec_destroy(switch_codec_t *codec) \param codec the codec to add \return SWITCH_STATUS_SUCCESS if successful */ -SWITCH_DECLARE(switch_status_t) switch_core_session_set_read_codec(switch_core_session_t *session, switch_codec_t *codec); +SWITCH_DECLARE(switch_status_t) switch_core_session_set_read_codec(switch_core_session_t *session, + switch_codec_t *codec); /*! \brief Retrieve the read codec from a given session @@ -1117,7 +995,8 @@ SWITCH_DECLARE(switch_codec_t *) switch_core_session_get_read_codec(switch_core_ \param codec the codec to add \return SWITCH_STATUS_SUCCESS if successful */ -SWITCH_DECLARE(switch_status_t) switch_core_session_set_write_codec(switch_core_session_t *session, switch_codec_t *codec); +SWITCH_DECLARE(switch_status_t) switch_core_session_set_write_codec(switch_core_session_t *session, + switch_codec_t *codec); /*! \brief Retrieve the write codec from a given session @@ -1177,12 +1056,10 @@ SWITCH_DECLARE(void) switch_core_db_test_reactive(switch_core_db_t *db, char *te \return SWITCH_STATUS_SUCCESS if the file is opened \note the loadable module used is chosen based on the file extension */ -SWITCH_DECLARE(switch_status_t) switch_core_file_open(switch_file_handle_t *fh, - char *file_path, +SWITCH_DECLARE(switch_status_t) switch_core_file_open(switch_file_handle_t *fh, + char *file_path, uint8_t channels, - uint32_t rate, - unsigned int flags, - switch_memory_pool_t *pool); + uint32_t rate, unsigned int flags, switch_memory_pool_t *pool); /*! \brief Read media from a file handle \param fh the file handle to read from (must be initilized by you memset all 0 for read, fill in channels and rate for write) @@ -1209,7 +1086,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_file_write(switch_file_handle_t *fh, \param whence the indicator (see traditional seek) \return SWITCH_STATUS_SUCCESS with cur_pos adjusted to new position */ -SWITCH_DECLARE(switch_status_t) switch_core_file_seek(switch_file_handle_t *fh, unsigned int *cur_pos, int64_t samples, int whence); +SWITCH_DECLARE(switch_status_t) switch_core_file_seek(switch_file_handle_t *fh, unsigned int *cur_pos, int64_t samples, + int whence); /*! \brief Set metadata to the desired string @@ -1218,7 +1096,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_file_seek(switch_file_handle_t *fh, \param string the string to add \return SWITCH_STATUS_SUCCESS with cur_pos adjusted to new position */ -SWITCH_DECLARE(switch_status_t) switch_core_file_set_string(switch_file_handle_t *fh, switch_audio_col_t col, const char *string); +SWITCH_DECLARE(switch_status_t) switch_core_file_set_string(switch_file_handle_t *fh, switch_audio_col_t col, + const char *string); /*! \brief get metadata of the desired string @@ -1227,7 +1106,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_file_set_string(switch_file_handle_t \param string pointer to the string to fetch \return SWITCH_STATUS_SUCCESS with cur_pos adjusted to new position */ -SWITCH_DECLARE(switch_status_t) switch_core_file_get_string(switch_file_handle_t *fh, switch_audio_col_t col, const char **string); +SWITCH_DECLARE(switch_status_t) switch_core_file_get_string(switch_file_handle_t *fh, switch_audio_col_t col, + const char **string); /*! @@ -1251,12 +1131,11 @@ SWITCH_DECLARE(switch_status_t) switch_core_file_close(switch_file_handle_t *fh) \param pool the pool to use (NULL for new pool) \return SWITCH_STATUS_SUCCESS if the handle is opened */ -SWITCH_DECLARE(switch_status_t) switch_core_speech_open(switch_speech_handle_t *sh, - char *module_name, - char *voice_name, - unsigned int rate, - switch_speech_flag_t *flags, - switch_memory_pool_t *pool); +SWITCH_DECLARE(switch_status_t) switch_core_speech_open(switch_speech_handle_t *sh, + char *module_name, + char *voice_name, + unsigned int rate, + switch_speech_flag_t *flags, switch_memory_pool_t *pool); /*! \brief Feed text to the TTS module \param sh the speech handle to feed @@ -1264,7 +1143,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_speech_open(switch_speech_handle_t * \param flags flags in/out for fine tuning \return SWITCH_STATUS_SUCCESS with len adjusted to the bytes written if successful */ -SWITCH_DECLARE(switch_status_t) switch_core_speech_feed_tts(switch_speech_handle_t *sh, char *text, switch_speech_flag_t *flags); +SWITCH_DECLARE(switch_status_t) switch_core_speech_feed_tts(switch_speech_handle_t *sh, char *text, + switch_speech_flag_t *flags); /*! \brief Flush TTS audio on a given handle @@ -1305,11 +1185,10 @@ SWITCH_DECLARE(void) switch_core_speech_float_param_tts(switch_speech_handle_t * \param flags flags in/out for fine tuning \return SWITCH_STATUS_SUCCESS with len adjusted to the bytes written if successful */ -SWITCH_DECLARE(switch_status_t) switch_core_speech_read_tts(switch_speech_handle_t *sh, - void *data, - switch_size_t *datalen, - uint32_t *rate, - switch_speech_flag_t *flags); +SWITCH_DECLARE(switch_status_t) switch_core_speech_read_tts(switch_speech_handle_t *sh, + void *data, + switch_size_t *datalen, + uint32_t * rate, switch_speech_flag_t *flags); /*! \brief Close an open speech handle \param sh the speech handle to close @@ -1334,9 +1213,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_asr_open(switch_asr_handle_t *ah, char *module_name, char *codec, int rate, - char *dest, - switch_asr_flag_t *flags, - switch_memory_pool_t *pool); + char *dest, switch_asr_flag_t *flags, switch_memory_pool_t *pool); /*! \brief Close an asr handle @@ -1354,7 +1231,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_asr_close(switch_asr_handle_t *ah, s \param flags flags to influence behaviour \return SWITCH_STATUS_SUCCESS */ -SWITCH_DECLARE(switch_status_t) switch_core_asr_feed(switch_asr_handle_t *ah, void *data, unsigned int len, switch_asr_flag_t *flags); +SWITCH_DECLARE(switch_status_t) switch_core_asr_feed(switch_asr_handle_t *ah, void *data, unsigned int len, + switch_asr_flag_t *flags); /*! \brief Check an asr handle for results @@ -1371,7 +1249,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_asr_check_results(switch_asr_handle_ \param flags flags to influence behaviour \return SWITCH_STATUS_SUCCESS */ -SWITCH_DECLARE(switch_status_t) switch_core_asr_get_results(switch_asr_handle_t *ah, char **xmlstr, switch_asr_flag_t *flags); +SWITCH_DECLARE(switch_status_t) switch_core_asr_get_results(switch_asr_handle_t *ah, char **xmlstr, + switch_asr_flag_t *flags); /*! \brief Load a grammar to an asr handle @@ -1420,12 +1299,10 @@ SWITCH_DECLARE(switch_status_t) switch_core_asr_resume(switch_asr_handle_t *ah); \param pool the pool to use (NULL for new pool) \return SWITCH_STATUS_SUCCESS if the handle is opened */ -SWITCH_DECLARE(switch_status_t) switch_core_directory_open(switch_directory_handle_t *dh, - char *module_name, - char *source, - char *dsn, - char *passwd, - switch_memory_pool_t *pool); +SWITCH_DECLARE(switch_status_t) switch_core_directory_open(switch_directory_handle_t *dh, + char *module_name, + char *source, + char *dsn, char *passwd, switch_memory_pool_t *pool); /*! \brief Query a directory handle @@ -1471,6 +1348,12 @@ SWITCH_DECLARE(switch_status_t) switch_core_directory_close(switch_directory_han */ SWITCH_DECLARE(FILE *) switch_core_data_channel(switch_text_channel_t channel); +/*! + \brief Determines if the core is ready to take calls + \return SWITCH_TRUE or SWITCH_FALSE +*/ +SWITCH_DECLARE(switch_bool_t) switch_core_ready(void); + /*! \brief Execute a management operation. \param relative_oid the relative oid of the operation. @@ -1481,8 +1364,7 @@ SWITCH_DECLARE(FILE *) switch_core_data_channel(switch_text_channel_t channel); */ SWITCH_DECLARE(switch_status_t) switch_core_management_exec(char *relative_oid, switch_management_action_t action, - char *data, - switch_size_t datalen); + char *data, switch_size_t datalen); /*! @@ -1522,7 +1404,7 @@ SWITCH_DECLARE(switch_time_t) switch_core_uptime(void); \param val the command arguement (if needed) \return 0 on success nonzero on error */ -SWITCH_DECLARE(int32_t) switch_core_session_ctl(switch_session_ctl_t cmd, uint32_t *val); +SWITCH_DECLARE(int32_t) switch_core_session_ctl(switch_session_ctl_t cmd, uint32_t * val); /*! \brief Get the output console @@ -1532,7 +1414,8 @@ SWITCH_DECLARE(FILE *) switch_core_get_console(void); /*! \brief Launch a thread */ -SWITCH_DECLARE(void) switch_core_launch_thread(void *(*func)(switch_thread_t *, void*), void *obj, switch_memory_pool_t *pool); +SWITCH_DECLARE(void) switch_core_launch_thread(void *(*func) (switch_thread_t *, void *), void *obj, + switch_memory_pool_t *pool); /*! \brief Initiate Globals @@ -1553,9 +1436,7 @@ SWITCH_DECLARE(uint8_t) switch_core_session_compare(switch_core_session_t *a, sw */ SWITCH_END_EXTERN_C - #endif - /* For Emacs: * Local Variables: * mode:c diff --git a/src/include/switch_core_db.h b/src/include/switch_core_db.h index 063a42b63d..30745a7097 100644 --- a/src/include/switch_core_db.h +++ b/src/include/switch_core_db.h @@ -36,28 +36,24 @@ #define SWITCH_CORE_DB_H SWITCH_BEGIN_EXTERN_C - /** * @defgroup switch_sqlite_top Brought To You By SQLite * @ingroup FREESWITCH * @{ */ - /** * @defgroup switch_core_db Database Routines * @ingroup switch_sqlite_top * @{ */ - /** * Each open database is represented by an instance of the * following opaque structure. */ - -typedef struct sqlite3 switch_core_db_t; + typedef struct sqlite3 switch_core_db_t; typedef struct sqlite3_stmt switch_core_db_stmt_t; -typedef int (*switch_core_db_callback_func_t)(void *pArg, int argc, char **argv, char **columnNames); +typedef int (*switch_core_db_callback_func_t) (void *pArg, int argc, char **argv, char **columnNames); /* ** These are special value for the destructor that is passed in as the @@ -71,7 +67,7 @@ typedef int (*switch_core_db_callback_func_t)(void *pArg, int argc, char **argv, ** The typedef is necessary to work around problems in certain ** C++ compilers. */ -typedef void (*switch_core_db_destructor_type_t)(void*); +typedef void (*switch_core_db_destructor_type_t) (void *); #define SWITCH_CORE_DB_STATIC ((switch_core_db_destructor_type_t)0) #define SWITCH_CORE_DB_TRANSIENT ((switch_core_db_destructor_type_t)-1) @@ -144,14 +140,14 @@ SWITCH_DECLARE(int) switch_core_db_open(const char *filename, switch_core_db_t * * * Return the value as UTF-8 text. */ -SWITCH_DECLARE(const unsigned char *)switch_core_db_column_text(switch_core_db_stmt_t *stmt, int iCol); +SWITCH_DECLARE(const unsigned char *) switch_core_db_column_text(switch_core_db_stmt_t *stmt, int iCol); /** * The first parameter is a compiled SQL statement. This function returns * the column heading for the Nth column of that statement, where N is the * second function parameter. The string returned is UTF-8. */ -SWITCH_DECLARE(const char *)switch_core_db_column_name(switch_core_db_stmt_t *stmt, int N); +SWITCH_DECLARE(const char *) switch_core_db_column_name(switch_core_db_stmt_t *stmt, int N); /** * Return the number of columns in the result set returned by the compiled @@ -168,7 +164,7 @@ SWITCH_DECLARE(int) switch_core_db_column_count(switch_core_db_stmt_t *pStmt); * The string "not an error" is returned when the most recent API call was * successful. */ -SWITCH_DECLARE(const char *)switch_core_db_errmsg(switch_core_db_t *db); +SWITCH_DECLARE(const char *) switch_core_db_errmsg(switch_core_db_t *db); /** * A function to executes one or more statements of SQL. @@ -212,9 +208,7 @@ SWITCH_DECLARE(const char *)switch_core_db_errmsg(switch_core_db_t *db); */ SWITCH_DECLARE(int) switch_core_db_exec(switch_core_db_t *db, const char *sql, - switch_core_db_callback_func_t callback, - void *data, - char **errmsg); + switch_core_db_callback_func_t callback, void *data, char **errmsg); /** * This function is called to delete a compiled @@ -256,9 +250,7 @@ SWITCH_DECLARE(int) switch_core_db_finalize(switch_core_db_stmt_t *pStmt); */ SWITCH_DECLARE(int) switch_core_db_prepare(switch_core_db_t *db, const char *zSql, - int nBytes, - switch_core_db_stmt_t **ppStmt, - const char **pzTail); + int nBytes, switch_core_db_stmt_t **ppStmt, const char **pzTail); /** * After an SQL query has been compiled with a call to either @@ -375,7 +367,8 @@ SWITCH_DECLARE(int) switch_core_db_bind_int64(switch_core_db_stmt_t *pStmt, int * an switch_core_db_prepare() or sqlite3_reset(). Unbound parameterss are * interpreted as NULL. */ -SWITCH_DECLARE(int) switch_core_db_bind_text(switch_core_db_stmt_t *pStmt, int i, const char *zData, int nData, switch_core_db_destructor_type_t xDel); +SWITCH_DECLARE(int) switch_core_db_bind_text(switch_core_db_stmt_t *pStmt, int i, const char *zData, int nData, + switch_core_db_destructor_type_t xDel); /** * In the SQL strings input to switch_core_db_prepare(), @@ -451,14 +444,13 @@ SWITCH_DECLARE(int64_t) switch_core_db_last_insert_rowid(switch_core_db_t *db); * * The return value of this routine is the same as from switch_core_db_exec(). */ -SWITCH_DECLARE(int) switch_core_db_get_table( - switch_core_db_t *db, /* An open database */ - const char *sql, /* SQL to be executed */ - char ***resultp, /* Result written to a char *[] that this points to */ - int *nrow, /* Number of result rows written here */ - int *ncolumn, /* Number of result columns written here */ - char **errmsg /* Error msg written here */ -); +SWITCH_DECLARE(int) switch_core_db_get_table(switch_core_db_t *db, /* An open database */ + const char *sql, /* SQL to be executed */ + char ***resultp, /* Result written to a char *[] that this points to */ + int *nrow, /* Number of result rows written here */ + int *ncolumn, /* Number of result columns written here */ + char **errmsg /* Error msg written here */ + ); /** * Call this routine to free the memory that sqlite3_get_table() allocated. @@ -471,36 +463,36 @@ SWITCH_DECLARE(void) switch_core_db_free_table(char **result); SWITCH_DECLARE(void) switch_core_db_free(char *z); /** Return values for switch_core_db_exec() and switch_core_db_step()*/ -#define SWITCH_CORE_DB_OK 0 /* Successful result */ +#define SWITCH_CORE_DB_OK 0 /* Successful result */ /* beginning-of-error-codes */ -#define SWITCH_CORE_DB_ERROR 1 /* SQL error or missing database */ -#define SWITCH_CORE_DB_INTERNAL 2 /* NOT USED. Internal logic error in SQLite */ -#define SWITCH_CORE_DB_PERM 3 /* Access permission denied */ -#define SWITCH_CORE_DB_ABORT 4 /* Callback routine requested an abort */ -#define SWITCH_CORE_DB_BUSY 5 /* The database file is locked */ -#define SWITCH_CORE_DB_LOCKED 6 /* A table in the database is locked */ -#define SWITCH_CORE_DB_NOMEM 7 /* A malloc() failed */ -#define SWITCH_CORE_DB_READONLY 8 /* Attempt to write a readonly database */ -#define SWITCH_CORE_DB_INTERRUPT 9 /* Operation terminated by switch_core_db_interrupt()*/ -#define SWITCH_CORE_DB_IOERR 10 /* Some kind of disk I/O error occurred */ -#define SWITCH_CORE_DB_CORRUPT 11 /* The database disk image is malformed */ -#define SWITCH_CORE_DB_NOTFOUND 12 /* NOT USED. Table or record not found */ -#define SWITCH_CORE_DB_FULL 13 /* Insertion failed because database is full */ -#define SWITCH_CORE_DB_CANTOPEN 14 /* Unable to open the database file */ -#define SWITCH_CORE_DB_PROTOCOL 15 /* Database lock protocol error */ -#define SWITCH_CORE_DB_EMPTY 16 /* Database is empty */ -#define SWITCH_CORE_DB_SCHEMA 17 /* The database schema changed */ -#define SWITCH_CORE_DB_TOOBIG 18 /* NOT USED. Too much data for one row */ -#define SWITCH_CORE_DB_CONSTRAINT 19 /* Abort due to contraint violation */ -#define SWITCH_CORE_DB_MISMATCH 20 /* Data type mismatch */ -#define SWITCH_CORE_DB_MISUSE 21 /* Library used incorrectly */ -#define SWITCH_CORE_DB_NOLFS 22 /* Uses OS features not supported on host */ -#define SWITCH_CORE_DB_AUTH 23 /* Authorization denied */ -#define SWITCH_CORE_DB_FORMAT 24 /* Auxiliary database format error */ -#define SWITCH_CORE_DB_RANGE 25 /* 2nd parameter to switch_core_db_bind out of range */ -#define SWITCH_CORE_DB_NOTADB 26 /* File opened that is not a database file */ -#define SWITCH_CORE_DB_ROW 100 /* switch_core_db_step() has another row ready */ -#define SWITCH_CORE_DB_DONE 101 /* switch_core_db_step() has finished executing */ +#define SWITCH_CORE_DB_ERROR 1 /* SQL error or missing database */ +#define SWITCH_CORE_DB_INTERNAL 2 /* NOT USED. Internal logic error in SQLite */ +#define SWITCH_CORE_DB_PERM 3 /* Access permission denied */ +#define SWITCH_CORE_DB_ABORT 4 /* Callback routine requested an abort */ +#define SWITCH_CORE_DB_BUSY 5 /* The database file is locked */ +#define SWITCH_CORE_DB_LOCKED 6 /* A table in the database is locked */ +#define SWITCH_CORE_DB_NOMEM 7 /* A malloc() failed */ +#define SWITCH_CORE_DB_READONLY 8 /* Attempt to write a readonly database */ +#define SWITCH_CORE_DB_INTERRUPT 9 /* Operation terminated by switch_core_db_interrupt() */ +#define SWITCH_CORE_DB_IOERR 10 /* Some kind of disk I/O error occurred */ +#define SWITCH_CORE_DB_CORRUPT 11 /* The database disk image is malformed */ +#define SWITCH_CORE_DB_NOTFOUND 12 /* NOT USED. Table or record not found */ +#define SWITCH_CORE_DB_FULL 13 /* Insertion failed because database is full */ +#define SWITCH_CORE_DB_CANTOPEN 14 /* Unable to open the database file */ +#define SWITCH_CORE_DB_PROTOCOL 15 /* Database lock protocol error */ +#define SWITCH_CORE_DB_EMPTY 16 /* Database is empty */ +#define SWITCH_CORE_DB_SCHEMA 17 /* The database schema changed */ +#define SWITCH_CORE_DB_TOOBIG 18 /* NOT USED. Too much data for one row */ +#define SWITCH_CORE_DB_CONSTRAINT 19 /* Abort due to contraint violation */ +#define SWITCH_CORE_DB_MISMATCH 20 /* Data type mismatch */ +#define SWITCH_CORE_DB_MISUSE 21 /* Library used incorrectly */ +#define SWITCH_CORE_DB_NOLFS 22 /* Uses OS features not supported on host */ +#define SWITCH_CORE_DB_AUTH 23 /* Authorization denied */ +#define SWITCH_CORE_DB_FORMAT 24 /* Auxiliary database format error */ +#define SWITCH_CORE_DB_RANGE 25 /* 2nd parameter to switch_core_db_bind out of range */ +#define SWITCH_CORE_DB_NOTADB 26 /* File opened that is not a database file */ +#define SWITCH_CORE_DB_ROW 100 /* switch_core_db_step() has another row ready */ +#define SWITCH_CORE_DB_DONE 101 /* switch_core_db_step() has finished executing */ /* end-of-error-codes */ @@ -547,12 +539,10 @@ SWITCH_DECLARE(void) switch_core_db_free(char *z); * should always use %q instead of %s when inserting text into a string * literal. */ -SWITCH_DECLARE(char *)switch_mprintf(const char *zFormat,...); +SWITCH_DECLARE(char *) switch_mprintf(const char *zFormat, ...); SWITCH_END_EXTERN_C - #endif - /* For Emacs: * Local Variables: * mode:c diff --git a/src/include/switch_event.h b/src/include/switch_event.h index 97c9c72641..75d81297cc 100644 --- a/src/include/switch_event.h +++ b/src/include/switch_event.h @@ -61,9 +61,8 @@ #include SWITCH_BEGIN_EXTERN_C - /*! \brief An event Header */ -struct switch_event_header{ + struct switch_event_header { /*! the header name */ char *name; /*! the header value */ @@ -139,7 +138,8 @@ SWITCH_DECLARE(switch_status_t) switch_event_shutdown(void); \param subclass_name the subclass name for custom event (only valid when event_id is SWITCH_EVENT_CUSTOM) \return SWITCH_STATUS_SUCCESS on success */ -SWITCH_DECLARE(switch_status_t) switch_event_create_subclass(switch_event_t **event, switch_event_types_t event_id, const char *subclass_name); +SWITCH_DECLARE(switch_status_t) switch_event_create_subclass(switch_event_t **event, switch_event_types_t event_id, + const char *subclass_name); /*! \brief Set the priority of an event @@ -172,7 +172,9 @@ SWITCH_DECLARE(char *) switch_event_get_body(switch_event_t *event); \param fmt the value of the header (varargs see standard sprintf family) \return SWITCH_STATUS_SUCCESS if the header was added */ -SWITCH_DECLARE(switch_status_t) switch_event_add_header(switch_event_t *event, switch_stack_t stack, const char *header_name, const char *fmt, ...) PRINTF_FUNCTION(4,5); +SWITCH_DECLARE(switch_status_t) switch_event_add_header(switch_event_t *event, switch_stack_t stack, + const char *header_name, const char *fmt, + ...) PRINTF_FUNCTION(4, 5); /*! \brief Destroy an event @@ -197,7 +199,8 @@ SWITCH_DECLARE(switch_status_t) switch_event_dup(switch_event_t **event, switch_ \param user_data optional private data to pass to the event handlers \return */ -SWITCH_DECLARE(switch_status_t) switch_event_fire_detailed(char *file, char *func, int line, switch_event_t **event, void *user_data); +SWITCH_DECLARE(switch_status_t) switch_event_fire_detailed(char *file, char *func, int line, switch_event_t **event, + void *user_data); /*! \brief Bind an event callback to a specific event @@ -208,7 +211,8 @@ SWITCH_DECLARE(switch_status_t) switch_event_fire_detailed(char *file, char *fun \param user_data optional user specific data to pass whenever the callback is invoked \return SWITCH_STATUS_SUCCESS if the event was binded */ -SWITCH_DECLARE(switch_status_t) switch_event_bind(char *id, switch_event_types_t event, char *subclass_name, switch_event_callback_t callback, void *user_data); +SWITCH_DECLARE(switch_status_t) switch_event_bind(char *id, switch_event_types_t event, char *subclass_name, + switch_event_callback_t callback, void *user_data); /*! \brief Render the name of an event id enumeration @@ -251,7 +255,7 @@ SWITCH_DECLARE(switch_status_t) switch_event_serialize(switch_event_t *event, ch \return the xml object if the operation was successful \note the body supplied by this function will supersede an existing body the event may have */ -SWITCH_DECLARE(switch_xml_t) switch_event_xmlize(switch_event_t *event, const char *fmt, ...) PRINTF_FUNCTION(2,3); +SWITCH_DECLARE(switch_xml_t) switch_event_xmlize(switch_event_t *event, const char *fmt, ...) PRINTF_FUNCTION(2, 3); /*! \brief Determine if the event system has been initilized @@ -266,7 +270,8 @@ SWITCH_DECLARE(switch_status_t) switch_event_running(void); \return SWITCH_STATUS_SUCCESS if the body was added to the event \note the body parameter can be shadowed by the switch_event_reserve_subclass_detailed function */ -SWITCH_DECLARE(switch_status_t) switch_event_add_body(switch_event_t *event, const char *fmt, ...) PRINTF_FUNCTION(2,3); +SWITCH_DECLARE(switch_status_t) switch_event_add_body(switch_event_t *event, const char *fmt, ...) PRINTF_FUNCTION(2, + 3); /*! @@ -311,9 +316,7 @@ SWITCH_DECLARE(void) switch_event_deliver(switch_event_t **event); ///\} SWITCH_END_EXTERN_C - #endif - /* For Emacs: * Local Variables: * mode:c diff --git a/src/include/switch_frame.h b/src/include/switch_frame.h index 3ba59f32ee..0da90a23fe 100644 --- a/src/include/switch_frame.h +++ b/src/include/switch_frame.h @@ -39,16 +39,15 @@ #include SWITCH_BEGIN_EXTERN_C - /*! \brief An abstraction of a data frame */ -struct switch_frame { + struct switch_frame { /*! a pointer to the codec information */ switch_codec_t *codec; /*! the originating source of the frame */ const char *source; /*! the raw packet */ void *packet; - /*! the size of the raw packet when applicable*/ + /*! the size of the raw packet when applicable */ uint32_t packetlen; /*! the frame data */ void *data; @@ -69,9 +68,7 @@ struct switch_frame { }; SWITCH_END_EXTERN_C - #endif - /* For Emacs: * Local Variables: * mode:c diff --git a/src/include/switch_ivr.h b/src/include/switch_ivr.h index 8d98defaf0..f0d2c4a524 100644 --- a/src/include/switch_ivr.h +++ b/src/include/switch_ivr.h @@ -42,7 +42,6 @@ #include SWITCH_BEGIN_EXTERN_C - /** * @defgroup switch_ivr IVR Library * @ingroup core1 @@ -50,8 +49,6 @@ SWITCH_BEGIN_EXTERN_C * building blocks for a higher level IVR interface. * @{ */ - - /*! \brief Generate an XML CDR report. \param session the session to get the data from. @@ -59,7 +56,7 @@ SWITCH_BEGIN_EXTERN_C \return SWITCH_STATUS_SUCCESS if successful \note on success the xml object must be freed */ -SWITCH_DECLARE(switch_status_t) switch_ivr_generate_xml_cdr(switch_core_session_t *session, switch_xml_t *xml_cdr); +SWITCH_DECLARE(switch_status_t) switch_ivr_generate_xml_cdr(switch_core_session_t *session, switch_xml_t * xml_cdr); /*! \brief Parse command from an event @@ -89,8 +86,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_park(switch_core_session_t *session, \return SWITCH_STATUS_SUCCESS to keep the collection moving. */ SWITCH_DECLARE(switch_status_t) switch_ivr_collect_digits_callback(switch_core_session_t *session, - switch_input_args_t *args, - uint32_t timeout); + switch_input_args_t *args, uint32_t timeout); /*! \brief Wait for specified number of DTMF digits, untile terminator is received or until the channel hangs up. @@ -108,8 +104,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_collect_digits_count(switch_core_sess uint32_t buflen, uint32_t maxdigits, const char *terminators, - char *terminator, - uint32_t timeout); + char *terminator, uint32_t timeout); /*! \brief Engage background Speech detection on a session @@ -124,9 +119,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_collect_digits_count(switch_core_sess SWITCH_DECLARE(switch_status_t) switch_ivr_detect_speech(switch_core_session_t *session, char *mod_name, char *grammar, - char *path, - char *dest, - switch_asr_handle_t *ah); + char *path, char *dest, switch_asr_handle_t *ah); /*! \brief Stop background Speech detection on a session @@ -156,7 +149,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_resume_detect_speech(switch_core_sess \param path the grammar path \return SWITCH_STATUS_SUCCESS if all is well */ -SWITCH_DECLARE(switch_status_t) switch_ivr_detect_speech_load_grammar(switch_core_session_t *session, char *grammar, char *path); +SWITCH_DECLARE(switch_status_t) switch_ivr_detect_speech_load_grammar(switch_core_session_t *session, char *grammar, + char *path); /*! \brief Unload a grammar on a background speech detection handle @@ -173,7 +167,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_detect_speech_unload_grammar(switch_c \param fh file handle to use (NULL for builtin one) \return SWITCH_STATUS_SUCCESS if all is well */ -SWITCH_DECLARE(switch_status_t) switch_ivr_record_session(switch_core_session_t *session, char *file, switch_file_handle_t *fh); +SWITCH_DECLARE(switch_status_t) switch_ivr_record_session(switch_core_session_t *session, char *file, + switch_file_handle_t *fh); /*! \brief Stop Recording a session @@ -198,9 +193,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_stop_inband_dtmf_session(switch_core_ \note passing a NULL dtmf_callback nad a not NULL buf indicates to copy any dtmf to buf and stop playback. */ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *session, - switch_file_handle_t *fh, - char *file, - switch_input_args_t *args); + switch_file_handle_t *fh, char *file, switch_input_args_t *args); /*! @@ -216,10 +209,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess \note passing a NULL dtmf_callback nad a not NULL buf indicates to copy any dtmf to buf and stop recording. */ SWITCH_DECLARE(switch_status_t) switch_ivr_record_file(switch_core_session_t *session, - switch_file_handle_t *fh, - char *file, - switch_input_args_t *args, - uint32_t limit); + switch_file_handle_t *fh, + char *file, switch_input_args_t *args, uint32_t limit); /*! @@ -239,23 +230,21 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_record_file(switch_core_session_t *se \note to test for digit capture failure look for \\0 in the first position of the buffer */ SWITCH_DECLARE(switch_status_t) switch_play_and_get_digits(switch_core_session_t *session, - uint32_t min_digits, - uint32_t max_digits, - uint32_t max_tries, - uint32_t timeout, - char* valid_terminators, - char* audio_file, - char* bad_input_audio_file, - void* digit_buffer, - uint32_t digit_buffer_length, - char* digits_regex); + uint32_t min_digits, + uint32_t max_digits, + uint32_t max_tries, + uint32_t timeout, + char *valid_terminators, + char *audio_file, + char *bad_input_audio_file, + void *digit_buffer, + uint32_t digit_buffer_length, char *digits_regex); SWITCH_DECLARE(switch_status_t) switch_ivr_speak_text_handle(switch_core_session_t *session, - switch_speech_handle_t *sh, - switch_codec_t *codec, - switch_timer_t *timer, - char *text, - switch_input_args_t *args); + switch_speech_handle_t *sh, + switch_codec_t *codec, + switch_timer_t *timer, + char *text, switch_input_args_t *args); /*! \brief Speak given text with given tts engine @@ -269,12 +258,10 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_speak_text_handle(switch_core_session \param buflen the len of buf \return SWITCH_STATUS_SUCCESS if all is well */ -SWITCH_DECLARE(switch_status_t) switch_ivr_speak_text(switch_core_session_t *session, +SWITCH_DECLARE(switch_status_t) switch_ivr_speak_text(switch_core_session_t *session, char *tts_name, char *voice_name, - uint32_t rate, - char *text, - switch_input_args_t *args); + uint32_t rate, char *text, switch_input_args_t *args); /*! \brief Make an outgoing call @@ -308,11 +295,10 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess \param peer_session_data data to pass to the DTMF callback for peer_session \return SWITCH_STATUS_SUCCESS if all is well */ -SWITCH_DECLARE(switch_status_t) switch_ivr_multi_threaded_bridge(switch_core_session_t *session, +SWITCH_DECLARE(switch_status_t) switch_ivr_multi_threaded_bridge(switch_core_session_t *session, switch_core_session_t *peer_session, switch_input_callback_function_t dtmf_callback, - void *session_data, - void *peer_session_data); + void *session_data, void *peer_session_data); /*! \brief Bridge Signalling from one session to another @@ -320,7 +306,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_multi_threaded_bridge(switch_core_ses \param peer_session the other session \return SWITCH_STATUS_SUCCESS if all is well */ -SWITCH_DECLARE(switch_status_t) switch_ivr_signal_bridge(switch_core_session_t *session, switch_core_session_t *peer_session); +SWITCH_DECLARE(switch_status_t) switch_ivr_signal_bridge(switch_core_session_t *session, + switch_core_session_t *peer_session); /*! \brief Transfer an existing session to another location @@ -329,7 +316,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_signal_bridge(switch_core_session_t * \param dialplan the new dialplan (OPTIONAL, may be NULL) \param context the new context (OPTIONAL, may be NULL) */ -SWITCH_DECLARE(switch_status_t) switch_ivr_session_transfer(switch_core_session_t *session, char *extension, char *dialplan, char *context); +SWITCH_DECLARE(switch_status_t) switch_ivr_session_transfer(switch_core_session_t *session, char *extension, + char *dialplan, char *context); /*! \brief Transfer an existing session to another location in the future @@ -340,7 +328,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_session_transfer(switch_core_session_ \param context the new context (OPTIONAL, may be NULL) \return the id of the task */ -SWITCH_DECLARE(uint32_t) switch_ivr_schedule_transfer(time_t runtime, char *uuid, char *extension, char *dialplan, char *context); +SWITCH_DECLARE(uint32_t) switch_ivr_schedule_transfer(time_t runtime, char *uuid, char *extension, char *dialplan, + char *context); /*! @@ -351,7 +340,8 @@ SWITCH_DECLARE(uint32_t) switch_ivr_schedule_transfer(time_t runtime, char *uuid \param bleg hangup up the B-Leg if possible \return the id of the task */ -SWITCH_DECLARE(uint32_t) switch_ivr_schedule_hangup(time_t runtime, char *uuid, switch_call_cause_t cause, switch_bool_t bleg); +SWITCH_DECLARE(uint32_t) switch_ivr_schedule_hangup(time_t runtime, char *uuid, switch_call_cause_t cause, + switch_bool_t bleg); /*! \brief Bridge two existing sessions @@ -413,7 +403,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_unhold(switch_core_session_t *session \param flags flags to send to the request (SMF_ECHO_BRIDGED to send the broadcast to both sides of the call) \return the id of the task */ -SWITCH_DECLARE(uint32_t) switch_ivr_schedule_broadcast(time_t runtime, char *uuid, char *path, switch_media_flag_t flags); +SWITCH_DECLARE(uint32_t) switch_ivr_schedule_broadcast(time_t runtime, char *uuid, char *path, + switch_media_flag_t flags); /*! \brief Signal the session to broadcast audio @@ -431,22 +422,24 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_broadcast(char *uuid, char *path, swi \param var the name of the variable to transfer (NULL for all) \return SWITCH_STATUS_SUCCESS if all is well */ -SWITCH_DECLARE(switch_status_t) switch_ivr_transfer_variable(switch_core_session_t *sessa, switch_core_session_t *sessb, char *var); +SWITCH_DECLARE(switch_status_t) switch_ivr_transfer_variable(switch_core_session_t *sessa, switch_core_session_t *sessb, + char *var); /******************************************************************************************************/ -struct switch_ivr_digit_stream_parser; -typedef struct switch_ivr_digit_stream_parser switch_ivr_digit_stream_parser_t; -struct switch_ivr_digit_stream; -typedef struct switch_ivr_digit_stream switch_ivr_digit_stream_t; + struct switch_ivr_digit_stream_parser; + typedef struct switch_ivr_digit_stream_parser switch_ivr_digit_stream_parser_t; + struct switch_ivr_digit_stream; + typedef struct switch_ivr_digit_stream switch_ivr_digit_stream_t; /*! \brief Create a digit stream parser object \param pool the pool to use for the new hash \param parser a pointer to the object pointer \return SWITCH_STATUS_SUCCESS if all is well */ -SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_parser_new(switch_memory_pool_t *pool, switch_ivr_digit_stream_parser_t **parser); +SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_parser_new(switch_memory_pool_t *pool, + switch_ivr_digit_stream_parser_t **parser); /*! \brief Destroy a digit stream parser object @@ -461,7 +454,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_parser_destroy(switch_iv \param stream a pointer to the stream object pointer \return NULL if no match found or consumer data that was associated with a given digit string when matched */ -SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_new(switch_ivr_digit_stream_parser_t *parser, switch_ivr_digit_stream_t **stream); +SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_new(switch_ivr_digit_stream_parser_t *parser, + switch_ivr_digit_stream_t **stream); /*! \brief Destroys a digit stream object @@ -477,7 +471,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_destroy(switch_ivr_digit \param data consumer data attached to this digit string \return SWITCH_STATUS_SUCCESS if all is well */ -SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_parser_set_event(switch_ivr_digit_stream_parser_t *parser, char *digits, void *data); +SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_parser_set_event(switch_ivr_digit_stream_parser_t *parser, + char *digits, void *data); /*! \brief Delete a string to action mapping @@ -485,7 +480,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_parser_set_event(switch_ \param digits the digit string to be removed from the map \return SWITCH_STATUS_SUCCESS if all is well */ -SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_parser_del_event(switch_ivr_digit_stream_parser_t *parser, char *digits); +SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_parser_del_event(switch_ivr_digit_stream_parser_t *parser, + char *digits); /*! \brief Feed digits collected into the stream for event match testing @@ -493,7 +489,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_parser_del_event(switch_ \param digit a digit to collect and test against the map of digit strings \return NULL if no match found or consumer data that was associated with a given digit string when matched */ -SWITCH_DECLARE(void *) switch_ivr_digit_stream_parser_feed(switch_ivr_digit_stream_parser_t *parser, switch_ivr_digit_stream_t *stream, char digit); +SWITCH_DECLARE(void *) switch_ivr_digit_stream_parser_feed(switch_ivr_digit_stream_parser_t *parser, + switch_ivr_digit_stream_t *stream, char digit); /*! \brief Reset the collected digit stream to nothing @@ -508,7 +505,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_reset(switch_ivr_digit_s \param digit the terminator digit \return SWITCH_STATUS_SUCCESS if all is well */ -SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_parser_set_terminator(switch_ivr_digit_stream_parser_t *parser, char digit); +SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_parser_set_terminator(switch_ivr_digit_stream_parser_t *parser, + char digit); /******************************************************************************************************/ @@ -524,28 +522,29 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_parser_set_terminator(sw * @{ */ -typedef enum { - SWITCH_IVR_MENU_FLAG_FALLTOMAIN = (1 << 0), - SWITCH_IVR_MENU_FLAG_FREEPOOL = (1 << 1), - SWITCH_IVR_MENU_FLAG_STACK = (1 << 2), -} switch_ivr_menu_flags; + typedef enum { + SWITCH_IVR_MENU_FLAG_FALLTOMAIN = (1 << 0), + SWITCH_IVR_MENU_FLAG_FREEPOOL = (1 << 1), + SWITCH_IVR_MENU_FLAG_STACK = (1 << 2), + } switch_ivr_menu_flags; /* Actions are either set in switch_ivr_menu_bind_function or returned by a callback */ -typedef enum { - SWITCH_IVR_ACTION_DIE, /* Exit the menu. */ - SWITCH_IVR_ACTION_EXECMENU, /* Goto another menu in the stack. */ - SWITCH_IVR_ACTION_EXECAPP, /* Execute an application. */ - SWITCH_IVR_ACTION_PLAYSOUND, /* Play a sound. */ - SWITCH_IVR_ACTION_SAYTEXT, /* say text. */ - SWITCH_IVR_ACTION_SAYPHRASE, /* say a phrase macro. */ - SWITCH_IVR_ACTION_BACK, /* Go back 1 menu. */ - SWITCH_IVR_ACTION_TOMAIN, /* Go back to the top level menu. */ - SWITCH_IVR_ACTION_TRANSFER, /* Transfer caller to another ext. */ - SWITCH_IVR_ACTION_NOOP, /* No operation */ -} switch_ivr_action_t; -struct switch_ivr_menu; -typedef switch_ivr_action_t switch_ivr_menu_action_function_t(struct switch_ivr_menu *, char *, char *, size_t, void *); -typedef struct switch_ivr_menu switch_ivr_menu_t; -typedef struct switch_ivr_menu_action switch_ivr_menu_action_t; + typedef enum { + SWITCH_IVR_ACTION_DIE, /* Exit the menu. */ + SWITCH_IVR_ACTION_EXECMENU, /* Goto another menu in the stack. */ + SWITCH_IVR_ACTION_EXECAPP, /* Execute an application. */ + SWITCH_IVR_ACTION_PLAYSOUND, /* Play a sound. */ + SWITCH_IVR_ACTION_SAYTEXT, /* say text. */ + SWITCH_IVR_ACTION_SAYPHRASE, /* say a phrase macro. */ + SWITCH_IVR_ACTION_BACK, /* Go back 1 menu. */ + SWITCH_IVR_ACTION_TOMAIN, /* Go back to the top level menu. */ + SWITCH_IVR_ACTION_TRANSFER, /* Transfer caller to another ext. */ + SWITCH_IVR_ACTION_NOOP, /* No operation */ + } switch_ivr_action_t; + struct switch_ivr_menu; + typedef switch_ivr_action_t switch_ivr_menu_action_function_t(struct switch_ivr_menu *, char *, char *, size_t, + void *); + typedef struct switch_ivr_menu switch_ivr_menu_t; + typedef struct switch_ivr_menu_action switch_ivr_menu_action_t; /******************************************************************************************************/ /*! @@ -564,19 +563,17 @@ typedef struct switch_ivr_menu_action switch_ivr_menu_action_t; *\param pool memory pool (NULL to create one) *\return SWITCH_STATUS_SUCCESS if the menu was created */ -SWITCH_DECLARE(switch_status_t) switch_ivr_menu_init(switch_ivr_menu_t **new_menu, - switch_ivr_menu_t *main, - const char *name, - const char *greeting_sound, - const char *short_greeting_sound, - const char *exit_sound, - const char *invalid_sound, - const char *tts_engine, - const char *tts_voice, - const char *phrase_lang, - int timeout, - int max_failures, - switch_memory_pool_t *pool); + SWITCH_DECLARE(switch_status_t) switch_ivr_menu_init(switch_ivr_menu_t **new_menu, + switch_ivr_menu_t *main, + const char *name, + const char *greeting_sound, + const char *short_greeting_sound, + const char *exit_sound, + const char *invalid_sound, + const char *tts_engine, + const char *tts_voice, + const char *phrase_lang, + int timeout, int max_failures, switch_memory_pool_t *pool); /*! *\brief switch_ivr_menu_bind_action: Bind a keystroke to an action. @@ -586,7 +583,9 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_menu_init(switch_ivr_menu_t **new_men *\param bind KeyStrokes to bind the action to. *\return SWUTCH_STATUS_SUCCESS if the action was binded */ -SWITCH_DECLARE(switch_status_t) switch_ivr_menu_bind_action(switch_ivr_menu_t *menu, switch_ivr_action_t ivr_action, const char *arg, const char *bind); + SWITCH_DECLARE(switch_status_t) switch_ivr_menu_bind_action(switch_ivr_menu_t *menu, + switch_ivr_action_t ivr_action, const char *arg, + const char *bind); /*! @@ -600,7 +599,9 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_menu_bind_action(switch_ivr_menu_t *m *\note The function returns an switch_ivr_action_t enum of what you want to do. and looks to your buffer for args. *\return SWUTCH_STATUS_SUCCESS if the function was binded */ -SWITCH_DECLARE(switch_status_t) switch_ivr_menu_bind_function(switch_ivr_menu_t *menu, switch_ivr_menu_action_function_t *function, const char *arg, const char *bind); + SWITCH_DECLARE(switch_status_t) switch_ivr_menu_bind_function(switch_ivr_menu_t *menu, + switch_ivr_menu_action_function_t * function, + const char *arg, const char *bind); /*! @@ -611,17 +612,18 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_menu_bind_function(switch_ivr_menu_t *\param obj A void pointer to an object you want to make avaliable to your callback functions that you may have binded with switch_ivr_menu_bind_function. *\return SWITCH_STATUS_SUCCESS if all is well */ -SWITCH_DECLARE(switch_status_t) switch_ivr_menu_execute(switch_core_session_t *session, switch_ivr_menu_t *stack, char *name, void *obj); + SWITCH_DECLARE(switch_status_t) switch_ivr_menu_execute(switch_core_session_t *session, switch_ivr_menu_t *stack, + char *name, void *obj); /*! *\brief free a stack of menu objects. *\param stack The top level menu you wish to destroy. *\return SWITCH_STATUS_SUCCESS if the object was a top level menu and it was freed */ -SWITCH_DECLARE(switch_status_t) switch_ivr_menu_stack_free(switch_ivr_menu_t *stack); + SWITCH_DECLARE(switch_status_t) switch_ivr_menu_stack_free(switch_ivr_menu_t *stack); -struct switch_ivr_menu_xml_ctx; -typedef struct switch_ivr_menu_xml_ctx switch_ivr_menu_xml_ctx_t; + struct switch_ivr_menu_xml_ctx; + typedef struct switch_ivr_menu_xml_ctx switch_ivr_menu_xml_ctx_t; /*! *\brief Build a menu stack from an xml source *\param xml_menu_ctx The XML menu parser context previously created by switch_ivr_menu_stack_xml_init @@ -630,10 +632,9 @@ typedef struct switch_ivr_menu_xml_ctx switch_ivr_menu_xml_ctx_t; *\param xml_menu The xml Menu source of the menu to be created *\return SWITCH_STATUS_SUCCESS if all is well */ -SWITCH_DECLARE(switch_status_t) switch_ivr_menu_stack_xml_build(switch_ivr_menu_xml_ctx_t *xml_menu_ctx, - switch_ivr_menu_t **menu_stack, - switch_xml_t xml_menus, - switch_xml_t xml_menu); + SWITCH_DECLARE(switch_status_t) switch_ivr_menu_stack_xml_build(switch_ivr_menu_xml_ctx_t *xml_menu_ctx, + switch_ivr_menu_t **menu_stack, + switch_xml_t xml_menus, switch_xml_t xml_menu); /*! *\param xml_menu_ctx The XML menu parser context previously created by switch_ivr_menu_stack_xml_init @@ -641,28 +642,25 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_menu_stack_xml_build(switch_ivr_menu_ *\param function The menu function callback that will be executed when menu digits are bound to this name *\return SWITCH_STATUS_SUCCESS if all is well */ -SWITCH_DECLARE(switch_status_t) switch_ivr_menu_stack_xml_add_custom(switch_ivr_menu_xml_ctx_t *xml_menu_ctx, - char *name, - switch_ivr_menu_action_function_t *function); + SWITCH_DECLARE(switch_status_t) switch_ivr_menu_stack_xml_add_custom(switch_ivr_menu_xml_ctx_t *xml_menu_ctx, + char *name, + switch_ivr_menu_action_function_t * function); /*! *\param xml_menu_ctx A pointer of a XML menu parser context to be created *\param pool memory pool (NULL to create one) *\return SWITCH_STATUS_SUCCESS if all is well */ -SWITCH_DECLARE(switch_status_t) switch_ivr_menu_stack_xml_init(switch_ivr_menu_xml_ctx_t **xml_menu_ctx, switch_memory_pool_t *pool); + SWITCH_DECLARE(switch_status_t) switch_ivr_menu_stack_xml_init(switch_ivr_menu_xml_ctx_t **xml_menu_ctx, + switch_memory_pool_t *pool); -SWITCH_DECLARE(switch_status_t) switch_ivr_phrase_macro(switch_core_session_t *session, - char *macro_name, - char *data, - char *lang, - switch_input_args_t *args); + SWITCH_DECLARE(switch_status_t) switch_ivr_phrase_macro(switch_core_session_t *session, + char *macro_name, + char *data, char *lang, switch_input_args_t *args); /** @} */ -SWITCH_END_EXTERN_C - + SWITCH_END_EXTERN_C #endif - /* For Emacs: * Local Variables: * mode:c diff --git a/src/include/switch_loadable_module.h b/src/include/switch_loadable_module.h index 2766136224..b82d39fe71 100644 --- a/src/include/switch_loadable_module.h +++ b/src/include/switch_loadable_module.h @@ -44,15 +44,13 @@ #include SWITCH_BEGIN_EXTERN_C - /*! \defgroup mods Loadable Module Functions \ingroup core1 \{ */ - /*! \brief The abstraction of a loadable module */ -struct switch_loadable_module_interface { + struct switch_loadable_module_interface { /*! the name of the module */ const char *module_name; /*! the table of endpoints the module has implmented */ @@ -76,7 +74,7 @@ struct switch_loadable_module_interface { /*! the table of chat interfaces the module has implmented */ const switch_chat_interface_t *chat_interface; /*! the table of say interfaces the module has implmented */ - const switch_say_interface_t *say_interface; + const switch_say_interface_t *say_interface; /*! the table of asr interfaces the module has implmented */ const switch_asr_interface_t *asr_interface; /*! the table of management interfaces the module has implmented */ @@ -125,9 +123,9 @@ SWITCH_DECLARE(switch_dialplan_interface_t *) switch_loadable_module_get_dialpla \note only use this function if you are making a module that in turn gateways module loading to another technology */ SWITCH_DECLARE(switch_status_t) switch_loadable_module_build_dynamic(char *filename, - switch_module_load_t switch_module_load, - switch_module_runtime_t switch_module_runtime, - switch_module_shutdown_t switch_module_shutdown); + switch_module_load_t switch_module_load, + switch_module_runtime_t switch_module_runtime, + switch_module_shutdown_t switch_module_shutdown); /*! \brief Retrieve the timer interface by it's registered name @@ -206,8 +204,8 @@ SWITCH_DECLARE(switch_management_interface_t *) switch_loadable_module_get_manag \param arraylen the max size in elements of the array \return the number of elements added to the array */ -SWITCH_DECLARE(int) switch_loadable_module_get_codecs(switch_memory_pool_t *pool, const switch_codec_implementation_t **array, - int arraylen); +SWITCH_DECLARE(int) switch_loadable_module_get_codecs(switch_memory_pool_t *pool, + const switch_codec_implementation_t **array, int arraylen); /*! @@ -230,7 +228,8 @@ SWITCH_DECLARE(int) switch_loadable_module_get_codecs_sorted(const switch_codec_ \param stream stream for output \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(char *cmd, char *arg, switch_core_session_t *session, + switch_stream_handle_t *stream); @@ -250,7 +249,8 @@ SWITCH_DECLARE(switch_status_t) switch_loadable_module_load_module(char *dir, ch \param filename the path to the module's dll or so file \return SWITCH_STATUS_SUCCESS on a successful load */ -SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename); +SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, + char *filename); SWITCH_MOD_DECLARE(switch_status_t) switch_module_reload(void); SWITCH_MOD_DECLARE(switch_status_t) switch_module_pause(void); SWITCH_MOD_DECLARE(switch_status_t) switch_module_resume(void); @@ -266,9 +266,7 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_shutdown(void); ///\} SWITCH_END_EXTERN_C - #endif - /* For Emacs: * Local Variables: * mode:c diff --git a/src/include/switch_log.h b/src/include/switch_log.h index fa400a2ef6..8cc8b1e646 100644 --- a/src/include/switch_log.h +++ b/src/include/switch_log.h @@ -41,35 +41,32 @@ #include SWITCH_BEGIN_EXTERN_C - ///\defgroup log Logger Routines ///\ingroup core1 ///\{ - - /*! \brief Log Data */ -typedef struct { + typedef struct { /*! The complete log message */ char *data; - /*! The file where the message originated */ + /*! The file where the message originated */ char *file; - /*! The line number where the message originated */ + /*! The line number where the message originated */ uint32_t line; - /*! The function where the message originated */ + /*! The function where the message originated */ char *func; - /*! The log level of the message */ + /*! The log level of the message */ switch_log_level_t level; /*! The time when the log line was sent */ switch_time_t timestamp; - /*! A pointer to where the actual content of the message starts (skipping past the preformatted portion) */ + /*! A pointer to where the actual content of the message starts (skipping past the preformatted portion) */ char *content; /* To maintain abi, only add new elements to the end of this struct and do not delete any elements */ } switch_log_node_t; -typedef switch_status_t (*switch_log_function_t)(const switch_log_node_t *node, switch_log_level_t level); +typedef switch_status_t (*switch_log_function_t) (const switch_log_node_t *node, switch_log_level_t level); /*! @@ -97,7 +94,8 @@ SWITCH_DECLARE(switch_status_t) switch_log_shutdown(void); \param ... variable args \note there are channel macros to supply the first 4 parameters */ -SWITCH_DECLARE(void) switch_log_printf(switch_text_channel_t channel, const char *file, const char *func, int line, switch_log_level_t level, const char *fmt, ...) PRINTF_FUNCTION(6,7); +SWITCH_DECLARE(void) switch_log_printf(switch_text_channel_t channel, const char *file, const char *func, int line, + switch_log_level_t level, const char *fmt, ...) PRINTF_FUNCTION(6, 7); /*! \brief Shut down the logging engine @@ -121,9 +119,7 @@ SWITCH_DECLARE(switch_log_level_t) switch_log_str2level(const char *str); ///\} SWITCH_END_EXTERN_C - #endif - /* For Emacs: * Local Variables: * mode:c diff --git a/src/include/switch_module_interfaces.h b/src/include/switch_module_interfaces.h index eb534fbdb5..39927b8728 100644 --- a/src/include/switch_module_interfaces.h +++ b/src/include/switch_module_interfaces.h @@ -42,10 +42,9 @@ #include SWITCH_BEGIN_EXTERN_C - /*! \brief A table of functions to execute at various states */ -struct switch_state_handler_table { + struct switch_state_handler_table { /*! executed when the state changes to init */ switch_state_handler_t on_init; /*! executed when the state changes to ring */ @@ -54,13 +53,13 @@ struct switch_state_handler_table { switch_state_handler_t on_execute; /*! executed when the state changes to hangup */ switch_state_handler_t on_hangup; - /*! executed when the state changes to loopback*/ + /*! executed when the state changes to loopback */ switch_state_handler_t on_loopback; - /*! executed when the state changes to transmit*/ + /*! executed when the state changes to transmit */ switch_state_handler_t on_transmit; - /*! executed when the state changes to hold*/ + /*! executed when the state changes to hold */ switch_state_handler_t on_hold; - /*! executed when the state changes to hibernate*/ + /*! executed when the state changes to hibernate */ switch_state_handler_t on_hibernate; }; @@ -75,133 +74,34 @@ struct switch_stream_handle { switch_event_t *event; }; -/*! \brief Node in which to store custom outgoing channel callback hooks */ -struct switch_io_event_hook_outgoing_channel { - /*! the outgoing channel callback hook*/ - switch_outgoing_channel_hook_t outgoing_channel; - struct switch_io_event_hook_outgoing_channel *next; -}; +struct switch_io_event_hooks; -/*! \brief Node in which to store custom answer channel callback hooks */ -struct switch_io_event_hook_answer_channel { - /*! the answer channel callback hook*/ - switch_answer_channel_hook_t answer_channel; - struct switch_io_event_hook_answer_channel *next; -}; - -/*! \brief Node in which to store custom receive message callback hooks */ -struct switch_io_event_hook_receive_message { - /*! the answer channel callback hook*/ - switch_receive_message_hook_t receive_message; - struct switch_io_event_hook_receive_message *next; -}; - -/*! \brief Node in which to store custom receive message callback hooks */ -struct switch_io_event_hook_receive_event { - /*! the answer channel callback hook*/ - switch_receive_event_hook_t receive_event; - struct switch_io_event_hook_receive_event *next; -}; - -/*! \brief Node in which to store custom read frame channel callback hooks */ -struct switch_io_event_hook_read_frame { - /*! the read frame channel callback hook*/ - switch_read_frame_hook_t read_frame; - struct switch_io_event_hook_read_frame *next; -}; - -/*! \brief Node in which to store custom write_frame channel callback hooks */ -struct switch_io_event_hook_write_frame { - /*! the write_frame channel callback hook*/ - switch_write_frame_hook_t write_frame; - struct switch_io_event_hook_write_frame *next; -}; - -/*! \brief Node in which to store custom kill channel callback hooks */ -struct switch_io_event_hook_kill_channel { - /*! the kill channel callback hook*/ - switch_kill_channel_hook_t kill_channel; - struct switch_io_event_hook_kill_channel *next; -}; - -/*! \brief Node in which to store custom waitfor read channel callback hooks */ -struct switch_io_event_hook_waitfor_read { - /*! the waitfor read channel callback hook*/ - switch_waitfor_read_hook_t waitfor_read; - struct switch_io_event_hook_waitfor_read *next; -}; - -/*! \brief Node in which to store custom waitfor write channel callback hooks */ -struct switch_io_event_hook_waitfor_write { - /*! the waitfor write channel callback hook*/ - switch_waitfor_write_hook_t waitfor_write; - struct switch_io_event_hook_waitfor_write *next; -}; - -/*! \brief Node in which to store custom send dtmf channel callback hooks */ -struct switch_io_event_hook_send_dtmf { - /*! the send dtmf channel callback hook*/ - switch_send_dtmf_hook_t send_dtmf; - struct switch_io_event_hook_send_dtmf *next; -}; - -/*! \brief Node in which to store state change callback hooks */ -struct switch_io_event_hook_state_change { - /*! the send dtmf channel callback hook*/ - switch_state_change_hook_t state_change; - struct switch_io_event_hook_state_change *next; -}; - -/*! \brief A table of lists of io_event_hooks to store the event hooks associated with a session */ -struct switch_io_event_hooks { - /*! a list of outgoing channel hooks */ - switch_io_event_hook_outgoing_channel_t *outgoing_channel; - /*! a list of answer channel hooks */ - switch_io_event_hook_answer_channel_t *answer_channel; - /*! a list of receive message hooks */ - switch_io_event_hook_receive_message_t *receive_message; - /*! a list of queue message hooks */ - switch_io_event_hook_receive_event_t *receive_event; - /*! a list of read frame hooks */ - switch_io_event_hook_read_frame_t *read_frame; - /*! a list of write frame hooks */ - switch_io_event_hook_write_frame_t *write_frame; - /*! a list of kill channel hooks */ - switch_io_event_hook_kill_channel_t *kill_channel; - /*! a list of wait for read hooks */ - switch_io_event_hook_waitfor_read_t *waitfor_read; - /*! a list of wait for write hooks */ - switch_io_event_hook_waitfor_write_t *waitfor_write; - /*! a list of send dtmf hooks */ - switch_io_event_hook_send_dtmf_t *send_dtmf; - /*! a list of state change hooks */ - switch_io_event_hook_state_change_t *state_change; -}; /*! \brief A table of i/o routines that an endpoint interface can implement */ struct switch_io_routines { /*! creates an outgoing session from given session, caller profile */ - switch_call_cause_t (*outgoing_channel)(switch_core_session_t *, switch_caller_profile_t *, switch_core_session_t **, switch_memory_pool_t **); + switch_call_cause_t (*outgoing_channel) (switch_core_session_t *, switch_caller_profile_t *, + switch_core_session_t **, switch_memory_pool_t **); /*! answers the given session's channel */ - switch_status_t (*answer_channel)(switch_core_session_t *); + switch_status_t (*answer_channel) (switch_core_session_t *); /*! read a frame from a session */ - switch_status_t (*read_frame)(switch_core_session_t *, switch_frame_t **, int, switch_io_flag_t, int); + switch_status_t (*read_frame) (switch_core_session_t *, switch_frame_t **, int, switch_io_flag_t, int); /*! write a frame to a session */ - switch_status_t (*write_frame)(switch_core_session_t *, switch_frame_t *, int, switch_io_flag_t, int); + switch_status_t (*write_frame) (switch_core_session_t *, switch_frame_t *, int, switch_io_flag_t, int); /*! send a kill signal to the session's channel */ - switch_status_t (*kill_channel)(switch_core_session_t *, int); + switch_status_t (*kill_channel) (switch_core_session_t *, int); /*! wait for the session's channel to be ready to read audio */ - switch_status_t (*waitfor_read)(switch_core_session_t *, int, int); + switch_status_t (*waitfor_read) (switch_core_session_t *, int, int); /*! wait for the session's channel to be ready to write audio */ - switch_status_t (*waitfor_write)(switch_core_session_t *, int, int); + switch_status_t (*waitfor_write) (switch_core_session_t *, int, int); /*! send a string of DTMF digits to a session's channel */ - switch_status_t (*send_dtmf)(switch_core_session_t *, char *); - /*! receive a message from another session*/ - switch_status_t (*receive_message)(switch_core_session_t *, switch_core_session_message_t *); - /*! queue a message for another session*/ - switch_status_t (*receive_event)(switch_core_session_t *, switch_event_t *); + switch_status_t (*send_dtmf) (switch_core_session_t *, char *); + /*! receive a message from another session */ + switch_status_t (*receive_message) (switch_core_session_t *, switch_core_session_message_t *); + /*! queue a message for another session */ + switch_status_t (*receive_event) (switch_core_session_t *, switch_event_t *); /*! change a sessions channel state */ - switch_status_t (*state_change)(switch_core_session_t *); + switch_status_t (*state_change) (switch_core_session_t *); }; /*! \brief Abstraction of an module endpoint interface @@ -250,15 +150,15 @@ struct switch_timer_interface { /*! the name of the interface */ const char *interface_name; /*! function to allocate the timer */ - switch_status_t (*timer_init)(switch_timer_t *); + switch_status_t (*timer_init) (switch_timer_t *); /*! function to wait for one cycle to pass */ - switch_status_t (*timer_next)(switch_timer_t *); + switch_status_t (*timer_next) (switch_timer_t *); /*! function to step the timer one step */ - switch_status_t (*timer_step)(switch_timer_t *); + switch_status_t (*timer_step) (switch_timer_t *); /*! function to check if the current step has expired */ - switch_status_t (*timer_check)(switch_timer_t *); + switch_status_t (*timer_check) (switch_timer_t *); /*! function to deallocate the timer */ - switch_status_t (*timer_destroy)(switch_timer_t *); + switch_status_t (*timer_destroy) (switch_timer_t *); const struct switch_timer_interface *next; }; @@ -276,19 +176,19 @@ struct switch_file_interface { /*! the name of the interface */ const char *interface_name; /*! function to open the file */ - switch_status_t (*file_open)(switch_file_handle_t *, char *file_path); + switch_status_t (*file_open) (switch_file_handle_t *, char *file_path); /*! function to close the file */ - switch_status_t (*file_close)(switch_file_handle_t *); + switch_status_t (*file_close) (switch_file_handle_t *); /*! function to read from the file */ - switch_status_t (*file_read)(switch_file_handle_t *, void *data, switch_size_t *len); + switch_status_t (*file_read) (switch_file_handle_t *, void *data, switch_size_t *len); /*! function to write from the file */ - switch_status_t (*file_write)(switch_file_handle_t *, void *data, switch_size_t *len); + switch_status_t (*file_write) (switch_file_handle_t *, void *data, switch_size_t *len); /*! function to seek to a certian position in the file */ - switch_status_t (*file_seek)(switch_file_handle_t *, unsigned int *cur_pos, int64_t samples, int whence); + switch_status_t (*file_seek) (switch_file_handle_t *, unsigned int *cur_pos, int64_t samples, int whence); /*! function to set meta data */ - switch_status_t (*file_set_string)(switch_file_handle_t *fh, switch_audio_col_t col, const char *string); + switch_status_t (*file_set_string) (switch_file_handle_t *fh, switch_audio_col_t col, const char *string); /*! function to get meta data */ - switch_status_t (*file_get_string)(switch_file_handle_t *fh, switch_audio_col_t col, const char **string); + switch_status_t (*file_get_string) (switch_file_handle_t *fh, switch_audio_col_t col, const char **string); /*! list of supported file extensions */ char **extens; const struct switch_file_interface *next; @@ -316,7 +216,7 @@ struct switch_file_handle { int seekable; /*! the sample count of the file */ unsigned int sample_count; - /*! the speed of the file playback*/ + /*! the speed of the file playback */ int speed; /*! the handle's memory pool */ switch_memory_pool_t *memory_pool; @@ -325,8 +225,8 @@ struct switch_file_handle { char *handler; int64_t pos; switch_buffer_t *audio_buffer; - uint32_t thresh; - uint32_t silence_hits; + uint32_t thresh; + uint32_t silence_hits; }; /*! \brief Abstract interface to an asr module */ @@ -334,27 +234,23 @@ struct switch_asr_interface { /*! the name of the interface */ const char *interface_name; /*! function to open the asr interface */ - switch_status_t (*asr_open)(switch_asr_handle_t *ah, - char *codec, - int rate, - char *dest, - switch_asr_flag_t *flags); + switch_status_t (*asr_open) (switch_asr_handle_t *ah, char *codec, int rate, char *dest, switch_asr_flag_t *flags); /*! function to load a grammar to the asr interface */ - switch_status_t (*asr_load_grammar)(switch_asr_handle_t *ah, char *grammar, char *path); + switch_status_t (*asr_load_grammar) (switch_asr_handle_t *ah, char *grammar, char *path); /*! function to unload a grammar to the asr interface */ - switch_status_t (*asr_unload_grammar)(switch_asr_handle_t *ah, char *grammar); + switch_status_t (*asr_unload_grammar) (switch_asr_handle_t *ah, char *grammar); /*! function to close the asr interface */ - switch_status_t (*asr_close)(switch_asr_handle_t *ah, switch_asr_flag_t *flags); - /*! function to feed audio to the ASR*/ - switch_status_t (*asr_feed)(switch_asr_handle_t *ah, void *data, unsigned int len, switch_asr_flag_t *flags); - /*! function to resume the ASR*/ - switch_status_t (*asr_resume)(switch_asr_handle_t *ah); - /*! function to pause the ASR*/ - switch_status_t (*asr_pause)(switch_asr_handle_t *ah); - /*! function to read results from the ASR*/ - switch_status_t (*asr_check_results)(switch_asr_handle_t *ah, switch_asr_flag_t *flags); - /*! function to read results from the ASR*/ - switch_status_t (*asr_get_results)(switch_asr_handle_t *ah, char **xmlstr, switch_asr_flag_t *flags); + switch_status_t (*asr_close) (switch_asr_handle_t *ah, switch_asr_flag_t *flags); + /*! function to feed audio to the ASR */ + switch_status_t (*asr_feed) (switch_asr_handle_t *ah, void *data, unsigned int len, switch_asr_flag_t *flags); + /*! function to resume the ASR */ + switch_status_t (*asr_resume) (switch_asr_handle_t *ah); + /*! function to pause the ASR */ + switch_status_t (*asr_pause) (switch_asr_handle_t *ah); + /*! function to read results from the ASR */ + switch_status_t (*asr_check_results) (switch_asr_handle_t *ah, switch_asr_flag_t *flags); + /*! function to read results from the ASR */ + switch_status_t (*asr_get_results) (switch_asr_handle_t *ah, char **xmlstr, switch_asr_flag_t *flags); const struct switch_asr_interface *next; }; @@ -364,11 +260,11 @@ struct switch_asr_handle { const switch_asr_interface_t *asr_interface; /*! flags to control behaviour */ uint32_t flags; - /*! The Name*/ + /*! The Name */ char *name; - /*! The Codec*/ + /*! The Codec */ char *codec; - /*! The Rate*/ + /*! The Rate */ uint32_t rate; char *grammar; /*! the handle's memory pool */ @@ -382,24 +278,20 @@ struct switch_speech_interface { /*! the name of the interface */ const char *interface_name; /*! function to open the speech interface */ - switch_status_t (*speech_open)(switch_speech_handle_t *sh, - char *voice_name, - int rate, - switch_speech_flag_t *flags); + switch_status_t (*speech_open) (switch_speech_handle_t *sh, + char *voice_name, int rate, switch_speech_flag_t *flags); /*! function to close the speech interface */ - switch_status_t (*speech_close)(switch_speech_handle_t *, switch_speech_flag_t *flags); - /*! function to feed audio to the ASR*/ - switch_status_t (*speech_feed_tts)(switch_speech_handle_t *sh, char *text, switch_speech_flag_t *flags); - /*! function to read audio from the TTS*/ - switch_status_t (*speech_read_tts)(switch_speech_handle_t *sh, - void *data, - switch_size_t *datalen, - uint32_t *rate, - switch_speech_flag_t *flags); - void (*speech_flush_tts)(switch_speech_handle_t *sh); - void (*speech_text_param_tts)(switch_speech_handle_t *sh, char *param, char *val); - void (*speech_numeric_param_tts)(switch_speech_handle_t *sh, char *param, int val); - void (*speech_float_param_tts)(switch_speech_handle_t *sh, char *param, double val); + switch_status_t (*speech_close) (switch_speech_handle_t *, switch_speech_flag_t *flags); + /*! function to feed audio to the ASR */ + switch_status_t (*speech_feed_tts) (switch_speech_handle_t *sh, char *text, switch_speech_flag_t *flags); + /*! function to read audio from the TTS */ + switch_status_t (*speech_read_tts) (switch_speech_handle_t *sh, + void *data, + switch_size_t *datalen, uint32_t * rate, switch_speech_flag_t *flags); + void (*speech_flush_tts) (switch_speech_handle_t *sh); + void (*speech_text_param_tts) (switch_speech_handle_t *sh, char *param, char *val); + void (*speech_numeric_param_tts) (switch_speech_handle_t *sh, char *param, int val); + void (*speech_float_param_tts) (switch_speech_handle_t *sh, char *param, double val); const struct switch_speech_interface *next; }; @@ -411,9 +303,9 @@ struct switch_speech_handle { const switch_speech_interface_t *speech_interface; /*! flags to control behaviour */ uint32_t flags; - /*! The Name*/ + /*! The Name */ char *name; - /*! The Rate*/ + /*! The Rate */ uint32_t rate; uint32_t speed; char voice[80]; @@ -429,7 +321,7 @@ struct switch_say_interface { /*! the name of the interface */ const char *interface_name; /*! function to pass down to the module */ - switch_say_callback_t say_function; + switch_say_callback_t say_function; const struct switch_say_interface *next; }; @@ -438,7 +330,7 @@ struct switch_chat_interface { /*! the name of the interface */ const char *interface_name; /*! function to open the directory interface */ - switch_status_t (*chat_send)(char *proto, char *from, char *to, char *subject, char *body, char *hint); + switch_status_t (*chat_send) (char *proto, char *from, char *to, char *subject, char *body, char *hint); const struct switch_chat_interface *next; }; @@ -447,7 +339,8 @@ struct switch_management_interface { /*! the name of the interface */ const char *relative_oid; /*! function to open the directory interface */ - switch_status_t (*management_function)(char *relative_oid, switch_management_action_t action, char *data, switch_size_t datalen); + switch_status_t (*management_function) (char *relative_oid, switch_management_action_t action, char *data, + switch_size_t datalen); const struct switch_management_interface *next; }; @@ -456,16 +349,16 @@ struct switch_directory_interface { /*! the name of the interface */ const char *interface_name; /*! function to open the directory interface */ - switch_status_t (*directory_open)(switch_directory_handle_t *dh, char *source, char *dsn, char *passwd); + switch_status_t (*directory_open) (switch_directory_handle_t *dh, char *source, char *dsn, char *passwd); /*! function to close the directory interface */ - switch_status_t (*directory_close)(switch_directory_handle_t *dh); + switch_status_t (*directory_close) (switch_directory_handle_t *dh); /*! function to query the directory interface */ - switch_status_t (*directory_query)(switch_directory_handle_t *dh, char *base, char *query); + switch_status_t (*directory_query) (switch_directory_handle_t *dh, char *base, char *query); /*! function to advance to the next record */ - switch_status_t (*directory_next)(switch_directory_handle_t *dh); + switch_status_t (*directory_next) (switch_directory_handle_t *dh); /*! function to advance to the next name/value pair in the current record */ - switch_status_t (*directory_next_pair)(switch_directory_handle_t *dh, char **var, char **val); - + switch_status_t (*directory_next_pair) (switch_directory_handle_t *dh, char **var, char **val); + const struct switch_directory_interface *next; }; @@ -534,7 +427,7 @@ struct switch_codec { switch_codec_settings_t codec_settings; /*! flags to modify behaviour */ uint32_t flags; - /*! the handle's memory pool*/ + /*! the handle's memory pool */ switch_memory_pool_t *memory_pool; /*! private data for the codec module to store handle specific info */ void *private_info; @@ -569,29 +462,25 @@ struct switch_codec_implementation { /*! max number of frames to send in one network packet */ int max_frames_per_packet; /*! function to initialize a codec handle using this implementation */ - switch_status_t (*init)(switch_codec_t *, switch_codec_flag_t, const switch_codec_settings_t *codec_settings); + switch_status_t (*init) (switch_codec_t *, switch_codec_flag_t, const switch_codec_settings_t *codec_settings); /*! function to encode raw data into encoded data */ - switch_status_t (*encode)(switch_codec_t *codec, - switch_codec_t *other_codec, - void *decoded_data, - uint32_t decoded_data_len, - uint32_t decoded_rate, - void *encoded_data, - uint32_t *encoded_data_len, - uint32_t *encoded_rate, - unsigned int *flag); + switch_status_t (*encode) (switch_codec_t *codec, + switch_codec_t *other_codec, + void *decoded_data, + uint32_t decoded_data_len, + uint32_t decoded_rate, + void *encoded_data, + uint32_t * encoded_data_len, uint32_t * encoded_rate, unsigned int *flag); /*! function to decode encoded data into raw data */ - switch_status_t (*decode)(switch_codec_t *codec, - switch_codec_t *other_codec, - void *encoded_data, - uint32_t encoded_data_len, - uint32_t encoded_rate, - void *decoded_data, - uint32_t *decoded_data_len, - uint32_t *decoded_rate, - unsigned int *flag); + switch_status_t (*decode) (switch_codec_t *codec, + switch_codec_t *other_codec, + void *encoded_data, + uint32_t encoded_data_len, + uint32_t encoded_rate, + void *decoded_data, + uint32_t * decoded_data_len, uint32_t * decoded_rate, unsigned int *flag); /*! deinitalize a codec handle using this implementation */ - switch_status_t (*destroy)(switch_codec_t *); + switch_status_t (*destroy) (switch_codec_t *); const struct switch_codec_implementation *next; }; @@ -635,9 +524,7 @@ struct switch_api_interface { }; SWITCH_END_EXTERN_C - #endif - /* For Emacs: * Local Variables: * mode:c diff --git a/src/include/switch_platform.h b/src/include/switch_platform.h index 2fbd5da16f..f8a50ad7d3 100644 --- a/src/include/switch_platform.h +++ b/src/include/switch_platform.h @@ -35,23 +35,17 @@ #define SWITCH_PLATFORM_H SWITCH_BEGIN_EXTERN_C - #ifdef __ICC #pragma warning (disable:810 869 981 279 1469 188) #endif - #include - +#define SWITCH_VA_NONE "%s", "" #ifdef _MSC_VER #define __SWITCH_FUNC__ __FUNCTION__ #else #define __SWITCH_FUNC__ (const char *)__func__ #endif - - #ifdef _MSC_VER - - /* disable the following warnings * C4100: The formal parameter is not referenced in the body of the function. The unreferenced parameter is ignored. * C4200: Non standard extension C zero sized array @@ -64,8 +58,7 @@ SWITCH_BEGIN_EXTERN_C * C4610: struct can never be instantiated - user defined constructor required */ #pragma warning(disable:4100 4200 4204 4706 4819 4132 4510 4512 4610 4996) - -#if (_MSC_VER >= 1400) // VC8+ +#if (_MSC_VER >= 1400) // VC8+ #ifndef _CRT_SECURE_NO_DEPRECATE #define _CRT_SECURE_NO_DEPRECATE #endif @@ -73,30 +66,27 @@ SWITCH_BEGIN_EXTERN_C #define _CRT_NONSTDC_NO_DEPRECATE #endif #endif // VC8+ - #if _MSC_VER < 1300 #ifndef __FUNCTION__ #define __FUNCTION__ "" #endif #endif - #undef inline #define inline __inline - #ifndef uint32_t -typedef unsigned __int8 uint8_t; -typedef unsigned __int16 uint16_t; -typedef unsigned __int32 uint32_t; -typedef unsigned __int64 uint64_t; -typedef __int8 int8_t; -typedef __int16 int16_t; -typedef __int32 int32_t; -typedef __int64 int64_t; -typedef unsigned long in_addr_t; +typedef unsigned __int8 uint8_t; +typedef unsigned __int16 uint16_t; +typedef unsigned __int32 uint32_t; +typedef unsigned __int64 uint64_t; +typedef __int8 int8_t; +typedef __int16 int16_t; +typedef __int32 int32_t; +typedef __int64 int64_t; +typedef unsigned long in_addr_t; #endif -typedef int pid_t; -typedef int uid_t; -typedef int gid_t; +typedef int pid_t; +typedef int uid_t; +typedef int gid_t; #define PACKED #include #define strcasecmp(s1, s2) stricmp(s1, s2) @@ -116,7 +106,6 @@ typedef int gid_t; #include #include #endif // _MSC_VER - #ifndef __LITTLE_ENDIAN #define __LITTLE_ENDIAN 1234 #endif @@ -130,9 +119,7 @@ typedef int gid_t; #define __BYTE_ORDER __LITTLE_ENDIAN #endif #endif - #ifdef WIN32 - #if defined(SWITCH_CORE_DECLARE_STATIC) #define SWITCH_DECLARE(type) type __stdcall #define SWITCH_DECLARE_NONSTD(type) type __cdecl @@ -146,7 +133,6 @@ typedef int gid_t; #define SWITCH_DECLARE_NONSTD(type) __declspec(dllimport) type __cdecl #define SWITCH_DECLARE_DATA __declspec(dllimport) #endif - #if defined(SWITCH_MOD_DECLARE_STATIC) #define SWITCH_MOD_DECLARE(type) type __cdecl #elif defined(MOD_EXPORTS) @@ -169,35 +155,32 @@ typedef int gid_t; #define SWITCH_DECLARE_DATA #define SWITCH_THREAD_FUNC #endif - #ifdef DOXYGEN #define DoxyDefine(x) x #else #define DoxyDefine(x) #endif - #if __GNUC__ >= 3 #define PRINTF_FUNCTION(fmtstr,vars) __attribute__((format(printf,fmtstr,vars))) #else #define PRINTF_FUNCTION(fmtstr,vars) #endif - #ifdef SWITCH_INT32 -typedef SWITCH_INT32 switch_int32_t; + typedef SWITCH_INT32 switch_int32_t; #else -typedef int32_t switch_int32_t; + typedef int32_t switch_int32_t; #endif #ifdef SWITCH_SIZE_T -typedef SWITCH_SIZE_T switch_size_t; +typedef SWITCH_SIZE_T switch_size_t; #else -typedef uintptr_t switch_size_t; +typedef uintptr_t switch_size_t; #endif #ifdef SWITCH_SSIZE_T -typedef SWITCH_SSIZE_T switch_ssize_t; +typedef SWITCH_SSIZE_T switch_ssize_t; #else -typedef intptr_t switch_ssize_t; +typedef intptr_t switch_ssize_t; #endif #ifdef WIN32 @@ -245,7 +228,6 @@ typedef intptr_t switch_ssize_t; #define SWITCH_TIME_T_FMT SWITCH_INT64_T_FMT SWITCH_END_EXTERN_C - /* these includes must be outside the extern "C" block on windows or it will break compatibility with c++ modules*/ #ifdef WIN32 /* Has windows.h already been included? If so, our preferences don't matter, @@ -257,7 +239,6 @@ SWITCH_END_EXTERN_C #define WIN32_LEAN_AND_MEAN #endif #ifndef _WIN32_WINNT - /* Restrict the server to a subset of Windows NT 4.0 header files by default */ #define _WIN32_WINNT 0x0400 @@ -288,19 +269,13 @@ SWITCH_END_EXTERN_C #endif /* !_WINDOWS_ */ #include #endif - #endif - - #ifndef FALSE #define FALSE 0 #endif #ifndef TRUE #define TRUE (!FALSE) #endif - - - /* For Emacs: * Local Variables: * mode:c diff --git a/src/include/switch_regex.h b/src/include/switch_regex.h index f4e0d6c478..3bc6216d4e 100644 --- a/src/include/switch_regex.h +++ b/src/include/switch_regex.h @@ -35,32 +35,28 @@ #define SWITCH_REGEX_H SWITCH_BEGIN_EXTERN_C - /** * @defgroup switch_regex * @ingroup FREESWITCH * @{ */ - -typedef struct real_pcre switch_regex_t; + typedef struct real_pcre switch_regex_t; SWITCH_DECLARE(switch_regex_t *) switch_regex_compile(const char *pattern, int options, const char **errorptr, - int *erroroffset, - const unsigned char *tables); + int *erroroffset, const unsigned char *tables); SWITCH_DECLARE(int) switch_regex_copy_substring(const char *subject, int *ovector, - int stringcount, - int stringnumber, - char *buffer, - int size); + int stringcount, int stringnumber, char *buffer, int size); 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(void) switch_perform_substitution(switch_regex_t *re, int match_count, char *data, char *field_data, char *substituted, uint32_t len, int *ovector); +SWITCH_DECLARE(int) switch_regex_perform(char *field, 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, + char *substituted, uint32_t len, int *ovector); /*! \brief Function to evaluate an expression against a string @@ -78,9 +74,7 @@ SWITCH_DECLARE(switch_status_t) switch_regex_match(char *target, char *expressio /** @} */ SWITCH_END_EXTERN_C - #endif - /* For Emacs: * Local Variables: * mode:c diff --git a/src/include/switch_resample.h b/src/include/switch_resample.h index d2ba8a42bb..cf9e98a8be 100644 --- a/src/include/switch_resample.h +++ b/src/include/switch_resample.h @@ -45,15 +45,13 @@ #include SWITCH_BEGIN_EXTERN_C - /*! \defgroup resamp Audio Resample Functions \ingroup core1 \{ */ - /*! \brief An audio resampling handle */ -typedef struct { + typedef struct { /*! a pointer to store the resampler object */ void *resampler; /*! the rate to resample from in hz */ @@ -87,11 +85,9 @@ typedef struct { \return SWITCH_STATUS_SUCCESS if the handle was created */ SWITCH_DECLARE(switch_status_t) switch_resample_create(switch_audio_resampler_t **new_resampler, - int from_rate, - switch_size_t from_size, - int to_rate, - uint32_t to_size, - switch_memory_pool_t *pool); + int from_rate, + switch_size_t from_size, + int to_rate, uint32_t to_size, switch_memory_pool_t *pool); /*! \brief Destroy an existing resampler handle @@ -109,7 +105,8 @@ SWITCH_DECLARE(void) switch_resample_destroy(switch_audio_resampler_t *resampler \param last parameter denoting the last sample is being resampled \return the used size of dst */ -SWITCH_DECLARE(uint32_t) switch_resample_process(switch_audio_resampler_t *resampler, float *src, int srclen, float *dst, uint32_t dstlen, int last); +SWITCH_DECLARE(uint32_t) switch_resample_process(switch_audio_resampler_t *resampler, float *src, int srclen, + float *dst, uint32_t dstlen, int last); /*! \brief Convert an array of floats to an array of shorts @@ -172,9 +169,7 @@ SWITCH_DECLARE(void) switch_change_sln_volume(int16_t *data, uint32_t samples, i ///\} SWITCH_END_EXTERN_C - #endif - /* For Emacs: * Local Variables: * mode:c diff --git a/src/include/switch_rtp.h b/src/include/switch_rtp.h index 0a9f293b81..7f3330a2a4 100644 --- a/src/include/switch_rtp.h +++ b/src/include/switch_rtp.h @@ -39,17 +39,13 @@ #define SWITCH_RTP_H SWITCH_BEGIN_EXTERN_C - #define SWITCH_RTP_MAX_BUF_LEN 16384 - ///\defgroup rtp RTP (RealTime Transport Protocol) ///\ingroup core1 ///\{ -typedef void (*switch_rtp_invalid_handler_t)(switch_rtp_t *rtp_session, - switch_socket_t *sock, - void *data, - switch_size_t datalen, - switch_sockaddr_t *from_addr); +typedef void (*switch_rtp_invalid_handler_t) (switch_rtp_t *rtp_session, + switch_socket_t *sock, + void *data, switch_size_t datalen, switch_sockaddr_t *from_addr); /*! \brief Initilize the RTP System @@ -77,15 +73,13 @@ SWITCH_DECLARE(switch_port_t) switch_rtp_request_port(void); \param pool a memory pool to use for the session \return the new RTP session or NULL on failure */ -SWITCH_DECLARE(switch_status_t)switch_rtp_create(switch_rtp_t **new_rtp_session, - switch_payload_t payload, - uint32_t samples_per_interval, - uint32_t ms_per_packet, - switch_rtp_flag_t flags, - char *crypto_key, - char *timer_name, - const char **err, - switch_memory_pool_t *pool); +SWITCH_DECLARE(switch_status_t) switch_rtp_create(switch_rtp_t **new_rtp_session, + switch_payload_t payload, + uint32_t samples_per_interval, + uint32_t ms_per_packet, + switch_rtp_flag_t flags, + char *crypto_key, + char *timer_name, const char **err, switch_memory_pool_t *pool); /*! @@ -104,18 +98,16 @@ SWITCH_DECLARE(switch_status_t)switch_rtp_create(switch_rtp_t **new_rtp_session, \param pool a memory pool to use for the session \return the new RTP session or NULL on failure */ -SWITCH_DECLARE(switch_rtp_t *)switch_rtp_new(char *rx_host, - switch_port_t rx_port, - char *tx_host, - switch_port_t tx_port, - switch_payload_t payload, - uint32_t samples_per_interval, - uint32_t ms_per_packet, - switch_rtp_flag_t flags, - char *crypto_key, - char *timer_name, - const char **err, - switch_memory_pool_t *pool); +SWITCH_DECLARE(switch_rtp_t *) switch_rtp_new(char *rx_host, + switch_port_t rx_port, + char *tx_host, + switch_port_t tx_port, + switch_payload_t payload, + uint32_t samples_per_interval, + uint32_t ms_per_packet, + switch_rtp_flag_t flags, + char *crypto_key, + char *timer_name, const char **err, switch_memory_pool_t *pool); /*! @@ -125,7 +117,8 @@ SWITCH_DECLARE(switch_rtp_t *)switch_rtp_new(char *rx_host, \param port the remote port \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, char *host, switch_port_t port, + const char **err); /*! \brief Assign a local address to the RTP session @@ -135,7 +128,8 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_set_remote_address(switch_rtp_t *rtp_ \param err pointer for error messages \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, char *host, switch_port_t port, + const char **err); /*! \brief Kill the socket on an existing RTP session @@ -189,14 +183,15 @@ SWITCH_DECLARE(void) switch_rtp_clear_flag(switch_rtp_t *rtp_session, switch_rtp \param rtp_session the RTP session to retrieve the socket from \return the socket from the RTP session */ -SWITCH_DECLARE(switch_socket_t *)switch_rtp_get_rtp_socket(switch_rtp_t *rtp_session); +SWITCH_DECLARE(switch_socket_t *) switch_rtp_get_rtp_socket(switch_rtp_t *rtp_session); /*! \brief Set the default samples per interval for a given RTP session \param rtp_session the RTP session to set the samples per interval on \param samples_per_interval the new default samples per interval */ -SWITCH_DECLARE(void) switch_rtp_set_default_samples_per_interval(switch_rtp_t *rtp_session, uint16_t samples_per_interval); +SWITCH_DECLARE(void) switch_rtp_set_default_samples_per_interval(switch_rtp_t *rtp_session, + uint16_t samples_per_interval); /*! \brief Get the default samples per interval for a given RTP session @@ -237,7 +232,8 @@ SWITCH_DECLARE(void) switch_rtp_set_invald_handler(switch_rtp_t *rtp_session, sw \param flags flags \return the number of bytes read */ -SWITCH_DECLARE(switch_status_t) switch_rtp_read(switch_rtp_t *rtp_session, void *data, uint32_t *datalen, switch_payload_t *payload_type, switch_frame_flag_t *flags); +SWITCH_DECLARE(switch_status_t) switch_rtp_read(switch_rtp_t *rtp_session, void *data, uint32_t * datalen, + switch_payload_t *payload_type, switch_frame_flag_t *flags); /*! \brief Queue RFC2833 DTMF data into an RTP Session @@ -282,9 +278,8 @@ SWITCH_DECLARE(switch_size_t) switch_rtp_dequeue_dtmf(switch_rtp_t *rtp_session, */ SWITCH_DECLARE(switch_status_t) switch_rtp_zerocopy_read(switch_rtp_t *rtp_session, void **data, - uint32_t *datalen, - switch_payload_t *payload_type, - switch_frame_flag_t *flags); + uint32_t * datalen, + switch_payload_t *payload_type, switch_frame_flag_t *flags); /*! \brief Read data from a given RTP session without copying @@ -303,7 +298,8 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_zerocopy_read_frame(switch_rtp_t *rtp \param flags frame flags \return the number of bytes written */ -SWITCH_DECLARE(int) switch_rtp_write(switch_rtp_t *rtp_session, void *data, uint32_t datalen, uint32_t ts, switch_frame_flag_t *flags); +SWITCH_DECLARE(int) switch_rtp_write(switch_rtp_t *rtp_session, void *data, uint32_t datalen, uint32_t ts, + switch_frame_flag_t *flags); /*! \brief Enable VAD on an RTP Session @@ -313,7 +309,8 @@ SWITCH_DECLARE(int) switch_rtp_write(switch_rtp_t *rtp_session, void *data, uint \param flags flags for control \return SWITCH_STAUTS_SUCCESS on success */ -SWITCH_DECLARE(switch_status_t) switch_rtp_enable_vad(switch_rtp_t *rtp_session, switch_core_session_t *session, switch_codec_t *codec, switch_vad_flag_t flags); +SWITCH_DECLARE(switch_status_t) switch_rtp_enable_vad(switch_rtp_t *rtp_session, switch_core_session_t *session, + switch_codec_t *codec, switch_vad_flag_t flags); /*! \brief Disable VAD on an RTP Session @@ -349,10 +346,7 @@ SWITCH_DECLARE(int) switch_rtp_write_manual(switch_rtp_t *rtp_session, uint16_t datalen, uint8_t m, switch_payload_t payload, - uint32_t ts, - uint16_t mseq, - uint32_t ssrc, - switch_frame_flag_t *flags); + uint32_t ts, uint16_t mseq, uint32_t ssrc, switch_frame_flag_t *flags); /*! \brief Retrieve the SSRC from a given RTP session @@ -387,16 +381,14 @@ SWITCH_DECLARE(void) switch_rtp_set_cng_pt(switch_rtp_t *rtp_session, switch_pay \param rtp_session the RTP session to retrieve the data from \return the pointer to the private data */ -SWITCH_DECLARE(void *)switch_rtp_get_private(switch_rtp_t *rtp_session); +SWITCH_DECLARE(void *) switch_rtp_get_private(switch_rtp_t *rtp_session); /*! \} */ SWITCH_END_EXTERN_C - #endif - /* For Emacs: * Local Variables: * mode:c diff --git a/src/include/switch_sqlite.h b/src/include/switch_sqlite.h index e547f5f566..966c164908 100644 --- a/src/include/switch_sqlite.h +++ b/src/include/switch_sqlite.h @@ -36,26 +36,22 @@ #define SWITCH_SQLITE_H SWITCH_BEGIN_EXTERN_C - #include - /** * @defgroup switch_sqlite_top Brought To You By SQLite * @ingroup FREESWITCH * @{ */ - /** * @defgroup switch_sqlite Database Routines * @ingroup switch_sqlite_top * @{ */ - /** * Each open sqlite database is represented by an instance of the * following opaque structure. */ -typedef sqlite3 switch_core_db_t; + typedef sqlite3 switch_core_db_t; typedef sqlite3_stmt switch_core_db_stmt_t; /** * Aggregate functions use the following routine to allocate @@ -67,17 +63,15 @@ typedef sqlite3_stmt switch_core_db_stmt_t; * * The buffer allocated is freed automatically by SQLite. */ -DoxyDefine(void *switch_core_db_aggregate_context(sqlite3_context*, int nBytes);) +DoxyDefine(void *switch_core_db_aggregate_context(sqlite3_context *, int nBytes);) #define switch_core_db_aggregate_context sqlite3_aggregate_context - /** * /return the number of calls to xStep for a particular * aggregate function instance. The current call to xStep counts so this * routine always returns at least 1. */ -DoxyDefine(int switch_core_db_aggregate_count(sqlite3_context*);) +DoxyDefine(int switch_core_db_aggregate_count(sqlite3_context *);) #define switch_core_db_aggregate_count sqlite3_aggregate_count - /** * In the SQL strings input to switch_core_db_prepare(), * one or more literals can be replace by parameters "?" or ":AAA" or @@ -106,9 +100,8 @@ DoxyDefine(int switch_core_db_aggregate_count(sqlite3_context*);) * an switch_core_db_prepare() or sqlite3_reset(). Unbound parameterss are * interpreted as NULL. */ -DoxyDefine(int switch_core_db_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*));) +DoxyDefine(int switch_core_db_bind_blob(sqlite3_stmt *, int, const void *, int n, void (*)(void *));) #define switch_core_db_bind_blob sqlite3_bind_blob - /** * In the SQL strings input to switch_core_db_prepare(), * one or more literals can be replace by parameters "?" or ":AAA" or @@ -129,9 +122,8 @@ DoxyDefine(int switch_core_db_bind_blob(sqlite3_stmt*, int, const void*, int n, * an switch_core_db_prepare() or sqlite3_reset(). Unbound parameterss are * interpreted as NULL. */ -DoxyDefine(int switch_core_db_bind_double(sqlite3_stmt*, int, double);) +DoxyDefine(int switch_core_db_bind_double(sqlite3_stmt *, int, double);) #define switch_core_db_bind_double sqlite3_bind_double - /** * In the SQL strings input to switch_core_db_prepare(), * one or more literals can be replace by parameters "?" or ":AAA" or @@ -152,9 +144,8 @@ DoxyDefine(int switch_core_db_bind_double(sqlite3_stmt*, int, double);) * an switch_core_db_prepare() or sqlite3_reset(). Unbound parameterss are * interpreted as NULL. */ -DoxyDefine(int switch_core_db_bind_int(sqlite3_stmt*, int, int);) +DoxyDefine(int switch_core_db_bind_int(sqlite3_stmt *, int, int);) #define switch_core_db_bind_int sqlite3_bind_int - /** * In the SQL strings input to switch_core_db_prepare(), * one or more literals can be replace by parameters "?" or ":AAA" or @@ -175,9 +166,8 @@ DoxyDefine(int switch_core_db_bind_int(sqlite3_stmt*, int, int);) * an switch_core_db_prepare() or sqlite3_reset(). Unbound parameterss are * interpreted as NULL. */ -DoxyDefine(int switch_core_db_bind_int64(sqlite3_stmt*, int, sqlite_int64);) +DoxyDefine(int switch_core_db_bind_int64(sqlite3_stmt *, int, sqlite_int64);) #define switch_core_db_bind_int64 sqlite3_bind_int64 - /** * In the SQL strings input to switch_core_db_prepare(), * one or more literals can be replace by parameters "?" or ":AAA" or @@ -198,9 +188,8 @@ DoxyDefine(int switch_core_db_bind_int64(sqlite3_stmt*, int, sqlite_int64);) * an switch_core_db_prepare() or sqlite3_reset(). Unbound parameterss are * interpreted as NULL. */ -DoxyDefine(int switch_core_db_bind_null(sqlite3_stmt*, int);) +DoxyDefine(int switch_core_db_bind_null(sqlite3_stmt *, int);) #define switch_core_db_bind_null sqlite3_bind_null - /** * In the SQL strings input to switch_core_db_prepare(), * one or more literals can be replace by parameters "?" or ":AAA" or @@ -229,9 +218,8 @@ DoxyDefine(int switch_core_db_bind_null(sqlite3_stmt*, int);) * an switch_core_db_prepare() or sqlite3_reset(). Unbound parameterss are * interpreted as NULL. */ -DoxyDefine(int switch_core_db_bind_text(sqlite3_stmt*, int, const char*, int n, void(*)(void*));) +DoxyDefine(int switch_core_db_bind_text(sqlite3_stmt *, int, const char *, int n, void (*)(void *));) #define switch_core_db_bind_text sqlite3_bind_text - /** * In the SQL strings input to switch_core_db_prepare(), * one or more literals can be replace by parameters "?" or ":AAA" or @@ -260,9 +248,8 @@ DoxyDefine(int switch_core_db_bind_text(sqlite3_stmt*, int, const char*, int n, * an switch_core_db_prepare() or sqlite3_reset(). Unbound parameterss are * interpreted as NULL. */ -DoxyDefine(int switch_core_db_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*));) +DoxyDefine(int switch_core_db_bind_text16(sqlite3_stmt *, int, const void *, int, void (*)(void *));) #define switch_core_db_bind_text16 sqlite3_bind_text16 - /** * In the SQL strings input to switch_core_db_prepare(), * one or more literals can be replace by parameters "?" or ":AAA" or @@ -283,24 +270,21 @@ DoxyDefine(int switch_core_db_bind_text16(sqlite3_stmt*, int, const void*, int, * an switch_core_db_prepare() or sqlite3_reset(). Unbound parameterss are * interpreted as NULL. */ -DoxyDefine(int switch_core_db_bind_value(sqlite3_stmt*, int, const sqlite3_value*);) +DoxyDefine(int switch_core_db_bind_value(sqlite3_stmt *, int, const sqlite3_value *);) #define switch_core_db_bind_value sqlite3_bind_value - /** * @return The number of parameters in a compiled SQL statement. * @remark This routine was added to support DBD::SQLite. */ -DoxyDefine(int switch_core_db_bind_parameter_count(sqlite3_stmt*);) +DoxyDefine(int switch_core_db_bind_parameter_count(sqlite3_stmt *);) #define switch_core_db_bind_parameter_count sqlite3_bind_parameter_count - /** * @return the index of a parameter with the given name. If no parameter with the * given name is found, return 0. * @remark The name must match exactly. */ -DoxyDefine(int switch_core_db_bind_parameter_index(sqlite3_stmt*, const char *zName);) +DoxyDefine(int switch_core_db_bind_parameter_index(sqlite3_stmt *, const char *zName);) #define switch_core_db_bind_parameter_index sqlite3_bind_parameter_index - /** * @return the name of the i-th parameter. * @remark Ordinary parameters "?" are @@ -308,9 +292,8 @@ DoxyDefine(int switch_core_db_bind_parameter_index(sqlite3_stmt*, const char *zN * $VVV the complete text of the parameter name is returned, including * the initial ":" or "$". NULL is returned if the index is out of range. */ -DoxyDefine(const char *switch_core_db_bind_parameter_name(sqlite3_stmt*, int);) +DoxyDefine(const char *switch_core_db_bind_parameter_name(sqlite3_stmt *, int);) #define switch_core_db_bind_parameter_name sqlite3_bind_parameter_name - /** * This routine identifies a callback function that is invoked * whenever an attempt is made to open a database table that is @@ -333,9 +316,8 @@ DoxyDefine(const char *switch_core_db_bind_parameter_name(sqlite3_stmt*, int);) * data structures out from under the executing query and will * probably result in a coredump. */ -DoxyDefine(int switch_core_db_busy_handler(switch_core_db*, int(*)(void*,int), void*);) +DoxyDefine(int switch_core_db_busy_handler(switch_core_db *, int (*)(void *, int), void *);) #define switch_core_db_busy_handler sqlite3_busy_handler - /** * This routine sets a busy handler that sleeps for a while when a * table is locked. The handler will sleep multiple times until @@ -346,9 +328,8 @@ DoxyDefine(int switch_core_db_busy_handler(switch_core_db*, int(*)(void*,int), v * Calling this routine with an argument less than or equal to zero * turns off all busy handlers. */ -DoxyDefine(int switch_core_db_busy_timeout(switch_core_db*, int ms);) +DoxyDefine(int switch_core_db_busy_timeout(switch_core_db *, int ms);) #define switch_core_db_busy_timeout sqlite3_busy_timeout - /** * This function returns the number of database rows that were changed * (or inserted or deleted) by the most recent called sqlite3_exec(). @@ -369,9 +350,8 @@ DoxyDefine(int switch_core_db_busy_timeout(switch_core_db*, int ms);) * table. To get an accurate count of the number of rows deleted, use * "DELETE FROM table WHERE 1" instead. */ -DoxyDefine(int switch_core_db_changes(switch_core_db*);) +DoxyDefine(int switch_core_db_changes(switch_core_db *);) #define switch_core_db_changes sqlite3_changes - /** * A function to close the database. * @@ -385,7 +365,6 @@ DoxyDefine(int switch_core_db_changes(switch_core_db*);) */ DoxyDefine(int switch_core_db_close(switch_core_db *);) #define switch_core_db_close sqlite3_close - /** * To avoid having to register all collation sequences before a database * can be used, a single callback function may be registered with the @@ -405,13 +384,10 @@ DoxyDefine(int switch_core_db_close(switch_core_db *);) * The collation sequence is returned to SQLite by a collation-needed * callback using the sqlite3_create_collation() API, described above. */ -DoxyDefine(int switch_core_db_collation_needed( - switch_core_db*, - void*, - void(*)(void*,switch_core_db*,int eTextRep,const char*) -);) +DoxyDefine(int switch_core_db_collation_needed(switch_core_db *, + void *, void (*)(void *, switch_core_db *, int eTextRep, const char *) + );) #define switch_core_db_collation_needed sqlite3_collation_needed - /** * The next group of routines returns information about the information * in a single column of the current result row of a query. @@ -453,9 +429,8 @@ DoxyDefine(int switch_core_db_collation_needed( * * @return the value of a BLOB. */ -DoxyDefine(const void *switch_core_db_column_blob(sqlite3_stmt *stmt, int iCol);) +DoxyDefine(const void *switch_core_db_column_blob(sqlite3_stmt * stmt, int iCol);) #define switch_core_db_column_blob sqlite3_column_blob - /** * The next group of routines returns information about the information * in a single column of the current result row of a query. In every @@ -497,9 +472,8 @@ DoxyDefine(const void *switch_core_db_column_blob(sqlite3_stmt *stmt, int iCol); * TEXT value represented as UTF-8. The "\000" terminator is included in the * byte count for TEXT values. */ -DoxyDefine(int switch_core_db_column_bytes(sqlite3_stmt*, int iCol);) +DoxyDefine(int switch_core_db_column_bytes(sqlite3_stmt *, int iCol);) #define switch_core_db_column_bytes sqlite3_column_bytes - /** * The next group of routines returns information about the information * in a single column of the current result row of a query. In every @@ -541,9 +515,8 @@ DoxyDefine(int switch_core_db_column_bytes(sqlite3_stmt*, int iCol);) * TEXT value represented as UTF-16. The "\u0000" terminator is included in * the byte count for TEXT values. */ -DoxyDefine(int switch_core_db_column_bytes16(sqlite3_stmt*, int iCol);) +DoxyDefine(int switch_core_db_column_bytes16(sqlite3_stmt *, int iCol);) #define switch_core_db_column_bytes16 sqlite3_column_bytes16 - /** * The next group of routines returns information about the information * in a single column of the current result row of a query. In every @@ -583,9 +556,8 @@ DoxyDefine(int switch_core_db_column_bytes16(sqlite3_stmt*, int iCol);) * * Return a FLOAT value. */ -DoxyDefine(double switch_core_db_column_double(sqlite3_stmt*, int iCol);) +DoxyDefine(double switch_core_db_column_double(sqlite3_stmt *, int iCol);) #define switch_core_db_column_double sqlite3_column_double - /** * The next group of routines returns information about the information * in a single column of the current result row of a query. In every @@ -626,9 +598,8 @@ DoxyDefine(double switch_core_db_column_double(sqlite3_stmt*, int iCol);) * Return an INTEGER value in the host computer's native integer representation. * This might be either a 32- or 64-bit integer depending on the host. */ -DoxyDefine(int switch_core_db_column_int(sqlite3_stmt*, int iCol);) +DoxyDefine(int switch_core_db_column_int(sqlite3_stmt *, int iCol);) #define switch_core_db_column_int sqlite3_column_int - /** * The next group of routines returns information about the information * in a single column of the current result row of a query. In every @@ -668,9 +639,8 @@ DoxyDefine(int switch_core_db_column_int(sqlite3_stmt*, int iCol);) * * Return an INTEGER value as a 64-bit signed integer. */ -DoxyDefine(sqlite_int64 switch_core_db_column_int64(sqlite3_stmt*, int iCol);) + DoxyDefine(sqlite_int64 switch_core_db_column_int64(sqlite3_stmt *, int iCol);) #define switch_core_db_column_int64 sqlite3_column_int64 - /** * The next group of routines returns information about the information * in a single column of the current result row of a query. In every @@ -710,9 +680,8 @@ DoxyDefine(sqlite_int64 switch_core_db_column_int64(sqlite3_stmt*, int iCol);) * * Return the value as UTF-8 text. */ -DoxyDefine(const unsigned char *switch_core_db_column_text(sqlite3_stmt*, int iCol);) +DoxyDefine(const unsigned char *switch_core_db_column_text(sqlite3_stmt *, int iCol);) #define switch_core_db_column_text sqlite3_column_text - /** * The next group of routines returns information about the information * in a single column of the current result row of a query. In every @@ -752,9 +721,8 @@ DoxyDefine(const unsigned char *switch_core_db_column_text(sqlite3_stmt*, int iC * * Return the value as UTF-16 text. */ -DoxyDefine(const void *switch_core_db_column_text16(sqlite3_stmt*, int iCol);) +DoxyDefine(const void *switch_core_db_column_text16(sqlite3_stmt *, int iCol);) #define switch_core_db_column_text16 sqlite3_column_text16 - /** * The next group of routines returns information about the information * in a single column of the current result row of a query. In every @@ -795,25 +763,22 @@ DoxyDefine(const void *switch_core_db_column_text16(sqlite3_stmt*, int iCol);) * ReturnS the datatype of the result. This is one of * SQLITE_INTEGER, SQLITE_FLOAT, SQLITE_TEXT, SQLITE_BLOB, or SQLITE_NULL. */ -DoxyDefine(int switch_core_db_column_type(sqlite3_stmt*, int iCol);) +DoxyDefine(int switch_core_db_column_type(sqlite3_stmt *, int iCol);) #define switch_core_db_column_type sqlite3_column_type - /** * The first parameter is a compiled SQL statement. This function returns * the column heading for the Nth column of that statement, where N is the * second function parameter. The string returned is UTF-8. */ -DoxyDefine(const char *switch_core_db_column_name(sqlite3_stmt*,int);) +DoxyDefine(const char *switch_core_db_column_name(sqlite3_stmt *, int);) #define switch_core_db_column_name sqlite3_column_name - /** * Return the number of columns in the result set returned by the compiled * SQL statement. This routine returns 0 if pStmt is an SQL statement * that does not return data (for example an UPDATE). */ -DoxyDefine(int switch_core_db_column_count(sqlite3_stmt *pStmt);) +DoxyDefine(int switch_core_db_column_count(sqlite3_stmt * pStmt);) #define switch_core_db_column_count sqlite3_column_count - /** * The first parameter is a compiled SQL statement. If this statement * is a SELECT statement, the Nth column of the returned result set @@ -834,7 +799,6 @@ DoxyDefine(int switch_core_db_column_count(sqlite3_stmt *pStmt);) */ DoxyDefine(const char *switch_core_db_column_decltype(sqlite3_stmt *, int i);) #define switch_core_db_column_decltype sqlite3_column_decltype - /** * The first parameter is a compiled SQL statement. If this statement * is a SELECT statement, the Nth column of the returned result set @@ -853,9 +817,8 @@ DoxyDefine(const char *switch_core_db_column_decltype(sqlite3_stmt *, int i);) * result column (i==1), and a NULL pointer for the first result column * (i==0). */ -DoxyDefine(const void *switch_core_db_column_decltype16(sqlite3_stmt*,int);) +DoxyDefine(const void *switch_core_db_column_decltype16(sqlite3_stmt *, int);) #define switch_core_db_column_decltype16 sqlite3_column_decltype16 - /** * Register a callback function to be invoked whenever a new transaction * is committed. The pArg argument is passed through to the callback. @@ -869,9 +832,8 @@ DoxyDefine(const void *switch_core_db_column_decltype16(sqlite3_stmt*,int);) * ****** THIS IS AN EXPERIMENTAL API AND IS SUBJECT TO CHANGE ****** */ -DoxyDefine(void *switch_core_db_commit_hook(switch_core_db*, int(*)(void*), void*);) +DoxyDefine(void *switch_core_db_commit_hook(switch_core_db *, int (*)(void *), void *);) #define switch_core_db_commit_hook sqlite3_commit_hook - /** * This functions return true if the given input string comprises * one or more complete SQL statements. The parameter must be a nul-terminated @@ -883,7 +845,6 @@ DoxyDefine(void *switch_core_db_commit_hook(switch_core_db*, int(*)(void*), void */ DoxyDefine(int switch_core_db_complete(const char *sql);) #define switch_core_db_complete sqlite3_complete - /** * This function is used to add new collation sequences to the * sqlite3 handle specified as the first argument. @@ -909,15 +870,12 @@ DoxyDefine(int switch_core_db_complete(const char *sql);) * the first string is less than, equal to, or greater than the second * string. i.e. (STRING1 - STRING2). */ -DoxyDefine(int switch_core_db_create_collation( - switch_core_db*, - const char *zName, - int eTextRep, - void*, - int(*xCompare)(void*,int,const void*,int,const void*) -);) +DoxyDefine(int switch_core_db_create_collation(switch_core_db *, + const char *zName, + int eTextRep, + void *, int (*xCompare) (void *, int, const void *, int, const void *) + );) #define switch_core_db_create_collation sqlite3_create_collation - /** * The following function is used to add user functions or aggregates * implemented in C to the SQL langauge interpreted by SQLite. The @@ -951,18 +909,16 @@ DoxyDefine(int switch_core_db_create_collation( * xFunc and an xFinal, or an xStep but no xFinal, SQLITE_ERROR is * returned. */ -DoxyDefine(int switch_core_db_create_function( - switch_core_db *, - const char *zFunctionName, - int nArg, - int eTextRep, - void*, - void (*xFunc)(sqlite3_context*,int,sqlite3_value**), - void (*xStep)(sqlite3_context*,int,sqlite3_value**), - void (*xFinal)(sqlite3_context*) -);) +DoxyDefine(int switch_core_db_create_function(switch_core_db *, + const char *zFunctionName, + int nArg, + int eTextRep, + void *, + void (*xFunc) (sqlite3_context *, int, sqlite3_value **), + void (*xStep) (sqlite3_context *, int, sqlite3_value **), + void (*xFinal) (sqlite3_context *) + );) #define switch_core_db_create_function sqlite3_create_function - /** * Return the number of values in the current row of the result set. * @@ -972,18 +928,16 @@ DoxyDefine(int switch_core_db_create_function( * error code, or before switch_core_db_step() has been called on a * compiled SQL statement, this routine returns zero. */ -DoxyDefine(int switch_core_db_data_count(sqlite3_stmt *pStmt);) +DoxyDefine(int switch_core_db_data_count(sqlite3_stmt * pStmt);) #define switch_core_db_data_count sqlite3_data_count - /** * Return the sqlite3* database handle to which the prepared statement given * in the argument belongs. This is the same database handle that was * the first argument to the switch_core_db_prepare() that was used to create * the statement in the first place. */ -DoxyDefine(switch_core_db *switch_core_db_db_handle(sqlite3_stmt*);) + DoxyDefine(switch_core_db * switch_core_db_db_handle(sqlite3_stmt *);) #define switch_core_db_db_handle sqlite3_db_handle - /** ** Return the error code for the most recent switch_core_db_* API call associated ** with switch_core_db handle 'db'. SQLITE_OK is returned if the most recent @@ -999,9 +953,8 @@ DoxyDefine(switch_core_db *switch_core_db_db_handle(sqlite3_stmt*);) ** code returned by this function is associated with the same error as ** the strings returned by sqlite3_errmsg() and sqlite3_errmsg16(). */ -DoxyDefine(int switch_core_db_errcode(switch_core_db *db);) +DoxyDefine(int switch_core_db_errcode(switch_core_db * db);) #define switch_core_db_errcode sqlite3_errcode - /** * Return a pointer to a UTF-8 encoded string describing in english the * error condition for the most recent sqlite3_* API call. The returned @@ -1010,9 +963,8 @@ DoxyDefine(int switch_core_db_errcode(switch_core_db *db);) * The string "not an error" is returned when the most recent API call was * successful. */ -DoxyDefine(const char *switch_core_db_errmsg(switch_core_db*);) +DoxyDefine(const char *switch_core_db_errmsg(switch_core_db *);) #define switch_core_db_errmsg sqlite3_errmsg - /** * A function to executes one or more statements of SQL. * @@ -1053,15 +1005,13 @@ DoxyDefine(const char *switch_core_db_errmsg(switch_core_db*);) * behavior can be modified somewhat using the sswitch_core_db_busy_handler() * and switch_core_db_busy_timeout() functions below.) */ -DoxyDefine(int switch_core_db_exec( - switch_core_db*, /* An open database */ - const char *sql, /* SQL to be executed */ - sqlite3_callback, /* Callback function */ - void *, /* 1st argument to callback function */ - char **errmsg /* Error msg written here */ -);) +DoxyDefine(int switch_core_db_exec(switch_core_db *, /* An open database */ + const char *sql, /* SQL to be executed */ + sqlite3_callback, /* Callback function */ + void *, /* 1st argument to callback function */ + char **errmsg /* Error msg written here */ + );) #define switch_core_db_exec sqlite3_exec - /** * Return TRUE (non-zero) if the statement supplied as an argument needs * to be recompiled. A statement needs to be recompiled whenever the @@ -1071,9 +1021,8 @@ DoxyDefine(int switch_core_db_exec( * added or changed. * */ -DoxyDefine(int switch_core_db_expired(sqlite3_stmt*);) +DoxyDefine(int switch_core_db_expired(sqlite3_stmt *);) #define switch_core_db_expired sqlite3_expired - /** * This function is called to delete a compiled * SQL statement obtained by a previous call to switch_core_db_prepare(). @@ -1088,24 +1037,21 @@ DoxyDefine(int switch_core_db_expired(sqlite3_stmt*);) * rolled back and transactions cancelled, depending on the circumstances, * and the result code returned will be SQLITE_ABORT. */ -DoxyDefine(int switch_core_db_finalize(sqlite3_stmt *pStmt);) +DoxyDefine(int switch_core_db_finalize(sqlite3_stmt * pStmt);) #define switch_core_db_finalize sqlite3_finalize - /** * Call this routine to free the memory that sqlite3_get_table() allocated. */ DoxyDefine(void switch_core_db_free_table(char **result);) #define switch_core_db_free_table sqlite3_free_table - /** * Test to see whether or not the database connection is in autocommit * mode. Return TRUE if it is and FALSE if not. Autocommit mode is on * by default. Autocommit is disabled by a BEGIN statement and reenabled * by the next COMMIT or ROLLBACK. */ -DoxyDefine(int switch_core_db_get_autocommit(switch_core_db*);) +DoxyDefine(int switch_core_db_get_autocommit(switch_core_db *);) #define switch_core_db_get_autocommit sqlite3_get_autocommit - /** * The following function may be used by scalar user functions to * associate meta-data with argument values. If the same value is passed to @@ -1125,9 +1071,8 @@ DoxyDefine(int switch_core_db_get_autocommit(switch_core_db*);) * expressions that are constant at compile time. This includes literal * values and SQL variables. */ -DoxyDefine(void *switch_core_db_get_auxdata(sqlite3_context*, int);) +DoxyDefine(void *switch_core_db_get_auxdata(sqlite3_context *, int);) #define switch_core_db_get_auxdata sqlite3_get_auxdata - /** * The following function may be used by scalar user functions to * associate meta-data with argument values. If the same value is passed to @@ -1149,9 +1094,8 @@ DoxyDefine(void *switch_core_db_get_auxdata(sqlite3_context*, int);) * expressions that are constant at compile time. This includes literal * values and SQL variables. */ -DoxyDefine(void switch_core_db_set_auxdata(sqlite3_context*, int, void*, void (*)(void*));) +DoxyDefine(void switch_core_db_set_auxdata(sqlite3_context *, int, void *, void (*)(void *));) #define switch_core_db_set_auxdata sqlite3_set_auxdata - /** * This next routine is really just a wrapper around sqlite3_exec(). * Instead of invoking a user-supplied callback for each row of the @@ -1193,16 +1137,14 @@ DoxyDefine(void switch_core_db_set_auxdata(sqlite3_context*, int, void*, void (* * * The return value of this routine is the same as from switch_core_db_exec(). */ -DoxyDefine(int switch_core_db_get_table( - switch_core_db*, /* An open database */ - const char *sql, /* SQL to be executed */ - char ***resultp, /* Result written to a char *[] that this points to */ - int *nrow, /* Number of result rows written here */ - int *ncolumn, /* Number of result columns written here */ - char **errmsg /* Error msg written here */ -);) +DoxyDefine(int switch_core_db_get_table(switch_core_db *, /* An open database */ + const char *sql, /* SQL to be executed */ + char ***resultp, /* Result written to a char *[] that this points to */ + int *nrow, /* Number of result rows written here */ + int *ncolumn, /* Number of result columns written here */ + char **errmsg /* Error msg written here */ + );) #define switch_core_db_get_table sqlite3_get_table - /** * This function is called to recover from a malloc() failure that occured * within the SQLite library. Normally, after a single malloc() fails the @@ -1224,16 +1166,14 @@ DoxyDefine(int switch_core_db_get_table( */ DoxyDefine(int switch_core_db_global_recover();) #define switch_core_db_global_recover sqlite3_global_recover - /** This function causes any pending database operation to abort and * return at its earliest opportunity. This routine is typically * called in response to a user action such as pressing "Cancel" * or Ctrl-C where the user wants a long query operation to halt * immediately. */ -DoxyDefine(void switch_core_db_interrupt(switch_core_db*);) +DoxyDefine(void switch_core_db_interrupt(switch_core_db *);) #define switch_core_db_interrupt sqlite3_interrupt - /** * Each entry in an SQLite table has a unique integer key. (The key is * the value of the INTEGER PRIMARY KEY column if there is such a column, @@ -1243,9 +1183,8 @@ DoxyDefine(void switch_core_db_interrupt(switch_core_db*);) * * This function is similar to the mysql_insert_id() function from MySQL. */ -DoxyDefine(sqlite_int64 switch_core_db_last_insert_rowid(switch_core_db*);) + DoxyDefine(sqlite_int64 switch_core_db_last_insert_rowid(switch_core_db *);) #define switch_core_db_last_insert_rowid sqlite3_last_insert_rowid - /** * Open the sqlite database file "filename". The "filename" is UTF-8 * encoded. An sqlite3* handle is returned in *ppDb, even @@ -1261,12 +1200,10 @@ DoxyDefine(sqlite_int64 switch_core_db_last_insert_rowid(switch_core_db*);) * with the switch_core_db* handle should be released by passing it to * switch_core_db_close() when it is no longer required. */ -DoxyDefine(int switch_core_db_open( - const char *filename, /* Database filename (UTF-8) */ - switch_core_db **ppDb /* OUT: SQLite db handle */ -);) +DoxyDefine(int switch_core_db_open(const char *filename, /* Database filename (UTF-8) */ + switch_core_db ** ppDb /* OUT: SQLite db handle */ + );) #define switch_core_db_open sqlite3_open - /** * To execute an SQL query, it must first be compiled into a byte-code * program using the following routine. @@ -1289,15 +1226,13 @@ DoxyDefine(int switch_core_db_open( * * On success, SQLITE_OK is returned. Otherwise an error code is returned. */ -DoxyDefine(int switch_core_db_prepare( - sqlite3 *db, /* Database handle */ - const char *zSql, /* SQL statement, UTF-8 encoded */ - int nBytes, /* Length of zSql in bytes. */ - sqlite3_stmt **ppStmt, /* OUT: Statement handle */ - const char **pzTail /* OUT: Pointer to unused portion of zSql */ -);) +DoxyDefine(int switch_core_db_prepare(sqlite3 * db, /* Database handle */ + const char *zSql, /* SQL statement, UTF-8 encoded */ + int nBytes, /* Length of zSql in bytes. */ + sqlite3_stmt ** ppStmt, /* OUT: Statement handle */ + const char **pzTail /* OUT: Pointer to unused portion of zSql */ + );) #define switch_core_db_prepare sqlite3_prepare - /** * Register a function for tracing SQL command evaluation. The function registered by * switch_core_db_profile() runs at the end of each SQL statement and includes @@ -1306,10 +1241,9 @@ DoxyDefine(int switch_core_db_prepare( * The sqlite3_profile() API is currently considered experimental and * is subject to change. */ -DoxyDefine(void *switch_core_db_profile(switch_core_db*, - void(*xProfile)(void*,const char*,sqlite_uint64), void*);) +DoxyDefine(void *switch_core_db_profile(switch_core_db *, + void (*xProfile) (void *, const char *, sqlite_uint64), void *);) #define switch_core_db_profile sqlite3_profile - /** * This routine configures a callback function - the progress callback - that * is invoked periodically during long running calls to switch_core_db_exec(), @@ -1336,9 +1270,8 @@ DoxyDefine(void *switch_core_db_profile(switch_core_db*, * ****** THIS IS AN EXPERIMENTAL API AND IS SUBJECT TO CHANGE ****** */ -DoxyDefine(void switch_core_db_progress_handler(switch_core_db*, int, int(*)(void*), void*);) +DoxyDefine(void switch_core_db_progress_handler(switch_core_db *, int, int (*)(void *), void *);) #define switch_core_db_progress_handler sqlite3_progress_handler - /** * The switch_core_db_reset() function is called to reset a compiled SQL * statement obtained by a previous call to switch_core_db_prepare() @@ -1346,93 +1279,80 @@ DoxyDefine(void switch_core_db_progress_handler(switch_core_db*, int, int(*)(voi * Any SQL statement variables that had values bound to them using * the switch_core_db_bind_*() API retain their values. */ -DoxyDefine(int switch_core_db_reset(sqlite3_stmt *pStmt);) +DoxyDefine(int switch_core_db_reset(sqlite3_stmt * pStmt);) #define switch_core_db_reset sqlite3_reset - /** * User-defined functions invoke this routine in order to * set their return value. */ -DoxyDefine(void switch_core_db_result_blob(sqlite3_context*, const void*, int, void(*)(void*));) +DoxyDefine(void switch_core_db_result_blob(sqlite3_context *, const void *, int, void (*)(void *));) #define switch_core_db_result_blob sqlite3_result_blob - /** * User-defined functions invoke this routine in order to * set their return value. */ -DoxyDefine(void switch_core_db_result_double(sqlite3_context*, double);) +DoxyDefine(void switch_core_db_result_double(sqlite3_context *, double);) #define switch_core_db_result_double sqlite3_result_double - /** * User-defined functions invoke this routine in order to * set their return value. */ -DoxyDefine(void switch_core_db_result_error(sqlite3_context*, const char*, int);) +DoxyDefine(void switch_core_db_result_error(sqlite3_context *, const char *, int);) #define switch_core_db_result_error sqlite3_result_error - /** * User-defined functions invoke this routine in order to * set their return value. */ -DoxyDefine(void switch_core_db_result_error16(sqlite3_context*, const void*, int);) +DoxyDefine(void switch_core_db_result_error16(sqlite3_context *, const void *, int);) #define switch_core_db_result_error16 sqlite3_result_error16 - /** * User-defined functions invoke this routine in order to * set their return value. */ -DoxyDefine(void switch_core_db_result_int(sqlite3_context*, int);) +DoxyDefine(void switch_core_db_result_int(sqlite3_context *, int);) #define switch_core_db_result_int sqlite3_result_int - /** * User-defined functions invoke this routine in order to * set their return value. */ -DoxyDefine(void switch_core_db_result_int64(sqlite3_context*, sqlite_int64);) +DoxyDefine(void switch_core_db_result_int64(sqlite3_context *, sqlite_int64);) #define switch_core_db_result_int64 sqlite3_result_int64 - /** * User-defined functions invoke this routine in order to * set their return value. */ -DoxyDefine(void switch_core_db_result_null(sqlite3_context*);) +DoxyDefine(void switch_core_db_result_null(sqlite3_context *);) #define switch_core_db_result_null sqlite3_result_null - /** * User-defined functions invoke this routine in order to * set their return value. */ -DoxyDefine(void switch_core_db_result_text(sqlite3_context*, const char*, int, void(*)(void*));) +DoxyDefine(void switch_core_db_result_text(sqlite3_context *, const char *, int, void (*)(void *));) #define switch_core_db_result_text sqlite3_result_text - /** * User-defined functions invoke this routine in order to * set their return value. */ -DoxyDefine(void switch_core_db_result_text16(sqlite3_context*, const void*, int, void(*)(void*));) +DoxyDefine(void switch_core_db_result_text16(sqlite3_context *, const void *, int, void (*)(void *));) #define switch_core_db_result_text16 sqlite3_result_text16 - /** * User-defined functions invoke this routine in order to * set their return value. */ -DoxyDefine(void switch_core_db_result_text16le(sqlite3_context*, const void*, int,void(*)(void*));) +DoxyDefine(void switch_core_db_result_text16le(sqlite3_context *, const void *, int, void (*)(void *));) #define switch_core_db_result_text16le sqlite3_result_text16le - /** * User-defined functions invoke this routine in order to * set their return value. */ -DoxyDefine(void switch_core_db_result_text16be(sqlite3_context*, const void*, int,void(*)(void*));) +DoxyDefine(void switch_core_db_result_text16be(sqlite3_context *, const void *, int, void (*)(void *));) #define switch_core_db_result_text16be sqlite3_result_text16be - /** * User-defined functions invoke this routine in order to * set their return value. */ -DoxyDefine(void switch_core_db_result_value(sqlite3_context*, sqlite3_value*);) +DoxyDefine(void switch_core_db_result_value(sqlite3_context *, sqlite3_value *);) #define switch_core_db_result_value sqlite3_result_value - /** * This routine registers a callback with the SQLite library. The * callback is invoked (at compile-time, not at run-time) for each @@ -1441,13 +1361,10 @@ DoxyDefine(void switch_core_db_result_value(sqlite3_context*, sqlite3_value*);) * SQL statement should be aborted with an error and SQLITE_IGNORE * if the column should be treated as a NULL value. */ -DoxyDefine(int switch_core_db_set_authorizer( - switch_core_db*, - int (*xAuth)(void*,int,const char*,const char*,const char*,const char*), - void *pUserData -);) +DoxyDefine(int switch_core_db_set_authorizer(switch_core_db *, + int (*xAuth) (void *, int, const char *, const char *, const char *, + const char *), void *pUserData);) #define switch_core_db_set_authorizer sqlite3_set_authorizer - /** * After an SQL query has been compiled with a call to either * switch_core_db_prepare(), then this function must be @@ -1480,9 +1397,8 @@ DoxyDefine(int switch_core_db_set_authorizer( * SQLITE_DONE. Or it could be the case the the same database connection * is being used simulataneously by two or more threads. */ -DoxyDefine(int switch_core_db_step(sqlite3_stmt*);) +DoxyDefine(int switch_core_db_step(sqlite3_stmt *);) #define switch_core_db_step sqlite3_step - /** * If the following global variable is made to point to a * string which is the name of a directory, then all temporary files @@ -1493,9 +1409,8 @@ DoxyDefine(int switch_core_db_step(sqlite3_stmt*);) * Once switch_core_db_open() has been called, changing this variable will invalidate * the current temporary database, if any. */ -DoxyDefine(extern char *switch_core_db_temp_directory;) + DoxyDefine(extern char *switch_core_db_temp_directory;) #define switch_core_db_temp_directory sqlite3_temp_directory - /** * This function returns the number of database rows that have been * modified by INSERT, UPDATE or DELETE statements since the database handle @@ -1512,17 +1427,15 @@ DoxyDefine(extern char *switch_core_db_temp_directory;) * table. To get an accurate count of the number of rows deleted, use * "DELETE FROM table WHERE 1" instead. */ -DoxyDefine(int switch_core_db_total_changes(switch_core_db*);) +DoxyDefine(int switch_core_db_total_changes(switch_core_db *);) #define switch_core_db_total_changes sqlite3_total_changes - /** * Register a function for tracing SQL command evaluation. The function * registered is invoked at the first switch_core_db_step() * for the evaluation of an SQL statement. */ -DoxyDefine(void *switch_core_db_trace(switch_core_db*, void(*xTrace)(void*,const char*), void*);) +DoxyDefine(void *switch_core_db_trace(switch_core_db *, void (*xTrace) (void *, const char *), void *);) #define switch_core_db_trace sqlite3_trace - /** * Move all bindings from the first prepared statement over to the second. * This routine is useful, for example, if the first prepared statement @@ -1530,17 +1443,15 @@ DoxyDefine(void *switch_core_db_trace(switch_core_db*, void(*xTrace)(void*,const * the second prepared statement then all of the bindings transfered over * to the second statement before the first statement is finalized. */ -DoxyDefine(int switch_core_db_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*);) +DoxyDefine(int switch_core_db_transfer_bindings(sqlite3_stmt *, sqlite3_stmt *);) #define switch_core_db_transfer_bindings sqlite3_transfer_bindings - /** * The pUserData parameter to the switch_core_db_create_function() * routine used to register user functions is available to * the implementation of the function using this call. */ -DoxyDefine(void *switch_core_db_user_data(sqlite3_context*);) +DoxyDefine(void *switch_core_db_user_data(sqlite3_context *);) #define switch_core_db_user_data sqlite3_user_data - /** * returns information about parameters to * a user-defined function. Function implementations use this routines @@ -1549,9 +1460,8 @@ DoxyDefine(void *switch_core_db_user_data(sqlite3_context*);) * sqlite3_value* pointer instead of an sqlite3_stmt* and an integer * column number. */ -DoxyDefine(const void *switch_core_db_value_blob(sqlite3_value*);) +DoxyDefine(const void *switch_core_db_value_blob(sqlite3_value *);) #define switch_core_db_value_blob sqlite3_value_blob - /** * returns information about parameters to * a user-defined function. Function implementations use this routines @@ -1560,9 +1470,8 @@ DoxyDefine(const void *switch_core_db_value_blob(sqlite3_value*);) * sqlite3_value* pointer instead of an sqlite3_stmt* and an integer * column number. */ -DoxyDefine(int switch_core_db_value_bytes(sqlite3_value*);) +DoxyDefine(int switch_core_db_value_bytes(sqlite3_value *);) #define switch_core_db_value_bytes sqlite3_value_bytes - /** * returns information about parameters to * a user-defined function. Function implementations use this routines @@ -1571,9 +1480,8 @@ DoxyDefine(int switch_core_db_value_bytes(sqlite3_value*);) * sqlite3_value* pointer instead of an sqlite3_stmt* and an integer * column number. */ -DoxyDefine(int switch_core_db_value_bytes16(sqlite3_value*);) +DoxyDefine(int switch_core_db_value_bytes16(sqlite3_value *);) #define switch_core_db_value_bytes16 sqlite3_value_bytes16 - /** * returns information about parameters to * a user-defined function. Function implementations use this routines @@ -1582,9 +1490,8 @@ DoxyDefine(int switch_core_db_value_bytes16(sqlite3_value*);) * sqlite3_value* pointer instead of an sqlite3_stmt* and an integer * column number. */ -DoxyDefine(double switch_core_db_value_double(sqlite3_value*);) +DoxyDefine(double switch_core_db_value_double(sqlite3_value *);) #define switch_core_db_value_double sqlite3_value_double - /** * returns information about parameters to * a user-defined function. Function implementations use this routines @@ -1593,9 +1500,8 @@ DoxyDefine(double switch_core_db_value_double(sqlite3_value*);) * sqlite3_value* pointer instead of an sqlite3_stmt* and an integer * column number. */ -DoxyDefine(int switch_core_db_value_int(sqlite3_value*);) +DoxyDefine(int switch_core_db_value_int(sqlite3_value *);) #define switch_core_db_value_int sqlite3_value_int - /** * returns information about parameters to * a user-defined function. Function implementations use this routines @@ -1604,9 +1510,8 @@ DoxyDefine(int switch_core_db_value_int(sqlite3_value*);) * sqlite3_value* pointer instead of an sqlite3_stmt* and an integer * column number. */ -DoxyDefine(sqlite_int64 switch_core_db_value_int64(sqlite3_value*);) + DoxyDefine(sqlite_int64 switch_core_db_value_int64(sqlite3_value *);) #define switch_core_db_value_int64 sqlite3_value_int64 - /** * returns information about parameters to * a user-defined function. Function implementations use this routines @@ -1615,9 +1520,8 @@ DoxyDefine(sqlite_int64 switch_core_db_value_int64(sqlite3_value*);) * sqlite3_value* pointer instead of an sqlite3_stmt* and an integer * column number. */ -DoxyDefine(const unsigned char *switch_core_db_value_text(sqlite3_value*);) +DoxyDefine(const unsigned char *switch_core_db_value_text(sqlite3_value *);) #define switch_core_db_value_text sqlite3_value_text - /** * returns information about parameters to * a user-defined function. Function implementations use this routines @@ -1626,9 +1530,8 @@ DoxyDefine(const unsigned char *switch_core_db_value_text(sqlite3_value*);) * sqlite3_value* pointer instead of an sqlite3_stmt* and an integer * column number. */ -DoxyDefine(const void *switch_core_db_value_text16(sqlite3_value*);) +DoxyDefine(const void *switch_core_db_value_text16(sqlite3_value *);) #define switch_core_db_value_text16 sqlite3_value_text16 - /** * returns information about parameters to * a user-defined function. Function implementations use this routines @@ -1637,9 +1540,8 @@ DoxyDefine(const void *switch_core_db_value_text16(sqlite3_value*);) * sqlite3_value* pointer instead of an sqlite3_stmt* and an integer * column number. */ -DoxyDefine(const void *switch_core_db_value_text16be(sqlite3_value*);) +DoxyDefine(const void *switch_core_db_value_text16be(sqlite3_value *);) #define switch_core_db_value_text16be sqlite3_value_text16be - /** * returns information about parameters to * a user-defined function. Function implementations use this routines @@ -1648,9 +1550,8 @@ DoxyDefine(const void *switch_core_db_value_text16be(sqlite3_value*);) * sqlite3_value* pointer instead of an sqlite3_stmt* and an integer * column number. */ -DoxyDefine(const void *switch_core_db_value_text16le(sqlite3_value*);) +DoxyDefine(const void *switch_core_db_value_text16le(sqlite3_value *);) #define switch_core_db_value_text16le sqlite3_value_text16le - /** * returns information about parameters to * a user-defined function. Function implementations use this routines @@ -1659,10 +1560,8 @@ DoxyDefine(const void *switch_core_db_value_text16le(sqlite3_value*);) * sqlite3_value* pointer instead of an sqlite3_stmt* and an integer * column number. */ -DoxyDefine(int switch_core_db_value_type(sqlite3_value*);) +DoxyDefine(int switch_core_db_value_type(sqlite3_value *);) #define switch_core_db_value_type sqlite3_value_type - - /** * This routine is a variant of the "sprintf()" from the * standard C library. The resulting string is written into memory @@ -1704,10 +1603,9 @@ DoxyDefine(int switch_core_db_value_type(sqlite3_value*);) * should always use %q instead of %s when inserting text into a string * literal. */ -DoxyDefine(char *switch_core_db_mprintf(const char*,...);) +DoxyDefine(char *switch_core_db_mprintf(const char *, ...);) #define switch_core_db_mprintf sqlite3_mprintf #define switch_mprintf sqlite3_mprintf - /** * This routine is a variant of the "sprintf()" from the * standard C library. The resulting string is written into memory @@ -1749,9 +1647,8 @@ DoxyDefine(char *switch_core_db_mprintf(const char*,...);) * should always use %q instead of %s when inserting text into a string * literal. */ -DoxyDefine(char *switch_core_db_vmprintf(const char*, va_list);) +DoxyDefine(char *switch_core_db_vmprintf(const char *, va_list);) #define switch_core_db_vmprintf sqlite3_vmprintf - /** * This routine is a variant of the "sprintf()" from the * standard C library. The resulting string is written into memory @@ -1793,22 +1690,17 @@ DoxyDefine(char *switch_core_db_vmprintf(const char*, va_list);) * should always use %q instead of %s when inserting text into a string * literal. */ -DoxyDefine(char *switch_core_db_snprintf(int,char*,const char*, ...);) +DoxyDefine(char *switch_core_db_snprintf(int, char *, const char *, ...);) #define switch_core_db_snprintf sqlite3_snprintf - /** * call this routine to free memory malloced by a call to switch_core_db_mprintf, switch_core_db_vmprintf, or switch_core_db_snprintf */ DoxyDefine(void switch_core_db_free(char *z);) #define switch_core_db_free sqlite3_free - /** @} */ /** @} */ - -SWITCH_END_EXTERN_C - + SWITCH_END_EXTERN_C #endif - /* For Emacs: * Local Variables: * mode:c diff --git a/src/include/switch_stun.h b/src/include/switch_stun.h index 2f000beefc..48e1ed6add 100644 --- a/src/include/switch_stun.h +++ b/src/include/switch_stun.h @@ -38,59 +38,57 @@ #define _SWITCH_STUN_PARSER_H SWITCH_BEGIN_EXTERN_C - #define SWITCH_STUN_DEFAULT_PORT 3478 #define SWITCH_STUN_PACKET_MIN_LEN 20 - -typedef enum { - SWITCH_STUN_BINDING_REQUEST = 0x0001, - SWITCH_STUN_BINDING_RESPONSE = 0x0101, - SWITCH_STUN_BINDING_ERROR_RESPONSE = 0x0111, - SWITCH_STUN_SHARED_SECRET_REQUEST = 0x0002, - SWITCH_STUN_SHARED_SECRET_RESPONSE = 0x0102, - SWITCH_STUN_SHARED_SECRET_ERROR_RESPONSE = 0x0112, - SWITCH_STUN_ALLOCATE_REQUEST = 0x0003, - SWITCH_STUN_ALLOCATE_RESPONSE = 0x0103, - SWITCH_STUN_ALLOCATE_ERROR_RESPONSE = 0x0113, - SWITCH_STUN_SEND_REQUEST = 0x0004, - SWITCH_STUN_SEND_RESPONSE = 0x0104, - SWITCH_STUN_SEND_ERROR_RESPONSE = 0x0114, - SWITCH_STUN_DATA_INDICATION = 0x0115 + typedef enum { + SWITCH_STUN_BINDING_REQUEST = 0x0001, + SWITCH_STUN_BINDING_RESPONSE = 0x0101, + SWITCH_STUN_BINDING_ERROR_RESPONSE = 0x0111, + SWITCH_STUN_SHARED_SECRET_REQUEST = 0x0002, + SWITCH_STUN_SHARED_SECRET_RESPONSE = 0x0102, + SWITCH_STUN_SHARED_SECRET_ERROR_RESPONSE = 0x0112, + SWITCH_STUN_ALLOCATE_REQUEST = 0x0003, + SWITCH_STUN_ALLOCATE_RESPONSE = 0x0103, + SWITCH_STUN_ALLOCATE_ERROR_RESPONSE = 0x0113, + SWITCH_STUN_SEND_REQUEST = 0x0004, + SWITCH_STUN_SEND_RESPONSE = 0x0104, + SWITCH_STUN_SEND_ERROR_RESPONSE = 0x0114, + SWITCH_STUN_DATA_INDICATION = 0x0115 } switch_stun_message_t; typedef enum { - SWITCH_STUN_ATTR_MAPPED_ADDRESS = 0x0001, /* Address */ - SWITCH_STUN_ATTR_RESPONSE_ADDRESS = 0x0002, /* Address */ - SWITCH_STUN_ATTR_CHANGE_REQUEST = 0x0003, /* UInt32 */ - SWITCH_STUN_ATTR_SOURCE_ADDRESS = 0x0004, /* Address */ - SWITCH_STUN_ATTR_CHANGED_ADDRESS = 0x0005, /* Address */ - SWITCH_STUN_ATTR_USERNAME = 0x0006, /* ByteString, multiple of 4 bytes */ - SWITCH_STUN_ATTR_PASSWORD = 0x0007, /* ByteString, multiple of 4 bytes */ - SWITCH_STUN_ATTR_MESSAGE_INTEGRITY = 0x0008, /* ByteString, 20 bytes */ - SWITCH_STUN_ATTR_ERROR_CODE = 0x0009, /* ErrorCode */ - SWITCH_STUN_ATTR_UNKNOWN_ATTRIBUTES = 0x000a, /* UInt16List */ - SWITCH_STUN_ATTR_REFLECTED_FROM = 0x000b, /* Address */ - SWITCH_STUN_ATTR_TRANSPORT_PREFERENCES = 0x000c, /* TransportPrefs */ - SWITCH_STUN_ATTR_LIFETIME = 0x000d, /* UInt32 */ - SWITCH_STUN_ATTR_ALTERNATE_SERVER = 0x000e, /* Address */ - SWITCH_STUN_ATTR_MAGIC_COOKIE = 0x000f, /* ByteString, 4 bytes */ - SWITCH_STUN_ATTR_BANDWIDTH = 0x0010, /* UInt32 */ - SWITCH_STUN_ATTR_DESTINATION_ADDRESS = 0x0011, /* Address */ - SWITCH_STUN_ATTR_SOURCE_ADDRESS2 = 0x0012, /* Address */ - SWITCH_STUN_ATTR_DATA = 0x0013, /* ByteString */ - SWITCH_STUN_ATTR_OPTIONS = 0x8001 /* UInt32 */ + SWITCH_STUN_ATTR_MAPPED_ADDRESS = 0x0001, /* Address */ + SWITCH_STUN_ATTR_RESPONSE_ADDRESS = 0x0002, /* Address */ + SWITCH_STUN_ATTR_CHANGE_REQUEST = 0x0003, /* UInt32 */ + SWITCH_STUN_ATTR_SOURCE_ADDRESS = 0x0004, /* Address */ + SWITCH_STUN_ATTR_CHANGED_ADDRESS = 0x0005, /* Address */ + SWITCH_STUN_ATTR_USERNAME = 0x0006, /* ByteString, multiple of 4 bytes */ + SWITCH_STUN_ATTR_PASSWORD = 0x0007, /* ByteString, multiple of 4 bytes */ + SWITCH_STUN_ATTR_MESSAGE_INTEGRITY = 0x0008, /* ByteString, 20 bytes */ + SWITCH_STUN_ATTR_ERROR_CODE = 0x0009, /* ErrorCode */ + SWITCH_STUN_ATTR_UNKNOWN_ATTRIBUTES = 0x000a, /* UInt16List */ + SWITCH_STUN_ATTR_REFLECTED_FROM = 0x000b, /* Address */ + SWITCH_STUN_ATTR_TRANSPORT_PREFERENCES = 0x000c, /* TransportPrefs */ + SWITCH_STUN_ATTR_LIFETIME = 0x000d, /* UInt32 */ + SWITCH_STUN_ATTR_ALTERNATE_SERVER = 0x000e, /* Address */ + SWITCH_STUN_ATTR_MAGIC_COOKIE = 0x000f, /* ByteString, 4 bytes */ + SWITCH_STUN_ATTR_BANDWIDTH = 0x0010, /* UInt32 */ + SWITCH_STUN_ATTR_DESTINATION_ADDRESS = 0x0011, /* Address */ + SWITCH_STUN_ATTR_SOURCE_ADDRESS2 = 0x0012, /* Address */ + SWITCH_STUN_ATTR_DATA = 0x0013, /* ByteString */ + SWITCH_STUN_ATTR_OPTIONS = 0x8001 /* UInt32 */ } switch_stun_attribute_t; typedef enum { - SWITCH_STUN_ERROR_BAD_REQUEST = 400, - SWITCH_STUN_ERROR_UNAUTHORIZED = 401, - SWITCH_STUN_ERROR_UNKNOWN_ATTRIBUTE = 420, - SWITCH_STUN_ERROR_STALE_CREDENTIALS = 430, - SWITCH_STUN_ERROR_INTEGRITY_CHECK_FAILURE = 431, - SWITCH_STUN_ERROR_MISSING_USERNAME = 432, - SWITCH_STUN_ERROR_USE_TLS = 433, - SWITCH_STUN_ERROR_SERVER_ERROR = 500, - SWITCH_STUN_ERROR_GLOBAL_FAILURE = 600 + SWITCH_STUN_ERROR_BAD_REQUEST = 400, + SWITCH_STUN_ERROR_UNAUTHORIZED = 401, + SWITCH_STUN_ERROR_UNKNOWN_ATTRIBUTE = 420, + SWITCH_STUN_ERROR_STALE_CREDENTIALS = 430, + SWITCH_STUN_ERROR_INTEGRITY_CHECK_FAILURE = 431, + SWITCH_STUN_ERROR_MISSING_USERNAME = 432, + SWITCH_STUN_ERROR_USE_TLS = 433, + SWITCH_STUN_ERROR_SERVER_ERROR = 500, + SWITCH_STUN_ERROR_GLOBAL_FAILURE = 600 } switch_stun_error_t; typedef enum { @@ -138,7 +136,7 @@ SWITCH_DECLARE(void) switch_stun_random_string(char *buf, uint16_t len, char *se \param len the length of the data \return a stun packet pointer to buf to use as an access point */ -SWITCH_DECLARE(switch_stun_packet_t *)switch_stun_packet_parse(uint8_t *buf, uint32_t len); +SWITCH_DECLARE(switch_stun_packet_t *) switch_stun_packet_parse(uint8_t * buf, uint32_t len); /*! \brief Obtain a printable string form of a given value @@ -146,7 +144,7 @@ SWITCH_DECLARE(switch_stun_packet_t *)switch_stun_packet_parse(uint8_t *buf, uin \param value the value to look up \return a sring version of value */ -SWITCH_DECLARE(const char *)switch_stun_value_to_name(int32_t type, uint32_t value); +SWITCH_DECLARE(const char *) switch_stun_value_to_name(int32_t type, uint32_t value); /*! @@ -156,7 +154,8 @@ SWITCH_DECLARE(const char *)switch_stun_value_to_name(int32_t type, uint32_t val \param port the port \return true or false */ -SWITCH_DECLARE(uint8_t) switch_stun_packet_attribute_get_mapped_address(switch_stun_packet_attribute_t *attribute, char *ipstr, uint16_t *port); +SWITCH_DECLARE(uint8_t) switch_stun_packet_attribute_get_mapped_address(switch_stun_packet_attribute_t *attribute, + char *ipstr, uint16_t * port); /*! \brief Extract a username from a packet attribute @@ -165,7 +164,8 @@ SWITCH_DECLARE(uint8_t) switch_stun_packet_attribute_get_mapped_address(switch_s \param len the maximum size of the username buffer \return a pointer to the username or NULL */ -SWITCH_DECLARE(char *)switch_stun_packet_attribute_get_username(switch_stun_packet_attribute_t *attribute, char *username, uint16_t len); +SWITCH_DECLARE(char *) switch_stun_packet_attribute_get_username(switch_stun_packet_attribute_t *attribute, + char *username, uint16_t len); /*! @@ -175,10 +175,8 @@ SWITCH_DECLARE(char *)switch_stun_packet_attribute_get_username(switch_stun_pack \param buf a pointer to data to use for the packet \return a pointer to a ready-to-use stun packet */ -SWITCH_DECLARE(switch_stun_packet_t *)switch_stun_packet_build_header(switch_stun_message_t type, - char *id, - uint8_t *buf - ); +SWITCH_DECLARE(switch_stun_packet_t *) switch_stun_packet_build_header(switch_stun_message_t type, + char *id, uint8_t * buf); /*! \brief Add a username packet attribute @@ -187,7 +185,8 @@ SWITCH_DECLARE(switch_stun_packet_t *)switch_stun_packet_build_header(switch_stu \param ulen the length of the username \return true or false */ -SWITCH_DECLARE(uint8_t) switch_stun_packet_attribute_add_username(switch_stun_packet_t *packet, char *username, uint16_t ulen); +SWITCH_DECLARE(uint8_t) switch_stun_packet_attribute_add_username(switch_stun_packet_t *packet, char *username, + uint16_t ulen); /*! @@ -197,7 +196,8 @@ SWITCH_DECLARE(uint8_t) switch_stun_packet_attribute_add_username(switch_stun_pa \param port the port of the mapped address \return true or false */ -SWITCH_DECLARE(uint8_t) switch_stun_packet_attribute_add_binded_address(switch_stun_packet_t *packet, char *ipstr, uint16_t port); +SWITCH_DECLARE(uint8_t) switch_stun_packet_attribute_add_binded_address(switch_stun_packet_t *packet, char *ipstr, + uint16_t port); /*! \brief Perform a stun lookup @@ -209,12 +209,10 @@ SWITCH_DECLARE(uint8_t) switch_stun_packet_attribute_add_binded_address(switch_s \param pool the memory pool to use \return SUCCESS or FAIL */ -SWITCH_DECLARE(switch_status_t) switch_stun_lookup (char **ip, - switch_port_t *port, - char *stunip, - switch_port_t stunport, - char **err, - switch_memory_pool_t *pool); +SWITCH_DECLARE(switch_status_t) switch_stun_lookup(char **ip, + switch_port_t *port, + char *stunip, + switch_port_t stunport, char **err, switch_memory_pool_t *pool); @@ -241,9 +239,7 @@ SWITCH_DECLARE(switch_status_t) switch_stun_lookup (char **ip, ///\} SWITCH_END_EXTERN_C - #endif - /* For Emacs: * Local Variables: * mode:c diff --git a/src/include/switch_types.h b/src/include/switch_types.h index 153761f198..2260ca3174 100644 --- a/src/include/switch_types.h +++ b/src/include/switch_types.h @@ -36,9 +36,7 @@ #include SWITCH_BEGIN_EXTERN_C - #define SWITCH_SEQ_ESC "\033[" - /* Ansi Control character suffixes */ #define SWITCH_SEQ_HOME_CHAR 'H' #define SWITCH_SEQ_HOME_CHAR_STR "H" @@ -48,11 +46,9 @@ SWITCH_BEGIN_EXTERN_C #define SWITCH_SEQ_CLEARSCR_CHAR0 '2' #define SWITCH_SEQ_CLEARSCR_CHAR1 'J' #define SWITCH_SEQ_CLEARSCR_CHAR "2J" - -#define SWITCH_SEQ_DEFAULT_COLOR SWITCH_SEQ_ESC SWITCH_SEQ_END_COLOR /* Reset to Default fg/bg color */ -#define SWITCH_SEQ_AND_COLOR ";" /* To add multiple color definitions */ -#define SWITCH_SEQ_END_COLOR "m" /* To end color definitions */ - +#define SWITCH_SEQ_DEFAULT_COLOR SWITCH_SEQ_ESC SWITCH_SEQ_END_COLOR /* Reset to Default fg/bg color */ +#define SWITCH_SEQ_AND_COLOR ";" /* To add multiple color definitions */ +#define SWITCH_SEQ_END_COLOR "m" /* To end color definitions */ /* Foreground colors values */ #define SWITCH_SEQ_F_BLACK "30" #define SWITCH_SEQ_F_RED "31" @@ -62,7 +58,6 @@ SWITCH_BEGIN_EXTERN_C #define SWITCH_SEQ_F_MAGEN "35" #define SWITCH_SEQ_F_CYAN "36" #define SWITCH_SEQ_F_WHITE "37" - /* Background colors values */ #define SWITCH_SEQ_B_BLACK "40" #define SWITCH_SEQ_B_RED "41" @@ -72,7 +67,6 @@ SWITCH_BEGIN_EXTERN_C #define SWITCH_SEQ_B_MAGEN "45" #define SWITCH_SEQ_B_CYAN "46" #define SWITCH_SEQ_B_WHITE "47" - /* Preset escape sequences - Change foreground colors only */ #define SWITCH_SEQ_FBLACK SWITCH_SEQ_ESC SWITCH_SEQ_F_BLACK SWITCH_SEQ_END_COLOR #define SWITCH_SEQ_FRED SWITCH_SEQ_ESC SWITCH_SEQ_F_RED SWITCH_SEQ_END_COLOR @@ -82,7 +76,6 @@ SWITCH_BEGIN_EXTERN_C #define SWITCH_SEQ_FMAGEN SWITCH_SEQ_ESC SWITCH_SEQ_F_MAGEN SWITCH_SEQ_END_COLOR #define SWITCH_SEQ_FCYAN SWITCH_SEQ_ESC SWITCH_SEQ_F_CYAN SWITCH_SEQ_END_COLOR #define SWITCH_SEQ_FWHITE SWITCH_SEQ_ESC SWITCH_SEQ_F_WHITE SWITCH_SEQ_END_COLOR - #define SWITCH_SEQ_BBLACK SWITCH_SEQ_ESC SWITCH_SEQ_B_BLACK SWITCH_SEQ_END_COLOR #define SWITCH_SEQ_BRED SWITCH_SEQ_ESC SWITCH_SEQ_B_RED SWITCH_SEQ_END_COLOR #define SWITCH_SEQ_BGREEN SWITCH_SEQ_ESC SWITCH_SEQ_B_GREEN SWITCH_SEQ_END_COLOR @@ -91,21 +84,17 @@ SWITCH_BEGIN_EXTERN_C #define SWITCH_SEQ_BMAGEN SWITCH_SEQ_ESC SWITCH_SEQ_B_MAGEN SWITCH_SEQ_END_COLOR #define SWITCH_SEQ_BCYAN SWITCH_SEQ_ESC SWITCH_SEQ_B_CYAN SWITCH_SEQ_END_COLOR #define SWITCH_SEQ_BWHITE SWITCH_SEQ_ESC SWITCH_SEQ_B_WHITE SWITCH_SEQ_END_COLOR - /* Preset escape sequences */ #define SWITCH_SEQ_HOME SWITCH_SEQ_ESC SWITCH_SEQ_HOME_CHAR_STR #define SWITCH_SEQ_CLEARLINE SWITCH_SEQ_ESC SWITCH_SEQ_CLEARLINE_CHAR_STR #define SWITCH_SEQ_CLEARLINEEND SWITCH_SEQ_ESC SWITCH_SEQ_CLEARLINEEND_CHAR #define SWITCH_SEQ_CLEARSCR SWITCH_SEQ_ESC SWITCH_SEQ_CLEARSCR_CHAR SWITCH_SEQ_HOME - #ifdef WIN32 #define SWITCH_PATH_SEPARATOR "\\" #else #define SWITCH_PATH_SEPARATOR "/" #endif - #define SWITCH_URL_SEPARATOR "://" - #define SWITCH_ENDPOINT_DISPOSITION_VARIABLE "endpoint_disposition" #define SWITCH_EXPORT_VARS_VARIABLE "export_vars" #define SWITCH_R_SDP_VARIABLE "switch_r_sdp" @@ -122,11 +111,10 @@ SWITCH_BEGIN_EXTERN_C #define SWITCH_REMOTE_MEDIA_PORT_VARIABLE "remote_media_port" #define SWITCH_HANGUP_AFTER_BRIDGE_VARIABLE "hangup_after_bridge" #define SWITCH_MAX_FORWARDS_VARIABLE "max_forwards" - #define SWITCH_SPEECH_KEY "speech" #define SWITCH_UUID_BRIDGE "uuid_bridge" #define SWITCH_BITS_PER_BYTE 8 -typedef uint8_t switch_byte_t; + typedef uint8_t switch_byte_t; typedef enum { SWITCH_FALSE = 0, @@ -137,7 +125,7 @@ typedef enum { SSM_NA, SSM_PRONOUNCED, SSM_ITERATED, - SSM_COUNTED + SSM_COUNTED } switch_say_method_t; typedef enum { @@ -242,12 +230,12 @@ typedef enum { } switch_caller_profile_flag_t; typedef enum { - SWITCH_AUDIO_COL_STR_TITLE = 0x01, - SWITCH_AUDIO_COL_STR_COPYRIGHT = 0x02, - SWITCH_AUDIO_COL_STR_SOFTWARE = 0x03, - SWITCH_AUDIO_COL_STR_ARTIST = 0x04, - SWITCH_AUDIO_COL_STR_COMMENT = 0x05, - SWITCH_AUDIO_COL_STR_DATE = 0x06 + SWITCH_AUDIO_COL_STR_TITLE = 0x01, + SWITCH_AUDIO_COL_STR_COPYRIGHT = 0x02, + SWITCH_AUDIO_COL_STR_SOFTWARE = 0x03, + SWITCH_AUDIO_COL_STR_ARTIST = 0x04, + SWITCH_AUDIO_COL_STR_COMMENT = 0x05, + SWITCH_AUDIO_COL_STR_DATE = 0x06 } switch_audio_col_t; typedef enum { @@ -269,10 +257,10 @@ typedef enum { */ typedef enum { - SWITCH_VAD_FLAG_TALKING = ( 1 << 0 ), - SWITCH_VAD_FLAG_EVENTS_TALK = ( 1 << 1 ), - SWITCH_VAD_FLAG_EVENTS_NOTALK = ( 1 << 2 ), - SWITCH_VAD_FLAG_CNG = ( 1 << 3) + SWITCH_VAD_FLAG_TALKING = (1 << 0), + SWITCH_VAD_FLAG_EVENTS_TALK = (1 << 1), + SWITCH_VAD_FLAG_EVENTS_NOTALK = (1 << 2), + SWITCH_VAD_FLAG_CNG = (1 << 3) } switch_vad_flag_t; #define SWITCH_RTP_CNG_PAYLOAD 13 @@ -299,7 +287,7 @@ typedef enum { */ typedef enum { - SWITCH_RTP_FLAG_NOBLOCK = ( 1 << 0), + SWITCH_RTP_FLAG_NOBLOCK = (1 << 0), SWITCH_RTP_FLAG_IO = (1 << 1), SWITCH_RTP_FLAG_USE_TIMER = (1 << 2), SWITCH_RTP_FLAG_TIMER_RECLOCK = (1 << 3), @@ -308,8 +296,8 @@ typedef enum { SWITCH_RTP_FLAG_RAW_WRITE = (1 << 6), SWITCH_RTP_FLAG_GOOGLEHACK = (1 << 7), SWITCH_RTP_FLAG_VAD = (1 << 8), - SWITCH_RTP_FLAG_BREAK = ( 1 << 9), - SWITCH_RTP_FLAG_MINI = ( 1 << 10), + SWITCH_RTP_FLAG_BREAK = (1 << 9), + SWITCH_RTP_FLAG_MINI = (1 << 10), SWITCH_RTP_FLAG_DATAWAIT = (1 << 11), SWITCH_RTP_FLAG_BUGGY_2833 = (1 << 12), SWITCH_RTP_FLAG_PASS_RFC2833 = (1 << 13), @@ -453,7 +441,7 @@ typedef enum { typedef enum { SWITCH_LOG_CONSOLE = 8, SWITCH_LOG_DEBUG = 7, - SWITCH_LOG_INFO = 6, + SWITCH_LOG_INFO = 6, SWITCH_LOG_NOTICE = 5, SWITCH_LOG_WARNING = 4, SWITCH_LOG_ERROR = 3, @@ -512,7 +500,7 @@ typedef enum { CS_HOLD, CS_HIBERNATE, CS_HANGUP, - CS_DONE + CS_DONE } switch_channel_state_t; @@ -544,25 +532,25 @@ CF_RING_READY = (1 << 18) - Channel is ready to send ringback */ typedef enum { - CF_ANSWERED = (1 << 0), - CF_OUTBOUND = (1 << 1), - CF_EARLY_MEDIA = (1 << 2), - CF_ORIGINATOR = (1 << 3), - CF_TRANSFER = (1 << 4), - CF_ACCEPT_CNG = (1 << 5), - CF_LOCK_THREAD = (1 << 6), - CF_BRIDGED = (1 << 7), - CF_HOLD = (1 << 8), - CF_SERVICE = (1 << 9), - CF_TAGGED = (1 << 10), - CF_WINNER = (1 << 11), - CF_CONTROLLED = (1 << 12), - CF_NOMEDIA = (1 << 13), - CF_SUSPEND = (1 << 14), - CF_EVENT_PARSE = (1 << 15), - CF_REPEAT_STATE = (1 << 16), - CF_GEN_RINGBACK = (1 << 17), - CF_RING_READY = (1 << 18) + CF_ANSWERED = (1 << 0), + CF_OUTBOUND = (1 << 1), + CF_EARLY_MEDIA = (1 << 2), + CF_ORIGINATOR = (1 << 3), + CF_TRANSFER = (1 << 4), + CF_ACCEPT_CNG = (1 << 5), + CF_LOCK_THREAD = (1 << 6), + CF_BRIDGED = (1 << 7), + CF_HOLD = (1 << 8), + CF_SERVICE = (1 << 9), + CF_TAGGED = (1 << 10), + CF_WINNER = (1 << 11), + CF_CONTROLLED = (1 << 12), + CF_NOMEDIA = (1 << 13), + CF_SUSPEND = (1 << 14), + CF_EVENT_PARSE = (1 << 15), + CF_REPEAT_STATE = (1 << 16), + CF_GEN_RINGBACK = (1 << 17), + CF_RING_READY = (1 << 18) } switch_channel_flag_t; @@ -600,7 +588,7 @@ typedef enum { SWITCH_SIG_NONE, SWITCH_SIG_KILL, SWITCH_SIG_XFER, - SWITCH_SIG_BREAK + SWITCH_SIG_BREAK } switch_signal_t; /*! @@ -618,14 +606,14 @@ SWITCH_CODEC_FLAG_PASSTHROUGH = (1 << 7) - Passthrough only */ typedef enum { - SWITCH_CODEC_FLAG_ENCODE = (1 << 0), - SWITCH_CODEC_FLAG_DECODE = (1 << 1), - SWITCH_CODEC_FLAG_SILENCE_START = (1 << 2), - SWITCH_CODEC_FLAG_SILENCE_STOP = (1 << 3), - SWITCH_CODEC_FLAG_SILENCE = (1 << 4), - SWITCH_CODEC_FLAG_FREE_POOL = (1 << 5), - SWITCH_CODEC_FLAG_AAL2 = (1 << 6), - SWITCH_CODEC_FLAG_PASSTHROUGH = (1 << 7) + SWITCH_CODEC_FLAG_ENCODE = (1 << 0), + SWITCH_CODEC_FLAG_DECODE = (1 << 1), + SWITCH_CODEC_FLAG_SILENCE_START = (1 << 2), + SWITCH_CODEC_FLAG_SILENCE_STOP = (1 << 3), + SWITCH_CODEC_FLAG_SILENCE = (1 << 4), + SWITCH_CODEC_FLAG_FREE_POOL = (1 << 5), + SWITCH_CODEC_FLAG_AAL2 = (1 << 6), + SWITCH_CODEC_FLAG_PASSTHROUGH = (1 << 7) } switch_codec_flag_t; @@ -641,12 +629,12 @@ SWITCH_SPEECH_FLAG_PAUSE = (1 << 4) - Pause toggle for playback */ typedef enum { - SWITCH_SPEECH_FLAG_NONE = 0, - SWITCH_SPEECH_FLAG_HASTEXT = (1 << 0), - SWITCH_SPEECH_FLAG_PEEK = (1 << 1), - SWITCH_SPEECH_FLAG_FREE_POOL = (1 << 2), - SWITCH_SPEECH_FLAG_BLOCKING = (1 << 3), - SWITCH_SPEECH_FLAG_PAUSE = (1 << 4) + SWITCH_SPEECH_FLAG_NONE = 0, + SWITCH_SPEECH_FLAG_HASTEXT = (1 << 0), + SWITCH_SPEECH_FLAG_PEEK = (1 << 1), + SWITCH_SPEECH_FLAG_FREE_POOL = (1 << 2), + SWITCH_SPEECH_FLAG_BLOCKING = (1 << 3), + SWITCH_SPEECH_FLAG_PAUSE = (1 << 4) } switch_speech_flag_t; @@ -662,12 +650,12 @@ SWITCH_ASR_FLAG_AUTO_RESUME = (1 << 4) - Auto Resume */ typedef enum { - SWITCH_ASR_FLAG_NONE = 0, - SWITCH_ASR_FLAG_DATA = (1 << 0), - SWITCH_ASR_FLAG_FREE_POOL = (1 << 1), - SWITCH_ASR_FLAG_CLOSED = (1 << 2), - SWITCH_ASR_FLAG_FIRE_EVENTS = (1 << 3), - SWITCH_ASR_FLAG_AUTO_RESUME = (1 << 4) + SWITCH_ASR_FLAG_NONE = 0, + SWITCH_ASR_FLAG_DATA = (1 << 0), + SWITCH_ASR_FLAG_FREE_POOL = (1 << 1), + SWITCH_ASR_FLAG_CLOSED = (1 << 2), + SWITCH_ASR_FLAG_FIRE_EVENTS = (1 << 3), + SWITCH_ASR_FLAG_AUTO_RESUME = (1 << 4) } switch_asr_flag_t; /*! @@ -678,7 +666,7 @@ SWITCH_DIRECTORY_FLAG_FREE_POOL = (1 << 0) - Free interface's pool on destruct */ typedef enum { - SWITCH_DIRECTORY_FLAG_FREE_POOL = (1 << 0), + SWITCH_DIRECTORY_FLAG_FREE_POOL = (1 << 0), } switch_directory_flag_t; @@ -708,7 +696,7 @@ SWITCH_TIMER_FLAG_FREE_POOL = (1 << 0) - Free timer's pool on destruction */ typedef enum { - SWITCH_TIMER_FLAG_FREE_POOL = (1 << 0), + SWITCH_TIMER_FLAG_FREE_POOL = (1 << 0), } switch_timer_flag_t; @@ -747,18 +735,18 @@ SWITCH_FILE_OPEN = (1 << 11) - File is open */ typedef enum { - SWITCH_FILE_FLAG_READ = (1 << 0), - SWITCH_FILE_FLAG_WRITE = (1 << 1), - SWITCH_FILE_FLAG_FREE_POOL = (1 << 2), - SWITCH_FILE_DATA_SHORT = (1 << 3), - SWITCH_FILE_DATA_INT = (1 << 4), - SWITCH_FILE_DATA_FLOAT = (1 << 5), - SWITCH_FILE_DATA_DOUBLE = (1 << 6), - SWITCH_FILE_DATA_RAW = (1 << 7), - SWITCH_FILE_PAUSE = (1 << 8), - SWITCH_FILE_NATIVE = (1 << 9), - SWITCH_FILE_SEEK = (1 << 10), - SWITCH_FILE_OPEN = (1 << 11) + SWITCH_FILE_FLAG_READ = (1 << 0), + SWITCH_FILE_FLAG_WRITE = (1 << 1), + SWITCH_FILE_FLAG_FREE_POOL = (1 << 2), + SWITCH_FILE_DATA_SHORT = (1 << 3), + SWITCH_FILE_DATA_INT = (1 << 4), + SWITCH_FILE_DATA_FLOAT = (1 << 5), + SWITCH_FILE_DATA_DOUBLE = (1 << 6), + SWITCH_FILE_DATA_RAW = (1 << 7), + SWITCH_FILE_PAUSE = (1 << 8), + SWITCH_FILE_NATIVE = (1 << 9), + SWITCH_FILE_SEEK = (1 << 10), + SWITCH_FILE_OPEN = (1 << 11) } switch_file_flag_t; typedef enum { @@ -951,19 +939,8 @@ typedef struct switch_codec_implementation switch_codec_implementation_t; typedef struct switch_buffer switch_buffer_t; typedef struct switch_codec_settings switch_codec_settings_t; -typedef struct switch_io_event_hook_outgoing_channel switch_io_event_hook_outgoing_channel_t; -typedef struct switch_io_event_hook_answer_channel switch_io_event_hook_answer_channel_t; -typedef struct switch_io_event_hook_receive_message switch_io_event_hook_receive_message_t; -typedef struct switch_io_event_hook_receive_event switch_io_event_hook_receive_event_t; -typedef struct switch_io_event_hook_read_frame switch_io_event_hook_read_frame_t; -typedef struct switch_io_event_hook_write_frame switch_io_event_hook_write_frame_t; -typedef struct switch_io_event_hook_kill_channel switch_io_event_hook_kill_channel_t; -typedef struct switch_io_event_hook_waitfor_read switch_io_event_hook_waitfor_read_t; -typedef struct switch_io_event_hook_waitfor_write switch_io_event_hook_waitfor_write_t; -typedef struct switch_io_event_hook_send_dtmf switch_io_event_hook_send_dtmf_t; -typedef struct switch_io_event_hook_state_change switch_io_event_hook_state_change_t; + typedef struct switch_io_routines switch_io_routines_t; -typedef struct switch_io_event_hooks switch_io_event_hooks_t; typedef struct switch_speech_handle switch_speech_handle_t; typedef struct switch_asr_handle switch_asr_handle_t; typedef struct switch_directory_handle switch_directory_handle_t; @@ -982,43 +959,30 @@ typedef struct switch_chat_interface switch_chat_interface_t; typedef struct switch_management_interface switch_management_interface_t; typedef struct switch_core_port_allocator switch_core_port_allocator_t; typedef struct switch_media_bug switch_media_bug_t; -typedef switch_bool_t (*switch_media_bug_callback_t)(switch_media_bug_t *, void *, switch_abc_type_t); -typedef void (*switch_application_function_t)(switch_core_session_t *, char *); -typedef void (*switch_event_callback_t)(switch_event_t *); -typedef switch_caller_extension_t *(*switch_dialplan_hunt_function_t)(switch_core_session_t *, void *); -typedef struct switch_core_scheduler_task switch_core_scheduler_task_t; -typedef void (*switch_core_scheduler_func_t)(switch_core_scheduler_task_t *task); -typedef switch_status_t (*switch_state_handler_t)(switch_core_session_t *); -typedef switch_status_t (*switch_outgoing_channel_hook_t)(switch_core_session_t *, switch_caller_profile_t *, switch_core_session_t *); -typedef switch_status_t (*switch_answer_channel_hook_t)(switch_core_session_t *); -typedef switch_status_t (*switch_receive_message_hook_t)(switch_core_session_t *, switch_core_session_message_t *); -typedef switch_status_t (*switch_receive_event_hook_t)(switch_core_session_t *, switch_event_t *); -typedef switch_status_t (*switch_read_frame_hook_t)(switch_core_session_t *, switch_frame_t **, int, switch_io_flag_t, int); -typedef switch_status_t (*switch_write_frame_hook_t)(switch_core_session_t *, switch_frame_t *, int, switch_io_flag_t, int); -typedef switch_status_t (*switch_kill_channel_hook_t)(switch_core_session_t *, int); -typedef switch_status_t (*switch_waitfor_read_hook_t)(switch_core_session_t *, int, int); -typedef switch_status_t (*switch_waitfor_write_hook_t)(switch_core_session_t *, int, int); -typedef switch_status_t (*switch_send_dtmf_hook_t)(switch_core_session_t *, char *); -typedef switch_status_t (*switch_state_change_hook_t)(switch_core_session_t *); +typedef switch_bool_t (*switch_media_bug_callback_t) (switch_media_bug_t *, void *, switch_abc_type_t); +typedef void (*switch_application_function_t) (switch_core_session_t *, char *); +typedef void (*switch_event_callback_t) (switch_event_t *); +typedef switch_caller_extension_t *(*switch_dialplan_hunt_function_t) (switch_core_session_t *, void *); +typedef struct switch_scheduler_task switch_scheduler_task_t; +typedef void (*switch_scheduler_func_t) (switch_scheduler_task_t *task); +typedef switch_status_t (*switch_state_handler_t) (switch_core_session_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_api_function_t)(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, - switch_input_type_t input_type, - void *buf, - unsigned int buflen); +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_input_callback_function_t) (switch_core_session_t *session, void *input, + switch_input_type_t input_type, void *buf, + unsigned int buflen); typedef struct switch_say_interface switch_say_interface_t; typedef struct { - switch_input_callback_function_t input_callback; - void *buf; - uint32_t buflen; + switch_input_callback_function_t input_callback; + void *buf; + uint32_t buflen; } switch_input_args_t; -typedef switch_status_t (*switch_say_callback_t)(switch_core_session_t *session, - char *tosay, - switch_say_type_t type, - switch_say_method_t method, - switch_input_args_t *args); +typedef switch_status_t (*switch_say_callback_t) (switch_core_session_t *session, + char *tosay, + switch_say_type_t type, + switch_say_method_t method, switch_input_args_t *args); typedef switch_status_t (*switch_module_load_t) (switch_loadable_module_interface_t **, char *); typedef switch_status_t (*switch_module_reload_t) (void); typedef switch_status_t (*switch_module_pause_t) (void); @@ -1028,12 +992,10 @@ typedef switch_status_t (*switch_module_runtime_t) (void); typedef switch_status_t (*switch_module_shutdown_t) (void); typedef struct switch_xml *switch_xml_t; typedef struct switch_core_time_duration switch_core_time_duration_t; -typedef switch_xml_t (*switch_xml_search_function_t)(const char *section, +typedef switch_xml_t(*switch_xml_search_function_t) (const char *section, const char *tag_name, const char *key_name, - const char *key_value, - const char *params, - void *user_data); + const char *key_value, const char *params, void *user_data); /* things we don't deserve to know about */ /*! \brief A channel */ @@ -1046,9 +1008,7 @@ struct switch_media_bug; struct switch_ivr_digit_stream_parser; SWITCH_END_EXTERN_C - #endif - /* For Emacs: * Local Variables: * mode:c diff --git a/src/include/switch_utils.h b/src/include/switch_utils.h index 9ef1f9a211..fc02eef109 100644 --- a/src/include/switch_utils.h +++ b/src/include/switch_utils.h @@ -41,24 +41,19 @@ #include SWITCH_BEGIN_EXTERN_C - #define switch_bytes_per_frame(rate, interval) ((uint32_t)((float)rate / (1000.0f / (float)interval))) - #define SWITCH_SMAX 32767 #define SWITCH_SMIN -32768 #define switch_normalize_to_16bit(n) if (n > SWITCH_SMAX) n = SWITCH_SMAX / 2; else if (n < SWITCH_SMIN) n = SWITCH_SMIN / 2; - #define switch_codec2str(codec,buf,len) snprintf(buf, len, "%s@%uk@%ui", \ codec->implementation->iananame, \ codec->implementation->samples_per_second, \ codec->implementation->microseconds_per_frame / 1000) - #ifdef WIN32 #define switch_is_file_path(file) (*(file +1) == ':' || *file == '/' || strstr(file, SWITCH_URL_SEPARATOR)) #else #define switch_is_file_path(file) ((*file == '/') || strstr(file, SWITCH_URL_SEPARATOR)) #endif - /*! \brief Evaluate the truthfullness of a string expression \param expr a string expression @@ -69,7 +64,6 @@ SWITCH_BEGIN_EXTERN_C !strcasecmp(expr, "on") ||\ !strcasecmp(expr, "true") ||\ atoi(expr))) ? SWITCH_TRUE : SWITCH_FALSE - /*! \brief find local ip of the box \param buf the buffer to write the ip adress found into @@ -242,7 +236,8 @@ SWITCH_DECLARE(int) switch_socket_waitfor(switch_pollfd_t *poll, int ms); SWITCH_DECLARE(const char *) switch_cut_path(const char *in); SWITCH_DECLARE(char *) switch_string_replace(const char *string, const char *search, const char *replace); -SWITCH_DECLARE(switch_status_t) switch_string_match(const char *string, size_t string_len, const char *search, size_t search_len); +SWITCH_DECLARE(switch_status_t) switch_string_match(const char *string, size_t string_len, const char *search, + size_t search_len); #define SWITCH_READ_ACCEPTABLE(status) (status == SWITCH_STATUS_SUCCESS || status == SWITCH_STATUS_BREAK) SWITCH_DECLARE(size_t) switch_url_encode(char *url, char *buf, size_t len); @@ -258,9 +253,7 @@ SWITCH_DECLARE(char *) switch_url_decode(char *s); #endif SWITCH_END_EXTERN_C - #endif - /* For Emacs: * Local Variables: * mode:c diff --git a/src/include/switch_xml.h b/src/include/switch_xml.h index f3c06a4edc..f07e7b635b 100644 --- a/src/include/switch_xml.h +++ b/src/include/switch_xml.h @@ -62,40 +62,38 @@ ///\ingroup core1 ///\{ SWITCH_BEGIN_EXTERN_C - -#define SWITCH_XML_BUFSIZE 1024 // size of internal memory buffers - -typedef enum { - SWITCH_XML_ROOT = (1 << 0), // root - SWITCH_XML_NAMEM = (1 << 1), // name is malloced - SWITCH_XML_TXTM = (1 << 2), // txt is malloced - SWITCH_XML_DUP = (1 << 3) // attribute name and value are strduped +#define SWITCH_XML_BUFSIZE 1024 // size of internal memory buffers + typedef enum { + SWITCH_XML_ROOT = (1 << 0), // root + SWITCH_XML_NAMEM = (1 << 1), // name is malloced + SWITCH_XML_TXTM = (1 << 2), // txt is malloced + SWITCH_XML_DUP = (1 << 3) // attribute name and value are strduped } switch_xml_flag_t; /*! \brief A representation of an XML tree */ struct switch_xml { /*! tag name */ - char *name; + char *name; /*! tag attributes { name, value, name, value, ... NULL } */ - char **attr; + char **attr; /*! tag character content, empty string if none */ - char *txt; - /*! path to free on destroy*/ - char *free_path; + char *txt; + /*! path to free on destroy */ + char *free_path; /*! tag offset from start of parent tag character content */ - switch_size_t off; + switch_size_t off; /*! next tag with same name in this section at this depth */ - switch_xml_t next; - /*! next tag with different name in same section and depth*/ - switch_xml_t sibling; + switch_xml_t next; + /*! next tag with different name in same section and depth */ + switch_xml_t sibling; /*! next tag, same section and depth, in original order */ - switch_xml_t ordered; - /*! head of sub tag list, NULL if none*/ - switch_xml_t child; - /*! parent tag, NULL if current tag is root tag*/ - switch_xml_t parent; + switch_xml_t ordered; + /*! head of sub tag list, NULL if none */ + switch_xml_t child; + /*! parent tag, NULL if current tag is root tag */ + switch_xml_t parent; /*! flags */ - uint32_t flags; + uint32_t flags; }; ///\brief Given a string of xml data and its length, parses it and creates an switch_xml @@ -118,13 +116,13 @@ SWITCH_DECLARE(switch_xml_t) switch_xml_parse_fd(int fd); ///\param file a file to parse ///\return a formated xml node or NULL SWITCH_DECLARE(switch_xml_t) switch_xml_parse_file(const char *file); - + ///\brief Wrapper for switch_xml_parse_str() that accepts a file stream. Reads the entire ///\ stream into memory and then parses it. For xml files, use switch_xml_parse_file() ///\ or switch_xml_parse_fd() ///\param fp a FILE pointer to parse ///\return an xml node or NULL -SWITCH_DECLARE(switch_xml_t) switch_xml_parse_fp(FILE *fp); +SWITCH_DECLARE(switch_xml_t) switch_xml_parse_fp(FILE * fp); ///\brief returns the first child tag (one level deeper) with the given name or NULL ///\ if not found @@ -139,7 +137,8 @@ SWITCH_DECLARE(switch_xml_t) switch_xml_child(switch_xml_t xml, const char *name ///\param attrname the attribute name ///\param value the value ///\return an xml node or NULL -SWITCH_DECLARE(switch_xml_t) switch_xml_find_child(switch_xml_t node, const char *childname, const char *attrname, const char *value); +SWITCH_DECLARE(switch_xml_t) switch_xml_find_child(switch_xml_t node, const char *childname, const char *attrname, + const char *value); ///\brief returns the next tag of the same name in the same section and depth or NULL ///\ if not found @@ -152,7 +151,7 @@ SWITCH_DECLARE(switch_xml_t) switch_xml_find_child(switch_xml_t node, const char ///\param xml the xml node ///\param idx the index ///\return an xml node or NULL -switch_xml_t switch_xml_idx(switch_xml_t xml, int idx); + switch_xml_t switch_xml_idx(switch_xml_t xml, int idx); ///\brief returns the name of the given tag ///\param xml the xml node @@ -184,7 +183,7 @@ SWITCH_DECLARE(const char *) switch_xml_attr_soft(switch_xml_t xml, const char * ///\ Returns NULL if not found. ///\param xml the xml node ///\return an xml node or NULL -SWITCH_DECLARE(switch_xml_t) switch_xml_get(switch_xml_t xml, ...); +SWITCH_DECLARE(switch_xml_t) switch_xml_get(switch_xml_t xml,...); ///\brief Converts an switch_xml structure back to xml. Returns a string of xml data that ///\ must be freed. @@ -203,7 +202,7 @@ SWITCH_DECLARE(const char **) switch_xml_pi(switch_xml_t xml, const char *target ///\param xml the xml node ///\note in the case of the root node the readlock will be lifted SWITCH_DECLARE(void) switch_xml_free(switch_xml_t xml); - + ///\brief returns parser error message or empty string if none ///\param xml the xml node ///\return the error string or nothing @@ -224,7 +223,7 @@ SWITCH_DECLARE(switch_xml_t) switch_xml_new(const char *name); ///\param name the name of the tag ///\param off the offset ///\return an xml node or NULL -switch_xml_t switch_xml_add_child(switch_xml_t xml, const char *name, switch_size_t off); + switch_xml_t switch_xml_add_child(switch_xml_t xml, const char *name, switch_size_t off); ///\brief wrapper for switch_xml_add_child() that strdup()s name ///\param xml the xml node @@ -237,7 +236,7 @@ switch_xml_t switch_xml_add_child(switch_xml_t xml, const char *name, switch_siz ///\param xml the xml node ///\param txt the text ///\return an xml node or NULL -switch_xml_t switch_xml_set_txt(switch_xml_t xml, const char *txt); + switch_xml_t switch_xml_set_txt(switch_xml_t xml, const char *txt); ///\brief wrapper for switch_xml_set_txt() that strdup()s txt ///\ sets the character content for the given tag and returns the tag @@ -316,16 +315,14 @@ SWITCH_DECLARE(switch_status_t) switch_xml_locate(const char *section, const char *tag_name, const char *key_name, const char *key_value, - switch_xml_t *root, - switch_xml_t *node, - const char *params); - + switch_xml_t * root, switch_xml_t * node, const char *params); + ///\brief open a config in the core registry ///\param file_path the name of the config section e.g. modules.conf ///\param node a pointer to point to the node if it is found ///\param params optional URL formatted params to pass to external gateways ///\return the root xml node associated with the current request or NULL -SWITCH_DECLARE(switch_xml_t) switch_xml_open_cfg(const char *file_path, switch_xml_t *node, const char *params); +SWITCH_DECLARE(switch_xml_t) switch_xml_open_cfg(const char *file_path, switch_xml_t * node, const char *params); ///\brief bind a search function to an external gateway ///\param function the search function to bind @@ -333,7 +330,8 @@ SWITCH_DECLARE(switch_xml_t) switch_xml_open_cfg(const char *file_path, switch_x ///\param user_data a pointer to private data to be used during the callback ///\return SWITCH_STATUS_SUCCESS if successful ///\note gateway functions will be executed in the order they were binded until a success is found else the root registry will be used -SWITCH_DECLARE(switch_status_t) switch_xml_bind_search_function(switch_xml_search_function_t function, switch_xml_section_t sections, void *user_data); +SWITCH_DECLARE(switch_status_t) switch_xml_bind_search_function(switch_xml_search_function_t function, + switch_xml_section_t sections, void *user_data); ///\brief parse a string for a list of sections ///\param str a | delimited list of section names @@ -341,11 +339,8 @@ SWITCH_DECLARE(switch_status_t) switch_xml_bind_search_function(switch_xml_searc SWITCH_DECLARE(switch_xml_section_t) switch_xml_parse_section_string(const char *str); SWITCH_END_EXTERN_C - ///\} - #endif // _SWITCH_XML_H - /* For Emacs: * Local Variables: * mode:c diff --git a/src/mod/applications/mod_bridgecall/mod_bridgecall.c b/src/mod/applications/mod_bridgecall/mod_bridgecall.c index af5103c9ea..11abd6adbf 100644 --- a/src/mod/applications/mod_bridgecall/mod_bridgecall.c +++ b/src/mod/applications/mod_bridgecall/mod_bridgecall.c @@ -44,11 +44,11 @@ static void audio_bridge_function(switch_core_session_t *session, char *data) char *var; uint8_t no_media_bridge = 0; switch_call_cause_t cause = SWITCH_CAUSE_NORMAL_CLEARING; - uint8_t do_continue = 0; + uint8_t do_continue = 0; - if (switch_strlen_zero(data)) { - return; - } + if (switch_strlen_zero(data)) { + return; + } caller_channel = switch_core_session_get_channel(session); assert(caller_channel != NULL); @@ -60,43 +60,50 @@ static void audio_bridge_function(switch_core_session_t *session, char *data) if ((var = switch_channel_get_variable(caller_channel, "continue_on_fail"))) { do_continue = switch_true(var); } - - if (switch_channel_test_flag(caller_channel, CF_NOMEDIA) || ((var = switch_channel_get_variable(caller_channel, "no_media")) && switch_true(var))) { - if (!switch_channel_test_flag(caller_channel, CF_ANSWERED) && !switch_channel_test_flag(caller_channel, CF_EARLY_MEDIA)) { + + if (switch_channel_test_flag(caller_channel, CF_NOMEDIA) + || ((var = switch_channel_get_variable(caller_channel, "no_media")) && switch_true(var))) { + if (!switch_channel_test_flag(caller_channel, CF_ANSWERED) + && !switch_channel_test_flag(caller_channel, CF_EARLY_MEDIA)) { switch_channel_set_flag(caller_channel, CF_NOMEDIA); } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Channel is already up, delaying point-to-point mode 'till both legs are up.\n"); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, + "Channel is already up, delaying point-to-point mode 'till both legs are up.\n"); no_media_bridge = 1; } } - if (switch_ivr_originate(session, &peer_session, &cause, data, timelimit, NULL, NULL, NULL, NULL) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Originate Failed. Cause: %s\n", switch_channel_cause2str(cause)); - if (!do_continue && cause != SWITCH_CAUSE_NO_ANSWER) { - /* All Causes besides NO_ANSWER terminate the originating session unless continue_on_fail is set. - We will pass the fail cause on when we hangup.*/ - switch_channel_hangup(caller_channel, cause); - } - /* Otherwise.. nobody answered. Go back to the dialplan instructions in case there was more to do. */ + if (switch_ivr_originate(session, &peer_session, &cause, data, timelimit, NULL, NULL, NULL, NULL) != + SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Originate Failed. Cause: %s\n", + switch_channel_cause2str(cause)); + if (!do_continue && cause != SWITCH_CAUSE_NO_ANSWER) { + /* All Causes besides NO_ANSWER terminate the originating session unless continue_on_fail is set. + We will pass the fail cause on when we hangup. */ + switch_channel_hangup(caller_channel, cause); + } + /* Otherwise.. nobody answered. Go back to the dialplan instructions in case there was more to do. */ return; } else { if (no_media_bridge) { - switch_channel_t *peer_channel = switch_core_session_get_channel(peer_session); - switch_frame_t *read_frame; - /* SIP won't let us redir media until the call has been answered #$^#%& so we will proxy any early media until they do */ - while(switch_channel_ready(caller_channel) && switch_channel_ready(peer_channel) && !switch_channel_test_flag(peer_channel, CF_ANSWERED)) { - switch_status_t status = switch_core_session_read_frame(peer_session, &read_frame, -1, 0); - uint8_t bad = 1; + switch_channel_t *peer_channel = switch_core_session_get_channel(peer_session); + switch_frame_t *read_frame; + /* SIP won't let us redir media until the call has been answered #$^#%& so we will proxy any early media until they do */ + while (switch_channel_ready(caller_channel) && switch_channel_ready(peer_channel) + && !switch_channel_test_flag(peer_channel, CF_ANSWERED)) { + switch_status_t status = switch_core_session_read_frame(peer_session, &read_frame, -1, 0); + uint8_t bad = 1; - if (SWITCH_READ_ACCEPTABLE(status) && switch_core_session_write_frame(session, read_frame, -1, 0) == SWITCH_STATUS_SUCCESS) { - bad = 0; - } - if (bad) { - switch_channel_hangup(caller_channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); - switch_channel_hangup(peer_channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); - return; - } - } + if (SWITCH_READ_ACCEPTABLE(status) + && switch_core_session_write_frame(session, read_frame, -1, 0) == SWITCH_STATUS_SUCCESS) { + bad = 0; + } + if (bad) { + switch_channel_hangup(caller_channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); + switch_channel_hangup(peer_channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); + return; + } + } switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Redirecting media to point-to-point mode.\n"); switch_ivr_nomedia(switch_core_session_get_uuid(session), SMF_FORCE); @@ -130,7 +137,8 @@ static const switch_loadable_module_interface_t mod_bridgecall_module_interface /*.application_interface */ &bridge_application_interface }; -SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename) +SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, + char *filename) { /* connect my internal structure to the blank pointer passed to me */ diff --git a/src/mod/applications/mod_commands/mod_commands.c b/src/mod/applications/mod_commands/mod_commands.c index 1028ea2e4c..856d2fa97d 100644 --- a/src/mod/applications/mod_commands/mod_commands.c +++ b/src/mod/applications/mod_commands/mod_commands.c @@ -76,18 +76,15 @@ static switch_status_t status_function(char *cmd, switch_core_session_t *session stream->write_function(stream, "

FreeSWITCH Status

\n"); } - stream->write_function(stream, "UP %u year%s, %u day%s, %u hour%s, %u minute%s, %u second%s, %u millisecond%s, %u microsecond%s\n", - duration.yr, duration.yr == 1 ? "" : "s", - duration.day, duration.day == 1 ? "" : "s", - duration.hr, duration.hr == 1 ? "" : "s", - duration.min, duration.min == 1 ? "" : "s", - duration.sec, duration.sec == 1 ? "" : "s", - duration.ms, duration.ms == 1 ? "" : "s", - duration.mms, duration.mms == 1 ? "" : "s" - ); + stream->write_function(stream, + "UP %u year%s, %u day%s, %u hour%s, %u minute%s, %u second%s, %u millisecond%s, %u microsecond%s\n", + duration.yr, duration.yr == 1 ? "" : "s", duration.day, duration.day == 1 ? "" : "s", + duration.hr, duration.hr == 1 ? "" : "s", duration.min, duration.min == 1 ? "" : "s", + duration.sec, duration.sec == 1 ? "" : "s", duration.ms, duration.ms == 1 ? "" : "s", + duration.mms, duration.mms == 1 ? "" : "s"); stream->write_function(stream, "%d sessions\n", switch_core_session_count()); - + if (html) { stream->write_function(stream, "\n"); } @@ -98,8 +95,10 @@ static switch_status_t status_function(char *cmd, switch_core_session_t *session int r; refresh++; r = atoi(refresh); - if (r > 0) { - stream->write_function(stream, "\n", r, r, html ? "html=1" : ""); + if (r > 0) { + stream->write_function(stream, + "\n", r, r, + html ? "html=1" : ""); } } } @@ -120,7 +119,7 @@ static switch_status_t ctl_function(char *data, switch_core_session_t *session, if ((mydata = strdup(data))) { argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); - + if (!strcmp(argv[0], "hupall")) { arg = 1; switch_core_session_ctl(SCSC_HUPALL, &arg); @@ -134,19 +133,20 @@ static switch_status_t ctl_function(char *data, switch_core_session_t *session, arg = 0; switch_core_session_ctl(SCSC_SHUTDOWN, &arg); } else { - stream->write_function(stream, "INVALID COMMAND [%s]\nUSAGE: fsctl [hupall|pause|resume|shutdown]\n", argv[0]); + stream->write_function(stream, "INVALID COMMAND [%s]\nUSAGE: fsctl [hupall|pause|resume|shutdown]\n", + argv[0]); goto end; - } + } stream->write_function(stream, "OK\n"); - end: + end: free(mydata); } else { stream->write_function(stream, "MEM ERR\n"); } - return SWITCH_STATUS_SUCCESS; - + return SWITCH_STATUS_SUCCESS; + } static switch_status_t load_function(char *mod, switch_core_session_t *session, switch_stream_handle_t *stream) @@ -161,7 +161,8 @@ static switch_status_t load_function(char *mod, switch_core_session_t *session, return SWITCH_STATUS_SUCCESS; } - if (switch_loadable_module_load_module((char *) SWITCH_GLOBAL_dirs.mod_dir, (char *) mod, SWITCH_TRUE) == SWITCH_STATUS_SUCCESS) { + if (switch_loadable_module_load_module((char *) SWITCH_GLOBAL_dirs.mod_dir, (char *) mod, SWITCH_TRUE) == + SWITCH_STATUS_SUCCESS) { stream->write_function(stream, "OK\n"); } else { stream->write_function(stream, "ERROR\n"); @@ -178,11 +179,11 @@ static switch_status_t reload_function(char *args, switch_core_session_t *sessio if (session) { return SWITCH_STATUS_FALSE; } - + if ((xml_root = switch_xml_open_root(1, &err))) { switch_xml_free(xml_root); } - + stream->write_function(stream, "OK [%s]\n", err); return SWITCH_STATUS_SUCCESS; @@ -213,13 +214,13 @@ static switch_status_t kill_function(char *dest, switch_core_session_t *isession static switch_status_t transfer_function(char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream) { switch_core_session_t *session = NULL; - char *argv[4] = {0}; + char *argv[4] = { 0 }; int argc = 0; if (isession) { return SWITCH_STATUS_FALSE; } - + argc = switch_separate_string(cmd, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); if (switch_strlen_zero(cmd) || argc < 2 || argc > 4) { @@ -229,11 +230,11 @@ static switch_status_t transfer_function(char *cmd, switch_core_session_t *isess 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"); + stream->write_function(stream, "OK\n"); } else { stream->write_function(stream, "ERROR\n"); } @@ -249,16 +250,17 @@ static switch_status_t transfer_function(char *cmd, switch_core_session_t *isess } -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(char *cmd, switch_core_session_t *isession, + switch_stream_handle_t *stream) { switch_core_session_t *session = NULL; - char *argv[6] = {0}; + char *argv[6] = { 0 }; int argc = 0; if (isession) { return SWITCH_STATUS_FALSE; } - + argc = switch_separate_string(cmd, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); if (switch_strlen_zero(cmd) || argc < 2 || argc > 5) { @@ -269,9 +271,9 @@ static switch_status_t sched_transfer_function(char *cmd, switch_core_session_t char *dp = argv[3]; char *context = argv[4]; time_t when; - + if (*argv[0] == '+') { - when = time (NULL) + atol(argv[0] + 1); + when = time(NULL) + atol(argv[0] + 1); } else { when = atol(argv[0]); } @@ -291,13 +293,13 @@ static switch_status_t sched_transfer_function(char *cmd, switch_core_session_t static switch_status_t sched_hangup_function(char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream) { switch_core_session_t *session = NULL; - char *argv[4] = {0}; + char *argv[4] = { 0 }; int argc = 0; if (isession) { return SWITCH_STATUS_FALSE; } - + argc = switch_separate_string(cmd, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); if (switch_strlen_zero(cmd) || argc < 1) { @@ -309,7 +311,7 @@ static switch_status_t sched_hangup_function(char *cmd, switch_core_session_t *i switch_call_cause_t cause = SWITCH_CAUSE_ALLOTTED_TIMEOUT; if (*argv[0] == '+') { - when = time (NULL) + atol(argv[0] + 1); + when = time(NULL) + atol(argv[0] + 1); } else { when = atol(argv[0]); } @@ -333,14 +335,14 @@ static switch_status_t sched_hangup_function(char *cmd, switch_core_session_t *i static switch_status_t uuid_media_function(char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream) { - char *argv[4] = {0}; + char *argv[4] = { 0 }; int argc = 0; switch_status_t status = SWITCH_STATUS_FALSE; - + if (isession) { return status; } - + argc = switch_separate_string(cmd, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); if (switch_strlen_zero(cmd) || argc < 1) { @@ -363,16 +365,17 @@ static switch_status_t uuid_media_function(char *cmd, switch_core_session_t *ise } -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(char *cmd, switch_core_session_t *isession, + switch_stream_handle_t *stream) { - char *argv[4] = {0}; + char *argv[4] = { 0 }; int argc = 0; switch_status_t status = SWITCH_STATUS_FALSE; if (isession) { return status; } - + argc = switch_separate_string(cmd, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); if (switch_strlen_zero(cmd) || argc < 2) { @@ -391,7 +394,7 @@ static switch_status_t uuid_broadcast_function(char *cmd, switch_core_session_t } else { flags |= SMF_ECHO_ALEG; } - + status = switch_ivr_broadcast(argv[0], argv[1], flags); stream->write_function(stream, "+OK Message Sent\n"); } @@ -400,16 +403,17 @@ static switch_status_t uuid_broadcast_function(char *cmd, switch_core_session_t } -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(char *cmd, switch_core_session_t *isession, + switch_stream_handle_t *stream) { - char *argv[4] = {0}; + char *argv[4] = { 0 }; int argc = 0; switch_status_t status = SWITCH_STATUS_FALSE; if (isession) { return status; } - + argc = switch_separate_string(cmd, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); if (switch_strlen_zero(cmd) || argc < 3) { @@ -419,7 +423,7 @@ static switch_status_t sched_broadcast_function(char *cmd, switch_core_session_t time_t when; if (*argv[0] == '+') { - when = time (NULL) + atol(argv[0] + 1); + when = time(NULL) + atol(argv[0] + 1); } else { when = atol(argv[0]); } @@ -435,7 +439,7 @@ static switch_status_t sched_broadcast_function(char *cmd, switch_core_session_t } else { flags |= SMF_ECHO_ALEG; } - + status = switch_ivr_schedule_broadcast(when, argv[1], argv[2], flags); stream->write_function(stream, "+OK Message Scheduled\n"); } @@ -445,14 +449,14 @@ static switch_status_t sched_broadcast_function(char *cmd, switch_core_session_t static switch_status_t uuid_hold_function(char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream) { - char *argv[4] = {0}; + char *argv[4] = { 0 }; int argc = 0; switch_status_t status = SWITCH_STATUS_FALSE; - + if (isession) { return status; } - + argc = switch_separate_string(cmd, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); if (switch_strlen_zero(cmd) || argc < 1) { @@ -476,13 +480,13 @@ static switch_status_t uuid_hold_function(char *cmd, switch_core_session_t *ises static switch_status_t uuid_bridge_function(char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream) { - char *argv[4] = {0}; + char *argv[4] = { 0 }; int argc = 0; if (isession) { return SWITCH_STATUS_FALSE; } - + argc = switch_separate_string(cmd, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); if (switch_strlen_zero(cmd) || argc != 2) { @@ -496,72 +500,73 @@ static switch_status_t uuid_bridge_function(char *cmd, switch_core_session_t *is 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(char *cmd, switch_core_session_t *isession, + switch_stream_handle_t *stream) { - switch_core_session_t *session = NULL; - char *argv[4] = {0}; - char *uuid = NULL, *action = NULL, *path = NULL; + switch_core_session_t *session = NULL; + char *argv[4] = { 0 }; + char *uuid = NULL, *action = NULL, *path = NULL; int argc = 0; if (isession) { return SWITCH_STATUS_FALSE; } - + if (switch_strlen_zero(cmd)) { - goto usage; - } + goto usage; + } if ((argc = switch_separate_string(cmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) != 3) { - goto usage; - } + goto usage; + } - uuid = argv[0]; - action = argv[1]; - path = argv[2]; - - if (!(session = switch_core_session_locate(uuid))) { + uuid = argv[0]; + action = argv[1]; + path = argv[2]; + + if (!(session = switch_core_session_locate(uuid))) { stream->write_function(stream, "-Error Cannot locate session!\n"); - return SWITCH_STATUS_SUCCESS; - } - - if (switch_strlen_zero(action) || switch_strlen_zero(path)) { - goto usage; - } + return SWITCH_STATUS_SUCCESS; + } - if (!strcasecmp(action, "start")) { - switch_ivr_record_session(session, path, NULL); - } else if (!strcasecmp(action, "stop")) { - switch_ivr_stop_record_session(session, path); - } else { - goto usage; - } + if (switch_strlen_zero(action) || switch_strlen_zero(path)) { + goto usage; + } - goto done; + if (!strcasecmp(action, "start")) { + switch_ivr_record_session(session, path, NULL); + } else if (!strcasecmp(action, "stop")) { + switch_ivr_stop_record_session(session, path); + } else { + goto usage; + } - usage: + goto done; - stream->write_function(stream, "USAGE: %s\n", session_record_api_interface.syntax); - return SWITCH_STATUS_SUCCESS; + usage: - done: + stream->write_function(stream, "USAGE: %s\n", session_record_api_interface.syntax); + return SWITCH_STATUS_SUCCESS; - if (session) { - switch_core_session_rwunlock(session); - } + done: - return SWITCH_STATUS_SUCCESS; + if (session) { + switch_core_session_rwunlock(session); + } + + return SWITCH_STATUS_SUCCESS; } static switch_status_t pause_function(char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream) { switch_core_session_t *session = NULL; - char *argv[4] = {0}; + char *argv[4] = { 0 }; int argc = 0; if (isession) { return SWITCH_STATUS_FALSE; } - + argc = switch_separate_string(cmd, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); if (switch_strlen_zero(cmd) || argc < 2) { @@ -569,7 +574,7 @@ static switch_status_t pause_function(char *cmd, switch_core_session_t *isession } else { char *uuid = argv[0]; char *dest = argv[1]; - + if ((session = switch_core_session_locate(uuid))) { switch_channel_t *channel = switch_core_session_get_channel(session); @@ -593,7 +598,7 @@ static switch_status_t originate_function(char *cmd, switch_core_session_t *ises { switch_channel_t *caller_channel; switch_core_session_t *caller_session; - char *argv[7] = {0}; + char *argv[7] = { 0 }; int i = 0, x, argc = 0; char *aleg, *exten, *dp, *context, *cid_name, *cid_num; uint32_t timeout = 60; @@ -612,12 +617,12 @@ static switch_status_t originate_function(char *cmd, switch_core_session_t *ises return SWITCH_STATUS_SUCCESS; } - for(x = 0; x < argc; x++) { + for (x = 0; x < argc; x++) { if (!strcasecmp(argv[x], "undef")) { argv[x] = NULL; } } - + if (!strcasecmp(argv[0], "machine")) { machine = 1; i++; @@ -629,7 +634,7 @@ static switch_status_t originate_function(char *cmd, switch_core_session_t *ises context = argv[i++]; cid_name = argv[i++]; cid_num = argv[i++]; - + if (!dp) { dp = "XML"; } @@ -642,20 +647,22 @@ static switch_status_t originate_function(char *cmd, switch_core_session_t *ises timeout = atoi(argv[6]); } - if (switch_ivr_originate(NULL, &caller_session, &cause, aleg, timeout, NULL, cid_name, cid_num, NULL) != SWITCH_STATUS_SUCCESS) { + if (switch_ivr_originate(NULL, &caller_session, &cause, aleg, timeout, NULL, cid_name, cid_num, NULL) != + SWITCH_STATUS_SUCCESS) { if (machine) { stream->write_function(stream, "fail: %s\n", switch_channel_cause2str(cause)); } 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)); } return SWITCH_STATUS_SUCCESS; - } + } caller_channel = switch_core_session_get_channel(caller_session); assert(caller_channel != NULL); switch_channel_clear_state_handler(caller_channel, NULL); - if (*exten == '&' && *(exten + 1)) { + if (*exten == '&' && *(exten + 1)) { switch_caller_extension_t *extension = NULL; char *app_name = switch_core_session_strdup(caller_session, (exten + 1)); char *arg = NULL, *e; @@ -696,7 +703,8 @@ struct holder { int print_title; }; -static int show_callback(void *pArg, int argc, char **argv, char **columnNames){ +static int show_callback(void *pArg, int argc, char **argv, char **columnNames) +{ struct holder *holder = (struct holder *) pArg; int x; @@ -706,26 +714,29 @@ static int show_callback(void *pArg, int argc, char **argv, char **columnNames){ holder->stream->write_function(holder->stream, "\n"); } - for(x = 0; x < argc; x++) { + for (x = 0; x < argc; x++) { if (holder->http) { holder->stream->write_function(holder->stream, ""); - holder->stream->write_function(holder->stream, "%s%s", columnNames[x], x == (argc - 1) ? "\n" : ""); + holder->stream->write_function(holder->stream, "%s%s", columnNames[x], + x == (argc - 1) ? "\n" : ""); } else { holder->stream->write_function(holder->stream, "%s%s", columnNames[x], x == (argc - 1) ? "\n" : ","); } } - } + } if (holder->http) { holder->stream->write_function(holder->stream, "", holder->count % 2 == 0 ? "eeeeee" : "ffffff"); } - for(x = 0; x < argc; x++) { + for (x = 0; x < argc; x++) { if (holder->http) { holder->stream->write_function(holder->stream, ""); - holder->stream->write_function(holder->stream, "%s%s", argv[x] ? argv[x] : "", x == (argc - 1) ? "\n" : ""); + holder->stream->write_function(holder->stream, "%s%s", argv[x] ? argv[x] : "", + x == (argc - 1) ? "\n" : ""); } else { - holder->stream->write_function(holder->stream, "%s%s", argv[x] ? argv[x] : "", x == (argc - 1) ? "\n" : ","); + holder->stream->write_function(holder->stream, "%s%s", argv[x] ? argv[x] : "", + x == (argc - 1) ? "\n" : ","); } } @@ -738,7 +749,7 @@ static switch_status_t show_function(char *cmd, switch_core_session_t *session, char sql[1024]; char *errmsg; switch_core_db_t *db = switch_core_db_handle(); - struct holder holder = {0}; + struct holder holder = { 0 }; int help = 0; if (session) { @@ -747,7 +758,7 @@ static switch_status_t show_function(char *cmd, switch_core_session_t *session, if (stream->event) { holder.http = switch_event_get_header(stream->event, "http-host"); - } + } holder.print_title = 1; @@ -756,14 +767,14 @@ static switch_status_t show_function(char *cmd, switch_core_session_t *session, if (!cmd) { stream->write_function(stream, "USAGE: %s\n", show_api_interface.syntax); return SWITCH_STATUS_SUCCESS; - } else if ( !strcmp(cmd,"codec") || !strcmp(cmd,"dialplan") || !strcmp(cmd,"file") || !strcmp(cmd,"timer")) { - sprintf (sql, "select type, name from interfaces where type = '%s'", cmd); - } else if (!strcmp(cmd,"application") || !strcmp(cmd,"api")) { - sprintf (sql, "select name, description, syntax from interfaces where type = '%s' and description != ''" , cmd); - } else if ( !strcmp(cmd,"calls")) { - sprintf (sql, "select * from calls"); - } else if ( !strcmp(cmd,"channels")) { - sprintf (sql, "select * from channels"); + } else if (!strcmp(cmd, "codec") || !strcmp(cmd, "dialplan") || !strcmp(cmd, "file") || !strcmp(cmd, "timer")) { + sprintf(sql, "select type, name from interfaces where type = '%s'", cmd); + } else if (!strcmp(cmd, "application") || !strcmp(cmd, "api")) { + sprintf(sql, "select name, description, syntax from interfaces where type = '%s' and description != ''", cmd); + } else if (!strcmp(cmd, "calls")) { + sprintf(sql, "select * from calls"); + } else if (!strcmp(cmd, "channels")) { + sprintf(sql, "select * from channels"); } else if (!strncasecmp(cmd, "help", 4)) { char *cmdname = NULL; @@ -771,15 +782,16 @@ static switch_status_t show_function(char *cmd, switch_core_session_t *session, holder.print_title = 0; if ((cmdname = strchr(cmd, ' ')) != 0) { *cmdname++ = '\0'; - snprintf (sql, sizeof(sql) - 1, "select name, syntax, description from interfaces where type = 'api' and name = '%s'", cmdname); + snprintf(sql, sizeof(sql) - 1, + "select name, syntax, description from interfaces where type = 'api' and name = '%s'", cmdname); } else { - snprintf (sql, sizeof(sql) - 1, "select name, syntax, description from interfaces where type = 'api'"); + snprintf(sql, sizeof(sql) - 1, "select name, syntax, description from interfaces where type = 'api'"); } } else { stream->write_function(stream, "USAGE: %s\n", show_api_interface.syntax); return SWITCH_STATUS_SUCCESS; } - + holder.stream = stream; holder.count = 0; @@ -794,7 +806,7 @@ static switch_status_t show_function(char *cmd, switch_core_session_t *session, } if (errmsg) { - stream->write_function(stream, "SQL ERR [%s]\n",errmsg); + stream->write_function(stream, "SQL ERR [%s]\n", errmsg); switch_core_db_free(errmsg); errmsg = NULL; } else if (help) { @@ -811,7 +823,7 @@ static switch_status_t show_function(char *cmd, switch_core_session_t *session, static switch_status_t version_function(char *cmd, switch_core_session_t *session, switch_stream_handle_t *stream) { 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); stream->write_function(stream, version_string); return SWITCH_STATUS_SUCCESS; @@ -822,10 +834,10 @@ static switch_status_t help_function(char *cmd, switch_core_session_t *session, char showcmd[1024]; int all = 0; if (switch_strlen_zero(cmd)) { - sprintf (showcmd, "help"); + sprintf(showcmd, "help"); all = 1; } else { - snprintf(showcmd, sizeof(showcmd) -1, "help %s", cmd); + snprintf(showcmd, sizeof(showcmd) - 1, "help %s", cmd); } if (all) { @@ -986,7 +998,8 @@ static switch_api_interface_t originate_api_interface = { /*.interface_name */ "originate", /*.desc */ "Originate a Call", /*.function */ originate_function, - /*.syntax */ " |&() [] [] [] [] []", + /*.syntax */ + " |&() [] [] [] [] []", /*.next */ &kill_api_interface }; @@ -1000,7 +1013,8 @@ static const switch_loadable_module_interface_t mod_commands_module_interface = /*.api_interface */ &originate_api_interface }; -SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename) +SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, + char *filename) { /* connect my internal structure to the blank pointer passed to me */ *module_interface = &mod_commands_module_interface; diff --git a/src/mod/applications/mod_conference/mod_conference.c b/src/mod/applications/mod_conference/mod_conference.c index a040e86ab8..9f901ce517 100644 --- a/src/mod/applications/mod_conference/mod_conference.c +++ b/src/mod/applications/mod_conference/mod_conference.c @@ -39,7 +39,7 @@ static char *global_cf_name = "conference.conf"; static switch_api_interface_t conf_api_interface; /* Size to allocate for audio buffers */ -#define CONF_BUFFER_SIZE 1024 * 128 +#define CONF_BUFFER_SIZE 1024 * 128 #define CONF_EVENT_MAINT "conference::maintenence" #define CONF_DEFAULT_LEADIN 20 @@ -53,7 +53,7 @@ static switch_api_interface_t conf_api_interface; #endif typedef enum { - FILE_STOP_CURRENT, + FILE_STOP_CURRENT, FILE_STOP_ALL } file_stop_t; @@ -70,20 +70,20 @@ static struct { } globals; typedef enum { - CALLER_CONTROL_MUTE, - CALLER_CONTROL_DEAF_MUTE, - CALLER_CONTROL_ENERGY_UP, - CALLER_CONTROL_ENERGY_EQU_CONF, - CALLER_CONTROL_ENERGEY_DN, - CALLER_CONTROL_VOL_TALK_UP, - CALLER_CONTROL_VOL_TALK_ZERO, - CALLER_CONTROL_VOL_TALK_DN, - CALLER_CONTROL_VOL_LISTEN_UP, - CALLER_CONTROL_VOL_LISTEN_ZERO, - CALLER_CONTROL_VOL_LISTEN_DN, - CALLER_CONTROL_HANGUP, - CALLER_CONTROL_MENU, - CALLER_CONTROL_DIAL, + CALLER_CONTROL_MUTE, + CALLER_CONTROL_DEAF_MUTE, + CALLER_CONTROL_ENERGY_UP, + CALLER_CONTROL_ENERGY_EQU_CONF, + CALLER_CONTROL_ENERGEY_DN, + CALLER_CONTROL_VOL_TALK_UP, + CALLER_CONTROL_VOL_TALK_ZERO, + CALLER_CONTROL_VOL_TALK_DN, + CALLER_CONTROL_VOL_LISTEN_UP, + CALLER_CONTROL_VOL_LISTEN_ZERO, + CALLER_CONTROL_VOL_LISTEN_DN, + CALLER_CONTROL_HANGUP, + CALLER_CONTROL_MENU, + CALLER_CONTROL_DIAL, CALLER_CONTROL_EVENT } caller_control_t; @@ -97,7 +97,7 @@ typedef struct caller_control_fn_table { char *key; char *digits; caller_control_t action; - void (*handler)(conference_member_t *, struct caller_control_actions *); + void (*handler) (conference_member_t *, struct caller_control_actions *); } caller_control_fn_table_t; typedef struct caller_control_actions { @@ -112,33 +112,33 @@ typedef struct caller_control_menu_info { } caller_control_menu_info_t; typedef enum { - MFLAG_RUNNING = (1 << 0), - MFLAG_CAN_SPEAK = (1 << 1), - MFLAG_CAN_HEAR = (1 << 2), - MFLAG_KICKED = (1 << 3), - MFLAG_ITHREAD = (1 << 4), + MFLAG_RUNNING = (1 << 0), + MFLAG_CAN_SPEAK = (1 << 1), + MFLAG_CAN_HEAR = (1 << 2), + MFLAG_KICKED = (1 << 3), + MFLAG_ITHREAD = (1 << 4), MFLAG_NOCHANNEL = (1 << 5), - MFLAG_INTREE = (1 << 6), + MFLAG_INTREE = (1 << 6), MFLAG_WASTE_BANDWIDTH = (1 << 7), MFLAG_FLUSH_BUFFER = (1 << 8) } member_flag_t; typedef enum { - CFLAG_RUNNING = (1 << 0), - CFLAG_DYNAMIC = (1 << 1), - CFLAG_ENFORCE_MIN = (1 << 2), - CFLAG_DESTRUCT = (1 << 3), - CFLAG_LOCKED = (1 << 4), + CFLAG_RUNNING = (1 << 0), + CFLAG_DYNAMIC = (1 << 1), + CFLAG_ENFORCE_MIN = (1 << 2), + CFLAG_DESTRUCT = (1 << 3), + CFLAG_LOCKED = (1 << 4), CFLAG_ANSWERED = (1 << 5) } conf_flag_t; typedef enum { - RFLAG_CAN_SPEAK = (1 << 0), + RFLAG_CAN_SPEAK = (1 << 0), RFLAG_CAN_HEAR = (1 << 1) } relation_flag_t; typedef enum { - NODE_TYPE_FILE, + NODE_TYPE_FILE, NODE_TYPE_SPEECH } node_type_t; @@ -178,10 +178,10 @@ typedef struct conference_obj { char *kicked_sound; char *caller_id_name; char *caller_id_number; - char *sound_prefix; - uint32_t max_members; - char *maxmember_sound; - uint32_t anounce_count; + char *sound_prefix; + uint32_t max_members; + char *maxmember_sound; + uint32_t anounce_count; switch_ivr_digit_stream_parser_t *dtmf_parser; char *pin; char *pin_sound; @@ -196,7 +196,7 @@ typedef struct conference_obj { uint32_t interval; switch_mutex_t *mutex; conference_member_t *members; - switch_mutex_t *member_mutex; + switch_mutex_t *member_mutex; conference_file_node_t *fnode; conference_file_node_t *async_fnode; switch_memory_pool_t *pool; @@ -254,12 +254,12 @@ typedef struct conference_record { } conference_record_t; typedef enum { - CONF_API_SUB_ARGS_SPLIT, - CONF_API_SUB_MEMBER_TARGET, + CONF_API_SUB_ARGS_SPLIT, + CONF_API_SUB_MEMBER_TARGET, CONF_API_SUB_ARGS_AS_ONE } conference_fntype_t; -typedef void (*void_fn_t)(void); +typedef void (*void_fn_t) (void); /* API command parser */ typedef struct api_command { @@ -272,69 +272,56 @@ typedef struct api_command { /* Function Prototypes */ static uint32_t next_member_id(void); -static conference_relationship_t *member_get_relationship(conference_member_t *member, conference_member_t *other_member); -static conference_member_t *conference_member_get(conference_obj_t *conference, uint32_t id); -static conference_relationship_t *member_add_relationship(conference_member_t *member, uint32_t id); -static switch_status_t member_del_relationship(conference_member_t *member, uint32_t id); -static switch_status_t conference_add_member(conference_obj_t *conference, conference_member_t *member); -static switch_status_t conference_del_member(conference_obj_t *conference, conference_member_t *member); +static conference_relationship_t *member_get_relationship(conference_member_t * member, + conference_member_t * other_member); +static conference_member_t *conference_member_get(conference_obj_t * conference, uint32_t id); +static conference_relationship_t *member_add_relationship(conference_member_t * member, uint32_t id); +static switch_status_t member_del_relationship(conference_member_t * member, uint32_t id); +static switch_status_t conference_add_member(conference_obj_t * conference, conference_member_t * member); +static switch_status_t conference_del_member(conference_obj_t * conference, conference_member_t * member); static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, void *obj); -static void conference_loop_output(conference_member_t *member); -static uint32_t conference_stop_file(conference_obj_t *conference, file_stop_t stop); -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 void conference_list(conference_obj_t *conference, switch_stream_handle_t *stream, char *delim); +static void conference_loop_output(conference_member_t * member); +static uint32_t conference_stop_file(conference_obj_t * conference, file_stop_t stop); +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 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 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, - switch_core_session_t *session, - char *bridgeto, - uint32_t timeout, - char *flags, - char *cid_name, - char *cid_num, - switch_call_cause_t *cause); -static switch_status_t conference_outcall_bg(conference_obj_t *conference, + switch_core_session_t *session, + char *bridgeto, + uint32_t timeout, + char *flags, char *cid_name, char *cid_num, switch_call_cause_t *cause); +static switch_status_t conference_outcall_bg(conference_obj_t * conference, char *conference_name, - switch_core_session_t *session, - char *bridgeto, - uint32_t timeout, - char *flags, - char *cid_name, - char *cid_num); + switch_core_session_t *session, + char *bridgeto, + uint32_t timeout, char *flags, char *cid_name, char *cid_num); static void conference_function(switch_core_session_t *session, char *data); -static void launch_conference_thread(conference_obj_t *conference); +static void launch_conference_thread(conference_obj_t * conference); static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, void *obj); -static switch_status_t conference_local_play_file(conference_obj_t *conference, - switch_core_session_t *session, char *path, uint32_t leadin, char *buf, switch_size_t len); -static switch_status_t conference_member_play_file(conference_member_t *member, char *file, uint32_t leadin); -static switch_status_t conference_member_say(conference_member_t *member, char *text, uint32_t leadin); -static uint32_t conference_member_stop_file(conference_member_t *member, file_stop_t stop); +static switch_status_t conference_local_play_file(conference_obj_t * conference, + switch_core_session_t *session, char *path, uint32_t leadin, + char *buf, switch_size_t len); +static switch_status_t conference_member_play_file(conference_member_t * member, char *file, uint32_t leadin); +static switch_status_t conference_member_say(conference_member_t * member, char *text, uint32_t leadin); +static uint32_t conference_member_stop_file(conference_member_t * member, file_stop_t stop); static conference_obj_t *conference_new(char *name, conf_xml_cfg_t cfg, switch_memory_pool_t *pool); static switch_status_t chat_send(char *proto, char *from, char *to, char *subject, char *body, char *hint); -static void launch_conference_record_thread(conference_obj_t *conference, char *path); +static void launch_conference_record_thread(conference_obj_t * conference, char *path); -typedef switch_status_t (*conf_api_args_cmd_t)(conference_obj_t*, switch_stream_handle_t*, int, char**); -typedef switch_status_t (*conf_api_member_cmd_t)(conference_member_t*, switch_stream_handle_t*, void*); -typedef switch_status_t (*conf_api_text_cmd_t)(conference_obj_t*, switch_stream_handle_t*, const char*); +typedef switch_status_t (*conf_api_args_cmd_t) (conference_obj_t *, switch_stream_handle_t *, int, char **); +typedef switch_status_t (*conf_api_member_cmd_t) (conference_member_t *, switch_stream_handle_t *, void *); +typedef switch_status_t (*conf_api_text_cmd_t) (conference_obj_t *, switch_stream_handle_t *, const char *); -static void conference_member_itterator(conference_obj_t *conference, - switch_stream_handle_t *stream, - conf_api_member_cmd_t pfncallback, - void *data); -static switch_status_t conf_api_sub_mute(conference_member_t *member, - switch_stream_handle_t *stream, - void *data); -static switch_status_t conf_api_sub_unmute(conference_member_t *member, - switch_stream_handle_t *stream, - void *data); -static switch_status_t conf_api_sub_deaf(conference_member_t *member, - switch_stream_handle_t *stream, - void *data); -static switch_status_t conf_api_sub_undeaf(conference_member_t *member, - switch_stream_handle_t *stream, - void *data); +static void conference_member_itterator(conference_obj_t * conference, + switch_stream_handle_t *stream, conf_api_member_cmd_t pfncallback, void *data); +static switch_status_t conf_api_sub_mute(conference_member_t * member, switch_stream_handle_t *stream, void *data); +static switch_status_t conf_api_sub_unmute(conference_member_t * member, switch_stream_handle_t *stream, void *data); +static switch_status_t conf_api_sub_deaf(conference_member_t * member, switch_stream_handle_t *stream, void *data); +static switch_status_t conf_api_sub_undeaf(conference_member_t * member, switch_stream_handle_t *stream, void *data); /* Return a Distinct ID # */ static uint32_t next_member_id(void) @@ -349,7 +336,8 @@ static uint32_t next_member_id(void) } /* if other_member has a relationship with member, produce it */ -static conference_relationship_t *member_get_relationship(conference_member_t *member, conference_member_t *other_member) +static conference_relationship_t *member_get_relationship(conference_member_t * member, + conference_member_t * other_member) { conference_relationship_t *rel = NULL; @@ -368,7 +356,7 @@ static conference_relationship_t *member_get_relationship(conference_member_t *m /* 0 matches everyone. (We will still test the others brcause a real match carries more clout) */ - if (rel->id == 0) { + if (rel->id == 0) { global = rel; } } @@ -386,54 +374,54 @@ static conference_relationship_t *member_get_relationship(conference_member_t *m } /* traverse the conference member list for the specified member id and return it's pointer */ -static conference_member_t *conference_member_get(conference_obj_t *conference, uint32_t id) +static conference_member_t *conference_member_get(conference_obj_t * conference, uint32_t id) { conference_member_t *member = NULL; - assert(conference != NULL); - assert(id != 0); + assert(conference != NULL); + assert(id != 0); - switch_mutex_lock(conference->member_mutex); - for(member = conference->members; member; member = member->next) { - - if (switch_test_flag(member, MFLAG_NOCHANNEL)) { - continue; - } - - if (member->id == id) { - break; - } - } + switch_mutex_lock(conference->member_mutex); + for (member = conference->members; member; member = member->next) { - if (member && !switch_test_flag(member, MFLAG_INTREE)) { - member = NULL; - } + if (switch_test_flag(member, MFLAG_NOCHANNEL)) { + continue; + } - switch_mutex_unlock(conference->member_mutex); + if (member->id == id) { + break; + } + } + + if (member && !switch_test_flag(member, MFLAG_INTREE)) { + member = NULL; + } + + switch_mutex_unlock(conference->member_mutex); return member; } /* stop the specified recording */ -static switch_status_t conference_record_stop(conference_obj_t *conference, char *path) +static switch_status_t conference_record_stop(conference_obj_t * conference, char *path) { conference_member_t *member = NULL; int count = 0; - assert (conference != NULL); - switch_mutex_lock(conference->member_mutex); - for(member = conference->members; member; member = member->next) { - if (switch_test_flag(member, MFLAG_NOCHANNEL) && (!path || !strcmp(path, member->rec_path))) { - switch_clear_flag_locked(member, MFLAG_RUNNING); - count++; - } - } - switch_mutex_unlock(conference->member_mutex); + assert(conference != NULL); + switch_mutex_lock(conference->member_mutex); + for (member = conference->members; member; member = member->next) { + if (switch_test_flag(member, MFLAG_NOCHANNEL) && (!path || !strcmp(path, member->rec_path))) { + switch_clear_flag_locked(member, MFLAG_RUNNING); + count++; + } + } + switch_mutex_unlock(conference->member_mutex); return count; } /* Add a custom relationship to a member */ -static conference_relationship_t *member_add_relationship(conference_member_t *member, uint32_t id) +static conference_relationship_t *member_add_relationship(conference_member_t * member, uint32_t id) { conference_relationship_t *rel = NULL; @@ -450,7 +438,7 @@ static conference_relationship_t *member_add_relationship(conference_member_t *m } /* Remove a custom relationship from a member */ -static switch_status_t member_del_relationship(conference_member_t *member, uint32_t id) +static switch_status_t member_del_relationship(conference_member_t * member, uint32_t id) { switch_status_t status = SWITCH_STATUS_FALSE; conference_relationship_t *rel, *last = NULL; @@ -477,174 +465,179 @@ static switch_status_t member_del_relationship(conference_member_t *member, uint } /* Gain exclusive access and add the member to the list */ -static switch_status_t conference_add_member(conference_obj_t *conference, conference_member_t *member) +static switch_status_t conference_add_member(conference_obj_t * conference, conference_member_t * member) { switch_status_t status = SWITCH_STATUS_FALSE; - switch_event_t *event; - char msg[512]; // for conference count anouncement + switch_event_t *event; + char msg[512]; // for conference count anouncement - assert(conference != NULL); - assert(member != NULL); + assert(conference != NULL); + assert(member != NULL); - switch_mutex_lock(conference->mutex); - switch_mutex_lock(member->audio_in_mutex); - switch_mutex_lock(member->audio_out_mutex); - switch_mutex_lock(member->flag_mutex); - - switch_mutex_lock(conference->member_mutex); - member->conference = conference; - member->next = conference->members; - member->energy_level = conference->energy_level; - conference->members = member; - switch_set_flag(member, MFLAG_INTREE); - switch_mutex_unlock(conference->member_mutex); + switch_mutex_lock(conference->mutex); + switch_mutex_lock(member->audio_in_mutex); + switch_mutex_lock(member->audio_out_mutex); + switch_mutex_lock(member->flag_mutex); - if (!switch_test_flag(member, MFLAG_NOCHANNEL)) { - conference->count++; - if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) { - switch_event_add_header(event, SWITCH_STACK_BOTTOM, "proto", CONF_CHAT_PROTO); - switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", "%s", conference->name); - switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", conference->name, conference->domain); - switch_event_add_header(event, SWITCH_STACK_BOTTOM, "status", "Active (%d caller%s)", conference->count, conference->count == 1 ? "" : "s"); - switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_type", "presence"); - switch_event_fire(&event); - } + switch_mutex_lock(conference->member_mutex); + member->conference = conference; + member->next = conference->members; + member->energy_level = conference->energy_level; + conference->members = member; + switch_set_flag(member, MFLAG_INTREE); + switch_mutex_unlock(conference->member_mutex); - if (conference->count > 1 && conference->enter_sound) { - conference_play_file(conference, conference->enter_sound, CONF_DEFAULT_LEADIN, switch_core_session_get_channel(member->session), 0); - } + if (!switch_test_flag(member, MFLAG_NOCHANNEL)) { + conference->count++; + if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) { + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "proto", CONF_CHAT_PROTO); + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", "%s", conference->name); + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", conference->name, conference->domain); + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "status", "Active (%d caller%s)", conference->count, + conference->count == 1 ? "" : "s"); + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_type", "presence"); + switch_event_fire(&event); + } - // anounce the total number of members in the conference - if (conference->count >= conference->anounce_count && conference->anounce_count > 1) { - snprintf(msg, sizeof(msg), "There are %d callers", conference->count); - conference_member_say(member, msg, CONF_DEFAULT_LEADIN); - } else if (conference->count == 1) { - if (conference->alone_sound) { - conference_play_file(conference, conference->alone_sound, CONF_DEFAULT_LEADIN, switch_core_session_get_channel(member->session), 0); - } else { - snprintf(msg, sizeof(msg), "You are currently the only person in this conference."); - conference_member_say(member, msg, CONF_DEFAULT_LEADIN); - } - } + if (conference->count > 1 && conference->enter_sound) { + conference_play_file(conference, conference->enter_sound, CONF_DEFAULT_LEADIN, + switch_core_session_get_channel(member->session), 0); + } + // anounce the total number of members in the conference + if (conference->count >= conference->anounce_count && conference->anounce_count > 1) { + snprintf(msg, sizeof(msg), "There are %d callers", conference->count); + conference_member_say(member, msg, CONF_DEFAULT_LEADIN); + } else if (conference->count == 1) { + if (conference->alone_sound) { + conference_play_file(conference, conference->alone_sound, CONF_DEFAULT_LEADIN, + switch_core_session_get_channel(member->session), 0); + } else { + snprintf(msg, sizeof(msg), "You are currently the only person in this conference."); + conference_member_say(member, msg, CONF_DEFAULT_LEADIN); + } + } - if (conference->min && conference->count >= conference->min) { - switch_set_flag(conference, CFLAG_ENFORCE_MIN); - } - - if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) { - switch_channel_t *channel = switch_core_session_get_channel(member->session); - switch_channel_event_set_data(channel, event); + if (conference->min && conference->count >= conference->min) { + switch_set_flag(conference, CFLAG_ENFORCE_MIN); + } - switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", conference->name); - switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id); - switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "add-member"); - switch_event_fire(&event); - } - } - switch_mutex_unlock(member->flag_mutex); - switch_mutex_unlock(member->audio_out_mutex); - switch_mutex_unlock(member->audio_in_mutex); + if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) { + switch_channel_t *channel = switch_core_session_get_channel(member->session); + switch_channel_event_set_data(channel, event); + + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", conference->name); + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id); + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "add-member"); + switch_event_fire(&event); + } + } + switch_mutex_unlock(member->flag_mutex); + switch_mutex_unlock(member->audio_out_mutex); + switch_mutex_unlock(member->audio_in_mutex); + + switch_mutex_unlock(conference->mutex); + status = SWITCH_STATUS_SUCCESS; - switch_mutex_unlock(conference->mutex); - status = SWITCH_STATUS_SUCCESS; - return status; } /* Gain exclusive access and remove the member from the list */ -static switch_status_t conference_del_member(conference_obj_t *conference, conference_member_t *member) +static switch_status_t conference_del_member(conference_obj_t * conference, conference_member_t * member) { switch_status_t status = SWITCH_STATUS_FALSE; - conference_member_t *imember, *last = NULL; - switch_event_t *event; + conference_member_t *imember, *last = NULL; + switch_event_t *event; - assert(conference != NULL); - assert(member != NULL); - - switch_mutex_lock(conference->mutex); - switch_mutex_lock(conference->member_mutex); - switch_mutex_lock(member->audio_in_mutex); - switch_mutex_lock(member->audio_out_mutex); - switch_mutex_lock(member->flag_mutex); - switch_clear_flag(member, MFLAG_INTREE); - - for (imember = conference->members; imember; imember = imember->next) { - if (imember == member ) { - if (last) { - last->next = imember->next; - } else { - conference->members = imember->next; - } - break; - } - last = imember; - } + assert(conference != NULL); + assert(member != NULL); - /* Close Unused Handles */ - if (member->fnode) { - conference_file_node_t *fnode, *cur; - switch_memory_pool_t *pool; + switch_mutex_lock(conference->mutex); + switch_mutex_lock(conference->member_mutex); + switch_mutex_lock(member->audio_in_mutex); + switch_mutex_lock(member->audio_out_mutex); + switch_mutex_lock(member->flag_mutex); + switch_clear_flag(member, MFLAG_INTREE); - fnode = member->fnode; - while(fnode) { - cur = fnode; - fnode = fnode->next; + for (imember = conference->members; imember; imember = imember->next) { + if (imember == member) { + if (last) { + last->next = imember->next; + } else { + conference->members = imember->next; + } + break; + } + last = imember; + } - if (cur->type == NODE_TYPE_SPEECH) { - switch_speech_flag_t flags = SWITCH_SPEECH_FLAG_NONE; - switch_core_speech_close(&cur->sh, &flags); - } else { - switch_core_file_close(&cur->fh); - } + /* Close Unused Handles */ + if (member->fnode) { + conference_file_node_t *fnode, *cur; + switch_memory_pool_t *pool; - pool = cur->pool; - switch_core_destroy_memory_pool(&pool); - } - } + fnode = member->fnode; + while (fnode) { + cur = fnode; + fnode = fnode->next; - member->conference = NULL; + if (cur->type == NODE_TYPE_SPEECH) { + switch_speech_flag_t flags = SWITCH_SPEECH_FLAG_NONE; + switch_core_speech_close(&cur->sh, &flags); + } else { + switch_core_file_close(&cur->fh); + } - if (!switch_test_flag(member, MFLAG_NOCHANNEL)) { - conference->count--; - if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) { - switch_event_add_header(event, SWITCH_STACK_BOTTOM, "proto", CONF_CHAT_PROTO); - switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", "%s", conference->name); - switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", conference->name, conference->domain); - switch_event_add_header(event, SWITCH_STACK_BOTTOM, "status", "Active (%d caller%s)", conference->count, conference->count == 1 ? "" : "s"); - switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_type", "presence"); - switch_event_fire(&event); - } + pool = cur->pool; + switch_core_destroy_memory_pool(&pool); + } + } - if ((conference->min && switch_test_flag(conference, CFLAG_ENFORCE_MIN) && conference->count < conference->min) - || (switch_test_flag(conference, CFLAG_DYNAMIC) && conference->count == 0) ) { - switch_set_flag(conference, CFLAG_DESTRUCT); - } else { - if (conference->exit_sound) { - conference_play_file(conference, conference->exit_sound, 0, switch_core_session_get_channel(member->session), 0); - } - if (conference->count == 1 && conference->alone_sound) { - conference_play_file(conference, conference->alone_sound, 0, switch_core_session_get_channel(member->session), 0); - } - } + member->conference = NULL; - if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) { - switch_channel_t *channel = switch_core_session_get_channel(member->session); - switch_channel_event_set_data(channel, event); + if (!switch_test_flag(member, MFLAG_NOCHANNEL)) { + conference->count--; + if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) { + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "proto", CONF_CHAT_PROTO); + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", "%s", conference->name); + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", conference->name, conference->domain); + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "status", "Active (%d caller%s)", conference->count, + conference->count == 1 ? "" : "s"); + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_type", "presence"); + switch_event_fire(&event); + } + + if ((conference->min && switch_test_flag(conference, CFLAG_ENFORCE_MIN) && conference->count < conference->min) + || (switch_test_flag(conference, CFLAG_DYNAMIC) && conference->count == 0)) { + switch_set_flag(conference, CFLAG_DESTRUCT); + } else { + if (conference->exit_sound) { + conference_play_file(conference, conference->exit_sound, 0, + switch_core_session_get_channel(member->session), 0); + } + if (conference->count == 1 && conference->alone_sound) { + conference_play_file(conference, conference->alone_sound, 0, + switch_core_session_get_channel(member->session), 0); + } + } + + if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) { + switch_channel_t *channel = switch_core_session_get_channel(member->session); + switch_channel_event_set_data(channel, event); + + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", conference->name); + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id); + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "del-member"); + switch_event_fire(&event); + } + } + switch_mutex_unlock(conference->member_mutex); + switch_mutex_unlock(member->flag_mutex); + switch_mutex_unlock(member->audio_out_mutex); + switch_mutex_unlock(member->audio_in_mutex); + switch_mutex_unlock(conference->mutex); + status = SWITCH_STATUS_SUCCESS; - switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", conference->name); - switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id); - switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "del-member"); - switch_event_fire(&event); - } - } - switch_mutex_unlock(conference->member_mutex); - switch_mutex_unlock(member->flag_mutex); - switch_mutex_unlock(member->audio_out_mutex); - switch_mutex_unlock(member->audio_in_mutex); - switch_mutex_unlock(conference->mutex); - status = SWITCH_STATUS_SUCCESS; - return status; } @@ -657,7 +650,7 @@ static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, v uint32_t samples = switch_bytes_per_frame(conference->rate, conference->interval); uint32_t bytes = samples * 2; uint8_t ready = 0; - switch_timer_t timer = {0}; + switch_timer_t timer = { 0 }; switch_event_t *event; uint8_t *file_frame; uint8_t *async_file_frame; @@ -666,10 +659,12 @@ static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, v async_file_frame = switch_core_alloc(conference->pool, CONF_BUFFER_SIZE); - if (switch_core_timer_init(&timer, conference->timer_name, conference->interval, samples, conference->pool) == SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "setup timer success interval: %u samples: %u\n", conference->interval, samples); + if (switch_core_timer_init(&timer, conference->timer_name, conference->interval, samples, conference->pool) == + SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "setup timer success interval: %u samples: %u\n", + conference->interval, samples); } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Timer Setup Failed. Conference Cannot Start\n"); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Timer Setup Failed. Conference Cannot Start\n"); return NULL; } @@ -677,7 +672,7 @@ static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, v globals.threads++; switch_mutex_unlock(globals.hash_mutex); - while(globals.running && !switch_test_flag(conference, CFLAG_DESTRUCT)) { + while (globals.running && !switch_test_flag(conference, CFLAG_DESTRUCT)) { switch_size_t file_sample_len = samples; switch_size_t file_data_len = samples * 2; int has_file_data = 0; @@ -703,28 +698,32 @@ static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, v switch_mutex_lock(imember->audio_in_mutex); /* if there is audio in the resample buffer it takes precedence over the other data */ if (imember->mux_resampler && switch_buffer_inuse(imember->resample_buffer) >= bytes) { - imember->read = (uint32_t)switch_buffer_read(imember->resample_buffer, imember->frame, bytes); + imember->read = (uint32_t) switch_buffer_read(imember->resample_buffer, imember->frame, bytes); ready++; - } else if ((imember->read = (uint32_t)switch_buffer_read(imember->audio_buffer, imember->frame, imember->buflen))) { + } else + if ((imember->read = + (uint32_t) switch_buffer_read(imember->audio_buffer, imember->frame, imember->buflen))) { /* If the caller is not at the right sample rate resample him to suit and buffer accordingly */ if (imember->mux_resampler) { int16_t *bptr = (int16_t *) imember->frame; int16_t out[1024]; int len = (int) imember->read; - imember->mux_resampler->from_len = switch_short_to_float(bptr, imember->mux_resampler->from, (int) len / 2); - imember->mux_resampler->to_len = switch_resample_process(imember->mux_resampler, imember->mux_resampler->from, - imember->mux_resampler->from_len, imember->mux_resampler->to, - imember->mux_resampler->to_size, 0); + imember->mux_resampler->from_len = + switch_short_to_float(bptr, imember->mux_resampler->from, (int) len / 2); + imember->mux_resampler->to_len = + switch_resample_process(imember->mux_resampler, imember->mux_resampler->from, + imember->mux_resampler->from_len, imember->mux_resampler->to, + imember->mux_resampler->to_size, 0); switch_float_to_short(imember->mux_resampler->to, out, len); len = imember->mux_resampler->to_len * 2; switch_buffer_write(imember->resample_buffer, out, len); if (switch_buffer_inuse(imember->resample_buffer) >= bytes) { - imember->read = (uint32_t)switch_buffer_read(imember->resample_buffer, imember->frame, bytes); + imember->read = (uint32_t) switch_buffer_read(imember->resample_buffer, imember->frame, bytes); ready++; } } else { - ready++; /* Tally of how many channels had data */ + ready++; /* Tally of how many channels had data */ } } switch_mutex_unlock(imember->audio_in_mutex); @@ -740,14 +739,12 @@ static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, v switch_speech_flag_t flags = SWITCH_SPEECH_FLAG_BLOCKING; uint32_t rate = conference->rate; - if (switch_core_speech_read_tts(&conference->fnode->sh, - file_frame, - &file_data_len, - &rate, - &flags) == SWITCH_STATUS_SUCCESS) { + if (switch_core_speech_read_tts(&conference->fnode->sh, + file_frame, + &file_data_len, &rate, &flags) == SWITCH_STATUS_SUCCESS) { file_sample_len = file_data_len / 2; } else { - file_sample_len = file_data_len = 0; + file_sample_len = file_data_len = 0; } } else if (conference->fnode->type == NODE_TYPE_FILE) { switch_core_file_read(&conference->fnode->fh, file_frame, &file_sample_len); @@ -774,16 +771,16 @@ static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, v conference->async_fnode->done++; } else { if (has_file_data) { - switch_size_t x; + switch_size_t x; for (x = 0; x < file_sample_len; x++) { int32_t z; int16_t *bptr, *muxed; - + muxed = (int16_t *) file_frame; bptr = (int16_t *) async_file_frame; z = muxed[x] + bptr[x]; switch_normalize_to_16bit(z); - muxed[x] = (int16_t)z; + muxed[x] = (int16_t) z; } } else { memcpy(file_frame, async_file_frame, file_sample_len * 2); @@ -810,7 +807,7 @@ static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, v continue; } - if (imember->read) { /* mux the frame with the collective */ + if (imember->read) { /* mux the frame with the collective */ uint32_t x; int16_t *bptr, *muxed; @@ -819,7 +816,7 @@ static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, v conference_relationship_t *rel; if ((rel = member_get_relationship(omember, imember))) { - if (! switch_test_flag(rel, RFLAG_CAN_HEAR)) { + if (!switch_test_flag(rel, RFLAG_CAN_HEAR)) { continue; } } @@ -830,7 +827,7 @@ static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, v conference_relationship_t *rel; if ((rel = member_get_relationship(imember, omember))) { - if (! switch_test_flag(rel, RFLAG_CAN_SPEAK)) { + if (!switch_test_flag(rel, RFLAG_CAN_SPEAK)) { continue; } } @@ -839,22 +836,22 @@ static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, v if (imember->read > imember->len) { imember->len = imember->read; } - + bptr = (int16_t *) imember->frame; muxed = (int16_t *) omember->mux_frame; - + for (x = 0; x < imember->read / 2; x++) { int32_t z = muxed[x] + bptr[x]; switch_normalize_to_16bit(z); - muxed[x] = (int16_t)z; + muxed[x] = (int16_t) z; } - + ready++; } } } - + /* Go back and write each member his dedicated copy of the audio frame that does not contain his own audio. */ for (imember = conference->members; imember; imember = imember->next) { if (switch_test_flag(imember, MFLAG_RUNNING)) { @@ -894,7 +891,7 @@ static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, v } switch_mutex_unlock(conference->mutex); - } /* Rinse ... Repeat */ + } /* Rinse ... Repeat */ if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) { switch_event_add_header(event, SWITCH_STACK_BOTTOM, "proto", CONF_CHAT_PROTO); @@ -908,36 +905,36 @@ static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, v } switch_core_timer_destroy(&timer); - + if (switch_test_flag(conference, CFLAG_DESTRUCT)) { switch_mutex_lock(conference->mutex); - /* Close Unused Handles */ + /* Close Unused Handles */ if (conference->fnode) { - conference_file_node_t *fnode, *cur; - switch_memory_pool_t *pool; + conference_file_node_t *fnode, *cur; + switch_memory_pool_t *pool; - fnode = conference->fnode; - while (fnode) { - cur = fnode; - fnode = fnode->next; + fnode = conference->fnode; + while (fnode) { + cur = fnode; + fnode = fnode->next; - if (cur->type == NODE_TYPE_SPEECH) { - switch_speech_flag_t flags = SWITCH_SPEECH_FLAG_NONE; - switch_core_speech_close(&cur->sh, &flags); - } else { - switch_core_file_close(&cur->fh); - } + if (cur->type == NODE_TYPE_SPEECH) { + switch_speech_flag_t flags = SWITCH_SPEECH_FLAG_NONE; + switch_core_speech_close(&cur->sh, &flags); + } else { + switch_core_file_close(&cur->fh); + } - pool = cur->pool; - switch_core_destroy_memory_pool(&pool); - } - conference->fnode = NULL; - } + pool = cur->pool; + switch_core_destroy_memory_pool(&pool); + } + conference->fnode = NULL; + } - switch_mutex_lock(conference->member_mutex); - for(imember = conference->members; imember; imember = imember->next) { + switch_mutex_lock(conference->member_mutex); + for (imember = conference->members; imember; imember = imember->next) { switch_channel_t *channel; if (!switch_test_flag(imember, MFLAG_NOCHANNEL)) { @@ -946,8 +943,8 @@ static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, v /* add this little bit to preserve the bridge cause code in case of an early media call that */ /* never answers */ if (switch_test_flag(conference, CFLAG_ANSWERED)) { - switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING); - } else { + switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING); + } else { /* put actual cause code from outbound channel hangup here */ switch_channel_hangup(channel, conference->bridge_hangup_cause); } @@ -955,11 +952,11 @@ static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, v switch_clear_flag_locked(imember, MFLAG_RUNNING); } - switch_mutex_unlock(conference->member_mutex); + switch_mutex_unlock(conference->member_mutex); switch_mutex_unlock(conference->mutex); - switch_mutex_lock(globals.hash_mutex); + switch_mutex_lock(globals.hash_mutex); switch_core_hash_delete(globals.conference_hash, conference->name); switch_mutex_unlock(globals.hash_mutex); @@ -979,44 +976,44 @@ static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, v } switch_mutex_lock(globals.hash_mutex); - globals.threads--; + globals.threads--; switch_mutex_unlock(globals.hash_mutex); return NULL; } -static void conference_loop_fn_mute_toggle(conference_member_t *member, caller_control_action_t *action) +static void conference_loop_fn_mute_toggle(conference_member_t * member, caller_control_action_t * action) { if (member != NULL) { if (switch_test_flag(member, MFLAG_CAN_SPEAK)) { conf_api_sub_mute(member, NULL, NULL); } else { conf_api_sub_unmute(member, NULL, NULL); - if (!switch_test_flag(member, MFLAG_CAN_HEAR)) { - conf_api_sub_undeaf(member, NULL, NULL); - } + if (!switch_test_flag(member, MFLAG_CAN_HEAR)) { + conf_api_sub_undeaf(member, NULL, NULL); + } } } } -static void conference_loop_fn_deafmute_toggle(conference_member_t *member, caller_control_action_t *action) +static void conference_loop_fn_deafmute_toggle(conference_member_t * member, caller_control_action_t * action) { if (member != NULL) { if (switch_test_flag(member, MFLAG_CAN_SPEAK)) { conf_api_sub_mute(member, NULL, NULL); - if (switch_test_flag(member, MFLAG_CAN_HEAR)) { - conf_api_sub_deaf(member, NULL, NULL); - } + if (switch_test_flag(member, MFLAG_CAN_HEAR)) { + conf_api_sub_deaf(member, NULL, NULL); + } } else { conf_api_sub_unmute(member, NULL, NULL); - if (!switch_test_flag(member, MFLAG_CAN_HEAR)) { - conf_api_sub_undeaf(member, NULL, NULL); - } + if (!switch_test_flag(member, MFLAG_CAN_HEAR)) { + conf_api_sub_undeaf(member, NULL, NULL); + } } } } -static void conference_loop_fn_energy_up(conference_member_t *member, caller_control_action_t *action) +static void conference_loop_fn_energy_up(conference_member_t * member, caller_control_action_t * action) { if (member != NULL) { char msg[512]; @@ -1045,9 +1042,9 @@ static void conference_loop_fn_energy_up(conference_member_t *member, caller_con } } -static void conference_loop_fn_energy_equ_conf(conference_member_t *member, caller_control_action_t *action) +static void conference_loop_fn_energy_equ_conf(conference_member_t * member, caller_control_action_t * action) { - if (member!= NULL) { + if (member != NULL) { char msg[512]; switch_event_t *event; @@ -1070,10 +1067,10 @@ static void conference_loop_fn_energy_equ_conf(conference_member_t *member, call } } } - -static void conference_loop_fn_energy_dn(conference_member_t *member, caller_control_action_t *action) + +static void conference_loop_fn_energy_dn(conference_member_t * member, caller_control_action_t * action) { - if (member!= NULL) { + if (member != NULL) { char msg[512]; switch_event_t *event; @@ -1100,9 +1097,9 @@ static void conference_loop_fn_energy_dn(conference_member_t *member, caller_con } } -static void conference_loop_fn_volume_talk_up(conference_member_t *member, caller_control_action_t *action) +static void conference_loop_fn_volume_talk_up(conference_member_t * member, caller_control_action_t * action) { - if (member!= NULL) { + if (member != NULL) { char msg[512]; switch_event_t *event; @@ -1127,9 +1124,9 @@ static void conference_loop_fn_volume_talk_up(conference_member_t *member, calle } } -static void conference_loop_fn_volume_talk_zero(conference_member_t *member, caller_control_action_t *action) +static void conference_loop_fn_volume_talk_zero(conference_member_t * member, caller_control_action_t * action) { - if (member!= NULL) { + if (member != NULL) { char msg[512]; switch_event_t *event; @@ -1153,9 +1150,9 @@ static void conference_loop_fn_volume_talk_zero(conference_member_t *member, cal } } -static void conference_loop_fn_volume_talk_dn(conference_member_t *member, caller_control_action_t *action) +static void conference_loop_fn_volume_talk_dn(conference_member_t * member, caller_control_action_t * action) { - if (member!= NULL) { + if (member != NULL) { char msg[512]; switch_event_t *event; @@ -1180,9 +1177,9 @@ static void conference_loop_fn_volume_talk_dn(conference_member_t *member, calle } } -static void conference_loop_fn_volume_listen_up(conference_member_t *member, caller_control_action_t *action) +static void conference_loop_fn_volume_listen_up(conference_member_t * member, caller_control_action_t * action) { - if (member!= NULL) { + if (member != NULL) { char msg[512]; switch_event_t *event; @@ -1207,9 +1204,9 @@ static void conference_loop_fn_volume_listen_up(conference_member_t *member, cal } } -static void conference_loop_fn_volume_listen_zero(conference_member_t *member, caller_control_action_t *action) +static void conference_loop_fn_volume_listen_zero(conference_member_t * member, caller_control_action_t * action) { - if (member!= NULL) { + if (member != NULL) { char msg[512]; switch_event_t *event; @@ -1233,9 +1230,9 @@ static void conference_loop_fn_volume_listen_zero(conference_member_t *member, c } } -static void conference_loop_fn_volume_listen_dn(conference_member_t *member, caller_control_action_t *action) +static void conference_loop_fn_volume_listen_dn(conference_member_t * member, caller_control_action_t * action) { - if (member!= NULL) { + if (member != NULL) { char msg[512]; switch_event_t *event; @@ -1260,7 +1257,7 @@ static void conference_loop_fn_volume_listen_dn(conference_member_t *member, cal } } -static void conference_loop_fn_event(conference_member_t *member, caller_control_action_t *action) +static void conference_loop_fn_event(conference_member_t * member, caller_control_action_t * action) { switch_event_t *event; if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) { @@ -1275,7 +1272,7 @@ static void conference_loop_fn_event(conference_member_t *member, caller_control } } -static void conference_loop_fn_hangup(conference_member_t *member, caller_control_action_t *action) +static void conference_loop_fn_hangup(conference_member_t * member, caller_control_action_t * action) { switch_clear_flag_locked(member, MFLAG_RUNNING); } @@ -1288,12 +1285,7 @@ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, v switch_status_t status; switch_frame_t *read_frame = NULL; switch_codec_t *read_codec; - uint32_t hangover = 40, - hangunder = 15, - hangover_hits = 0, - hangunder_hits = 0, - energy_level = 0, - diff_level = 400; + uint32_t hangover = 40, hangunder = 15, hangover_hits = 0, hangunder_hits = 0, energy_level = 0, diff_level = 400; uint8_t talking = 0; assert(member != NULL); @@ -1307,7 +1299,7 @@ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, v /* As long as we have a valid read, feed that data into an input buffer where the conference thread will take it and mux it with any audio from other channels. */ - while(switch_test_flag(member, MFLAG_RUNNING) && switch_channel_ready(channel)) { + while (switch_test_flag(member, MFLAG_RUNNING) && switch_channel_ready(channel)) { /* Read a frame. */ status = switch_core_session_read_frame(member->session, &read_frame, -1, 0); @@ -1351,15 +1343,17 @@ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, v switch_event_t *event; talking = 1; switch_set_flag_locked(member, MFLAG_FLUSH_BUFFER); - if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) { + if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == + SWITCH_STATUS_SUCCESS) { switch_channel_event_set_data(channel, event); - switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", member->conference->name); + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", + member->conference->name); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "start-talking"); switch_event_fire(&event); } } - } + } } else { if (hangunder_hits) { hangunder_hits--; @@ -1370,13 +1364,15 @@ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, v hangover_hits = hangunder_hits = 0; talking = 0; - if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) { + if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == + SWITCH_STATUS_SUCCESS) { switch_channel_event_set_data(channel, event); - switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", member->conference->name); + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", + member->conference->name); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "stop-talking"); switch_event_fire(&event); - } + } } } } @@ -1388,10 +1384,12 @@ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, v int16_t *bptr = (int16_t *) read_frame->data; int len = (int) read_frame->datalen;; - member->read_resampler->from_len = switch_short_to_float(bptr, member->read_resampler->from, (int) len / 2); - member->read_resampler->to_len = switch_resample_process(member->read_resampler, member->read_resampler->from, - member->read_resampler->from_len, member->read_resampler->to, - member->read_resampler->to_size, 0); + member->read_resampler->from_len = + switch_short_to_float(bptr, member->read_resampler->from, (int) len / 2); + member->read_resampler->to_len = + switch_resample_process(member->read_resampler, member->read_resampler->from, + member->read_resampler->from_len, member->read_resampler->to, + member->read_resampler->to_size, 0); switch_float_to_short(member->read_resampler->to, read_frame->data, len); len = member->read_resampler->to_len * 2; read_frame->datalen = len; @@ -1415,7 +1413,7 @@ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, v } /* launch an input thread for the call leg */ -static void launch_conference_loop_input(conference_member_t *member, switch_memory_pool_t *pool) +static void launch_conference_loop_input(conference_member_t * member, switch_memory_pool_t *pool) { if (member != NULL) { switch_thread_t *thread; @@ -1430,30 +1428,31 @@ static void launch_conference_loop_input(conference_member_t *member, switch_mem } static caller_control_fn_table_t ccfntbl[] = { - {"mute", "0", CALLER_CONTROL_MUTE, conference_loop_fn_mute_toggle}, - {"deaf mute", "*", CALLER_CONTROL_DEAF_MUTE, conference_loop_fn_deafmute_toggle}, - {"energy up", "9", CALLER_CONTROL_ENERGY_UP, conference_loop_fn_energy_up}, - {"energy equ", "8", CALLER_CONTROL_ENERGY_EQU_CONF, conference_loop_fn_energy_equ_conf}, - {"energy dn", "7", CALLER_CONTROL_ENERGEY_DN, conference_loop_fn_energy_dn}, - {"vol talk up", "3", CALLER_CONTROL_VOL_TALK_UP, conference_loop_fn_volume_talk_up}, - {"vol talk zero", "2", CALLER_CONTROL_VOL_TALK_ZERO, conference_loop_fn_volume_talk_zero}, - {"vol talk dn", "1", CALLER_CONTROL_VOL_TALK_DN, conference_loop_fn_volume_talk_dn}, - {"vol listen up", "6", CALLER_CONTROL_VOL_LISTEN_UP, conference_loop_fn_volume_listen_up}, - {"vol listen zero", "5", CALLER_CONTROL_VOL_LISTEN_ZERO, conference_loop_fn_volume_listen_zero}, - {"vol listen dn", "4", CALLER_CONTROL_VOL_LISTEN_DN, conference_loop_fn_volume_listen_dn}, - {"hangup", "#", CALLER_CONTROL_HANGUP, conference_loop_fn_hangup}, + {"mute", "0", CALLER_CONTROL_MUTE, conference_loop_fn_mute_toggle}, + {"deaf mute", "*", CALLER_CONTROL_DEAF_MUTE, conference_loop_fn_deafmute_toggle}, + {"energy up", "9", CALLER_CONTROL_ENERGY_UP, conference_loop_fn_energy_up}, + {"energy equ", "8", CALLER_CONTROL_ENERGY_EQU_CONF, conference_loop_fn_energy_equ_conf}, + {"energy dn", "7", CALLER_CONTROL_ENERGEY_DN, conference_loop_fn_energy_dn}, + {"vol talk up", "3", CALLER_CONTROL_VOL_TALK_UP, conference_loop_fn_volume_talk_up}, + {"vol talk zero", "2", CALLER_CONTROL_VOL_TALK_ZERO, conference_loop_fn_volume_talk_zero}, + {"vol talk dn", "1", CALLER_CONTROL_VOL_TALK_DN, conference_loop_fn_volume_talk_dn}, + {"vol listen up", "6", CALLER_CONTROL_VOL_LISTEN_UP, conference_loop_fn_volume_listen_up}, + {"vol listen zero", "5", CALLER_CONTROL_VOL_LISTEN_ZERO, conference_loop_fn_volume_listen_zero}, + {"vol listen dn", "4", CALLER_CONTROL_VOL_LISTEN_DN, conference_loop_fn_volume_listen_dn}, + {"hangup", "#", CALLER_CONTROL_HANGUP, conference_loop_fn_hangup}, {"event", NULL, CALLER_CONTROL_EVENT, conference_loop_fn_event} }; + #define CCFNTBL_QTY (sizeof(ccfntbl)/sizeof(ccfntbl[0])) /* marshall frames from the conference (or file or tts output) to the call leg */ /* NB. this starts the input thread after some initial setup for the call leg */ -static void conference_loop_output(conference_member_t *member) +static void conference_loop_output(conference_member_t * member) { switch_channel_t *channel; - switch_frame_t write_frame = {0}; + switch_frame_t write_frame = { 0 }; uint8_t data[SWITCH_RECOMMENDED_BUFFER_SIZE]; - switch_timer_t timer = {0}; + switch_timer_t timer = { 0 }; switch_codec_t *read_codec = switch_core_session_get_read_codec(member->session); uint32_t interval = read_codec->implementation->microseconds_per_frame / 1000; //uint32_t samples = switch_bytes_per_frame(member->conference->rate, member->conference->interval); @@ -1465,16 +1464,13 @@ static void conference_loop_output(conference_member_t *member) assert(channel != NULL); assert(member->conference != NULL); - if (switch_core_timer_init(&timer, - member->conference->timer_name, - interval, + if (switch_core_timer_init(&timer, member->conference->timer_name, interval, //member->conference->interval, - samples, - NULL) == SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "setup timer %s success interval: %u samples: %u\n", - member->conference->timer_name, interval, samples); + samples, NULL) == SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "setup timer %s success interval: %u samples: %u\n", + member->conference->timer_name, interval, samples); } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Timer Setup Failed. Conference Cannot Start\n"); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Timer Setup Failed. Conference Cannot Start\n"); return; } @@ -1490,16 +1486,18 @@ static void conference_loop_output(conference_member_t *member) launch_conference_loop_input(member, switch_core_session_get_pool(member->session)); /* build a digit stream object */ - if (member->conference->dtmf_parser != NULL && - switch_ivr_digit_stream_new(member->conference->dtmf_parser, &member->digit_stream) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Warning Will Robinson, there is no digit parser stream object\n"); + if (member->conference->dtmf_parser != NULL && + switch_ivr_digit_stream_new(member->conference->dtmf_parser, &member->digit_stream) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, + "Warning Will Robinson, there is no digit parser stream object\n"); } - /* Fair WARNING, If you expect the caller to hear anything or for digit handling to be proccessed, */ - /* you better not block this thread loop for more than the duration of member->conference->timer_name! */ - while(switch_test_flag(member, MFLAG_RUNNING) && switch_test_flag(member, MFLAG_ITHREAD) && switch_channel_ready(channel)) { + /* Fair WARNING, If you expect the caller to hear anything or for digit handling to be proccessed, */ + /* you better not block this thread loop for more than the duration of member->conference->timer_name! */ + while (switch_test_flag(member, MFLAG_RUNNING) && switch_test_flag(member, MFLAG_ITHREAD) + && switch_channel_ready(channel)) { char dtmf[128] = ""; - uint8_t file_frame[CONF_BUFFER_SIZE] = {0}; + uint8_t file_frame[CONF_BUFFER_SIZE] = { 0 }; switch_size_t file_data_len = samples * 2; switch_size_t file_sample_len = samples; char *digit; @@ -1515,9 +1513,9 @@ static void conference_loop_output(conference_member_t *member) char *body = switch_event_get_body(event); char *p, *freeme = NULL; - if ((p = strchr(to, '+')) && - strncmp(to, CONF_CHAT_PROTO, strlen(CONF_CHAT_PROTO))) { - freeme = switch_mprintf("%s+%s@%s", CONF_CHAT_PROTO, member->conference->name, member->conference->domain); + if ((p = strchr(to, '+')) && strncmp(to, CONF_CHAT_PROTO, strlen(CONF_CHAT_PROTO))) { + freeme = + switch_mprintf("%s+%s@%s", CONF_CHAT_PROTO, member->conference->name, member->conference->domain); to = freeme; } @@ -1529,12 +1527,14 @@ static void conference_loop_output(conference_member_t *member) if (switch_channel_test_flag(channel, CF_OUTBOUND)) { /* test to see if outbound channel has answered */ if (switch_channel_test_flag(channel, CF_ANSWERED) && !switch_test_flag(member->conference, CFLAG_ANSWERED)) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Outbound conference channel answered, setting CFLAG_ANSWERED\n"); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, + "Outbound conference channel answered, setting CFLAG_ANSWERED\n"); switch_set_flag(member->conference, CFLAG_ANSWERED); } } else { if (switch_test_flag(member->conference, CFLAG_ANSWERED) && !switch_channel_test_flag(channel, CF_ANSWERED)) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CLFAG_ANSWERED set, answering inbound channel\n"); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, + "CLFAG_ANSWERED set, answering inbound channel\n"); switch_channel_answer(channel); } } @@ -1547,35 +1547,34 @@ static void conference_loop_output(conference_member_t *member) for (digit = dtmf; *digit && caller_action == NULL; digit++) { caller_action = (caller_control_action_t *) - switch_ivr_digit_stream_parser_feed(member->conference->dtmf_parser, member->digit_stream, *digit); + switch_ivr_digit_stream_parser_feed(member->conference->dtmf_parser, member->digit_stream, + *digit); } } - /* otherwise, clock the parser so that it can handle digit timeout detection */ + /* otherwise, clock the parser so that it can handle digit timeout detection */ } else if (member->conference->dtmf_parser != NULL) { - caller_action = (caller_control_action_t *)switch_ivr_digit_stream_parser_feed(member->conference->dtmf_parser, member->digit_stream, '\0'); + caller_action = + (caller_control_action_t *) switch_ivr_digit_stream_parser_feed(member->conference->dtmf_parser, + member->digit_stream, '\0'); } /* if a caller action has been detected, handle it */ if (caller_action != NULL && caller_action->fndesc != NULL && caller_action->fndesc->handler != NULL) { - //switch_channel_t *channel = switch_core_session_get_channel(member->session); - //switch_caller_profile_t *profile = switch_channel_get_caller_profile(channel); - char *param = NULL; - - if (caller_action->fndesc->action != CALLER_CONTROL_MENU) { - param = caller_action->data; - } + //switch_channel_t *channel = switch_core_session_get_channel(member->session); + //switch_caller_profile_t *profile = switch_channel_get_caller_profile(channel); + char *param = NULL; + if (caller_action->fndesc->action != CALLER_CONTROL_MENU) { + param = caller_action->data; + } #ifdef INTENSE_DEBUG - switch_log_printf(SWITCH_CHANNEL_LOG, - SWITCH_LOG_INFO, - "executing caller control '%s' param '%s' on call '%u, %s, %s, %s'\n", - caller_action->fndesc->key, - param ? param : "none", - member->id, - switch_channel_get_name(channel), - profile->caller_id_name, - profile->caller_id_number - ); + switch_log_printf(SWITCH_CHANNEL_LOG, + SWITCH_LOG_INFO, + "executing caller control '%s' param '%s' on call '%u, %s, %s, %s'\n", + caller_action->fndesc->key, + param ? param : "none", + member->id, + switch_channel_get_name(channel), profile->caller_id_name, profile->caller_id_number); #endif caller_action->fndesc->handler(member, caller_action); @@ -1586,7 +1585,7 @@ static void conference_loop_output(conference_member_t *member) /* handle file and TTS frames */ if (member->fnode) { - switch_mutex_lock(member->flag_mutex); + switch_mutex_lock(member->flag_mutex); /* if we are done, clean it up */ if (member->fnode->done) { conference_file_node_t *fnode; @@ -1610,19 +1609,17 @@ static void conference_loop_output(conference_member_t *member) /* skip this frame until leadin time has expired */ if (member->fnode->leadin) { member->fnode->leadin--; - } else { /* send the node frame instead of the conference frame to the call leg */ + } else { /* send the node frame instead of the conference frame to the call leg */ if (member->fnode->type == NODE_TYPE_SPEECH) { switch_speech_flag_t flags = SWITCH_SPEECH_FLAG_BLOCKING; uint32_t rate = member->conference->rate; - if (switch_core_speech_read_tts(&member->fnode->sh, - file_frame, - &file_data_len, - &rate, - &flags) == SWITCH_STATUS_SUCCESS) { + if (switch_core_speech_read_tts(&member->fnode->sh, + file_frame, + &file_data_len, &rate, &flags) == SWITCH_STATUS_SUCCESS) { file_sample_len = file_data_len / 2; } else { - file_sample_len = file_data_len = 0; + file_sample_len = file_data_len = 0; } } else if (member->fnode->type == NODE_TYPE_FILE) { switch_core_file_read(&member->fnode->fh, file_frame, &file_sample_len); @@ -1631,10 +1628,10 @@ static void conference_loop_output(conference_member_t *member) if (file_sample_len <= 0) { member->fnode->done++; - } else { /* there is file node data to deliver */ + } else { /* there is file node data to deliver */ write_frame.data = file_frame; - write_frame.datalen = (uint32_t)file_data_len; - write_frame.samples = (uint32_t)file_sample_len; + write_frame.datalen = (uint32_t) file_data_len; + write_frame.samples = (uint32_t) file_sample_len; /* Check for output volume adjustments */ if (member->volume_out_level) { switch_change_sln_volume(write_frame.data, write_frame.samples, member->volume_out_level); @@ -1648,22 +1645,22 @@ static void conference_loop_output(conference_member_t *member) } } } - switch_mutex_unlock(member->flag_mutex); - } else { /* send the conferecne frame to the call leg */ + switch_mutex_unlock(member->flag_mutex); + } else { /* send the conferecne frame to the call leg */ switch_buffer_t *use_buffer = NULL; uint32_t mux_used = (uint32_t) switch_buffer_inuse(member->mux_buffer); - if (mux_used){ + if (mux_used) { if (mux_used < bytes) { if (++low_count >= 5) { /* partial frame sitting around this long is useless and builds delay */ switch_set_flag_locked(member, MFLAG_FLUSH_BUFFER); } mux_used = 0; - } else if (mux_used > bytes * 2) { + } else if (mux_used > bytes * 2) { /* getting behind, clear the buffer */ switch_set_flag_locked(member, MFLAG_FLUSH_BUFFER); - } + } } if (switch_test_flag(member, MFLAG_FLUSH_BUFFER)) { @@ -1683,7 +1680,7 @@ static void conference_loop_output(conference_member_t *member) use_buffer = member->mux_buffer; low_count = 0; - if ((write_frame.datalen = (uint32_t)switch_buffer_read(use_buffer, write_frame.data, bytes))) { + if ((write_frame.datalen = (uint32_t) switch_buffer_read(use_buffer, write_frame.data, bytes))) { if (write_frame.datalen && switch_test_flag(member, MFLAG_CAN_HEAR)) { write_frame.samples = write_frame.datalen / 2; @@ -1699,7 +1696,7 @@ static void conference_loop_output(conference_member_t *member) switch_mutex_unlock(member->audio_out_mutex); switch_core_timer_next(&timer); - + } else { if (switch_test_flag(member, MFLAG_WASTE_BANDWIDTH)) { switch_generate_sln_silence(write_frame.data, samples, 1400); @@ -1711,7 +1708,7 @@ static void conference_loop_output(conference_member_t *member) switch_core_timer_next(&timer); } } - } /* Rinse ... Repeat */ + } /* Rinse ... Repeat */ if (member->digit_stream != NULL) { switch_ivr_digit_stream_destroy(member->digit_stream); @@ -1720,8 +1717,8 @@ static void conference_loop_output(conference_member_t *member) switch_clear_flag_locked(member, MFLAG_RUNNING); switch_core_timer_destroy(&timer); - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Channel leaving conference, cause: %s\n", - switch_channel_cause2str(switch_channel_get_cause(channel))); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Channel leaving conference, cause: %s\n", + switch_channel_cause2str(switch_channel_get_cause(channel))); /* if it's an outbound channel, store the release cause in the conference struct, we might need it */ if (switch_channel_test_flag(channel, CF_OUTBOUND)) { @@ -1729,7 +1726,7 @@ static void conference_loop_output(conference_member_t *member) } /* Wait for the input thead to end */ - while(switch_test_flag(member, MFLAG_ITHREAD)) { + while (switch_test_flag(member, MFLAG_ITHREAD)) { switch_yield(1000); } } @@ -1738,15 +1735,15 @@ static void conference_loop_output(conference_member_t *member) static void *SWITCH_THREAD_FUNC conference_record_thread_run(switch_thread_t *thread, void *obj) { uint8_t data[SWITCH_RECOMMENDED_BUFFER_SIZE]; - switch_file_handle_t fh = {0}; - conference_member_t smember = {0}, *member; + switch_file_handle_t fh = { 0 }; + conference_member_t smember = { 0 }, *member; conference_record_t *rec = (conference_record_t *) obj; conference_obj_t *conference = rec->conference; uint32_t samples = switch_bytes_per_frame(conference->rate, conference->interval); //uint32_t bytes = samples * 2; uint32_t low_count = 0, mux_used; char *vval; - switch_timer_t timer = {0}; + switch_timer_t timer = { 0 }; uint32_t rlen; if (switch_thread_rwlock_tryrdlock(conference->rwlock) != SWITCH_STATUS_SUCCESS) { @@ -1775,13 +1772,15 @@ static void *SWITCH_THREAD_FUNC conference_record_thread_run(switch_thread_t *th switch_mutex_init(&member->audio_out_mutex, SWITCH_MUTEX_NESTED, rec->pool); /* Setup an audio buffer for the incoming audio */ - if (switch_buffer_create_dynamic(&member->audio_buffer, CONF_DBLOCK_SIZE, CONF_DBUFFER_SIZE, 0) != SWITCH_STATUS_SUCCESS) { + if (switch_buffer_create_dynamic(&member->audio_buffer, CONF_DBLOCK_SIZE, CONF_DBUFFER_SIZE, 0) != + SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error Creating Audio Buffer!\n"); goto end; } /* Setup an audio buffer for the outgoing audio */ - if (switch_buffer_create_dynamic(&member->mux_buffer, CONF_DBLOCK_SIZE, CONF_DBUFFER_SIZE, 0) != SWITCH_STATUS_SUCCESS) { + if (switch_buffer_create_dynamic(&member->mux_buffer, CONF_DBLOCK_SIZE, CONF_DBUFFER_SIZE, 0) != + SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error Creating Audio Buffer!\n"); goto end; } @@ -1791,32 +1790,34 @@ static void *SWITCH_THREAD_FUNC conference_record_thread_run(switch_thread_t *th goto end; } - if (switch_core_file_open(&fh, - rec->path, - (uint8_t)1, + if (switch_core_file_open(&fh, + rec->path, + (uint8_t) 1, conference->rate, - SWITCH_FILE_FLAG_WRITE | SWITCH_FILE_DATA_SHORT, - rec->pool) != SWITCH_STATUS_SUCCESS) { + SWITCH_FILE_FLAG_WRITE | SWITCH_FILE_DATA_SHORT, rec->pool) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening File [%s]\n", rec->path); goto end; } - if (switch_core_timer_init(&timer, conference->timer_name, conference->interval, samples, rec->pool) == SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "setup timer success interval: %u samples: %u\n", conference->interval, samples); + if (switch_core_timer_init(&timer, conference->timer_name, conference->interval, samples, rec->pool) == + SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "setup timer success interval: %u samples: %u\n", + conference->interval, samples); } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Timer Setup Failed. Conference Cannot Start\n"); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Timer Setup Failed. Conference Cannot Start\n"); goto end; } - + if ((vval = switch_mprintf("Conference %s", conference->name))) { switch_core_file_set_string(&fh, SWITCH_AUDIO_COL_STR_TITLE, vval); switch_safe_free(vval); } - switch_core_file_set_string(&fh, SWITCH_AUDIO_COL_STR_ARTIST, "FreeSWITCH mod_conference Software Conference Module"); + switch_core_file_set_string(&fh, SWITCH_AUDIO_COL_STR_ARTIST, + "FreeSWITCH mod_conference Software Conference Module"); - while(switch_test_flag(member, MFLAG_RUNNING) && switch_test_flag(conference, CFLAG_RUNNING) && conference->count) { + while (switch_test_flag(member, MFLAG_RUNNING) && switch_test_flag(conference, CFLAG_RUNNING) && conference->count) { mux_used = (uint32_t) switch_buffer_inuse(member->mux_buffer); if (switch_test_flag(member, MFLAG_FLUSH_BUFFER)) { @@ -1833,8 +1834,8 @@ static void *SWITCH_THREAD_FUNC conference_record_thread_run(switch_thread_t *th /* Flush the output buffer and write all the data (presumably muxed) to the file */ switch_mutex_lock(member->audio_out_mutex); low_count = 0; - - if ((rlen = (uint32_t)switch_buffer_read(member->mux_buffer, data, sizeof(data)))) { + + if ((rlen = (uint32_t) switch_buffer_read(member->mux_buffer, data, sizeof(data)))) { if (!switch_test_flag((&fh), SWITCH_FILE_PAUSE)) { switch_size_t len = (switch_size_t) rlen / sizeof(int16_t); if (switch_core_file_write(&fh, data, &len) != SWITCH_STATUS_SUCCESS) { @@ -1847,9 +1848,9 @@ static void *SWITCH_THREAD_FUNC conference_record_thread_run(switch_thread_t *th } else { switch_core_timer_next(&timer); } - } /* Rinse ... Repeat */ + } /* Rinse ... Repeat */ - end: + end: switch_core_timer_destroy(&timer); conference_del_member(conference, member); @@ -1876,38 +1877,38 @@ static void *SWITCH_THREAD_FUNC conference_record_thread_run(switch_thread_t *th } /* Make files stop playing in a conference either the current one or all of them */ -static uint32_t conference_stop_file(conference_obj_t *conference, file_stop_t stop) +static uint32_t conference_stop_file(conference_obj_t * conference, file_stop_t stop) { uint32_t count = 0; - conference_file_node_t *nptr; + conference_file_node_t *nptr; - assert(conference != NULL); + assert(conference != NULL); - switch_mutex_lock(conference->mutex); + switch_mutex_lock(conference->mutex); - if (stop == FILE_STOP_ALL) { - for (nptr = conference->fnode; nptr; nptr = nptr->next) { - nptr->done++; - count++; - } + if (stop == FILE_STOP_ALL) { + for (nptr = conference->fnode; nptr; nptr = nptr->next) { + nptr->done++; + count++; + } if (conference->async_fnode) { conference->async_fnode->done++; count++; } - } else { - if (conference->fnode) { - conference->fnode->done++; - count++; - } - } - - switch_mutex_unlock(conference->mutex); + } else { + if (conference->fnode) { + conference->fnode->done++; + count++; + } + } + + switch_mutex_unlock(conference->mutex); return count; } /* stop playing a file for the member of the conference */ -static uint32_t conference_member_stop_file(conference_member_t *member, file_stop_t stop) +static uint32_t conference_member_stop_file(conference_member_t * member, file_stop_t stop) { uint32_t count = 0; @@ -1935,88 +1936,88 @@ static uint32_t conference_member_stop_file(conference_member_t *member, file_st } /* Play a file in the conference room */ -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) { switch_status_t status = SWITCH_STATUS_SUCCESS; - conference_file_node_t *fnode, *nptr = NULL; - switch_memory_pool_t *pool; - uint32_t count; - char *dfile = NULL, *expanded = NULL; + conference_file_node_t *fnode, *nptr = NULL; + switch_memory_pool_t *pool; + uint32_t count; + char *dfile = NULL, *expanded = NULL; - assert(conference != NULL); + assert(conference != NULL); - switch_mutex_lock(conference->mutex); - switch_mutex_lock(conference->member_mutex); - count = conference->count; - switch_mutex_unlock(conference->member_mutex); - switch_mutex_unlock(conference->mutex); + switch_mutex_lock(conference->mutex); + switch_mutex_lock(conference->member_mutex); + count = conference->count; + switch_mutex_unlock(conference->member_mutex); + switch_mutex_unlock(conference->mutex); - if (!count) { - status = SWITCH_STATUS_FALSE; - goto done; - } + if (!count) { + status = SWITCH_STATUS_FALSE; + goto done; + } - if (channel) { - if ((expanded = switch_channel_expand_variables(channel, file)) != file) { - file = expanded; - } else { - expanded = NULL; - } - } + if (channel) { + if ((expanded = switch_channel_expand_variables(channel, file)) != file) { + file = expanded; + } else { + expanded = NULL; + } + } - if (!async && !strncasecmp(file, "say:", 4)) { - status = conference_say(conference, file + 4, leadin); - goto done; - } + if (!async && !strncasecmp(file, "say:", 4)) { + status = conference_say(conference, file + 4, leadin); + goto done; + } - if (!switch_is_file_path(file)) { - if (conference->sound_prefix) { - if (!(dfile = switch_mprintf("%s/%s", conference->sound_prefix, file))) { - goto done; - } - file = dfile; - } else if (!async) { - status = conference_say(conference, file, leadin); - goto done; - } else { + if (!switch_is_file_path(file)) { + if (conference->sound_prefix) { + if (!(dfile = switch_mprintf("%s/%s", conference->sound_prefix, file))) { + goto done; + } + file = dfile; + } else if (!async) { + status = conference_say(conference, file, leadin); + goto done; + } else { goto done; } - } + } - /* Setup a memory pool to use. */ - if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Pool Failure\n"); - status = SWITCH_STATUS_MEMERR; - goto done; - } + /* Setup a memory pool to use. */ + if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Pool Failure\n"); + status = SWITCH_STATUS_MEMERR; + goto done; + } - /* Create a node object*/ - if (!(fnode = switch_core_alloc(pool, sizeof(*fnode)))) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Alloc Failure\n"); - switch_core_destroy_memory_pool(&pool); - status = SWITCH_STATUS_MEMERR; - goto done; - } + /* Create a node object */ + if (!(fnode = switch_core_alloc(pool, sizeof(*fnode)))) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Alloc Failure\n"); + switch_core_destroy_memory_pool(&pool); + status = SWITCH_STATUS_MEMERR; + goto done; + } - fnode->type = NODE_TYPE_FILE; - fnode->leadin = leadin; + fnode->type = NODE_TYPE_FILE; + fnode->leadin = leadin; - /* Open the file */ - if (switch_core_file_open(&fnode->fh, - file, - (uint8_t)1, + /* Open the file */ + if (switch_core_file_open(&fnode->fh, + file, + (uint8_t) 1, conference->rate, - SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, - pool) != SWITCH_STATUS_SUCCESS) { - switch_core_destroy_memory_pool(&pool); - status = SWITCH_STATUS_NOTFOUND; - goto done; - } + SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, pool) != SWITCH_STATUS_SUCCESS) { + switch_core_destroy_memory_pool(&pool); + status = SWITCH_STATUS_NOTFOUND; + goto done; + } - fnode->pool = pool; + fnode->pool = pool; fnode->async = async; - /* Queue the node */ - switch_mutex_lock(conference->mutex); + /* Queue the node */ + switch_mutex_lock(conference->mutex); if (async) { if (conference->async_fnode) { @@ -2028,12 +2029,12 @@ static switch_status_t conference_play_file(conference_obj_t *conference, char * switch_memory_pool_t *pool; switch_core_file_close(&nptr->fh); pool = nptr->pool; - switch_core_destroy_memory_pool(&pool); + switch_core_destroy_memory_pool(&pool); } - + } else { for (nptr = conference->fnode; nptr && nptr->next; nptr = nptr->next); - + if (nptr) { nptr->next = fnode; } else { @@ -2041,1027 +2042,1027 @@ static switch_status_t conference_play_file(conference_obj_t *conference, char * } } - switch_mutex_unlock(conference->mutex); + switch_mutex_unlock(conference->mutex); - done: + done: - switch_safe_free(expanded); - switch_safe_free(dfile); + switch_safe_free(expanded); + switch_safe_free(dfile); - - return status; + + return status; } /* Play a file in the conference room to a member */ -static switch_status_t conference_member_play_file(conference_member_t *member, char *file, uint32_t leadin) +static switch_status_t conference_member_play_file(conference_member_t * member, char *file, uint32_t leadin) { - switch_status_t status = SWITCH_STATUS_FALSE; - char *dfile = NULL, *expanded = NULL; + switch_status_t status = SWITCH_STATUS_FALSE; + char *dfile = NULL, *expanded = NULL; - if (member != NULL && file != NULL) { - conference_file_node_t *fnode, *nptr; - switch_memory_pool_t *pool; + if (member != NULL && file != NULL) { + conference_file_node_t *fnode, *nptr; + switch_memory_pool_t *pool; - if ((expanded = switch_channel_expand_variables(switch_core_session_get_channel(member->session), file)) != file) { - file = expanded; - } else { - expanded = NULL; - } + if ((expanded = + switch_channel_expand_variables(switch_core_session_get_channel(member->session), file)) != file) { + file = expanded; + } else { + expanded = NULL; + } - if (!strncasecmp(file, "say:", 4)) { - status = conference_say(member->conference, file + 4, leadin); - goto done; - } + if (!strncasecmp(file, "say:", 4)) { + status = conference_say(member->conference, file + 4, leadin); + goto done; + } - if (!switch_is_file_path(file)) { - if (member->conference->sound_prefix) { - if (!(dfile = switch_mprintf("%s/%s", member->conference->sound_prefix, file))) { - goto done; - } - file = dfile; - } else { - status = conference_say(member->conference, file, leadin); - goto done; - } - } + if (!switch_is_file_path(file)) { + if (member->conference->sound_prefix) { + if (!(dfile = switch_mprintf("%s/%s", member->conference->sound_prefix, file))) { + goto done; + } + file = dfile; + } else { + status = conference_say(member->conference, file, leadin); + goto done; + } + } - /* Setup a memory pool to use. */ - if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Pool Failure\n"); - status = SWITCH_STATUS_MEMERR; - goto done; - } + /* Setup a memory pool to use. */ + if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Pool Failure\n"); + status = SWITCH_STATUS_MEMERR; + goto done; + } - /* Create a node object*/ - if (!(fnode = switch_core_alloc(pool, sizeof(*fnode)))) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Alloc Failure\n"); - switch_core_destroy_memory_pool(&pool); - status = SWITCH_STATUS_MEMERR; - goto done; - } + /* Create a node object */ + if (!(fnode = switch_core_alloc(pool, sizeof(*fnode)))) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Alloc Failure\n"); + switch_core_destroy_memory_pool(&pool); + status = SWITCH_STATUS_MEMERR; + goto done; + } - fnode->type = NODE_TYPE_FILE; - fnode->leadin = leadin; + fnode->type = NODE_TYPE_FILE; + fnode->leadin = leadin; - /* Open the file */ - if (switch_core_file_open(&fnode->fh, - file, - (uint8_t)1, + /* Open the file */ + if (switch_core_file_open(&fnode->fh, + file, + (uint8_t) 1, member->conference->rate, - SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, - pool) != SWITCH_STATUS_SUCCESS) { - switch_core_destroy_memory_pool(&pool); - status = SWITCH_STATUS_NOTFOUND; - goto done; - } + SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, pool) != SWITCH_STATUS_SUCCESS) { + switch_core_destroy_memory_pool(&pool); + status = SWITCH_STATUS_NOTFOUND; + goto done; + } - fnode->pool = pool; + fnode->pool = pool; - /* Queue the node */ - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "queueing file '%s' for play\n", file); - switch_mutex_lock(member->flag_mutex); - for (nptr = member->fnode; nptr && nptr->next; nptr = nptr->next); + /* Queue the node */ + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "queueing file '%s' for play\n", file); + switch_mutex_lock(member->flag_mutex); + for (nptr = member->fnode; nptr && nptr->next; nptr = nptr->next); - if (nptr) { - nptr->next = fnode; - } else { - member->fnode = fnode; - } - switch_mutex_unlock(member->flag_mutex); + if (nptr) { + nptr->next = fnode; + } else { + member->fnode = fnode; + } + switch_mutex_unlock(member->flag_mutex); - status = SWITCH_STATUS_SUCCESS; - } + status = SWITCH_STATUS_SUCCESS; + } - done: + done: - switch_safe_free(expanded); - switch_safe_free(dfile); + switch_safe_free(expanded); + switch_safe_free(dfile); - return status; + return status; } /* Say some thing with TTS in the conference room */ -static switch_status_t conference_member_say(conference_member_t *member, char *text, uint32_t leadin) +static switch_status_t conference_member_say(conference_member_t * member, char *text, uint32_t leadin) { - switch_status_t status = SWITCH_STATUS_FALSE; + switch_status_t status = SWITCH_STATUS_FALSE; - if (member != NULL && !switch_strlen_zero(text)) { - conference_obj_t *conference = (member != NULL ? member->conference : NULL); - conference_file_node_t *fnode, *nptr; - switch_memory_pool_t *pool; - switch_speech_flag_t flags = SWITCH_SPEECH_FLAG_NONE; + if (member != NULL && !switch_strlen_zero(text)) { + conference_obj_t *conference = (member != NULL ? member->conference : NULL); + conference_file_node_t *fnode, *nptr; + switch_memory_pool_t *pool; + switch_speech_flag_t flags = SWITCH_SPEECH_FLAG_NONE; - assert(conference != NULL); - - if (!(conference->tts_engine && conference->tts_voice)) { - return SWITCH_STATUS_SUCCESS; - } + assert(conference != NULL); - /* Setup a memory pool to use. */ - if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Pool Failure\n"); - return SWITCH_STATUS_MEMERR; - } + if (!(conference->tts_engine && conference->tts_voice)) { + return SWITCH_STATUS_SUCCESS; + } - /* Create a node object*/ - if (!(fnode = switch_core_alloc(pool, sizeof(*fnode)))) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Alloc Failure\n"); - switch_core_destroy_memory_pool(&pool); - return SWITCH_STATUS_MEMERR; - } + /* Setup a memory pool to use. */ + if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Pool Failure\n"); + return SWITCH_STATUS_MEMERR; + } - fnode->type = NODE_TYPE_SPEECH; - fnode->leadin = leadin; - fnode->pool = pool; + /* Create a node object */ + if (!(fnode = switch_core_alloc(pool, sizeof(*fnode)))) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Alloc Failure\n"); + switch_core_destroy_memory_pool(&pool); + return SWITCH_STATUS_MEMERR; + } - memset(&fnode->sh, 0, sizeof(fnode->sh)); - if (switch_core_speech_open(&fnode->sh, - conference->tts_engine, - conference->tts_voice, - conference->rate, - &flags, - fnode->pool) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid TTS module [%s]!\n", conference->tts_engine); - return SWITCH_STATUS_FALSE; - } + fnode->type = NODE_TYPE_SPEECH; + fnode->leadin = leadin; + fnode->pool = pool; - /* Queue the node */ - switch_mutex_lock(member->flag_mutex); - for (nptr = member->fnode; nptr && nptr->next; nptr = nptr->next); + memset(&fnode->sh, 0, sizeof(fnode->sh)); + if (switch_core_speech_open(&fnode->sh, + conference->tts_engine, + conference->tts_voice, + conference->rate, &flags, fnode->pool) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid TTS module [%s]!\n", + conference->tts_engine); + return SWITCH_STATUS_FALSE; + } - if (nptr) { - nptr->next = fnode; - } else { - member->fnode = fnode; - } + /* Queue the node */ + switch_mutex_lock(member->flag_mutex); + for (nptr = member->fnode; nptr && nptr->next; nptr = nptr->next); - /* Begin Generation */ - switch_sleep(200000); - switch_core_speech_feed_tts(&fnode->sh, text, &flags); - switch_mutex_unlock(member->flag_mutex); + if (nptr) { + nptr->next = fnode; + } else { + member->fnode = fnode; + } - status = SWITCH_STATUS_SUCCESS; - } + /* Begin Generation */ + switch_sleep(200000); + switch_core_speech_feed_tts(&fnode->sh, text, &flags); + switch_mutex_unlock(member->flag_mutex); - return status; + status = SWITCH_STATUS_SUCCESS; + } + + return status; } /* Say some thing with TTS in the conference room */ -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) { - switch_status_t status = SWITCH_STATUS_FALSE; - conference_file_node_t *fnode, *nptr; - switch_memory_pool_t *pool; - switch_speech_flag_t flags = SWITCH_SPEECH_FLAG_NONE; - uint32_t count; + switch_status_t status = SWITCH_STATUS_FALSE; + conference_file_node_t *fnode, *nptr; + switch_memory_pool_t *pool; + switch_speech_flag_t flags = SWITCH_SPEECH_FLAG_NONE; + uint32_t count; - assert(conference != NULL); + assert(conference != NULL); - if (switch_strlen_zero(text)) { - return SWITCH_STATUS_GENERR; - } + if (switch_strlen_zero(text)) { + return SWITCH_STATUS_GENERR; + } - switch_mutex_lock(conference->mutex); - switch_mutex_lock(conference->member_mutex); - count = conference->count; - if (!(conference->tts_engine && conference->tts_voice)) { - count = 0; - } - switch_mutex_unlock(conference->member_mutex); - switch_mutex_unlock(conference->mutex); + switch_mutex_lock(conference->mutex); + switch_mutex_lock(conference->member_mutex); + count = conference->count; + if (!(conference->tts_engine && conference->tts_voice)) { + count = 0; + } + switch_mutex_unlock(conference->member_mutex); + switch_mutex_unlock(conference->mutex); - if (!count) { - return SWITCH_STATUS_FALSE; - } + if (!count) { + return SWITCH_STATUS_FALSE; + } - /* Setup a memory pool to use. */ - if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Pool Failure\n"); - return SWITCH_STATUS_MEMERR; - } + /* Setup a memory pool to use. */ + if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Pool Failure\n"); + return SWITCH_STATUS_MEMERR; + } - /* Create a node object*/ - if (!(fnode = switch_core_alloc(pool, sizeof(*fnode)))) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Alloc Failure\n"); - switch_core_destroy_memory_pool(&pool); - return SWITCH_STATUS_MEMERR; - } + /* Create a node object */ + if (!(fnode = switch_core_alloc(pool, sizeof(*fnode)))) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Alloc Failure\n"); + switch_core_destroy_memory_pool(&pool); + return SWITCH_STATUS_MEMERR; + } - fnode->type = NODE_TYPE_SPEECH; - fnode->leadin = leadin; + fnode->type = NODE_TYPE_SPEECH; + fnode->leadin = leadin; - memset(&fnode->sh, 0, sizeof(fnode->sh)); - if (switch_core_speech_open(&fnode->sh, - conference->tts_engine, - conference->tts_voice, - conference->rate, - &flags, - conference->pool) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid TTS module [%s]!\n", conference->tts_engine); - return SWITCH_STATUS_FALSE; - } + memset(&fnode->sh, 0, sizeof(fnode->sh)); + if (switch_core_speech_open(&fnode->sh, + conference->tts_engine, + conference->tts_voice, + conference->rate, &flags, conference->pool) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid TTS module [%s]!\n", conference->tts_engine); + return SWITCH_STATUS_FALSE; + } - fnode->pool = pool; + fnode->pool = pool; - /* Queue the node */ - switch_mutex_lock(conference->mutex); - for (nptr = conference->fnode; nptr && nptr->next; nptr = nptr->next); + /* Queue the node */ + switch_mutex_lock(conference->mutex); + for (nptr = conference->fnode; nptr && nptr->next; nptr = nptr->next); - if (nptr) { - nptr->next = fnode; - } else { - conference->fnode = fnode; - } + if (nptr) { + nptr->next = fnode; + } else { + conference->fnode = fnode; + } - /* Begin Generation */ - switch_sleep(200000); - switch_core_speech_feed_tts(&fnode->sh, (char *)text, &flags); - switch_mutex_unlock(conference->mutex); + /* Begin Generation */ + switch_sleep(200000); + switch_core_speech_feed_tts(&fnode->sh, (char *) text, &flags); + switch_mutex_unlock(conference->mutex); - status = SWITCH_STATUS_SUCCESS; + status = SWITCH_STATUS_SUCCESS; - return status; + return status; } /* execute a callback for every member of the conference */ -static void conference_member_itterator(conference_obj_t *conference, switch_stream_handle_t *stream, conf_api_member_cmd_t pfncallback, void *data) +static void conference_member_itterator(conference_obj_t * conference, switch_stream_handle_t *stream, + conf_api_member_cmd_t pfncallback, void *data) { - conference_member_t *member = NULL; + conference_member_t *member = NULL; - assert(conference != NULL); - assert(stream != NULL); - assert(pfncallback != NULL); + assert(conference != NULL); + assert(stream != NULL); + assert(pfncallback != NULL); + + switch_mutex_lock(conference->member_mutex); + for (member = conference->members; member; member = member->next) { + pfncallback(member, stream, data); + } + switch_mutex_unlock(conference->member_mutex); - switch_mutex_lock(conference->member_mutex); - for (member = conference->members; member; member = member->next) { - pfncallback(member, stream, data); - } - switch_mutex_unlock(conference->member_mutex); - } -static void conference_list_pretty(conference_obj_t *conference, switch_stream_handle_t *stream) +static void conference_list_pretty(conference_obj_t * conference, switch_stream_handle_t *stream) { - conference_member_t *member = NULL; + conference_member_t *member = NULL; - assert(conference != NULL); - assert(stream != NULL); + assert(conference != NULL); + assert(stream != NULL); - switch_mutex_lock(conference->member_mutex); - // stream->write_function(stream, "
Current Callers:\n");
+	switch_mutex_lock(conference->member_mutex);
+	//      stream->write_function(stream, "
Current Callers:\n");
 
-    for (member = conference->members; member; member = member->next) {
-        switch_channel_t *channel;
-        switch_caller_profile_t *profile;
+	for (member = conference->members; member; member = member->next) {
+		switch_channel_t *channel;
+		switch_caller_profile_t *profile;
 
-        if (switch_test_flag(member, MFLAG_NOCHANNEL)) {
-            continue;
-        }
-        channel = switch_core_session_get_channel(member->session);
-        profile = switch_channel_get_caller_profile(channel);
+		if (switch_test_flag(member, MFLAG_NOCHANNEL)) {
+			continue;
+		}
+		channel = switch_core_session_get_channel(member->session);
+		profile = switch_channel_get_caller_profile(channel);
 
 
-        stream->write_function(stream, "%u) %s (%s)\n", 
-                               member->id, 
-                               profile->caller_id_name, 
-                               profile->caller_id_number
-                               );
+		stream->write_function(stream, "%u) %s (%s)\n", member->id, profile->caller_id_name, profile->caller_id_number);
 
-    }
+	}
+
+	switch_mutex_unlock(conference->member_mutex);
 
-    switch_mutex_unlock(conference->member_mutex);
-	
 }
 
-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)
 {
-    conference_member_t *member = NULL;
+	conference_member_t *member = NULL;
 
-    assert(conference != NULL);
-    assert(stream != NULL);
-    assert(delim != NULL);
+	assert(conference != NULL);
+	assert(stream != NULL);
+	assert(delim != NULL);
 
 
-    switch_mutex_lock(conference->member_mutex);
+	switch_mutex_lock(conference->member_mutex);
 
-    for (member = conference->members; member; member = member->next) {
-        switch_channel_t *channel;
-        switch_caller_profile_t *profile;
-        char *uuid;
-        char *name;
-        uint32_t count = 0;
+	for (member = conference->members; member; member = member->next) {
+		switch_channel_t *channel;
+		switch_caller_profile_t *profile;
+		char *uuid;
+		char *name;
+		uint32_t count = 0;
 
-        if (switch_test_flag(member, MFLAG_NOCHANNEL)) {
-            continue;
-        }
+		if (switch_test_flag(member, MFLAG_NOCHANNEL)) {
+			continue;
+		}
 
-        uuid = switch_core_session_get_uuid(member->session);
-        channel = switch_core_session_get_channel(member->session);
-        profile = switch_channel_get_caller_profile(channel);
-        name = switch_channel_get_name(channel);
+		uuid = switch_core_session_get_uuid(member->session);
+		channel = switch_core_session_get_channel(member->session);
+		profile = switch_channel_get_caller_profile(channel);
+		name = switch_channel_get_name(channel);
 
 
-        stream->write_function(stream, "%u%s%s%s%s%s%s%s%s%s", 
-                               member->id, delim, 
-                               name, delim, 
-                               uuid, delim, 
-                               profile->caller_id_name, delim, 
-                               profile->caller_id_number, delim);
+		stream->write_function(stream, "%u%s%s%s%s%s%s%s%s%s",
+							   member->id, delim,
+							   name, delim,
+							   uuid, delim, profile->caller_id_name, delim, profile->caller_id_number, delim);
 
-        if (switch_test_flag(member, MFLAG_CAN_HEAR)) {
-            stream->write_function(stream, "hear");
-            count++;
-        }
+		if (switch_test_flag(member, MFLAG_CAN_HEAR)) {
+			stream->write_function(stream, "hear");
+			count++;
+		}
 
-        if (switch_test_flag(member, MFLAG_CAN_SPEAK)) {
-            stream->write_function(stream, "%s%s", count ? "|" : "", "speak");
-            count++;
-        }
+		if (switch_test_flag(member, MFLAG_CAN_SPEAK)) {
+			stream->write_function(stream, "%s%s", count ? "|" : "", "speak");
+			count++;
+		}
 
-        stream->write_function(stream, "%s%d%s%d%s%d\n", 
-                               delim, 
-                               member->volume_in_level, delim, 
-                               member->volume_out_level, delim, 
-                               member->energy_level);
-    }
+		stream->write_function(stream, "%s%d%s%d%s%d\n",
+							   delim,
+							   member->volume_in_level, delim, member->volume_out_level, delim, member->energy_level);
+	}
+
+	switch_mutex_unlock(conference->member_mutex);
 
-    switch_mutex_unlock(conference->member_mutex);
-	
 }
 
-static switch_status_t conf_api_sub_mute(conference_member_t *member, switch_stream_handle_t *stream, void *data)
+static switch_status_t conf_api_sub_mute(conference_member_t * member, switch_stream_handle_t *stream, void *data)
 {
-    switch_status_t ret_status = SWITCH_STATUS_SUCCESS;
+	switch_status_t ret_status = SWITCH_STATUS_SUCCESS;
 
-    if (member != NULL) {
-        switch_event_t *event;
+	if (member != NULL) {
+		switch_event_t *event;
 
-        switch_clear_flag_locked(member, MFLAG_CAN_SPEAK);
-        if (member->conference->muted_sound) {
-            conference_member_play_file(member, member->conference->muted_sound, 0);
-        } else {
-            char msg[512];
+		switch_clear_flag_locked(member, MFLAG_CAN_SPEAK);
+		if (member->conference->muted_sound) {
+			conference_member_play_file(member, member->conference->muted_sound, 0);
+		} else {
+			char msg[512];
 
-            snprintf(msg, sizeof(msg), "Muted");
-            conference_member_say(member, msg, 0);
-        }
-        if (stream != NULL) {
-            stream->write_function(stream, "OK mute %u\n", member->id);
-        }
-        if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
-            switch_channel_t *channel = switch_core_session_get_channel(member->session);
-            switch_channel_event_set_data(channel, event);
+			snprintf(msg, sizeof(msg), "Muted");
+			conference_member_say(member, msg, 0);
+		}
+		if (stream != NULL) {
+			stream->write_function(stream, "OK mute %u\n", member->id);
+		}
+		if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+			switch_channel_t *channel = switch_core_session_get_channel(member->session);
+			switch_channel_event_set_data(channel, event);
 
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", member->conference->name);
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id);
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "mute-member");
-            switch_event_fire(&event);
-        }
-    } else {
-        ret_status = SWITCH_STATUS_GENERR;
-    }
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", member->conference->name);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "mute-member");
+			switch_event_fire(&event);
+		}
+	} else {
+		ret_status = SWITCH_STATUS_GENERR;
+	}
 
-    return ret_status;
+	return ret_status;
 }
 
-static switch_status_t conf_api_sub_unmute(conference_member_t *member, switch_stream_handle_t *stream, void *data)
+static switch_status_t conf_api_sub_unmute(conference_member_t * member, switch_stream_handle_t *stream, void *data)
 {
-    switch_status_t ret_status = SWITCH_STATUS_SUCCESS;
+	switch_status_t ret_status = SWITCH_STATUS_SUCCESS;
 
-    if (member != NULL) {
-        switch_event_t *event;
+	if (member != NULL) {
+		switch_event_t *event;
 
-        switch_set_flag_locked(member, MFLAG_CAN_SPEAK);
-        if (stream != NULL) {
-            stream->write_function(stream, "OK unmute %u\n", member->id);
-        }
-        if (member->conference->unmuted_sound) {
-            conference_member_play_file(member, member->conference->unmuted_sound, 0);
-        } else {
-            char msg[512];
+		switch_set_flag_locked(member, MFLAG_CAN_SPEAK);
+		if (stream != NULL) {
+			stream->write_function(stream, "OK unmute %u\n", member->id);
+		}
+		if (member->conference->unmuted_sound) {
+			conference_member_play_file(member, member->conference->unmuted_sound, 0);
+		} else {
+			char msg[512];
 
-            snprintf(msg, sizeof(msg), "Un-Muted");
-            conference_member_say(member, msg, 0);
-        }
-        if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
-            switch_channel_t *channel = switch_core_session_get_channel(member->session);
-            switch_channel_event_set_data(channel, event);
+			snprintf(msg, sizeof(msg), "Un-Muted");
+			conference_member_say(member, msg, 0);
+		}
+		if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+			switch_channel_t *channel = switch_core_session_get_channel(member->session);
+			switch_channel_event_set_data(channel, event);
 
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", member->conference->name);
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id);
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "unmute-member");
-            switch_event_fire(&event);
-        }
-    } else {
-        ret_status = SWITCH_STATUS_GENERR;
-    }
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", member->conference->name);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "unmute-member");
+			switch_event_fire(&event);
+		}
+	} else {
+		ret_status = SWITCH_STATUS_GENERR;
+	}
 
-    return ret_status;
+	return ret_status;
 }
 
-static switch_status_t conf_api_sub_deaf(conference_member_t *member, switch_stream_handle_t *stream, void *data)
+static switch_status_t conf_api_sub_deaf(conference_member_t * member, switch_stream_handle_t *stream, void *data)
 {
-    switch_status_t ret_status = SWITCH_STATUS_SUCCESS;
+	switch_status_t ret_status = SWITCH_STATUS_SUCCESS;
 
-    if (member != NULL) {
-        switch_event_t *event;
+	if (member != NULL) {
+		switch_event_t *event;
 
-        switch_clear_flag_locked(member, MFLAG_CAN_HEAR);
-        if (stream != NULL) {
-            stream->write_function(stream, "OK deaf %u\n", member->id);
-        }
-        if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
-            switch_channel_t *channel = switch_core_session_get_channel(member->session);
-            switch_channel_event_set_data(channel, event);
+		switch_clear_flag_locked(member, MFLAG_CAN_HEAR);
+		if (stream != NULL) {
+			stream->write_function(stream, "OK deaf %u\n", member->id);
+		}
+		if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+			switch_channel_t *channel = switch_core_session_get_channel(member->session);
+			switch_channel_event_set_data(channel, event);
 
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", member->conference->name);
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id);
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "deaf-member");
-            switch_event_fire(&event);
-        }
-    } else {
-        ret_status = SWITCH_STATUS_GENERR;
-    }
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", member->conference->name);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "deaf-member");
+			switch_event_fire(&event);
+		}
+	} else {
+		ret_status = SWITCH_STATUS_GENERR;
+	}
 
-    return ret_status;
+	return ret_status;
 }
 
-static switch_status_t conf_api_sub_undeaf(conference_member_t *member, switch_stream_handle_t *stream, void *data)
+static switch_status_t conf_api_sub_undeaf(conference_member_t * member, switch_stream_handle_t *stream, void *data)
 {
-    switch_status_t ret_status = SWITCH_STATUS_SUCCESS;
+	switch_status_t ret_status = SWITCH_STATUS_SUCCESS;
 
-    if (member != NULL) {
-        switch_event_t *event;
+	if (member != NULL) {
+		switch_event_t *event;
 
-        switch_set_flag_locked(member, MFLAG_CAN_HEAR);
-        if (stream != NULL) {
-            stream->write_function(stream, "OK undeaf %u\n", member->id);
-        }
-        if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
-            switch_channel_t *channel = switch_core_session_get_channel(member->session);
-            switch_channel_event_set_data(channel, event);
+		switch_set_flag_locked(member, MFLAG_CAN_HEAR);
+		if (stream != NULL) {
+			stream->write_function(stream, "OK undeaf %u\n", member->id);
+		}
+		if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+			switch_channel_t *channel = switch_core_session_get_channel(member->session);
+			switch_channel_event_set_data(channel, event);
 
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", member->conference->name);
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id);
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "undeaf-member");
-            switch_event_fire(&event);
-        }
-    } else {
-        ret_status = SWITCH_STATUS_GENERR;
-    }
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", member->conference->name);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "undeaf-member");
+			switch_event_fire(&event);
+		}
+	} else {
+		ret_status = SWITCH_STATUS_GENERR;
+	}
 
-    return ret_status;
+	return ret_status;
 }
 
-static switch_status_t conf_api_sub_kick(conference_member_t *member, switch_stream_handle_t *stream, void *data)
+static switch_status_t conf_api_sub_kick(conference_member_t * member, switch_stream_handle_t *stream, void *data)
 {
-    switch_status_t ret_status = SWITCH_STATUS_SUCCESS;
+	switch_status_t ret_status = SWITCH_STATUS_SUCCESS;
 
-    if (member != NULL) {
-        switch_event_t *event;
+	if (member != NULL) {
+		switch_event_t *event;
 
-        switch_mutex_lock(member->flag_mutex);
-        switch_clear_flag(member, MFLAG_RUNNING);
-        switch_set_flag(member, MFLAG_KICKED);
-        switch_core_session_kill_channel(member->session, SWITCH_SIG_BREAK);
-        switch_mutex_unlock(member->flag_mutex);
+		switch_mutex_lock(member->flag_mutex);
+		switch_clear_flag(member, MFLAG_RUNNING);
+		switch_set_flag(member, MFLAG_KICKED);
+		switch_core_session_kill_channel(member->session, SWITCH_SIG_BREAK);
+		switch_mutex_unlock(member->flag_mutex);
 
-        if (stream != NULL) {
-            stream->write_function(stream, "OK kicked %u\n", member->id);
-        }
+		if (stream != NULL) {
+			stream->write_function(stream, "OK kicked %u\n", member->id);
+		}
 
-        if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
-            switch_channel_t *channel = switch_core_session_get_channel(member->session);
-            switch_channel_event_set_data(channel, event);
+		if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+			switch_channel_t *channel = switch_core_session_get_channel(member->session);
+			switch_channel_event_set_data(channel, event);
 
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", member->conference->name);
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id);
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "kick-member");
-            switch_event_fire(&event);
-        }
-    } else {
-        ret_status = SWITCH_STATUS_GENERR;
-    }
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", member->conference->name);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "kick-member");
+			switch_event_fire(&event);
+		}
+	} else {
+		ret_status = SWITCH_STATUS_GENERR;
+	}
 
-    return ret_status;
+	return ret_status;
 }
 
 
-static switch_status_t conf_api_sub_dtmf(conference_member_t *member, switch_stream_handle_t *stream, void *data)
+static switch_status_t conf_api_sub_dtmf(conference_member_t * member, switch_stream_handle_t *stream, void *data)
 {
-    switch_event_t *event;
-    char *dtmf = (char *) data;
+	switch_event_t *event;
+	char *dtmf = (char *) data;
 
-    if (member == NULL) {
-        stream->write_function(stream, "Invalid member!\n");
-        return SWITCH_STATUS_GENERR;
-    }
+	if (member == NULL) {
+		stream->write_function(stream, "Invalid member!\n");
+		return SWITCH_STATUS_GENERR;
+	}
 
-    if (switch_strlen_zero(dtmf)) {
-        stream->write_function(stream, "Invalid input!\n");
-        return SWITCH_STATUS_GENERR;
-    }
-
-    
-    switch_mutex_lock(member->flag_mutex);
-    switch_core_session_kill_channel(member->session, SWITCH_SIG_BREAK);
-    switch_core_session_send_dtmf(member->session, dtmf);
-    switch_mutex_unlock(member->flag_mutex);
+	if (switch_strlen_zero(dtmf)) {
+		stream->write_function(stream, "Invalid input!\n");
+		return SWITCH_STATUS_GENERR;
+	}
 
 
-    if (stream != NULL) {
-        stream->write_function(stream, "OK sent %s to %u\n", (char *) data, member->id);
-    }
+	switch_mutex_lock(member->flag_mutex);
+	switch_core_session_kill_channel(member->session, SWITCH_SIG_BREAK);
+	switch_core_session_send_dtmf(member->session, dtmf);
+	switch_mutex_unlock(member->flag_mutex);
 
-    if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
-        switch_channel_t *channel = switch_core_session_get_channel(member->session);
-        switch_channel_event_set_data(channel, event);
 
-        switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", member->conference->name);
-        switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id);
-        switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "dtmf-member");
-        switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Digits", "%s", dtmf);
-        switch_event_fire(&event);
-    }
+	if (stream != NULL) {
+		stream->write_function(stream, "OK sent %s to %u\n", (char *) data, member->id);
+	}
 
-    return SWITCH_STATUS_SUCCESS;
+	if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+		switch_channel_t *channel = switch_core_session_get_channel(member->session);
+		switch_channel_event_set_data(channel, event);
+
+		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", member->conference->name);
+		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id);
+		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "dtmf-member");
+		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Digits", "%s", dtmf);
+		switch_event_fire(&event);
+	}
+
+	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status_t conf_api_sub_energy(conference_member_t *member, switch_stream_handle_t *stream, void *data)
+static switch_status_t conf_api_sub_energy(conference_member_t * member, switch_stream_handle_t *stream, void *data)
 {
-    switch_status_t ret_status = SWITCH_STATUS_SUCCESS;
+	switch_status_t ret_status = SWITCH_STATUS_SUCCESS;
 
-    if (member != NULL) {
-        switch_event_t *event;
+	if (member != NULL) {
+		switch_event_t *event;
 
-        if (data) {
-            switch_mutex_lock(member->flag_mutex);
-            member->energy_level = atoi((char *)data);
-            switch_mutex_unlock(member->flag_mutex);
-        }
+		if (data) {
+			switch_mutex_lock(member->flag_mutex);
+			member->energy_level = atoi((char *) data);
+			switch_mutex_unlock(member->flag_mutex);
+		}
 
-        if (stream != NULL) {
-            stream->write_function(stream, "Energy %u = %d\n", member->id, member->energy_level);
-        }
+		if (stream != NULL) {
+			stream->write_function(stream, "Energy %u = %d\n", member->id, member->energy_level);
+		}
 
-        if (data) {
-            if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
-                switch_channel_t *channel = switch_core_session_get_channel(member->session);
-                switch_channel_event_set_data(channel, event);
+		if (data) {
+			if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+				switch_channel_t *channel = switch_core_session_get_channel(member->session);
+				switch_channel_event_set_data(channel, event);
 
-                switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", member->conference->name);
-                switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id);
-                switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "energy-level-member");
-                switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Energy-Level", "%d", member->energy_level);
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", member->conference->name);
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id);
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "energy-level-member");
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Energy-Level", "%d", member->energy_level);
 
-                switch_event_fire(&event);
-            }
-        }
-    } else {
-        ret_status = SWITCH_STATUS_GENERR;
-    }
+				switch_event_fire(&event);
+			}
+		}
+	} else {
+		ret_status = SWITCH_STATUS_GENERR;
+	}
 
-    return ret_status;
+	return ret_status;
 }
 
-static switch_status_t conf_api_sub_volume_in(conference_member_t *member, switch_stream_handle_t *stream, void *data)
+static switch_status_t conf_api_sub_volume_in(conference_member_t * member, switch_stream_handle_t *stream, void *data)
 {
-    switch_status_t ret_status = SWITCH_STATUS_SUCCESS;
+	switch_status_t ret_status = SWITCH_STATUS_SUCCESS;
 
-    if (member != NULL) {
-        switch_event_t *event;
+	if (member != NULL) {
+		switch_event_t *event;
 
-        if (data) {
-            switch_mutex_lock(member->flag_mutex);
-            member->volume_in_level = atoi((char *)data);
-            switch_normalize_volume(member->volume_in_level);
-            switch_mutex_unlock(member->flag_mutex);
-        }
+		if (data) {
+			switch_mutex_lock(member->flag_mutex);
+			member->volume_in_level = atoi((char *) data);
+			switch_normalize_volume(member->volume_in_level);
+			switch_mutex_unlock(member->flag_mutex);
+		}
 
-        if (stream != NULL) {
-            stream->write_function(stream, "Volume IN %u = %d\n", member->id, member->volume_in_level);
-        }
-        if (data) {
-            if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
-                switch_channel_t *channel = switch_core_session_get_channel(member->session);
-                switch_channel_event_set_data(channel, event);
+		if (stream != NULL) {
+			stream->write_function(stream, "Volume IN %u = %d\n", member->id, member->volume_in_level);
+		}
+		if (data) {
+			if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+				switch_channel_t *channel = switch_core_session_get_channel(member->session);
+				switch_channel_event_set_data(channel, event);
 
-                switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", member->conference->name);
-                switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id);
-                switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "volume-in-member");
-                switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Volume-Level", "%u", member->volume_in_level);
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", member->conference->name);
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id);
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "volume-in-member");
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Volume-Level", "%u", member->volume_in_level);
 
-                switch_event_fire(&event);
-            }
-        }
-    } else {
-        ret_status = SWITCH_STATUS_GENERR;
-    }
+				switch_event_fire(&event);
+			}
+		}
+	} else {
+		ret_status = SWITCH_STATUS_GENERR;
+	}
 
-    return ret_status;
+	return ret_status;
 }
 
-static switch_status_t conf_api_sub_volume_out(conference_member_t *member, switch_stream_handle_t *stream, void *data)
+static switch_status_t conf_api_sub_volume_out(conference_member_t * member, switch_stream_handle_t *stream, void *data)
 {
-    switch_status_t ret_status = SWITCH_STATUS_SUCCESS;
+	switch_status_t ret_status = SWITCH_STATUS_SUCCESS;
 
-    if (member != NULL) {
-        switch_event_t *event;
+	if (member != NULL) {
+		switch_event_t *event;
 
-        if (data) {
-            switch_mutex_lock(member->flag_mutex);
-            member->volume_out_level = atoi((char *)data);
-            switch_normalize_volume(member->volume_out_level);
-            switch_mutex_unlock(member->flag_mutex);
-        }
+		if (data) {
+			switch_mutex_lock(member->flag_mutex);
+			member->volume_out_level = atoi((char *) data);
+			switch_normalize_volume(member->volume_out_level);
+			switch_mutex_unlock(member->flag_mutex);
+		}
 
-        if (stream != NULL) {
-            stream->write_function(stream, "Volume OUT %u = %d\n", member->id, member->volume_out_level);
-        }
+		if (stream != NULL) {
+			stream->write_function(stream, "Volume OUT %u = %d\n", member->id, member->volume_out_level);
+		}
 
-        if (data) {
-            if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
-                switch_channel_t *channel = switch_core_session_get_channel(member->session);
-                switch_channel_event_set_data(channel, event);
+		if (data) {
+			if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+				switch_channel_t *channel = switch_core_session_get_channel(member->session);
+				switch_channel_event_set_data(channel, event);
 
-                switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", member->conference->name);
-                switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id);
-                switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "volume-out-member");
-                switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Volume-Level", "%u", member->volume_out_level);
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", member->conference->name);
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id);
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "volume-out-member");
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Volume-Level", "%u", member->volume_out_level);
 
-                switch_event_fire(&event);
-            }
-        }
-    } else {
-        ret_status = SWITCH_STATUS_GENERR;
-    }
+				switch_event_fire(&event);
+			}
+		}
+	} else {
+		ret_status = SWITCH_STATUS_GENERR;
+	}
 
-    return ret_status;
+	return ret_status;
 }
 
-static switch_status_t conf_api_sub_list(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char**argv)
+static switch_status_t conf_api_sub_list(conference_obj_t * conference, switch_stream_handle_t *stream, int argc,
+										 char **argv)
 {
-    int ret_status = SWITCH_STATUS_GENERR;
+	int ret_status = SWITCH_STATUS_GENERR;
 
-    switch_hash_index_t *hi;
-    void *val;
-    char *d = ";";
-    int pretty = 0;
-    int argofs = (argc >= 2 && strcasecmp(argv[1], "list") == 0);	// detect being called from chat vs. api
+	switch_hash_index_t *hi;
+	void *val;
+	char *d = ";";
+	int pretty = 0;
+	int argofs = (argc >= 2 && strcasecmp(argv[1], "list") == 0);	// detect being called from chat vs. api
 
-    if (argv[1+argofs]) {
-        if (argv[2+argofs] && !strcasecmp(argv[1+argofs], "delim")) {
-            d = argv[2+argofs];
+	if (argv[1 + argofs]) {
+		if (argv[2 + argofs] && !strcasecmp(argv[1 + argofs], "delim")) {
+			d = argv[2 + argofs];
 
-            if (*d == '"') {
-                if (++d) {
-                    char *p;
-                    if ((p = strchr(d, '"'))) {
-                        *p = '\0';
-                    }
-                } else {
-                    d = ";";
-                }
-            }
-        } else if (strcasecmp(argv[1+argofs], "pretty") == 0) {
-            pretty = 1;
-        }
-    }
+			if (*d == '"') {
+				if (++d) {
+					char *p;
+					if ((p = strchr(d, '"'))) {
+						*p = '\0';
+					}
+				} else {
+					d = ";";
+				}
+			}
+		} else if (strcasecmp(argv[1 + argofs], "pretty") == 0) {
+			pretty = 1;
+		}
+	}
 
-    if (conference == NULL) {
-        for (hi = switch_hash_first(globals.conference_pool, globals.conference_hash); hi; hi = switch_hash_next(hi)) {
-            switch_hash_this(hi, NULL, NULL, &val);
-            conference = (conference_obj_t *) val;
+	if (conference == NULL) {
+		for (hi = switch_hash_first(globals.conference_pool, globals.conference_hash); hi; hi = switch_hash_next(hi)) {
+			switch_hash_this(hi, NULL, NULL, &val);
+			conference = (conference_obj_t *) val;
 
-            stream->write_function(stream, "Conference %s (%u member%s%s)\n", 
-                                   conference->name, 
-                                   conference->count, 
-                                   conference->count == 1 ? "" : "s",
-                                   switch_test_flag(conference, CFLAG_LOCKED) ? " locked" : ""
-                                   );
-            if (pretty) {
-                conference_list_pretty(conference, stream);
-            } else {
-                conference_list(conference, stream, d);
-            }
-        }
-    } else {
-        if (pretty) {
-            conference_list_pretty(conference, stream);
-        } else {
-            conference_list(conference, stream, d);
-        }
-    }
+			stream->write_function(stream, "Conference %s (%u member%s%s)\n",
+								   conference->name,
+								   conference->count,
+								   conference->count == 1 ? "" : "s",
+								   switch_test_flag(conference, CFLAG_LOCKED) ? " locked" : "");
+			if (pretty) {
+				conference_list_pretty(conference, stream);
+			} else {
+				conference_list(conference, stream, d);
+			}
+		}
+	} else {
+		if (pretty) {
+			conference_list_pretty(conference, stream);
+		} else {
+			conference_list(conference, stream, d);
+		}
+	}
 
-    ret_status = SWITCH_STATUS_SUCCESS;
+	ret_status = SWITCH_STATUS_SUCCESS;
 
-    return ret_status;
+	return ret_status;
 }
 
-static switch_status_t conf_api_sub_play(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char**argv)
+static switch_status_t conf_api_sub_play(conference_obj_t * conference, switch_stream_handle_t *stream, int argc,
+										 char **argv)
 {
-    int ret_status = SWITCH_STATUS_GENERR;
-    switch_event_t *event;
+	int ret_status = SWITCH_STATUS_GENERR;
+	switch_event_t *event;
 	uint8_t async = 0;
 
-    assert(conference != NULL);
-    assert(stream != NULL);
+	assert(conference != NULL);
+	assert(stream != NULL);
 
-    if ((argc == 4 && !strcasecmp(argv[3], "async")) || (argc == 5 && !strcasecmp(argv[4], "async"))) {    
+	if ((argc == 4 && !strcasecmp(argv[3], "async")) || (argc == 5 && !strcasecmp(argv[4], "async"))) {
 		argc--;
 		async++;
 	}
-	
-    if (argc == 3) {
-        if (conference_play_file(conference, argv[2], 0, NULL, async) == SWITCH_STATUS_SUCCESS) {
-            stream->write_function(stream, "(play) Playing file %s\n", argv[2]);
-            if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
-                switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", conference->name);
-                switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "play-file");
-                switch_event_add_header(event, SWITCH_STACK_BOTTOM, "File", "%s", argv[2]);
-                switch_event_fire(&event);
-            }
-        } else {
-            stream->write_function(stream, "(play) File: %s not found.\n", argv[2] ? argv[2] : "(unspecified)");
-        }
-        ret_status = SWITCH_STATUS_SUCCESS;
-    } else if (argc == 4) {
-        uint32_t id = atoi(argv[3]);
-        conference_member_t *member;
 
-        if ((member = conference_member_get(conference, id))) {
-            if (conference_member_play_file(member, argv[2], 0) == SWITCH_STATUS_SUCCESS) {
-                stream->write_function(stream, "(play) Playing file %s to member %u\n", argv[2], id);
-                if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
-                    switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", conference->name);
-                    switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", id);
-                    switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "play-file-member");
-                    switch_event_add_header(event, SWITCH_STACK_BOTTOM, "File", "%s", argv[2]);
-                    switch_event_fire(&event);
-                }
-            } else {
-                stream->write_function(stream, "(play) File: %s not found.\n", argv[2] ? argv[2] : "(unspecified)");
-            }
-            ret_status = SWITCH_STATUS_SUCCESS;
-        } else {
-            stream->write_function(stream, "Member: %u not found.\n", id);
-        }
-    }
+	if (argc == 3) {
+		if (conference_play_file(conference, argv[2], 0, NULL, async) == SWITCH_STATUS_SUCCESS) {
+			stream->write_function(stream, "(play) Playing file %s\n", argv[2]);
+			if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", conference->name);
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "play-file");
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "File", "%s", argv[2]);
+				switch_event_fire(&event);
+			}
+		} else {
+			stream->write_function(stream, "(play) File: %s not found.\n", argv[2] ? argv[2] : "(unspecified)");
+		}
+		ret_status = SWITCH_STATUS_SUCCESS;
+	} else if (argc == 4) {
+		uint32_t id = atoi(argv[3]);
+		conference_member_t *member;
 
-    return ret_status;
+		if ((member = conference_member_get(conference, id))) {
+			if (conference_member_play_file(member, argv[2], 0) == SWITCH_STATUS_SUCCESS) {
+				stream->write_function(stream, "(play) Playing file %s to member %u\n", argv[2], id);
+				if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) ==
+					SWITCH_STATUS_SUCCESS) {
+					switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", conference->name);
+					switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", id);
+					switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "play-file-member");
+					switch_event_add_header(event, SWITCH_STACK_BOTTOM, "File", "%s", argv[2]);
+					switch_event_fire(&event);
+				}
+			} else {
+				stream->write_function(stream, "(play) File: %s not found.\n", argv[2] ? argv[2] : "(unspecified)");
+			}
+			ret_status = SWITCH_STATUS_SUCCESS;
+		} else {
+			stream->write_function(stream, "Member: %u not found.\n", id);
+		}
+	}
+
+	return ret_status;
 }
 
-static switch_status_t conf_api_sub_say(conference_obj_t *conference, switch_stream_handle_t *stream, const char *text)
+static switch_status_t conf_api_sub_say(conference_obj_t * conference, switch_stream_handle_t *stream, const char *text)
 {
-    int ret_status = SWITCH_STATUS_GENERR;
+	int ret_status = SWITCH_STATUS_GENERR;
 
-    if (switch_strlen_zero(text)) {
-        stream->write_function(stream, "(say) Error! No text.");
-        return ret_status;
-    }
+	if (switch_strlen_zero(text)) {
+		stream->write_function(stream, "(say) Error! No text.");
+		return ret_status;
+	}
 
-    if (conference_say(conference, text, 0) == SWITCH_STATUS_SUCCESS) {
-        switch_event_t *event;
+	if (conference_say(conference, text, 0) == SWITCH_STATUS_SUCCESS) {
+		switch_event_t *event;
 
-        stream->write_function(stream, "(say) OK\n");
-        if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", conference->name);
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "speak-text");
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Text", "%s", text);
-            switch_event_fire(&event);
-        }
-        ret_status = SWITCH_STATUS_SUCCESS;
-    } else {
-        stream->write_function(stream, "(say) Error!");
-    }
+		stream->write_function(stream, "(say) OK\n");
+		if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", conference->name);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "speak-text");
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Text", "%s", text);
+			switch_event_fire(&event);
+		}
+		ret_status = SWITCH_STATUS_SUCCESS;
+	} else {
+		stream->write_function(stream, "(say) Error!");
+	}
 
-    return ret_status;
+	return ret_status;
 }
 
-static switch_status_t conf_api_sub_saymember(conference_obj_t *conference, switch_stream_handle_t *stream, const char *text)
+static switch_status_t conf_api_sub_saymember(conference_obj_t * conference, switch_stream_handle_t *stream,
+											  const char *text)
 {
-    int ret_status = SWITCH_STATUS_GENERR;
-    char *expanded = NULL;
-    char *start_text = NULL;
-    char *workspace = NULL;
-    uint32_t id = 0;
-    conference_member_t *member;
+	int ret_status = SWITCH_STATUS_GENERR;
+	char *expanded = NULL;
+	char *start_text = NULL;
+	char *workspace = NULL;
+	uint32_t id = 0;
+	conference_member_t *member;
 
-    if (switch_strlen_zero(text)) {
-        stream->write_function(stream, "(saymember) No Text!\n");
-        goto done;
-    }
+	if (switch_strlen_zero(text)) {
+		stream->write_function(stream, "(saymember) No Text!\n");
+		goto done;
+	}
 
-    if (!(workspace = strdup(text))) {
-        stream->write_function(stream, "(saymember) Memory Error!\n");
-        goto done;
-    }
+	if (!(workspace = strdup(text))) {
+		stream->write_function(stream, "(saymember) Memory Error!\n");
+		goto done;
+	}
 
-    if ((start_text = strchr(workspace, ' '))) {
-        *start_text++ = '\0';
-        text = start_text;
-    }
+	if ((start_text = strchr(workspace, ' '))) {
+		*start_text++ = '\0';
+		text = start_text;
+	}
 
-    id = atoi(workspace);
+	id = atoi(workspace);
 
-    if (!id || switch_strlen_zero(text)) {
-        stream->write_function(stream, "(saymember) No Text!\n");
-        goto done;
-    }
+	if (!id || switch_strlen_zero(text)) {
+		stream->write_function(stream, "(saymember) No Text!\n");
+		goto done;
+	}
 
-    if (!(member = conference_member_get(conference, id))) {
-        stream->write_function(stream, "(saymember) Unknown Member %u!", id);
-        goto done;
-    }
+	if (!(member = conference_member_get(conference, id))) {
+		stream->write_function(stream, "(saymember) Unknown Member %u!", id);
+		goto done;
+	}
 
-    if ((expanded = switch_channel_expand_variables(switch_core_session_get_channel(member->session), (char *)text)) != text) {
-        text = expanded;
-    } else {
-        expanded = NULL;
-    }
+	if ((expanded =
+		 switch_channel_expand_variables(switch_core_session_get_channel(member->session), (char *) text)) != text) {
+		text = expanded;
+	} else {
+		expanded = NULL;
+	}
 
-    if (text && conference_member_say(member, (char *)text, 0) == SWITCH_STATUS_SUCCESS) {
-        switch_event_t *event;
+	if (text && conference_member_say(member, (char *) text, 0) == SWITCH_STATUS_SUCCESS) {
+		switch_event_t *event;
 
-        stream->write_function(stream, "(saymember) OK\n");
-        if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", conference->name);
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "speak-text-member");
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", id);
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Text", "%s", text);
-            switch_event_fire(&event);
-        }
-        ret_status = SWITCH_STATUS_SUCCESS;
-    } else {
-        stream->write_function(stream, "(saymember) Error!");
-    }
+		stream->write_function(stream, "(saymember) OK\n");
+		if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", conference->name);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "speak-text-member");
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", id);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Text", "%s", text);
+			switch_event_fire(&event);
+		}
+		ret_status = SWITCH_STATUS_SUCCESS;
+	} else {
+		stream->write_function(stream, "(saymember) Error!");
+	}
 
- done:    
-    switch_safe_free(workspace);
-    switch_safe_free(expanded);
-    return ret_status;
+  done:
+	switch_safe_free(workspace);
+	switch_safe_free(expanded);
+	return ret_status;
 }
 
-static switch_status_t conf_api_sub_stop(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char**argv)
+static switch_status_t conf_api_sub_stop(conference_obj_t * conference, switch_stream_handle_t *stream, int argc,
+										 char **argv)
 {
-    int ret_status = SWITCH_STATUS_GENERR;
-    uint8_t current = 0, all = 0;
+	int ret_status = SWITCH_STATUS_GENERR;
+	uint8_t current = 0, all = 0;
 
-    assert(conference != NULL);
-    assert(stream != NULL);
-
-    if (argc > 2) {
-        current = strcasecmp(argv[2], "current") ? 0 : 1;
-        all = strcasecmp(argv[2], "all") ? 0 : 1;
-    } else {
-        all = 1;
-    }
-
-    if (current || all) {
-        if (argc == 4) {
-            uint32_t id = atoi(argv[3]);
-            conference_member_t *member;
-
-            if ((member = conference_member_get(conference, id))) {
-                uint32_t stopped = conference_member_stop_file(member, current ? FILE_STOP_CURRENT : FILE_STOP_ALL);
-                stream->write_function(stream, "Stopped %u files.\n", stopped);
-            } else {
-                stream->write_function(stream, "Member: %u not found.\n", id);
-            }
-            ret_status = SWITCH_STATUS_SUCCESS;
-        } else {
-            uint32_t stopped = conference_stop_file(conference, current ? FILE_STOP_CURRENT : FILE_STOP_ALL);
-            stream->write_function(stream, "Stopped %u files.\n", stopped);
-            ret_status = SWITCH_STATUS_SUCCESS;
-        }
-    }
-
-    return ret_status;
-}
-
-static switch_status_t conf_api_sub_relate(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char**argv)
-{
-    int ret_status = SWITCH_STATUS_GENERR;
-
-    assert(conference != NULL);
-    assert(stream != NULL);
-
-    if (argc > 4) {
-        uint8_t nospeak = 0, nohear = 0, clear = 0;
-        nospeak = strstr(argv[4], "nospeak") ? 1 : 0;
-        nohear = strstr(argv[4], "nohear") ? 1 : 0;
-
-        if (!strcasecmp(argv[4], "clear")) {
-            clear = 1;
-        }
-
-        if (!(clear || nospeak || nohear)) { 
-            ret_status = SWITCH_STATUS_GENERR;
-            goto done;
-        }
-        ret_status = SWITCH_STATUS_SUCCESS;
-
-        if (clear) {
-            conference_member_t *member = NULL;
-            uint32_t id = atoi(argv[2]);
-            uint32_t oid = atoi(argv[3]);
-
-            if ((member = conference_member_get(conference, id))) {
-                member_del_relationship(member, oid);
-                stream->write_function(stream, "relationship %u->%u cleared.", id, oid);
-            } else {
-                stream->write_function(stream, "relationship %u->%u not found", id, oid);
-            }
-        } else if (nospeak || nohear) {
-            conference_member_t *member = NULL, *other_member = NULL;
-            uint32_t id = atoi(argv[2]);
-            uint32_t oid = atoi(argv[3]);
-
-            if ((member = conference_member_get(conference, id)) && (other_member = conference_member_get(conference, oid))) {
-                conference_relationship_t *rel = NULL;
-                if ((rel = member_get_relationship(member, other_member))) {
-                    rel->flags = 0;
-                } else {
-                    rel = member_add_relationship(member, oid);
-                }
-
-                if (rel) {
-                    switch_set_flag(rel, RFLAG_CAN_SPEAK | RFLAG_CAN_HEAR);
-                    if (nospeak) {
-                        switch_clear_flag(rel, RFLAG_CAN_SPEAK);
-                    }
-                    if (nohear) {
-                        switch_clear_flag(rel, RFLAG_CAN_HEAR);
-                    }
-                    stream->write_function(stream, "ok %u->%u set\n", id, oid);
-                } else {
-                    stream->write_function(stream, "error!\n");
-                }
-            } else {
-                stream->write_function(stream, "relationship %u->%u not found", id, oid);
-            }
-        }
-    }
-
- done:
-    return ret_status;
-}
-
-static switch_status_t conf_api_sub_lock(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char**argv)
-{
-    switch_event_t *event;
-
-    assert(conference != NULL);
-    assert(stream != NULL);
-
-    if (conference->is_locked_sound) {
-        conference_play_file(conference, conference->is_locked_sound, CONF_DEFAULT_LEADIN, NULL, 0);
-    }
-
-    switch_set_flag_locked(conference, CFLAG_LOCKED);
-    stream->write_function(stream, "OK %s locked\n", argv[0]);
-    if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
-        switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", conference->name);
-        switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "lock");
-        switch_event_fire(&event);
-    }
-
-    return 0;
-}
-
-static switch_status_t conf_api_sub_unlock(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char**argv)
-{
-    switch_event_t *event;
-
-    assert(conference != NULL);
-    assert(stream != NULL);
-
-    if (conference->is_unlocked_sound) {
-        conference_play_file(conference, conference->is_unlocked_sound, CONF_DEFAULT_LEADIN, NULL, 0);
-    }
-
-    switch_clear_flag_locked(conference, CFLAG_LOCKED);
-    stream->write_function(stream, "OK %s unlocked\n", argv[0]);
-    if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
-        switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", conference->name);
-        switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "unlock");
-        switch_event_fire(&event);
-    }
-	
-
-    return 0;
-}
-
-static switch_status_t conf_api_sub_dial(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char**argv)
-{
-    switch_status_t ret_status = SWITCH_STATUS_SUCCESS;
-
-    assert(stream != NULL);
+	assert(conference != NULL);
+	assert(stream != NULL);
 
 	if (argc > 2) {
-        switch_call_cause_t cause;
+		current = strcasecmp(argv[2], "current") ? 0 : 1;
+		all = strcasecmp(argv[2], "all") ? 0 : 1;
+	} else {
+		all = 1;
+	}
+
+	if (current || all) {
+		if (argc == 4) {
+			uint32_t id = atoi(argv[3]);
+			conference_member_t *member;
+
+			if ((member = conference_member_get(conference, id))) {
+				uint32_t stopped = conference_member_stop_file(member, current ? FILE_STOP_CURRENT : FILE_STOP_ALL);
+				stream->write_function(stream, "Stopped %u files.\n", stopped);
+			} else {
+				stream->write_function(stream, "Member: %u not found.\n", id);
+			}
+			ret_status = SWITCH_STATUS_SUCCESS;
+		} else {
+			uint32_t stopped = conference_stop_file(conference, current ? FILE_STOP_CURRENT : FILE_STOP_ALL);
+			stream->write_function(stream, "Stopped %u files.\n", stopped);
+			ret_status = SWITCH_STATUS_SUCCESS;
+		}
+	}
+
+	return ret_status;
+}
+
+static switch_status_t conf_api_sub_relate(conference_obj_t * conference, switch_stream_handle_t *stream, int argc,
+										   char **argv)
+{
+	int ret_status = SWITCH_STATUS_GENERR;
+
+	assert(conference != NULL);
+	assert(stream != NULL);
+
+	if (argc > 4) {
+		uint8_t nospeak = 0, nohear = 0, clear = 0;
+		nospeak = strstr(argv[4], "nospeak") ? 1 : 0;
+		nohear = strstr(argv[4], "nohear") ? 1 : 0;
+
+		if (!strcasecmp(argv[4], "clear")) {
+			clear = 1;
+		}
+
+		if (!(clear || nospeak || nohear)) {
+			ret_status = SWITCH_STATUS_GENERR;
+			goto done;
+		}
+		ret_status = SWITCH_STATUS_SUCCESS;
+
+		if (clear) {
+			conference_member_t *member = NULL;
+			uint32_t id = atoi(argv[2]);
+			uint32_t oid = atoi(argv[3]);
+
+			if ((member = conference_member_get(conference, id))) {
+				member_del_relationship(member, oid);
+				stream->write_function(stream, "relationship %u->%u cleared.", id, oid);
+			} else {
+				stream->write_function(stream, "relationship %u->%u not found", id, oid);
+			}
+		} else if (nospeak || nohear) {
+			conference_member_t *member = NULL, *other_member = NULL;
+			uint32_t id = atoi(argv[2]);
+			uint32_t oid = atoi(argv[3]);
+
+			if ((member = conference_member_get(conference, id))
+				&& (other_member = conference_member_get(conference, oid))) {
+				conference_relationship_t *rel = NULL;
+				if ((rel = member_get_relationship(member, other_member))) {
+					rel->flags = 0;
+				} else {
+					rel = member_add_relationship(member, oid);
+				}
+
+				if (rel) {
+					switch_set_flag(rel, RFLAG_CAN_SPEAK | RFLAG_CAN_HEAR);
+					if (nospeak) {
+						switch_clear_flag(rel, RFLAG_CAN_SPEAK);
+					}
+					if (nohear) {
+						switch_clear_flag(rel, RFLAG_CAN_HEAR);
+					}
+					stream->write_function(stream, "ok %u->%u set\n", id, oid);
+				} else {
+					stream->write_function(stream, "error!\n");
+				}
+			} else {
+				stream->write_function(stream, "relationship %u->%u not found", id, oid);
+			}
+		}
+	}
+
+  done:
+	return ret_status;
+}
+
+static switch_status_t conf_api_sub_lock(conference_obj_t * conference, switch_stream_handle_t *stream, int argc,
+										 char **argv)
+{
+	switch_event_t *event;
+
+	assert(conference != NULL);
+	assert(stream != NULL);
+
+	if (conference->is_locked_sound) {
+		conference_play_file(conference, conference->is_locked_sound, CONF_DEFAULT_LEADIN, NULL, 0);
+	}
+
+	switch_set_flag_locked(conference, CFLAG_LOCKED);
+	stream->write_function(stream, "OK %s locked\n", argv[0]);
+	if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", conference->name);
+		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "lock");
+		switch_event_fire(&event);
+	}
+
+	return 0;
+}
+
+static switch_status_t conf_api_sub_unlock(conference_obj_t * conference, switch_stream_handle_t *stream, int argc,
+										   char **argv)
+{
+	switch_event_t *event;
+
+	assert(conference != NULL);
+	assert(stream != NULL);
+
+	if (conference->is_unlocked_sound) {
+		conference_play_file(conference, conference->is_unlocked_sound, CONF_DEFAULT_LEADIN, NULL, 0);
+	}
+
+	switch_clear_flag_locked(conference, CFLAG_LOCKED);
+	stream->write_function(stream, "OK %s unlocked\n", argv[0]);
+	if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", conference->name);
+		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "unlock");
+		switch_event_fire(&event);
+	}
+
+
+	return 0;
+}
+
+static switch_status_t conf_api_sub_dial(conference_obj_t * conference, switch_stream_handle_t *stream, int argc,
+										 char **argv)
+{
+	switch_status_t ret_status = SWITCH_STATUS_SUCCESS;
+
+	assert(stream != NULL);
+
+	if (argc > 2) {
+		switch_call_cause_t cause;
 
 		if (conference) {
 			conference_outcall(conference, NULL, NULL, argv[2], 60, NULL, argv[4], argv[3], &cause);
@@ -3069,21 +3070,22 @@ static switch_status_t conf_api_sub_dial(conference_obj_t *conference, switch_st
 			conference_outcall(NULL, argv[0], NULL, argv[2], 60, NULL, argv[4], argv[3], &cause);
 		}
 
-        stream->write_function(stream, "Call Requested: result: [%s]\n", switch_channel_cause2str(cause));
-    } else {
-        stream->write_function(stream, "Bad Args\n");
-        ret_status = SWITCH_STATUS_GENERR;
-    }
+		stream->write_function(stream, "Call Requested: result: [%s]\n", switch_channel_cause2str(cause));
+	} else {
+		stream->write_function(stream, "Bad Args\n");
+		ret_status = SWITCH_STATUS_GENERR;
+	}
 
-    return ret_status;
+	return ret_status;
 }
 
 
-static switch_status_t conf_api_sub_bgdial(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char**argv)
+static switch_status_t conf_api_sub_bgdial(conference_obj_t * conference, switch_stream_handle_t *stream, int argc,
+										   char **argv)
 {
-    switch_status_t ret_status = SWITCH_STATUS_SUCCESS;
+	switch_status_t ret_status = SWITCH_STATUS_SUCCESS;
 
-    assert(stream != NULL);
+	assert(stream != NULL);
 
 	if (argc > 2) {
 		if (conference) {
@@ -3092,171 +3094,174 @@ static switch_status_t conf_api_sub_bgdial(conference_obj_t *conference, switch_
 			conference_outcall_bg(NULL, argv[1], NULL, argv[2], 60, NULL, argv[4], argv[3]);
 		}
 		stream->write_function(stream, "OK\n");
-    } else {
-        stream->write_function(stream, "Bad Args\n");
-        ret_status = SWITCH_STATUS_GENERR;
-    }
+	} else {
+		stream->write_function(stream, "Bad Args\n");
+		ret_status = SWITCH_STATUS_GENERR;
+	}
 
-    return ret_status;
+	return ret_status;
 }
 
-static switch_status_t conf_api_sub_transfer(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char**argv)
+static switch_status_t conf_api_sub_transfer(conference_obj_t * conference, switch_stream_handle_t *stream, int argc,
+											 char **argv)
 {
-    switch_status_t ret_status = SWITCH_STATUS_SUCCESS;
-    char *params = NULL;
-    assert(conference != NULL);
-    assert(stream != NULL);
+	switch_status_t ret_status = SWITCH_STATUS_SUCCESS;
+	char *params = NULL;
+	assert(conference != NULL);
+	assert(stream != NULL);
 
-    if (argc > 3 && !switch_strlen_zero(argv[2])) {
-        int x;
+	if (argc > 3 && !switch_strlen_zero(argv[2])) {
+		int x;
 
-        for (x = 3; xwrite_function(stream, "No Member %u in conference %s.\n", id, conference->name);
-                continue;
-            }
+			if (!id || !(member = conference_member_get(conference, id))) {
+				stream->write_function(stream, "No Member %u in conference %s.\n", id, conference->name);
+				continue;
+			}
 
-            channel = switch_core_session_get_channel(member->session);
+			channel = switch_core_session_get_channel(member->session);
 
-            /* build a new conference if it doesn't exist */
-            if (!(new_conference = (conference_obj_t *) switch_core_hash_find(globals.conference_hash, argv[2]))) {
-                switch_memory_pool_t *pool = NULL;
-                char *conf_name;
-                conf_xml_cfg_t xml_cfg = {0};
+			/* build a new conference if it doesn't exist */
+			if (!(new_conference = (conference_obj_t *) switch_core_hash_find(globals.conference_hash, argv[2]))) {
+				switch_memory_pool_t *pool = NULL;
+				char *conf_name;
+				conf_xml_cfg_t xml_cfg = { 0 };
 
-                /* Setup a memory pool to use. */
-                if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) {
-                    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Pool Failure\n");
-                    goto done;
-                }
+				/* Setup a memory pool to use. */
+				if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) {
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Pool Failure\n");
+					goto done;
+				}
 
-                conf_name = switch_core_strdup(pool, argv[2]);
+				conf_name = switch_core_strdup(pool, argv[2]);
 
-                if ((profile_name = strchr(conf_name, '@'))) {
-                    *profile_name++ = '\0';
-                } else {
-                    profile_name = "default";
-                }
-                params = switch_mprintf("conf_name=%s&profile_name=%s", conf_name, profile_name);
-                /* Open the config from the xml registry  */
-                if (!(cxml = switch_xml_open_cfg(global_cf_name, &cfg, params))) {
-                    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", global_cf_name);
-                    goto done;
-                }
+				if ((profile_name = strchr(conf_name, '@'))) {
+					*profile_name++ = '\0';
+				} else {
+					profile_name = "default";
+				}
+				params = switch_mprintf("conf_name=%s&profile_name=%s", conf_name, profile_name);
+				/* Open the config from the xml registry  */
+				if (!(cxml = switch_xml_open_cfg(global_cf_name, &cfg, params))) {
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", global_cf_name);
+					goto done;
+				}
 
-                if ((profiles = switch_xml_child(cfg, "profiles"))) {
-                    xml_cfg.profile = switch_xml_find_child(profiles, "profile", "name", profile_name);
-                }
+				if ((profiles = switch_xml_child(cfg, "profiles"))) {
+					xml_cfg.profile = switch_xml_find_child(profiles, "profile", "name", profile_name);
+				}
 
-                if (!xml_cfg.profile) {
-                    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot find profile: %s\n", profile_name);
-                    switch_xml_free(cxml);
-                    cxml = NULL;
-                    goto done;
-                }
+				if (!xml_cfg.profile) {
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot find profile: %s\n", profile_name);
+					switch_xml_free(cxml);
+					cxml = NULL;
+					goto done;
+				}
 
-                xml_cfg.controls = switch_xml_child(cfg, "caller-controls");
+				xml_cfg.controls = switch_xml_child(cfg, "caller-controls");
 
-                /* Release the config registry handle */
-                if (cxml) {
-                    switch_xml_free(cxml);
-                    cxml = NULL;
-                }
+				/* Release the config registry handle */
+				if (cxml) {
+					switch_xml_free(cxml);
+					cxml = NULL;
+				}
 
-                /* Create the conference object. */
-                new_conference = conference_new(conf_name, xml_cfg, pool);
+				/* Create the conference object. */
+				new_conference = conference_new(conf_name, xml_cfg, pool);
 
-                if (!new_conference) {
-                    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
-                    if (pool != NULL) {
-                        switch_core_destroy_memory_pool(&pool);
-                    }
-                    goto done;
-                }
+				if (!new_conference) {
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
+					if (pool != NULL) {
+						switch_core_destroy_memory_pool(&pool);
+					}
+					goto done;
+				}
 
-                /* Set the minimum number of members (once you go above it you cannot go below it) */
-                new_conference->min = 1;
+				/* Set the minimum number of members (once you go above it you cannot go below it) */
+				new_conference->min = 1;
 
-                /* Indicate the conference is dynamic */
-                switch_set_flag_locked(new_conference, CFLAG_DYNAMIC);
+				/* Indicate the conference is dynamic */
+				switch_set_flag_locked(new_conference, CFLAG_DYNAMIC);
 
-                switch_mutex_lock(new_conference->mutex);
+				switch_mutex_lock(new_conference->mutex);
 
-                /* Start the conference thread for this conference */
-                launch_conference_thread(new_conference);
-            } else {
-                switch_mutex_lock(new_conference->mutex);
-            }
+				/* Start the conference thread for this conference */
+				launch_conference_thread(new_conference);
+			} else {
+				switch_mutex_lock(new_conference->mutex);
+			}
 
-            /* move the member from the old conference to the new one */
-            conference_del_member(conference, member);
-            conference_add_member(new_conference, member);
-            switch_mutex_unlock(new_conference->mutex);
+			/* move the member from the old conference to the new one */
+			conference_del_member(conference, member);
+			conference_add_member(new_conference, member);
+			switch_mutex_unlock(new_conference->mutex);
 
-            stream->write_function(stream, "OK Members sent to conference %s.\n", argv[2]);
+			stream->write_function(stream, "OK Members sent to conference %s.\n", argv[2]);
 
-            /* tell them what happened */
-            if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
-                switch_channel_event_set_data(channel, event);
-                switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id);
-                switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Old-Conference-Name", "%s", conference->name);
-                switch_event_add_header(event, SWITCH_STACK_BOTTOM, "New-Conference-Name", "%s", argv[3]);
-                switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "transfer");
-                switch_event_fire(&event);
-            }
-        }
-    } else {
-        ret_status = SWITCH_STATUS_GENERR;
-    }
+			/* tell them what happened */
+			if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+				switch_channel_event_set_data(channel, event);
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id);
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Old-Conference-Name", "%s", conference->name);
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "New-Conference-Name", "%s", argv[3]);
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "transfer");
+				switch_event_fire(&event);
+			}
+		}
+	} else {
+		ret_status = SWITCH_STATUS_GENERR;
+	}
 
- done:
-    switch_safe_free(params);
-    return ret_status;
+  done:
+	switch_safe_free(params);
+	return ret_status;
 }
 
-static switch_status_t conf_api_sub_record(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char**argv)
+static switch_status_t conf_api_sub_record(conference_obj_t * conference, switch_stream_handle_t *stream, int argc,
+										   char **argv)
 {
-    switch_status_t ret_status = SWITCH_STATUS_SUCCESS;
-    assert(conference != NULL);
-    assert(stream != NULL);
+	switch_status_t ret_status = SWITCH_STATUS_SUCCESS;
+	assert(conference != NULL);
+	assert(stream != NULL);
 
-    if (argc > 2) {
+	if (argc > 2) {
 		stream->write_function(stream, "Record file %s\n", argv[2]);
-        launch_conference_record_thread(conference, argv[2]);
-    } else {
-        ret_status = SWITCH_STATUS_GENERR;
-    }
+		launch_conference_record_thread(conference, argv[2]);
+	} else {
+		ret_status = SWITCH_STATUS_GENERR;
+	}
 
-    return ret_status;
+	return ret_status;
 }
 
-static switch_status_t conf_api_sub_norecord(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char**argv)
+static switch_status_t conf_api_sub_norecord(conference_obj_t * conference, switch_stream_handle_t *stream, int argc,
+											 char **argv)
 {
-    switch_status_t ret_status = SWITCH_STATUS_SUCCESS;
+	switch_status_t ret_status = SWITCH_STATUS_SUCCESS;
 
-    assert(conference != NULL);
-    assert(stream != NULL);
+	assert(conference != NULL);
+	assert(stream != NULL);
 
-    if (argc > 2) {
-        int all = (strcasecmp(argv[2], "all") == 0 );
+	if (argc > 2) {
+		int all = (strcasecmp(argv[2], "all") == 0);
 		stream->write_function(stream, "Stop recording file %s\n", argv[2]);
-		
-        if (!conference_record_stop(conference, all ? NULL : argv[2]) && !all) {
-            stream->write_function(stream, "non-existant recording '%s'\n", argv[2]);
-        }
-    } else {
-        ret_status = SWITCH_STATUS_GENERR;
-    }
-	
-    return ret_status;
+
+		if (!conference_record_stop(conference, all ? NULL : argv[2]) && !all) {
+			stream->write_function(stream, "non-existant recording '%s'\n", argv[2]);
+		}
+	} else {
+		ret_status = SWITCH_STATUS_GENERR;
+	}
+
+	return ret_status;
 }
 
 typedef enum {
@@ -3287,198 +3292,215 @@ typedef enum {
 /* API Interface Function sub-commands */
 /* Entries in this list should be kept in sync with the enum above */
 static api_command_t conf_api_sub_commands[] = {
-	{"list", (void_fn_t)&conf_api_sub_list, CONF_API_SUB_ARGS_SPLIT, " list [delim ]"}, 
-	{"energy", (void_fn_t)&conf_api_sub_energy, CONF_API_SUB_MEMBER_TARGET, " energy  []"}, 
-	{"volume_in", (void_fn_t)&conf_api_sub_volume_in, CONF_API_SUB_MEMBER_TARGET, " volume_in  []"}, 
-	{"volume_out", (void_fn_t)&conf_api_sub_volume_out, CONF_API_SUB_MEMBER_TARGET, " volume_out  []"}, 
-	{"play", (void_fn_t)&conf_api_sub_play, CONF_API_SUB_ARGS_SPLIT, " play  []"}, 
-	{"say", (void_fn_t)&conf_api_sub_say, CONF_API_SUB_ARGS_AS_ONE, " say "}, 
-	{"saymember", (void_fn_t)&conf_api_sub_saymember, CONF_API_SUB_ARGS_AS_ONE, " saymember  "}, 
-	{"stop", (void_fn_t)&conf_api_sub_stop, CONF_API_SUB_ARGS_SPLIT, " stop <[current|all|last]> []"}, 
-	{"dtmf", (void_fn_t)&conf_api_sub_dtmf, CONF_API_SUB_MEMBER_TARGET, " dtmf <[member_id|all|last]> "}, 
-	{"kick", (void_fn_t)&conf_api_sub_kick, CONF_API_SUB_MEMBER_TARGET, " kick <[member_id|all|last]>"}, 
-	{"mute", (void_fn_t)&conf_api_sub_mute, CONF_API_SUB_MEMBER_TARGET, " mute <[member_id|all]|last>"}, 
-	{"unmute", (void_fn_t)&conf_api_sub_unmute, CONF_API_SUB_MEMBER_TARGET, " unmute <[member_id|all]|last>"}, 
-	{"deaf", (void_fn_t)&conf_api_sub_deaf, CONF_API_SUB_MEMBER_TARGET, " deaf <[member_id|all]|last>"}, 
-	{"undeaf", (void_fn_t)&conf_api_sub_undeaf, CONF_API_SUB_MEMBER_TARGET, " undeaf <[member_id|all]|last>"}, 
-	{"relate", (void_fn_t)&conf_api_sub_relate, CONF_API_SUB_ARGS_SPLIT, " relate   [nospeak|nohear|clear]"}, 
-	{"lock", (void_fn_t)&conf_api_sub_lock, CONF_API_SUB_ARGS_SPLIT, " lock"}, 
-	{"unlock", (void_fn_t)&conf_api_sub_unlock, CONF_API_SUB_ARGS_SPLIT, " unlock"}, 
-	{"dial", (void_fn_t)&conf_api_sub_dial, CONF_API_SUB_ARGS_SPLIT, " dial /  "}, 
-	{"bgdial", (void_fn_t)&conf_api_sub_bgdial, CONF_API_SUB_ARGS_SPLIT, " bgdial /  "}, 
-	{"transfer", (void_fn_t)&conf_api_sub_transfer, CONF_API_SUB_ARGS_SPLIT, " transfer   [...]"}, 
-	{"record", (void_fn_t)&conf_api_sub_record, CONF_API_SUB_ARGS_SPLIT, " record "}, 
-	{"norecord", (void_fn_t)&conf_api_sub_norecord, CONF_API_SUB_ARGS_SPLIT, " norecord <[filename|all]>"}, 
+	{"list", (void_fn_t) & conf_api_sub_list, CONF_API_SUB_ARGS_SPLIT, " list [delim ]"},
+	{"energy", (void_fn_t) & conf_api_sub_energy, CONF_API_SUB_MEMBER_TARGET,
+	 " energy  []"},
+	{"volume_in", (void_fn_t) & conf_api_sub_volume_in, CONF_API_SUB_MEMBER_TARGET,
+	 " volume_in  []"},
+	{"volume_out", (void_fn_t) & conf_api_sub_volume_out, CONF_API_SUB_MEMBER_TARGET,
+	 " volume_out  []"},
+	{"play", (void_fn_t) & conf_api_sub_play, CONF_API_SUB_ARGS_SPLIT, " play  []"},
+	{"say", (void_fn_t) & conf_api_sub_say, CONF_API_SUB_ARGS_AS_ONE, " say "},
+	{"saymember", (void_fn_t) & conf_api_sub_saymember, CONF_API_SUB_ARGS_AS_ONE,
+	 " saymember  "},
+	{"stop", (void_fn_t) & conf_api_sub_stop, CONF_API_SUB_ARGS_SPLIT,
+	 " stop <[current|all|last]> []"},
+	{"dtmf", (void_fn_t) & conf_api_sub_dtmf, CONF_API_SUB_MEMBER_TARGET,
+	 " dtmf <[member_id|all|last]> "},
+	{"kick", (void_fn_t) & conf_api_sub_kick, CONF_API_SUB_MEMBER_TARGET, " kick <[member_id|all|last]>"},
+	{"mute", (void_fn_t) & conf_api_sub_mute, CONF_API_SUB_MEMBER_TARGET, " mute <[member_id|all]|last>"},
+	{"unmute", (void_fn_t) & conf_api_sub_unmute, CONF_API_SUB_MEMBER_TARGET,
+	 " unmute <[member_id|all]|last>"},
+	{"deaf", (void_fn_t) & conf_api_sub_deaf, CONF_API_SUB_MEMBER_TARGET, " deaf <[member_id|all]|last>"},
+	{"undeaf", (void_fn_t) & conf_api_sub_undeaf, CONF_API_SUB_MEMBER_TARGET,
+	 " undeaf <[member_id|all]|last>"},
+	{"relate", (void_fn_t) & conf_api_sub_relate, CONF_API_SUB_ARGS_SPLIT,
+	 " relate   [nospeak|nohear|clear]"},
+	{"lock", (void_fn_t) & conf_api_sub_lock, CONF_API_SUB_ARGS_SPLIT, " lock"},
+	{"unlock", (void_fn_t) & conf_api_sub_unlock, CONF_API_SUB_ARGS_SPLIT, " unlock"},
+	{"dial", (void_fn_t) & conf_api_sub_dial, CONF_API_SUB_ARGS_SPLIT,
+	 " dial /  "},
+	{"bgdial", (void_fn_t) & conf_api_sub_bgdial, CONF_API_SUB_ARGS_SPLIT,
+	 " bgdial /  "},
+	{"transfer", (void_fn_t) & conf_api_sub_transfer, CONF_API_SUB_ARGS_SPLIT,
+	 " transfer   [...]"},
+	{"record", (void_fn_t) & conf_api_sub_record, CONF_API_SUB_ARGS_SPLIT, " record "},
+	{"norecord", (void_fn_t) & conf_api_sub_norecord, CONF_API_SUB_ARGS_SPLIT, " norecord <[filename|all]>"},
 };
 
 #define CONFFUNCAPISIZE (sizeof(conf_api_sub_commands)/sizeof(conf_api_sub_commands[0]))
 
-switch_status_t conf_api_dispatch(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char **argv, const char *cmdline, int argn)
-{	
-    switch_status_t status = SWITCH_STATUS_FALSE;
-    uint32_t i, found = 0;
-    assert(conference != NULL);
-    assert(stream != NULL);
+switch_status_t conf_api_dispatch(conference_obj_t * conference, switch_stream_handle_t *stream, int argc, char **argv,
+								  const char *cmdline, int argn)
+{
+	switch_status_t status = SWITCH_STATUS_FALSE;
+	uint32_t i, found = 0;
+	assert(conference != NULL);
+	assert(stream != NULL);
 
-    /* loop through the command table to find a match */
-    for (i = 0; iwrite_function(stream, conf_api_sub_commands[i].psyntax);
-                    }
-                }
-                break;
+					if (pfn(conference, stream, argc, argv) != SWITCH_STATUS_SUCCESS) {
+						/* command returned error, so show syntax usage */
+						stream->write_function(stream, conf_api_sub_commands[i].psyntax);
+					}
+				}
+				break;
 
-                /* member specific command that can be itteratted */
-            case CONF_API_SUB_MEMBER_TARGET:
-                {
-                    uint32_t id = 0;
-                    uint8_t all = 0;
-                    uint8_t last = 0;
+				/* member specific command that can be itteratted */
+			case CONF_API_SUB_MEMBER_TARGET:
+				{
+					uint32_t id = 0;
+					uint8_t all = 0;
+					uint8_t last = 0;
 
-                    if (argv[argn+1]) {
-                        if (!(id = atoi(argv[argn+1]))) {
-                            all = strcasecmp(argv[argn+1], "all") ? 0 : 1;
-                            last = strcasecmp(argv[argn+1], "last") ? 0 : 1;
-                        }                        
-                    }
+					if (argv[argn + 1]) {
+						if (!(id = atoi(argv[argn + 1]))) {
+							all = strcasecmp(argv[argn + 1], "all") ? 0 : 1;
+							last = strcasecmp(argv[argn + 1], "last") ? 0 : 1;
+						}
+					}
 
-                    if (all) {
-                        conference_member_itterator(conference, stream, (conf_api_member_cmd_t)conf_api_sub_commands[i].pfnapicmd, argv[argn+2]);
-                    } else if (last) {
-                        conference_member_t *member = NULL;
-                        conference_member_t *last_member = NULL;
+					if (all) {
+						conference_member_itterator(conference, stream,
+													(conf_api_member_cmd_t) conf_api_sub_commands[i].pfnapicmd,
+													argv[argn + 2]);
+					} else if (last) {
+						conference_member_t *member = NULL;
+						conference_member_t *last_member = NULL;
 
-                        switch_mutex_lock(conference->member_mutex);
+						switch_mutex_lock(conference->member_mutex);
 
-                        /* find last (oldest) member */
-                        member = conference->members;
-                        while (member != NULL) {
-                            if (last_member == NULL || member->id > last_member->id) {
-                                last_member = member;
-                            }
-                            member = member->next;
-                        }
+						/* find last (oldest) member */
+						member = conference->members;
+						while (member != NULL) {
+							if (last_member == NULL || member->id > last_member->id) {
+								last_member = member;
+							}
+							member = member->next;
+						}
 
-                        /* exec functio on last (oldest) member */
-                        if (last_member != NULL) {
-                            conf_api_member_cmd_t pfn = (conf_api_member_cmd_t)conf_api_sub_commands[i].pfnapicmd;
-                            pfn(last_member, stream, argv[argn+2]);
-                        }
+						/* exec functio on last (oldest) member */
+						if (last_member != NULL) {
+							conf_api_member_cmd_t pfn = (conf_api_member_cmd_t) conf_api_sub_commands[i].pfnapicmd;
+							pfn(last_member, stream, argv[argn + 2]);
+						}
 
-                        switch_mutex_unlock(conference->member_mutex);
-                    } else if (id) {
-                        conf_api_member_cmd_t pfn = (conf_api_member_cmd_t)conf_api_sub_commands[i].pfnapicmd;
-                        conference_member_t *member = conference_member_get(conference, id);
-                        
-                        if (member != NULL) {
-                            pfn(conference_member_get(conference, id), stream, argv[argn+2]);
-                        } else {
-                            stream->write_function(stream, "Non-Existant ID %u\n", id);
-                        }
-                    } else {
-                        stream->write_function(stream, conf_api_sub_commands[i].psyntax);
-                    }
-                }
-                break;
+						switch_mutex_unlock(conference->member_mutex);
+					} else if (id) {
+						conf_api_member_cmd_t pfn = (conf_api_member_cmd_t) conf_api_sub_commands[i].pfnapicmd;
+						conference_member_t *member = conference_member_get(conference, id);
 
-                /* commands that deals with all text after command */
-            case CONF_API_SUB_ARGS_AS_ONE:
-                {	
-                    conf_api_text_cmd_t pfn = (conf_api_text_cmd_t) conf_api_sub_commands[i].pfnapicmd;
-                    char *start_text;
-                    const char *modified_cmdline = cmdline;
-                    const char *cmd = conf_api_sub_commands[i].pname;
+						if (member != NULL) {
+							pfn(conference_member_get(conference, id), stream, argv[argn + 2]);
+						} else {
+							stream->write_function(stream, "Non-Existant ID %u\n", id);
+						}
+					} else {
+						stream->write_function(stream, conf_api_sub_commands[i].psyntax);
+					}
+				}
+				break;
 
-                    if ((start_text = strstr(modified_cmdline, cmd))) {
-                        modified_cmdline = start_text + strlen(cmd);
-                        while(modified_cmdline && *modified_cmdline && (*modified_cmdline  == ' ' || *modified_cmdline == '\t')) {
-                            modified_cmdline++;
-                        }
-                    }
-                            
-                    /* call the command handler */
-                    if (pfn(conference, stream, modified_cmdline) != SWITCH_STATUS_SUCCESS) {
-                        /* command returned error, so show syntax usage */
-                        stream->write_function(stream, conf_api_sub_commands[i].psyntax);
-                    }
-                }
-                break;
-            }
-        }
-    }
+				/* commands that deals with all text after command */
+			case CONF_API_SUB_ARGS_AS_ONE:
+				{
+					conf_api_text_cmd_t pfn = (conf_api_text_cmd_t) conf_api_sub_commands[i].pfnapicmd;
+					char *start_text;
+					const char *modified_cmdline = cmdline;
+					const char *cmd = conf_api_sub_commands[i].pname;
 
-    if (!found) {
-        stream->write_function(stream, "Confernece command '%s' not found.\n", argv[argn]);
-    } else {
-        status = SWITCH_STATUS_SUCCESS;
-    }
+					if ((start_text = strstr(modified_cmdline, cmd))) {
+						modified_cmdline = start_text + strlen(cmd);
+						while (modified_cmdline && *modified_cmdline
+							   && (*modified_cmdline == ' ' || *modified_cmdline == '\t')) {
+							modified_cmdline++;
+						}
+					}
 
-    return status;
+					/* call the command handler */
+					if (pfn(conference, stream, modified_cmdline) != SWITCH_STATUS_SUCCESS) {
+						/* command returned error, so show syntax usage */
+						stream->write_function(stream, conf_api_sub_commands[i].psyntax);
+					}
+				}
+				break;
+			}
+		}
+	}
+
+	if (!found) {
+		stream->write_function(stream, "Confernece command '%s' not found.\n", argv[argn]);
+	} else {
+		status = SWITCH_STATUS_SUCCESS;
+	}
+
+	return status;
 }
 
 /* API Interface Function */
 static switch_status_t conf_api_main(char *buf, switch_core_session_t *session, switch_stream_handle_t *stream)
 {
-    char *lbuf = NULL;
-    switch_status_t status = SWITCH_STATUS_SUCCESS;
-    char *http = NULL;
-    int argc;
-    char *argv[25] = {0};
+	char *lbuf = NULL;
+	switch_status_t status = SWITCH_STATUS_SUCCESS;
+	char *http = NULL;
+	int argc;
+	char *argv[25] = { 0 };
 
-    if (!buf) {
-        buf = "help";
-    }
+	if (!buf) {
+		buf = "help";
+	}
 
-    if (session) {
-        return SWITCH_STATUS_FALSE;
-    }
+	if (session) {
+		return SWITCH_STATUS_FALSE;
+	}
 
-    if (stream->event) {
-        http = switch_event_get_header(stream->event, "http-host");
-    }
+	if (stream->event) {
+		http = switch_event_get_header(stream->event, "http-host");
+	}
 
-    if (http) {
-        /* Output must be to a web browser */
-        stream->write_function(stream, "
\n");
-    }
+	if (http) {
+		/* Output must be to a web browser */
+		stream->write_function(stream, "
\n");
+	}
 
-    if (!(lbuf = strdup(buf))) {
-        return status;
-    }
+	if (!(lbuf = strdup(buf))) {
+		return status;
+	}
 
-    argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
+	argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
 
-    /* try to find a command to execute */
-    if (argc) {
-        conference_obj_t *conference = NULL;
+	/* try to find a command to execute */
+	if (argc) {
+		conference_obj_t *conference = NULL;
 
-        if ((conference = (conference_obj_t *) switch_core_hash_find(globals.conference_hash, argv[0]))) {
-            if (switch_thread_rwlock_tryrdlock(conference->rwlock) != SWITCH_STATUS_SUCCESS) {
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Read Lock Fail\n");
-                goto done;
-            }
-            if (argc >= 2) {
-                conf_api_dispatch(conference, stream, argc, argv, (const char *)buf, 1);
-            } else {
-                stream->write_function(stream, "Conference command, not specified.\nTry 'help'\n");
-            }
-            switch_thread_rwlock_unlock(conference->rwlock);
+		if ((conference = (conference_obj_t *) switch_core_hash_find(globals.conference_hash, argv[0]))) {
+			if (switch_thread_rwlock_tryrdlock(conference->rwlock) != SWITCH_STATUS_SUCCESS) {
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Read Lock Fail\n");
+				goto done;
+			}
+			if (argc >= 2) {
+				conf_api_dispatch(conference, stream, argc, argv, (const char *) buf, 1);
+			} else {
+				stream->write_function(stream, "Conference command, not specified.\nTry 'help'\n");
+			}
+			switch_thread_rwlock_unlock(conference->rwlock);
 
-        } else {
-            /* special case the list command, because it doesn't require a conference argument */
-            if (strcasecmp(argv[0], "list") == 0) {
-                conf_api_sub_list(NULL, stream, argc, argv);
-            } else if (strcasecmp(argv[0], "help") == 0 || strcasecmp(argv[0], "commands") == 0) {
-                stream->write_function(stream, "%s\n", conf_api_interface.syntax);
+		} else {
+			/* special case the list command, because it doesn't require a conference argument */
+			if (strcasecmp(argv[0], "list") == 0) {
+				conf_api_sub_list(NULL, stream, argc, argv);
+			} else if (strcasecmp(argv[0], "help") == 0 || strcasecmp(argv[0], "commands") == 0) {
+				stream->write_function(stream, "%s\n", conf_api_interface.syntax);
 			} else if (argv[1] && strcasecmp(argv[1], "dial") == 0) {
 				if (conf_api_sub_dial(NULL, stream, argc, argv) != SWITCH_STATUS_SUCCESS) {
 					/* command returned error, so show syntax usage */
@@ -3489,68 +3511,65 @@ static switch_status_t conf_api_main(char *buf, switch_core_session_t *session,
 					/* command returned error, so show syntax usage */
 					stream->write_function(stream, conf_api_sub_commands[CONF_API_COMMAND_BGDIAL].psyntax);
 				}
-            } else {
-                stream->write_function(stream, "Conference %s not found\n", argv[0]);
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Conference %s not found\n", argv[0]);
-            }
-        }
+			} else {
+				stream->write_function(stream, "Conference %s not found\n", argv[0]);
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Conference %s not found\n", argv[0]);
+			}
+		}
 
-    } else {
-        stream->write_function(stream, "No parameters specified.\nTry 'help conference'\n");
-    }
+	} else {
+		stream->write_function(stream, "No parameters specified.\nTry 'help conference'\n");
+	}
 
- done:
-    switch_safe_free(lbuf);
+  done:
+	switch_safe_free(lbuf);
 
-    return status;
+	return status;
 
 }
 
 /* outbound call bridge progress call state callback handler */
 static switch_status_t audio_bridge_on_ring(switch_core_session_t *session)
 {
-    switch_channel_t *channel = NULL;
+	switch_channel_t *channel = NULL;
 
-    channel = switch_core_session_get_channel(session);
-    assert(channel != NULL);
+	channel = switch_core_session_get_channel(session);
+	assert(channel != NULL);
 
-    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CUSTOM RING\n");
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CUSTOM RING\n");
 
-    /* put the channel in a passive state so we can loop audio to it */
-    switch_channel_set_state(channel, CS_TRANSMIT);
-    return SWITCH_STATUS_FALSE;
+	/* put the channel in a passive state so we can loop audio to it */
+	switch_channel_set_state(channel, CS_TRANSMIT);
+	return SWITCH_STATUS_FALSE;
 }
 
 static const switch_state_handler_table_t audio_bridge_peer_state_handlers = {
-    /*.on_init */ NULL, 
-    /*.on_ring */ audio_bridge_on_ring, 
-    /*.on_execute */ NULL, 
-    /*.on_hangup */ NULL, 
-    /*.on_loopback */ NULL, 
-    /*.on_transmit */ NULL, 
-    /*.on_hold */ NULL, 
+	/*.on_init */ NULL,
+	/*.on_ring */ audio_bridge_on_ring,
+	/*.on_execute */ NULL,
+	/*.on_hangup */ NULL,
+	/*.on_loopback */ NULL,
+	/*.on_transmit */ NULL,
+	/*.on_hold */ NULL,
 };
 
 
 /* generate an outbound call from the conference */
-static switch_status_t conference_outcall(conference_obj_t *conference, 
-										  char *conference_name,										  
-                                          switch_core_session_t *session, 
-                                          char *bridgeto, 
-                                          uint32_t timeout, 
-                                          char *flags, 
-                                          char *cid_name, 
-                                          char *cid_num,
-                                          switch_call_cause_t *cause)
+static switch_status_t conference_outcall(conference_obj_t * conference,
+										  char *conference_name,
+										  switch_core_session_t *session,
+										  char *bridgeto,
+										  uint32_t timeout,
+										  char *flags, char *cid_name, char *cid_num, switch_call_cause_t *cause)
 {
-    switch_core_session_t *peer_session;
-    switch_channel_t *peer_channel;
-    switch_status_t status = SWITCH_STATUS_SUCCESS;
-    switch_channel_t *caller_channel = NULL;
-    char appdata[512];
+	switch_core_session_t *peer_session;
+	switch_channel_t *peer_channel;
+	switch_status_t status = SWITCH_STATUS_SUCCESS;
+	switch_channel_t *caller_channel = NULL;
+	char appdata[512];
 
 
-    *cause = SWITCH_CAUSE_NORMAL_CLEARING;
+	*cause = SWITCH_CAUSE_NORMAL_CLEARING;
 
 
 	if (conference == NULL) {
@@ -3565,227 +3584,223 @@ static switch_status_t conference_outcall(conference_obj_t *conference,
 
 		peer_channel = switch_core_session_get_channel(peer_session);
 		assert(peer_channel != NULL);
-		
+
 		goto callup;
 	}
 
 
 	conference_name = conference->name;
 
-    if (switch_thread_rwlock_tryrdlock(conference->rwlock) != SWITCH_STATUS_SUCCESS) {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Read Lock Fail\n");
-        return SWITCH_STATUS_FALSE;
-    }
+	if (switch_thread_rwlock_tryrdlock(conference->rwlock) != SWITCH_STATUS_SUCCESS) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Read Lock Fail\n");
+		return SWITCH_STATUS_FALSE;
+	}
 
-    if (session != NULL) {
-        caller_channel = switch_core_session_get_channel(session);
-	
-    }
+	if (session != NULL) {
+		caller_channel = switch_core_session_get_channel(session);
 
-    if (switch_strlen_zero(cid_name)) {
-        cid_name = conference->caller_id_name;
-    }
+	}
 
-    if (switch_strlen_zero(cid_num)) {
-        cid_num = conference->caller_id_number;
-    }
+	if (switch_strlen_zero(cid_name)) {
+		cid_name = conference->caller_id_name;
+	}
 
-    /* establish an outbound call leg */
-    if (switch_ivr_originate(session, 
-                             &peer_session, 
-                             cause, 
-                             bridgeto, 
-                             timeout, 
-                             &audio_bridge_peer_state_handlers, 
-                             cid_name, 
-                             cid_num, 
-                             NULL) != SWITCH_STATUS_SUCCESS) {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot create outgoing channel, cause: %s\n", 
-                          switch_channel_cause2str(*cause));
-        if (caller_channel) {
-            switch_channel_hangup(caller_channel, *cause);
-        }
-        goto done;
-    } 
+	if (switch_strlen_zero(cid_num)) {
+		cid_num = conference->caller_id_number;
+	}
+
+	/* establish an outbound call leg */
+	if (switch_ivr_originate(session,
+							 &peer_session,
+							 cause,
+							 bridgeto,
+							 timeout,
+							 &audio_bridge_peer_state_handlers, cid_name, cid_num, NULL) != SWITCH_STATUS_SUCCESS) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot create outgoing channel, cause: %s\n",
+						  switch_channel_cause2str(*cause));
+		if (caller_channel) {
+			switch_channel_hangup(caller_channel, *cause);
+		}
+		goto done;
+	}
 
 
-    peer_channel = switch_core_session_get_channel(peer_session);
-    assert(peer_channel != NULL);
+	peer_channel = switch_core_session_get_channel(peer_session);
+	assert(peer_channel != NULL);
 
-    /* make sure the conference still exists */
-    if (!switch_test_flag(conference, CFLAG_RUNNING)) {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Conference is gone now, nevermind..\n");
-        if (caller_channel) {
-            switch_channel_hangup(caller_channel, SWITCH_CAUSE_NO_ROUTE_DESTINATION);
-        }
-        switch_channel_hangup(peer_channel, SWITCH_CAUSE_NO_ROUTE_DESTINATION);
-        goto done;
-    }
+	/* make sure the conference still exists */
+	if (!switch_test_flag(conference, CFLAG_RUNNING)) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Conference is gone now, nevermind..\n");
+		if (caller_channel) {
+			switch_channel_hangup(caller_channel, SWITCH_CAUSE_NO_ROUTE_DESTINATION);
+		}
+		switch_channel_hangup(peer_channel, SWITCH_CAUSE_NO_ROUTE_DESTINATION);
+		goto done;
+	}
 
-    if (caller_channel && switch_channel_test_flag(peer_channel, CF_ANSWERED)) {
-        switch_channel_answer(caller_channel);
-    }
+	if (caller_channel && switch_channel_test_flag(peer_channel, CF_ANSWERED)) {
+		switch_channel_answer(caller_channel);
+	}
 
- callup:
+  callup:
 
-    /* if the outbound call leg is ready */
-    if (switch_channel_test_flag(peer_channel, CF_ANSWERED) || switch_channel_test_flag(peer_channel, CF_EARLY_MEDIA)) {
-        switch_caller_extension_t *extension = NULL;
+	/* if the outbound call leg is ready */
+	if (switch_channel_test_flag(peer_channel, CF_ANSWERED) || switch_channel_test_flag(peer_channel, CF_EARLY_MEDIA)) {
+		switch_caller_extension_t *extension = NULL;
 
-        /* build an extension name object */
-        if ((extension = switch_caller_extension_new(peer_session, conference_name, conference_name)) == 0) {
-            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "memory error!\n");
-            status = SWITCH_STATUS_MEMERR;
-            goto done;
-        }
-        /* add them to the conference */
-        if (flags && strcasecmp(flags, "none")) {
-            snprintf(appdata, sizeof(appdata), "%s +flags{%s}", conference_name, flags);
-            switch_caller_extension_add_application(peer_session, extension, (char *) global_app_name, appdata);
-        } else {
-            switch_caller_extension_add_application(peer_session, extension, (char *) global_app_name, conference_name);
-        }
+		/* build an extension name object */
+		if ((extension = switch_caller_extension_new(peer_session, conference_name, conference_name)) == 0) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "memory error!\n");
+			status = SWITCH_STATUS_MEMERR;
+			goto done;
+		}
+		/* add them to the conference */
+		if (flags && strcasecmp(flags, "none")) {
+			snprintf(appdata, sizeof(appdata), "%s +flags{%s}", conference_name, flags);
+			switch_caller_extension_add_application(peer_session, extension, (char *) global_app_name, appdata);
+		} else {
+			switch_caller_extension_add_application(peer_session, extension, (char *) global_app_name, conference_name);
+		}
 
-        switch_channel_set_caller_extension(peer_channel, extension);
-        switch_channel_set_state(peer_channel, CS_EXECUTE);
+		switch_channel_set_caller_extension(peer_channel, extension);
+		switch_channel_set_state(peer_channel, CS_EXECUTE);
 
-    } else {
-        switch_channel_hangup(peer_channel, SWITCH_CAUSE_NO_ANSWER);
-        status = SWITCH_STATUS_FALSE;
-        goto done;
-    }
+	} else {
+		switch_channel_hangup(peer_channel, SWITCH_CAUSE_NO_ANSWER);
+		status = SWITCH_STATUS_FALSE;
+		goto done;
+	}
 
- done:
+  done:
 	if (conference) {
 		switch_thread_rwlock_unlock(conference->rwlock);
 	}
-    return status;
+	return status;
 }
 
 struct bg_call {
-    conference_obj_t *conference;
-    switch_core_session_t *session;
-    char *bridgeto;
-    uint32_t timeout;
-    char *flags;
-    char *cid_name;
-    char *cid_num;
+	conference_obj_t *conference;
+	switch_core_session_t *session;
+	char *bridgeto;
+	uint32_t timeout;
+	char *flags;
+	char *cid_name;
+	char *cid_num;
 	char *conference_name;
 };
 
 static void *SWITCH_THREAD_FUNC conference_outcall_run(switch_thread_t *thread, void *obj)
 {
-    struct bg_call *call = (struct bg_call *) obj;
-    
-    if (call) {
-        switch_call_cause_t cause;
-        switch_event_t *event;
+	struct bg_call *call = (struct bg_call *) obj;
 
-        conference_outcall(call->conference, NULL, call->session, call->bridgeto, call->timeout, call->flags, call->cid_name, call->cid_num, &cause);
+	if (call) {
+		switch_call_cause_t cause;
+		switch_event_t *event;
 
-        if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", call->conference->name);
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "bgdial-result");
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Result", "%s", switch_channel_cause2str(cause));
-            switch_event_fire(&event);
-        }
-        switch_safe_free(call->bridgeto);
-        switch_safe_free(call->flags);
-        switch_safe_free(call->cid_name);
-        switch_safe_free(call->cid_num);
-        switch_safe_free(call->conference_name);
-        switch_safe_free(call);
-    }
+		conference_outcall(call->conference, NULL, call->session, call->bridgeto, call->timeout, call->flags,
+						   call->cid_name, call->cid_num, &cause);
 
-    return NULL;
+		if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", call->conference->name);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "bgdial-result");
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Result", "%s", switch_channel_cause2str(cause));
+			switch_event_fire(&event);
+		}
+		switch_safe_free(call->bridgeto);
+		switch_safe_free(call->flags);
+		switch_safe_free(call->cid_name);
+		switch_safe_free(call->cid_num);
+		switch_safe_free(call->conference_name);
+		switch_safe_free(call);
+	}
+
+	return NULL;
 }
 
-static switch_status_t conference_outcall_bg(conference_obj_t *conference, 
+static switch_status_t conference_outcall_bg(conference_obj_t * conference,
 											 char *conference_name,
-                                             switch_core_session_t *session, 
-                                             char *bridgeto, 
-                                             uint32_t timeout, 
-                                             char *flags, 
-                                             char *cid_name, 
-                                             char *cid_num)
+											 switch_core_session_t *session,
+											 char *bridgeto,
+											 uint32_t timeout, char *flags, char *cid_name, char *cid_num)
 {
-    struct bg_call *call = NULL;
-    
-    if ((call = malloc(sizeof(*call)))) {
-        switch_thread_t *thread;
-        switch_threadattr_t *thd_attr = NULL;
+	struct bg_call *call = NULL;
 
-        memset(call, 0, sizeof(*call));
-        call->conference = conference;
-        call->session = session;
-        call->timeout = timeout;
+	if ((call = malloc(sizeof(*call)))) {
+		switch_thread_t *thread;
+		switch_threadattr_t *thd_attr = NULL;
+
+		memset(call, 0, sizeof(*call));
+		call->conference = conference;
+		call->session = session;
+		call->timeout = timeout;
+
+		if (bridgeto) {
+			call->bridgeto = strdup(bridgeto);
+		}
+		if (flags) {
+			call->flags = strdup(flags);
+		}
+		if (cid_name) {
+			call->cid_name = strdup(cid_name);
+		}
+		if (cid_num) {
+			call->cid_num = strdup(cid_num);
+		}
 
-        if (bridgeto) {
-            call->bridgeto = strdup(bridgeto);
-        }
-        if (flags) {
-            call->flags = strdup(flags);
-        }
-        if (cid_name) {
-            call->cid_name = strdup(cid_name);
-        }
-        if (cid_num) {
-            call->cid_num = strdup(cid_num);
-        }
-		
 		if (conference_name) {
 			call->conference_name = strdup(conference_name);
 		}
 
-        
-        switch_threadattr_create(&thd_attr, conference->pool);
-        switch_threadattr_detach_set(thd_attr, 1);
-        switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
-        switch_thread_create(&thread, thd_attr, conference_outcall_run, call, conference->pool);
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Lanuching BG Thread for outcall\n");
+
+		switch_threadattr_create(&thd_attr, conference->pool);
+		switch_threadattr_detach_set(thd_attr, 1);
+		switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
+		switch_thread_create(&thread, thd_attr, conference_outcall_run, call, conference->pool);
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Lanuching BG Thread for outcall\n");
 
 		return SWITCH_STATUS_SUCCESS;
-    }
+	}
 
 	return SWITCH_STATUS_MEMERR;
 }
 
 /* Play a file */
-static switch_status_t conference_local_play_file(conference_obj_t *conference, 
-                                                  switch_core_session_t *session, char *path, uint32_t leadin, char *buf, switch_size_t len)
+static switch_status_t conference_local_play_file(conference_obj_t * conference,
+												  switch_core_session_t *session, char *path, uint32_t leadin,
+												  char *buf, switch_size_t len)
 {
-    uint32_t x = 0;
-    switch_status_t status = SWITCH_STATUS_SUCCESS;
+	uint32_t x = 0;
+	switch_status_t status = SWITCH_STATUS_SUCCESS;
 
-    /* generate some space infront of the file to be played */
-    for (x = 0; x < leadin; x++) {
-        switch_frame_t *read_frame;
-        switch_status_t status = switch_core_session_read_frame(session, &read_frame, 1000, 0);
+	/* generate some space infront of the file to be played */
+	for (x = 0; x < leadin; x++) {
+		switch_frame_t *read_frame;
+		switch_status_t status = switch_core_session_read_frame(session, &read_frame, 1000, 0);
 
-        if (!SWITCH_READ_ACCEPTABLE(status)) {
-            break;
-        }
-    }
+		if (!SWITCH_READ_ACCEPTABLE(status)) {
+			break;
+		}
+	}
 
-    /* if all is well, really play the file */
-    if (status == SWITCH_STATUS_SUCCESS) {
-        char *dpath = NULL;
+	/* if all is well, really play the file */
+	if (status == SWITCH_STATUS_SUCCESS) {
+		char *dpath = NULL;
 
-        if (conference->sound_prefix) {
-            if (!(dpath = switch_mprintf("%s/%s", conference->sound_prefix, path))) {
-                return SWITCH_STATUS_MEMERR;
-            }
-            path = dpath;
-        }
+		if (conference->sound_prefix) {
+			if (!(dpath = switch_mprintf("%s/%s", conference->sound_prefix, path))) {
+				return SWITCH_STATUS_MEMERR;
+			}
+			path = dpath;
+		}
 
-        status = switch_ivr_play_file(session, NULL, path, NULL);
-        switch_safe_free(dpath);
-    }
+		status = switch_ivr_play_file(session, NULL, path, NULL);
+		switch_safe_free(dpath);
+	}
 
-    return status;
+	return status;
 }
 
-static void set_mflags(char *flags, member_flag_t *f)
+static void set_mflags(char *flags, member_flag_t * f)
 {
 	if (flags) {
 		if (strstr(flags, "mute")) {
@@ -3803,392 +3818,396 @@ static void set_mflags(char *flags, member_flag_t *f)
 /* Application interface function that is called from the dialplan to join the channel to a conference */
 static void conference_function(switch_core_session_t *session, char *data)
 {
-    switch_codec_t *read_codec = NULL;
-    uint32_t flags = 0;
-    conference_member_t member = {0};
-    conference_obj_t *conference = NULL;
-    switch_channel_t *channel = NULL;
-    char *mydata = switch_core_session_strdup(session, data);
-    char *conf_name = NULL;
-    char *bridge_prefix = "bridge:";
-    char *flags_prefix = "+flags{";
-    char *bridgeto = NULL;
-    char *profile_name = NULL;
-    switch_xml_t cxml = NULL, cfg = NULL, profiles = NULL;
-    char *flags_str;
-    member_flag_t mflags = 0;
-    switch_core_session_message_t msg = {0};
-    uint8_t rl = 0, isbr = 0;
-    char *dpin = NULL;
-    conf_xml_cfg_t xml_cfg = {0};
-    char *params = NULL;
+	switch_codec_t *read_codec = NULL;
+	uint32_t flags = 0;
+	conference_member_t member = { 0 };
+	conference_obj_t *conference = NULL;
+	switch_channel_t *channel = NULL;
+	char *mydata = switch_core_session_strdup(session, data);
+	char *conf_name = NULL;
+	char *bridge_prefix = "bridge:";
+	char *flags_prefix = "+flags{";
+	char *bridgeto = NULL;
+	char *profile_name = NULL;
+	switch_xml_t cxml = NULL, cfg = NULL, profiles = NULL;
+	char *flags_str;
+	member_flag_t mflags = 0;
+	switch_core_session_message_t msg = { 0 };
+	uint8_t rl = 0, isbr = 0;
+	char *dpin = NULL;
+	conf_xml_cfg_t xml_cfg = { 0 };
+	char *params = NULL;
 
-    channel = switch_core_session_get_channel(session);
-    assert(channel != NULL);
+	channel = switch_core_session_get_channel(session);
+	assert(channel != NULL);
 
-    if (!mydata) {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Pool Failure\n");
-        return;
-    }
+	if (!mydata) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Pool Failure\n");
+		return;
+	}
 
 
-    /* is this a bridging conference ? */
-    if (!strncasecmp(mydata, bridge_prefix, strlen(bridge_prefix))) {
-        isbr = 1;
-        mydata += strlen(bridge_prefix);
-        if ((bridgeto = strchr(mydata, ':'))) {
-            *bridgeto++ = '\0';
-        } else {
-            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Config Error!\n");
-            goto done;
-        }
-    }
+	/* is this a bridging conference ? */
+	if (!strncasecmp(mydata, bridge_prefix, strlen(bridge_prefix))) {
+		isbr = 1;
+		mydata += strlen(bridge_prefix);
+		if ((bridgeto = strchr(mydata, ':'))) {
+			*bridgeto++ = '\0';
+		} else {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Config Error!\n");
+			goto done;
+		}
+	}
 
-    conf_name = mydata;
+	conf_name = mydata;
 
-    /* is there a conference pin ? */
-    if ((dpin = strchr(conf_name, '+'))) {
-        *dpin++ = '\0';
-    }
+	/* is there a conference pin ? */
+	if ((dpin = strchr(conf_name, '+'))) {
+		*dpin++ = '\0';
+	}
 
-    /* is there profile specification ? */
-    if ((profile_name = strchr(conf_name, '@'))) {
-        *profile_name++ = '\0';
-    } else {
-        profile_name = "default";
-    }
+	/* is there profile specification ? */
+	if ((profile_name = strchr(conf_name, '@'))) {
+		*profile_name++ = '\0';
+	} else {
+		profile_name = "default";
+	}
 
-    params = switch_mprintf("conf_name=%s&profile_name=%s", conf_name, profile_name);
+	params = switch_mprintf("conf_name=%s&profile_name=%s", conf_name, profile_name);
 
-    /* Open the config from the xml registry */
-    if (!(cxml = switch_xml_open_cfg(global_cf_name, &cfg, params))) {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", global_cf_name);
-        goto done;
-    }
+	/* Open the config from the xml registry */
+	if (!(cxml = switch_xml_open_cfg(global_cf_name, &cfg, params))) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", global_cf_name);
+		goto done;
+	}
 
-    if ((profiles = switch_xml_child(cfg, "profiles"))) {
-        xml_cfg.profile = switch_xml_find_child(profiles, "profile", "name", profile_name);
-    }
+	if ((profiles = switch_xml_child(cfg, "profiles"))) {
+		xml_cfg.profile = switch_xml_find_child(profiles, "profile", "name", profile_name);
+	}
 
-    if (!xml_cfg.profile) {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot find profile: %s\n", profile_name);
-        switch_xml_free(cxml);
-        cxml = NULL;
-        goto done;
-    }
+	if (!xml_cfg.profile) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot find profile: %s\n", profile_name);
+		switch_xml_free(cxml);
+		cxml = NULL;
+		goto done;
+	}
 
-    xml_cfg.controls = switch_xml_child(cfg, "caller-controls");
+	xml_cfg.controls = switch_xml_child(cfg, "caller-controls");
 
-    /* if this is a bridging call, and it's not a duplicate, build a */
-    /* conference object, and skip pin handling, and locked checking */
-    if (isbr) {
-        char *uuid = switch_core_session_get_uuid(session);
+	/* if this is a bridging call, and it's not a duplicate, build a */
+	/* conference object, and skip pin handling, and locked checking */
+	if (isbr) {
+		char *uuid = switch_core_session_get_uuid(session);
 
-        if (!strcmp(conf_name, "_uuid_")) {
-            conf_name = uuid;
-        }
-
-        if ((conference = (conference_obj_t *) switch_core_hash_find(globals.conference_hash, conf_name))) {
-            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Conference %s already exists!\n", conf_name);
-            goto done;
-        }
-
-        /* Create the conference object. */
-        conference = conference_new(conf_name, xml_cfg, NULL);
-
-        if (!conference) {
-            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
-            goto done;
-        }
-
-        /* Set the minimum number of members (once you go above it you cannot go below it) */
-        conference->min = 2;
-
-        /* if the dialplan specified a pin, override the profile's value */
-        if (dpin) {
-            conference->pin = switch_core_strdup(conference->pool, dpin);
-        }
-
-        /* Indicate the conference is dynamic */
-        switch_set_flag_locked(conference, CFLAG_DYNAMIC);	
-
-        /* Start the conference thread for this conference */
-        launch_conference_thread(conference);
-
-    } else {
-        /* if the conference exists, get the pointer to it */
-        if (!(conference = (conference_obj_t *) switch_core_hash_find(globals.conference_hash, conf_name))) {
-            /* couldn't find the conference, create one */
-            conference = conference_new(conf_name, xml_cfg, NULL);
-
-            if (!conference) {
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
-                goto done;
-            }
-
-            /* if the dialplan specified a pin, override the profile's value */
-            if (dpin) {
-                conference->pin = switch_core_strdup(conference->pool, dpin);
-            }
-
-            /* Set the minimum number of members (once you go above it you cannot go below it) */
-            conference->min = 1;
-
-            /* Indicate the conference is dynamic */
-            switch_set_flag_locked(conference, CFLAG_DYNAMIC);
-
-            /* Start the conference thread for this conference */
-            launch_conference_thread(conference);
-        }
-
-        /* acquire a read lock on the thread so it can't leave without us */
-        if (switch_thread_rwlock_tryrdlock(conference->rwlock) != SWITCH_STATUS_SUCCESS) {
-            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Read Lock Fail\n");
-            goto done;
-        }
-        rl++;
-        
-        /* if this is not an outbound call, deal with conference pins */
-        if (!switch_channel_test_flag(channel, CF_OUTBOUND) && conference->pin) {
-            char pin_buf[80] = "";
-            int  pin_retries = 3;	/* XXX - this should be configurable - i'm too lazy to do it right now... */
-            int  pin_valid = 0;
-            switch_status_t status = SWITCH_STATUS_SUCCESS;
-
-            /* Answer the channel */
-            switch_channel_answer(channel);
-
-            while(!pin_valid && pin_retries && status == SWITCH_STATUS_SUCCESS) {
-
-                /* be friendly */
-                if (conference->pin_sound) {
-                    conference_local_play_file(conference, session, conference->pin_sound, 20, pin_buf, sizeof(pin_buf));
-                } 
-                /* wait for them if neccessary */
-                if (strlen(pin_buf) < strlen(conference->pin)) {
-                    char *buf = pin_buf + strlen(pin_buf);
-                    char term = '\0';
-
-                    status = switch_ivr_collect_digits_count(session, 
-                                                             buf, 
-                                                             sizeof(pin_buf) - (unsigned int)strlen(pin_buf), 
-                                                             (unsigned int)strlen(conference->pin) - (unsigned int)strlen(pin_buf), 
-                                                             "#", &term, 10000);
-                }
-
-                pin_valid = (status == SWITCH_STATUS_SUCCESS && strcmp(pin_buf, conference->pin) == 0);
-                if (!pin_valid) {
-                    /* zero the collected pin */
-                    memset(pin_buf, 0, sizeof(pin_buf));
-
-                    /* more friendliness */
-                    if (conference->bad_pin_sound) {
-                        conference_local_play_file(conference, session, conference->bad_pin_sound, 20, pin_buf, sizeof(pin_buf));
-                    }
-                }
-                pin_retries --;
-            }
-
-            if (!pin_valid) {
-                goto done;
-            }
-        }
-
-        /* don't allow more callers if the conference is locked, unless we invited them */
-        if (switch_test_flag(conference, CFLAG_LOCKED) && !switch_channel_test_flag(channel, CF_OUTBOUND)) {
-            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Conference %s is locked.\n", conf_name);
-            if (conference->locked_sound) {
-                /* Answer the channel */
-                switch_channel_answer(channel);
-                conference_local_play_file(conference, session, conference->locked_sound, 20, NULL, 0);
-            }
-            goto done;
-        }
-
-        /* dont allow more callers than the max_members allows for -- I explicitly didnt allow outbound calls
-         * someone else can add that (see above) if they feel that outbound calls should be able to violate the
-         * max_members limit -- TRX
-         */
-        if((conference->max_members > 0) && (conference->count >= conference->max_members)) {
-            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Conference %s is full.\n",conf_name);
-            if(conference->maxmember_sound) {
-                /* Answer the channel */
-                switch_channel_answer(channel);
-                conference_local_play_file(conference, session, conference->maxmember_sound, 20, NULL, 0);
-            }
-            goto done;
-        }
-
-    }
-
-    /* Release the config registry handle */
-    if (cxml) {
-        switch_xml_free(cxml);
-        cxml = NULL;
-    }
-
-    /* if we're using "bridge:" make an outbound call and bridge it in */
-    if (!switch_strlen_zero(bridgeto) && strcasecmp(bridgeto, "none")) {
-        switch_call_cause_t cause;
-        if (conference_outcall(conference, NULL, session, bridgeto, 60, NULL, NULL, NULL, &cause) != SWITCH_STATUS_SUCCESS) {
-            goto done;
-        }
-    } else {	
-        /* if we're not using "bridge:" set the conference answered flag */
-        /* and this isn't an outbound channel, answer the call */
-        if (!switch_channel_test_flag(channel, CF_OUTBOUND)) 
-            switch_set_flag(conference, CFLAG_ANSWERED);
-    }
-
-    /* Save the original read codec. */
-    read_codec = switch_core_session_get_read_codec(session);
-    member.native_rate = read_codec->implementation->samples_per_second;
-    member.pool = switch_core_session_get_pool(session);
-
-    /* Setup a Signed Linear codec for reading audio. */
-    if (switch_core_codec_init(&member.read_codec, 
-                               "L16", 
-                               NULL, 
-                               read_codec->implementation->samples_per_second, 
-                               read_codec->implementation->microseconds_per_frame / 1000, 
-                               1, 
-                               SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, 
-                               NULL, 
-                               member.pool) == SWITCH_STATUS_SUCCESS) {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Raw Codec Activation Success L16@%uhz 1 channel %dms\n", 
-                          read_codec->implementation->samples_per_second,
-						  read_codec->implementation->microseconds_per_frame / 1000);
-    } else {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Raw Codec Activation Failed L16@%uhz 1 channel %dms\n", 
-						  read_codec->implementation->samples_per_second,
-						  read_codec->implementation->microseconds_per_frame / 1000);
-        flags = 0;
-        goto done;
-    }
-
-    if (read_codec->implementation->samples_per_second != conference->rate) {
-        switch_audio_resampler_t **resampler = read_codec->implementation->samples_per_second > conference->rate ? 
-            &member.read_resampler : &member.mux_resampler;
-
-        if (switch_resample_create(resampler, 
-                               read_codec->implementation->samples_per_second, 
-                               read_codec->implementation->samples_per_second * 20, 
-                               conference->rate, 
-                               conference->rate * 20, 
-							   member.pool) != SWITCH_STATUS_SUCCESS){
-            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Unable to crete resampler!\n");
-            goto done;
+		if (!strcmp(conf_name, "_uuid_")) {
+			conf_name = uuid;
 		}
 
-        /* Setup an audio buffer for the resampled audio */
-        if (switch_buffer_create_dynamic(&member.resample_buffer, CONF_DBLOCK_SIZE, CONF_DBUFFER_SIZE, CONF_DBUFFER_MAX) != SWITCH_STATUS_SUCCESS) {
-            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error Creating Audio Buffer!\n");
-            goto done;
-        }
-    }
-    /* Setup a Signed Linear codec for writing audio. */
-    if (switch_core_codec_init(&member.write_codec, 
-                               "L16", 
-                               NULL, 
-                               read_codec->implementation->samples_per_second, 
-                               read_codec->implementation->microseconds_per_frame / 1000, 
-                               1, 
-                               SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, 
-                               NULL, 
-                               member.pool) == SWITCH_STATUS_SUCCESS) {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Raw Codec Activation Success L16@%uhz 1 channel %dms\n", 
+		if ((conference = (conference_obj_t *) switch_core_hash_find(globals.conference_hash, conf_name))) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Conference %s already exists!\n", conf_name);
+			goto done;
+		}
+
+		/* Create the conference object. */
+		conference = conference_new(conf_name, xml_cfg, NULL);
+
+		if (!conference) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
+			goto done;
+		}
+
+		/* Set the minimum number of members (once you go above it you cannot go below it) */
+		conference->min = 2;
+
+		/* if the dialplan specified a pin, override the profile's value */
+		if (dpin) {
+			conference->pin = switch_core_strdup(conference->pool, dpin);
+		}
+
+		/* Indicate the conference is dynamic */
+		switch_set_flag_locked(conference, CFLAG_DYNAMIC);
+
+		/* Start the conference thread for this conference */
+		launch_conference_thread(conference);
+
+	} else {
+		/* if the conference exists, get the pointer to it */
+		if (!(conference = (conference_obj_t *) switch_core_hash_find(globals.conference_hash, conf_name))) {
+			/* couldn't find the conference, create one */
+			conference = conference_new(conf_name, xml_cfg, NULL);
+
+			if (!conference) {
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
+				goto done;
+			}
+
+			/* if the dialplan specified a pin, override the profile's value */
+			if (dpin) {
+				conference->pin = switch_core_strdup(conference->pool, dpin);
+			}
+
+			/* Set the minimum number of members (once you go above it you cannot go below it) */
+			conference->min = 1;
+
+			/* Indicate the conference is dynamic */
+			switch_set_flag_locked(conference, CFLAG_DYNAMIC);
+
+			/* Start the conference thread for this conference */
+			launch_conference_thread(conference);
+		}
+
+		/* acquire a read lock on the thread so it can't leave without us */
+		if (switch_thread_rwlock_tryrdlock(conference->rwlock) != SWITCH_STATUS_SUCCESS) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Read Lock Fail\n");
+			goto done;
+		}
+		rl++;
+
+		/* if this is not an outbound call, deal with conference pins */
+		if (!switch_channel_test_flag(channel, CF_OUTBOUND) && conference->pin) {
+			char pin_buf[80] = "";
+			int pin_retries = 3;	/* XXX - this should be configurable - i'm too lazy to do it right now... */
+			int pin_valid = 0;
+			switch_status_t status = SWITCH_STATUS_SUCCESS;
+
+			/* Answer the channel */
+			switch_channel_answer(channel);
+
+			while (!pin_valid && pin_retries && status == SWITCH_STATUS_SUCCESS) {
+
+				/* be friendly */
+				if (conference->pin_sound) {
+					conference_local_play_file(conference, session, conference->pin_sound, 20, pin_buf,
+											   sizeof(pin_buf));
+				}
+				/* wait for them if neccessary */
+				if (strlen(pin_buf) < strlen(conference->pin)) {
+					char *buf = pin_buf + strlen(pin_buf);
+					char term = '\0';
+
+					status = switch_ivr_collect_digits_count(session,
+															 buf,
+															 sizeof(pin_buf) - (unsigned int) strlen(pin_buf),
+															 (unsigned int) strlen(conference->pin) -
+															 (unsigned int) strlen(pin_buf), "#", &term, 10000);
+				}
+
+				pin_valid = (status == SWITCH_STATUS_SUCCESS && strcmp(pin_buf, conference->pin) == 0);
+				if (!pin_valid) {
+					/* zero the collected pin */
+					memset(pin_buf, 0, sizeof(pin_buf));
+
+					/* more friendliness */
+					if (conference->bad_pin_sound) {
+						conference_local_play_file(conference, session, conference->bad_pin_sound, 20, pin_buf,
+												   sizeof(pin_buf));
+					}
+				}
+				pin_retries--;
+			}
+
+			if (!pin_valid) {
+				goto done;
+			}
+		}
+
+		/* don't allow more callers if the conference is locked, unless we invited them */
+		if (switch_test_flag(conference, CFLAG_LOCKED) && !switch_channel_test_flag(channel, CF_OUTBOUND)) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Conference %s is locked.\n", conf_name);
+			if (conference->locked_sound) {
+				/* Answer the channel */
+				switch_channel_answer(channel);
+				conference_local_play_file(conference, session, conference->locked_sound, 20, NULL, 0);
+			}
+			goto done;
+		}
+
+		/* dont allow more callers than the max_members allows for -- I explicitly didnt allow outbound calls
+		 * someone else can add that (see above) if they feel that outbound calls should be able to violate the
+		 * max_members limit -- TRX
+		 */
+		if ((conference->max_members > 0) && (conference->count >= conference->max_members)) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Conference %s is full.\n", conf_name);
+			if (conference->maxmember_sound) {
+				/* Answer the channel */
+				switch_channel_answer(channel);
+				conference_local_play_file(conference, session, conference->maxmember_sound, 20, NULL, 0);
+			}
+			goto done;
+		}
+
+	}
+
+	/* Release the config registry handle */
+	if (cxml) {
+		switch_xml_free(cxml);
+		cxml = NULL;
+	}
+
+	/* if we're using "bridge:" make an outbound call and bridge it in */
+	if (!switch_strlen_zero(bridgeto) && strcasecmp(bridgeto, "none")) {
+		switch_call_cause_t cause;
+		if (conference_outcall(conference, NULL, session, bridgeto, 60, NULL, NULL, NULL, &cause) !=
+			SWITCH_STATUS_SUCCESS) {
+			goto done;
+		}
+	} else {
+		/* if we're not using "bridge:" set the conference answered flag */
+		/* and this isn't an outbound channel, answer the call */
+		if (!switch_channel_test_flag(channel, CF_OUTBOUND))
+			switch_set_flag(conference, CFLAG_ANSWERED);
+	}
+
+	/* Save the original read codec. */
+	read_codec = switch_core_session_get_read_codec(session);
+	member.native_rate = read_codec->implementation->samples_per_second;
+	member.pool = switch_core_session_get_pool(session);
+
+	/* Setup a Signed Linear codec for reading audio. */
+	if (switch_core_codec_init(&member.read_codec,
+							   "L16",
+							   NULL,
+							   read_codec->implementation->samples_per_second,
+							   read_codec->implementation->microseconds_per_frame / 1000,
+							   1,
+							   SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
+							   NULL, member.pool) == SWITCH_STATUS_SUCCESS) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
+						  "Raw Codec Activation Success L16@%uhz 1 channel %dms\n",
 						  read_codec->implementation->samples_per_second,
 						  read_codec->implementation->microseconds_per_frame / 1000);
-    } else {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Raw Codec Activation Failed L16@%uhz 1 channel %dms\n", 
+	} else {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Raw Codec Activation Failed L16@%uhz 1 channel %dms\n",
 						  read_codec->implementation->samples_per_second,
 						  read_codec->implementation->microseconds_per_frame / 1000);
-        flags = 0;
-        goto codec_done2;
-    }
+		flags = 0;
+		goto done;
+	}
 
-    /* Setup an audio buffer for the incoming audio */
-    if (switch_buffer_create_dynamic(&member.audio_buffer, CONF_DBLOCK_SIZE, CONF_DBUFFER_SIZE, CONF_DBUFFER_MAX) != SWITCH_STATUS_SUCCESS) {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error Creating Audio Buffer!\n");
-        goto codec_done1;
-    }
+	if (read_codec->implementation->samples_per_second != conference->rate) {
+		switch_audio_resampler_t **resampler = read_codec->implementation->samples_per_second > conference->rate ?
+			&member.read_resampler : &member.mux_resampler;
 
-    /* Setup an audio buffer for the outgoing audio */
-    if (switch_buffer_create_dynamic(&member.mux_buffer, CONF_DBLOCK_SIZE, CONF_DBUFFER_SIZE, CONF_DBUFFER_MAX) != SWITCH_STATUS_SUCCESS) {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error Creating Audio Buffer!\n");
-        goto codec_done1;
-    }
+		if (switch_resample_create(resampler,
+								   read_codec->implementation->samples_per_second,
+								   read_codec->implementation->samples_per_second * 20,
+								   conference->rate, conference->rate * 20, member.pool) != SWITCH_STATUS_SUCCESS) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Unable to crete resampler!\n");
+			goto done;
+		}
 
-    /* Prepare MUTEXS */
-    member.id = next_member_id();
-    member.session = session;
-    switch_mutex_init(&member.flag_mutex, SWITCH_MUTEX_NESTED, member.pool);
-    switch_mutex_init(&member.audio_in_mutex, SWITCH_MUTEX_NESTED, member.pool);
-    switch_mutex_init(&member.audio_out_mutex, SWITCH_MUTEX_NESTED, member.pool);
+		/* Setup an audio buffer for the resampled audio */
+		if (switch_buffer_create_dynamic(&member.resample_buffer, CONF_DBLOCK_SIZE, CONF_DBUFFER_SIZE, CONF_DBUFFER_MAX)
+			!= SWITCH_STATUS_SUCCESS) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error Creating Audio Buffer!\n");
+			goto done;
+		}
+	}
+	/* Setup a Signed Linear codec for writing audio. */
+	if (switch_core_codec_init(&member.write_codec,
+							   "L16",
+							   NULL,
+							   read_codec->implementation->samples_per_second,
+							   read_codec->implementation->microseconds_per_frame / 1000,
+							   1,
+							   SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
+							   NULL, member.pool) == SWITCH_STATUS_SUCCESS) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
+						  "Raw Codec Activation Success L16@%uhz 1 channel %dms\n",
+						  read_codec->implementation->samples_per_second,
+						  read_codec->implementation->microseconds_per_frame / 1000);
+	} else {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Raw Codec Activation Failed L16@%uhz 1 channel %dms\n",
+						  read_codec->implementation->samples_per_second,
+						  read_codec->implementation->microseconds_per_frame / 1000);
+		flags = 0;
+		goto codec_done2;
+	}
 
-    /* Install our Signed Linear codec so we get the audio in that format */
-    switch_core_session_set_read_codec(member.session, &member.read_codec);
+	/* Setup an audio buffer for the incoming audio */
+	if (switch_buffer_create_dynamic(&member.audio_buffer, CONF_DBLOCK_SIZE, CONF_DBUFFER_SIZE, CONF_DBUFFER_MAX) !=
+		SWITCH_STATUS_SUCCESS) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error Creating Audio Buffer!\n");
+		goto codec_done1;
+	}
 
-    if ((flags_str = strstr(mydata, flags_prefix))) {
-        char *p;
+	/* Setup an audio buffer for the outgoing audio */
+	if (switch_buffer_create_dynamic(&member.mux_buffer, CONF_DBLOCK_SIZE, CONF_DBUFFER_SIZE, CONF_DBUFFER_MAX) !=
+		SWITCH_STATUS_SUCCESS) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error Creating Audio Buffer!\n");
+		goto codec_done1;
+	}
+
+	/* Prepare MUTEXS */
+	member.id = next_member_id();
+	member.session = session;
+	switch_mutex_init(&member.flag_mutex, SWITCH_MUTEX_NESTED, member.pool);
+	switch_mutex_init(&member.audio_in_mutex, SWITCH_MUTEX_NESTED, member.pool);
+	switch_mutex_init(&member.audio_out_mutex, SWITCH_MUTEX_NESTED, member.pool);
+
+	/* Install our Signed Linear codec so we get the audio in that format */
+	switch_core_session_set_read_codec(member.session, &member.read_codec);
+
+	if ((flags_str = strstr(mydata, flags_prefix))) {
+		char *p;
+
+		*flags_str = '\0';
+		flags_str += strlen(flags_prefix);
+		if ((p = strchr(flags_str, '}'))) {
+			*p = '\0';
+		}
+	}
 
-        *flags_str = '\0';
-        flags_str += strlen(flags_prefix);
-        if ((p = strchr(flags_str, '}'))) {
-            *p = '\0';
-        }
-    }
-	
 	mflags = conference->mflags;
 	set_mflags(flags_str, &mflags);
-    switch_set_flag_locked((&member), MFLAG_RUNNING | mflags);
-	
-    /* Add the caller to the conference */
-    if (conference_add_member(conference, &member) != SWITCH_STATUS_SUCCESS) {
-        goto codec_done1;
-    }
+	switch_set_flag_locked((&member), MFLAG_RUNNING | mflags);
 
-    msg.from = __FILE__;
+	/* Add the caller to the conference */
+	if (conference_add_member(conference, &member) != SWITCH_STATUS_SUCCESS) {
+		goto codec_done1;
+	}
 
-    /* Tell the channel we are going to be in a bridge */
-    msg.message_id = SWITCH_MESSAGE_INDICATE_BRIDGE;
-    switch_core_session_receive_message(session, &msg);
+	msg.from = __FILE__;
 
-    /* Run the confernece loop */
-    conference_loop_output(&member);
+	/* Tell the channel we are going to be in a bridge */
+	msg.message_id = SWITCH_MESSAGE_INDICATE_BRIDGE;
+	switch_core_session_receive_message(session, &msg);
 
-    /* Tell the channel we are no longer going to be in a bridge */
-    msg.message_id = SWITCH_MESSAGE_INDICATE_UNBRIDGE;
-    switch_core_session_receive_message(session, &msg);
+	/* Run the confernece loop */
+	conference_loop_output(&member);
 
-    /* Remove the caller from the conference */
-    conference_del_member(member.conference, &member);
+	/* Tell the channel we are no longer going to be in a bridge */
+	msg.message_id = SWITCH_MESSAGE_INDICATE_UNBRIDGE;
+	switch_core_session_receive_message(session, &msg);
 
-    /* Put the original codec back */
-    switch_core_session_set_read_codec(member.session, read_codec);
+	/* Remove the caller from the conference */
+	conference_del_member(member.conference, &member);
 
-    /* Clean Up.  codec_done(X): is for error situations after the codecs were setup and done: is for situations before */
- codec_done1:
-    switch_core_codec_destroy(&member.read_codec);
- codec_done2:
-    switch_core_codec_destroy(&member.write_codec);
- done:
-    switch_safe_free(params);
-    switch_buffer_destroy(&member.resample_buffer);
-    switch_buffer_destroy(&member.audio_buffer);
-    switch_buffer_destroy(&member.mux_buffer);
+	/* Put the original codec back */
+	switch_core_session_set_read_codec(member.session, read_codec);
 
-    /* Release the config registry handle */
-    if (cxml) {
-        switch_xml_free(cxml);
-    }
+	/* Clean Up.  codec_done(X): is for error situations after the codecs were setup and done: is for situations before */
+  codec_done1:
+	switch_core_codec_destroy(&member.read_codec);
+  codec_done2:
+	switch_core_codec_destroy(&member.write_codec);
+  done:
+	switch_safe_free(params);
+	switch_buffer_destroy(&member.resample_buffer);
+	switch_buffer_destroy(&member.audio_buffer);
+	switch_buffer_destroy(&member.mux_buffer);
 
-    if (switch_test_flag(&member, MFLAG_KICKED) && conference->kicked_sound) {
+	/* Release the config registry handle */
+	if (cxml) {
+		switch_xml_free(cxml);
+	}
+
+	if (switch_test_flag(&member, MFLAG_KICKED) && conference->kicked_sound) {
 		char *toplay = NULL;
 		char *dfile = NULL;
 
-        if (conference->sound_prefix) {
-            assert((dfile = switch_mprintf("%s/%s", conference->sound_prefix, conference->kicked_sound)));
+		if (conference->sound_prefix) {
+			assert((dfile = switch_mprintf("%s/%s", conference->sound_prefix, conference->kicked_sound)));
 			toplay = dfile;
 		} else {
 			toplay = conference->kicked_sound;
@@ -4196,720 +4215,735 @@ static void conference_function(switch_core_session_t *session, char *data)
 
 		switch_ivr_play_file(session, NULL, toplay, NULL);
 		switch_safe_free(dfile);
-    }
+	}
 
-    switch_core_session_reset(session);
+	switch_core_session_reset(session);
 
-    /* release the readlock */
-    if (rl) {
-        switch_thread_rwlock_unlock(conference->rwlock);
-    }
+	/* release the readlock */
+	if (rl) {
+		switch_thread_rwlock_unlock(conference->rwlock);
+	}
 }
 
 /* Create a thread for the conference and launch it */
-static void launch_conference_thread(conference_obj_t *conference)
+static void launch_conference_thread(conference_obj_t * conference)
 {
-    switch_thread_t *thread;
-    switch_threadattr_t *thd_attr = NULL;
+	switch_thread_t *thread;
+	switch_threadattr_t *thd_attr = NULL;
 
-    switch_set_flag_locked(conference, CFLAG_RUNNING);
-    switch_threadattr_create(&thd_attr, conference->pool);
-    switch_threadattr_detach_set(thd_attr, 1);
-    switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
-    switch_mutex_lock(globals.hash_mutex);
-    switch_core_hash_insert(globals.conference_hash, conference->name, conference);
-    switch_mutex_unlock(globals.hash_mutex);
-    switch_thread_create(&thread, thd_attr, conference_thread_run, conference, conference->pool);
+	switch_set_flag_locked(conference, CFLAG_RUNNING);
+	switch_threadattr_create(&thd_attr, conference->pool);
+	switch_threadattr_detach_set(thd_attr, 1);
+	switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
+	switch_mutex_lock(globals.hash_mutex);
+	switch_core_hash_insert(globals.conference_hash, conference->name, conference);
+	switch_mutex_unlock(globals.hash_mutex);
+	switch_thread_create(&thread, thd_attr, conference_thread_run, conference, conference->pool);
 }
 
-static void launch_conference_record_thread(conference_obj_t *conference, char *path)
+static void launch_conference_record_thread(conference_obj_t * conference, char *path)
 {
-    switch_thread_t *thread;
-    switch_threadattr_t *thd_attr = NULL;
-    switch_memory_pool_t *pool;
-    conference_record_t *rec;
+	switch_thread_t *thread;
+	switch_threadattr_t *thd_attr = NULL;
+	switch_memory_pool_t *pool;
+	conference_record_t *rec;
 
-    /* Setup a memory pool to use. */
-    if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Pool Failure\n");
-    }
+	/* Setup a memory pool to use. */
+	if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Pool Failure\n");
+	}
 
-    /* Create a node object*/
-    if (!(rec = switch_core_alloc(pool, sizeof(*rec)))) {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Alloc Failure\n");
-        switch_core_destroy_memory_pool(&pool);
-    }
+	/* Create a node object */
+	if (!(rec = switch_core_alloc(pool, sizeof(*rec)))) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Alloc Failure\n");
+		switch_core_destroy_memory_pool(&pool);
+	}
 
-    rec->conference = conference;
-    rec->path = switch_core_strdup(pool, path);
-    rec->pool = pool;
+	rec->conference = conference;
+	rec->path = switch_core_strdup(pool, path);
+	rec->pool = pool;
 
-    switch_threadattr_create(&thd_attr, rec->pool);
-    switch_threadattr_detach_set(thd_attr, 1);
-    switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
-    switch_thread_create(&thread, thd_attr, conference_record_thread_run, rec, rec->pool);
+	switch_threadattr_create(&thd_attr, rec->pool);
+	switch_threadattr_detach_set(thd_attr, 1);
+	switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
+	switch_thread_create(&thread, thd_attr, conference_record_thread_run, rec, rec->pool);
 }
 
 static const switch_application_interface_t conference_application_interface = {
-    /*.interface_name */ global_app_name, 
-    /*.application_function */ conference_function, 
-    NULL, NULL, NULL, 
+	/*.interface_name */ global_app_name,
+	/*.application_function */ conference_function,
+	NULL, NULL, NULL,
 	/* flags */ SAF_NONE,
-    /*.next*/ NULL
+	/*.next */ NULL
 };
 
 static switch_api_interface_t conf_api_interface = {
-    /*.interface_name */	"conference", 
-    /*.desc */				"Conference module commands", 
-    /*.function */			conf_api_main, 
-    /*.syntax */		/* see switch_module_load, this is built on the fly */
-    /*.next */ 
+	/*.interface_name */ "conference",
+	/*.desc */ "Conference module commands",
+	/*.function */ conf_api_main,
+	/*.syntax *//* see switch_module_load, this is built on the fly */
+	/*.next */
 };
 
 static switch_status_t chat_send(char *proto, char *from, char *to, char *subject, char *body, char *hint)
 {
-    char name[512] = "", *p, *lbuf = NULL;
-    switch_chat_interface_t *ci;
-    conference_obj_t *conference = NULL;
-    switch_stream_handle_t stream = {0};
+	char name[512] = "", *p, *lbuf = NULL;
+	switch_chat_interface_t *ci;
+	conference_obj_t *conference = NULL;
+	switch_stream_handle_t stream = { 0 };
 
-    if ((p = strchr(to, '+'))) {
-        to = ++p;
-    }
+	if ((p = strchr(to, '+'))) {
+		to = ++p;
+	}
 
-    if (!body) {
-        return SWITCH_STATUS_SUCCESS;
-    }
+	if (!body) {
+		return SWITCH_STATUS_SUCCESS;
+	}
 
-    if (!(ci = switch_loadable_module_get_chat_interface(proto))) {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Chat Interface [%s]!\n", proto);
-    }
+	if (!(ci = switch_loadable_module_get_chat_interface(proto))) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Chat Interface [%s]!\n", proto);
+	}
 
 
-    if ((p = strchr(to, '@'))) {
-        switch_copy_string(name, to, ++p-to);
-    } else {
-        switch_copy_string(name, to, sizeof(name));
-    }
+	if ((p = strchr(to, '@'))) {
+		switch_copy_string(name, to, ++p - to);
+	} else {
+		switch_copy_string(name, to, sizeof(name));
+	}
 
-    if (!(conference = (conference_obj_t *) switch_core_hash_find(globals.conference_hash, name))) {
-        ci->chat_send(CONF_CHAT_PROTO, to, hint && strchr(hint, '/') ? hint : from, "", "Conference not active.", NULL);
-        return SWITCH_STATUS_FALSE;
-    }
+	if (!(conference = (conference_obj_t *) switch_core_hash_find(globals.conference_hash, name))) {
+		ci->chat_send(CONF_CHAT_PROTO, to, hint && strchr(hint, '/') ? hint : from, "", "Conference not active.", NULL);
+		return SWITCH_STATUS_FALSE;
+	}
 
-    SWITCH_STANDARD_STREAM(stream);
+	SWITCH_STANDARD_STREAM(stream);
 
-    if (body != NULL && (lbuf = strdup(body))) {
-        int argc;
-        char *argv[25];
+	if (body != NULL && (lbuf = strdup(body))) {
+		int argc;
+		char *argv[25];
 
-        memset(argv, 0, sizeof(argv));
-        argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
+		memset(argv, 0, sizeof(argv));
+		argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
 
-        /* try to find a command to execute */
-        if (argc) {
-            /* special case list */
-            if (strcasecmp(argv[0], "list") == 0) {
-                conference_list_pretty(conference, &stream);
-                /* provide help */
-            } 
+		/* try to find a command to execute */
+		if (argc) {
+			/* special case list */
+			if (strcasecmp(argv[0], "list") == 0) {
+				conference_list_pretty(conference, &stream);
+				/* provide help */
+			}
 #if 0
-            else {
-                if (strcasecmp(argv[0], "help") == 0 || strcasecmp(argv[0], "commands") == 0) {
-                    stream.write_function(&stream, "%s\n", conf_api_interface.syntax);
-                    /* find a normal command */
-                } else {
-                    conf_api_dispatch(conference, &stream, argc, argv, (const char *)body, 0);
-                }
-            }
+			else {
+				if (strcasecmp(argv[0], "help") == 0 || strcasecmp(argv[0], "commands") == 0) {
+					stream.write_function(&stream, "%s\n", conf_api_interface.syntax);
+					/* find a normal command */
+				} else {
+					conf_api_dispatch(conference, &stream, argc, argv, (const char *) body, 0);
+				}
+			}
 #endif
-        } else {
-            stream.write_function(&stream, "No parameters specified.\nTry 'help'\n");
-        }
-    }
-    switch_safe_free(lbuf);
+		} else {
+			stream.write_function(&stream, "No parameters specified.\nTry 'help'\n");
+		}
+	}
+	switch_safe_free(lbuf);
 
-    ci->chat_send(CONF_CHAT_PROTO, to, from, "", stream.data, NULL);
-    switch_safe_free(stream.data);
+	ci->chat_send(CONF_CHAT_PROTO, to, from, "", stream.data, NULL);
+	switch_safe_free(stream.data);
 
-    return SWITCH_STATUS_SUCCESS;
+	return SWITCH_STATUS_SUCCESS;
 }
 
 static const switch_chat_interface_t conference_chat_interface = {
-    /*.name */ CONF_CHAT_PROTO, 
-    /*.chat_send */ chat_send, 
+	/*.name */ CONF_CHAT_PROTO,
+	/*.chat_send */ chat_send,
 
 };
 
 static switch_loadable_module_interface_t conference_module_interface = {
-    /*.module_name */ modname, 
-    /*.endpoint_interface */ NULL, 
-    /*.timer_interface */ NULL, 
-    /*.dialplan_interface */ NULL, 
-    /*.codec_interface */ NULL, 
-    /*.application_interface */ &conference_application_interface, 
-    /*.api_interface */ &conf_api_interface, 
-    /*.file_interface */ NULL, 
-    /*.speech_interface */ NULL, 
-    /*.directory_interface */ NULL, 
-    /*.chat_interface */ &conference_chat_interface
+	/*.module_name */ modname,
+	/*.endpoint_interface */ NULL,
+	/*.timer_interface */ NULL,
+	/*.dialplan_interface */ NULL,
+	/*.codec_interface */ NULL,
+	/*.application_interface */ &conference_application_interface,
+	/*.api_interface */ &conf_api_interface,
+	/*.file_interface */ NULL,
+	/*.speech_interface */ NULL,
+	/*.directory_interface */ NULL,
+	/*.chat_interface */ &conference_chat_interface
 };
 
-static switch_status_t conf_default_controls(conference_obj_t *conference)
+static switch_status_t conf_default_controls(conference_obj_t * conference)
 {
-    switch_status_t status = SWITCH_STATUS_FALSE;
-    uint32_t i;
-    caller_control_action_t *action;
+	switch_status_t status = SWITCH_STATUS_FALSE;
+	uint32_t i;
+	caller_control_action_t *action;
 
-    assert(conference != NULL);
+	assert(conference != NULL);
 
-    for(i = 0, status = SWITCH_STATUS_SUCCESS; status == SWITCH_STATUS_SUCCESS && ipool, sizeof(caller_control_action_t));
-            if (action != NULL) {
-                action->fndesc = &ccfntbl[i];
-                action->data = NULL;
-                status = switch_ivr_digit_stream_parser_set_event(conference->dtmf_parser, ccfntbl[i].digits, action);
-            } else {
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "unable to alloc memory for caller control binding '%s' to '%s'\n", 
-                                  ccfntbl[i].key, ccfntbl[i].digits);
-                status = SWITCH_STATUS_MEMERR;
-            }
-        }
-    }
-	
+	for (i = 0, status = SWITCH_STATUS_SUCCESS; status == SWITCH_STATUS_SUCCESS && i < CCFNTBL_QTY; i++) {
+		if (!switch_strlen_zero(ccfntbl[i].digits)) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
+							  "Installing default caller control action '%s' bound to '%s'.\n", ccfntbl[i].key,
+							  ccfntbl[i].digits);
+			action = (caller_control_action_t *) switch_core_alloc(conference->pool, sizeof(caller_control_action_t));
+			if (action != NULL) {
+				action->fndesc = &ccfntbl[i];
+				action->data = NULL;
+				status = switch_ivr_digit_stream_parser_set_event(conference->dtmf_parser, ccfntbl[i].digits, action);
+			} else {
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+								  "unable to alloc memory for caller control binding '%s' to '%s'\n", ccfntbl[i].key,
+								  ccfntbl[i].digits);
+				status = SWITCH_STATUS_MEMERR;
+			}
+		}
+	}
 
-    return status;
+
+	return status;
 }
 
-static switch_status_t conference_new_install_caller_controls_custom(conference_obj_t *conference, switch_xml_t xml_controls, switch_xml_t xml_menus)
+static switch_status_t conference_new_install_caller_controls_custom(conference_obj_t * conference,
+																	 switch_xml_t xml_controls, switch_xml_t xml_menus)
 {
-    switch_status_t status = SWITCH_STATUS_FALSE;
-    switch_xml_t xml_kvp;
+	switch_status_t status = SWITCH_STATUS_FALSE;
+	switch_xml_t xml_kvp;
 
-    assert(conference != NULL);
-    assert(xml_controls != NULL);
+	assert(conference != NULL);
+	assert(xml_controls != NULL);
 
-    /* parse the controls tree for caller control digit strings */
-    for (xml_kvp = switch_xml_child(xml_controls, "control"); xml_kvp; xml_kvp = xml_kvp->next) {
-        char *key = (char *) switch_xml_attr(xml_kvp, "action");
-        char *val = (char *) switch_xml_attr(xml_kvp, "digits");
-        char *data = (char *)switch_xml_attr_soft(xml_kvp, "data");
+	/* parse the controls tree for caller control digit strings */
+	for (xml_kvp = switch_xml_child(xml_controls, "control"); xml_kvp; xml_kvp = xml_kvp->next) {
+		char *key = (char *) switch_xml_attr(xml_kvp, "action");
+		char *val = (char *) switch_xml_attr(xml_kvp, "digits");
+		char *data = (char *) switch_xml_attr_soft(xml_kvp, "data");
 
-        if (!switch_strlen_zero(key) && !switch_strlen_zero(val)) {
-            uint32_t i;
+		if (!switch_strlen_zero(key) && !switch_strlen_zero(val)) {
+			uint32_t i;
 
-            /* scan through all of the valid actions, and if found, */
-            /* set the new caller control action digit string, then */
-            /* stop scanning the table, and go to the next xml kvp. */
-            for(i = 0, status = SWITCH_STATUS_NOOP; ipool, sizeof(caller_control_action_t));
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
+									  "Installing caller control action '%s' bound to '%s'.\n", key, val);
+					action =
+						(caller_control_action_t *) switch_core_alloc(conference->pool,
+																	  sizeof(caller_control_action_t));
 					if (action != NULL) {
 						action->fndesc = &ccfntbl[i];
-						action->data = (void *)switch_core_strdup(conference->pool, data);
+						action->data = (void *) switch_core_strdup(conference->pool, data);
 						action->binded_dtmf = switch_core_strdup(conference->pool, val);
 						status = switch_ivr_digit_stream_parser_set_event(conference->dtmf_parser, val, action);
 					} else {
-						switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "unable to alloc memory for caller control binding '%s' to '%s'\n", ccfntbl[i].key, ccfntbl[i].digits);
+						switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+										  "unable to alloc memory for caller control binding '%s' to '%s'\n",
+										  ccfntbl[i].key, ccfntbl[i].digits);
 						status = SWITCH_STATUS_MEMERR;
 					}
 				}
 			}
-            if (status == SWITCH_STATUS_NOOP) {
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid caller control action name '%s'.\n", key);
-            }
-        } else {
-            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid caller control config entry pair action = '%s' digits = '%s'\n", key, val);
-        }
-    }
+			if (status == SWITCH_STATUS_NOOP) {
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid caller control action name '%s'.\n",
+								  key);
+			}
+		} else {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
+							  "Invalid caller control config entry pair action = '%s' digits = '%s'\n", key, val);
+		}
+	}
 
-    return status;
+	return status;
 }
 
 /* create a new conferene with a specific profile */
 static conference_obj_t *conference_new(char *name, conf_xml_cfg_t cfg, switch_memory_pool_t *pool)
 {
-    conference_obj_t *conference;
-    switch_xml_t xml_kvp;
-    char *rate_name = NULL;
-    char *interval_name = NULL;
-    char *timer_name = NULL;
-    char *domain = NULL;
-    char *tts_engine = NULL;
-    char *tts_voice = NULL;
-    char *enter_sound = NULL;
-    char *sound_prefix = NULL;
-    char *exit_sound = NULL;
-    char *alone_sound = NULL;
-    char *ack_sound = NULL;
-    char *nack_sound = NULL;
-    char *muted_sound = NULL;
-    char *unmuted_sound = NULL;
-    char *locked_sound = NULL;
-    char *is_locked_sound = NULL;
-    char *is_unlocked_sound = NULL;
-    char *kicked_sound = NULL;
-    char *pin = NULL;
-    char *pin_sound = NULL; 
-    char *bad_pin_sound = NULL;
-    char *energy_level = NULL;
-    char *caller_id_name = NULL;
-    char *caller_id_number = NULL;
-    char *caller_controls = NULL;
+	conference_obj_t *conference;
+	switch_xml_t xml_kvp;
+	char *rate_name = NULL;
+	char *interval_name = NULL;
+	char *timer_name = NULL;
+	char *domain = NULL;
+	char *tts_engine = NULL;
+	char *tts_voice = NULL;
+	char *enter_sound = NULL;
+	char *sound_prefix = NULL;
+	char *exit_sound = NULL;
+	char *alone_sound = NULL;
+	char *ack_sound = NULL;
+	char *nack_sound = NULL;
+	char *muted_sound = NULL;
+	char *unmuted_sound = NULL;
+	char *locked_sound = NULL;
+	char *is_locked_sound = NULL;
+	char *is_unlocked_sound = NULL;
+	char *kicked_sound = NULL;
+	char *pin = NULL;
+	char *pin_sound = NULL;
+	char *bad_pin_sound = NULL;
+	char *energy_level = NULL;
+	char *caller_id_name = NULL;
+	char *caller_id_number = NULL;
+	char *caller_controls = NULL;
 	char *member_flags = NULL;
-    uint32_t max_members = 0;
-    uint32_t anounce_count = 0;
-    char *maxmember_sound = NULL;
-    uint32_t rate = 8000, interval = 20;
-    switch_status_t status;
+	uint32_t max_members = 0;
+	uint32_t anounce_count = 0;
+	char *maxmember_sound = NULL;
+	uint32_t rate = 8000, interval = 20;
+	switch_status_t status;
 
-    /* Validate the conference name */
-    if (switch_strlen_zero(name)) {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Record! no name.\n");
-        return NULL;
-    }
+	/* Validate the conference name */
+	if (switch_strlen_zero(name)) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Record! no name.\n");
+		return NULL;
+	}
 
-    /* parse the profile tree for param values */
-    for (xml_kvp = switch_xml_child(cfg.profile, "param"); xml_kvp; xml_kvp = xml_kvp->next) {
-        char *var = (char *) switch_xml_attr_soft(xml_kvp, "name");
-        char *val = (char *) switch_xml_attr_soft(xml_kvp, "value");
-        char buf[128] = "";
-        char *p;
+	/* parse the profile tree for param values */
+	for (xml_kvp = switch_xml_child(cfg.profile, "param"); xml_kvp; xml_kvp = xml_kvp->next) {
+		char *var = (char *) switch_xml_attr_soft(xml_kvp, "name");
+		char *val = (char *) switch_xml_attr_soft(xml_kvp, "value");
+		char buf[128] = "";
+		char *p;
 
-        if ((p = strchr(var, '_'))) {
-            switch_copy_string(buf, var, sizeof(buf));
-            for(p = buf; *p; p++) {
-                if (*p == '_') {
-                    *p = '-';
-                }
-            }
-            var = buf;
-        }
+		if ((p = strchr(var, '_'))) {
+			switch_copy_string(buf, var, sizeof(buf));
+			for (p = buf; *p; p++) {
+				if (*p == '_') {
+					*p = '-';
+				}
+			}
+			var = buf;
+		}
 
-        if (!strcasecmp(var, "rate")) {
-            rate_name = val;
-        } else if (!strcasecmp(var, "domain")) {
-            domain = val;
-        } else if (!strcasecmp(var, "interval")) {
-            interval_name = val;
-        } else if (!strcasecmp(var, "timer-name")) {
-            timer_name = val;
-        } else if (!strcasecmp(var, "tts-engine")) {
-            tts_engine = val;
-        } else if (!strcasecmp(var, "tts-voice")) {
-            tts_voice = val;
-        } else if (!strcasecmp(var, "enter-sound")) {
-            enter_sound = val;
-        } else if (!strcasecmp(var, "exit-sound")) {
-            exit_sound = val;
-        } else if (!strcasecmp(var, "alone-sound")) {
-            alone_sound = val;
-        } else if (!strcasecmp(var, "ack-sound")) {
-            ack_sound = val;
-        } else if (!strcasecmp(var, "nack-sound")) {
-            nack_sound = val;
-        } else if (!strcasecmp(var, "muted-sound")) {
-            muted_sound = val;
-        } else if (!strcasecmp(var, "unmuted-sound")) {
-            unmuted_sound = val;
-        } else if (!strcasecmp(var, "locked-sound")) {
-            locked_sound = val;
-        } else if (!strcasecmp(var, "is-locked-sound")) {
-            is_locked_sound = val;
-        } else if (!strcasecmp(var, "is-unlocked-sound")) {
-            is_unlocked_sound = val;
-        } else if (!strcasecmp(var, "member-flags")) {
+		if (!strcasecmp(var, "rate")) {
+			rate_name = val;
+		} else if (!strcasecmp(var, "domain")) {
+			domain = val;
+		} else if (!strcasecmp(var, "interval")) {
+			interval_name = val;
+		} else if (!strcasecmp(var, "timer-name")) {
+			timer_name = val;
+		} else if (!strcasecmp(var, "tts-engine")) {
+			tts_engine = val;
+		} else if (!strcasecmp(var, "tts-voice")) {
+			tts_voice = val;
+		} else if (!strcasecmp(var, "enter-sound")) {
+			enter_sound = val;
+		} else if (!strcasecmp(var, "exit-sound")) {
+			exit_sound = val;
+		} else if (!strcasecmp(var, "alone-sound")) {
+			alone_sound = val;
+		} else if (!strcasecmp(var, "ack-sound")) {
+			ack_sound = val;
+		} else if (!strcasecmp(var, "nack-sound")) {
+			nack_sound = val;
+		} else if (!strcasecmp(var, "muted-sound")) {
+			muted_sound = val;
+		} else if (!strcasecmp(var, "unmuted-sound")) {
+			unmuted_sound = val;
+		} else if (!strcasecmp(var, "locked-sound")) {
+			locked_sound = val;
+		} else if (!strcasecmp(var, "is-locked-sound")) {
+			is_locked_sound = val;
+		} else if (!strcasecmp(var, "is-unlocked-sound")) {
+			is_unlocked_sound = val;
+		} else if (!strcasecmp(var, "member-flags")) {
 			member_flags = val;
-        } else if (!strcasecmp(var, "kicked-sound")) {
-            kicked_sound = val;
-        } else if (!strcasecmp(var, "pin")) {
-            pin = val;
-        } else if (!strcasecmp(var, "pin-sound")) {
-            pin_sound = val;
-        } else if (!strcasecmp(var, "bad-pin-sound")) {
-            bad_pin_sound = val;
-        } else if (!strcasecmp(var, "energy-level")) {
-            energy_level = val;
-        } else if (!strcasecmp(var, "caller-id-name")) {
-            caller_id_name = val;
-        } else if (!strcasecmp(var, "caller-id-number")) {
-            caller_id_number = val;
-        } else if (!strcasecmp(var, "caller-controls")) {
-            caller_controls = val;
-        } else if (!strcasecmp(var, "sound-prefix")) {
-            sound_prefix = val;
-        } else if (!strcasecmp(var, "max-members")) {
-            errno = 0; // sanity first
-            max_members = strtol(val,NULL,0); // base 0 lets 0x... for hex 0... for octal and base 10 otherwise through
-            if(errno == ERANGE || errno == EINVAL || max_members < 0 || max_members == 1) {
-                // a negative wont work well, and its foolish to have a conference limited to 1 person unless the outbound 
-                // stuff is added, see comments above
-                max_members = 0; // set to 0 to disable max counts
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "max-members %s is invalid, not setting a limit\n",val);
-            }
-        } else if(!strcasecmp(var, "max-members-sound")) {
-            maxmember_sound = val;
-        } else if(!strcasecmp(var, "anounce-count")) {
-            errno = 0; // safety first
-            anounce_count = strtol(val,NULL,0);
-            if(errno == ERANGE || errno == EINVAL) {
-                anounce_count = 0;
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "anounce-count is invalid, not anouncing member counts\n");
-            }
-        }
-    }
+		} else if (!strcasecmp(var, "kicked-sound")) {
+			kicked_sound = val;
+		} else if (!strcasecmp(var, "pin")) {
+			pin = val;
+		} else if (!strcasecmp(var, "pin-sound")) {
+			pin_sound = val;
+		} else if (!strcasecmp(var, "bad-pin-sound")) {
+			bad_pin_sound = val;
+		} else if (!strcasecmp(var, "energy-level")) {
+			energy_level = val;
+		} else if (!strcasecmp(var, "caller-id-name")) {
+			caller_id_name = val;
+		} else if (!strcasecmp(var, "caller-id-number")) {
+			caller_id_number = val;
+		} else if (!strcasecmp(var, "caller-controls")) {
+			caller_controls = val;
+		} else if (!strcasecmp(var, "sound-prefix")) {
+			sound_prefix = val;
+		} else if (!strcasecmp(var, "max-members")) {
+			errno = 0;			// sanity first
+			max_members = strtol(val, NULL, 0);	// base 0 lets 0x... for hex 0... for octal and base 10 otherwise through
+			if (errno == ERANGE || errno == EINVAL || max_members < 0 || max_members == 1) {
+				// a negative wont work well, and its foolish to have a conference limited to 1 person unless the outbound 
+				// stuff is added, see comments above
+				max_members = 0;	// set to 0 to disable max counts
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+								  "max-members %s is invalid, not setting a limit\n", val);
+			}
+		} else if (!strcasecmp(var, "max-members-sound")) {
+			maxmember_sound = val;
+		} else if (!strcasecmp(var, "anounce-count")) {
+			errno = 0;			// safety first
+			anounce_count = strtol(val, NULL, 0);
+			if (errno == ERANGE || errno == EINVAL) {
+				anounce_count = 0;
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+								  "anounce-count is invalid, not anouncing member counts\n");
+			}
+		}
+	}
 
-    /* Set defaults and various paramaters */
+	/* Set defaults and various paramaters */
 
-    /* Speed in hertz */
-    if (!switch_strlen_zero(rate_name)) {
-        uint32_t r = atoi(rate_name);
-        if (r) {
-            rate = r;
-        }
-    }
+	/* Speed in hertz */
+	if (!switch_strlen_zero(rate_name)) {
+		uint32_t r = atoi(rate_name);
+		if (r) {
+			rate = r;
+		}
+	}
 
-    /* Packet Interval in milliseconds */
-    if (!switch_strlen_zero(interval_name)) {
-        uint32_t i = atoi(interval_name);
-        if (i) {
-            interval = i;
-        }
-    }
+	/* Packet Interval in milliseconds */
+	if (!switch_strlen_zero(interval_name)) {
+		uint32_t i = atoi(interval_name);
+		if (i) {
+			interval = i;
+		}
+	}
 
-    /* Timer module to use */
-    if (switch_strlen_zero(timer_name)) {
-        timer_name = "soft";
-    }
+	/* Timer module to use */
+	if (switch_strlen_zero(timer_name)) {
+		timer_name = "soft";
+	}
 
-    /* Caller ID Name */
-    if (switch_strlen_zero(caller_id_name)) {
-        caller_id_name = (char *) global_app_name;
-    }
+	/* Caller ID Name */
+	if (switch_strlen_zero(caller_id_name)) {
+		caller_id_name = (char *) global_app_name;
+	}
 
-    /* Caller ID Number */
-    if (switch_strlen_zero(caller_id_number)) {
-        caller_id_number = "0000000000";
-    }
+	/* Caller ID Number */
+	if (switch_strlen_zero(caller_id_number)) {
+		caller_id_number = "0000000000";
+	}
 
-    if (!pool) {
-        /* Setup a memory pool to use. */
-        if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) {
-            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Pool Failure\n");
-            status = SWITCH_STATUS_TERM;
-            return NULL;
-        }
-    }
+	if (!pool) {
+		/* Setup a memory pool to use. */
+		if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Pool Failure\n");
+			status = SWITCH_STATUS_TERM;
+			return NULL;
+		}
+	}
 
-    /* Create the conference object. */
-    if (!(conference = switch_core_alloc(pool, sizeof(*conference)))) {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
-        status = SWITCH_STATUS_TERM;
-        return NULL;
-    }
+	/* Create the conference object. */
+	if (!(conference = switch_core_alloc(pool, sizeof(*conference)))) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
+		status = SWITCH_STATUS_TERM;
+		return NULL;
+	}
 
-    /* initialize the conference object with settings from the specified profile */
-    conference->pool = pool;
-    conference->timer_name = switch_core_strdup(conference->pool, timer_name);
-    conference->tts_engine = switch_core_strdup(conference->pool, tts_engine);
-    conference->tts_voice = switch_core_strdup(conference->pool, tts_voice);
+	/* initialize the conference object with settings from the specified profile */
+	conference->pool = pool;
+	conference->timer_name = switch_core_strdup(conference->pool, timer_name);
+	conference->tts_engine = switch_core_strdup(conference->pool, tts_engine);
+	conference->tts_voice = switch_core_strdup(conference->pool, tts_voice);
 
-    conference->caller_id_name = switch_core_strdup(conference->pool, caller_id_name);
-    conference->caller_id_number = switch_core_strdup(conference->pool, caller_id_number);
+	conference->caller_id_name = switch_core_strdup(conference->pool, caller_id_name);
+	conference->caller_id_number = switch_core_strdup(conference->pool, caller_id_number);
 
 	conference->mflags = MFLAG_CAN_SPEAK | MFLAG_CAN_HEAR;
 
 	if (member_flags) {
 		set_mflags(member_flags, &conference->mflags);
-	} 
+	}
 
-    if (sound_prefix) {
-        conference->sound_prefix = switch_core_strdup(conference->pool, sound_prefix);
-    }
+	if (sound_prefix) {
+		conference->sound_prefix = switch_core_strdup(conference->pool, sound_prefix);
+	}
 
-    if (!switch_strlen_zero(enter_sound)) {
-        conference->enter_sound = switch_core_strdup(conference->pool, enter_sound);
-    }
+	if (!switch_strlen_zero(enter_sound)) {
+		conference->enter_sound = switch_core_strdup(conference->pool, enter_sound);
+	}
 
-    if (!switch_strlen_zero(exit_sound)) {
-        conference->exit_sound = switch_core_strdup(conference->pool, exit_sound);
-    }
+	if (!switch_strlen_zero(exit_sound)) {
+		conference->exit_sound = switch_core_strdup(conference->pool, exit_sound);
+	}
 
-    if (!switch_strlen_zero(ack_sound)) {
-        conference->ack_sound = switch_core_strdup(conference->pool, ack_sound);
-    }
+	if (!switch_strlen_zero(ack_sound)) {
+		conference->ack_sound = switch_core_strdup(conference->pool, ack_sound);
+	}
 
-    if (!switch_strlen_zero(nack_sound)) {
-        conference->nack_sound = switch_core_strdup(conference->pool, nack_sound);
-    }
+	if (!switch_strlen_zero(nack_sound)) {
+		conference->nack_sound = switch_core_strdup(conference->pool, nack_sound);
+	}
 
-    if (!switch_strlen_zero(muted_sound)) {
-        conference->muted_sound = switch_core_strdup(conference->pool, muted_sound);
-    }
+	if (!switch_strlen_zero(muted_sound)) {
+		conference->muted_sound = switch_core_strdup(conference->pool, muted_sound);
+	}
 
-    if (!switch_strlen_zero(unmuted_sound)) {
-        conference->unmuted_sound = switch_core_strdup(conference->pool, unmuted_sound);
-    }
+	if (!switch_strlen_zero(unmuted_sound)) {
+		conference->unmuted_sound = switch_core_strdup(conference->pool, unmuted_sound);
+	}
 
-    if (!switch_strlen_zero(kicked_sound)) {
-        conference->kicked_sound = switch_core_strdup(conference->pool, kicked_sound);
-    }
+	if (!switch_strlen_zero(kicked_sound)) {
+		conference->kicked_sound = switch_core_strdup(conference->pool, kicked_sound);
+	}
 
-    if (!switch_strlen_zero(pin_sound)) {
-        conference->pin_sound = switch_core_strdup(conference->pool, pin_sound);
-    }
+	if (!switch_strlen_zero(pin_sound)) {
+		conference->pin_sound = switch_core_strdup(conference->pool, pin_sound);
+	}
 
-    if (!switch_strlen_zero(bad_pin_sound)) {
-        conference->bad_pin_sound = switch_core_strdup(conference->pool, bad_pin_sound);
-    }
+	if (!switch_strlen_zero(bad_pin_sound)) {
+		conference->bad_pin_sound = switch_core_strdup(conference->pool, bad_pin_sound);
+	}
 
-    if (!switch_strlen_zero(pin)) {
-        conference->pin = switch_core_strdup(conference->pool, pin);
-    }
+	if (!switch_strlen_zero(pin)) {
+		conference->pin = switch_core_strdup(conference->pool, pin);
+	}
 
-    if (!switch_strlen_zero(alone_sound)) {
-        conference->alone_sound = switch_core_strdup(conference->pool, alone_sound);
-    } 
+	if (!switch_strlen_zero(alone_sound)) {
+		conference->alone_sound = switch_core_strdup(conference->pool, alone_sound);
+	}
 
-    if (!switch_strlen_zero(locked_sound)) {
-        conference->locked_sound = switch_core_strdup(conference->pool, locked_sound);
-    }
+	if (!switch_strlen_zero(locked_sound)) {
+		conference->locked_sound = switch_core_strdup(conference->pool, locked_sound);
+	}
 
-    if (!switch_strlen_zero(is_locked_sound)) {
-        conference->is_locked_sound = switch_core_strdup(conference->pool, is_locked_sound);
-    }
+	if (!switch_strlen_zero(is_locked_sound)) {
+		conference->is_locked_sound = switch_core_strdup(conference->pool, is_locked_sound);
+	}
 
-    if (!switch_strlen_zero(is_unlocked_sound)) {
-        conference->is_unlocked_sound = switch_core_strdup(conference->pool, is_unlocked_sound);
-    }
+	if (!switch_strlen_zero(is_unlocked_sound)) {
+		conference->is_unlocked_sound = switch_core_strdup(conference->pool, is_unlocked_sound);
+	}
 
-    if (!switch_strlen_zero(energy_level)) {
-        conference->energy_level = atoi(energy_level);
-    }
+	if (!switch_strlen_zero(energy_level)) {
+		conference->energy_level = atoi(energy_level);
+	}
 
-    if (!switch_strlen_zero(maxmember_sound)) {
-        conference->maxmember_sound = switch_core_strdup(conference->pool, maxmember_sound);
-    }
+	if (!switch_strlen_zero(maxmember_sound)) {
+		conference->maxmember_sound = switch_core_strdup(conference->pool, maxmember_sound);
+	}
+	// its going to be 0 by default, set to a value otherwise so this should be safe
+	conference->max_members = max_members;
+	conference->anounce_count = anounce_count;
 
-    // its going to be 0 by default, set to a value otherwise so this should be safe
-    conference->max_members = max_members;
-    conference->anounce_count = anounce_count;
+	conference->name = switch_core_strdup(conference->pool, name);
+	if (domain) {
+		conference->domain = switch_core_strdup(conference->pool, domain);
+	} else {
+		conference->domain = "cluecon.com";
+	}
+	conference->rate = rate;
+	conference->interval = interval;
+	conference->dtmf_parser = NULL;
 
-    conference->name = switch_core_strdup(conference->pool, name);
-    if (domain) {
-        conference->domain = switch_core_strdup(conference->pool, domain);
-    } else {
-        conference->domain = "cluecon.com";
-    }
-    conference->rate = rate;
-    conference->interval = interval;
-    conference->dtmf_parser = NULL;
+	/* caller control configuration chores */
+	if (switch_ivr_digit_stream_parser_new(conference->pool, &conference->dtmf_parser) == SWITCH_STATUS_SUCCESS) {
 
-    /* caller control configuration chores */
-    if (switch_ivr_digit_stream_parser_new(conference->pool, &conference->dtmf_parser) == SWITCH_STATUS_SUCCESS) {
+		/* if no controls, or default controls specified, install default */
+		if (caller_controls == NULL || *caller_controls == '\0' || strcasecmp(caller_controls, "default") == 0) {
+			status = conf_default_controls(conference);
+		} else if (strcasecmp(caller_controls, "none") != 0) {
+			/* try to build caller control if the group has been specified and != "none" */
+			switch_xml_t xml_controls = switch_xml_find_child(cfg.controls, "group", "name", caller_controls);
+			status = conference_new_install_caller_controls_custom(conference, xml_controls, NULL);
 
-        /* if no controls, or default controls specified, install default */
-        if (caller_controls == NULL || *caller_controls == '\0' || strcasecmp(caller_controls, "default") == 0) {
-            status = conf_default_controls(conference);
-        } else if (strcasecmp(caller_controls, "none") != 0) {
-            /* try to build caller control if the group has been specified and != "none" */
-            switch_xml_t xml_controls = switch_xml_find_child(cfg.controls, "group", "name", caller_controls);
-            status = conference_new_install_caller_controls_custom(conference, xml_controls, NULL);
+			if (status != SWITCH_STATUS_SUCCESS) {
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+								  "Unable to install caller controls group '%s'\n", caller_controls);
+			}
+		} else {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "no caller controls intalled.\n");
+		}
+	} else {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to allocate caller control digit parser.\n");
+	}
 
-            if (status != SWITCH_STATUS_SUCCESS) {
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to install caller controls group '%s'\n", caller_controls);
-            }
-        } else {
-            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "no caller controls intalled.\n");
-        }
-    } else {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to allocate caller control digit parser.\n");
-    }
-
-    /* Activate the conference mutex for exclusivity */
-    switch_mutex_init(&conference->mutex, SWITCH_MUTEX_NESTED, conference->pool);
-    switch_mutex_init(&conference->flag_mutex, SWITCH_MUTEX_NESTED, conference->pool);
-    switch_thread_rwlock_create(&conference->rwlock, conference->pool);
+	/* Activate the conference mutex for exclusivity */
+	switch_mutex_init(&conference->mutex, SWITCH_MUTEX_NESTED, conference->pool);
+	switch_mutex_init(&conference->flag_mutex, SWITCH_MUTEX_NESTED, conference->pool);
+	switch_thread_rwlock_create(&conference->rwlock, conference->pool);
 	switch_mutex_init(&conference->member_mutex, SWITCH_MUTEX_NESTED, conference->pool);
 
-    return conference;
+	return conference;
 }
 
-static void pres_event_handler(switch_event_t *event) 
-{ 
-    char *to = switch_event_get_header(event, "to"); 
-    char *dup_to = NULL, *conf_name, *e; 
-    conference_obj_t *conference; 
+static void pres_event_handler(switch_event_t *event)
+{
+	char *to = switch_event_get_header(event, "to");
+	char *dup_to = NULL, *conf_name, *e;
+	conference_obj_t *conference;
 
-    if (!to || strncasecmp(to, "conf+", 5)) { 
-        return; 
-    } 
+	if (!to || strncasecmp(to, "conf+", 5)) {
+		return;
+	}
 
-    if (!(dup_to = strdup(to))) { 
-        return; 
-    } 
+	if (!(dup_to = strdup(to))) {
+		return;
+	}
 
-    conf_name = dup_to + 5; 
+	conf_name = dup_to + 5;
 
-    if ((e = strchr(conf_name, '@'))) { 
-        *e = '\0'; 
-    } 
+	if ((e = strchr(conf_name, '@'))) {
+		*e = '\0';
+	}
 
-    if ((conference = (conference_obj_t *) switch_core_hash_find(globals.conference_hash, conf_name))) { 
-        switch_event_t *event; 
+	if ((conference = (conference_obj_t *) switch_core_hash_find(globals.conference_hash, conf_name))) {
+		switch_event_t *event;
 
-        if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) { 
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "proto", CONF_CHAT_PROTO); 
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", "%s", conference->name); 
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", conference->name, conference->domain); 
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "status", "Active (%d caller%s)", conference->count, conference->count == 1 ? "" : "s"); 
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_type", "presence"); 
-            switch_event_fire(&event); 
-        } 
-    } else if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) { 
-        switch_event_add_header(event, SWITCH_STACK_BOTTOM, "proto", CONF_CHAT_PROTO); 
-        switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", "%s", conf_name); 
-        switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s", to); 
-        switch_event_add_header(event, SWITCH_STACK_BOTTOM, "status", "Idle"); 
-        switch_event_add_header(event, SWITCH_STACK_BOTTOM, "rpid", "idle"); 
-        switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_type", "presence"); 
-        switch_event_fire(&event); 
-    } 
+		if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "proto", CONF_CHAT_PROTO);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", "%s", conference->name);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", conference->name, conference->domain);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "status", "Active (%d caller%s)", conference->count,
+									conference->count == 1 ? "" : "s");
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_type", "presence");
+			switch_event_fire(&event);
+		}
+	} else if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
+		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "proto", CONF_CHAT_PROTO);
+		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", "%s", conf_name);
+		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s", to);
+		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "status", "Idle");
+		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "rpid", "idle");
+		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_type", "presence");
+		switch_event_fire(&event);
+	}
 
-    switch_safe_free(dup_to); 
-} 
- 
-static void send_presence(switch_event_types_t id) 
-{ 
-    switch_xml_t cxml, cfg, advertise, room; 
+	switch_safe_free(dup_to);
+}
 
-    /* Open the config from the xml registry */ 
-    if (!(cxml = switch_xml_open_cfg(global_cf_name, &cfg, "presence"))) { 
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", global_cf_name); 
-        goto done; 
-    } 
+static void send_presence(switch_event_types_t id)
+{
+	switch_xml_t cxml, cfg, advertise, room;
 
-    if ((advertise = switch_xml_child(cfg, "advertise"))) { 
-        for (room = switch_xml_child(advertise, "room"); room; room = room->next) { 
-            char *name = (char *) switch_xml_attr_soft(room, "name"); 
-            char *status = (char *) switch_xml_attr_soft(room, "status"); 
-            switch_event_t *event; 
+	/* Open the config from the xml registry */
+	if (!(cxml = switch_xml_open_cfg(global_cf_name, &cfg, "presence"))) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", global_cf_name);
+		goto done;
+	}
 
-            if (name && switch_event_create(&event, id) == SWITCH_STATUS_SUCCESS) { 
-                switch_event_add_header(event, SWITCH_STACK_BOTTOM, "proto", CONF_CHAT_PROTO); 
-                switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", "%s", name); 
-                switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s", name); 
-                switch_event_add_header(event, SWITCH_STACK_BOTTOM, "status", "%s", status ? status : "Available"); 
-                switch_event_add_header(event, SWITCH_STACK_BOTTOM, "rpid", "idle"); 
-                switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_type", "presence"); 
-                switch_event_fire(&event); 
-            } 
-        } 
-    } 
+	if ((advertise = switch_xml_child(cfg, "advertise"))) {
+		for (room = switch_xml_child(advertise, "room"); room; room = room->next) {
+			char *name = (char *) switch_xml_attr_soft(room, "name");
+			char *status = (char *) switch_xml_attr_soft(room, "status");
+			switch_event_t *event;
 
- done: 
-    /* Release the config registry handle */ 
-    if (cxml) { 
-        switch_xml_free(cxml); 
-        cxml = NULL; 
-    } 
-} 
+			if (name && switch_event_create(&event, id) == SWITCH_STATUS_SUCCESS) {
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "proto", CONF_CHAT_PROTO);
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", "%s", name);
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s", name);
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "status", "%s", status ? status : "Available");
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "rpid", "idle");
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_type", "presence");
+				switch_event_fire(&event);
+			}
+		}
+	}
+
+  done:
+	/* Release the config registry handle */
+	if (cxml) {
+		switch_xml_free(cxml);
+		cxml = NULL;
+	}
+}
 
 /* Called by FreeSWITCH when the module loads */
-SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
+													   char *filename)
 {
-    uint32_t i;
-    size_t nl, ol = 0;
-    char *p = NULL;
-    switch_status_t status = SWITCH_STATUS_SUCCESS;
+	uint32_t i;
+	size_t nl, ol = 0;
+	char *p = NULL;
+	switch_status_t status = SWITCH_STATUS_SUCCESS;
 
-    memset(&globals, 0, sizeof(globals));
+	memset(&globals, 0, sizeof(globals));
 
-    /* build api interface help ".syntax" field string */
-    p = strdup("");
-    for (i = 0; i= 1) {
 			switch_ivr_detect_speech_load_grammar(session, argv[1], argv[2]);
 		} else if (!strcasecmp(argv[0], "nogrammar")) {
@@ -58,16 +59,17 @@ static void detect_speech_function(switch_core_session_t *session, char *data)
 			switch_ivr_detect_speech(session, argv[0], argv[1], argv[2], argv[3], NULL);
 		}
 	} else {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Usage: %s\n", detect_speech_application_interface.syntax);
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Usage: %s\n",
+						  detect_speech_application_interface.syntax);
 	}
-	
+
 }
 
 static void ring_ready_function(switch_core_session_t *session, char *data)
 {
 	switch_channel_t *channel;
 	channel = switch_core_session_get_channel(session);
-    assert(channel != NULL);
+	assert(channel != NULL);
 	switch_channel_ring_ready(channel);
 }
 
@@ -84,7 +86,7 @@ static void queue_dtmf_function(switch_core_session_t *session, char *data)
 static void transfer_function(switch_core_session_t *session, char *data)
 {
 	int argc;
-	char *argv[4] = {0};
+	char *argv[4] = { 0 };
 	char *mydata;
 
 	if (data && (mydata = switch_core_session_strdup(session, data))) {
@@ -99,15 +101,15 @@ static void transfer_function(switch_core_session_t *session, char *data)
 static void sched_transfer_function(switch_core_session_t *session, char *data)
 {
 	int argc;
-	char *argv[4] = {0};
+	char *argv[4] = { 0 };
 	char *mydata;
-	
+
 	if (data && (mydata = switch_core_session_strdup(session, data))) {
 		if ((argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) >= 2) {
 			time_t when;
 
 			if (*argv[0] == '+') {
-				when = time (NULL) + atol(argv[0] + 1);
+				when = time(NULL) + atol(argv[0] + 1);
 			} else {
 				when = atol(argv[0]);
 			}
@@ -122,7 +124,7 @@ static void sched_transfer_function(switch_core_session_t *session, char *data)
 static void sched_hangup_function(switch_core_session_t *session, char *data)
 {
 	int argc;
-	char *argv[5] = {0};
+	char *argv[5] = { 0 };
 	char *mydata;
 
 	if (data && (mydata = switch_core_session_strdup(session, data))) {
@@ -132,11 +134,11 @@ static void sched_hangup_function(switch_core_session_t *session, char *data)
 			switch_bool_t bleg = SWITCH_FALSE;
 
 			if (*argv[0] == '+') {
-				when = time (NULL) + atol(argv[0] + 1);
+				when = time(NULL) + atol(argv[0] + 1);
 			} else {
 				when = atol(argv[0]);
 			}
-			
+
 			if (argv[1]) {
 				cause = switch_channel_str2cause(argv[1]);
 			}
@@ -156,20 +158,20 @@ static void sched_hangup_function(switch_core_session_t *session, char *data)
 static void sched_broadcast_function(switch_core_session_t *session, char *data)
 {
 	int argc;
-	char *argv[6] = {0};
+	char *argv[6] = { 0 };
 	char *mydata;
 
 	if (data && (mydata = switch_core_session_strdup(session, data))) {
 		if ((argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) >= 2) {
 			time_t when;
 			switch_media_flag_t flags = SMF_NONE;
-			
+
 			if (*argv[0] == '+') {
-				when = time (NULL) + atol(argv[0] + 1);
+				when = time(NULL) + atol(argv[0] + 1);
 			} else {
 				when = atol(argv[0]);
 			}
-			
+
 			if (argv[2]) {
 				if (!strcmp(argv[2], "both")) {
 					flags |= (SMF_ECHO_ALEG | SMF_ECHO_BLEG);
@@ -207,26 +209,26 @@ static void eval_function(switch_core_session_t *session, char *data)
 
 static void phrase_function(switch_core_session_t *session, char *data)
 {
-    switch_channel_t *channel;
-    char *mydata = NULL;
+	switch_channel_t *channel;
+	char *mydata = NULL;
 
-    channel = switch_core_session_get_channel(session);
-    assert(channel != NULL);
-    
-    if ((mydata = switch_core_session_strdup(session, data))) {
-        char *lang;
-        char *macro = mydata;
-        char *mdata = NULL;
+	channel = switch_core_session_get_channel(session);
+	assert(channel != NULL);
 
-        if ((mdata = strchr(macro, ','))) {
-            *mdata++ = '\0';
-        }
+	if ((mydata = switch_core_session_strdup(session, data))) {
+		char *lang;
+		char *macro = mydata;
+		char *mdata = NULL;
 
-        lang = switch_channel_get_variable(channel, "language");
-        
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Execute %s(%s) lang %s\n", macro, mdata, lang);
-        switch_ivr_phrase_macro(session, macro, mdata, lang, NULL);
-    }
+		if ((mdata = strchr(macro, ','))) {
+			*mdata++ = '\0';
+		}
+
+		lang = switch_channel_get_variable(channel, "language");
+
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Execute %s(%s) lang %s\n", macro, mdata, lang);
+		switch_ivr_phrase_macro(session, macro, mdata, lang, NULL);
+	}
 
 }
 
@@ -234,14 +236,14 @@ static void phrase_function(switch_core_session_t *session, char *data)
 static void hangup_function(switch_core_session_t *session, char *data)
 {
 	switch_channel_t *channel;
-    switch_call_cause_t cause = SWITCH_CAUSE_NORMAL_CLEARING;
+	switch_call_cause_t cause = SWITCH_CAUSE_NORMAL_CLEARING;
 
 	channel = switch_core_session_get_channel(session);
-    assert(channel != NULL);
+	assert(channel != NULL);
 
-    if (!switch_strlen_zero((char *) data)) {
-        cause = switch_channel_str2cause((char *) data);
-    }
+	if (!switch_strlen_zero((char *) data)) {
+		cause = switch_channel_str2cause((char *) data);
+	}
 
 	switch_channel_hangup(channel, cause);
 }
@@ -251,7 +253,7 @@ static void answer_function(switch_core_session_t *session, char *data)
 	switch_channel_t *channel;
 	channel = switch_core_session_get_channel(session);
 
-    assert(channel != NULL);
+	assert(channel != NULL);
 	switch_channel_answer(channel);
 }
 
@@ -260,18 +262,18 @@ static void pre_answer_function(switch_core_session_t *session, char *data)
 	switch_channel_t *channel;
 	channel = switch_core_session_get_channel(session);
 
-    assert(channel != NULL);
+	assert(channel != NULL);
 	switch_channel_pre_answer(channel);
 }
 
 static void redirect_function(switch_core_session_t *session, char *data)
 {
-    switch_core_session_message_t msg = {0};
+	switch_core_session_message_t msg = { 0 };
 
-    /* Tell the channel to redirect */
+	/* Tell the channel to redirect */
 	msg.from = __FILE__;
 	msg.string_arg = data;
-    msg.message_id = SWITCH_MESSAGE_INDICATE_REDIRECT;
+	msg.message_id = SWITCH_MESSAGE_INDICATE_REDIRECT;
 	switch_core_session_receive_message(session, &msg);
 
 }
@@ -283,7 +285,7 @@ static void set_function(switch_core_session_t *session, char *data)
 	char *var, *val = NULL;
 
 	channel = switch_core_session_get_channel(session);
-    assert(channel != NULL);
+	assert(channel != NULL);
 
 	if (switch_strlen_zero(data)) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No variable name specified.\n");
@@ -293,11 +295,11 @@ static void set_function(switch_core_session_t *session, char *data)
 
 		if (val) {
 			*val++ = '\0';
-            if (switch_strlen_zero(val)) {
-                val = NULL;
-            }
+			if (switch_strlen_zero(val)) {
+				val = NULL;
+			}
 		}
-		
+
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "SET [%s]=[%s]\n", var, val ? val : "UNDEF");
 		switch_channel_set_variable(channel, var, val);
 	}
@@ -309,7 +311,7 @@ static void export_function(switch_core_session_t *session, char *data)
 	char *exports, *new_exports = NULL, *new_exports_d = NULL, *var, *val = NULL;
 
 	channel = switch_core_session_get_channel(session);
-    assert(channel != NULL);
+	assert(channel != NULL);
 
 	if (switch_strlen_zero(data)) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No variable name specified.\n");
@@ -320,11 +322,11 @@ static void export_function(switch_core_session_t *session, char *data)
 
 		if (val) {
 			*val++ = '\0';
-            if (switch_strlen_zero(val)) {
-                val = NULL;
-            }
+			if (switch_strlen_zero(val)) {
+				val = NULL;
+			}
 		}
-		
+
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "EXPORT [%s]=[%s]\n", var, val ? val : "UNDEF");
 		switch_channel_set_variable(channel, var, val);
 
@@ -346,7 +348,7 @@ static void unset_function(switch_core_session_t *session, char *data)
 	switch_channel_t *channel;
 
 	channel = switch_core_session_get_channel(session);
-    assert(channel != NULL);
+	assert(channel != NULL);
 
 	if (switch_strlen_zero(data)) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No variable name specified.\n");
@@ -359,43 +361,43 @@ static void unset_function(switch_core_session_t *session, char *data)
 static void log_function(switch_core_session_t *session, char *data)
 {
 	switch_channel_t *channel;
-    char *level, *log_str;
+	char *level, *log_str;
 
 	channel = switch_core_session_get_channel(session);
-    assert(channel != NULL);
+	assert(channel != NULL);
 
-    if (data && (level = strdup(data))) {
-        switch_event_types_t etype = SWITCH_LOG_DEBUG;
-        
-        if ((log_str = strchr(level, ' '))) {
-            *log_str++ = '\0';
-            switch_name_event(level, &etype);
-        } else {
-            log_str = level;
-        }
+	if (data && (level = strdup(data))) {
+		switch_event_types_t etype = SWITCH_LOG_DEBUG;
 
-        switch_log_printf(SWITCH_CHANNEL_LOG, etype, "%s\n", log_str);
-        switch_safe_free(level);
-    }
+		if ((log_str = strchr(level, ' '))) {
+			*log_str++ = '\0';
+			switch_name_event(level, &etype);
+		} else {
+			log_str = level;
+		}
+
+		switch_log_printf(SWITCH_CHANNEL_LOG, etype, "%s\n", log_str);
+		switch_safe_free(level);
+	}
 }
 
 
 static void info_function(switch_core_session_t *session, char *data)
 {
 	switch_channel_t *channel;
-    switch_event_t *event;
-    char *buf;
+	switch_event_t *event;
+	char *buf;
 
 	channel = switch_core_session_get_channel(session);
-    assert(channel != NULL);
+	assert(channel != NULL);
+
+	if (switch_event_create(&event, SWITCH_EVENT_MESSAGE) == SWITCH_STATUS_SUCCESS) {
+		switch_channel_event_set_data(channel, event);
+		switch_event_serialize(event, &buf);
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "CHANNEL_DATA:\n%s\n", buf);
+		switch_event_destroy(&event);
+	}
 
-    if (switch_event_create(&event, SWITCH_EVENT_MESSAGE) == SWITCH_STATUS_SUCCESS) {
-        switch_channel_event_set_data(channel, event);
-        switch_event_serialize(event, &buf);
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "CHANNEL_DATA:\n%s\n", buf);
-        switch_event_destroy(&event);
-    }
-    
 }
 
 static void privacy_function(switch_core_session_t *session, char *data)
@@ -405,8 +407,8 @@ static void privacy_function(switch_core_session_t *session, char *data)
 	char *arg;
 
 	channel = switch_core_session_get_channel(session);
-    	assert(channel != NULL);		
-	
+	assert(channel != NULL);
+
 	caller_profile = switch_channel_get_caller_profile(channel);
 
 	if (switch_strlen_zero(data)) {
@@ -416,7 +418,7 @@ static void privacy_function(switch_core_session_t *session, char *data)
 
 		switch_set_flag(caller_profile, SWITCH_CPF_SCREEN);
 
-		if(!strcasecmp(arg, "no")) {
+		if (!strcasecmp(arg, "no")) {
 			switch_clear_flag(caller_profile, SWITCH_CPF_HIDE_NAME);
 			switch_clear_flag(caller_profile, SWITCH_CPF_HIDE_NUMBER);
 		} else if (!strcasecmp(arg, "yes")) {
@@ -428,7 +430,8 @@ static void privacy_function(switch_core_session_t *session, char *data)
 		} else if (!strcasecmp(arg, "number")) {
 			switch_set_flag(caller_profile, SWITCH_CPF_HIDE_NUMBER);
 		} else {
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "INVALID privacy mode specified. Use a valid mode [no|yes|name|full|number].\n");
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+							  "INVALID privacy mode specified. Use a valid mode [no|yes|name|full|number].\n");
 		}
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Set Privacy to %s [%d]\n", arg, caller_profile->flags);
 	}
@@ -440,7 +443,8 @@ static void strftime_function(switch_core_session_t *session, char *data)
 	int argc;
 	char *lbuf;
 
-	if (data && (lbuf = switch_core_session_strdup(session, data)) && (argc = switch_separate_string(lbuf, '=', argv, (sizeof(argv) / sizeof(argv[0])))) > 1) {
+	if (data && (lbuf = switch_core_session_strdup(session, data))
+		&& (argc = switch_separate_string(lbuf, '=', argv, (sizeof(argv) / sizeof(argv[0])))) > 1) {
 		switch_size_t retsize;
 		switch_time_exp_t tm;
 		char date[80] = "";
@@ -459,26 +463,26 @@ 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)
 {
-    switch_time_t out;
-    
-    if (switch_strlen_zero(data)) {
-        out = switch_time_now();
-    } else {
-        out = switch_str_time(data);
-    }
+	switch_time_t out;
 
-    stream->write_function(stream, "%d", (uint32_t)((out) / (int64_t)(1000000)) );
+	if (switch_strlen_zero(data)) {
+		out = switch_time_now();
+	} else {
+		out = switch_str_time(data);
+	}
+
+	stream->write_function(stream, "%d", (uint32_t) ((out) / (int64_t) (1000000)));
 
 	return SWITCH_STATUS_SUCCESS;
 }
 
 static switch_status_t strftime_api_function(char *fmt, switch_core_session_t *session, switch_stream_handle_t *stream)
 {
-	
+
 	switch_size_t retsize;
 	switch_time_exp_t tm;
 	char date[80] = "";
-	
+
 	switch_time_exp_lt(&tm, switch_time_now());
 	switch_strftime(date, &retsize, sizeof(date), fmt ? fmt : "%Y-%m-%d %T", &tm);
 	stream->write_function(stream, "%s", date);
@@ -493,14 +497,15 @@ static switch_status_t presence_api_function(char *fmt, switch_core_session_t *s
 	int argc = 0;
 	switch_event_types_t type = SWITCH_EVENT_PRESENCE_IN;
 
-	if (fmt && (lbuf = strdup(fmt)) && (argc = switch_separate_string(lbuf, '|', argv, (sizeof(argv) / sizeof(argv[0])))) > 0) {
+	if (fmt && (lbuf = strdup(fmt))
+		&& (argc = switch_separate_string(lbuf, '|', argv, (sizeof(argv) / sizeof(argv[0])))) > 0) {
 		if (!strcasecmp(argv[0], "out")) {
 			type = SWITCH_EVENT_PRESENCE_OUT;
 		} else if (argc != 4) {
 			stream->write_function(stream, "Invalid");
 			return SWITCH_STATUS_SUCCESS;
 		}
-		
+
 		if (switch_event_create(&event, type) == SWITCH_STATUS_SUCCESS) {
 			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "proto", "dp");
 			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", "%s", __FILE__);
@@ -527,9 +532,10 @@ static switch_status_t chat_api_function(char *fmt, switch_core_session_t *sessi
 	char *lbuf, *argv[4];
 	int argc = 0;
 
-	if (fmt && (lbuf = strdup(fmt)) && (argc = switch_separate_string(lbuf, '|', argv, (sizeof(argv) / sizeof(argv[0])))) == 4) {
+	if (fmt && (lbuf = strdup(fmt))
+		&& (argc = switch_separate_string(lbuf, '|', argv, (sizeof(argv) / sizeof(argv[0])))) == 4) {
 		switch_chat_interface_t *ci;
-		
+
 		if ((ci = switch_loadable_module_get_chat_interface(argv[0]))) {
 			ci->chat_send("dp", argv[1], argv[2], "", argv[3], "");
 			stream->write_function(stream, "Sent");
@@ -539,7 +545,7 @@ static switch_status_t chat_api_function(char *fmt, switch_core_session_t *sessi
 	} else {
 		stream->write_function(stream, "Invalid");
 	}
-	
+
 	return SWITCH_STATUS_SUCCESS;
 }
 
@@ -551,7 +557,7 @@ static switch_ivr_action_t menu_handler(switch_ivr_menu_t *menu, char *param, ch
 	switch_ivr_action_t action = SWITCH_IVR_ACTION_NOOP;
 
 	if (param != NULL) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "menu_handler '%s'\n",param);
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "menu_handler '%s'\n", param);
 	}
 
 	return action;
@@ -563,7 +569,7 @@ static void ivr_application_function(switch_core_session_t *session, char *data)
 	switch_channel_t *channel = switch_core_session_get_channel(session);
 	char *params;
 
-	if (channel && data && (params = switch_core_session_strdup(session,data))) {
+	if (channel && data && (params = switch_core_session_strdup(session, data))) {
 		switch_xml_t cxml = NULL, cfg = NULL, xml_menus = NULL, xml_menu = NULL;
 
 		// Open the config from the xml registry
@@ -577,16 +583,17 @@ static void ivr_application_function(switch_core_session_t *session, char *data)
 					switch_ivr_menu_t *menu_stack = NULL;
 
 					// build a menu tree and execute it
-					if (switch_ivr_menu_stack_xml_init(&xml_ctx,NULL) == SWITCH_STATUS_SUCCESS
+					if (switch_ivr_menu_stack_xml_init(&xml_ctx, NULL) == SWITCH_STATUS_SUCCESS
 #ifdef _TEST_CALLBACK_
-						&& switch_ivr_menu_stack_xml_add_custom(xml_ctx, "custom", &menu_handler) == SWITCH_STATUS_SUCCESS
+						&& switch_ivr_menu_stack_xml_add_custom(xml_ctx, "custom",
+																&menu_handler) == SWITCH_STATUS_SUCCESS
 #endif
-						&& switch_ivr_menu_stack_xml_build(xml_ctx,&menu_stack,xml_menus,xml_menu) == SWITCH_STATUS_SUCCESS)
-					{
+						&& switch_ivr_menu_stack_xml_build(xml_ctx, &menu_stack, xml_menus,
+														   xml_menu) == SWITCH_STATUS_SUCCESS) {
 						switch_xml_free(cxml);
 						cxml = NULL;
 						switch_channel_pre_answer(channel);
-						switch_ivr_menu_execute(session,menu_stack,params,NULL);
+						switch_ivr_menu_execute(session, menu_stack, params, NULL);
 						switch_ivr_menu_stack_free(menu_stack);
 					} else {
 						switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to create menu '%s'\n", params);
@@ -670,7 +677,7 @@ static switch_application_interface_t sched_hangup_application_interface = {
 
 static const switch_application_interface_t queuedtmf_application_interface = {
 	/*.interface_name */ "queue_dtmf",
-	/*.application_function */ queue_dtmf_function,	
+	/*.application_function */ queue_dtmf_function,
 	/* long_desc */ "Queue dtmf to be sent from a session",
 	/* short_desc */ "Queue dtmf to be sent",
 	/* syntax */ "",
@@ -680,7 +687,7 @@ static const switch_application_interface_t queuedtmf_application_interface = {
 
 static const switch_application_interface_t redirect_application_interface = {
 	/*.interface_name */ "redirect",
-	/*.application_function */ redirect_function,	
+	/*.application_function */ redirect_function,
 	/* long_desc */ "Send a redirect message to a session.",
 	/* short_desc */ "Send session redirect",
 	/* syntax */ "",
@@ -690,7 +697,7 @@ static const switch_application_interface_t redirect_application_interface = {
 
 static const switch_application_interface_t ivr_application_interface = {
 	/*.interface_name */ "ivr",
-	/*.application_function */ ivr_application_function,	
+	/*.application_function */ ivr_application_function,
 	/* long_desc */ "Run an ivr menu.",
 	/* short_desc */ "Run an ivr menu",
 	/* syntax */ "",
@@ -700,7 +707,7 @@ static const switch_application_interface_t ivr_application_interface = {
 
 static const switch_application_interface_t detect_speech_application_interface = {
 	/*.interface_name */ "detect_speech",
-	/*.application_function */ detect_speech_function,	
+	/*.application_function */ detect_speech_function,
 	/* long_desc */ "Detect speech on a channel.",
 	/* short_desc */ "Detect speech",
 	/* syntax */ "   [] OR grammar  [] OR pause OR resume",
@@ -777,7 +784,6 @@ static const switch_application_interface_t hangup_application_interface = {
 	/* syntax */ "[]",
 	/* flags */ SAF_SUPPORT_NOMEDIA,
 	/*.next */ &log_application_interface
-
 };
 
 static const switch_application_interface_t answer_application_interface = {
@@ -788,7 +794,6 @@ static const switch_application_interface_t answer_application_interface = {
 	/* syntax */ "",
 	/* flags */ SAF_SUPPORT_NOMEDIA,
 	/*.next */ &hangup_application_interface
-
 };
 
 static const switch_application_interface_t pre_answer_application_interface = {
@@ -799,7 +804,6 @@ static const switch_application_interface_t pre_answer_application_interface = {
 	/* syntax */ "",
 	/* flags */ SAF_SUPPORT_NOMEDIA,
 	/*.next */ &answer_application_interface
-
 };
 
 static const switch_application_interface_t eval_application_interface = {
@@ -810,7 +814,6 @@ static const switch_application_interface_t eval_application_interface = {
 	/* syntax */ "",
 	/* flags */ SAF_SUPPORT_NOMEDIA,
 	/*.next */ &pre_answer_application_interface
-
 };
 
 static const switch_application_interface_t phrase_application_interface = {
@@ -821,7 +824,6 @@ static const switch_application_interface_t phrase_application_interface = {
 	/* syntax */ ",",
 	/* flags */ SAF_NONE,
 	/*.next */ &eval_application_interface
-
 };
 
 static const switch_application_interface_t strftime_application_interface = {
@@ -832,13 +834,13 @@ static const switch_application_interface_t strftime_application_interface = {
 	/* syntax */ NULL,
 	/* flags */ SAF_SUPPORT_NOMEDIA,
 	/*.next */ &phrase_application_interface
-
 };
 
 static const switch_application_interface_t sleep_application_interface = {
 	/*.interface_name */ "sleep",
 	/*.application_function */ sleep_function,
-	/* long_desc */ "Pause the channel for a given number of milliseconds, consuming the audio for that period of time.",
+	/* long_desc */
+	"Pause the channel for a given number of milliseconds, consuming the audio for that period of time.",
 	/* short_desc */ "Pause a channel",
 	/* syntax */ "",
 	/* flags */ SAF_NONE,
@@ -875,7 +877,8 @@ static const switch_loadable_module_interface_t mod_dptools_module_interface = {
 	/*.api_interface */ &presence_api_interface
 };
 
-SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
+													   char *filename)
 {
 
 	/* connect my internal structure to the blank pointer passed to me */
diff --git a/src/mod/applications/mod_echo/mod_echo.c b/src/mod/applications/mod_echo/mod_echo.c
index 47f06db920..7e455777ff 100644
--- a/src/mod/applications/mod_echo/mod_echo.c
+++ b/src/mod/applications/mod_echo/mod_echo.c
@@ -38,7 +38,7 @@ static void echo_function(switch_core_session_t *session, char *data)
 	switch_channel_t *channel;
 
 	channel = switch_core_session_get_channel(session);
-	assert(channel != NULL);	
+	assert(channel != NULL);
 
 	switch_channel_answer(channel);
 
@@ -67,7 +67,8 @@ static switch_loadable_module_interface_t echo_module_interface = {
 	/*.directory_interface */ NULL
 };
 
-SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
+													   char *filename)
 {
 	/* connect my internal structure to the blank pointer passed to me */
 	*module_interface = &echo_module_interface;
diff --git a/src/mod/applications/mod_enum/mod_enum.c b/src/mod/applications/mod_enum/mod_enum.c
index 629f06ad4b..e845d7015a 100644
--- a/src/mod/applications/mod_enum/mod_enum.c
+++ b/src/mod/applications/mod_enum/mod_enum.c
@@ -48,10 +48,10 @@ struct enum_record {
 typedef struct enum_record enum_record_t;
 
 struct query {
-	const char *name;		/* original query string */
+	const char *name;			/* original query string */
 	char *number;
 	unsigned char dn[DNS_MAXDN];
-	enum dns_type qtyp;		/* type of the query */
+	enum dns_type qtyp;			/* type of the query */
 	enum_record_t *results;
 };
 typedef struct query enum_query_t;
@@ -77,7 +77,7 @@ static struct {
 SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_root, globals.root)
 
 
-static void add_route(char *service, char *regex, char *replace)
+	 static void add_route(char *service, char *regex, char *replace)
 {
 	enum_route_t *route, *rp;
 
@@ -86,11 +86,11 @@ static void add_route(char *service, char *regex, char *replace)
 	}
 
 	memset(route, 0, sizeof(*route));
-	
+
 	route->service = strdup(service);
 	route->regex = strdup(regex);
 	route->replace = strdup(replace);
-	
+
 	if (!globals.route_order) {
 		globals.route_order = route;
 	} else {
@@ -107,8 +107,8 @@ static void add_route(char *service, char *regex, char *replace)
 static switch_status_t load_config(void)
 {
 	char *cf = "enum.conf";
-    switch_xml_t cfg, xml = NULL, param, settings, route, routes;
-    switch_status_t status = SWITCH_STATUS_SUCCESS;
+	switch_xml_t cfg, xml = NULL, param, settings, route, routes;
+	switch_status_t status = SWITCH_STATUS_SUCCESS;
 
 	memset(&globals, 0, sizeof(globals));
 	if (switch_core_new_memory_pool(&globals.pool) != SWITCH_STATUS_SUCCESS) {
@@ -119,39 +119,39 @@ static switch_status_t load_config(void)
 
 	switch_core_hash_init(&globals.routes, globals.pool);
 
-    if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
-        status = SWITCH_STATUS_FALSE;
-        goto done;
-    }
+	if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
+		status = SWITCH_STATUS_FALSE;
+		goto done;
+	}
 
-    if ((settings = switch_xml_child(cfg, "settings"))) {
-        for (param = switch_xml_child(settings, "param"); param; param = param->next) {
-            char *var = (char *) switch_xml_attr_soft(param, "name");
-            char *val = (char *) switch_xml_attr_soft(param, "value");
-            if (!strcasecmp(var, "default-root")) {
+	if ((settings = switch_xml_child(cfg, "settings"))) {
+		for (param = switch_xml_child(settings, "param"); param; param = param->next) {
+			char *var = (char *) switch_xml_attr_soft(param, "name");
+			char *val = (char *) switch_xml_attr_soft(param, "value");
+			if (!strcasecmp(var, "default-root")) {
 				set_global_root(val);
-            } else if (!strcasecmp(var, "log-level-trace")) {
-				
-            }
-        }
-    }
+			} else if (!strcasecmp(var, "log-level-trace")) {
 
-    if ((routes = switch_xml_child(cfg, "routes"))) {
-        for (route = switch_xml_child(routes, "route"); route; route = route->next) {
-            char *service = (char *) switch_xml_attr_soft(route, "service");
-            char *regex = (char *) switch_xml_attr_soft(route, "regex");
-            char *replace = (char *) switch_xml_attr_soft(route, "replace");
+			}
+		}
+	}
+
+	if ((routes = switch_xml_child(cfg, "routes"))) {
+		for (route = switch_xml_child(routes, "route"); route; route = route->next) {
+			char *service = (char *) switch_xml_attr_soft(route, "service");
+			char *regex = (char *) switch_xml_attr_soft(route, "regex");
+			char *replace = (char *) switch_xml_attr_soft(route, "replace");
 
 			if (service && regex && replace) {
 				add_route(service, regex, replace);
 			} else {
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Route!\n");
 			}
-        }
-    }
-	
- done:
+		}
+	}
+
+  done:
 
 	if (xml) {
 		switch_xml_free(xml);
@@ -168,20 +168,20 @@ static switch_status_t load_config(void)
 
 static char *reverse_number(char *in, char *root)
 {
-    switch_size_t len;
-    char *out = NULL;
-    char *y,*z;
+	switch_size_t len;
+	char *out = NULL;
+	char *y, *z;
 
-    if (!(in && root)) {
-        return NULL;
-    }
+	if (!(in && root)) {
+		return NULL;
+	}
 
-    len = (strlen(in) * 2) + strlen(root) + 1;
-    if ((out = malloc(len))) {
-        memset(out, 0, len);
+	len = (strlen(in) * 2) + strlen(root) + 1;
+	if ((out = malloc(len))) {
+		memset(out, 0, len);
 
-        z = out;
-        for(y = in + (strlen(in) - 1); y; y--) {
+		z = out;
+		for (y = in + (strlen(in) - 1); y; y--) {
 			if (*y > 47 && *y < 58) {
 				*z++ = *y;
 				*z++ = '.';
@@ -189,21 +189,22 @@ static char *reverse_number(char *in, char *root)
 			if (y == in) {
 				break;
 			}
-        }
-        strcat(z, root);
-    }
+		}
+		strcat(z, root);
+	}
 
 	return out;
 }
 
-static void dnserror(enum_query_t *q, int errnum) {
+static void dnserror(enum_query_t * q, int errnum)
+{
 
-    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "unable to lookup %s record for %s: %s\n",
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "unable to lookup %s record for %s: %s\n",
 					  dns_typename(q->qtyp), dns_dntosp(q->dn), dns_strerror(errnum));
 }
 
 
-static void add_result(enum_query_t *q, int order, int preference, char *service, char *route)
+static void add_result(enum_query_t * q, int order, int preference, char *service, char *route)
 {
 	enum_record_t *new_result, *rp, *prev = NULL;
 
@@ -213,12 +214,12 @@ static void add_result(enum_query_t *q, int order, int preference, char *service
 	}
 
 	memset(new_result, 0, sizeof(*new_result));
-	
+
 	new_result->order = order;
 	new_result->preference = preference;
 	new_result->service = strdup(service);
 	new_result->route = strdup(route);
-	
+
 
 	if (!q->results) {
 		q->results = new_result;
@@ -227,12 +228,12 @@ static void add_result(enum_query_t *q, int order, int preference, char *service
 
 	rp = q->results;
 
-	while(rp && strcmp(rp->service, new_result->service)) {
+	while (rp && strcmp(rp->service, new_result->service)) {
 		prev = rp;
 		rp = rp->next;
 	}
 
-	while(rp && !strcmp(rp->service, new_result->service) && new_result->order > rp->order) {
+	while (rp && !strcmp(rp->service, new_result->service) && new_result->order > rp->order) {
 		prev = rp;
 		rp = rp->next;
 	}
@@ -241,7 +242,7 @@ static void add_result(enum_query_t *q, int order, int preference, char *service
 		prev = rp;
 		rp = rp->next;
 	}
-	
+
 	if (prev) {
 		new_result->next = rp;
 		prev->next = new_result;
@@ -252,11 +253,11 @@ static void add_result(enum_query_t *q, int order, int preference, char *service
 }
 
 
-static void free_results(enum_record_t **results) 
+static void free_results(enum_record_t ** results)
 {
 	enum_record_t *fp, *rp;
 
-	for(rp = *results; rp;) {
+	for (rp = *results; rp;) {
 		fp = rp;
 		rp = rp->next;
 		switch_safe_free(fp->service);
@@ -266,7 +267,8 @@ static void free_results(enum_record_t **results)
 	*results = NULL;
 }
 
-static void parse_rr(const struct dns_parse *p, enum_query_t *q, struct dns_rr *rr) {
+static void parse_rr(const struct dns_parse *p, enum_query_t * q, struct dns_rr *rr)
+{
 	const unsigned char *pkt = p->dnsp_pkt;
 	const unsigned char *end = p->dnsp_end;
 	const unsigned char *dptr = rr->dnsrr_dptr;
@@ -282,25 +284,26 @@ static void parse_rr(const struct dns_parse *p, enum_query_t *q, struct dns_rr *
 	char *regex = NULL;
 	char *replace = NULL;
 	int argc = 0;
-	char *argv[4] = {0};
+	char *argv[4] = { 0 };
 	int leap;
 
-	switch(rr->dnsrr_typ) {
+	switch (rr->dnsrr_typ) {
 
-	case DNS_T_NAPTR:	/* prio weight port targetDN */
+	case DNS_T_NAPTR:			/* prio weight port targetDN */
 		c = dptr;
 		c += 2 + 2 + 2;
-		if (dns_getdn(pkt, &c, end, dn, DNS_MAXDN) <= 0 || c != dend) goto xperr;
+		if (dns_getdn(pkt, &c, end, dn, DNS_MAXDN) <= 0 || c != dend)
+			goto xperr;
 		c = dptr;
-		
+
 		leap = *dn;
-		nme = (char *)dn+1;
+		nme = (char *) dn + 1;
 
-		order = dns_get16(c+0);
-		preference = dns_get16(c+2);
-		flags = (char) dns_get16(c+4);		
+		order = dns_get16(c + 0);
+		preference = dns_get16(c + 2);
+		flags = (char) dns_get16(c + 4);
 
-		if ((ptr = nme+leap)) {
+		if ((ptr = nme + leap)) {
 			service = nme;
 			*ptr++ = '\0';
 			argc = switch_separate_string(ptr, '!', argv, (sizeof(argv) / sizeof(argv[0])));
@@ -308,7 +311,7 @@ static void parse_rr(const struct dns_parse *p, enum_query_t *q, struct dns_rr *
 			replace = argv[2];
 		}
 
-		for(ptr = replace; ptr && *ptr; ptr++) {
+		for (ptr = replace; ptr && *ptr; ptr++) {
 			if (*ptr == '\\') {
 				*ptr = '$';
 			}
@@ -326,15 +329,17 @@ static void parse_rr(const struct dns_parse *p, enum_query_t *q, struct dns_rr *
 
 			if ((proceed = switch_regex_perform(q->number, regex, &re, ovector, sizeof(ovector) / sizeof(ovector[0])))) {
 				if (strchr(regex, '(')) {
-					switch_perform_substitution(re, proceed, replace, q->number, substituted, sizeof(substituted), ovector);
+					switch_perform_substitution(re, proceed, replace, q->number, substituted, sizeof(substituted),
+												ovector);
 					uri = substituted;
 				} else {
 					uri = replace;
 				}
 
-				if ((route = (enum_route_t *) switch_core_hash_find(globals.routes, service))){
+				if ((route = (enum_route_t *) switch_core_hash_find(globals.routes, service))) {
 					switch_regex_safe_free(re);
-					if ((proceed = switch_regex_perform(uri, route->regex, &re, ovector, sizeof(ovector) / sizeof(ovector[0])))) {
+					if ((proceed =
+						 switch_regex_perform(uri, route->regex, &re, ovector, sizeof(ovector) / sizeof(ovector[0])))) {
 						if (strchr(route->regex, '(')) {
 							switch_perform_substitution(re, proceed, route->replace, uri, rbuf, sizeof(rbuf), ovector);
 							uri = rbuf;
@@ -343,7 +348,7 @@ static void parse_rr(const struct dns_parse *p, enum_query_t *q, struct dns_rr *
 						}
 					}
 				}
-				
+
 				add_result(q, order, preference, service, uri);
 			}
 
@@ -358,12 +363,13 @@ static void parse_rr(const struct dns_parse *p, enum_query_t *q, struct dns_rr *
 
 	return;
 
- xperr:
+  xperr:
 	//printf("\n");
 	return;
 }
 
-static void dnscb(struct dns_ctx *ctx, void *result, void *data) {
+static void dnscb(struct dns_ctx *ctx, void *result, void *data)
+{
 	int r = dns_status(ctx);
 	enum_query_t *q = data;
 	struct dns_parse p;
@@ -375,25 +381,25 @@ static void dnscb(struct dns_ctx *ctx, void *result, void *data) {
 		dnserror(q, r);
 		return;
 	}
-	pkt = result; end = pkt + r; cur = dns_payload(pkt);
+	pkt = result;
+	end = pkt + r;
+	cur = dns_payload(pkt);
 	dns_getdn(pkt, &cur, end, dn, sizeof(dn));
 	dns_initparse(&p, NULL, pkt, cur, end);
 	p.dnsp_qcls = p.dnsp_qtyp = 0;
 	qdn = dn;
 	nrr = 0;
-	while((r = dns_nextrr(&p, &rr)) > 0) {
-		if (!dns_dnequal(qdn, rr.dnsrr_dn)) continue;
-		if ((qcls == DNS_C_ANY || qcls == rr.dnsrr_cls) &&
-			(q->qtyp == DNS_T_ANY || q->qtyp == rr.dnsrr_typ))
+	while ((r = dns_nextrr(&p, &rr)) > 0) {
+		if (!dns_dnequal(qdn, rr.dnsrr_dn))
+			continue;
+		if ((qcls == DNS_C_ANY || qcls == rr.dnsrr_cls) && (q->qtyp == DNS_T_ANY || q->qtyp == rr.dnsrr_typ))
 			++nrr;
 		else if (rr.dnsrr_typ == DNS_T_CNAME && !nrr) {
 			if (dns_getdn(pkt, &rr.dnsrr_dptr, end,
-						  p.dnsp_dnbuf, sizeof(p.dnsp_dnbuf)) <= 0 ||
-				rr.dnsrr_dptr != rr.dnsrr_dend) {
+						  p.dnsp_dnbuf, sizeof(p.dnsp_dnbuf)) <= 0 || rr.dnsrr_dptr != rr.dnsrr_dend) {
 				r = DNS_E_PROTOCOL;
 				break;
-			}
-			else {
+			} else {
 				qdn = p.dnsp_dnbuf;
 			}
 		}
@@ -409,28 +415,28 @@ static void dnscb(struct dns_ctx *ctx, void *result, void *data) {
 	dns_rewind(&p, NULL);
 	p.dnsp_qtyp = q->qtyp;
 	p.dnsp_qcls = qcls;
-	while(dns_nextrr(&p, &rr)) {
+	while (dns_nextrr(&p, &rr)) {
 		parse_rr(&p, q, &rr);
 	}
-  
+
 	free(result);
 }
 
 
-static switch_status_t enum_lookup(char *root, char *in, enum_record_t **results)
+static switch_status_t enum_lookup(char *root, char *in, enum_record_t ** results)
 {
-	switch_status_t sstatus  = SWITCH_STATUS_SUCCESS;
+	switch_status_t sstatus = SWITCH_STATUS_SUCCESS;
 	char *name = NULL;
-	enum_query_t query = {0};
+	enum_query_t query = { 0 };
 	enum dns_type l_qtyp = DNS_T_NAPTR;
 	int i = 0, abs = 0;
-	dns_socket fd = (dns_socket)-1;
+	dns_socket fd = (dns_socket) - 1;
 	fd_set fds;
-	struct timeval tv = {0};
+	struct timeval tv = { 0 };
 	time_t now = 0;
 	struct dns_ctx *nctx = NULL;
 	char *num, *mnum = NULL;
-	
+
 	if (*in != '+') {
 		mnum = switch_mprintf("+%s", in);
 		num = mnum;
@@ -458,7 +464,7 @@ static switch_status_t enum_lookup(char *root, char *in, enum_record_t **results
 		goto done;
 	}
 
-	dns_ptodn(name, (unsigned int)strlen(name), query.dn, sizeof(query.dn), &abs);
+	dns_ptodn(name, (unsigned int) strlen(name), query.dn, sizeof(query.dn), &abs);
 	query.name = name;
 	query.number = num;
 	query.qtyp = l_qtyp;
@@ -466,7 +472,7 @@ static switch_status_t enum_lookup(char *root, char *in, enum_record_t **results
 	if (abs) {
 		abs = DNS_NOSRCH;
 	}
-	
+
 	if (!dns_submit_dn(nctx, query.dn, qcls, l_qtyp, abs, 0, dnscb, &query)) {
 		dnserror(&query, dns_status(nctx));
 	}
@@ -474,7 +480,7 @@ static switch_status_t enum_lookup(char *root, char *in, enum_record_t **results
 	FD_ZERO(&fds);
 	now = 0;
 
-	while((i = dns_timeouts(nctx, -1, now)) > 0) {
+	while ((i = dns_timeouts(nctx, -1, now)) > 0) {
 #ifdef _MSC_VER
 #pragma warning(push)
 #pragma warning(disable: 4389 4127)
@@ -485,9 +491,10 @@ static switch_status_t enum_lookup(char *root, char *in, enum_record_t **results
 #endif
 		tv.tv_sec = i;
 		tv.tv_usec = 0;
-		i = select((int)(fd+1), &fds, 0, 0, &tv);
+		i = select((int) (fd + 1), &fds, 0, 0, &tv);
 		now = time(NULL);
-		if (i > 0) dns_ioevent(nctx, now);
+		if (i > 0)
+			dns_ioevent(nctx, now);
 	}
 
 	if (!query.results) {
@@ -497,17 +504,17 @@ static switch_status_t enum_lookup(char *root, char *in, enum_record_t **results
 	*results = query.results;
 	query.results = NULL;
 
- done:
+  done:
 
 	if (fd > -1) {
 		closesocket(fd);
-		fd = (dns_socket)-1;
+		fd = (dns_socket) - 1;
 	}
 
 	if (nctx) {
 		dns_free(nctx);
 	}
-	
+
 	switch_safe_free(name);
 	switch_safe_free(mnum);
 
@@ -524,34 +531,37 @@ static switch_caller_extension_t *enum_dialplan_hunt(switch_core_session_t *sess
 	enum_route_t *rtp;
 	char *dp = (char *) arg;
 
-    assert(channel != NULL);
+	assert(channel != NULL);
 
 	caller_profile = switch_channel_get_caller_profile(channel);
-	
+
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "ENUM Lookup on %s\n", caller_profile->destination_number);
 
-	if (enum_lookup(switch_strlen_zero(dp) ? globals.root : dp, caller_profile->destination_number, &results) == SWITCH_STATUS_SUCCESS) {
-		if ((extension = switch_caller_extension_new(session, caller_profile->destination_number, caller_profile->destination_number)) == 0) {
+	if (enum_lookup(switch_strlen_zero(dp) ? globals.root : dp, caller_profile->destination_number, &results) ==
+		SWITCH_STATUS_SUCCESS) {
+		if ((extension =
+			 switch_caller_extension_new(session, caller_profile->destination_number,
+										 caller_profile->destination_number)) == 0) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "memory error!\n");
-			free_results(&results);	
+			free_results(&results);
 			return NULL;
 		}
 		switch_channel_set_variable(channel, SWITCH_HANGUP_AFTER_BRIDGE_VARIABLE, "true");
-		
-		for(rtp = globals.route_order; rtp; rtp = rtp->next) {
-			for(rp = results; rp; rp = rp->next) {
+
+		for (rtp = globals.route_order; rtp; rtp = rtp->next) {
+			for (rp = results; rp; rp = rp->next) {
 				if (!strcmp(rtp->service, rp->service)) {
-					switch_caller_extension_add_application(session, extension, "bridge", rp->route);					
+					switch_caller_extension_add_application(session, extension, "bridge", rp->route);
 				}
 			}
 		}
 
-		free_results(&results);	
+		free_results(&results);
 	}
 
 	if (extension) {
-        switch_channel_set_state(channel, CS_EXECUTE);
-    }
+		switch_channel_set_state(channel, CS_EXECUTE);
+	}
 
 	return extension;
 
@@ -560,7 +570,7 @@ static switch_caller_extension_t *enum_dialplan_hunt(switch_core_session_t *sess
 static void enum_app_function(switch_core_session_t *session, char *data)
 {
 	int argc = 0;
-    char *argv[4] = {0};
+	char *argv[4] = { 0 };
 	char *mydata = NULL;
 	char *dest = NULL, *root = NULL;
 	enum_record_t *results, *rp;
@@ -575,26 +585,27 @@ static void enum_app_function(switch_core_session_t *session, char *data)
 	assert(channel != NULL);
 
 	if (!(mydata = switch_core_session_strdup(session, data))) {
-        return;
-    }
+		return;
+	}
 
-    if ((argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) {
+	if ((argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(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) {
 			switch_hash_index_t *hi;
 			void *vval;
 			const void *vvar;
 
-			for (hi = switch_channel_variable_first(channel, switch_core_session_get_pool(session)); hi; hi = switch_hash_next(hi)) {
+			for (hi = switch_channel_variable_first(channel, switch_core_session_get_pool(session)); hi;
+				 hi = switch_hash_next(hi)) {
 				switch_hash_this(hi, &vvar, NULL, &vval);
 				if (vvar && !strncmp(vvar, "enum_", 5)) {
 					switch_channel_set_variable(channel, (char *) vvar, NULL);
 				}
 			}
 
-			for(rtp = globals.route_order; rtp; rtp = rtp->next) {
-				for(rp = results; rp; rp = rp->next) {
+			for (rtp = globals.route_order; rtp; rtp = rtp->next) {
+				for (rp = results; rp; rp = rp->next) {
 					if (!strcmp(rtp->service, rp->service)) {
 						snprintf(vbuf, sizeof(vbuf), "enum_route_%d", cnt++);
 						switch_channel_set_variable(channel, vbuf, rp->route);
@@ -608,19 +619,19 @@ static void enum_app_function(switch_core_session_t *session, char *data)
 			}
 			snprintf(vbuf, sizeof(vbuf), "%d", cnt);
 			switch_channel_set_variable(channel, "enum_route_count", vbuf);
-			*(rbuf+strlen(rbuf)-1) = '\0';
+			*(rbuf + strlen(rbuf) - 1) = '\0';
 			switch_channel_set_variable(channel, "enum_auto_route", rbuf);
-			free_results(&results);	
+			free_results(&results);
 		}
 	}
-	
+
 }
 
 static switch_status_t enum_function(char *data, switch_core_session_t *session, switch_stream_handle_t *stream)
 {
 
 	int argc = 0;
-	char *argv[4] = {0};
+	char *argv[4] = { 0 };
 	enum_record_t *results, *rp;
 	char *mydata = NULL;
 	char *dest = NULL, *root = NULL;
@@ -639,35 +650,36 @@ static switch_status_t enum_function(char *data, switch_core_session_t *session,
 	if ((argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) {
 		dest = argv[0];
 		root = argv[1] ? argv[1] : globals.root;
-		
+
 		if (!enum_lookup(root, data, &results) == SWITCH_STATUS_SUCCESS) {
 			stream->write_function(stream, "No Match!\n");
 			return SWITCH_STATUS_SUCCESS;
 		}
-		
+
 		stream->write_function(stream,
 							   "\nOffered Routes:\n"
 							   "Order\tPref\tService   \tRoute\n"
 							   "==============================================================================\n");
 
-		for(rp = results; rp; rp = rp->next) {
+		for (rp = results; rp; rp = rp->next) {
 			stream->write_function(stream, "%d\t%d\t%-10s\t%s\n", rp->order, rp->preference, rp->service, rp->route);
 		}
-	
+
 
 		stream->write_function(stream,
 							   "\nSupported Routes:\n"
 							   "Order\tPref\tService   \tRoute\n"
 							   "==============================================================================\n");
 
-		for(rtp = globals.route_order; rtp; rtp = rtp->next) {
-			for(rp = results; rp; rp = rp->next) {
+		for (rtp = globals.route_order; rtp; rtp = rtp->next) {
+			for (rp = results; rp; rp = rp->next) {
 				if (!strcmp(rtp->service, rp->service)) {
-					stream->write_function(stream, "%d\t%d\t%-10s\t%s\n", rp->order, rp->preference, rp->service, rp->route);
+					stream->write_function(stream, "%d\t%d\t%-10s\t%s\n", rp->order, rp->preference, rp->service,
+										   rp->route);
 				}
 			}
 		}
-		
+
 		free_results(&results);
 	} else {
 		stream->write_function(stream, "Invalid Input!\n");
@@ -678,14 +690,14 @@ static switch_status_t enum_function(char *data, switch_core_session_t *session,
 
 
 static const switch_dialplan_interface_t enum_dialplan_interface = {
-    /*.interface_name = */ "enum",
-    /*.hunt_function = */ enum_dialplan_hunt
-    /*.next = NULL */
+	/*.interface_name = */ "enum",
+	/*.hunt_function = */ enum_dialplan_hunt
+		/*.next = NULL */
 };
 
 static const switch_application_interface_t enum_application_interface = {
 	/*.interface_name */ "enum",
-	/*.application_function */ enum_app_function,	
+	/*.application_function */ enum_app_function,
 	/* long_desc */ "Perform an ENUM lookup",
 	/* short_desc */ "Perform an ENUM lookup",
 	/* syntax */ " []",
@@ -714,7 +726,8 @@ static switch_loadable_module_interface_t enum_module_interface = {
 	/*.directory_interface */ NULL
 };
 
-SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
+													   char *filename)
 {
 
 	if (dns_init(0) < 0) {
@@ -729,5 +742,3 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_mod
 	/* indicate that the module should continue to be loaded */
 	return SWITCH_STATUS_SUCCESS;
 }
-
-
diff --git a/src/mod/applications/mod_ivrtest/mod_ivrtest.c b/src/mod/applications/mod_ivrtest/mod_ivrtest.c
index 494e4de7e2..d0058d5830 100644
--- a/src/mod/applications/mod_ivrtest/mod_ivrtest.c
+++ b/src/mod/applications/mod_ivrtest/mod_ivrtest.c
@@ -39,16 +39,17 @@ static const char modname[] = "mod_ivrtest";
   dtmf handler function you can hook up to be executed when a digit is dialed during playback 
    if you return anything but SWITCH_STATUS_SUCCESS the playback will stop.
 */
-static switch_status_t on_dtmf(switch_core_session_t *session, void *input, switch_input_type_t itype, void *buf, unsigned int buflen)
+static switch_status_t on_dtmf(switch_core_session_t *session, void *input, switch_input_type_t itype, void *buf,
+							   unsigned int buflen)
 {
 	switch (itype) {
-	case SWITCH_INPUT_TYPE_DTMF: {
-		char *dtmf = (char *) input;
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Digits %s\n", dtmf);
-	
-		switch_copy_string((char *)buf, dtmf, buflen);
-		return SWITCH_STATUS_BREAK;
-	}
+	case SWITCH_INPUT_TYPE_DTMF:{
+			char *dtmf = (char *) input;
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Digits %s\n", dtmf);
+
+			switch_copy_string((char *) buf, dtmf, buflen);
+			return SWITCH_STATUS_BREAK;
+		}
 		break;
 	default:
 		break;
@@ -72,7 +73,7 @@ static void xml_function(switch_core_session_t *session, char *data)
 	for (team = switch_xml_child(f1, "team"); team; team = team->next) {
 		teamname = switch_xml_attr_soft(team, "name");
 		for (driver = switch_xml_child(team, "driver"); driver; driver = driver->next) {
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, 
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
 							  "%s, %s: %s\n", switch_xml_child(driver, "name")->txt, teamname,
 							  switch_xml_child(driver, "points")->txt);
 		}
@@ -84,7 +85,7 @@ static void xml_function(switch_core_session_t *session, char *data)
 static void ivr_application_function(switch_core_session_t *session, char *data)
 {
 	switch_channel_t *channel = switch_core_session_get_channel(session);
-	char *params = switch_core_session_strdup(session,data);
+	char *params = switch_core_session_strdup(session, data);
 
 	if (channel != NULL && params != NULL) {
 		switch_ivr_menu_t *menu = NULL, *sub_menu = NULL;
@@ -98,12 +99,7 @@ static void ivr_application_function(switch_core_session_t *session, char *data)
 									  "main",
 									  "please enter some numbers so i can figure out if I have any bugs or not",
 									  "enter some numbers",
-									  NULL,
-									  "I have no idea what that is",
-									  "cepstral",
-									  "david",
-									  NULL,
-									  15000, 10, NULL);
+									  NULL, "I have no idea what that is", "cepstral", "david", NULL, 15000, 10, NULL);
 
 
 		status = switch_ivr_menu_init(&sub_menu,
@@ -111,12 +107,7 @@ static void ivr_application_function(switch_core_session_t *session, char *data)
 									  "sub",
 									  "/ram/congrats.wav",
 									  "/ram/extension.wav",
-									  NULL,
-									  "/ram/invalid.wav",
-									  NULL,
-									  NULL,
-									  NULL,
-									  15000, 10, NULL);
+									  NULL, "/ram/invalid.wav", NULL, NULL, NULL, 15000, 10, NULL);
 
 		if (status == SWITCH_STATUS_SUCCESS) {
 			// build the menu
@@ -125,10 +116,10 @@ static void ivr_application_function(switch_core_session_t *session, char *data)
 			switch_ivr_menu_bind_action(menu, SWITCH_IVR_ACTION_EXECMENU, "sub", "3");
 			//switch_ivr_menu_bind_action(menu, SWITCH_IVR_ACTION_PLAYSOUND, "/usr/local/freeswitch/sounds/3.wav", "3");
 
-			
+
 			switch_ivr_menu_bind_action(sub_menu, SWITCH_IVR_ACTION_PLAYSOUND, "/ram/swimp.raw", "1");
 			switch_ivr_menu_bind_action(sub_menu, SWITCH_IVR_ACTION_BACK, NULL, "2");
-			
+
 
 			// start the menu
 			status = switch_ivr_menu_execute(session, menu, "main", NULL);
@@ -136,11 +127,11 @@ static void ivr_application_function(switch_core_session_t *session, char *data)
 			// cleaup the menu
 			switch_ivr_menu_stack_free(menu);
 		} else {
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "unable to build menu %s\n",params);
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "unable to build menu %s\n", params);
 		}
-			
 
-		switch_ivr_play_file(session, NULL,"/ram/goodbye.wav",NULL);
+
+		switch_ivr_play_file(session, NULL, "/ram/goodbye.wav", NULL);
 	}
 }
 
@@ -151,15 +142,13 @@ static void dirtest_function(switch_core_session_t *session, char *data)
 	switch_directory_handle_t dh;
 
 	channel = switch_core_session_get_channel(session);
-    assert(channel != NULL);
+	assert(channel != NULL);
 
 
-	if (switch_core_directory_open(&dh, 
+	if (switch_core_directory_open(&dh,
 								   "ldap",
 								   "ldap.freeswitch.org",
-								   "cn=Manager,dc=freeswitch,dc=org",
-								   "test",
-								   NULL) != SWITCH_STATUS_SUCCESS) {
+								   "cn=Manager,dc=freeswitch,dc=org", "test", NULL) != SWITCH_STATUS_SUCCESS) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't connect\n");
 		return;
 	}
@@ -177,16 +166,17 @@ static void dirtest_function(switch_core_session_t *session, char *data)
 
 }
 
-static switch_status_t show_dtmf(switch_core_session_t *session, void *input, switch_input_type_t itype, void *buf, unsigned int buflen)
+static switch_status_t show_dtmf(switch_core_session_t *session, void *input, switch_input_type_t itype, void *buf,
+								 unsigned int buflen)
 {
 
 	switch (itype) {
-	case SWITCH_INPUT_TYPE_DTMF: {
-		char *dtmf = (char *) input;
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Digits %s\n", dtmf);
+	case SWITCH_INPUT_TYPE_DTMF:{
+			char *dtmf = (char *) input;
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Digits %s\n", dtmf);
 
-		switch_copy_string((char *)buf, dtmf, buflen);
-	}
+			switch_copy_string((char *) buf, dtmf, buflen);
+		}
 		break;
 	default:
 		break;
@@ -203,9 +193,9 @@ static void tts_function(switch_core_session_t *session, char *data)
 	char buf[10] = "";
 	char *argv[3];
 	int argc;
-    switch_input_args_t args = {0};
+	switch_input_args_t args = { 0 };
 
-	if(!(mydata = switch_core_session_strdup(session, (char *) data))) {
+	if (!(mydata = switch_core_session_strdup(session, (char *) data))) {
 		return;
 	}
 
@@ -221,14 +211,14 @@ static void tts_function(switch_core_session_t *session, char *data)
 	}
 
 	channel = switch_core_session_get_channel(session);
-    assert(channel != NULL);
-	
-    switch_channel_answer(channel);
+	assert(channel != NULL);
+
+	switch_channel_answer(channel);
 
 	codec = switch_core_session_get_read_codec(session);
-    args.input_callback = show_dtmf;
-    args.buf = buf;
-    args.buflen = sizeof(buf);
+	args.input_callback = show_dtmf;
+	args.buf = buf;
+	args.buflen = sizeof(buf);
 	switch_ivr_speak_text(session, tts_name, voice_name, codec->implementation->samples_per_second, text, &args);
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Done\n");
 }
@@ -236,17 +226,17 @@ static void tts_function(switch_core_session_t *session, char *data)
 #ifdef BUGTEST
 static switch_bool_t bug_callback(switch_media_bug_t *bug, void *user_data, switch_abc_type_t type)
 {
-    switch_frame_t *frame;
+	switch_frame_t *frame;
 
-    switch(type) {
+	switch (type) {
 	case SWITCH_ABC_TYPE_WRITE_REPLACE:
-        frame = switch_core_media_bug_get_replace_frame(bug);
-        switch_core_media_bug_set_replace_frame(bug, frame);
-        printf("W00t\n");
-        break;
-    default:
-        break;
-    }
+		frame = switch_core_media_bug_get_replace_frame(bug);
+		switch_core_media_bug_set_replace_frame(bug, frame);
+		printf("W00t\n");
+		break;
+	default:
+		break;
+	}
 
 	return SWITCH_TRUE;
 }
@@ -257,56 +247,46 @@ static void bugtest_function(switch_core_session_t *session, char *data)
 #ifdef BUGTEST
 	switch_media_bug_t *bug;
 	switch_channel_t *channel = switch_core_session_get_channel(session);
-    switch_status_t status;
+	switch_status_t status;
 
 	if ((status = switch_core_media_bug_add(session,
-											bug_callback,
-											NULL,
-											SMBF_WRITE_REPLACE,
-											&bug)) != SWITCH_STATUS_SUCCESS) {
+											bug_callback, NULL, SMBF_WRITE_REPLACE, &bug)) != SWITCH_STATUS_SUCCESS) {
 		switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
-        return;
+		return;
 	}
 #endif
 	//switch_ivr_schedule_broadcast(time(NULL) + 10, switch_core_session_get_uuid(session), "/Users/anthm/sr8k.wav", SMF_ECHO_ALEG);
 	//switch_ivr_schedule_transfer(time(NULL) + 10, switch_core_session_get_uuid(session), "2000", NULL, NULL);
 	//switch_ivr_schedule_hangup(time(NULL) + 10, switch_core_session_get_uuid(session), SWITCH_CAUSE_ALLOTTED_TIMEOUT);
 
-    switch_ivr_play_file(session, NULL, data, NULL);
+	switch_ivr_play_file(session, NULL, data, NULL);
 }
 
 #if 1
 static void asrtest_function(switch_core_session_t *session, char *data)
 {
-	switch_ivr_detect_speech(session,
-							 "lumenvox",
-							 "demo",
-							 data,
-							 "127.0.0.1",
-							 NULL);
+	switch_ivr_detect_speech(session, "lumenvox", "demo", data, "127.0.0.1", NULL);
 }
 
-#else 
+#else
 static void asrtest_function(switch_core_session_t *session, char *data)
 {
-	switch_asr_handle_t ah = {0};
+	switch_asr_handle_t ah = { 0 };
 	switch_asr_flag_t flags = SWITCH_ASR_FLAG_NONE;
 	switch_channel_t *channel = switch_core_session_get_channel(session);
 	char *codec_name = "L16";
-	switch_codec_t codec = {0}, *read_codec;
-	switch_frame_t write_frame = {0}, *write_frame_p = NULL;
+	switch_codec_t codec = { 0 }, *read_codec;
+	switch_frame_t write_frame = { 0 }, *write_frame_p = NULL;
 	char xdata[1024] = "";
 
 	read_codec = switch_core_session_get_read_codec(session);
 	assert(read_codec != NULL);
-	
+
 
 	if (switch_core_asr_open(&ah, "lumenvox",
 							 read_codec->implementation->iananame,
 							 8000,
-							 "127.0.0.1",
-							 &flags,
-							 switch_core_session_get_pool(session)) == SWITCH_STATUS_SUCCESS) {
+							 "127.0.0.1", &flags, switch_core_session_get_pool(session)) == SWITCH_STATUS_SUCCESS) {
 		if (strcmp(ah.codec, read_codec->implementation->iananame)) {
 			if (switch_core_codec_init(&codec,
 									   ah.codec,
@@ -317,36 +297,39 @@ static void asrtest_function(switch_core_session_t *session, char *data)
 									   SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
 									   NULL, switch_core_session_get_pool(session)) == SWITCH_STATUS_SUCCESS) {
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Raw Codec Activated\n");
-				switch_core_session_set_read_codec(session, &codec);		
+				switch_core_session_set_read_codec(session, &codec);
 				write_frame.data = xdata;
 				write_frame.buflen = sizeof(xdata);
 				write_frame.codec = &codec;
 				write_frame_p = &write_frame;
 			} else {
-				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Codec Activation Failed %s@%uhz %u channels %dms\n",
-								  codec_name, read_codec->implementation->samples_per_second, read_codec->implementation->number_of_channels,
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+								  "Codec Activation Failed %s@%uhz %u channels %dms\n", codec_name,
+								  read_codec->implementation->samples_per_second,
+								  read_codec->implementation->number_of_channels,
 								  read_codec->implementation->microseconds_per_frame / 1000);
 				switch_core_session_reset(session);
 				return;
 			}
 		}
-		
-		
-		if (switch_core_asr_load_grammar(&ah, "demo", "/opt/lumenvox/engine_7.0/Lang/BuiltinGrammars/ABNFPhone.gram") != SWITCH_STATUS_SUCCESS) {
+
+
+		if (switch_core_asr_load_grammar(&ah, "demo", "/opt/lumenvox/engine_7.0/Lang/BuiltinGrammars/ABNFPhone.gram") !=
+			SWITCH_STATUS_SUCCESS) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Error loading Grammar\n");
 			goto end;
 		}
-		
-		while(switch_channel_ready(channel)) {
+
+		while (switch_channel_ready(channel)) {
 			switch_frame_t *read_frame;
 			switch_status_t status = switch_core_session_read_frame(session, &read_frame, -1, 0);
 			char *xmlstr = NULL;
 			switch_xml_t xml = NULL, result;
- 
+
 			if (!SWITCH_READ_ACCEPTABLE(status)) {
 				break;
 			}
-			
+
 			if (switch_test_flag(read_frame, SFF_CNG)) {
 				continue;
 			}
@@ -355,7 +338,7 @@ static void asrtest_function(switch_core_session_t *session, char *data)
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Error Feeding Data\n");
 				break;
 			}
-			
+
 			if (switch_core_asr_check_results(&ah, &flags) == SWITCH_STATUS_SUCCESS) {
 				if (switch_core_asr_get_results(&ah, &xmlstr, &flags) != SWITCH_STATUS_SUCCESS) {
 					break;
@@ -368,7 +351,7 @@ static void asrtest_function(switch_core_session_t *session, char *data)
 				}
 				switch_safe_free(xmlstr);
 			}
-			
+
 			if (write_frame_p) {
 				write_frame.datalen = read_frame->datalen;
 				switch_core_session_write_frame(session, write_frame_p, -1, 0);
@@ -378,7 +361,7 @@ static void asrtest_function(switch_core_session_t *session, char *data)
 			}
 		}
 
-	end:
+	  end:
 		if (write_frame_p) {
 			switch_core_session_set_read_codec(session, read_codec);
 			switch_core_codec_destroy(&codec);
@@ -400,9 +383,9 @@ static void ivrtest_function(switch_core_session_t *session, char *data)
 	char buf[10] = "";
 	char term;
 	char say[128] = "";
-	
+
 	channel = switch_core_session_get_channel(session);
-    assert(channel != NULL);
+	assert(channel != NULL);
 
 	switch_channel_answer(channel);
 
@@ -410,18 +393,19 @@ static void ivrtest_function(switch_core_session_t *session, char *data)
 
 	while (switch_channel_get_state(channel) == CS_EXECUTE) {
 		memset(buf, 0, sizeof(buf));
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Enter up to 10 digits, press # to terminate, * to hangup\n");
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE,
+						  "Enter up to 10 digits, press # to terminate, * to hangup\n");
 
 		if (data) {
-            switch_input_args_t args = {0};
+			switch_input_args_t args = { 0 };
 			/* you could have passed NULL instead of on_dtmf to get this exact behaviour (copy the digits to buf and stop playing)
 			   but you may want to pass the function if you have something cooler to do...
-			*/
-            args.input_callback = on_dtmf;
-            args.buf = buf;
-            args.buflen = sizeof(buf);
+			 */
+			args.input_callback = on_dtmf;
+			args.buf = buf;
+			args.buflen = sizeof(buf);
 			status = switch_ivr_play_file(session, NULL, data, &args);
-			
+
 			if (status != SWITCH_STATUS_SUCCESS && status != SWITCH_STATUS_BREAK) {
 				switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
 				break;
@@ -440,7 +424,7 @@ static void ivrtest_function(switch_core_session_t *session, char *data)
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, say);
 		switch_ivr_speak_text(session, "cepstral", "david", codec->implementation->samples_per_second, say, NULL);
 	}
-	
+
 }
 
 
@@ -449,9 +433,10 @@ static switch_status_t my_on_hangup(switch_core_session_t *session)
 	switch_channel_t *channel;
 
 	channel = switch_core_session_get_channel(session);
-    assert(channel != NULL);
+	assert(channel != NULL);
 
-	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "I globally hooked to [%s] on the hangup event\n", switch_channel_get_name(channel));
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "I globally hooked to [%s] on the hangup event\n",
+					  switch_channel_get_name(channel));
 	return SWITCH_STATUS_SUCCESS;
 
 }
@@ -472,7 +457,7 @@ static const switch_application_interface_t bug_application_interface = {
 	/*.application_function */ bugtest_function,
 	NULL, NULL, NULL,
 	/* flags */ SAF_NONE,
-	/*.next*/ NULL
+	/*.next */ NULL
 };
 
 static const switch_application_interface_t ivr_application_interface = {
@@ -480,7 +465,7 @@ static const switch_application_interface_t ivr_application_interface = {
 	/*.application_function */ ivr_application_function,
 	NULL, NULL, NULL,
 	/* flags */ SAF_NONE,
-	/*.next*/ &bug_application_interface
+	/*.next */ &bug_application_interface
 };
 
 static const switch_application_interface_t xml_application_interface = {
@@ -488,7 +473,7 @@ static const switch_application_interface_t xml_application_interface = {
 	/*.application_function */ xml_function,
 	NULL, NULL, NULL,
 	/* flags */ SAF_NONE,
-	/*.next*/ &ivr_application_interface
+	/*.next */ &ivr_application_interface
 };
 
 static const switch_application_interface_t disast_application_interface = {
@@ -496,7 +481,7 @@ static const switch_application_interface_t disast_application_interface = {
 	/*.application_function */ disast_function,
 	NULL, NULL, NULL,
 	/* flags */ SAF_SUPPORT_NOMEDIA,
-	/*.next*/ &xml_application_interface
+	/*.next */ &xml_application_interface
 };
 
 static const switch_application_interface_t tts_application_interface = {
@@ -504,7 +489,7 @@ static const switch_application_interface_t tts_application_interface = {
 	/*.application_function */ tts_function,
 	NULL, NULL, NULL,
 	/* flags */ SAF_NONE,
-	/*.next*/ &disast_application_interface
+	/*.next */ &disast_application_interface
 };
 
 static const switch_application_interface_t dirtest_application_interface = {
@@ -512,7 +497,7 @@ static const switch_application_interface_t dirtest_application_interface = {
 	/*.application_function */ dirtest_function,
 	NULL, NULL, NULL,
 	/* flags */ SAF_SUPPORT_NOMEDIA,
-	/*.next*/ &tts_application_interface
+	/*.next */ &tts_application_interface
 };
 
 static const switch_application_interface_t ivrtest_application_interface = {
@@ -520,7 +505,7 @@ static const switch_application_interface_t ivrtest_application_interface = {
 	/*.application_function */ ivrtest_function,
 	NULL, NULL, NULL,
 	/* flags */ SAF_NONE,
-	/*.next*/ &dirtest_application_interface
+	/*.next */ &dirtest_application_interface
 };
 
 static const switch_application_interface_t asrtest_application_interface = {
@@ -528,7 +513,7 @@ static const switch_application_interface_t asrtest_application_interface = {
 	/*.application_function */ asrtest_function,
 	NULL, NULL, NULL,
 	/* flags */ SAF_NONE,
-	/*.next*/ &ivrtest_application_interface
+	/*.next */ &ivrtest_application_interface
 };
 
 static const switch_loadable_module_interface_t mod_ivrtest_module_interface = {
@@ -540,7 +525,8 @@ static const switch_loadable_module_interface_t mod_ivrtest_module_interface = {
 	/*.application_interface */ &asrtest_application_interface
 };
 
-SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
+													   char *filename)
 {
 
 	/* connect my internal structure to the blank pointer passed to me */
diff --git a/src/mod/applications/mod_park/mod_park.c b/src/mod/applications/mod_park/mod_park.c
index af358ced34..8ab2a9f0ed 100644
--- a/src/mod/applications/mod_park/mod_park.c
+++ b/src/mod/applications/mod_park/mod_park.c
@@ -35,13 +35,13 @@ static const char modname[] = "mod_park";
 static void park_function(switch_core_session_t *session, char *data)
 {
 	switch_ivr_park(session, NULL);
-	
+
 }
 
 static const switch_application_interface_t park_application_interface = {
 	/*.interface_name */ "park",
 	/*.application_function */ park_function,
-	NULL,NULL,NULL,
+	NULL, NULL, NULL,
 	/* flags */ SAF_NONE,
 	NULL
 };
@@ -59,7 +59,8 @@ static switch_loadable_module_interface_t park_module_interface = {
 	/*.directory_interface */ NULL
 };
 
-SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
+													   char *filename)
 {
 	/* connect my internal structure to the blank pointer passed to me */
 	*module_interface = &park_module_interface;
diff --git a/src/mod/applications/mod_playback/mod_playback.c b/src/mod/applications/mod_playback/mod_playback.c
index c235ae3252..5d47e8b238 100644
--- a/src/mod/applications/mod_playback/mod_playback.c
+++ b/src/mod/applications/mod_playback/mod_playback.c
@@ -38,24 +38,25 @@ static const char modname[] = "mod_playback";
   dtmf handler function you can hook up to be executed when a digit is dialed during playback 
    if you return anything but SWITCH_STATUS_SUCCESS the playback will stop.
 */
-static switch_status_t on_dtmf(switch_core_session_t *session, void *input, switch_input_type_t itype, void *buf, unsigned int buflen)
+static switch_status_t on_dtmf(switch_core_session_t *session, void *input, switch_input_type_t itype, void *buf,
+							   unsigned int buflen)
 {
 
-	
+
 	switch (itype) {
-	case SWITCH_INPUT_TYPE_DTMF: {
-		char *dtmf = (char *) input;
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Digits %s\n", dtmf);
-		
-		if (*dtmf == '*') {
-			return SWITCH_STATUS_BREAK;
+	case SWITCH_INPUT_TYPE_DTMF:{
+			char *dtmf = (char *) input;
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Digits %s\n", dtmf);
+
+			if (*dtmf == '*') {
+				return SWITCH_STATUS_BREAK;
+			}
 		}
-	}
 		break;
 	default:
 		break;
 	}
-	
+
 	return SWITCH_STATUS_SUCCESS;
 }
 
@@ -64,28 +65,28 @@ static void speak_function(switch_core_session_t *session, char *data)
 {
 	switch_channel_t *channel;
 	char buf[10];
-	char *argv[4] = {0};
+	char *argv[4] = { 0 };
 	int argc;
 	char *engine = NULL;
 	char *voice = NULL;
 	char *text = NULL;
 	char *mydata = NULL;
 	switch_codec_t *codec;
-    switch_input_args_t args = {0};
+	switch_input_args_t args = { 0 };
 
 	codec = switch_core_session_get_read_codec(session);
 	assert(codec != NULL);
 
 	channel = switch_core_session_get_channel(session);
-    assert(channel != NULL);
+	assert(channel != NULL);
 
 	mydata = switch_core_session_strdup(session, data);
-	argc = switch_separate_string(mydata, '|', argv, sizeof(argv)/sizeof(argv[0]));
+	argc = switch_separate_string(mydata, '|', argv, sizeof(argv) / sizeof(argv[0]));
 
 	engine = argv[0];
 	voice = argv[1];
 	text = argv[2];
-	
+
 	if (!(engine && voice && text)) {
 		if (!engine) {
 			engine = "NULL";
@@ -102,27 +103,27 @@ static void speak_function(switch_core_session_t *session, char *data)
 
 	switch_channel_pre_answer(channel);
 
-    args.input_callback = on_dtmf;
-    args.buf = buf;
-    args.buflen = sizeof(buf);
+	args.input_callback = on_dtmf;
+	args.buf = buf;
+	args.buflen = sizeof(buf);
 	switch_ivr_speak_text(session, engine, voice, codec->implementation->samples_per_second, text, &args);
-	
+
 }
 
 static void playback_function(switch_core_session_t *session, char *data)
 {
 	switch_channel_t *channel;
 	char *file_name = NULL;
-    switch_input_args_t args = {0};
+	switch_input_args_t args = { 0 };
 
 	file_name = switch_core_session_strdup(session, data);
 
 	channel = switch_core_session_get_channel(session);
-    assert(channel != NULL);
+	assert(channel != NULL);
 
 	switch_channel_pre_answer(channel);
 
-    args.input_callback = on_dtmf;
+	args.input_callback = on_dtmf;
 	switch_ivr_play_file(session, NULL, file_name, &args);
 
 }
@@ -132,21 +133,21 @@ static void record_function(switch_core_session_t *session, char *data)
 {
 	switch_channel_t *channel;
 	switch_status_t status;
-    uint32_t limit = 0;
-    char *path;
-    char *p;
-    switch_input_args_t args = {0};
+	uint32_t limit = 0;
+	char *path;
+	char *p;
+	switch_input_args_t args = { 0 };
 
 	channel = switch_core_session_get_channel(session);
-    assert(channel != NULL);
+	assert(channel != NULL);
 
-    path = switch_core_session_strdup(session, data);
-    if ((p = strchr(path, '+'))) {
-        *p++ = '\0';
-        limit = atoi(p);
-    }
+	path = switch_core_session_strdup(session, data);
+	if ((p = strchr(path, '+'))) {
+		*p++ = '\0';
+		limit = atoi(p);
+	}
 
-    args.input_callback = on_dtmf;
+	args.input_callback = on_dtmf;
 	status = switch_ivr_record_file(session, NULL, path, &args, limit);
 
 	if (!switch_channel_ready(channel) || (status != SWITCH_STATUS_SUCCESS && !SWITCH_STATUS_IS_BREAK(status))) {
@@ -159,9 +160,9 @@ static void record_session_function(switch_core_session_t *session, char *data)
 {
 	switch_channel_t *channel;
 	channel = switch_core_session_get_channel(session);
-    assert(channel != NULL);
+	assert(channel != NULL);
 
-	switch_ivr_record_session(session, data, NULL);	
+	switch_ivr_record_session(session, data, NULL);
 }
 
 
@@ -169,9 +170,9 @@ static void stop_record_session_function(switch_core_session_t *session, char *d
 {
 	switch_channel_t *channel;
 	channel = switch_core_session_get_channel(session);
-    assert(channel != NULL);
+	assert(channel != NULL);
 
-	switch_ivr_stop_record_session(session, data);	
+	switch_ivr_stop_record_session(session, data);
 }
 
 
@@ -223,7 +224,7 @@ static const switch_application_interface_t playback_application_interface = {
 	/* short_desc */ "Playback File",
 	/* syntax */ "",
 	/* flags */ SAF_NONE,
-	/*.next*/	&stop_record_session_application_interface
+	/*.next */ &stop_record_session_application_interface
 };
 
 static const switch_loadable_module_interface_t mod_playback_module_interface = {
@@ -235,7 +236,8 @@ static const switch_loadable_module_interface_t mod_playback_module_interface =
 	/*.application_interface */ &playback_application_interface
 };
 
-SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
+													   char *filename)
 {
 
 	/* connect my internal structure to the blank pointer passed to me */
diff --git a/src/mod/applications/mod_rss/mod_rss.c b/src/mod/applications/mod_rss/mod_rss.c
index 8dd096431c..499d163fdc 100644
--- a/src/mod/applications/mod_rss/mod_rss.c
+++ b/src/mod/applications/mod_rss/mod_rss.c
@@ -68,9 +68,9 @@ static uint32_t match_count(char *str, uint32_t max)
 {
 	char tstr[80] = "";
 	uint32_t matches = 0, x = 0;
-	uint32_t len = (uint32_t)strlen(str);
+	uint32_t len = (uint32_t) strlen(str);
 
-	for (x = 0; x < max ; x++) {
+	for (x = 0; x < max; x++) {
 		snprintf(tstr, sizeof(tstr), "%u", x);
 		if (!strncasecmp(str, tstr, len)) {
 			matches++;
@@ -85,68 +85,68 @@ static uint32_t match_count(char *str, uint32_t max)
   dtmf handler function you can hook up to be executed when a digit is dialed during playback 
   if you return anything but SWITCH_STATUS_SUCCESS the playback will stop.
 */
-static switch_status_t on_dtmf(switch_core_session_t *session, void *input, switch_input_type_t itype, void *buf, unsigned int buflen)
-
+static switch_status_t on_dtmf(switch_core_session_t *session, void *input, switch_input_type_t itype, void *buf,
+							   unsigned int buflen)
 {
 	switch (itype) {
-	case SWITCH_INPUT_TYPE_DTMF: {
-		char *dtmf = (char *) input;
-		struct dtmf_buffer *dtb;
-		dtb = (struct dtmf_buffer *) buf;
-	
-		switch(*dtmf) {
-		case '#':
-			switch_set_flag(dtb, SFLAG_MAIN);
-			return SWITCH_STATUS_BREAK;
-		case '6':
-			dtb->index++;
-			return SWITCH_STATUS_BREAK;
-		case '4':
-			dtb->index--;
-			return SWITCH_STATUS_BREAK;
-		case '*':
-			if (switch_test_flag(dtb->sh, SWITCH_SPEECH_FLAG_PAUSE)) {
-				switch_clear_flag(dtb->sh, SWITCH_SPEECH_FLAG_PAUSE);
-			} else {
-				switch_set_flag(dtb->sh, SWITCH_SPEECH_FLAG_PAUSE);
-			}
-			break;
-		case '5':
-			switch_core_speech_text_param_tts(dtb->sh, "voice", "next");
-			switch_set_flag(dtb, SFLAG_INFO);
-			return SWITCH_STATUS_BREAK;
-			break;
-		case '9':
-			switch_core_speech_text_param_tts(dtb->sh, "voice", dtb->voice);
-			switch_set_flag(dtb, SFLAG_INFO);
-			return SWITCH_STATUS_BREAK;
-			break;
-		case '2':
-			if (dtb->speed < 260) {
-				dtb->speed += 30;
+	case SWITCH_INPUT_TYPE_DTMF:{
+			char *dtmf = (char *) input;
+			struct dtmf_buffer *dtb;
+			dtb = (struct dtmf_buffer *) buf;
+
+			switch (*dtmf) {
+			case '#':
+				switch_set_flag(dtb, SFLAG_MAIN);
+				return SWITCH_STATUS_BREAK;
+			case '6':
+				dtb->index++;
+				return SWITCH_STATUS_BREAK;
+			case '4':
+				dtb->index--;
+				return SWITCH_STATUS_BREAK;
+			case '*':
+				if (switch_test_flag(dtb->sh, SWITCH_SPEECH_FLAG_PAUSE)) {
+					switch_clear_flag(dtb->sh, SWITCH_SPEECH_FLAG_PAUSE);
+				} else {
+					switch_set_flag(dtb->sh, SWITCH_SPEECH_FLAG_PAUSE);
+				}
+				break;
+			case '5':
+				switch_core_speech_text_param_tts(dtb->sh, "voice", "next");
+				switch_set_flag(dtb, SFLAG_INFO);
+				return SWITCH_STATUS_BREAK;
+				break;
+			case '9':
+				switch_core_speech_text_param_tts(dtb->sh, "voice", dtb->voice);
+				switch_set_flag(dtb, SFLAG_INFO);
+				return SWITCH_STATUS_BREAK;
+				break;
+			case '2':
+				if (dtb->speed < 260) {
+					dtb->speed += 30;
+					switch_core_speech_numeric_param_tts(dtb->sh, "speech/rate", dtb->speed);
+					switch_set_flag(dtb, SFLAG_INFO);
+					return SWITCH_STATUS_BREAK;
+				}
+				break;
+			case '7':
+				dtb->speed = TTS_MEAN_SPEED;
 				switch_core_speech_numeric_param_tts(dtb->sh, "speech/rate", dtb->speed);
 				switch_set_flag(dtb, SFLAG_INFO);
 				return SWITCH_STATUS_BREAK;
-			}
-			break;
-		case '7':
-			dtb->speed = TTS_MEAN_SPEED;
-			switch_core_speech_numeric_param_tts(dtb->sh, "speech/rate", dtb->speed);
-			switch_set_flag(dtb, SFLAG_INFO);
-			return SWITCH_STATUS_BREAK;
-		case '8':
-			if (dtb->speed > 80) {
-				dtb->speed -= 30;
-				switch_core_speech_numeric_param_tts(dtb->sh, "speech/rate", dtb->speed);
-				switch_set_flag(dtb, SFLAG_INFO);
+			case '8':
+				if (dtb->speed > 80) {
+					dtb->speed -= 30;
+					switch_core_speech_numeric_param_tts(dtb->sh, "speech/rate", dtb->speed);
+					switch_set_flag(dtb, SFLAG_INFO);
+					return SWITCH_STATUS_BREAK;
+				}
+				break;
+			case '0':
+				switch_set_flag(dtb, SFLAG_INSTRUCT);
 				return SWITCH_STATUS_BREAK;
 			}
-			break;
-		case '0':
-			switch_set_flag(dtb, SFLAG_INSTRUCT);
-			return SWITCH_STATUS_BREAK;
 		}
-	}
 		break;
 	default:
 		break;
@@ -159,9 +159,9 @@ static void rss_function(switch_core_session_t *session, char *data)
 	switch_channel_t *channel;
 	switch_status_t status;
 	const char *err = NULL;
-	struct dtmf_buffer dtb = {0};
+	struct dtmf_buffer dtb = { 0 };
 	switch_xml_t xml = NULL, item, xchannel = NULL;
-	struct rss_entry entries[TTS_MAX_ENTRIES] = {{0}};
+	struct rss_entry entries[TTS_MAX_ENTRIES] = { {0} };
 	uint32_t i = 0;
 	char *title_txt = "", *description_txt = "", *rights_txt = "";
 	switch_codec_t speech_codec, *codec = switch_core_session_get_read_codec(session);
@@ -169,31 +169,32 @@ static void rss_function(switch_core_session_t *session, char *data)
 	char *voice = TTS_DEFAULT_VOICE;
 	char *timer_name = NULL;
 	switch_speech_handle_t sh;
-    switch_speech_flag_t flags = SWITCH_SPEECH_FLAG_NONE;
+	switch_speech_flag_t flags = SWITCH_SPEECH_FLAG_NONE;
 	switch_core_thread_session_t thread_session;
 	uint32_t rate, interval = 20;
 	int stream_id = 0;
-	switch_timer_t timer = {0}, *timerp = NULL;
+	switch_timer_t timer = { 0 }, *timerp = NULL;
 	uint32_t last;
 	char *mydata = NULL;
 	char *filename = NULL;
-	char *argv[3], *feed_list[TTS_MAX_ENTRIES] = {0} , *feed_names[TTS_MAX_ENTRIES] = {0};
+	char *argv[3], *feed_list[TTS_MAX_ENTRIES] = { 0 }, *feed_names[TTS_MAX_ENTRIES] = {
+	0};
 	int argc, feed_index = 0;
 	char *cf = "rss.conf";
-    switch_xml_t cfg, cxml, feeds, feed;
+	switch_xml_t cfg, cxml, feeds, feed;
 	char buf[1024];
 	int32_t jumpto = -1;
 	uint32_t matches = 0;
-	switch_input_args_t args = {0};
+	switch_input_args_t args = { 0 };
 
 	channel = switch_core_session_get_channel(session);
-    assert(channel != NULL);
+	assert(channel != NULL);
 
 
 	if (!(cxml = switch_xml_open_cfg(cf, &cfg, NULL))) {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
-        return;
-    }
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
+		return;
+	}
 
 	if ((feeds = switch_xml_child(cfg, "feeds"))) {
 		for (feed = switch_xml_child(feeds, "feed"); feed; feed = feed->next) {
@@ -210,14 +211,14 @@ static void rss_function(switch_core_session_t *session, char *data)
 	}
 
 	switch_xml_free(cxml);
-	
+
 	switch_channel_answer(channel);
 
 
 
 	if (!switch_strlen_zero(data)) {
 		if ((mydata = switch_core_session_strdup(session, data))) {
-			argc = switch_separate_string(mydata, ' ', argv, sizeof(argv)/sizeof(argv[0]));
+			argc = switch_separate_string(mydata, ' ', argv, sizeof(argv) / sizeof(argv[0]));
 
 			if (argv[0]) {
 				engine = argv[0];
@@ -246,40 +247,40 @@ static void rss_function(switch_core_session_t *session, char *data)
 	memset(&sh, 0, sizeof(sh));
 	if (switch_core_speech_open(&sh,
 								engine,
-								voice,
-								rate,
-								&flags,
-								switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
+								voice, rate, &flags, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid TTS module!\n");
 		return;
 	}
-	
+
 	if (switch_core_codec_init(&speech_codec,
 							   "L16",
 							   NULL,
-							   (int)rate,
+							   (int) rate,
 							   interval,
 							   1,
 							   SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
-							   NULL,
-							   switch_core_session_get_pool(session)) == SWITCH_STATUS_SUCCESS) {
+							   NULL, switch_core_session_get_pool(session)) == SWITCH_STATUS_SUCCESS) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Raw Codec Activated\n");
 	} else {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Raw Codec Activation Failed L16@%uhz 1 channel %dms\n", rate, interval);
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Raw Codec Activation Failed L16@%uhz 1 channel %dms\n",
+						  rate, interval);
 		flags = 0;
 		switch_core_speech_close(&sh, &flags);
 		return;
 	}
-	
+
 	if (timer_name) {
-		if (switch_core_timer_init(&timer, timer_name, interval, (int)(rate / 50), switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
+		if (switch_core_timer_init
+			(&timer, timer_name, interval, (int) (rate / 50),
+			 switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "setup timer failed!\n");
 			switch_core_codec_destroy(&speech_codec);
 			flags = 0;
 			switch_core_speech_close(&sh, &flags);
 			return;
 		}
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "setup timer success %u bytes per %d ms!\n", (rate / 50)*2, interval);
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "setup timer success %u bytes per %d ms!\n",
+						  (rate / 50) * 2, interval);
 
 		/* start a thread to absorb incoming audio */
 		for (stream_id = 0; stream_id < switch_core_session_get_stream_count(session); stream_id++) {
@@ -292,7 +293,7 @@ static void rss_function(switch_core_session_t *session, char *data)
 	while (switch_channel_ready(channel)) {
 		int32_t len = 0, idx = 0;
 		char cmd[3];
-	main_menu:
+	  main_menu:
 		filename = NULL;
 		len = idx = 0;
 		*cmd = '\0';
@@ -304,36 +305,30 @@ static void rss_function(switch_core_session_t *session, char *data)
 		} else {
 			switch_core_speech_flush_tts(&sh);
 #ifdef MATCH_COUNT
-			snprintf(buf + len, sizeof(buf) - len, 
+			snprintf(buf + len, sizeof(buf) - len,
 					 ",Main Menu.  "
-					 "Select one of the following news sources, or press 0 to exit. "
-					 ",");
+					 "Select one of the following news sources, or press 0 to exit. " ",");
 #else
-			snprintf(buf + len, sizeof(buf) - len, 
+			snprintf(buf + len, sizeof(buf) - len,
 					 ",Main Menu.  "
 					 "Select one of the following news sources, followed by the pound key or press 0 to exit. "
 					 ",");
 #endif
-			len = (int32_t)strlen(buf);
+			len = (int32_t) strlen(buf);
 
 			for (idx = 0; idx < feed_index; idx++) {
 				snprintf(buf + len, sizeof(buf) - len, "%d: %s. ", idx + 1, feed_names[idx]);
-				len = (int32_t)strlen(buf);
+				len = (int32_t) strlen(buf);
 			}
 
 
 			snprintf(buf + len, sizeof(buf) - len, "");
-			len = (int32_t)strlen(buf);
+			len = (int32_t) strlen(buf);
 
 			args.input_callback = NULL;
 			args.buf = cmd;
 			args.buflen = sizeof(cmd);
-			status = switch_ivr_speak_text_handle(session,
-												  &sh,
-												  &speech_codec,
-												  timerp,
-												  buf,
-												  &args);
+			status = switch_ivr_speak_text_handle(session, &sh, &speech_codec, timerp, buf, &args);
 			if (status != SWITCH_STATUS_SUCCESS && status != SWITCH_STATUS_BREAK) {
 				goto finished;
 			}
@@ -346,31 +341,31 @@ static void rss_function(switch_core_session_t *session, char *data)
 				break;
 			}
 
-			if ((p=strchr(cmd, '#'))) {
+			if ((p = strchr(cmd, '#'))) {
 				*p = '\0';
 #ifdef MATCH_COUNT
 				/* Hmmm... I know there are no more matches so I don't *need* them to press pound but 
 				   I already told them to press it.  Will this confuse people or not?  Let's make em press 
 				   pound unless this define is enabled for now.
-				*/
+				 */
 			} else if (match_count(cmd, feed_index) > 1) {
 #else
 			} else {
 #endif
 				char term;
 				char *cp;
-				int blen = sizeof(cmd) - (int)strlen(cmd);
+				int blen = sizeof(cmd) - (int) strlen(cmd);
 
 				cp = cmd + blen;
 				switch_ivr_collect_digits_count(session, cp, blen, blen, "#", &term, 5000);
 			}
-			
+
 			i = atoi(cmd) - 1;
 
 			if (i > -1 && i < feed_index) {
 				filename = feed_list[i];
 			} else if (matches > 1) {
-				
+
 			} else {
 				args.input_callback = NULL;
 				args.buf = NULL;
@@ -378,19 +373,17 @@ static void rss_function(switch_core_session_t *session, char *data)
 				status = switch_ivr_speak_text_handle(session,
 													  &sh,
 													  &speech_codec,
-													  timerp,
-													  "I'm sorry. That is an Invalid Selection. ",
-													  &args);
+													  timerp, "I'm sorry. That is an Invalid Selection. ", &args);
 				if (status != SWITCH_STATUS_SUCCESS && status != SWITCH_STATUS_BREAK) {
 					goto finished;
 				}
 			}
 		}
-	
+
 		if (!filename) {
 			continue;
 		}
-		
+
 
 
 		if (!(xml = switch_xml_parse_file(filename))) {
@@ -411,7 +404,7 @@ static void rss_function(switch_core_session_t *session, char *data)
 			if ((title = switch_xml_child(xchannel, "title"))) {
 				title_txt = title->txt;
 			}
-			
+
 			if ((description = switch_xml_child(xchannel, "description"))) {
 				description_txt = description->txt;
 			}
@@ -444,19 +437,19 @@ static void rss_function(switch_core_session_t *session, char *data)
 			if ((title = switch_xml_child(item, "title"))) {
 				entries[i].title_txt = title->txt;
 			}
-		
+
 			if ((description = switch_xml_child(item, "description"))) {
 				char *t, *e;
 				entries[i].description_txt = description->txt;
-				for(;;) {
+				for (;;) {
 					if (!(t = strchr(entries[i].description_txt, '<'))) {
 						break;
 					}
 					if (!(e = strchr(t, '>'))) {
 						break;
 					}
-				
-					memset(t, 32, ++e-t);
+
+					memset(t, 32, ++e - t);
 				}
 			}
 
@@ -471,9 +464,8 @@ static void rss_function(switch_core_session_t *session, char *data)
 			if (entries[i].description_txt && (p = strchr(entries[i].description_txt, '<'))) {
 				*p = '\0';
 			}
-
 #ifdef _STRIP_SOME_CHARS_
-			for(p = entries[i].description_txt; *p; p++) {
+			for (p = entries[i].description_txt; *p; p++) {
 				if (*p == '\'' || *p == '"' || *p == ':') {
 					*p = ' ';
 				}
@@ -493,17 +485,13 @@ static void rss_function(switch_core_session_t *session, char *data)
 			switch_strftime(date, &retsize, sizeof(date), "%I:%M %p", &tm);
 
 
-			snprintf(buf, sizeof(buf), ",%s. %s. %s. local time: %s, Press 0 for options, 5 to change voice, or pound to return to the main menu. ", 
+			snprintf(buf, sizeof(buf),
+					 ",%s. %s. %s. local time: %s, Press 0 for options, 5 to change voice, or pound to return to the main menu. ",
 					 title_txt, description_txt, rights_txt, date);
 			args.input_callback = NULL;
 			args.buf = cmd;
 			args.buflen = sizeof(cmd);
-			status = switch_ivr_speak_text_handle(session,
-												  &sh,
-												  &speech_codec,
-												  timerp,
-												  buf,
-												  &args);
+			status = switch_ivr_speak_text_handle(session, &sh, &speech_codec, timerp, buf, &args);
 			if (status != SWITCH_STATUS_SUCCESS && status != SWITCH_STATUS_BREAK) {
 				goto finished;
 			}
@@ -519,7 +507,7 @@ static void rss_function(switch_core_session_t *session, char *data)
 			}
 		}
 
-		for(last = 0; last < TTS_MAX_ENTRIES; last++) {
+		for (last = 0; last < TTS_MAX_ENTRIES; last++) {
 			if (!entries[last].inuse) {
 				last--;
 				break;
@@ -531,8 +519,8 @@ static void rss_function(switch_core_session_t *session, char *data)
 		dtb.speed = TTS_MEAN_SPEED;
 		switch_set_flag(&dtb, SFLAG_INFO);
 		switch_copy_string(dtb.voice, voice, sizeof(dtb.voice));
-		while(entries[0].inuse && switch_channel_ready(channel)) {
-			while(switch_channel_ready(channel)) {
+		while (entries[0].inuse && switch_channel_ready(channel)) {
+			while (switch_channel_ready(channel)) {
 				uint8_t cont = 0;
 
 				if (dtb.index >= TTS_MAX_ENTRIES) {
@@ -557,12 +545,8 @@ static void rss_function(switch_core_session_t *session, char *data)
 					if (switch_test_flag(&dtb, SFLAG_INFO)) {
 						switch_clear_flag(&dtb, SFLAG_INFO);
 						snprintf(buf + len, sizeof(buf) - len,
-								 "%s %s. I am speaking at %u words per minute. ",
-								 sh.engine,
-								 sh.voice,
-								 dtb.speed
-								 );
-						len = (uint32_t)strlen(buf);
+								 "%s %s. I am speaking at %u words per minute. ", sh.engine, sh.voice, dtb.speed);
+						len = (uint32_t) strlen(buf);
 					}
 
 					if (switch_test_flag(&dtb, SFLAG_INSTRUCT)) {
@@ -577,33 +561,29 @@ static void rss_function(switch_core_session_t *session, char *data)
 								 "To hear these options again, press zero or press pound to return to the main menu. ");
 					} else {
 						snprintf(buf + len, sizeof(buf) - len, "Story %d. ", dtb.index + 1);
-						len = (uint32_t)strlen(buf);
+						len = (uint32_t) strlen(buf);
 
 						if (entries[dtb.index].subject_txt) {
 							snprintf(buf + len, sizeof(buf) - len, "Subject: %s. ", entries[dtb.index].subject_txt);
-							len = (uint32_t)strlen(buf);
+							len = (uint32_t) strlen(buf);
 						}
-				
+
 						if (entries[dtb.index].dept_txt) {
-							snprintf(buf + len, sizeof(buf) - len, "From the %s department. ", entries[dtb.index].dept_txt);
-							len = (uint32_t)strlen(buf);
+							snprintf(buf + len, sizeof(buf) - len, "From the %s department. ",
+									 entries[dtb.index].dept_txt);
+							len = (uint32_t) strlen(buf);
 						}
 
 						if (entries[dtb.index].title_txt) {
 							snprintf(buf + len, sizeof(buf) - len, "%s", entries[dtb.index].title_txt);
-							len = (uint32_t)strlen(buf);
+							len = (uint32_t) strlen(buf);
 						}
 					}
 					switch_core_speech_flush_tts(&sh);
 					args.input_callback = on_dtmf;
 					args.buf = &dtb;
 					args.buflen = sizeof(dtb);
-					status = switch_ivr_speak_text_handle(session,
-														  &sh,
-														  &speech_codec,
-														  timerp,
-														  buf,
-														  &args);
+					status = switch_ivr_speak_text_handle(session, &sh, &speech_codec, timerp, buf, &args);
 					if (status == SWITCH_STATUS_BREAK) {
 						continue;
 					} else if (status != SWITCH_STATUS_SUCCESS) {
@@ -614,7 +594,7 @@ static void rss_function(switch_core_session_t *session, char *data)
 						cont = 0;
 						continue;
 					}
-					
+
 					if (entries[dtb.index].description_txt) {
 						args.input_callback = on_dtmf;
 						args.buf = &dtb;
@@ -622,9 +602,7 @@ static void rss_function(switch_core_session_t *session, char *data)
 						status = switch_ivr_speak_text_handle(session,
 															  &sh,
 															  &speech_codec,
-															  timerp,
-															  entries[dtb.index].description_txt,
-															  &args);
+															  timerp, entries[dtb.index].description_txt, &args);
 					}
 					if (status == SWITCH_STATUS_BREAK) {
 						continue;
@@ -638,7 +616,7 @@ static void rss_function(switch_core_session_t *session, char *data)
 		}
 	}
 
- finished:
+  finished:
 	switch_core_speech_close(&sh, &flags);
 	switch_core_codec_destroy(&speech_codec);
 
@@ -659,7 +637,7 @@ static const switch_application_interface_t rss_application_interface = {
 	/*.application_function */ rss_function,
 	NULL, NULL, NULL,
 	/* flags */ SAF_NONE,
-	/*.next*/ NULL
+	/*.next */ NULL
 };
 
 
@@ -677,7 +655,8 @@ static switch_loadable_module_interface_t rss_module_interface = {
 };
 
 
-SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
+													   char *filename)
 {
 	/* connect my internal structure to the blank pointer passed to me */
 	*module_interface = &rss_module_interface;
diff --git a/src/mod/applications/mod_skel/mod_skel.c b/src/mod/applications/mod_skel/mod_skel.c
index 306535eb0d..6bd6cc01d1 100644
--- a/src/mod/applications/mod_skel/mod_skel.c
+++ b/src/mod/applications/mod_skel/mod_skel.c
@@ -47,7 +47,8 @@ static switch_loadable_module_interface_t skel_module_interface = {
 	/*.directory_interface */ NULL
 };
 
-SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
+													   char *filename)
 {
 	/* connect my internal structure to the blank pointer passed to me */
 	*module_interface = &skel_module_interface;
diff --git a/src/mod/asr_tts/mod_cepstral/mod_cepstral.c b/src/mod/asr_tts/mod_cepstral/mod_cepstral.c
index 4b81c772d1..afd619e56f 100644
--- a/src/mod/asr_tts/mod_cepstral/mod_cepstral.c
+++ b/src/mod/asr_tts/mod_cepstral/mod_cepstral.c
@@ -69,23 +69,23 @@ typedef struct {
 
 
 /* This callback caches the audio in the buffer */
-static swift_result_t write_audio(swift_event *event, swift_event_t type, void *udata)
+static swift_result_t write_audio(swift_event * event, swift_event_t type, void *udata)
 {
 	cepstral_t *cepstral;
-    swift_event_t rv = SWIFT_SUCCESS;
-    void *buf = NULL;
-    int len = 0, i = 0;
-	
+	swift_event_t rv = SWIFT_SUCCESS;
+	void *buf = NULL;
+	int len = 0, i = 0;
+
 	cepstral = udata;
 	assert(cepstral != NULL);
-	
+
 	if (!cepstral->port || cepstral->done || cepstral->done_gen) {
-		return  SWIFT_UNKNOWN_ERROR;
+		return SWIFT_UNKNOWN_ERROR;
 	}
 
 	/* Only proceed when we have success */
-    if (!SWIFT_FAILED((rv = swift_event_get_audio(event, &buf, &len)))) {
-		while(!cepstral->done) {
+	if (!SWIFT_FAILED((rv = swift_event_get_audio(event, &buf, &len)))) {
+		while (!cepstral->done) {
 			switch_mutex_lock(cepstral->audio_lock);
 			if (switch_buffer_write(cepstral->audio_buffer, buf, len) > 0) {
 				switch_mutex_unlock(cepstral->audio_lock);
@@ -100,7 +100,7 @@ static swift_result_t write_audio(swift_event *event, swift_event_t type, void *
 					}
 				}
 			}
-			
+
 		}
 	} else {
 		cepstral->done = 1;
@@ -109,11 +109,12 @@ static swift_result_t write_audio(swift_event *event, swift_event_t type, void *
 	if (cepstral->done) {
 		rv = SWIFT_UNKNOWN_ERROR;
 	}
-	
-    return rv;
+
+	return rv;
 }
 
-static switch_status_t cepstral_speech_open(switch_speech_handle_t *sh, char *voice_name, int rate, switch_speech_flag_t *flags)
+static switch_status_t cepstral_speech_open(switch_speech_handle_t *sh, char *voice_name, int rate,
+											switch_speech_flag_t *flags)
 {
 	cepstral_t *cepstral = switch_core_alloc(sh->memory_pool, sizeof(*cepstral));
 	char srate[25];
@@ -143,7 +144,7 @@ static switch_status_t cepstral_speech_open(switch_speech_handle_t *sh, char *vo
 		goto all_done;
 	}
 
-		
+
 	if (voice_name && SWIFT_FAILED(swift_port_set_voice_by_name(cepstral->port, voice_name))) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid voice %s!\n", voice_name);
 		voice_name = NULL;
@@ -157,7 +158,7 @@ static switch_status_t cepstral_speech_open(switch_speech_handle_t *sh, char *vo
 		}
 
 		/* Set the voice found by find_first_voice() as the port's current voice */
-		if ( SWIFT_FAILED(swift_port_set_voice(cepstral->port, cepstral->voice)) ) {
+		if (SWIFT_FAILED(swift_port_set_voice(cepstral->port, cepstral->voice))) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to set voice.\n");
 			goto all_done;
 		}
@@ -173,8 +174,8 @@ static switch_status_t cepstral_speech_open(switch_speech_handle_t *sh, char *vo
 
 	sh->private_info = cepstral;
 	return SWITCH_STATUS_SUCCESS;
-	
- all_done:
+
+  all_done:
 	return SWITCH_STATUS_FALSE;
 }
 
@@ -185,18 +186,19 @@ static switch_status_t cepstral_speech_close(switch_speech_handle_t *sh, switch_
 	assert(sh != NULL);
 	cepstral = sh->private_info;
 	assert(cepstral != NULL);
-	
+
 
 	cepstral->done = 1;
 	cepstral->done_gen = 1;
 	swift_port_stop(cepstral->port, SWIFT_ASYNC_ANY, SWIFT_EVENT_NOW);
 	/* Close the Swift Port and Engine */
-	if (NULL != cepstral->port) swift_port_close(cepstral->port);
+	if (NULL != cepstral->port)
+		swift_port_close(cepstral->port);
 	//if (NULL != cepstral->engine) swift_engine_close(cepstral->engine);
 
 	cepstral->port = NULL;
 	//cepstral->engine = NULL;
-	
+
 	switch_buffer_destroy(&cepstral->audio_buffer);
 
 	return SWITCH_STATUS_SUCCESS;
@@ -206,7 +208,7 @@ static switch_status_t cepstral_speech_feed_tts(switch_speech_handle_t *sh, char
 {
 	cepstral_t *cepstral;
 	const char *fp = "file:";
-	int len = (int)strlen(fp);
+	int len = (int) strlen(fp);
 
 	assert(sh != NULL);
 	cepstral = sh->private_info;
@@ -214,7 +216,7 @@ static switch_status_t cepstral_speech_feed_tts(switch_speech_handle_t *sh, char
 
 	cepstral->done_gen = 0;
 	cepstral->done = 0;
-	
+
 	cepstral->tts_stream = NULL;
 
 	if (!strncasecmp(text, fp, len)) {
@@ -222,17 +224,17 @@ static switch_status_t cepstral_speech_feed_tts(switch_speech_handle_t *sh, char
 		if (switch_strlen_zero(text)) {
 			return SWITCH_STATUS_FALSE;
 		}
-		swift_port_speak_file(cepstral->port, text, NULL, &cepstral->tts_stream, NULL); 
+		swift_port_speak_file(cepstral->port, text, NULL, &cepstral->tts_stream, NULL);
 	} else {
-        char *to_say;
+		char *to_say;
 		if (switch_strlen_zero(text)) {
 			return SWITCH_STATUS_FALSE;
 		}
 
-        if ((to_say = switch_mprintf(" %s ", text))) {
-            swift_port_speak_text(cepstral->port, to_say, 0, NULL, &cepstral->tts_stream, NULL); 
-            switch_safe_free(to_say);
-        }
+		if ((to_say = switch_mprintf(" %s ", text))) {
+			swift_port_speak_text(cepstral->port, to_say, 0, NULL, &cepstral->tts_stream, NULL);
+			switch_safe_free(to_say);
+		}
 	}
 
 	return SWITCH_STATUS_SUCCESS;
@@ -243,10 +245,10 @@ static void cepstral_speech_flush_tts(switch_speech_handle_t *sh)
 	cepstral_t *cepstral;
 
 	cepstral = sh->private_info;
-    assert(cepstral != NULL);
+	assert(cepstral != NULL);
 
 	cepstral->done_gen = 1;
-    cepstral->done = 1;
+	cepstral->done = 1;
 	if (cepstral->audio_buffer) {
 		switch_mutex_lock(cepstral->audio_lock);
 		switch_buffer_zero(cepstral->audio_buffer);
@@ -257,9 +259,7 @@ static void cepstral_speech_flush_tts(switch_speech_handle_t *sh)
 
 static switch_status_t cepstral_speech_read_tts(switch_speech_handle_t *sh,
 												void *data,
-												size_t *datalen,
-												uint32_t *rate,
-												switch_speech_flag_t *flags) 
+												size_t *datalen, uint32_t * rate, switch_speech_flag_t *flags)
 {
 	cepstral_t *cepstral;
 	size_t desired = *datalen;
@@ -270,7 +270,7 @@ static switch_status_t cepstral_speech_read_tts(switch_speech_handle_t *sh,
 	cepstral = sh->private_info;
 	assert(cepstral != NULL);
 
-	while(!cepstral->done) {
+	while (!cepstral->done) {
 		if (!cepstral->done_gen) {
 			int check = swift_port_status(cepstral->port, cepstral->tts_stream);
 
@@ -282,8 +282,8 @@ static switch_status_t cepstral_speech_read_tts(switch_speech_handle_t *sh,
 		switch_mutex_lock(cepstral->audio_lock);
 		used = switch_buffer_inuse(cepstral->audio_buffer);
 		switch_mutex_unlock(cepstral->audio_lock);
-		
-		
+
+
 		if (!used && cepstral->done_gen) {
 
 			status = SWITCH_STATUS_BREAK;
@@ -304,15 +304,15 @@ static switch_status_t cepstral_speech_read_tts(switch_speech_handle_t *sh,
 			switch_yield(1000);
 			continue;
 		}
-		
+
 		/* There is enough, read it and return */
 		switch_mutex_lock(cepstral->audio_lock);
 		*datalen = switch_buffer_read(cepstral->audio_buffer, data, desired);
 		if (padding) {
 			size_t x = 0;
 			unsigned char *p = data;
-			
-			for(x = 0; x < padding; x++) {
+
+			for (x = 0; x < padding; x++) {
 				*(p + x) = 0;
 				(*datalen)++;
 			}
@@ -323,7 +323,7 @@ static switch_status_t cepstral_speech_read_tts(switch_speech_handle_t *sh,
 
 		break;
 	}
-	
+
 	return status;
 }
 
@@ -338,7 +338,7 @@ static void cepstral_text_param_tts(switch_speech_handle_t *sh, char *param, cha
 		char *voice_name = val;
 		if (!strcasecmp(voice_name, "next")) {
 			if ((cepstral->voice = swift_port_find_next_voice(cepstral->port))) {
-				if ( SWIFT_FAILED(swift_port_set_voice(cepstral->port, cepstral->voice)) ) {
+				if (SWIFT_FAILED(swift_port_set_voice(cepstral->port, cepstral->voice))) {
 					cepstral->done = cepstral->done_gen = 1;
 					return;
 				}
@@ -354,22 +354,22 @@ static void cepstral_text_param_tts(switch_speech_handle_t *sh, char *param, cha
 		}
 
 		if (!voice_name) {
-            /* Find the first voice on the system */
-            if ((cepstral->voice = swift_port_find_first_voice(cepstral->port, NULL, NULL)) == NULL) {
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to find any voices!\n");
+			/* Find the first voice on the system */
+			if ((cepstral->voice = swift_port_find_first_voice(cepstral->port, NULL, NULL)) == NULL) {
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to find any voices!\n");
 				cepstral->done = cepstral->done_gen = 1;
 				return;
-            }
+			}
 
-            /* Set the voice found by find_first_voice() as the port's current voice */
-            if ( SWIFT_FAILED(swift_port_set_voice(cepstral->port, cepstral->voice)) ) {
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to set voice.\n");
+			/* Set the voice found by find_first_voice() as the port's current voice */
+			if (SWIFT_FAILED(swift_port_set_voice(cepstral->port, cepstral->voice))) {
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to set voice.\n");
 				cepstral->done = cepstral->done_gen = 1;
 				return;
-            }
+			}
 
 			voice_name = (char *) swift_voice_get_attribute(cepstral->voice, "name");
-        } 
+		}
 
 		if (voice_name) {
 			switch_copy_string(sh->voice, voice_name, sizeof(sh->voice));
@@ -405,15 +405,15 @@ static void cepstral_float_param_tts(switch_speech_handle_t *sh, char *param, do
 }
 
 static const switch_speech_interface_t cepstral_speech_interface = {
-	/*.interface_name*/			"cepstral",
-	/*.speech_open*/			cepstral_speech_open,
-	/*.speech_close*/			cepstral_speech_close,
-	/*.speech_feed_tts*/		cepstral_speech_feed_tts,
-	/*.speech_read_tts*/		cepstral_speech_read_tts,
-	/*.speech_flush_tts*/		cepstral_speech_flush_tts,
-	/*.speech_text_param_tts*/  cepstral_text_param_tts,
-	/*.speech_numeric_param_tts*/  cepstral_numeric_param_tts,
-	/*.speech_numeric_param_tts*/  cepstral_float_param_tts
+	/*.interface_name */ "cepstral",
+	/*.speech_open */ cepstral_speech_open,
+	/*.speech_close */ cepstral_speech_close,
+	/*.speech_feed_tts */ cepstral_speech_feed_tts,
+	/*.speech_read_tts */ cepstral_speech_read_tts,
+	/*.speech_flush_tts */ cepstral_speech_flush_tts,
+	/*.speech_text_param_tts */ cepstral_text_param_tts,
+	/*.speech_numeric_param_tts */ cepstral_numeric_param_tts,
+	/*.speech_numeric_param_tts */ cepstral_float_param_tts
 };
 
 static const switch_loadable_module_interface_t cepstral_module_interface = {
@@ -433,11 +433,11 @@ switch_status_t switch_module_load(const switch_loadable_module_interface_t **mo
 {
 
 	/* Open the Swift TTS Engine */
-	if ( SWIFT_FAILED(engine = swift_engine_open(NULL)) ) {
+	if (SWIFT_FAILED(engine = swift_engine_open(NULL))) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to open Swift Engine.");
 		return SWITCH_STATUS_GENERR;
 	}
-	
+
 	/* connect my internal structure to the blank pointer passed to me */
 	*module_interface = &cepstral_module_interface;
 
diff --git a/src/mod/codecs/mod_amr/mod_amr.c b/src/mod/codecs/mod_amr/mod_amr.c
index d57a189a2b..44ad3d66c5 100644
--- a/src/mod/codecs/mod_amr/mod_amr.c
+++ b/src/mod/codecs/mod_amr/mod_amr.c
@@ -30,7 +30,7 @@
  *
  * mod_amr.c -- GSM-AMR Codec Module
  *
- */  
+ */
 #include "switch.h"
 static const char modname[] = "mod_amr";
 
@@ -114,14 +114,14 @@ static struct {
 #endif
 
 static switch_status_t switch_amr_init(switch_codec_t *codec, switch_codec_flag_t flags,
-									  const switch_codec_settings_t *codec_settings) 
+									   const switch_codec_settings_t *codec_settings)
 {
 
 #ifdef AMR_PASSTHROUGH
 	codec->flags |= SWITCH_CODEC_FLAG_PASSTHROUGH;
-    if (codec->fmtp_in) {
-        codec->fmtp_out = switch_core_strdup(codec->memory_pool, codec->fmtp_in);
-    }
+	if (codec->fmtp_in) {
+		codec->fmtp_out = switch_core_strdup(codec->memory_pool, codec->fmtp_in);
+	}
 	return SWITCH_STATUS_SUCCESS;
 #else
 	struct amr_context *context = NULL;
@@ -139,10 +139,10 @@ static switch_status_t switch_amr_init(switch_codec_t *codec, switch_codec_flag_
 
 		if (codec->fmtp_in) {
 			argc = switch_separate_string(codec->fmtp_in, ';', argv, (sizeof(argv) / sizeof(argv[0])));
-			for(x = 0; x < argc; x++) {
+			for (x = 0; x < argc; x++) {
 				char *data = argv[x];
 				char *arg;
-				while(*data && *data == ' ') {
+				while (*data && *data == ' ') {
 					data++;
 				}
 				if ((arg = strchr(data, '='))) {
@@ -171,16 +171,16 @@ static switch_status_t switch_amr_init(switch_codec_t *codec, switch_codec_flag_
 					} else if (!strcasecmp(data, "mode-change-period")) {
 						context->change_period = atoi(arg);
 					} else if (!strcasecmp(data, "ptime")) {
-						context->ptime = (switch_byte_t)atoi(arg);
+						context->ptime = (switch_byte_t) atoi(arg);
 					} else if (!strcasecmp(data, "channels")) {
-						context->channels = (switch_byte_t)atoi(arg);
+						context->channels = (switch_byte_t) atoi(arg);
 					} else if (!strcasecmp(data, "maxptime")) {
-						context->max_ptime = (switch_byte_t)atoi(arg);
+						context->max_ptime = (switch_byte_t) atoi(arg);
 					} else if (!strcasecmp(data, "mode-set")) {
 						int y, m_argc;
 						char *m_argv[7];
 						m_argc = switch_separate_string(arg, ',', m_argv, (sizeof(m_argv) / sizeof(m_argv[0])));
-						for(y = 0; y < m_argc; y++) {
+						for (y = 0; y < m_argc; y++) {
 							context->enc_modes |= (1 << atoi(m_argv[y]));
 						}
 					}
@@ -192,7 +192,7 @@ static switch_status_t switch_amr_init(switch_codec_t *codec, switch_codec_flag_
 		if (context->enc_modes) {
 			for (i = 7; i > -1; i++) {
 				if (context->enc_modes & (1 << i)) {
-					context->enc_mode = (switch_byte_t)i;
+					context->enc_mode = (switch_byte_t) i;
 					break;
 				}
 			}
@@ -201,10 +201,11 @@ static switch_status_t switch_amr_init(switch_codec_t *codec, switch_codec_flag_
 		if (!context->enc_mode) {
 			context->enc_mode = globals.default_bitrate;
 		}
-		
-		snprintf(fmtptmp, sizeof(fmtptmp), "octet-align=%d; mode-set=%d", switch_test_flag(context, AMR_OPT_OCTET_ALIGN) ? 1 : 0, context->enc_mode);
+
+		snprintf(fmtptmp, sizeof(fmtptmp), "octet-align=%d; mode-set=%d",
+				 switch_test_flag(context, AMR_OPT_OCTET_ALIGN) ? 1 : 0, context->enc_mode);
 		codec->fmtp_out = switch_core_strdup(codec->memory_pool, fmtptmp);
-		
+
 		context->enc_mode = AMR_DEFAULT_BITRATE;
 		context->encoder_state = NULL;
 		context->decoder_state = NULL;
@@ -224,7 +225,7 @@ static switch_status_t switch_amr_init(switch_codec_t *codec, switch_codec_flag_
 #endif
 }
 
-static switch_status_t switch_amr_destroy(switch_codec_t *codec) 
+static switch_status_t switch_amr_destroy(switch_codec_t *codec)
 {
 #ifndef AMR_PASSTHROUGH
 	struct amr_context *context = codec->private_info;
@@ -240,45 +241,39 @@ static switch_status_t switch_amr_destroy(switch_codec_t *codec)
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status_t switch_amr_encode(switch_codec_t *codec, 
-										switch_codec_t *other_codec, 
-										void *decoded_data,
-
-										uint32_t decoded_data_len, 
-										uint32_t decoded_rate, 
-										void *encoded_data,
-
-										uint32_t *encoded_data_len, 
-										uint32_t *encoded_rate, 
-										unsigned int *flag) 
+static switch_status_t switch_amr_encode(switch_codec_t *codec,
+										 switch_codec_t *other_codec,
+										 void *decoded_data,
+										 uint32_t decoded_data_len,
+										 uint32_t decoded_rate,
+										 void *encoded_data,
+										 uint32_t * encoded_data_len, uint32_t * encoded_rate, unsigned int *flag)
 {
 #ifdef AMR_PASSTHROUGH
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "This codec is only usable in passthrough mode!\n");
 	return SWITCH_STATUS_FALSE;
 #else
 	struct amr_context *context = codec->private_info;
-	
+
 	if (!context) {
 		return SWITCH_STATUS_FALSE;
 	}
-	
-	*encoded_data_len = Encoder_Interface_Encode( context->encoder_state, context->enc_mode, (int16_t *)decoded_data, (switch_byte_t *) encoded_data, 0);
+
+	*encoded_data_len =
+		Encoder_Interface_Encode(context->encoder_state, context->enc_mode, (int16_t *) decoded_data,
+								 (switch_byte_t *) encoded_data, 0);
 
 	return SWITCH_STATUS_SUCCESS;
 #endif
 }
 
-static switch_status_t switch_amr_decode(switch_codec_t *codec, 
-										switch_codec_t *other_codec, 
-										void *encoded_data,
-
-										uint32_t encoded_data_len, 
-										uint32_t encoded_rate, 
-										void *decoded_data,
-
-										uint32_t *decoded_data_len, 
-										uint32_t *decoded_rate, 
-										unsigned int *flag) 
+static switch_status_t switch_amr_decode(switch_codec_t *codec,
+										 switch_codec_t *other_codec,
+										 void *encoded_data,
+										 uint32_t encoded_data_len,
+										 uint32_t encoded_rate,
+										 void *decoded_data,
+										 uint32_t * decoded_data_len, uint32_t * decoded_rate, unsigned int *flag)
 {
 #ifdef AMR_PASSTHROUGH
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "This codec is only usable in passthrough mode!\n");
@@ -290,51 +285,51 @@ static switch_status_t switch_amr_decode(switch_codec_t *codec,
 		return SWITCH_STATUS_FALSE;
 	}
 
-	Decoder_Interface_Decode(context->decoder_state, (unsigned char *)encoded_data, (int16_t *)decoded_data, 0);
+	Decoder_Interface_Decode(context->decoder_state, (unsigned char *) encoded_data, (int16_t *) decoded_data, 0);
 	*decoded_data_len = codec->implementation->bytes_per_frame;
 
 	return SWITCH_STATUS_SUCCESS;
 #endif
 }
 
-/* Registration */ 
+/* Registration */
 
-static const switch_codec_implementation_t amr_implementation = { 
-	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO, 
-	/*.ianacode */ 96, 
-	/*.iananame */ "AMR", 
+static const switch_codec_implementation_t amr_implementation = {
+	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
+	/*.ianacode */ 96,
+	/*.iananame */ "AMR",
 	/*.fmtp */ "octet-align=0",
-	/*.samples_per_second */ 8000, 
-	/*.bits_per_second */ 0, 
-	/*.microseconds_per_frame */ 20000, 
-	/*.samples_per_frame */ 160, 
+	/*.samples_per_second */ 8000,
+	/*.bits_per_second */ 0,
+	/*.microseconds_per_frame */ 20000,
+	/*.samples_per_frame */ 160,
 	/*.bytes_per_frame */ 320,
-	/*.encoded_bytes_per_frame */ 0, 
-	/*.number_of_channels */ 1, 
-	/*.pref_frames_per_packet */ 1, 
-	/*.max_frames_per_packet */ 1, 
-	/*.init */ switch_amr_init, 
-	/*.encode */ switch_amr_encode, 
-	/*.decode */ switch_amr_decode, 
-	/*.destroy */ switch_amr_destroy, 
+	/*.encoded_bytes_per_frame */ 0,
+	/*.number_of_channels */ 1,
+	/*.pref_frames_per_packet */ 1,
+	/*.max_frames_per_packet */ 1,
+	/*.init */ switch_amr_init,
+	/*.encode */ switch_amr_encode,
+	/*.decode */ switch_amr_decode,
+	/*.destroy */ switch_amr_destroy,
 };
 
-static const switch_codec_interface_t amr_codec_interface = { 
-	/*.interface_name */ "GSM-AMR", 
-	/*.implementations */ &amr_implementation, 
+static const switch_codec_interface_t amr_codec_interface = {
+	/*.interface_name */ "GSM-AMR",
+	/*.implementations */ &amr_implementation,
 };
 
-static switch_loadable_module_interface_t amr_module_interface = { 
-	/*.module_name */ modname, 
-	/*.endpoint_interface */ NULL, 
-	/*.timer_interface */ NULL, 
-	/*.dialplan_interface */ NULL, 
-	/*.codec_interface */ &amr_codec_interface, 
-	/*.application_interface */ NULL 
+static switch_loadable_module_interface_t amr_module_interface = {
+	/*.module_name */ modname,
+	/*.endpoint_interface */ NULL,
+	/*.timer_interface */ NULL,
+	/*.dialplan_interface */ NULL,
+	/*.codec_interface */ &amr_codec_interface,
+	/*.application_interface */ NULL
 };
 
 SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
-													 char *filename)
+													   char *filename)
 {
 #ifndef AMR_PASSTHROUGH
 	char *cf = "amr.conf";
@@ -349,17 +344,16 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_mod
 				char *var = (char *) switch_xml_attr_soft(param, "name");
 				char *val = (char *) switch_xml_attr_soft(param, "value");
 				if (!strcasecmp(var, "default-bitrate")) {
-					globals.default_bitrate = (switch_byte_t)atoi(val);
+					globals.default_bitrate = (switch_byte_t) atoi(val);
 				}
 			}
 		}
 	}
-
 #endif
 
-	/* connect my internal structure to the blank pointer passed to me */ 
+	/* connect my internal structure to the blank pointer passed to me */
 	*module_interface = &amr_module_interface;
 
-	/* indicate that the module should continue to be loaded */ 
+	/* indicate that the module should continue to be loaded */
 	return SWITCH_STATUS_SUCCESS;
 }
diff --git a/src/mod/codecs/mod_g711/mod_g711.c b/src/mod/codecs/mod_g711/mod_g711.c
index 83b8d54388..b8d9b1fd7b 100644
--- a/src/mod/codecs/mod_g711/mod_g711.c
+++ b/src/mod/codecs/mod_g711/mod_g711.c
@@ -37,7 +37,7 @@ static const char modname[] = "mod_g711";
 
 
 static switch_status_t switch_g711u_init(switch_codec_t *codec, switch_codec_flag_t flags,
-									   const switch_codec_settings_t *codec_settings)
+										 const switch_codec_settings_t *codec_settings)
 {
 	int encoding, decoding;
 
@@ -53,12 +53,12 @@ static switch_status_t switch_g711u_init(switch_codec_t *codec, switch_codec_fla
 
 
 static switch_status_t switch_g711u_encode(switch_codec_t *codec,
-										 switch_codec_t *other_codec,
-										 void *decoded_data,
-										 uint32_t decoded_data_len,
-										 uint32_t decoded_rate,
-										 void *encoded_data,
-										 uint32_t *encoded_data_len, uint32_t *encoded_rate, unsigned int *flag)
+										   switch_codec_t *other_codec,
+										   void *decoded_data,
+										   uint32_t decoded_data_len,
+										   uint32_t decoded_rate,
+										   void *encoded_data,
+										   uint32_t * encoded_data_len, uint32_t * encoded_rate, unsigned int *flag)
 {
 	short *dbuf;
 	unsigned char *ebuf;
@@ -77,12 +77,12 @@ static switch_status_t switch_g711u_encode(switch_codec_t *codec,
 }
 
 static switch_status_t switch_g711u_decode(switch_codec_t *codec,
-										 switch_codec_t *other_codec,
-										 void *encoded_data,
-										 uint32_t encoded_data_len,
-										 uint32_t encoded_rate,
-										 void *decoded_data,
-										 uint32_t *decoded_data_len, uint32_t *decoded_rate, unsigned int *flag)
+										   switch_codec_t *other_codec,
+										   void *encoded_data,
+										   uint32_t encoded_data_len,
+										   uint32_t encoded_rate,
+										   void *decoded_data,
+										   uint32_t * decoded_data_len, uint32_t * decoded_rate, unsigned int *flag)
 {
 	short *dbuf;
 	unsigned char *ebuf;
@@ -112,7 +112,7 @@ static switch_status_t switch_g711u_destroy(switch_codec_t *codec)
 
 
 static switch_status_t switch_g711a_init(switch_codec_t *codec, switch_codec_flag_t flags,
-									   const switch_codec_settings_t *codec_settings)
+										 const switch_codec_settings_t *codec_settings)
 {
 	int encoding, decoding;
 
@@ -128,12 +128,12 @@ static switch_status_t switch_g711a_init(switch_codec_t *codec, switch_codec_fla
 
 
 static switch_status_t switch_g711a_encode(switch_codec_t *codec,
-										 switch_codec_t *other_codec,
-										 void *decoded_data,
-										 uint32_t decoded_data_len,
-										 uint32_t decoded_rate,
-										 void *encoded_data,
-										 uint32_t *encoded_data_len, uint32_t *encoded_rate, unsigned int *flag)
+										   switch_codec_t *other_codec,
+										   void *decoded_data,
+										   uint32_t decoded_data_len,
+										   uint32_t decoded_rate,
+										   void *encoded_data,
+										   uint32_t * encoded_data_len, uint32_t * encoded_rate, unsigned int *flag)
 {
 	short *dbuf;
 	unsigned char *ebuf;
@@ -152,12 +152,12 @@ static switch_status_t switch_g711a_encode(switch_codec_t *codec,
 }
 
 static switch_status_t switch_g711a_decode(switch_codec_t *codec,
-										 switch_codec_t *other_codec,
-										 void *encoded_data,
-										 uint32_t encoded_data_len,
-										 uint32_t encoded_rate,
-										 void *decoded_data,
-										 uint32_t *decoded_data_len, uint32_t *decoded_rate, unsigned int *flag)
+										   switch_codec_t *other_codec,
+										   void *encoded_data,
+										   uint32_t encoded_data_len,
+										   uint32_t encoded_rate,
+										   void *decoded_data,
+										   uint32_t * decoded_data_len, uint32_t * decoded_rate, unsigned int *flag)
 {
 	short *dbuf;
 	unsigned char *ebuf;
@@ -226,7 +226,7 @@ static const switch_codec_implementation_t g711u_8k_60ms_implementation = {
 	/*.encode */ switch_g711u_encode,
 	/*.decode */ switch_g711u_decode,
 	/*.destroy */ switch_g711u_destroy,
-	/*.next*/ &g711u_8k_120ms_implementation
+	/*.next */ &g711u_8k_120ms_implementation
 };
 
 static const switch_codec_implementation_t g711u_8k_30ms_implementation = {
@@ -247,7 +247,7 @@ static const switch_codec_implementation_t g711u_8k_30ms_implementation = {
 	/*.encode */ switch_g711u_encode,
 	/*.decode */ switch_g711u_decode,
 	/*.destroy */ switch_g711u_destroy,
-	/*.next*/ &g711u_8k_60ms_implementation
+	/*.next */ &g711u_8k_60ms_implementation
 };
 
 static const switch_codec_implementation_t g711u_8k_20ms_implementation = {
@@ -268,7 +268,7 @@ static const switch_codec_implementation_t g711u_8k_20ms_implementation = {
 	/*.encode */ switch_g711u_encode,
 	/*.decode */ switch_g711u_decode,
 	/*.destroy */ switch_g711u_destroy,
-	/*.next*/ &g711u_8k_30ms_implementation
+	/*.next */ &g711u_8k_30ms_implementation
 };
 
 static const switch_codec_implementation_t g711u_8k_10ms_implementation = {
@@ -289,7 +289,7 @@ static const switch_codec_implementation_t g711u_8k_10ms_implementation = {
 	/*.encode */ switch_g711u_encode,
 	/*.decode */ switch_g711u_decode,
 	/*.destroy */ switch_g711u_destroy,
-	/*.next*/ &g711u_8k_20ms_implementation
+	/*.next */ &g711u_8k_20ms_implementation
 };
 
 
@@ -332,7 +332,7 @@ static const switch_codec_implementation_t g711a_8k_60ms_implementation = {
 	/*.encode */ switch_g711a_encode,
 	/*.decode */ switch_g711a_decode,
 	/*.destroy */ switch_g711a_destroy,
-    /*.next*/ &g711a_8k_120ms_implementation
+	/*.next */ &g711a_8k_120ms_implementation
 };
 
 static const switch_codec_implementation_t g711a_8k_30ms_implementation = {
@@ -353,7 +353,7 @@ static const switch_codec_implementation_t g711a_8k_30ms_implementation = {
 	/*.encode */ switch_g711a_encode,
 	/*.decode */ switch_g711a_decode,
 	/*.destroy */ switch_g711a_destroy,
-    /*.next*/ &g711a_8k_60ms_implementation
+	/*.next */ &g711a_8k_60ms_implementation
 };
 
 static const switch_codec_implementation_t g711a_8k_20ms_implementation = {
@@ -374,7 +374,7 @@ static const switch_codec_implementation_t g711a_8k_20ms_implementation = {
 	/*.encode */ switch_g711a_encode,
 	/*.decode */ switch_g711a_decode,
 	/*.destroy */ switch_g711a_destroy,
-    /*.next*/ &g711a_8k_30ms_implementation
+	/*.next */ &g711a_8k_30ms_implementation
 };
 
 static const switch_codec_implementation_t g711a_8k_10ms_implementation = {
@@ -395,7 +395,7 @@ static const switch_codec_implementation_t g711a_8k_10ms_implementation = {
 	/*.encode */ switch_g711a_encode,
 	/*.decode */ switch_g711a_decode,
 	/*.destroy */ switch_g711a_destroy,
-    /*.next*/ &g711a_8k_20ms_implementation
+	/*.next */ &g711a_8k_20ms_implementation
 };
 
 
@@ -421,7 +421,8 @@ static switch_loadable_module_interface_t g711_module_interface = {
 };
 
 
-SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
+													   char *filename)
 {
 	/* connect my internal structure to the blank pointer passed to me */
 	*module_interface = &g711_module_interface;
diff --git a/src/mod/codecs/mod_g722/mod_g722.c b/src/mod/codecs/mod_g722/mod_g722.c
index 3537e4fd8a..d884c46241 100644
--- a/src/mod/codecs/mod_g722/mod_g722.c
+++ b/src/mod/codecs/mod_g722/mod_g722.c
@@ -41,7 +41,7 @@ struct g722_context {
 };
 
 static switch_status_t switch_g722_init(switch_codec_t *codec, switch_codec_flag_t flags,
-									   const switch_codec_settings_t *codec_settings)
+										const switch_codec_settings_t *codec_settings)
 {
 	int encoding, decoding;
 	struct g722_context *context = NULL;
@@ -50,18 +50,18 @@ static switch_status_t switch_g722_init(switch_codec_t *codec, switch_codec_flag
 	encoding = (flags & SWITCH_CODEC_FLAG_ENCODE);
 	decoding = (flags & SWITCH_CODEC_FLAG_DECODE);
 
-	if (!(encoding || decoding) || (!(context = switch_core_alloc(codec->memory_pool, sizeof(struct g722_context))))) { 
+	if (!(encoding || decoding) || (!(context = switch_core_alloc(codec->memory_pool, sizeof(struct g722_context))))) {
 		return SWITCH_STATUS_FALSE;
 	} else {
 		if (encoding) {
-			if(codec->implementation->samples_per_second == 16000){
+			if (codec->implementation->samples_per_second == 16000) {
 				g722_encode_init(&context->encoder_object, 64000, G722_PACKED);
 			} else {
 				g722_encode_init(&context->encoder_object, 64000, G722_SAMPLE_RATE_8000);
 			}
 		}
 		if (decoding) {
-			if(codec->implementation->samples_per_second == 16000){
+			if (codec->implementation->samples_per_second == 16000) {
 				g722_decode_init(&context->decoder_object, 64000, G722_PACKED);
 			} else {
 				g722_decode_init(&context->decoder_object, 64000, G722_SAMPLE_RATE_8000);
@@ -70,44 +70,47 @@ static switch_status_t switch_g722_init(switch_codec_t *codec, switch_codec_flag
 	}
 
 	codec->private_info = context;
-	return SWITCH_STATUS_SUCCESS;	
+	return SWITCH_STATUS_SUCCESS;
 }
 
 static switch_status_t switch_g722_encode(switch_codec_t *codec,
-										 switch_codec_t *other_codec,
-										 void *decoded_data,
-										 uint32_t decoded_data_len,
-										 uint32_t decoded_rate,
-										 void *encoded_data,
-										 uint32_t *encoded_data_len, uint32_t *encoded_rate, unsigned int *flag)
+										  switch_codec_t *other_codec,
+										  void *decoded_data,
+										  uint32_t decoded_data_len,
+										  uint32_t decoded_rate,
+										  void *encoded_data,
+										  uint32_t * encoded_data_len, uint32_t * encoded_rate, unsigned int *flag)
 {
 	struct g722_context *context = codec->private_info;
 
 	if (!context) {
-		return SWITCH_STATUS_FALSE; 
+		return SWITCH_STATUS_FALSE;
 	}
 
-	*encoded_data_len = g722_encode(&context->encoder_object, (uint8_t *) encoded_data, (int16_t *) decoded_data, decoded_data_len / 2);
-	
+	*encoded_data_len =
+		g722_encode(&context->encoder_object, (uint8_t *) encoded_data, (int16_t *) decoded_data, decoded_data_len / 2);
+
 	return SWITCH_STATUS_SUCCESS;
 }
 
 static switch_status_t switch_g722_decode(switch_codec_t *codec,
-										 switch_codec_t *other_codec,
-										 void *encoded_data,
-										 uint32_t encoded_data_len,
-										 uint32_t encoded_rate,
-										 void *decoded_data,
-										 uint32_t *decoded_data_len, uint32_t *decoded_rate, unsigned int *flag)
+										  switch_codec_t *other_codec,
+										  void *encoded_data,
+										  uint32_t encoded_data_len,
+										  uint32_t encoded_rate,
+										  void *decoded_data,
+										  uint32_t * decoded_data_len, uint32_t * decoded_rate, unsigned int *flag)
 {
 	struct g722_context *context = codec->private_info;
 
 	if (!context) {
-		return SWITCH_STATUS_FALSE; 
+		return SWITCH_STATUS_FALSE;
 	}
 
-	*decoded_data_len = (2 * g722_decode(&context->decoder_object, (int16_t *) decoded_data, (uint8_t *) encoded_data, encoded_data_len));
-	
+	*decoded_data_len =
+		(2 *
+		 g722_decode(&context->decoder_object, (int16_t *) decoded_data, (uint8_t *) encoded_data, encoded_data_len));
+
 	return SWITCH_STATUS_SUCCESS;
 }
 
@@ -175,7 +178,8 @@ static switch_loadable_module_interface_t g722_module_interface = {
 	/*.application_interface */ NULL
 };
 
-SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
+													   char *filename)
 {
 	/* connect my internal structure to the blank pointer passed to me */
 	*module_interface = &g722_module_interface;
diff --git a/src/mod/codecs/mod_g723_1/mod_g723_1.c b/src/mod/codecs/mod_g723_1/mod_g723_1.c
index c6a3e5a98a..eae6492e3a 100644
--- a/src/mod/codecs/mod_g723_1/mod_g723_1.c
+++ b/src/mod/codecs/mod_g723_1/mod_g723_1.c
@@ -30,7 +30,7 @@
  *
  * mod_g723.c -- G723.1 Codec Module
  *
- */  
+ */
 #include "switch.h"
 
 #ifndef G723_PASSTHROUGH
@@ -61,11 +61,11 @@ struct g723_context {
 #endif
 
 static switch_status_t switch_g723_init(switch_codec_t *codec, switch_codec_flag_t flags,
-									  const switch_codec_settings_t *codec_settings) 
+										const switch_codec_settings_t *codec_settings)
 {
 #ifdef G723_PASSTHROUGH
 	codec->flags |= SWITCH_CODEC_FLAG_PASSTHROUGH;
-	return  SWITCH_STATUS_FALSE;
+	return SWITCH_STATUS_FALSE;
 #else
 	struct g723_context *context = NULL;
 	int encoding, decoding;
@@ -79,10 +79,10 @@ static switch_status_t switch_g723_init(switch_codec_t *codec, switch_codec_flag
 
 		if (encoding) {
 			Init_Coder(&context->encoder_object);
-			if( UseVx ) {
+			if (UseVx) {
 				Init_Vad(&context->encoder_object);
 				Init_Cod_Cng(&context->encoder_object);
-			}		   
+			}
 		}
 
 		if (decoding) {
@@ -98,7 +98,7 @@ static switch_status_t switch_g723_init(switch_codec_t *codec, switch_codec_flag
 }
 
 
-static switch_status_t switch_g723_destroy(switch_codec_t *codec) 
+static switch_status_t switch_g723_destroy(switch_codec_t *codec)
 {
 #ifndef G723_PASSTHROUGH
 	codec->private_info = NULL;
@@ -106,17 +106,13 @@ static switch_status_t switch_g723_destroy(switch_codec_t *codec)
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status_t switch_g723_encode(switch_codec_t *codec, 
-										switch_codec_t *other_codec, 
-										void *decoded_data,
-
-										uint32_t decoded_data_len, 
-										uint32_t decoded_rate, 
-										void *encoded_data,
-
-										uint32_t *encoded_data_len, 
-										uint32_t *encoded_rate, 
-										unsigned int *flag) 
+static switch_status_t switch_g723_encode(switch_codec_t *codec,
+										  switch_codec_t *other_codec,
+										  void *decoded_data,
+										  uint32_t decoded_data_len,
+										  uint32_t decoded_rate,
+										  void *encoded_data,
+										  uint32_t * encoded_data_len, uint32_t * encoded_rate, unsigned int *flag)
 {
 #ifdef G723_PASSTHROUGH
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "This codec is only usable in passthrough mode!\n");
@@ -131,28 +127,24 @@ static switch_status_t switch_g723_encode(switch_codec_t *codec,
 		return SWITCH_STATUS_FALSE;
 	}
 
-	for(x = 0; x < Frame; x++) {
+	for (x = 0; x < Frame; x++) {
 		context->cod_float_buf[x] = decoded_slin_buf[x];
 	}
 
-	Coder(&context->encoder_object, (FLOAT *)context->cod_float_buf, ebuf);
+	Coder(&context->encoder_object, (FLOAT *) context->cod_float_buf, ebuf);
 	*encoded_data_len = codec->implementation->encoded_bytes_per_frame;
 
 	return SWITCH_STATUS_SUCCESS;
 #endif
 }
 
-static switch_status_t switch_g723_decode(switch_codec_t *codec, 
-										switch_codec_t *other_codec, 
-										void *encoded_data,
-
-										uint32_t encoded_data_len, 
-										uint32_t encoded_rate, 
-										void *decoded_data,
-
-										uint32_t *decoded_data_len, 
-										uint32_t *decoded_rate, 
-										unsigned int *flag) 
+static switch_status_t switch_g723_decode(switch_codec_t *codec,
+										  switch_codec_t *other_codec,
+										  void *encoded_data,
+										  uint32_t encoded_data_len,
+										  uint32_t encoded_rate,
+										  void *decoded_data,
+										  uint32_t * decoded_data_len, uint32_t * decoded_rate, unsigned int *flag)
 {
 #ifdef G723_PASSTHROUGH
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "This codec is only usable in passthrough mode!\n");
@@ -165,10 +157,10 @@ static switch_status_t switch_g723_decode(switch_codec_t *codec,
 	if (!context) {
 		return SWITCH_STATUS_FALSE;
 	}
-	
+
 	Decod(&context->decoder_object, (FLOAT *) context->dec_float_buf, (char *) decoded_data, 0);
 
-	for (x=0;xdec_float_buf[x];
 	}
 	*decoded_data_len = codec->implementation->bytes_per_frame;
@@ -177,49 +169,49 @@ static switch_status_t switch_g723_decode(switch_codec_t *codec,
 #endif
 }
 
-/* Registration */ 
+/* Registration */
 
-static const switch_codec_implementation_t g723_1_implementation = { 
-	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO, 
-	/*.ianacode */ 4, 
-	/*.iananame */ "G723", 
+static const switch_codec_implementation_t g723_1_implementation = {
+	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
+	/*.ianacode */ 4,
+	/*.iananame */ "G723",
 	/*.fmtp */ NULL,
-	/*.samples_per_second */ 8000, 
-	/*.bits_per_second */ 6300, 
-	/*.microseconds_per_frame */ 30000, 
-	/*.samples_per_frame */ 240, 
-	/*.bytes_per_frame */ 480, 
-	/*.encoded_bytes_per_frame */ 24, 
-	/*.number_of_channels */ 1, 
-	/*.pref_frames_per_packet */ 1, 
-	/*.max_frames_per_packet */ 4, 
-	/*.init */ switch_g723_init, 
-	/*.encode */ switch_g723_encode, 
-	/*.decode */ switch_g723_decode, 
-	/*.destroy */ switch_g723_destroy, 
+	/*.samples_per_second */ 8000,
+	/*.bits_per_second */ 6300,
+	/*.microseconds_per_frame */ 30000,
+	/*.samples_per_frame */ 240,
+	/*.bytes_per_frame */ 480,
+	/*.encoded_bytes_per_frame */ 24,
+	/*.number_of_channels */ 1,
+	/*.pref_frames_per_packet */ 1,
+	/*.max_frames_per_packet */ 4,
+	/*.init */ switch_g723_init,
+	/*.encode */ switch_g723_encode,
+	/*.decode */ switch_g723_decode,
+	/*.destroy */ switch_g723_destroy,
 };
 
-static const switch_codec_interface_t g723_1_codec_interface = { 
-	/*.interface_name */ "g723.1 6.3k", 
-	/*.implementations */ &g723_1_implementation, 
+static const switch_codec_interface_t g723_1_codec_interface = {
+	/*.interface_name */ "g723.1 6.3k",
+	/*.implementations */ &g723_1_implementation,
 };
 
-static switch_loadable_module_interface_t g723_module_interface = { 
-	/*.module_name */ modname, 
-	/*.endpoint_interface */ NULL, 
-	/*.timer_interface */ NULL, 
-	/*.dialplan_interface */ NULL, 
-	/*.codec_interface */ &g723_1_codec_interface, 
-	/*.application_interface */ NULL 
+static switch_loadable_module_interface_t g723_module_interface = {
+	/*.module_name */ modname,
+	/*.endpoint_interface */ NULL,
+	/*.timer_interface */ NULL,
+	/*.dialplan_interface */ NULL,
+	/*.codec_interface */ &g723_1_codec_interface,
+	/*.application_interface */ NULL
 };
 
 SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
-													 char *filename)
+													   char *filename)
 {
-	/* connect my internal structure to the blank pointer passed to me */ 
+	/* connect my internal structure to the blank pointer passed to me */
 	*module_interface = &g723_module_interface;
 
-	/* indicate that the module should continue to be loaded */ 
+	/* indicate that the module should continue to be loaded */
 	return SWITCH_STATUS_SUCCESS;
 }
 
diff --git a/src/mod/codecs/mod_g726/mod_g726.c b/src/mod/codecs/mod_g726/mod_g726.c
index d74b27d376..82cd575398 100644
--- a/src/mod/codecs/mod_g726/mod_g726.c
+++ b/src/mod/codecs/mod_g726/mod_g726.c
@@ -28,15 +28,15 @@
  *
  * mod_g726.c -- G726 Codec Module
  *
- */  
+ */
 #include "switch.h"
 #include "g72x.h"
 #include "switch_bitpack.h"
 
 static const char modname[] = "mod_g726";
 
-typedef int (*encoder_t)(int, int, g726_state *);
-typedef int (*decoder_t)(int, int, g726_state *);
+typedef int (*encoder_t) (int, int, g726_state *);
+typedef int (*decoder_t) (int, int, g726_state *);
 
 
 typedef struct {
@@ -53,7 +53,7 @@ typedef struct {
 } g726_handle_t;
 
 static switch_status_t switch_g726_init(switch_codec_t *codec, switch_codec_flag_t flags,
-									  const switch_codec_settings_t *codec_settings) 
+										const switch_codec_settings_t *codec_settings)
 {
 	uint32_t encoding, decoding;
 	g726_handle_t *handle;
@@ -65,8 +65,8 @@ static switch_status_t switch_g726_init(switch_codec_t *codec, switch_codec_flag
 		return SWITCH_STATUS_FALSE;
 	} else {
 		handle->bytes = (switch_byte_t) codec->implementation->encoded_bytes_per_frame;
-		
-		switch(handle->bytes) {
+
+		switch (handle->bytes) {
 		case 100:
 			handle->encoder = g726_40_encoder;
 			handle->decoder = g726_40_decoder;
@@ -88,22 +88,24 @@ static switch_status_t switch_g726_init(switch_codec_t *codec, switch_codec_flag
 			handle->loops = 160;
 			break;
 		default:
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "invalid Encoding Size %d!\n", codec->implementation->encoded_bytes_per_frame);
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "invalid Encoding Size %d!\n",
+							  codec->implementation->encoded_bytes_per_frame);
 			return SWITCH_STATUS_FALSE;
 			break;
 		}
 
 		g726_init_state(&handle->context);
 		codec->private_info = handle;
-		handle->bits_per_frame = (switch_byte_t) (codec->implementation->bits_per_second / (codec->implementation->samples_per_second));
-		handle->mode = (flags & SWITCH_CODEC_FLAG_AAL2 || strstr(codec->implementation->iananame, "AAL2")) 
+		handle->bits_per_frame =
+			(switch_byte_t) (codec->implementation->bits_per_second / (codec->implementation->samples_per_second));
+		handle->mode = (flags & SWITCH_CODEC_FLAG_AAL2 || strstr(codec->implementation->iananame, "AAL2"))
 			? SWITCH_BITPACK_MODE_AAL2 : SWITCH_BITPACK_MODE_RFC3551;
 		return SWITCH_STATUS_SUCCESS;
 	}
 }
 
 
-static switch_status_t switch_g726_destroy(switch_codec_t *codec) 
+static switch_status_t switch_g726_destroy(switch_codec_t *codec)
 {
 	codec->private_info = NULL;
 	return SWITCH_STATUS_SUCCESS;
@@ -111,17 +113,13 @@ static switch_status_t switch_g726_destroy(switch_codec_t *codec)
 
 
 
-static switch_status_t switch_g726_encode(switch_codec_t *codec, 
-										switch_codec_t *other_codec, 
-										void *decoded_data,
-
-										uint32_t decoded_data_len, 
-										uint32_t decoded_rate, 
-										void *encoded_data,
-
-										uint32_t *encoded_data_len, 
-										uint32_t *encoded_rate, 
-										unsigned int *flag) 
+static switch_status_t switch_g726_encode(switch_codec_t *codec,
+										  switch_codec_t *other_codec,
+										  void *decoded_data,
+										  uint32_t decoded_data_len,
+										  uint32_t decoded_rate,
+										  void *encoded_data,
+										  uint32_t * encoded_data_len, uint32_t * encoded_rate, unsigned int *flag)
 {
 
 	g726_handle_t *handle = codec->private_info;
@@ -153,7 +151,8 @@ static switch_status_t switch_g726_encode(switch_codec_t *codec,
 		if (new_len <= *encoded_data_len) {
 			*encoded_data_len = new_len;
 		} else {
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "buffer overflow!!! %u >= %u\n", new_len, *encoded_data_len);
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "buffer overflow!!! %u >= %u\n", new_len,
+							  *encoded_data_len);
 			return SWITCH_STATUS_FALSE;
 		}
 	}
@@ -163,17 +162,13 @@ static switch_status_t switch_g726_encode(switch_codec_t *codec,
 
 
 
-static switch_status_t switch_g726_decode(switch_codec_t *codec, 
-										switch_codec_t *other_codec, 
-										void *encoded_data,
-
-										uint32_t encoded_data_len, 
-										uint32_t encoded_rate, 
-										void *decoded_data,
-
-										uint32_t *decoded_data_len, 
-										uint32_t *decoded_rate, 
-										unsigned int *flag) 
+static switch_status_t switch_g726_decode(switch_codec_t *codec,
+										  switch_codec_t *other_codec,
+										  void *encoded_data,
+										  uint32_t encoded_data_len,
+										  uint32_t encoded_rate,
+										  void *decoded_data,
+										  uint32_t * decoded_data_len, uint32_t * decoded_rate, unsigned int *flag)
 {
 
 	g726_handle_t *handle = codec->private_info;
@@ -192,13 +187,13 @@ static switch_status_t switch_g726_decode(switch_codec_t *codec,
 		for (y = 0; y < handle->loops; y++) {
 			switch_bitpack_out(&handle->unpack, in[z++]);
 		}
-		for(y = 0; y < handle->bytes; y++) {
+		for (y = 0; y < handle->bytes; y++) {
 			*ddp++ = (int16_t) handle->decoder(handle->buf[y], AUDIO_ENCODING_LINEAR, context);
-            new_len += 2;
+			new_len += 2;
 		}
 		switch_bitpack_done(&handle->unpack);
 	}
-	
+
 	if (new_len <= *decoded_data_len) {
 		*decoded_data_len = new_len;
 	} else {
@@ -213,239 +208,239 @@ static switch_status_t switch_g726_decode(switch_codec_t *codec,
 
 
 
-/* Registration */ 
+/* Registration */
 
-static const switch_codec_implementation_t g726_16k_implementation = { 
-	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO, 
-	/*.ianacode */ 127, 
-	/*.iananame */ "G726-16", 
-	/*.fmtp */ NULL,
-	/*.samples_per_second */ 8000, 
-	/*.bits_per_second */ 16000, 
-	/*.microseconds_per_frame */ 20000, 
-	/*.samples_per_frame */ 160, 
-	/*.bytes_per_frame */ 320, 
-	/*.encoded_bytes_per_frame */ 40, 
-	/*.number_of_channels */ 1, 
-	/*.pref_frames_per_packet */ 1, 
-	/*.max_frames_per_packet */ 1, 
-	/*.init */ switch_g726_init, 
-	/*.encode */ switch_g726_encode, 
-	/*.decode */ switch_g726_decode, 
-	/*.destroy */ switch_g726_destroy, 
-};
-
-
-static const switch_codec_implementation_t g726_24k_implementation = { 
-	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO, 
-	/*.ianacode */ 126, 
-	/*.iananame */ "G726-24", 
-	/*.fmtp */ NULL,
-	/*.samples_per_second */ 8000, 
-	/*.bits_per_second */ 24000, 
-	/*.microseconds_per_frame */ 20000, 
-	/*.samples_per_frame */ 160, 
-	/*.bytes_per_frame */ 320, 
-	/*.encoded_bytes_per_frame */ 60, 
-	/*.number_of_channels */ 1, 
-	/*.pref_frames_per_packet */ 1, 
-	/*.max_frames_per_packet */ 1, 
-	/*.init */ switch_g726_init, 
-	/*.encode */ switch_g726_encode, 
-	/*.decode */ switch_g726_decode, 
-	/*.destroy */ switch_g726_destroy, 
-};
-
-static const switch_codec_implementation_t g726_32k_implementation = { 
-	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO, 
-	/*.ianacode */ 2, 
-	/*.iananame */ "G726-32", 
-	/*.fmtp */ NULL,
-	/*.samples_per_second */ 8000, 
-	/*.bits_per_second */ 32000, 
-	/*.microseconds_per_frame */ 20000, 
-	/*.samples_per_frame */ 160, 
-	/*.bytes_per_frame */ 320, 
-	/*.encoded_bytes_per_frame */ 80, 
-	/*.number_of_channels */ 1, 
-	/*.pref_frames_per_packet */ 1, 
-	/*.max_frames_per_packet */ 1, 
-	/*.init */ switch_g726_init, 
-	/*.encode */ switch_g726_encode, 
-	/*.decode */ switch_g726_decode, 
-	/*.destroy */ switch_g726_destroy, 
-};
-
-static const switch_codec_implementation_t g726_40k_implementation = { 
-	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO, 
-	/*.ianacode */ 125, 
-	/*.iananame */ "G726-40", 
+static const switch_codec_implementation_t g726_16k_implementation = {
+	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
+	/*.ianacode */ 127,
+	/*.iananame */ "G726-16",
 	/*.fmtp */ NULL,
 	/*.samples_per_second */ 8000,
-	/*.bits_per_second */ 40000, 
-	/*.microseconds_per_frame */ 20000, 
-	/*.samples_per_frame */ 160, 
-	/*.bytes_per_frame */ 320, 
-	/*.encoded_bytes_per_frame */ 100, 
-	/*.number_of_channels */ 1, 
-	/*.pref_frames_per_packet */ 1, 
-	/*.max_frames_per_packet */ 1, 
-	/*.init */ switch_g726_init, 
-	/*.encode */ switch_g726_encode, 
-	/*.decode */ switch_g726_decode, 
-	/*.destroy */ switch_g726_destroy, 
+	/*.bits_per_second */ 16000,
+	/*.microseconds_per_frame */ 20000,
+	/*.samples_per_frame */ 160,
+	/*.bytes_per_frame */ 320,
+	/*.encoded_bytes_per_frame */ 40,
+	/*.number_of_channels */ 1,
+	/*.pref_frames_per_packet */ 1,
+	/*.max_frames_per_packet */ 1,
+	/*.init */ switch_g726_init,
+	/*.encode */ switch_g726_encode,
+	/*.decode */ switch_g726_decode,
+	/*.destroy */ switch_g726_destroy,
 };
 
 
-
-static const switch_codec_implementation_t aal2_g726_16k_implementation = { 
-	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO, 
-	/*.ianacode */ 124, 
-	/*.iananame */ "AAL2-G726-16", 
-	/*.fmtp */ NULL,
-	/*.samples_per_second */ 8000, 
-	/*.bits_per_second */ 16000, 
-	/*.microseconds_per_frame */ 20000, 
-	/*.samples_per_frame */ 160, 
-	/*.bytes_per_frame */ 320, 
-	/*.encoded_bytes_per_frame */ 40, 
-	/*.number_of_channels */ 1, 
-	/*.pref_frames_per_packet */ 1, 
-	/*.max_frames_per_packet */ 1, 
-	/*.init */ switch_g726_init, 
-	/*.encode */ switch_g726_encode, 
-	/*.decode */ switch_g726_decode, 
-	/*.destroy */ switch_g726_destroy, 
-};
-
-
-static const switch_codec_implementation_t aal2_g726_24k_implementation = { 
-	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO, 
-	/*.ianacode */ 123, 
-	/*.iananame */ "AAL2-G726-24", 
-	/*.fmtp */ NULL,
-	/*.samples_per_second */ 8000, 
-	/*.bits_per_second */ 24000, 
-	/*.microseconds_per_frame */ 20000, 
-	/*.samples_per_frame */ 160, 
-	/*.bytes_per_frame */ 320, 
-	/*.encoded_bytes_per_frame */ 60, 
-	/*.number_of_channels */ 1, 
-	/*.pref_frames_per_packet */ 1, 
-	/*.max_frames_per_packet */ 1, 
-	/*.init */ switch_g726_init, 
-	/*.encode */ switch_g726_encode, 
-	/*.decode */ switch_g726_decode, 
-	/*.destroy */ switch_g726_destroy, 
-};
-
-static const switch_codec_implementation_t aal2_g726_32k_implementation = { 
-	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO, 
-	/*.ianacode */ 2, 
-	/*.iananame */ "AAL2-G726-32", 
-	/*.fmtp */ NULL,
-	/*.samples_per_second */ 8000, 
-	/*.bits_per_second */ 32000, 
-	/*.microseconds_per_frame */ 20000, 
-	/*.samples_per_frame */ 160, 
-	/*.bytes_per_frame */ 320, 
-	/*.encoded_bytes_per_frame */ 80, 
-	/*.number_of_channels */ 1, 
-	/*.pref_frames_per_packet */ 1, 
-	/*.max_frames_per_packet */ 1, 
-	/*.init */ switch_g726_init, 
-	/*.encode */ switch_g726_encode, 
-	/*.decode */ switch_g726_decode, 
-	/*.destroy */ switch_g726_destroy, 
-};
-
-static const switch_codec_implementation_t aal2_g726_40k_implementation = { 
-	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO, 
-	/*.ianacode */ 122, 
-	/*.iananame */ "AAL2-G726-40", 
+static const switch_codec_implementation_t g726_24k_implementation = {
+	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
+	/*.ianacode */ 126,
+	/*.iananame */ "G726-24",
 	/*.fmtp */ NULL,
 	/*.samples_per_second */ 8000,
-	/*.bits_per_second */ 40000, 
-	/*.microseconds_per_frame */ 20000, 
-	/*.samples_per_frame */ 160, 
-	/*.bytes_per_frame */ 320, 
-	/*.encoded_bytes_per_frame */ 100, 
-	/*.number_of_channels */ 1, 
-	/*.pref_frames_per_packet */ 1, 
-	/*.max_frames_per_packet */ 1, 
-	/*.init */ switch_g726_init, 
-	/*.encode */ switch_g726_encode, 
-	/*.decode */ switch_g726_decode, 
-	/*.destroy */ switch_g726_destroy, 
+	/*.bits_per_second */ 24000,
+	/*.microseconds_per_frame */ 20000,
+	/*.samples_per_frame */ 160,
+	/*.bytes_per_frame */ 320,
+	/*.encoded_bytes_per_frame */ 60,
+	/*.number_of_channels */ 1,
+	/*.pref_frames_per_packet */ 1,
+	/*.max_frames_per_packet */ 1,
+	/*.init */ switch_g726_init,
+	/*.encode */ switch_g726_encode,
+	/*.decode */ switch_g726_decode,
+	/*.destroy */ switch_g726_destroy,
 };
 
-const switch_codec_interface_t g726_16k_codec_interface = { 
-	/*.interface_name */ "G.726 16k", 
-	/*.implementations */ &g726_16k_implementation, 
+static const switch_codec_implementation_t g726_32k_implementation = {
+	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
+	/*.ianacode */ 2,
+	/*.iananame */ "G726-32",
+	/*.fmtp */ NULL,
+	/*.samples_per_second */ 8000,
+	/*.bits_per_second */ 32000,
+	/*.microseconds_per_frame */ 20000,
+	/*.samples_per_frame */ 160,
+	/*.bytes_per_frame */ 320,
+	/*.encoded_bytes_per_frame */ 80,
+	/*.number_of_channels */ 1,
+	/*.pref_frames_per_packet */ 1,
+	/*.max_frames_per_packet */ 1,
+	/*.init */ switch_g726_init,
+	/*.encode */ switch_g726_encode,
+	/*.decode */ switch_g726_decode,
+	/*.destroy */ switch_g726_destroy,
 };
 
-const switch_codec_interface_t g726_24k_codec_interface = { 
-	/*.interface_name */ "G.726 24k", 
-	/*.implementations */ &g726_24k_implementation, 
+static const switch_codec_implementation_t g726_40k_implementation = {
+	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
+	/*.ianacode */ 125,
+	/*.iananame */ "G726-40",
+	/*.fmtp */ NULL,
+	/*.samples_per_second */ 8000,
+	/*.bits_per_second */ 40000,
+	/*.microseconds_per_frame */ 20000,
+	/*.samples_per_frame */ 160,
+	/*.bytes_per_frame */ 320,
+	/*.encoded_bytes_per_frame */ 100,
+	/*.number_of_channels */ 1,
+	/*.pref_frames_per_packet */ 1,
+	/*.max_frames_per_packet */ 1,
+	/*.init */ switch_g726_init,
+	/*.encode */ switch_g726_encode,
+	/*.decode */ switch_g726_decode,
+	/*.destroy */ switch_g726_destroy,
+};
+
+
+
+static const switch_codec_implementation_t aal2_g726_16k_implementation = {
+	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
+	/*.ianacode */ 124,
+	/*.iananame */ "AAL2-G726-16",
+	/*.fmtp */ NULL,
+	/*.samples_per_second */ 8000,
+	/*.bits_per_second */ 16000,
+	/*.microseconds_per_frame */ 20000,
+	/*.samples_per_frame */ 160,
+	/*.bytes_per_frame */ 320,
+	/*.encoded_bytes_per_frame */ 40,
+	/*.number_of_channels */ 1,
+	/*.pref_frames_per_packet */ 1,
+	/*.max_frames_per_packet */ 1,
+	/*.init */ switch_g726_init,
+	/*.encode */ switch_g726_encode,
+	/*.decode */ switch_g726_decode,
+	/*.destroy */ switch_g726_destroy,
+};
+
+
+static const switch_codec_implementation_t aal2_g726_24k_implementation = {
+	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
+	/*.ianacode */ 123,
+	/*.iananame */ "AAL2-G726-24",
+	/*.fmtp */ NULL,
+	/*.samples_per_second */ 8000,
+	/*.bits_per_second */ 24000,
+	/*.microseconds_per_frame */ 20000,
+	/*.samples_per_frame */ 160,
+	/*.bytes_per_frame */ 320,
+	/*.encoded_bytes_per_frame */ 60,
+	/*.number_of_channels */ 1,
+	/*.pref_frames_per_packet */ 1,
+	/*.max_frames_per_packet */ 1,
+	/*.init */ switch_g726_init,
+	/*.encode */ switch_g726_encode,
+	/*.decode */ switch_g726_decode,
+	/*.destroy */ switch_g726_destroy,
+};
+
+static const switch_codec_implementation_t aal2_g726_32k_implementation = {
+	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
+	/*.ianacode */ 2,
+	/*.iananame */ "AAL2-G726-32",
+	/*.fmtp */ NULL,
+	/*.samples_per_second */ 8000,
+	/*.bits_per_second */ 32000,
+	/*.microseconds_per_frame */ 20000,
+	/*.samples_per_frame */ 160,
+	/*.bytes_per_frame */ 320,
+	/*.encoded_bytes_per_frame */ 80,
+	/*.number_of_channels */ 1,
+	/*.pref_frames_per_packet */ 1,
+	/*.max_frames_per_packet */ 1,
+	/*.init */ switch_g726_init,
+	/*.encode */ switch_g726_encode,
+	/*.decode */ switch_g726_decode,
+	/*.destroy */ switch_g726_destroy,
+};
+
+static const switch_codec_implementation_t aal2_g726_40k_implementation = {
+	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
+	/*.ianacode */ 122,
+	/*.iananame */ "AAL2-G726-40",
+	/*.fmtp */ NULL,
+	/*.samples_per_second */ 8000,
+	/*.bits_per_second */ 40000,
+	/*.microseconds_per_frame */ 20000,
+	/*.samples_per_frame */ 160,
+	/*.bytes_per_frame */ 320,
+	/*.encoded_bytes_per_frame */ 100,
+	/*.number_of_channels */ 1,
+	/*.pref_frames_per_packet */ 1,
+	/*.max_frames_per_packet */ 1,
+	/*.init */ switch_g726_init,
+	/*.encode */ switch_g726_encode,
+	/*.decode */ switch_g726_decode,
+	/*.destroy */ switch_g726_destroy,
+};
+
+const switch_codec_interface_t g726_16k_codec_interface = {
+	/*.interface_name */ "G.726 16k",
+	/*.implementations */ &g726_16k_implementation,
+};
+
+const switch_codec_interface_t g726_24k_codec_interface = {
+	/*.interface_name */ "G.726 24k",
+	/*.implementations */ &g726_24k_implementation,
 	/*.next */ &g726_16k_codec_interface
 };
 
-const switch_codec_interface_t g726_32k_codec_interface = { 
-	/*.interface_name */ "G.726 32k", 
-	/*.implementations */ &g726_32k_implementation, 
+const switch_codec_interface_t g726_32k_codec_interface = {
+	/*.interface_name */ "G.726 32k",
+	/*.implementations */ &g726_32k_implementation,
 	/*.next */ &g726_24k_codec_interface
 };
 
-const switch_codec_interface_t g726_40k_codec_interface = { 
-	/*.interface_name */ "G.726 40k", 
-	/*.implementations */ &g726_40k_implementation, 
+const switch_codec_interface_t g726_40k_codec_interface = {
+	/*.interface_name */ "G.726 40k",
+	/*.implementations */ &g726_40k_implementation,
 	/*.next */ &g726_32k_codec_interface
 };
 
 
 
-const switch_codec_interface_t aal2_g726_16k_codec_interface = { 
-	/*.interface_name */ "G.726 16k (aal2)", 
-	/*.implementations */ &aal2_g726_16k_implementation, 
+const switch_codec_interface_t aal2_g726_16k_codec_interface = {
+	/*.interface_name */ "G.726 16k (aal2)",
+	/*.implementations */ &aal2_g726_16k_implementation,
 	/*.next */ &g726_40k_codec_interface
 };
 
-const switch_codec_interface_t aal2_g726_24k_codec_interface = { 
-	/*.interface_name */ "G.726 24k (aal2)", 
-	/*.implementations */ &aal2_g726_24k_implementation, 
+const switch_codec_interface_t aal2_g726_24k_codec_interface = {
+	/*.interface_name */ "G.726 24k (aal2)",
+	/*.implementations */ &aal2_g726_24k_implementation,
 	/*.next */ &aal2_g726_16k_codec_interface
 };
 
-const switch_codec_interface_t aal2_g726_32k_codec_interface = { 
-	/*.interface_name */ "G.726 32k (aal2)", 
-	/*.implementations */ &aal2_g726_32k_implementation, 
+const switch_codec_interface_t aal2_g726_32k_codec_interface = {
+	/*.interface_name */ "G.726 32k (aal2)",
+	/*.implementations */ &aal2_g726_32k_implementation,
 	/*.next */ &aal2_g726_24k_codec_interface
 };
 
-const switch_codec_interface_t aal2_g726_40k_codec_interface = { 
-	/*.interface_name */ "G.726 40k (aal2)", 
-	/*.implementations */ &aal2_g726_40k_implementation, 
+const switch_codec_interface_t aal2_g726_40k_codec_interface = {
+	/*.interface_name */ "G.726 40k (aal2)",
+	/*.implementations */ &aal2_g726_40k_implementation,
 	/*.next */ &aal2_g726_32k_codec_interface
 };
 
 
 
-static switch_loadable_module_interface_t g726_module_interface = { 
-	/*.module_name */ modname, 
-	/*.endpoint_interface */ NULL, 
-	/*.timer_interface */ NULL, 
-	/*.dialplan_interface */ NULL, 
-	/*.codec_interface */ &aal2_g726_40k_codec_interface, 
-	/*.application_interface */ NULL 
+static switch_loadable_module_interface_t g726_module_interface = {
+	/*.module_name */ modname,
+	/*.endpoint_interface */ NULL,
+	/*.timer_interface */ NULL,
+	/*.dialplan_interface */ NULL,
+	/*.codec_interface */ &aal2_g726_40k_codec_interface,
+	/*.application_interface */ NULL
 };
 
 SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
-													 char *filename)
+													   char *filename)
 {
-	/* connect my internal structure to the blank pointer passed to me */ 
+	/* connect my internal structure to the blank pointer passed to me */
 	*module_interface = &g726_module_interface;
 
-	/* indicate that the module should continue to be loaded */ 
+	/* indicate that the module should continue to be loaded */
 	return SWITCH_STATUS_SUCCESS;
 }
 
diff --git a/src/mod/codecs/mod_g729/mod_g729.c b/src/mod/codecs/mod_g729/mod_g729.c
index d28e42dc53..f49defa1e3 100644
--- a/src/mod/codecs/mod_g729/mod_g729.c
+++ b/src/mod/codecs/mod_g729/mod_g729.c
@@ -30,7 +30,7 @@
  *
  * mod_g729.c -- G729 Codec Module
  *
- */  
+ */
 
 static const char modname[] = "mod_g729";
 
@@ -46,15 +46,15 @@ struct g729_context {
 #endif
 
 static switch_status_t switch_g729_init(switch_codec_t *codec, switch_codec_flag_t flags,
-									  const switch_codec_settings_t *codec_settings) 
+										const switch_codec_settings_t *codec_settings)
 {
 #ifdef G729_PASSTHROUGH
 	codec->flags |= SWITCH_CODEC_FLAG_PASSTHROUGH;
-    if (codec->fmtp_in) {
-        codec->fmtp_out = switch_core_strdup(codec->memory_pool, codec->fmtp_in);
-    }
+	if (codec->fmtp_in) {
+		codec->fmtp_out = switch_core_strdup(codec->memory_pool, codec->fmtp_in);
+	}
 	return SWITCH_STATUS_SUCCESS;
-#else 
+#else
 	struct g729_context *context = NULL;
 	int encoding, decoding;
 
@@ -64,9 +64,9 @@ static switch_status_t switch_g729_init(switch_codec_t *codec, switch_codec_flag
 	if (!(encoding || decoding) || (!(context = switch_core_alloc(codec->memory_pool, sizeof(struct g729_context))))) {
 		return SWITCH_STATUS_FALSE;
 	} else {
-        if (codec->fmtp_in) {
-            codec->fmtp_out = switch_core_strdup(codec->memory_pool, codec->fmtp_in);
-        }
+		if (codec->fmtp_in) {
+			codec->fmtp_out = switch_core_strdup(codec->memory_pool, codec->fmtp_in);
+		}
 
 		if (encoding) {
 			g729_init_coder(&context->encoder_object, 0);
@@ -84,7 +84,7 @@ static switch_status_t switch_g729_init(switch_codec_t *codec, switch_codec_flag
 #endif
 }
 
-static switch_status_t switch_g729_destroy(switch_codec_t *codec) 
+static switch_status_t switch_g729_destroy(switch_codec_t *codec)
 {
 #ifndef G729_PASSTHROUGH
 	codec->private_info = NULL;
@@ -92,17 +92,13 @@ static switch_status_t switch_g729_destroy(switch_codec_t *codec)
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status_t switch_g729_encode(switch_codec_t *codec, 
-										switch_codec_t *other_codec, 
-										void *decoded_data,
-
-										uint32_t decoded_data_len, 
-										uint32_t decoded_rate, 
-										void *encoded_data,
-
-										uint32_t *encoded_data_len, 
-										uint32_t *encoded_rate, 
-										unsigned int *flag) 
+static switch_status_t switch_g729_encode(switch_codec_t *codec,
+										  switch_codec_t *other_codec,
+										  void *decoded_data,
+										  uint32_t decoded_data_len,
+										  uint32_t decoded_rate,
+										  void *encoded_data,
+										  uint32_t * encoded_data_len, uint32_t * encoded_rate, unsigned int *flag)
 {
 #ifdef G729_PASSTHROUGH
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "This codec is only usable in passthrough mode!\n");
@@ -117,7 +113,7 @@ static switch_status_t switch_g729_encode(switch_codec_t *codec,
 
 	if (decoded_data_len % 160 == 0) {
 		uint32_t new_len = 0;
-		INT16 * ddp = decoded_data;
+		INT16 *ddp = decoded_data;
 		char *edp = encoded_data;
 		int x;
 		int loops = (int) decoded_data_len / 160;
@@ -132,7 +128,8 @@ static switch_status_t switch_g729_encode(switch_codec_t *codec,
 		if (new_len <= *encoded_data_len) {
 			*encoded_data_len = new_len;
 		} else {
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "buffer overflow!!! %u >= %u\n", new_len, *encoded_data_len);
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "buffer overflow!!! %u >= %u\n", new_len,
+							  *encoded_data_len);
 			return SWITCH_STATUS_FALSE;
 		}
 	}
@@ -140,17 +137,13 @@ static switch_status_t switch_g729_encode(switch_codec_t *codec,
 #endif
 }
 
-static switch_status_t switch_g729_decode(switch_codec_t *codec, 
-										switch_codec_t *other_codec, 
-										void *encoded_data,
-
-										uint32_t encoded_data_len, 
-										uint32_t encoded_rate, 
-										void *decoded_data,
-
-										uint32_t *decoded_data_len, 
-										uint32_t *decoded_rate, 
-										unsigned int *flag) 
+static switch_status_t switch_g729_decode(switch_codec_t *codec,
+										  switch_codec_t *other_codec,
+										  void *encoded_data,
+										  uint32_t encoded_data_len,
+										  uint32_t encoded_rate,
+										  void *decoded_data,
+										  uint32_t * decoded_data_len, uint32_t * decoded_rate, unsigned int *flag)
 {
 #ifdef G729_PASSTHROUGH
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "This codec is only usable in passthrough mode!\n");
@@ -189,7 +182,7 @@ static switch_status_t switch_g729_decode(switch_codec_t *codec,
 			uint32_t new_len = 0;
 
 			test = (uint8_t *) encoded_data;
-			if (*test == 0 && *(test+1) == 0) {
+			if (*test == 0 && *(test + 1) == 0) {
 				*decoded_data_len = (encoded_data_len / divisor) * 160;
 				memset(decoded_data, 0, *decoded_data_len);
 				return SWITCH_STATUS_SUCCESS;
@@ -213,55 +206,56 @@ static switch_status_t switch_g729_decode(switch_codec_t *codec,
 				return SWITCH_STATUS_FALSE;
 
 			}
-		} 
+		}
 	} else {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "yo this frame is an odd size [%d]\n", encoded_data_len);
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "yo this frame is an odd size [%d]\n",
+						  encoded_data_len);
 		return SWITCH_STATUS_FALSE;
 	}
 	return SWITCH_STATUS_SUCCESS;
 #endif
 }
 
-/* Registration */ 
+/* Registration */
 
-static const switch_codec_implementation_t g729_10ms_8k_implementation = { 
-	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO, 
-	/*.ianacode */ 18, 
-	/*.iananame */ "G729", 
+static const switch_codec_implementation_t g729_10ms_8k_implementation = {
+	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
+	/*.ianacode */ 18,
+	/*.iananame */ "G729",
 	/*.fmtp */ NULL,
-	/*.samples_per_second */ 8000, 
-	/*.bits_per_second */ 32000, 
-	/*.microseconds_per_frame */ 10000, 
-	/*.samples_per_frame */ 80, 
-	/*.bytes_per_frame */ 160, 
-	/*.encoded_bytes_per_frame */ 10, 
-	/*.number_of_channels */ 1, 
-	/*.pref_frames_per_packet */ 1, 
-	/*.max_frames_per_packet */ 1, 
-	/*.init */ switch_g729_init, 
-	/*.encode */ switch_g729_encode, 
-	/*.decode */ switch_g729_decode, 
-	/*.destroy */ switch_g729_destroy, 
+	/*.samples_per_second */ 8000,
+	/*.bits_per_second */ 32000,
+	/*.microseconds_per_frame */ 10000,
+	/*.samples_per_frame */ 80,
+	/*.bytes_per_frame */ 160,
+	/*.encoded_bytes_per_frame */ 10,
+	/*.number_of_channels */ 1,
+	/*.pref_frames_per_packet */ 1,
+	/*.max_frames_per_packet */ 1,
+	/*.init */ switch_g729_init,
+	/*.encode */ switch_g729_encode,
+	/*.decode */ switch_g729_decode,
+	/*.destroy */ switch_g729_destroy,
 };
 
-static const switch_codec_implementation_t g729_8k_implementation = { 
-	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO, 
-	/*.ianacode */ 18, 
-	/*.iananame */ "G729", 
+static const switch_codec_implementation_t g729_8k_implementation = {
+	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
+	/*.ianacode */ 18,
+	/*.iananame */ "G729",
 	/*.fmtp */ NULL,
-	/*.samples_per_second */ 8000, 
-	/*.bits_per_second */ 64000, 
-	/*.microseconds_per_frame */ 20000, 
-	/*.samples_per_frame */ 160, 
-	/*.bytes_per_frame */ 320, 
-	/*.encoded_bytes_per_frame */ 20, 
-	/*.number_of_channels */ 1, 
-	/*.pref_frames_per_packet */ 1, 
-	/*.max_frames_per_packet */ 1, 
-	/*.init */ switch_g729_init, 
-	/*.encode */ switch_g729_encode, 
-	/*.decode */ switch_g729_decode, 
-	/*.destroy */ switch_g729_destroy, 
+	/*.samples_per_second */ 8000,
+	/*.bits_per_second */ 64000,
+	/*.microseconds_per_frame */ 20000,
+	/*.samples_per_frame */ 160,
+	/*.bytes_per_frame */ 320,
+	/*.encoded_bytes_per_frame */ 20,
+	/*.number_of_channels */ 1,
+	/*.pref_frames_per_packet */ 1,
+	/*.max_frames_per_packet */ 1,
+	/*.init */ switch_g729_init,
+	/*.encode */ switch_g729_encode,
+	/*.decode */ switch_g729_decode,
+	/*.destroy */ switch_g729_destroy,
 	&g729_10ms_8k_implementation
 };
 
@@ -271,22 +265,22 @@ static const switch_codec_interface_t g729_codec_interface = {
 	/*.next */ NULL
 };
 
-static switch_loadable_module_interface_t g729_module_interface = { 
+static switch_loadable_module_interface_t g729_module_interface = {
 	/*.module_name */ "g729",
-	/*.endpoint_interface */ NULL, 
-	/*.timer_interface */ NULL, 
-	/*.dialplan_interface */ NULL, 
-	/*.codec_interface */ &g729_codec_interface, 
-	/*.application_interface */ NULL 
+	/*.endpoint_interface */ NULL,
+	/*.timer_interface */ NULL,
+	/*.dialplan_interface */ NULL,
+	/*.codec_interface */ &g729_codec_interface,
+	/*.application_interface */ NULL
 };
 
 SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
-													 char *filename)
+													   char *filename)
 {
-	/* connect my internal structure to the blank pointer passed to me */ 
+	/* connect my internal structure to the blank pointer passed to me */
 	*module_interface = &g729_module_interface;
 
-	/* indicate that the module should continue to be loaded */ 
+	/* indicate that the module should continue to be loaded */
 	return SWITCH_STATUS_SUCCESS;
 }
 
diff --git a/src/mod/codecs/mod_gsm/mod_gsm.c b/src/mod/codecs/mod_gsm/mod_gsm.c
index f82b7e617e..f5e107d70e 100644
--- a/src/mod/codecs/mod_gsm/mod_gsm.c
+++ b/src/mod/codecs/mod_gsm/mod_gsm.c
@@ -28,7 +28,7 @@
  *
  * mod_codec_gsm.c -- gsm Codec Module
  *
- */  
+ */
 #include "switch.h"
 #include "gsm.h"
 static const char modname[] = "mod_gsm";
@@ -37,7 +37,7 @@ struct gsm_context {
 	gsm decoder;
 };
 static switch_status_t switch_gsm_init(switch_codec_t *codec, switch_codec_flag_t flags,
-									   const switch_codec_settings_t *codec_settings) 
+									   const switch_codec_settings_t *codec_settings)
 {
 	struct gsm_context *context;
 	int encoding, decoding;
@@ -55,7 +55,7 @@ static switch_status_t switch_gsm_init(switch_codec_t *codec, switch_codec_flag_
 	codec->private_info = context;
 	return SWITCH_STATUS_SUCCESS;
 }
-static switch_status_t switch_gsm_destroy(switch_codec_t *codec) 
+static switch_status_t switch_gsm_destroy(switch_codec_t *codec)
 {
 	struct gsm_context *context = codec->private_info;
 	int encoding = (codec->flags & SWITCH_CODEC_FLAG_ENCODE);
@@ -68,8 +68,8 @@ static switch_status_t switch_gsm_destroy(switch_codec_t *codec)
 	return SWITCH_STATUS_SUCCESS;
 }
 static switch_status_t switch_gsm_encode(switch_codec_t *codec, switch_codec_t *other_codec, void *decoded_data,
-										  uint32_t decoded_data_len, uint32_t decoded_rate, void *encoded_data,
-										  uint32_t *encoded_data_len, uint32_t *encoded_rate, unsigned int *flag) 
+										 uint32_t decoded_data_len, uint32_t decoded_rate, void *encoded_data,
+										 uint32_t * encoded_data_len, uint32_t * encoded_rate, unsigned int *flag)
 {
 	struct gsm_context *context = codec->private_info;
 	if (!context) {
@@ -77,8 +77,8 @@ static switch_status_t switch_gsm_encode(switch_codec_t *codec, switch_codec_t *
 	}
 	if (decoded_data_len % 320 == 0) {
 		uint32_t new_len = 0;
-		gsm_signal * ddp = decoded_data;
-		gsm_byte * edp = encoded_data;
+		gsm_signal *ddp = decoded_data;
+		gsm_byte *edp = encoded_data;
 		int x;
 		int loops = (int) decoded_data_len / 320;
 		for (x = 0; x < loops && new_len < *encoded_data_len; x++) {
@@ -90,15 +90,16 @@ static switch_status_t switch_gsm_encode(switch_codec_t *codec, switch_codec_t *
 		if (new_len <= *encoded_data_len) {
 			*encoded_data_len = new_len;
 		} else {
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "buffer overflow!!! %u >= %u\n", new_len, *encoded_data_len);
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "buffer overflow!!! %u >= %u\n", new_len,
+							  *encoded_data_len);
 			return SWITCH_STATUS_FALSE;
 		}
 	}
 	return SWITCH_STATUS_SUCCESS;
 }
 static switch_status_t switch_gsm_decode(switch_codec_t *codec, switch_codec_t *other_codec, void *encoded_data,
-										  uint32_t encoded_data_len, uint32_t encoded_rate, void *decoded_data,
-										  uint32_t *decoded_data_len, uint32_t *decoded_rate, unsigned int *flag) 
+										 uint32_t encoded_data_len, uint32_t encoded_rate, void *decoded_data,
+										 uint32_t * decoded_data_len, uint32_t * decoded_rate, unsigned int *flag)
 {
 	struct gsm_context *context = codec->private_info;
 	if (!context) {
@@ -107,8 +108,8 @@ static switch_status_t switch_gsm_decode(switch_codec_t *codec, switch_codec_t *
 
 	if (encoded_data_len % 33 == 0) {
 		int loops = (int) encoded_data_len / 33;
-		gsm_byte * edp = encoded_data;
-		gsm_signal * ddp = decoded_data;
+		gsm_byte *edp = encoded_data;
+		gsm_signal *ddp = decoded_data;
 		int x;
 		uint32_t new_len = 0;
 
@@ -121,57 +122,59 @@ static switch_status_t switch_gsm_decode(switch_codec_t *codec, switch_codec_t *
 		if (new_len <= *decoded_data_len) {
 			*decoded_data_len = new_len;
 		} else {
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "buffer overflow!!! %u %u\n", new_len, *decoded_data_len);
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "buffer overflow!!! %u %u\n", new_len,
+							  *decoded_data_len);
 			return SWITCH_STATUS_FALSE;
 		}
 	} else {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "yo this frame is an odd size [%u]\n", encoded_data_len);
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "yo this frame is an odd size [%u]\n",
+						  encoded_data_len);
 	}
 	return SWITCH_STATUS_SUCCESS;
 }
 
 
-/* Registration */ 
-static const switch_codec_implementation_t gsm_8k_implementation = { 
-		/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO, 
-		/*.ianacode */ 3, 
-		/*.iananame */ "GSM", 
-		/*.fmtp */ NULL,
-		/*.samples_per_second */ 8000, 
-		/*.bits_per_second */ 13200, 
-		/*.microseconds_per_frame */ 20000, 
-		/*.samples_per_frame */ 160, 
-		/*.bytes_per_frame */ 320, 
-		/*.encoded_bytes_per_frame */ 33, 
-		/*.number_of_channels */ 1, 
-		/*.pref_frames_per_packet */ 1, 
-		/*.max_frames_per_packet */ 1, 
-		/*.init */ switch_gsm_init, 
-		/*.encode */ switch_gsm_encode, 
-		/*.decode */ switch_gsm_decode, 
-		/*.destroy */ switch_gsm_destroy, 
+/* Registration */
+static const switch_codec_implementation_t gsm_8k_implementation = {
+	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
+	/*.ianacode */ 3,
+	/*.iananame */ "GSM",
+	/*.fmtp */ NULL,
+	/*.samples_per_second */ 8000,
+	/*.bits_per_second */ 13200,
+	/*.microseconds_per_frame */ 20000,
+	/*.samples_per_frame */ 160,
+	/*.bytes_per_frame */ 320,
+	/*.encoded_bytes_per_frame */ 33,
+	/*.number_of_channels */ 1,
+	/*.pref_frames_per_packet */ 1,
+	/*.max_frames_per_packet */ 1,
+	/*.init */ switch_gsm_init,
+	/*.encode */ switch_gsm_encode,
+	/*.decode */ switch_gsm_decode,
+	/*.destroy */ switch_gsm_destroy,
 };
-static const switch_codec_interface_t gsm_codec_interface = { 
-		/*.interface_name */ "gsm", 
-		/*.implementations */ &gsm_8k_implementation, 
+static const switch_codec_interface_t gsm_codec_interface = {
+	/*.interface_name */ "gsm",
+	/*.implementations */ &gsm_8k_implementation,
 };
-static switch_loadable_module_interface_t gsm_module_interface = { 
-		/*.module_name */ modname, 
-		/*.endpoint_interface */ NULL, 
-		/*.timer_interface */ NULL, 
-		/*.dialplan_interface */ NULL, 
-		/*.codec_interface */ &gsm_codec_interface, 
-		/*.application_interface */ NULL 
+static switch_loadable_module_interface_t gsm_module_interface = {
+	/*.module_name */ modname,
+	/*.endpoint_interface */ NULL,
+	/*.timer_interface */ NULL,
+	/*.dialplan_interface */ NULL,
+	/*.codec_interface */ &gsm_codec_interface,
+	/*.application_interface */ NULL
 };
 SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
-														char *filename)
+													   char *filename)
 {
-	
-		/* connect my internal structure to the blank pointer passed to me */ 
-		*module_interface = &gsm_module_interface;
-	
-		/* indicate that the module should continue to be loaded */ 
-		return SWITCH_STATUS_SUCCESS;
+
+	/* connect my internal structure to the blank pointer passed to me */
+	*module_interface = &gsm_module_interface;
+
+	/* indicate that the module should continue to be loaded */
+	return SWITCH_STATUS_SUCCESS;
 }
 
 /* For Emacs:
diff --git a/src/mod/codecs/mod_ilbc/mod_ilbc.c b/src/mod/codecs/mod_ilbc/mod_ilbc.c
index 4ce80f65ad..d724b32dad 100644
--- a/src/mod/codecs/mod_ilbc/mod_ilbc.c
+++ b/src/mod/codecs/mod_ilbc/mod_ilbc.c
@@ -28,7 +28,7 @@
  *
  * mod_ilbc.c -- ilbc Codec Module
  *
- */  
+ */
 #include "switch.h"
 #include "iLBC_encode.h"
 #include "iLBC_decode.h"
@@ -45,11 +45,11 @@ struct ilbc_context {
 };
 
 static switch_status_t switch_ilbc_init(switch_codec_t *codec, switch_codec_flag_t flags,
-									  const switch_codec_settings_t *codec_settings) 
+										const switch_codec_settings_t *codec_settings)
 {
 	struct ilbc_context *context;
 	int encoding, decoding;
-	uint8_t ms = (uint8_t)(codec->implementation->microseconds_per_frame / 1000);
+	uint8_t ms = (uint8_t) (codec->implementation->microseconds_per_frame / 1000);
 
 
 	if (ms != 20 && ms != 30) {
@@ -82,13 +82,13 @@ static switch_status_t switch_ilbc_init(switch_codec_t *codec, switch_codec_flag
 	}
 
 	codec->fmtp_out = switch_core_strdup(codec->memory_pool, codec->implementation->fmtp);
-	
+
 	codec->private_info = context;
 	return SWITCH_STATUS_SUCCESS;
 }
 
 
-static switch_status_t switch_ilbc_destroy(switch_codec_t *codec) 
+static switch_status_t switch_ilbc_destroy(switch_codec_t *codec)
 {
 	codec->private_info = NULL;
 	return SWITCH_STATUS_SUCCESS;
@@ -96,14 +96,12 @@ static switch_status_t switch_ilbc_destroy(switch_codec_t *codec)
 
 
 static switch_status_t switch_ilbc_encode(switch_codec_t *codec,
-										 switch_codec_t *other_codec,
-										 void *decoded_data,
-										 uint32_t decoded_data_len,
-										 uint32_t decoded_rate,
-										 void *encoded_data,
-										 uint32_t *encoded_data_len, 
-										 uint32_t *encoded_rate,
-										 unsigned int *flag)
+										  switch_codec_t *other_codec,
+										  void *decoded_data,
+										  uint32_t decoded_data_len,
+										  uint32_t decoded_rate,
+										  void *encoded_data,
+										  uint32_t * encoded_data_len, uint32_t * encoded_rate, unsigned int *flag)
 {
 	struct ilbc_context *context = codec->private_info;
 
@@ -120,7 +118,7 @@ static switch_status_t switch_ilbc_encode(switch_codec_t *codec,
 		float buf[240];
 
 		for (x = 0; x < loops && new_len < *encoded_data_len; x++) {
-			for(y = 0; y < context->dbytes / sizeof(short) ; y++) {
+			for (y = 0; y < context->dbytes / sizeof(short); y++) {
 				buf[y] = ddp[y];
 			}
 			iLBC_encode(edp, buf, &context->encoder);
@@ -131,7 +129,8 @@ static switch_status_t switch_ilbc_encode(switch_codec_t *codec,
 		if (new_len <= *encoded_data_len) {
 			*encoded_data_len = new_len;
 		} else {
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "buffer overflow!!! %u >= %u\n", new_len, *encoded_data_len);
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "buffer overflow!!! %u >= %u\n", new_len,
+							  *encoded_data_len);
 			return SWITCH_STATUS_FALSE;
 		}
 	}
@@ -139,14 +138,12 @@ static switch_status_t switch_ilbc_encode(switch_codec_t *codec,
 }
 
 static switch_status_t switch_ilbc_decode(switch_codec_t *codec,
-										switch_codec_t *other_codec,
-										void *encoded_data,
-										uint32_t encoded_data_len,
-										uint32_t encoded_rate,
-										void *decoded_data,
-										uint32_t *decoded_data_len, 
-										uint32_t *decoded_rate, 
-										unsigned int *flag)
+										  switch_codec_t *other_codec,
+										  void *encoded_data,
+										  uint32_t encoded_data_len,
+										  uint32_t encoded_rate,
+										  void *decoded_data,
+										  uint32_t * decoded_data_len, uint32_t * decoded_rate, unsigned int *flag)
 {
 	struct ilbc_context *context = codec->private_info;
 
@@ -165,8 +162,8 @@ static switch_status_t switch_ilbc_decode(switch_codec_t *codec,
 
 		for (x = 0; x < loops && new_len < *decoded_data_len; x++) {
 			iLBC_decode(buf, edp, &context->decoder, 1);
-			for(y = 0; y < context->dbytes / sizeof(short) ; y++) {
-				ddp[y] = (short)buf[y];
+			for (y = 0; y < context->dbytes / sizeof(short); y++) {
+				ddp[y] = (short) buf[y];
 			}
 			ddp += context->dbytes / sizeof(short);
 			edp += context->bytes;
@@ -179,160 +176,161 @@ static switch_status_t switch_ilbc_decode(switch_codec_t *codec,
 			return SWITCH_STATUS_FALSE;
 		}
 	} else {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "yo this frame is an odd size [%d]\n", encoded_data_len);
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "yo this frame is an odd size [%d]\n",
+						  encoded_data_len);
 		return SWITCH_STATUS_FALSE;
 	}
 	return SWITCH_STATUS_SUCCESS;
 }
 
 
-/* Registration */ 
+/* Registration */
 
-static const switch_codec_implementation_t ilbc_8k_30ms_implementation = { 
-		/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO, 
-		/*.ianacode */ 97, 
-		/*.iananame */ "iLBC", 
-		/*.fmtp */ "mode=30",
-		/*.samples_per_second */ 8000, 
-		/*.bits_per_second */ NO_OF_BYTES_30MS*8*8000/BLOCKL_30MS,
-		/*.microseconds_per_frame */ 30000,
-		/*.samples_per_frame */ 240,
-		/*.bytes_per_frame */ 480,
-		/*.encoded_bytes_per_frame */ NO_OF_BYTES_30MS,
-		/*.number_of_channels */ 1,
-		/*.pref_frames_per_packet */ 1,
-		/*.max_frames_per_packet */ 1,
-		/*.init */ switch_ilbc_init,
-		/*.encode */ switch_ilbc_encode,
-		/*.decode */ switch_ilbc_decode,
-		/*.destroy */ switch_ilbc_destroy
+static const switch_codec_implementation_t ilbc_8k_30ms_implementation = {
+	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
+	/*.ianacode */ 97,
+	/*.iananame */ "iLBC",
+	/*.fmtp */ "mode=30",
+	/*.samples_per_second */ 8000,
+	/*.bits_per_second */ NO_OF_BYTES_30MS * 8 * 8000 / BLOCKL_30MS,
+	/*.microseconds_per_frame */ 30000,
+	/*.samples_per_frame */ 240,
+	/*.bytes_per_frame */ 480,
+	/*.encoded_bytes_per_frame */ NO_OF_BYTES_30MS,
+	/*.number_of_channels */ 1,
+	/*.pref_frames_per_packet */ 1,
+	/*.max_frames_per_packet */ 1,
+	/*.init */ switch_ilbc_init,
+	/*.encode */ switch_ilbc_encode,
+	/*.decode */ switch_ilbc_decode,
+	/*.destroy */ switch_ilbc_destroy
 };
 
-static const switch_codec_implementation_t ilbc_8k_20ms_implementation = { 
-		/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO, 
-		/*.ianacode */ 97, 
-		/*.iananame */ "iLBC", 
-		/*.fmtp */ "mode=20",
-		/*.samples_per_second */ 8000, 
-		/*.bits_per_second */ NO_OF_BYTES_20MS*8*8000/BLOCKL_20MS, 
-		/*.microseconds_per_frame */ 20000,
-		/*.samples_per_frame */ 160,
-		/*.bytes_per_frame */ 320,
-		/*.encoded_bytes_per_frame */ NO_OF_BYTES_20MS, 
-		/*.number_of_channels */ 1,
-		/*.pref_frames_per_packet */ 1,
-		/*.max_frames_per_packet */ 1,
-		/*.init */ switch_ilbc_init,
-		/*.encode */ switch_ilbc_encode,
-		/*.decode */ switch_ilbc_decode,
-		/*.destroy */ switch_ilbc_destroy,
-		/*.next */ &ilbc_8k_30ms_implementation
+static const switch_codec_implementation_t ilbc_8k_20ms_implementation = {
+	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
+	/*.ianacode */ 97,
+	/*.iananame */ "iLBC",
+	/*.fmtp */ "mode=20",
+	/*.samples_per_second */ 8000,
+	/*.bits_per_second */ NO_OF_BYTES_20MS * 8 * 8000 / BLOCKL_20MS,
+	/*.microseconds_per_frame */ 20000,
+	/*.samples_per_frame */ 160,
+	/*.bytes_per_frame */ 320,
+	/*.encoded_bytes_per_frame */ NO_OF_BYTES_20MS,
+	/*.number_of_channels */ 1,
+	/*.pref_frames_per_packet */ 1,
+	/*.max_frames_per_packet */ 1,
+	/*.init */ switch_ilbc_init,
+	/*.encode */ switch_ilbc_encode,
+	/*.decode */ switch_ilbc_decode,
+	/*.destroy */ switch_ilbc_destroy,
+	/*.next */ &ilbc_8k_30ms_implementation
 };
 
 
 
-static const switch_codec_implementation_t ilbc_102_8k_30ms_implementation = { 
-		/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO, 
-		/*.ianacode */ 102, 
-		/*.iananame */ "iLBC", 
-		/*.fmtp */ "mode=30",
-		/*.samples_per_second */ 8000, 
-		/*.bits_per_second */ NO_OF_BYTES_30MS*8*8000/BLOCKL_30MS,
-		/*.microseconds_per_frame */ 30000,
-		/*.samples_per_frame */ 240,
-		/*.bytes_per_frame */ 480,
-		/*.encoded_bytes_per_frame */ NO_OF_BYTES_30MS,
-		/*.number_of_channels */ 1,
-		/*.pref_frames_per_packet */ 1,
-		/*.max_frames_per_packet */ 1,
-		/*.init */ switch_ilbc_init,
-		/*.encode */ switch_ilbc_encode,
-		/*.decode */ switch_ilbc_decode,
-		/*.destroy */ switch_ilbc_destroy
+static const switch_codec_implementation_t ilbc_102_8k_30ms_implementation = {
+	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
+	/*.ianacode */ 102,
+	/*.iananame */ "iLBC",
+	/*.fmtp */ "mode=30",
+	/*.samples_per_second */ 8000,
+	/*.bits_per_second */ NO_OF_BYTES_30MS * 8 * 8000 / BLOCKL_30MS,
+	/*.microseconds_per_frame */ 30000,
+	/*.samples_per_frame */ 240,
+	/*.bytes_per_frame */ 480,
+	/*.encoded_bytes_per_frame */ NO_OF_BYTES_30MS,
+	/*.number_of_channels */ 1,
+	/*.pref_frames_per_packet */ 1,
+	/*.max_frames_per_packet */ 1,
+	/*.init */ switch_ilbc_init,
+	/*.encode */ switch_ilbc_encode,
+	/*.decode */ switch_ilbc_decode,
+	/*.destroy */ switch_ilbc_destroy
 };
 
-static const switch_codec_implementation_t ilbc_102_8k_20ms_implementation = { 
-		/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO, 
-		/*.ianacode */ 102, 
-		/*.iananame */ "iLBC102", 
-		/*.fmtp */ "mode=20",
-		/*.samples_per_second */ 8000, 
-		/*.bits_per_second */ NO_OF_BYTES_20MS*8*8000/BLOCKL_20MS, 
-		/*.microseconds_per_frame */ 20000,
-		/*.samples_per_frame */ 160,
-		/*.bytes_per_frame */ 320,
-		/*.encoded_bytes_per_frame */ NO_OF_BYTES_20MS, 
-		/*.number_of_channels */ 1,
-		/*.pref_frames_per_packet */ 1,
-		/*.max_frames_per_packet */ 1,
-		/*.init */ switch_ilbc_init,
-		/*.encode */ switch_ilbc_encode,
-		/*.decode */ switch_ilbc_decode,
-		/*.destroy */ switch_ilbc_destroy,
-		/*.next */ &ilbc_102_8k_30ms_implementation
+static const switch_codec_implementation_t ilbc_102_8k_20ms_implementation = {
+	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
+	/*.ianacode */ 102,
+	/*.iananame */ "iLBC102",
+	/*.fmtp */ "mode=20",
+	/*.samples_per_second */ 8000,
+	/*.bits_per_second */ NO_OF_BYTES_20MS * 8 * 8000 / BLOCKL_20MS,
+	/*.microseconds_per_frame */ 20000,
+	/*.samples_per_frame */ 160,
+	/*.bytes_per_frame */ 320,
+	/*.encoded_bytes_per_frame */ NO_OF_BYTES_20MS,
+	/*.number_of_channels */ 1,
+	/*.pref_frames_per_packet */ 1,
+	/*.max_frames_per_packet */ 1,
+	/*.init */ switch_ilbc_init,
+	/*.encode */ switch_ilbc_encode,
+	/*.decode */ switch_ilbc_decode,
+	/*.destroy */ switch_ilbc_destroy,
+	/*.next */ &ilbc_102_8k_30ms_implementation
 };
 
 
-static const switch_codec_implementation_t ilbc_8k_20ms_nonext_implementation = { 
-		/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO, 
-		/*.ianacode */ 97, 
-		/*.iananame */ "iLBC20ms",
-		/*.fmtp */ "mode=20",
-		/*.samples_per_second */ 8000, 
-		/*.bits_per_second */ NO_OF_BYTES_20MS*8*8000/BLOCKL_20MS, 
-		/*.microseconds_per_frame */ 20000,
-		/*.samples_per_frame */ 160,
-		/*.bytes_per_frame */ 320,
-		/*.encoded_bytes_per_frame */ NO_OF_BYTES_20MS, 
-		/*.number_of_channels */ 1,
-		/*.pref_frames_per_packet */ 1,
-		/*.max_frames_per_packet */ 1,
-		/*.init */ switch_ilbc_init,
-		/*.encode */ switch_ilbc_encode,
-		/*.decode */ switch_ilbc_decode,
-		/*.destroy */ switch_ilbc_destroy
+static const switch_codec_implementation_t ilbc_8k_20ms_nonext_implementation = {
+	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
+	/*.ianacode */ 97,
+	/*.iananame */ "iLBC20ms",
+	/*.fmtp */ "mode=20",
+	/*.samples_per_second */ 8000,
+	/*.bits_per_second */ NO_OF_BYTES_20MS * 8 * 8000 / BLOCKL_20MS,
+	/*.microseconds_per_frame */ 20000,
+	/*.samples_per_frame */ 160,
+	/*.bytes_per_frame */ 320,
+	/*.encoded_bytes_per_frame */ NO_OF_BYTES_20MS,
+	/*.number_of_channels */ 1,
+	/*.pref_frames_per_packet */ 1,
+	/*.max_frames_per_packet */ 1,
+	/*.init */ switch_ilbc_init,
+	/*.encode */ switch_ilbc_encode,
+	/*.decode */ switch_ilbc_decode,
+	/*.destroy */ switch_ilbc_destroy
 };
 
 
-static const switch_codec_interface_t ilbc_20ms_codec_interface = { 
-		/*.interface_name */ "ilbc", 
-		/*.implementations */ &ilbc_8k_20ms_nonext_implementation
+static const switch_codec_interface_t ilbc_20ms_codec_interface = {
+	/*.interface_name */ "ilbc",
+	/*.implementations */ &ilbc_8k_20ms_nonext_implementation
 };
 
-static const switch_codec_interface_t ilbc_102_codec_interface = { 
-		/*.interface_name */ "ilbc", 
-		/*.implementations */ &ilbc_102_8k_20ms_implementation, 
-		/*.next*/ &ilbc_20ms_codec_interface
+static const switch_codec_interface_t ilbc_102_codec_interface = {
+	/*.interface_name */ "ilbc",
+	/*.implementations */ &ilbc_102_8k_20ms_implementation,
+	/*.next */ &ilbc_20ms_codec_interface
 };
 
-static const switch_codec_interface_t ilbc_codec_interface = { 
-		/*.interface_name */ "ilbc", 
-		/*.implementations */ &ilbc_8k_20ms_implementation, 
-		/*.next*/ &ilbc_102_codec_interface
+static const switch_codec_interface_t ilbc_codec_interface = {
+	/*.interface_name */ "ilbc",
+	/*.implementations */ &ilbc_8k_20ms_implementation,
+	/*.next */ &ilbc_102_codec_interface
 };
 
 
-static switch_loadable_module_interface_t ilbc_module_interface = { 
-		/*.module_name */ modname, 
-		/*.endpoint_interface */ NULL, 
-		/*.timer_interface */ NULL, 
-		/*.dialplan_interface */ NULL, 
-		/*.codec_interface */ &ilbc_codec_interface, 
-		/*.application_interface */ NULL 
+static switch_loadable_module_interface_t ilbc_module_interface = {
+	/*.module_name */ modname,
+	/*.endpoint_interface */ NULL,
+	/*.timer_interface */ NULL,
+	/*.dialplan_interface */ NULL,
+	/*.codec_interface */ &ilbc_codec_interface,
+	/*.application_interface */ NULL
 };
 
 
 
 SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
-														char *filename)
+													   char *filename)
 {
-	
-		/* connect my internal structure to the blank pointer passed to me */ 
-		*module_interface = &ilbc_module_interface;
-	
 
-		/* indicate that the module should continue to be loaded */ 
-		return SWITCH_STATUS_SUCCESS;
+	/* connect my internal structure to the blank pointer passed to me */
+	*module_interface = &ilbc_module_interface;
+
+
+	/* indicate that the module should continue to be loaded */
+	return SWITCH_STATUS_SUCCESS;
 
 }
 
diff --git a/src/mod/codecs/mod_l16/mod_l16.c b/src/mod/codecs/mod_l16/mod_l16.c
index b86bc91963..053865b53c 100644
--- a/src/mod/codecs/mod_l16/mod_l16.c
+++ b/src/mod/codecs/mod_l16/mod_l16.c
@@ -35,7 +35,7 @@ static const char modname[] = "mod_l16";
 
 
 static switch_status_t switch_raw_init(switch_codec_t *codec, switch_codec_flag_t flags,
-									 const switch_codec_settings_t *codec_settings)
+									   const switch_codec_settings_t *codec_settings)
 {
 	int encoding, decoding;
 
@@ -50,15 +50,16 @@ static switch_status_t switch_raw_init(switch_codec_t *codec, switch_codec_flag_
 }
 
 static switch_status_t switch_raw_encode(switch_codec_t *codec,
-									   switch_codec_t *other_codec,
-									   void *decoded_data,
-									   uint32_t decoded_data_len,
-									   uint32_t decoded_rate,
-									   void *encoded_data,
-									   uint32_t *encoded_data_len, uint32_t *encoded_rate, unsigned int *flag)
+										 switch_codec_t *other_codec,
+										 void *decoded_data,
+										 uint32_t decoded_data_len,
+										 uint32_t decoded_rate,
+										 void *encoded_data,
+										 uint32_t * encoded_data_len, uint32_t * encoded_rate, unsigned int *flag)
 {
 	/* NOOP indicates that the audio in is already the same as the audio out, so no conversion was necessary. */
-	if (codec && other_codec && codec->implementation->samples_per_second != other_codec->implementation->samples_per_second) {
+	if (codec && other_codec
+		&& codec->implementation->samples_per_second != other_codec->implementation->samples_per_second) {
 		memcpy(encoded_data, decoded_data, decoded_data_len);
 		*encoded_data_len = decoded_data_len;
 		return SWITCH_STATUS_RESAMPLE;
@@ -67,14 +68,15 @@ static switch_status_t switch_raw_encode(switch_codec_t *codec,
 }
 
 static switch_status_t switch_raw_decode(switch_codec_t *codec,
-									   switch_codec_t *other_codec,
-									   void *encoded_data,
-									   uint32_t encoded_data_len,
-									   uint32_t encoded_rate,
-									   void *decoded_data,
-									   uint32_t *decoded_data_len, uint32_t *decoded_rate, unsigned int *flag)
+										 switch_codec_t *other_codec,
+										 void *encoded_data,
+										 uint32_t encoded_data_len,
+										 uint32_t encoded_rate,
+										 void *decoded_data,
+										 uint32_t * decoded_data_len, uint32_t * decoded_rate, unsigned int *flag)
 {
-	if (codec && other_codec && codec->implementation->samples_per_second != other_codec->implementation->samples_per_second) {
+	if (codec && other_codec
+		&& codec->implementation->samples_per_second != other_codec->implementation->samples_per_second) {
 		memcpy(decoded_data, encoded_data, encoded_data_len);
 		*decoded_data_len = encoded_data_len;
 		return SWITCH_STATUS_RESAMPLE;
@@ -107,7 +109,7 @@ static const switch_codec_implementation_t raw_32k_60ms_implementation = {
 	/*.encode = */ switch_raw_encode,
 	/*.decode = */ switch_raw_decode,
 	/*.destroy = */ switch_raw_destroy
-	/*.next = */ 
+		/*.next = */
 };
 
 static const switch_codec_implementation_t raw_32k_30ms_implementation = {
@@ -298,6 +300,7 @@ static const switch_codec_implementation_t raw_16k_10ms_implementation = {
 	/*.destroy = */ switch_raw_destroy,
 	/*.next = */ &raw_16k_20ms_implementation
 };
+
 ///////////////////////////////
 
 
@@ -426,7 +429,8 @@ static switch_loadable_module_interface_t raw_module_interface = {
 };
 
 
-SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
+													   char *filename)
 {
 	/* connect my internal structure to the blank pointer passed to me */
 	*module_interface = &raw_module_interface;
diff --git a/src/mod/codecs/mod_lpc10/mod_lpc10.c b/src/mod/codecs/mod_lpc10/mod_lpc10.c
index 7bb418da47..dc900f86ba 100644
--- a/src/mod/codecs/mod_lpc10/mod_lpc10.c
+++ b/src/mod/codecs/mod_lpc10/mod_lpc10.c
@@ -28,16 +28,16 @@
  *
  * mod_lpc10.c -- LPC10 Codec Module
  *
- */  
+ */
 
 #include "switch.h"
 #include "lpc10.h"
 
 enum {
 	SamplesPerFrame = 180,
-	BitsPerFrame    = 54,
-	BytesPerFrame   = (BitsPerFrame+7)/8,
-	BitsPerSecond   = 2400
+	BitsPerFrame = 54,
+	BytesPerFrame = (BitsPerFrame + 7) / 8,
+	BitsPerSecond = 2400
 };
 
 #define   SampleValueScale 32768.0
@@ -52,7 +52,7 @@ struct lpc10_context {
 };
 
 static switch_status_t switch_lpc10_init(switch_codec_t *codec, switch_codec_flag_t flags,
-									  const switch_codec_settings_t *codec_settings) 
+										 const switch_codec_settings_t *codec_settings)
 {
 	uint32_t encoding, decoding;
 	struct lpc10_context *context = NULL;
@@ -78,44 +78,40 @@ static switch_status_t switch_lpc10_init(switch_codec_t *codec, switch_codec_fla
 	}
 }
 
-static switch_status_t switch_lpc10_destroy(switch_codec_t *codec) 
+static switch_status_t switch_lpc10_destroy(switch_codec_t *codec)
 {
 	codec->private_info = NULL;
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status_t switch_lpc10_encode(switch_codec_t *codec, 
-										switch_codec_t *other_codec, 
-										void *decoded_data,
-
-										uint32_t decoded_data_len, 
-										uint32_t decoded_rate, 
-										void *encoded_data,
-
-										uint32_t *encoded_data_len, 
-										uint32_t *encoded_rate, 
-										unsigned int *flag) 
+static switch_status_t switch_lpc10_encode(switch_codec_t *codec,
+										   switch_codec_t *other_codec,
+										   void *decoded_data,
+										   uint32_t decoded_data_len,
+										   uint32_t decoded_rate,
+										   void *encoded_data,
+										   uint32_t * encoded_data_len, uint32_t * encoded_rate, unsigned int *flag)
 {
 	struct lpc10_context *context = codec->private_info;
 	uint8_t i;
 	int32_t bits[BitsPerFrame];
 	real speech[SamplesPerFrame];
-	const short *sampleBuffer = (const short *)decoded_data;
-	unsigned char *buffer = (unsigned char *)encoded_data;
+	const short *sampleBuffer = (const short *) decoded_data;
+	unsigned char *buffer = (unsigned char *) encoded_data;
 
 	if (!context) {
 		return SWITCH_STATUS_FALSE;
 	}
 
 	for (i = 0; i < SamplesPerFrame; i++)
-		speech[i] = (real)(sampleBuffer[i]/SampleValueScale);
+		speech[i] = (real) (sampleBuffer[i] / SampleValueScale);
 
 	lpc10_encode(speech, bits, &context->encoder_object);
 
 	memset(encoded_data, 0, BytesPerFrame);
 	for (i = 0; i < BitsPerFrame; i++) {
 		if (bits[i])
-			buffer[i>>3] |= 1 << (i&7);
+			buffer[i >> 3] |= 1 << (i & 7);
 	}
 
 	*encoded_data_len = BytesPerFrame;
@@ -123,91 +119,87 @@ static switch_status_t switch_lpc10_encode(switch_codec_t *codec,
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status_t switch_lpc10_decode(switch_codec_t *codec, 
-										switch_codec_t *other_codec, 
-										void *encoded_data,
-
-										uint32_t encoded_data_len, 
-										uint32_t encoded_rate, 
-										void *decoded_data,
-
-										uint32_t *decoded_data_len, 
-										uint32_t *decoded_rate, 
-										unsigned int *flag) 
+static switch_status_t switch_lpc10_decode(switch_codec_t *codec,
+										   switch_codec_t *other_codec,
+										   void *encoded_data,
+										   uint32_t encoded_data_len,
+										   uint32_t encoded_rate,
+										   void *decoded_data,
+										   uint32_t * decoded_data_len, uint32_t * decoded_rate, unsigned int *flag)
 {
 	struct lpc10_context *context = codec->private_info;
 	int i;
 	INT32 bits[BitsPerFrame];
 	real speech[SamplesPerFrame];
-	short *sampleBuffer = (short *)decoded_data;
-	const unsigned char *buffer = (const unsigned char *)encoded_data;
+	short *sampleBuffer = (short *) decoded_data;
+	const unsigned char *buffer = (const unsigned char *) encoded_data;
 
 	if (!context) {
 		return SWITCH_STATUS_FALSE;
 	}
 
 	for (i = 0; i < BitsPerFrame; i++)
-		bits[i] = (buffer[i>>3]&(1<<(i&7))) != 0;
+		bits[i] = (buffer[i >> 3] & (1 << (i & 7))) != 0;
 
 	lpc10_decode(bits, speech, &context->decoder_object);
 
 	for (i = 0; i < SamplesPerFrame; i++) {
-		real sample = (real)(speech[i]*SampleValueScale);
+		real sample = (real) (speech[i] * SampleValueScale);
 		if (sample < MinSampleValue)
 			sample = MinSampleValue;
 		else if (sample > MaxSampleValue)
 			sample = MaxSampleValue;
-		sampleBuffer[i] = (short)sample;
+		sampleBuffer[i] = (short) sample;
 	}
 
-	*decoded_data_len = SamplesPerFrame*2;
+	*decoded_data_len = SamplesPerFrame * 2;
 
 	return SWITCH_STATUS_SUCCESS;
 }
 
-/* Registration */ 
+/* Registration */
 
-static const switch_codec_implementation_t lpc10_implementation = { 
-	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO, 
-	/*.ianacode */ 7, 
-	/*.iananame */ "LPC", 
+static const switch_codec_implementation_t lpc10_implementation = {
+	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
+	/*.ianacode */ 7,
+	/*.iananame */ "LPC",
 	/*.fmtp */ NULL,
 	/*.samples_per_second */ 8000,
-	/*.bits_per_second */ 240, 
-	/*.microseconds_per_frame */ 22500, 
-	/*.samples_per_frame */ 180, 
-	/*.bytes_per_frame */ 360, 
-	/*.encoded_bytes_per_frame */ 7, 
-	/*.number_of_channels */ 1, 
-	/*.pref_frames_per_packet */ 1, 
-	/*.max_frames_per_packet */ 1, 
-	/*.init */ switch_lpc10_init, 
-	/*.encode */ switch_lpc10_encode, 
-	/*.decode */ switch_lpc10_decode, 
-	/*.destroy */ switch_lpc10_destroy, 
+	/*.bits_per_second */ 240,
+	/*.microseconds_per_frame */ 22500,
+	/*.samples_per_frame */ 180,
+	/*.bytes_per_frame */ 360,
+	/*.encoded_bytes_per_frame */ 7,
+	/*.number_of_channels */ 1,
+	/*.pref_frames_per_packet */ 1,
+	/*.max_frames_per_packet */ 1,
+	/*.init */ switch_lpc10_init,
+	/*.encode */ switch_lpc10_encode,
+	/*.decode */ switch_lpc10_decode,
+	/*.destroy */ switch_lpc10_destroy,
 };
 
-const switch_codec_interface_t lpc10_codec_interface = { 
-	/*.interface_name */ "LPC-10 2.4kbps", 
-	/*.implementations */ &lpc10_implementation, 
+const switch_codec_interface_t lpc10_codec_interface = {
+	/*.interface_name */ "LPC-10 2.4kbps",
+	/*.implementations */ &lpc10_implementation,
 };
 
-static switch_loadable_module_interface_t lpc10_module_interface = { 
-	/*.module_name */ modname, 
-	/*.endpoint_interface */ NULL, 
-	/*.timer_interface */ NULL, 
-	/*.dialplan_interface */ NULL, 
-	/*.codec_interface */ &lpc10_codec_interface, 
-	/*.application_interface */ NULL 
+static switch_loadable_module_interface_t lpc10_module_interface = {
+	/*.module_name */ modname,
+	/*.endpoint_interface */ NULL,
+	/*.timer_interface */ NULL,
+	/*.dialplan_interface */ NULL,
+	/*.codec_interface */ &lpc10_codec_interface,
+	/*.application_interface */ NULL
 };
 
 SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
-													 char *filename)
+													   char *filename)
 {
-	/* connect my internal structure to the blank pointer passed to me */ 
+	/* connect my internal structure to the blank pointer passed to me */
 	*module_interface = &lpc10_module_interface;
 
-	/* indicate that the module should continue to be loaded */ 
+	/* indicate that the module should continue to be loaded */
 	return SWITCH_STATUS_SUCCESS;
 }
 
diff --git a/src/mod/codecs/mod_speex/mod_speex.c b/src/mod/codecs/mod_speex/mod_speex.c
index be108e313e..c6f11073f5 100644
--- a/src/mod/codecs/mod_speex/mod_speex.c
+++ b/src/mod/codecs/mod_speex/mod_speex.c
@@ -73,7 +73,7 @@ struct speex_context {
 };
 
 static switch_status_t switch_speex_init(switch_codec_t *codec, switch_codec_flag_t flags,
-									   const switch_codec_settings_t *codec_settings)
+										 const switch_codec_settings_t *codec_settings)
 {
 	struct speex_context *context = NULL;
 	int encoding, decoding;
@@ -158,12 +158,12 @@ static switch_status_t switch_speex_init(switch_codec_t *codec, switch_codec_fla
 }
 
 static switch_status_t switch_speex_encode(switch_codec_t *codec,
-										 switch_codec_t *other_codec,
-										 void *decoded_data,
-										 uint32_t decoded_data_len,
-										 uint32_t decoded_rate,
-										 void *encoded_data,
-										 uint32_t *encoded_data_len, uint32_t *encoded_rate, unsigned int *flag)
+										   switch_codec_t *other_codec,
+										   void *decoded_data,
+										   uint32_t decoded_data_len,
+										   uint32_t decoded_rate,
+										   void *encoded_data,
+										   uint32_t * encoded_data_len, uint32_t * encoded_rate, unsigned int *flag)
 {
 	struct speex_context *context = codec->private_info;
 	short *buf;
@@ -211,12 +211,12 @@ static switch_status_t switch_speex_encode(switch_codec_t *codec,
 }
 
 static switch_status_t switch_speex_decode(switch_codec_t *codec,
-										 switch_codec_t *other_codec,
-										 void *encoded_data,
-										 uint32_t encoded_data_len,
-										 uint32_t encoded_rate,
-										 void *decoded_data,
-										 uint32_t *decoded_data_len, uint32_t *decoded_rate, unsigned int *flag)
+										   switch_codec_t *other_codec,
+										   void *encoded_data,
+										   uint32_t encoded_data_len,
+										   uint32_t encoded_rate,
+										   void *decoded_data,
+										   uint32_t * decoded_data_len, uint32_t * decoded_rate, unsigned int *flag)
 {
 	struct speex_context *context = codec->private_info;
 	short *buf;
@@ -343,7 +343,8 @@ static switch_loadable_module_interface_t speex_module_interface = {
 	/*.application_interface */ NULL
 };
 
-SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
+													   char *filename)
 {
 	/* connect my internal structure to the blank pointer passed to me */
 	*module_interface = &speex_module_interface;
diff --git a/src/mod/dialplans/mod_dialplan_directory/mod_dialplan_directory.c b/src/mod/dialplans/mod_dialplan_directory/mod_dialplan_directory.c
index 733468e354..047a4d12e6 100644
--- a/src/mod/dialplans/mod_dialplan_directory/mod_dialplan_directory.c
+++ b/src/mod/dialplans/mod_dialplan_directory/mod_dialplan_directory.c
@@ -46,12 +46,12 @@ static struct {
 } globals;
 
 SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_directory_name, globals.directory_name)
-SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_host, globals.host)
-SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_dn, globals.dn)
-SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_pass, globals.pass)
-SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_base, globals.base)
+	SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_host, globals.host)
+	SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_dn, globals.dn)
+	SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_pass, globals.pass)
+	SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_base, globals.base)
 
-static void load_config(void)
+	 static void load_config(void)
 {
 	char *cf = "dialplan_directory.conf";
 	switch_xml_t cfg, xml, settings, param;
@@ -100,19 +100,16 @@ static switch_caller_extension_t *directory_dialplan_hunt(switch_core_session_t
 	caller_profile = switch_channel_get_caller_profile(channel);
 
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Hello %s You Dialed %s!\n", caller_profile->caller_id_name,
-						  caller_profile->destination_number);
-	
-	
-	if (! (globals.directory_name && globals.host && globals.dn && globals.base && globals.pass)) {
+					  caller_profile->destination_number);
+
+
+	if (!(globals.directory_name && globals.host && globals.dn && globals.base && globals.pass)) {
 		return NULL;
 	}
 
-	if (switch_core_directory_open(&dh, 
+	if (switch_core_directory_open(&dh,
 								   globals.directory_name,
-								   globals.host,
-								   globals.dn,
-								   globals.pass,
-								   NULL) != SWITCH_STATUS_SUCCESS) {
+								   globals.host, globals.dn, globals.pass, NULL) != SWITCH_STATUS_SUCCESS) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't connect\n");
 		return NULL;
 	}
@@ -127,10 +124,10 @@ static switch_caller_extension_t *directory_dialplan_hunt(switch_core_session_t
 	while (switch_core_directory_next(&dh) == SWITCH_STATUS_SUCCESS) {
 		while (switch_core_directory_next_pair(&dh, &var, &val) == SWITCH_STATUS_SUCCESS) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "DIRECTORY VALUE [%s]=[%s]\n", var, val);
-			if(!strcasecmp(var, "callflow")) {
+			if (!strcasecmp(var, "callflow")) {
 				if (!extension) {
 					if ((extension = switch_caller_extension_new(session, caller_profile->destination_number,
-																  caller_profile->destination_number)) == 0) {
+																 caller_profile->destination_number)) == 0) {
 						switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "memory error!\n");
 						goto out;
 					}
@@ -143,11 +140,11 @@ static switch_caller_extension_t *directory_dialplan_hunt(switch_core_session_t
 			}
 		}
 	}
- out:
-	
+  out:
+
 	switch_core_directory_close(&dh);
 
-	
+
 	if (extension) {
 		switch_channel_set_state(channel, CS_EXECUTE);
 	}
@@ -159,7 +156,7 @@ static switch_caller_extension_t *directory_dialplan_hunt(switch_core_session_t
 static const switch_dialplan_interface_t directory_dialplan_interface = {
 	/*.interface_name = */ "directory",
 	/*.hunt_function = */ directory_dialplan_hunt
-	/*.next = NULL */
+		/*.next = NULL */
 };
 
 static const switch_loadable_module_interface_t directory_dialplan_module_interface = {
@@ -171,7 +168,8 @@ static const switch_loadable_module_interface_t directory_dialplan_module_interf
 	/*.application_interface = */ NULL
 };
 
-SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
+													   char *filename)
 {
 
 	load_config();
diff --git a/src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c b/src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c
index 15864aa992..647734d632 100644
--- a/src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c
+++ b/src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c
@@ -50,7 +50,7 @@ static int parse_exten(switch_core_session_t *session, switch_xml_t xexten, swit
 	switch_channel_t *channel;
 	char *exten_name = (char *) switch_xml_attr_soft(xexten, "name");
 	int proceed = 0;
-    switch_stream_handle_t stream = {0};
+	switch_stream_handle_t stream = { 0 };
 
 	channel = switch_core_session_get_channel(session);
 	caller_profile = switch_channel_get_caller_profile(channel);
@@ -63,7 +63,7 @@ static int parse_exten(switch_core_session_t *session, switch_xml_t xexten, swit
 		switch_regex_t *re = NULL;
 		int ovector[30];
 		break_t do_break_i = BREAK_ON_FALSE;
-		
+
 		field = (char *) switch_xml_attr(xcond, "field");
 
 		expression = (char *) switch_xml_attr_soft(xcond, "expression");
@@ -83,54 +83,58 @@ static int parse_exten(switch_core_session_t *session, switch_xml_t xexten, swit
 		if (field) {
 			if (*field == '$') {
 				char *cmd = switch_core_session_strdup(session, field + 1);
-				char *e, *arg;                
-                field = cmd;
-                field_data = "";
+				char *e, *arg;
+				field = cmd;
+				field_data = "";
 
-                if (*field == '{') {
-                    field++;
-                    if ((e = strchr(field, '}'))) {
-                        *e = '\0';
-                        field_data = switch_channel_get_variable(channel, field);
-                    }
-                } else {
-                    switch_safe_free(stream.data);
-                    memset(&stream, 0, sizeof(stream));
-                    SWITCH_STANDARD_STREAM(stream);
+				if (*field == '{') {
+					field++;
+					if ((e = strchr(field, '}'))) {
+						*e = '\0';
+						field_data = switch_channel_get_variable(channel, field);
+					}
+				} else {
+					switch_safe_free(stream.data);
+					memset(&stream, 0, sizeof(stream));
+					SWITCH_STANDARD_STREAM(stream);
 
-                    if ((arg = strchr(cmd, '('))) {
-                        *arg++ = '\0';
-                        if ((e = strchr(arg, ')'))) {
-                            *e = '\0';
-                            if (switch_api_execute(cmd, arg, session, &stream) == SWITCH_STATUS_SUCCESS) {
-                                field_data = stream.data;
-                            }
-                        }
-                    }
-                }
-            } else {
+					if ((arg = strchr(cmd, '('))) {
+						*arg++ = '\0';
+						if ((e = strchr(arg, ')'))) {
+							*e = '\0';
+							if (switch_api_execute(cmd, arg, session, &stream) == SWITCH_STATUS_SUCCESS) {
+								field_data = stream.data;
+							}
+						}
+					}
+				}
+			} else {
 				field_data = switch_caller_get_field_by_name(caller_profile, field);
 			}
 			if (!field_data) {
 				field_data = "";
 			}
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "test conditions %s(%s) =~ /%s/\n", field, field_data, expression);
-			if (!(proceed = switch_regex_perform(field_data, expression, &re, ovector, sizeof(ovector) / sizeof(ovector[0])))) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "test conditions %s(%s) =~ /%s/\n", field,
+							  field_data, expression);
+			if (!
+				(proceed =
+				 switch_regex_perform(field_data, expression, &re, ovector, sizeof(ovector) / sizeof(ovector[0])))) {
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Regex mismatch\n");
 
 				for (xaction = switch_xml_child(xcond, "anti-action"); xaction; xaction = xaction->next) {
-					char *application = (char*) switch_xml_attr_soft(xaction, "application");
+					char *application = (char *) switch_xml_attr_soft(xaction, "application");
 					char *data = (char *) switch_xml_attr_soft(xaction, "data");
 
 					if (!*extension) {
 						if ((*extension =
-							 switch_caller_extension_new(session, exten_name, caller_profile->destination_number)) == 0) {
+							 switch_caller_extension_new(session, exten_name,
+														 caller_profile->destination_number)) == 0) {
 							switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "memory error!\n");
-                            proceed = 0;
-                            goto done;
+							proceed = 0;
+							goto done;
 						}
 					}
-					
+
 					switch_caller_extension_add_application(session, *extension, application, data);
 				}
 
@@ -145,20 +149,20 @@ static int parse_exten(switch_core_session_t *session, switch_xml_t xexten, swit
 
 
 		for (xaction = switch_xml_child(xcond, "action"); xaction; xaction = xaction->next) {
-			char *application = (char*) switch_xml_attr_soft(xaction, "application");
+			char *application = (char *) switch_xml_attr_soft(xaction, "application");
 			char *data = (char *) switch_xml_attr_soft(xaction, "data");
 			char *substituted = NULL;
-            uint32_t len = 0;
+			uint32_t len = 0;
 			char *app_data = NULL;
 
 			if (field && strchr(expression, '(')) {
-                len = (uint32_t)(strlen(data) + strlen(field_data) + 10);
-                if (!(substituted = malloc(len))) {
-                    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "memory error!\n");
-                    proceed = 0;
-                    goto done;
-                }
-                memset(substituted, 0, len);
+				len = (uint32_t) (strlen(data) + strlen(field_data) + 10);
+				if (!(substituted = malloc(len))) {
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "memory error!\n");
+					proceed = 0;
+					goto done;
+				}
+				memset(substituted, 0, len);
 				switch_perform_substitution(re, proceed, data, field_data, substituted, len, ovector);
 				app_data = substituted;
 			} else {
@@ -169,15 +173,15 @@ static int parse_exten(switch_core_session_t *session, switch_xml_t xexten, swit
 				if ((*extension =
 					 switch_caller_extension_new(session, exten_name, caller_profile->destination_number)) == 0) {
 					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "memory error!\n");
-                    proceed = 0;
-                    goto done;
+					proceed = 0;
+					goto done;
 				}
 			}
 
 			switch_caller_extension_add_application(session, *extension, application, app_data);
-            switch_safe_free(substituted);
+			switch_safe_free(substituted);
 		}
-        
+
 		switch_regex_safe_free(re);
 
 		if (do_break_i == BREAK_ON_TRUE || do_break_i == BREAK_ALWAYS) {
@@ -185,110 +189,111 @@ static int parse_exten(switch_core_session_t *session, switch_xml_t xexten, swit
 		}
 	}
 
- done:
-    switch_safe_free(stream.data);
+  done:
+	switch_safe_free(stream.data);
 	return proceed;
 }
 
 static switch_status_t dialplan_xml_locate(switch_core_session_t *session,
 										   switch_caller_profile_t *caller_profile,
-										   switch_xml_t *root,
-										   switch_xml_t *node)
+										   switch_xml_t * root, switch_xml_t * node)
 {
 	switch_status_t status = SWITCH_STATUS_GENERR;
 	switch_channel_t *channel;
-    switch_stream_handle_t stream = {0};
-    switch_size_t encode_len = 1024, new_len = 0;
-    char *encode_buf = NULL;
-    char *prof[12] = {0}, *prof_names[12] = {0}, *e = NULL;
-    switch_hash_index_t *hi;
-    uint32_t x = 0;
+	switch_stream_handle_t stream = { 0 };
+	switch_size_t encode_len = 1024, new_len = 0;
+	char *encode_buf = NULL;
+	char *prof[12] = { 0 }, *prof_names[12] = {
+	0}, *e = NULL;
+	switch_hash_index_t *hi;
+	uint32_t x = 0;
 
 	channel = switch_core_session_get_channel(session);
 
-    SWITCH_STANDARD_STREAM(stream);
-    
-    if (!(encode_buf = malloc(encode_len))) {
-        goto done;
-    }
-    
-    prof[0] = caller_profile->context;
-    prof[1] = caller_profile->destination_number;
-    prof[2] = caller_profile->caller_id_name;
-    prof[3] = caller_profile->caller_id_number;
-    prof[4] = caller_profile->network_addr;
-    prof[5] = caller_profile->ani;
-    prof[6] = caller_profile->aniii;
-    prof[7] = caller_profile->rdnis;
-    prof[8] = caller_profile->source;
-    prof[9] = caller_profile->chan_name;
-    prof[10] = caller_profile->uuid;
+	SWITCH_STANDARD_STREAM(stream);
 
-    prof_names[0] = "context";
-    prof_names[1] = "destination_number";
-    prof_names[2] = "caller_id_name";
-    prof_names[3] = "caller_id_number";
-    prof_names[4] = "network_addr";
-    prof_names[5] = "ani";
-    prof_names[6] = "aniii";
-    prof_names[7] = "rdnis";
-    prof_names[8] = "source";
-    prof_names[9] = "chan_name";
-    prof_names[10] = "uuid";
+	if (!(encode_buf = malloc(encode_len))) {
+		goto done;
+	}
 
-    for (x = 0; prof[x]; x++) {
+	prof[0] = caller_profile->context;
+	prof[1] = caller_profile->destination_number;
+	prof[2] = caller_profile->caller_id_name;
+	prof[3] = caller_profile->caller_id_number;
+	prof[4] = caller_profile->network_addr;
+	prof[5] = caller_profile->ani;
+	prof[6] = caller_profile->aniii;
+	prof[7] = caller_profile->rdnis;
+	prof[8] = caller_profile->source;
+	prof[9] = caller_profile->chan_name;
+	prof[10] = caller_profile->uuid;
+
+	prof_names[0] = "context";
+	prof_names[1] = "destination_number";
+	prof_names[2] = "caller_id_name";
+	prof_names[3] = "caller_id_number";
+	prof_names[4] = "network_addr";
+	prof_names[5] = "ani";
+	prof_names[6] = "aniii";
+	prof_names[7] = "rdnis";
+	prof_names[8] = "source";
+	prof_names[9] = "chan_name";
+	prof_names[10] = "uuid";
+
+	for (x = 0; prof[x]; x++) {
 		if (switch_strlen_zero(prof[x])) {
 			continue;
 		}
-        new_len = (strlen(prof[x]) * 3) + 1;
-        if (encode_len < new_len) {
-            char *tmp;
-            
-            encode_len = new_len;
+		new_len = (strlen(prof[x]) * 3) + 1;
+		if (encode_len < new_len) {
+			char *tmp;
 
-            if (!(tmp = realloc(encode_buf, encode_len))) {
-                goto done;
-            }
+			encode_len = new_len;
 
-            encode_buf = tmp;
-        }
-        switch_url_encode(prof[x], encode_buf, encode_len - 1);
-        stream.write_function(&stream, "%s=%s&", prof_names[x], encode_buf);
-    }
+			if (!(tmp = realloc(encode_buf, encode_len))) {
+				goto done;
+			}
 
-
-	for (hi = switch_channel_variable_first(channel, switch_core_session_get_pool(session)); hi; hi = switch_hash_next(hi)) {
-        void *val;
-        const void *var;
-		switch_hash_this(hi, &var, NULL, &val);
-        
-        new_len = (strlen((char *) var) * 3) + 1;
-        if (encode_len < new_len) {
-            char *tmp;
-            
-            encode_len = new_len;
-
-            if (!(tmp = realloc(encode_buf, encode_len))) {
-                goto done;
-            }
-
-            encode_buf = tmp;
-        }
-
-        switch_url_encode((char *) val, encode_buf, encode_len - 1);
-        stream.write_function(&stream, "%s=%s&", (char *) var, encode_buf);
-        
+			encode_buf = tmp;
+		}
+		switch_url_encode(prof[x], encode_buf, encode_len - 1);
+		stream.write_function(&stream, "%s=%s&", prof_names[x], encode_buf);
 	}
-    
-    e = (char *)stream.data + (strlen((char *)stream.data) - 1);
 
-    if (e && *e == '&') {
-        *e = '\0';
-    }
+
+	for (hi = switch_channel_variable_first(channel, switch_core_session_get_pool(session)); hi;
+		 hi = switch_hash_next(hi)) {
+		void *val;
+		const void *var;
+		switch_hash_this(hi, &var, NULL, &val);
+
+		new_len = (strlen((char *) var) * 3) + 1;
+		if (encode_len < new_len) {
+			char *tmp;
+
+			encode_len = new_len;
+
+			if (!(tmp = realloc(encode_buf, encode_len))) {
+				goto done;
+			}
+
+			encode_buf = tmp;
+		}
+
+		switch_url_encode((char *) val, encode_buf, encode_len - 1);
+		stream.write_function(&stream, "%s=%s&", (char *) var, encode_buf);
+
+	}
+
+	e = (char *) stream.data + (strlen((char *) stream.data) - 1);
+
+	if (e && *e == '&') {
+		*e = '\0';
+	}
 
 	status = switch_xml_locate("dialplan", NULL, NULL, NULL, root, node, stream.data);
 
-done:
+  done:
 	switch_safe_free(stream.data);
 	switch_safe_free(encode_buf);
 	return status;
@@ -300,7 +305,7 @@ static switch_caller_extension_t *dialplan_hunt(switch_core_session_t *session,
 	switch_caller_extension_t *extension = NULL;
 	switch_channel_t *channel;
 	switch_xml_t alt_root = NULL, cfg, xml = NULL, xcontext, xexten;
-    char *alt_path = (char *) arg;
+	char *alt_path = (char *) arg;
 
 	channel = switch_core_session_get_channel(session);
 
@@ -319,41 +324,43 @@ static switch_caller_extension_t *dialplan_hunt(switch_core_session_t *session,
 	/* get our handle to the "dialplan" section of the config */
 
 	if (!switch_strlen_zero(alt_path)) {
-        switch_xml_t conf = NULL, tag = NULL;
-        if (!(alt_root = switch_xml_parse_file(alt_path))) {
-            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of [%s] failed\n", alt_path);
-            goto done;
-        }
-        
-		if ((conf = switch_xml_find_child(alt_root, "section", "name", "dialplan")) && 
+		switch_xml_t conf = NULL, tag = NULL;
+		if (!(alt_root = switch_xml_parse_file(alt_path))) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of [%s] failed\n", alt_path);
+			goto done;
+		}
+
+		if ((conf = switch_xml_find_child(alt_root, "section", "name", "dialplan")) &&
 			(tag = switch_xml_find_child(conf, "dialplan", NULL, NULL))) {
-            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Getting dialplan from alternate path: %s\n", alt_path);
-            xml = alt_root;
-            cfg = tag;
-        } else {
-            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of dialplan failed\n");
-            goto done;
-        }
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Getting dialplan from alternate path: %s\n",
+							  alt_path);
+			xml = alt_root;
+			cfg = tag;
+		} else {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of dialplan failed\n");
+			goto done;
+		}
 	} else {
 		if (dialplan_xml_locate(session, caller_profile, &xml, &cfg) != SWITCH_STATUS_SUCCESS) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of dialplan failed\n");
 			goto done;
 		}
-    }
-    
-    /* get a handle to the context tag */
+	}
+
+	/* get a handle to the context tag */
 	if (!(xcontext = switch_xml_find_child(cfg, "context", "name", caller_profile->context))) {
 		if (!(xcontext = switch_xml_find_child(cfg, "context", "name", "global"))) {
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "context %s not found\n", caller_profile->context);
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "context %s not found\n",
+							  caller_profile->context);
 			goto done;
 		}
 	}
-	
+
 	if (!(xexten = switch_xml_find_child(xcontext, "extension", "name", caller_profile->destination_number))) {
 		xexten = switch_xml_child(xcontext, "extension");
 	}
-	
-	while(xexten) {
+
+	while (xexten) {
 		int proceed = 0;
 		char *cont = (char *) switch_xml_attr_soft(xexten, "continue");
 
@@ -374,7 +381,7 @@ static switch_caller_extension_t *dialplan_hunt(switch_core_session_t *session,
 		switch_channel_set_state(channel, CS_EXECUTE);
 	}
 
-done:
+  done:
 	switch_xml_free(xml);
 	return extension;
 }
@@ -383,7 +390,7 @@ done:
 static const switch_dialplan_interface_t dialplan_interface = {
 	/*.interface_name = */ "XML",
 	/*.hunt_function = */ dialplan_hunt
-	/*.next = NULL */
+		/*.next = NULL */
 };
 
 static const switch_loadable_module_interface_t dialplan_module_interface = {
@@ -395,7 +402,8 @@ static const switch_loadable_module_interface_t dialplan_module_interface = {
 	/*.application_interface = */ NULL
 };
 
-SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
+													   char *filename)
 {
 
 	/* connect my internal structure to the blank pointer passed to me */
diff --git a/src/mod/directories/mod_ldap/mod_ldap.c b/src/mod/directories/mod_ldap/mod_ldap.c
index 202ace335c..d093c566de 100644
--- a/src/mod/directories/mod_ldap/mod_ldap.c
+++ b/src/mod/directories/mod_ldap/mod_ldap.c
@@ -44,10 +44,10 @@ static const char modname[] = "mod_ldap";
 
 struct ldap_context {
 	LDAP *ld;
-	LDAPMessage* msg;
-	LDAPMessage* entry;
-	BerElement* ber;
-	char* attr;
+	LDAPMessage *msg;
+	LDAPMessage *entry;
+	BerElement *ber;
+	char *attr;
 	char *var;
 	char *val;
 	char **vals;
@@ -60,14 +60,14 @@ struct ldap_context {
 static switch_status_t mod_ldap_open(switch_directory_handle_t *dh, char *source, char *dsn, char *passwd)
 {
 	struct ldap_context *context;
-	int  auth_method = LDAP_AUTH_SIMPLE;
+	int auth_method = LDAP_AUTH_SIMPLE;
 	int desired_version = LDAP_VERSION3;
 
 	if ((context = switch_core_alloc(dh->memory_pool, sizeof(*context))) == 0) {
 		return SWITCH_STATUS_MEMERR;
 	}
-	
-	if ((context->ld = ldap_init(source, LDAP_PORT)) == NULL ) {
+
+	if ((context->ld = ldap_init(source, LDAP_PORT)) == NULL) {
 		return SWITCH_STATUS_FALSE;
 	}
 
@@ -76,11 +76,11 @@ static switch_status_t mod_ldap_open(switch_directory_handle_t *dh, char *source
 		return SWITCH_STATUS_FALSE;
 	}
 
-	if (ldap_bind_s(context->ld, dsn, passwd, auth_method) != LDAP_SUCCESS ) {
+	if (ldap_bind_s(context->ld, dsn, passwd, auth_method) != LDAP_SUCCESS) {
 		return SWITCH_STATUS_FALSE;
 	}
 
-	
+
 	dh->private_info = context;
 
 	return SWITCH_STATUS_SUCCESS;
@@ -112,7 +112,7 @@ static switch_status_t mod_ldap_query(switch_directory_handle_t *dh, char *base,
 	if (ldap_count_entries(context->ld, context->msg) <= 0) {
 		return SWITCH_STATUS_FALSE;
 	}
-	
+
 	return SWITCH_STATUS_SUCCESS;
 }
 
@@ -161,7 +161,7 @@ static switch_status_t mod_ldap_next_pair(switch_directory_handle_t *dh, char **
 		*val = context->val;
 		return SWITCH_STATUS_SUCCESS;
 	} else {
-	itter:
+	  itter:
 		if (context->attr && context->vals) {
 			if ((*val = context->vals[context->vi++])) {
 				*var = context->attr;
@@ -177,7 +177,7 @@ static switch_status_t mod_ldap_next_pair(switch_directory_handle_t *dh, char **
 			ldap_memfree(context->val);
 			context->val = NULL;
 			if (context->ber) {
-				ber_free(context->ber,0);
+				ber_free(context->ber, 0);
 				context->ber = NULL;
 			}
 			context->attr = ldap_first_attribute(context->ld, context->entry, &context->ber);
@@ -188,22 +188,23 @@ static switch_status_t mod_ldap_next_pair(switch_directory_handle_t *dh, char **
 			context->attr = ldap_next_attribute(context->ld, context->entry, context->ber);
 		}
 		context->vitt++;
-		if (context->entry && context->attr && (context->vals = ldap_get_values(context->ld, context->entry, context->attr)) != 0) {
+		if (context->entry && context->attr
+			&& (context->vals = ldap_get_values(context->ld, context->entry, context->attr)) != 0) {
 			goto itter;
 		}
 	}
-	
+
 	return SWITCH_STATUS_FALSE;
 }
 
 
 static const switch_directory_interface_t ldap_directory_interface = {
-    /*.interface_name */ "ldap",
-	/*.directory_open*/ mod_ldap_open,
-	/*.directory_close*/ mod_ldap_close,
-	/*.directory_query*/ mod_ldap_query,
-	/*.directory_next*/ mod_ldap_next,
-	/*.directory_next_pair*/ mod_ldap_next_pair
+	/*.interface_name */ "ldap",
+	/*.directory_open */ mod_ldap_open,
+	/*.directory_close */ mod_ldap_close,
+	/*.directory_query */ mod_ldap_query,
+	/*.directory_next */ mod_ldap_next,
+	/*.directory_next_pair */ mod_ldap_next_pair
 };
 
 
diff --git a/src/mod/endpoints/mod_dingaling/mod_dingaling.c b/src/mod/endpoints/mod_dingaling/mod_dingaling.c
index f12c084c72..597c210ac0 100644
--- a/src/mod/endpoints/mod_dingaling/mod_dingaling.c
+++ b/src/mod/endpoints/mod_dingaling/mod_dingaling.c
@@ -45,12 +45,9 @@ static const char modname[] = "mod_dingaling";
 static switch_memory_pool_t *module_pool = NULL;
 
 static char sub_sql[] =
-"CREATE TABLE subscriptions (\n"
-"   sub_from            VARCHAR(255),\n"
-"   sub_to          VARCHAR(255),\n"
-"   show          VARCHAR(255),\n"
-"   status          VARCHAR(255)\n"
-");\n";
+	"CREATE TABLE subscriptions (\n"
+	"   sub_from            VARCHAR(255),\n"
+	"   sub_to          VARCHAR(255),\n" "   show          VARCHAR(255),\n" "   status          VARCHAR(255)\n" ");\n";
 
 
 typedef enum {
@@ -65,16 +62,16 @@ typedef enum {
 	TFLAG_CODEC_READY = (1 << 8),
 	TFLAG_TRANSPORT = (1 << 9),
 	TFLAG_ANSWER = (1 << 10),
-	TFLAG_VAD_IN = ( 1 << 11),
-	TFLAG_VAD_OUT = ( 1 << 12),
-	TFLAG_VAD = ( 1 << 13),
-	TFLAG_DO_CAND = ( 1 << 14),
+	TFLAG_VAD_IN = (1 << 11),
+	TFLAG_VAD_OUT = (1 << 12),
+	TFLAG_VAD = (1 << 13),
+	TFLAG_DO_CAND = (1 << 14),
 	TFLAG_DO_DESC = (1 << 15),
 	TFLAG_LANADDR = (1 << 16),
 	TFLAG_AUTO = (1 << 17),
 	TFLAG_DTMF = (1 << 18),
-	TFLAG_TIMER = ( 1 << 19),
-	TFLAG_TERM = ( 1 << 20),
+	TFLAG_TIMER = (1 << 19),
+	TFLAG_TERM = (1 << 20),
 	TFLAG_TRANSPORT_ACCEPT = (1 << 21),
 	TFLAG_READY = (1 << 22),
 } TFLAGS;
@@ -97,28 +94,28 @@ static struct {
 	switch_hash_t *profile_hash;
 	int running;
 	int handles;
-    char guess_ip[80];
+	char guess_ip[80];
 } globals;
 
 struct mdl_profile {
-    char *name;
-    char *login;
-    char *password;
-    char *message;
+	char *name;
+	char *login;
+	char *password;
+	char *message;
 	char *auto_reply;
-    char *dialplan;
-    char *ip;
-    char *extip;
-    char *lanaddr;
+	char *dialplan;
+	char *ip;
+	char *extip;
+	char *lanaddr;
 	char *server;
-    char *exten;
-    char *context;
+	char *exten;
+	char *context;
 	char *timer_name;
 	char *dbname;
 	switch_mutex_t *mutex;
-    ldl_handle_t *handle;
-    uint32_t flags;
-    uint32_t user_flags;
+	ldl_handle_t *handle;
+	uint32_t flags;
+	uint32_t user_flags;
 };
 
 struct private_object {
@@ -170,32 +167,36 @@ struct rfc2833_digit {
 
 
 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_rates_string, globals.codec_rates_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)
 
-static switch_status_t dl_login(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 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_ring(switch_core_session_t *session);
-static switch_status_t channel_on_loopback(switch_core_session_t *session);
-static switch_status_t channel_on_transmit(switch_core_session_t *session);
-static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *session, switch_caller_profile_t *outbound_profile,
-													switch_core_session_t **new_session, switch_memory_pool_t **pool);
-static switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t **frame, int timeout,
-										  switch_io_flag_t flags, int stream_id);
-static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, int timeout,
-										   switch_io_flag_t flags, int stream_id);
-static switch_status_t channel_kill_channel(switch_core_session_t *session, int sig);
+	 static switch_status_t dl_login(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 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_ring(switch_core_session_t *session);
+	 static switch_status_t channel_on_loopback(switch_core_session_t *session);
+	 static switch_status_t channel_on_transmit(switch_core_session_t *session);
+	 static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *session,
+														 switch_caller_profile_t *outbound_profile,
+														 switch_core_session_t **new_session,
+														 switch_memory_pool_t **pool);
+	 static switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t **frame, int timeout,
+											   switch_io_flag_t flags, int stream_id);
+	 static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, int timeout,
+												switch_io_flag_t flags, int stream_id);
+	 static switch_status_t channel_kill_channel(switch_core_session_t *session, int sig);
 
-static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsession, ldl_signal_t dl_signal, char *to, char *from, char *subject, char *msg);
-static ldl_status handle_response(ldl_handle_t *handle, char *id);
-static switch_status_t load_config(void);
-static int sin_callback(void *pArg, int argc, char **argv, char **columnNames);
+	 static ldl_status handle_signalling(ldl_handle_t * handle, ldl_session_t * dlsession, ldl_signal_t dl_signal,
+										 char *to, char *from, char *subject, char *msg);
+	 static ldl_status handle_response(ldl_handle_t * handle, char *id);
+	 static switch_status_t load_config(void);
+	 static int sin_callback(void *pArg, int argc, char **argv, char **columnNames);
 
 #define is_special(s) (s && (strstr(s, "ext+") || strstr(s, "user+")))
 
-static char *translate_rpid(char *in, char *ext)
+	 static char *translate_rpid(char *in, char *ext)
 {
 	char *r = NULL;
 
@@ -210,7 +211,7 @@ static char *translate_rpid(char *in, char *ext)
 	if (!in) {
 		return NULL;
 	}
-	
+
 	if (!strcasecmp(in, "busy")) {
 		r = "dnd";
 	}
@@ -228,7 +229,7 @@ static char *translate_rpid(char *in, char *ext)
 	} else if (ext && !strcasecmp(ext, "away")) {
 		r = "away";
 	}
-	
+
 	return r;
 }
 
@@ -242,7 +243,7 @@ static int sub_callback(void *pArg, int argc, char **argv, char **columnNames)
 	char *rpid = argv[3];
 	char *status = argv[4];
 	//char *proto = argv[5];
-	
+
 	if (switch_strlen_zero(type)) {
 		type = NULL;
 	} else if (!strcasecmp(type, "unavailable")) {
@@ -283,10 +284,10 @@ static void pres_event_handler(switch_event_t *event)
 {
 	struct mdl_profile *profile = NULL;
 	switch_hash_index_t *hi;
-    void *val;
+	void *val;
 	char *proto = switch_event_get_header(event, "proto");
 	char *from = switch_event_get_header(event, "from");
-	char *status= switch_event_get_header(event, "status");
+	char *status = switch_event_get_header(event, "status");
 	char *rpid = switch_event_get_header(event, "rpid");
 	char *type = switch_event_get_header(event, "event_subtype");
 	char *sql;
@@ -306,35 +307,36 @@ static void pres_event_handler(switch_event_t *event)
 		status = NULL;
 	}
 
-	switch(event->event_id) {
-	case SWITCH_EVENT_PRESENCE_PROBE: 
-        if (proto) {
-        	char *sql;
-            switch_core_db_t *db;
-            char *errmsg;
-            char *to = switch_event_get_header(event, "to");
-            char *f_host = NULL;
-            if (to) {
-                if ((f_host = strchr(to, '@'))) {
-                    f_host++;
-                }
-            }
+	switch (event->event_id) {
+	case SWITCH_EVENT_PRESENCE_PROBE:
+		if (proto) {
+			char *sql;
+			switch_core_db_t *db;
+			char *errmsg;
+			char *to = switch_event_get_header(event, "to");
+			char *f_host = NULL;
+			if (to) {
+				if ((f_host = strchr(to, '@'))) {
+					f_host++;
+				}
+			}
 
-            if (f_host && (profile = switch_core_hash_find(globals.profile_hash, f_host))) {
-                if (to && (sql = switch_mprintf("select * from subscriptions where sub_to='%q'", to))) {
-                    if (!(db = switch_core_db_open_file(profile->dbname))) {
-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening DB %s\n", profile->dbname);
-                        return;
-                    }
-                    switch_mutex_lock(profile->mutex);
-                    switch_core_db_exec(db, sql, sin_callback, profile, &errmsg);
-                    switch_mutex_unlock(profile->mutex);
-                    switch_core_db_close(db);
-                    switch_safe_free(sql);
-                }
-            }
-        }
-        return;
+			if (f_host && (profile = switch_core_hash_find(globals.profile_hash, f_host))) {
+				if (to && (sql = switch_mprintf("select * from subscriptions where sub_to='%q'", to))) {
+					if (!(db = switch_core_db_open_file(profile->dbname))) {
+						switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening DB %s\n",
+										  profile->dbname);
+						return;
+					}
+					switch_mutex_lock(profile->mutex);
+					switch_core_db_exec(db, sql, sin_callback, profile, &errmsg);
+					switch_mutex_unlock(profile->mutex);
+					switch_core_db_close(db);
+					switch_safe_free(sql);
+				}
+			}
+		}
+		return;
 	case SWITCH_EVENT_PRESENCE_IN:
 		if (!status) {
 			status = "Available";
@@ -346,7 +348,7 @@ static void pres_event_handler(switch_event_t *event)
 	default:
 		break;
 	}
-	
+
 
 	if (!type) {
 		type = "";
@@ -357,20 +359,21 @@ static void pres_event_handler(switch_event_t *event)
 	if (!status) {
 		status = "Away";
 	}
-	
 
-	sql = switch_mprintf("select sub_from, sub_to,'%q','%q','%q','%q' from subscriptions where sub_to like '%%%q'", 
+
+	sql = switch_mprintf("select sub_from, sub_to,'%q','%q','%q','%q' from subscriptions where sub_to like '%%%q'",
 						 type, rpid, status, proto, from);
-	
-	
-	for (hi = switch_hash_first(switch_hash_pool_get(globals.profile_hash), globals.profile_hash); hi; hi = switch_hash_next(hi)) {
-		char *errmsg;
-        switch_hash_this(hi, NULL, NULL, &val);
-        profile = (struct mdl_profile *) val;
 
-        if (!(profile->user_flags & LDL_FLAG_COMPONENT)) {
+
+	for (hi = switch_hash_first(switch_hash_pool_get(globals.profile_hash), globals.profile_hash); hi;
+		 hi = switch_hash_next(hi)) {
+		char *errmsg;
+		switch_hash_this(hi, NULL, NULL, &val);
+		profile = (struct mdl_profile *) val;
+
+		if (!(profile->user_flags & LDL_FLAG_COMPONENT)) {
 			continue;
-        }
+		}
 
 
 		if (sql) {
@@ -383,7 +386,7 @@ static void pres_event_handler(switch_event_t *event)
 			switch_mutex_unlock(profile->mutex);
 			switch_core_db_close(db);
 		}
-		
+
 
 	}
 
@@ -400,9 +403,9 @@ static switch_status_t chat_send(char *proto, char *from, char *to, char *subjec
 	if (from && (f_user = strdup(from))) {
 		if ((f_host = strchr(f_user, '@'))) {
 			*f_host++ = '\0';
-            if ((f_resource = strchr(f_host, '/'))) {
-                *f_resource++ = '\0';
-            }
+			if ((f_resource = strchr(f_host, '/'))) {
+				*f_resource++ = '\0';
+			}
 		}
 	}
 
@@ -412,7 +415,7 @@ static switch_status_t chat_send(char *proto, char *from, char *to, char *subjec
 		}
 
 		if (f_host && (profile = switch_core_hash_find(globals.profile_hash, f_host))) {
-			
+
 			if (!strcmp(proto, MDL_CHAT_PROTO)) {
 				from = hint;
 			} else {
@@ -439,12 +442,12 @@ static switch_status_t chat_send(char *proto, char *from, char *to, char *subjec
 
 static void roster_event_handler(switch_event_t *event)
 {
-	char *status= switch_event_get_header(event, "status");
-	char *from= switch_event_get_header(event, "from");
+	char *status = switch_event_get_header(event, "status");
+	char *from = switch_event_get_header(event, "from");
 	char *event_type = switch_event_get_header(event, "event_type");
 	struct mdl_profile *profile = NULL;
 	switch_hash_index_t *hi;
-    void *val;
+	void *val;
 	char *sql;
 	switch_core_db_t *db;
 
@@ -453,7 +456,7 @@ static void roster_event_handler(switch_event_t *event)
 	}
 
 	if (switch_strlen_zero(event_type)) {
-		event_type="presence";
+		event_type = "presence";
 	}
 
 	if (from) {
@@ -462,14 +465,15 @@ static void roster_event_handler(switch_event_t *event)
 		sql = switch_mprintf("select *,'%q' from subscriptions", status ? status : "");
 	}
 
-	for (hi = switch_hash_first(switch_hash_pool_get(globals.profile_hash), globals.profile_hash); hi; hi = switch_hash_next(hi)) {
+	for (hi = switch_hash_first(switch_hash_pool_get(globals.profile_hash), globals.profile_hash); hi;
+		 hi = switch_hash_next(hi)) {
 		char *errmsg;
-        switch_hash_this(hi, NULL, NULL, &val);
-        profile = (struct mdl_profile *) val;
+		switch_hash_this(hi, NULL, NULL, &val);
+		profile = (struct mdl_profile *) val;
 
-        if (!(profile->user_flags & LDL_FLAG_COMPONENT)) {
+		if (!(profile->user_flags & LDL_FLAG_COMPONENT)) {
 			continue;
-        }
+		}
 
 
 		if (sql) {
@@ -482,7 +486,7 @@ static void roster_event_handler(switch_event_t *event)
 			switch_mutex_unlock(profile->mutex);
 			switch_core_db_close(db);
 		}
-		
+
 	}
 
 	switch_safe_free(sql);
@@ -498,7 +502,7 @@ static int so_callback(void *pArg, int argc, char **argv, char **columnNames)
 
 
 	ldl_handle_send_presence(profile->handle, sub_to, sub_from, "unavailable", "dnd", "Bub-Bye");
-	
+
 	return 0;
 }
 
@@ -510,12 +514,12 @@ static int sin_callback(void *pArg, int argc, char **argv, char **columnNames)
 
 	//char *sub_from = argv[0];
 	char *sub_to = argv[1];
-	
+
 	if (is_special(sub_to)) {
 		if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
 			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "proto", MDL_CHAT_PROTO);
 			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", "%s", profile->login);
-			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s",  sub_to);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s", sub_to);
 			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "rpid", "available");
 			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "status", "Online");
 			switch_event_fire(&event);
@@ -529,22 +533,23 @@ static void sign_off(void)
 {
 	struct mdl_profile *profile = NULL;
 	switch_hash_index_t *hi;
-    void *val;
+	void *val;
 	char *sql;
 	switch_core_db_t *db;
 
 
 	sql = switch_mprintf("select * from subscriptions");
-	
 
-	for (hi = switch_hash_first(switch_hash_pool_get(globals.profile_hash), globals.profile_hash); hi; hi = switch_hash_next(hi)) {
+
+	for (hi = switch_hash_first(switch_hash_pool_get(globals.profile_hash), globals.profile_hash); hi;
+		 hi = switch_hash_next(hi)) {
 		char *errmsg;
-        switch_hash_this(hi, NULL, NULL, &val);
-        profile = (struct mdl_profile *) val;
+		switch_hash_this(hi, NULL, NULL, &val);
+		profile = (struct mdl_profile *) val;
 
-        if (!(profile->user_flags & LDL_FLAG_COMPONENT)) {
+		if (!(profile->user_flags & LDL_FLAG_COMPONENT)) {
 			continue;
-        }
+		}
 
 
 		if (sql) {
@@ -557,9 +562,9 @@ static void sign_off(void)
 			switch_mutex_unlock(profile->mutex);
 			switch_core_db_close(db);
 		}
-		
+
 	}
-	
+
 	switch_yield(1000000);
 	switch_safe_free(sql);
 
@@ -571,7 +576,10 @@ static void sign_on(struct mdl_profile *profile)
 	switch_core_db_t *db;
 	char *errmsg;
 
-	if ((sql = switch_mprintf("select * from subscriptions where sub_to like 'ext+%%' or sub_to like 'user+%%' or sub_to like 'conf+%%'"))) {
+	if ((sql =
+		 switch_mprintf
+		 ("select * from subscriptions where sub_to like 'ext+%%' or sub_to like 'user+%%' or sub_to like 'conf+%%'")))
+	{
 		if (!(db = switch_core_db_open_file(profile->dbname))) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening DB %s\n", profile->dbname);
 			return;
@@ -590,9 +598,10 @@ static void terminate_session(switch_core_session_t **session, int line, switch_
 		switch_channel_t *channel = switch_core_session_get_channel(*session);
 		switch_channel_state_t state = switch_channel_get_state(channel);
 		struct private_object *tech_pvt = NULL;
-		
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Terminate called from line %d state=%s\n", line, switch_channel_state_name(state));
- 
+
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Terminate called from line %d state=%s\n", line,
+						  switch_channel_state_name(state));
+
 		tech_pvt = switch_core_session_get_private(*session);
 
 		if (!tech_pvt || !switch_test_flag(tech_pvt, TFLAG_READY)) {
@@ -601,14 +610,14 @@ static void terminate_session(switch_core_session_t **session, int line, switch_
 		}
 
 		if (switch_test_flag(tech_pvt, TFLAG_TERM)) {
-			/*once is enough*/
+			/*once is enough */
 			return;
 		}
 
 		if (state < CS_HANGUP) {
 			switch_channel_hangup(channel, cause);
 		}
-		
+
 		switch_mutex_lock(tech_pvt->flag_mutex);
 		switch_set_flag(tech_pvt, TFLAG_TERM);
 		switch_set_flag(tech_pvt, TFLAG_BYE);
@@ -626,7 +635,7 @@ static void dl_logger(char *file, const char *func, int line, int level, char *f
 	char data[1024];
 
 	va_start(ap, fmt);
-	
+
 	vsnprintf(data, sizeof(data), fmt, ap);
 	switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, SWITCH_LOG_DEBUG, "%s", data);
 
@@ -648,7 +657,8 @@ static int get_codecs(struct private_object *tech_pvt)
 				return 0;
 			}
 		} else if (((tech_pvt->num_codecs =
-					 switch_loadable_module_get_codecs(switch_core_session_get_pool(tech_pvt->session), tech_pvt->codecs, SWITCH_MAX_CODECS))) <= 0) {
+					 switch_loadable_module_get_codecs(switch_core_session_get_pool(tech_pvt->session),
+													   tech_pvt->codecs, SWITCH_MAX_CODECS))) <= 0) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "NO codecs?\n");
 			return 0;
 		}
@@ -673,16 +683,17 @@ static void *SWITCH_THREAD_FUNC handle_thread_run(switch_thread_t *thread, void
 	switch_clear_flag(profile, TFLAG_IO);
 	globals.handles--;
 	ldl_handle_destroy(&handle);
-	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Handle %s [%s] Destroyed\n", profile->name, profile->login);
-	
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Handle %s [%s] Destroyed\n", profile->name,
+					  profile->login);
+
 	return NULL;
 }
 
-static void handle_thread_launch(ldl_handle_t *handle)
+static void handle_thread_launch(ldl_handle_t * handle)
 {
 	switch_thread_t *thread;
 	switch_threadattr_t *thd_attr = NULL;
-	
+
 	switch_threadattr_create(&thd_attr, module_pool);
 	switch_threadattr_detach_set(thd_attr, 1);
 	switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
@@ -702,10 +713,10 @@ static int activate_rtp(struct private_object *tech_pvt)
 		return 1;
 	}
 
-    if (!(tech_pvt->remote_ip && tech_pvt->remote_port)) {
+	if (!(tech_pvt->remote_ip && tech_pvt->remote_port)) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "No valid candidates received!\n");
-        return 0;
-    }
+		return 0;
+	}
 
 	if (switch_core_codec_init(&tech_pvt->read_codec,
 							   tech_pvt->codec_name,
@@ -722,9 +733,9 @@ static int activate_rtp(struct private_object *tech_pvt)
 	tech_pvt->read_frame.rate = tech_pvt->read_codec.implementation->samples_per_second;
 	tech_pvt->read_frame.codec = &tech_pvt->read_codec;
 
-	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Set Read Codec to %s@%d\n", 
-					  tech_pvt->codec_name, (int)tech_pvt->read_codec.implementation->samples_per_second);
-	
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Set Read Codec to %s@%d\n",
+					  tech_pvt->codec_name, (int) tech_pvt->read_codec.implementation->samples_per_second);
+
 	if (switch_core_codec_init(&tech_pvt->write_codec,
 							   tech_pvt->codec_name,
 							   NULL,
@@ -737,20 +748,21 @@ static int activate_rtp(struct private_object *tech_pvt)
 		switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 		return 0;
 	}
-	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Set Write Codec to %s@%d\n",  
-					  tech_pvt->codec_name,(int)tech_pvt->write_codec.implementation->samples_per_second);
-							
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Set Write Codec to %s@%d\n",
+					  tech_pvt->codec_name, (int) tech_pvt->write_codec.implementation->samples_per_second);
+
 	switch_core_session_set_read_codec(tech_pvt->session, &tech_pvt->read_codec);
 	switch_core_session_set_write_codec(tech_pvt->session, &tech_pvt->write_codec);
-	
 
-	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "SETUP RTP %s:%d -> %s:%d\n", tech_pvt->profile->ip, tech_pvt->local_port, tech_pvt->remote_ip, tech_pvt->remote_port);
-	
+
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "SETUP RTP %s:%d -> %s:%d\n", tech_pvt->profile->ip,
+					  tech_pvt->local_port, tech_pvt->remote_ip, tech_pvt->remote_port);
+
 	flags = SWITCH_RTP_FLAG_GOOGLEHACK | SWITCH_RTP_FLAG_AUTOADJ;
 	//flags = SWITCH_RTP_FLAG_AUTOADJ;
 
 	if (switch_test_flag(tech_pvt->profile, TFLAG_TIMER)) {
-	  flags |= SWITCH_RTP_FLAG_USE_TIMER;
+		flags |= SWITCH_RTP_FLAG_USE_TIMER;
 	}
 
 	flags |= SWITCH_RTP_FLAG_AUTO_CNG;
@@ -760,7 +772,7 @@ static int activate_rtp(struct private_object *tech_pvt)
 												 tech_pvt->remote_ip,
 												 tech_pvt->remote_port,
 												 tech_pvt->codec_num,
-                                                 tech_pvt->read_codec.implementation->encoded_bytes_per_frame,
+												 tech_pvt->read_codec.implementation->encoded_bytes_per_frame,
 												 tech_pvt->read_codec.implementation->microseconds_per_frame,
 												 flags,
 												 NULL,
@@ -775,7 +787,8 @@ static int activate_rtp(struct private_object *tech_pvt)
 		uint8_t inb = switch_test_flag(tech_pvt, TFLAG_OUTBOUND) ? 0 : 1;
 		switch_rtp_activate_ice(tech_pvt->rtp_session, tech_pvt->remote_user, tech_pvt->local_user);
 		if ((vad_in && inb) || (vad_out && !inb)) {
-			switch_rtp_enable_vad(tech_pvt->rtp_session, tech_pvt->session, &tech_pvt->read_codec, SWITCH_VAD_FLAG_TALKING);
+			switch_rtp_enable_vad(tech_pvt->rtp_session, tech_pvt->session, &tech_pvt->read_codec,
+								  SWITCH_VAD_FLAG_TALKING);
 			switch_set_flag_locked(tech_pvt, TFLAG_VAD);
 		}
 		switch_rtp_set_cng_pt(tech_pvt->rtp_session, 13);
@@ -818,10 +831,10 @@ static int do_candidates(struct private_object *tech_pvt, int force)
 
 		cand[0].port = tech_pvt->local_port;
 		cand[0].address = advip;
-				
+
 		if (!strncasecmp(advip, "stun:", 5)) {
 			char *stun_ip = advip + 5;
-					
+
 			if (tech_pvt->stun_ip) {
 				cand[0].address = tech_pvt->stun_ip;
 				cand[0].port = tech_pvt->stun_port;
@@ -833,18 +846,18 @@ static int do_candidates(struct private_object *tech_pvt, int force)
 				}
 
 				cand[0].address = tech_pvt->profile->ip;
-				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Stun Lookup Local %s:%d\n", cand[0].address, cand[0].port);
-				if (switch_stun_lookup(&cand[0].address,
-									   &cand[0].port,
-									   stun_ip,
-									   SWITCH_STUN_DEFAULT_PORT,
-									   &err,
-									   switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
-					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Stun Failed! %s:%d [%s]\n", stun_ip, SWITCH_STUN_DEFAULT_PORT, err);
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Stun Lookup Local %s:%d\n", cand[0].address,
+								  cand[0].port);
+				if (switch_stun_lookup
+					(&cand[0].address, &cand[0].port, stun_ip, SWITCH_STUN_DEFAULT_PORT, &err,
+					 switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Stun Failed! %s:%d [%s]\n", stun_ip,
+									  SWITCH_STUN_DEFAULT_PORT, err);
 					switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 					return 0;
 				}
-				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Stun Success %s:%d\n", cand[0].address, cand[0].port);
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Stun Success %s:%d\n", cand[0].address,
+								  cand[0].port);
 			}
 			cand[0].type = "stun";
 			tech_pvt->stun_ip = switch_core_session_strdup(tech_pvt->session, cand[0].address);
@@ -858,7 +871,8 @@ static int do_candidates(struct private_object *tech_pvt, int force)
 		cand[0].password = tech_pvt->local_pass;
 		cand[0].pref = 1;
 		cand[0].protocol = "udp";
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Send Candidate %s:%d [%s]\n", cand[0].address, cand[0].port, cand[0].username);
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Send Candidate %s:%d [%s]\n", cand[0].address,
+						  cand[0].port, cand[0].username);
 		tech_pvt->cand_id = ldl_session_candidates(tech_pvt->dlsession, cand, 1);
 		switch_set_flag_locked(tech_pvt, TFLAG_TRANSPORT);
 		switch_set_flag_locked(tech_pvt, TFLAG_RTP_READY);
@@ -912,12 +926,12 @@ static int do_describe(struct private_object *tech_pvt, int force)
 			tech_pvt->codec_rate = tech_pvt->codecs[0]->samples_per_second;
 			tech_pvt->r_codec_num = tech_pvt->codecs[0]->ianacode;
 			tech_pvt->codec_index = 0;
-					
+
 			payloads[0].name = lame(tech_pvt->codecs[0]->iananame);
 			payloads[0].id = tech_pvt->codecs[0]->ianacode;
 			payloads[0].rate = tech_pvt->codecs[0]->samples_per_second;
 			payloads[0].bps = tech_pvt->codecs[0]->bits_per_second;
-			
+
 		} else {
 			payloads[0].name = lame(tech_pvt->codecs[tech_pvt->codec_index]->iananame);
 			payloads[0].id = tech_pvt->codecs[tech_pvt->codec_index]->ianacode;
@@ -925,12 +939,15 @@ static int do_describe(struct private_object *tech_pvt, int force)
 			payloads[0].bps = tech_pvt->codecs[tech_pvt->codec_index]->bits_per_second;
 		}
 
-				
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Send Describe [%s@%d]\n", payloads[0].name, payloads[0].rate);
-		tech_pvt->desc_id = ldl_session_describe(tech_pvt->dlsession, payloads, 1,
-												 switch_test_flag(tech_pvt, TFLAG_OUTBOUND) ? LDL_DESCRIPTION_INITIATE : LDL_DESCRIPTION_ACCEPT);
+
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Send Describe [%s@%d]\n", payloads[0].name,
+						  payloads[0].rate);
+		tech_pvt->desc_id =
+			ldl_session_describe(tech_pvt->dlsession, payloads, 1,
+								 switch_test_flag(tech_pvt,
+												  TFLAG_OUTBOUND) ? LDL_DESCRIPTION_INITIATE : LDL_DESCRIPTION_ACCEPT);
 		switch_set_flag_locked(tech_pvt, TFLAG_CODEC_READY);
-	} 
+	}
 	switch_clear_flag_locked(tech_pvt, TFLAG_DO_CAND);
 	return 1;
 }
@@ -957,7 +974,7 @@ static switch_status_t negotiate_media(switch_core_session_t *session)
 	/* jingle has no ringing indication so we will just pretend that we got one */
 	switch_core_session_queue_indication(session, SWITCH_MESSAGE_INDICATE_RINGING);
 	switch_channel_mark_ring_ready(channel);
-	
+
 	if (switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) {
 		tech_pvt->next_cand = switch_time_now() + DL_CAND_WAIT;
 		tech_pvt->next_desc = switch_time_now();
@@ -966,63 +983,62 @@ static switch_status_t negotiate_media(switch_core_session_t *session)
 		tech_pvt->next_desc = switch_time_now() + DL_CAND_WAIT;
 	}
 
-	while(! (switch_test_flag(tech_pvt, TFLAG_CODEC_READY) && 
-			 switch_test_flag(tech_pvt, TFLAG_RTP_READY) && 
-			 switch_test_flag(tech_pvt, TFLAG_ANSWER) && 
-			 switch_test_flag(tech_pvt, TFLAG_TRANSPORT_ACCEPT) &&
-			 switch_test_flag(tech_pvt, TFLAG_TRANSPORT))) {
+	while (!(switch_test_flag(tech_pvt, TFLAG_CODEC_READY) &&
+			 switch_test_flag(tech_pvt, TFLAG_RTP_READY) &&
+			 switch_test_flag(tech_pvt, TFLAG_ANSWER) &&
+			 switch_test_flag(tech_pvt, TFLAG_TRANSPORT_ACCEPT) && switch_test_flag(tech_pvt, TFLAG_TRANSPORT))) {
 		now = switch_time_now();
-		elapsed = (unsigned int)((now - started) / 1000);
+		elapsed = (unsigned int) ((now - started) / 1000);
 
 		if (switch_channel_get_state(channel) >= CS_HANGUP || switch_test_flag(tech_pvt, TFLAG_BYE)) {
 			goto out;
 		}
 
-		
+
 		if (now >= tech_pvt->next_desc) {
 			if (!do_describe(tech_pvt, 0)) {
 				goto out;
 			}
 		}
-		
+
 		if (tech_pvt->next_cand && now >= tech_pvt->next_cand) {
 			if (!do_candidates(tech_pvt, 0)) {
 				goto out;
 			}
 		}
 		if (elapsed > 60000) {
-			terminate_session(&tech_pvt->session,  __LINE__, SWITCH_CAUSE_NORMAL_CLEARING);
+			terminate_session(&tech_pvt->session, __LINE__, SWITCH_CAUSE_NORMAL_CLEARING);
 			switch_set_flag_locked(tech_pvt, TFLAG_BYE);
 			switch_clear_flag_locked(tech_pvt, TFLAG_IO);
 			goto done;
 		}
-		if (switch_test_flag(tech_pvt, TFLAG_BYE) || ! switch_test_flag(tech_pvt, TFLAG_IO)) {
+		if (switch_test_flag(tech_pvt, TFLAG_BYE) || !switch_test_flag(tech_pvt, TFLAG_IO)) {
 			goto done;
 		}
 		switch_yield(1000);
 	}
-	
+
 	if (switch_channel_get_state(channel) >= CS_HANGUP || switch_test_flag(tech_pvt, TFLAG_BYE)) {
 		goto out;
-	}	
+	}
 
 	if (!activate_rtp(tech_pvt)) {
 		goto out;
 	}
-	
+
 	if (switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) {
 		if (!do_candidates(tech_pvt, 0)) {
 			goto out;
 		}
 		switch_channel_answer(channel);
-	} 
+	}
 	ret = SWITCH_STATUS_SUCCESS;
 
 	goto done;
-	
- out:
-	terminate_session(&session,  __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
- done:
+
+  out:
+	terminate_session(&session, __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+  done:
 
 	return ret;
 }
@@ -1065,7 +1081,7 @@ static switch_status_t channel_on_ring(switch_core_session_t *session)
 
 	tech_pvt = switch_core_session_get_private(session);
 	assert(tech_pvt != NULL);
-	
+
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL RING\n", switch_channel_get_name(channel));
 
 	return SWITCH_STATUS_SUCCESS;
@@ -1093,7 +1109,7 @@ static switch_status_t channel_on_hangup(switch_core_session_t *session)
 {
 	switch_channel_t *channel = NULL;
 	struct private_object *tech_pvt = NULL;
-	
+
 	channel = switch_core_session_get_channel(session);
 	assert(channel != NULL);
 
@@ -1105,12 +1121,11 @@ static switch_status_t channel_on_hangup(switch_core_session_t *session)
 	switch_set_flag_locked(tech_pvt, TFLAG_BYE);
 
 	/* Dunno why, but if googletalk calls us for the first time, as soon as the call ends
-	 they think we are offline for no reason so we send this presence packet to stop it from happening
-	 We should find out why.....
-	*/
-	if ((tech_pvt->profile->user_flags & LDL_FLAG_COMPONENT) && is_special(tech_pvt->them)) {	
-		ldl_handle_send_presence(tech_pvt->profile->handle,
-								 tech_pvt->them, tech_pvt->us, NULL, NULL, "Click To Call");
+	   they think we are offline for no reason so we send this presence packet to stop it from happening
+	   We should find out why.....
+	 */
+	if ((tech_pvt->profile->user_flags & LDL_FLAG_COMPONENT) && is_special(tech_pvt->them)) {
+		ldl_handle_send_presence(tech_pvt->profile->handle, tech_pvt->them, tech_pvt->us, NULL, NULL, "Click To Call");
 	}
 	if (tech_pvt->dlsession) {
 		if (!switch_test_flag(tech_pvt, TFLAG_TERM)) {
@@ -1144,42 +1159,42 @@ static switch_status_t channel_kill_channel(switch_core_session_t *session, int
 	switch_channel_t *channel = NULL;
 	struct private_object *tech_pvt = NULL;
 
-    if (!(channel = switch_core_session_get_channel(session))) {
-        return SWITCH_STATUS_SUCCESS;
-    }
+	if (!(channel = switch_core_session_get_channel(session))) {
+		return SWITCH_STATUS_SUCCESS;
+	}
 
-    if (!(tech_pvt = switch_core_session_get_private(session))) {
-        return SWITCH_STATUS_SUCCESS;
-    }
-    
+	if (!(tech_pvt = switch_core_session_get_private(session))) {
+		return SWITCH_STATUS_SUCCESS;
+	}
 
-    switch (sig) {
-    case SWITCH_SIG_KILL:
-        switch_clear_flag_locked(tech_pvt, TFLAG_IO);
-        switch_clear_flag_locked(tech_pvt, TFLAG_VOICE);
-        switch_set_flag_locked(tech_pvt, TFLAG_BYE);
 
-        if (tech_pvt->dlsession) {
-            if (!switch_test_flag(tech_pvt, TFLAG_TERM)) {
-                ldl_session_terminate(tech_pvt->dlsession);
-                switch_set_flag_locked(tech_pvt, TFLAG_TERM);
-            }
-            ldl_session_destroy(&tech_pvt->dlsession);
-            
-        }
+	switch (sig) {
+	case SWITCH_SIG_KILL:
+		switch_clear_flag_locked(tech_pvt, TFLAG_IO);
+		switch_clear_flag_locked(tech_pvt, TFLAG_VOICE);
+		switch_set_flag_locked(tech_pvt, TFLAG_BYE);
 
-        if (switch_rtp_ready(tech_pvt->rtp_session)) {
-            switch_rtp_kill_socket(tech_pvt->rtp_session);
-        }
-        break;
+		if (tech_pvt->dlsession) {
+			if (!switch_test_flag(tech_pvt, TFLAG_TERM)) {
+				ldl_session_terminate(tech_pvt->dlsession);
+				switch_set_flag_locked(tech_pvt, TFLAG_TERM);
+			}
+			ldl_session_destroy(&tech_pvt->dlsession);
+
+		}
+
+		if (switch_rtp_ready(tech_pvt->rtp_session)) {
+			switch_rtp_kill_socket(tech_pvt->rtp_session);
+		}
+		break;
 	case SWITCH_SIG_BREAK:
-        if (switch_rtp_ready(tech_pvt->rtp_session)) {
+		if (switch_rtp_ready(tech_pvt->rtp_session)) {
 			switch_rtp_set_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_BREAK);
 		}
 		break;
-    }
+	}
 
-    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL KILL\n", switch_channel_get_name(channel));
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL KILL\n", switch_channel_get_name(channel));
 
 
 	return SWITCH_STATUS_SUCCESS;
@@ -1228,8 +1243,7 @@ static switch_status_t channel_send_dtmf(switch_core_session_t *session, char *d
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "DTMF [%s]\n", dtmf);
 
 	return switch_rtp_queue_rfc2833(tech_pvt->rtp_session,
-									dtmf,
-									100 * (tech_pvt->read_codec.implementation->samples_per_second / 1000));
+									dtmf, 100 * (tech_pvt->read_codec.implementation->samples_per_second / 1000));
 
 }
 
@@ -1268,11 +1282,12 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
 	ms = tech_pvt->read_codec.implementation->microseconds_per_frame;
 	tech_pvt->read_frame.datalen = 0;
 
-	
-	while (!switch_test_flag(tech_pvt, TFLAG_BYE) && switch_test_flag(tech_pvt, TFLAG_IO) && tech_pvt->read_frame.datalen == 0) {
+
+	while (!switch_test_flag(tech_pvt, TFLAG_BYE) && switch_test_flag(tech_pvt, TFLAG_IO)
+		   && tech_pvt->read_frame.datalen == 0) {
 		tech_pvt->read_frame.flags = 0;
 		status = switch_rtp_zerocopy_read_frame(tech_pvt->rtp_session, &tech_pvt->read_frame);
-		
+
 		if (status != SWITCH_STATUS_SUCCESS && status != SWITCH_STATUS_BREAK) {
 			return SWITCH_STATUS_FALSE;
 		}
@@ -1291,23 +1306,25 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
 		}
 
 		if (switch_test_flag(&tech_pvt->read_frame, SFF_CNG)) {
-			tech_pvt->read_frame.datalen = tech_pvt->last_read ? tech_pvt->last_read : tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
+			tech_pvt->read_frame.datalen =
+				tech_pvt->last_read ? tech_pvt->last_read : tech_pvt->read_codec.implementation->
+				encoded_bytes_per_frame;
 		}
 
 		if (tech_pvt->read_frame.datalen > 0) {
-            if (!switch_test_flag((&tech_pvt->read_frame), SFF_CNG)) {
-                if (tech_pvt->read_codec.implementation->encoded_bytes_per_frame && bytes) {
-                    bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
-                    frames = (tech_pvt->read_frame.datalen / bytes);
-                } else {
-                    frames = 1;
-                }
-                samples = frames * tech_pvt->read_codec.implementation->samples_per_frame;
-                ms = frames * tech_pvt->read_codec.implementation->microseconds_per_frame;
-                tech_pvt->timestamp_recv += (int32_t) samples;
-                tech_pvt->read_frame.samples = (int) samples;
-                tech_pvt->last_read = tech_pvt->read_frame.datalen;
-            }
+			if (!switch_test_flag((&tech_pvt->read_frame), SFF_CNG)) {
+				if (tech_pvt->read_codec.implementation->encoded_bytes_per_frame && bytes) {
+					bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
+					frames = (tech_pvt->read_frame.datalen / bytes);
+				} else {
+					frames = 1;
+				}
+				samples = frames * tech_pvt->read_codec.implementation->samples_per_frame;
+				ms = frames * tech_pvt->read_codec.implementation->microseconds_per_frame;
+				tech_pvt->timestamp_recv += (int32_t) samples;
+				tech_pvt->read_frame.samples = (int) samples;
+				tech_pvt->last_read = tech_pvt->read_frame.datalen;
+			}
 			break;
 		}
 
@@ -1362,7 +1379,7 @@ static switch_status_t channel_write_frame(switch_core_session_t *session, switc
 	samples = frames * tech_pvt->read_codec.implementation->samples_per_frame;
 	tech_pvt->timestamp_send += samples;
 	if (switch_rtp_write_frame(tech_pvt->rtp_session, frame, 0) < 0) {
-		terminate_session(&session,  __LINE__, SWITCH_CAUSE_NORMAL_CLEARING);
+		terminate_session(&session, __LINE__, SWITCH_CAUSE_NORMAL_CLEARING);
 		return SWITCH_STATUS_FALSE;
 	}
 
@@ -1391,16 +1408,16 @@ static switch_status_t channel_receive_message(switch_core_session_t *session, s
 {
 	switch_channel_t *channel;
 	struct private_object *tech_pvt;
-			
+
 	channel = switch_core_session_get_channel(session);
 	assert(channel != NULL);
-			
+
 	tech_pvt = switch_core_session_get_private(session);
 	assert(tech_pvt != NULL);
 
 	switch (msg->message_id) {
 	case SWITCH_MESSAGE_INDICATE_BRIDGE:
-	  if (tech_pvt->rtp_session && switch_test_flag(tech_pvt->profile, TFLAG_TIMER)) {
+		if (tech_pvt->rtp_session && switch_test_flag(tech_pvt->profile, TFLAG_TIMER)) {
 			switch_rtp_clear_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_USE_TIMER);
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "De-activate timed RTP!\n");
 			//switch_rtp_set_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_TIMER_RECLOCK);
@@ -1423,14 +1440,14 @@ static switch_status_t channel_receive_message(switch_core_session_t *session, s
 static switch_status_t channel_receive_event(switch_core_session_t *session, switch_event_t *event)
 {
 	switch_channel_t *channel;
-    struct private_object *tech_pvt;
+	struct private_object *tech_pvt;
 	char *subject, *body;
 
-    channel = switch_core_session_get_channel(session);
-    assert(channel != NULL);
+	channel = switch_core_session_get_channel(session);
+	assert(channel != NULL);
 
-    tech_pvt = switch_core_session_get_private(session);
-    assert(tech_pvt != NULL);
+	tech_pvt = switch_core_session_get_private(session);
+	assert(tech_pvt != NULL);
 
 
 	if (!(body = switch_event_get_body(event))) {
@@ -1464,8 +1481,8 @@ static const switch_io_routines_t channel_io_routines = {
 	/*.waitfor_read */ channel_waitfor_read,
 	/*.waitfor_write */ channel_waitfor_write,
 	/*.send_dtmf */ channel_send_dtmf,
-	/*.receive_message*/ channel_receive_message,
-	/*.receive_event*/ channel_receive_event
+	/*.receive_message */ channel_receive_message,
+	/*.receive_event */ channel_receive_event
 };
 
 static const switch_endpoint_interface_t channel_endpoint_interface = {
@@ -1508,17 +1525,17 @@ static const switch_loadable_module_interface_t channel_module_interface = {
 	/*.application_interface */ NULL,
 	/*.api_interface */ &login_api_interface,
 	/*.file_interface */ NULL,
-    /*.speech_interface */ NULL,
-    /*.directory_interface */ NULL,
-    /*.chat_interface */ &channel_chat_interface
-
+	/*.speech_interface */ NULL,
+	/*.directory_interface */ NULL,
+	/*.chat_interface */ &channel_chat_interface
 };
 
 
 /* Make sure when you have 2 sessions in the same scope that you pass the appropriate one to the routines
    that allocate memory or you will have 1 channel with memory allocated from another channel's pool!
 */
-static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *session, switch_caller_profile_t *outbound_profile,
+static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *session,
+													switch_caller_profile_t *outbound_profile,
 													switch_core_session_t **new_session, switch_memory_pool_t **pool)
 {
 	if ((*new_session = switch_core_session_request(&channel_endpoint_interface, pool)) != 0) {
@@ -1544,7 +1561,7 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
 			*callto++ = '\0';
 		} else {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Invalid URL!\n");
-			terminate_session(new_session,  __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+			terminate_session(new_session, __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 			return SWITCH_CAUSE_INVALID_NUMBER_FORMAT;
 		}
 
@@ -1552,9 +1569,9 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
 			*dnis++ = '\0';
 		}
 
-        for (p = callto; p && *p; p++) {
-            *p = (char) tolower(*p);
-        }
+		for (p = callto; p && *p; p++) {
+			*p = (char) tolower(*p);
+		}
 
 		if ((p = strchr(profile_name, '@'))) {
 			*p++ = '\0';
@@ -1574,30 +1591,31 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
 						user = ubuf;
 					} else {
 						switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Invalid User!\n");
-						terminate_session(new_session,  __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+						terminate_session(new_session, __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 					}
 				}
 			}
 
 			if (!ldl_handle_ready(mdl_profile->handle)) {
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Doh! we are not logged in yet!\n");
-				terminate_session(new_session,  __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+				terminate_session(new_session, __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 				return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
 			}
 			if (!(full_id = ldl_handle_probe(mdl_profile->handle, callto, user, idbuf, sizeof(idbuf)))) {
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Unknown Recipient!\n");
-				terminate_session(new_session,  __LINE__, SWITCH_CAUSE_NO_USER_RESPONSE);
+				terminate_session(new_session, __LINE__, SWITCH_CAUSE_NO_USER_RESPONSE);
 				return SWITCH_CAUSE_NO_USER_RESPONSE;
 			}
 		} else {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Unknown Profile!\n");
-			terminate_session(new_session,  __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+			terminate_session(new_session, __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 			return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
 		}
-		
-		
+
+
 		switch_core_session_add_stream(*new_session, NULL);
-		if ((tech_pvt = (struct private_object *) switch_core_session_alloc(*new_session, sizeof(struct private_object))) != 0) {
+		if ((tech_pvt =
+			 (struct private_object *) switch_core_session_alloc(*new_session, sizeof(struct private_object))) != 0) {
 			memset(tech_pvt, 0, sizeof(*tech_pvt));
 			switch_mutex_init(&tech_pvt->flag_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(*new_session));
 			tech_pvt->flags |= globals.flags;
@@ -1611,13 +1629,13 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
 			tech_pvt->dnis = switch_core_session_strdup(*new_session, dnis);
 		} else {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Hey where is my memory pool?\n");
-			terminate_session(new_session,  __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+			terminate_session(new_session, __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 			return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
 		}
 
 		if (outbound_profile) {
 			char name[128];
-			
+
 			snprintf(name, sizeof(name), "DingaLing/%s", outbound_profile->destination_number);
 			switch_channel_set_name(channel, name);
 
@@ -1626,7 +1644,7 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
 			tech_pvt->caller_profile = caller_profile;
 		} else {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Doh! no caller profile\n");
-			terminate_session(new_session,  __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+			terminate_session(new_session, __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 			return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
 		}
 
@@ -1637,14 +1655,16 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
 		tech_pvt->us = switch_core_session_strdup(*new_session, user);
 		tech_pvt->them = switch_core_session_strdup(*new_session, full_id);
 		ldl_session_create(&dlsession, mdl_profile->handle, sess_id, full_id, user, LDL_FLAG_OUTBOUND);
-		
+
 		if (session) {
 			switch_channel_t *calling_channel = switch_core_session_get_channel(session);
 			cid_msg = switch_channel_get_variable(calling_channel, "dl_cid_msg");
 		}
 
 		if (!cid_msg) {
-			f_cid_msg = switch_mprintf("Incoming Call From %s %s\n", outbound_profile->caller_id_name, outbound_profile->caller_id_number);
+			f_cid_msg =
+				switch_mprintf("Incoming Call From %s %s\n", outbound_profile->caller_id_name,
+							   outbound_profile->caller_id_number);
 			cid_msg = f_cid_msg;
 		}
 
@@ -1669,8 +1689,8 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
 		ldl_session_set_value(dlsession, "caller_id_number", outbound_profile->caller_id_number);
 		tech_pvt->dlsession = dlsession;
 		if (!get_codecs(tech_pvt)) {
-			terminate_session(new_session,  __LINE__, SWITCH_CAUSE_BEARERCAPABILITY_NOTAVAIL);
-            return SWITCH_CAUSE_BEARERCAPABILITY_NOTAVAIL;
+			terminate_session(new_session, __LINE__, SWITCH_CAUSE_BEARERCAPABILITY_NOTAVAIL);
+			return SWITCH_CAUSE_BEARERCAPABILITY_NOTAVAIL;
 		}
 		switch_channel_set_state(channel, CS_INIT);
 		return SWITCH_CAUSE_SUCCESS;
@@ -1681,7 +1701,8 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
 
 }
 
-SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
+													   char *filename)
 {
 
 	if (switch_core_new_memory_pool(&module_pool) != SWITCH_STATUS_SUCCESS) {
@@ -1692,12 +1713,14 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_mod
 	load_config();
 
 	if (switch_event_reserve_subclass(DL_EVENT_LOGIN_SUCCESS) != SWITCH_STATUS_SUCCESS) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!", DL_EVENT_LOGIN_SUCCESS);
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!",
+						  DL_EVENT_LOGIN_SUCCESS);
 		return SWITCH_STATUS_GENERR;
 	}
 
 	if (switch_event_reserve_subclass(DL_EVENT_LOGIN_FAILURE) != SWITCH_STATUS_SUCCESS) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!", DL_EVENT_LOGIN_FAILURE);
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!",
+						  DL_EVENT_LOGIN_FAILURE);
 		return SWITCH_STATUS_GENERR;
 	}
 
@@ -1705,23 +1728,30 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_mod
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!", DL_EVENT_CONNECTED);
 		return SWITCH_STATUS_GENERR;
 	}
-	
-	if (switch_event_bind((char *) modname, SWITCH_EVENT_PRESENCE_IN, SWITCH_EVENT_SUBCLASS_ANY, pres_event_handler, NULL) != SWITCH_STATUS_SUCCESS) {
+
+	if (switch_event_bind
+		((char *) modname, SWITCH_EVENT_PRESENCE_IN, SWITCH_EVENT_SUBCLASS_ANY, pres_event_handler,
+		 NULL) != SWITCH_STATUS_SUCCESS) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
 		return SWITCH_STATUS_GENERR;
 	}
 
-	if (switch_event_bind((char *) modname, SWITCH_EVENT_PRESENCE_PROBE, SWITCH_EVENT_SUBCLASS_ANY, pres_event_handler, NULL) != SWITCH_STATUS_SUCCESS) {
+	if (switch_event_bind
+		((char *) modname, SWITCH_EVENT_PRESENCE_PROBE, SWITCH_EVENT_SUBCLASS_ANY, pres_event_handler,
+		 NULL) != SWITCH_STATUS_SUCCESS) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
 		return SWITCH_STATUS_GENERR;
 	}
 
-	if (switch_event_bind((char *) modname, SWITCH_EVENT_PRESENCE_OUT, SWITCH_EVENT_SUBCLASS_ANY, pres_event_handler, NULL) != SWITCH_STATUS_SUCCESS) {
+	if (switch_event_bind
+		((char *) modname, SWITCH_EVENT_PRESENCE_OUT, SWITCH_EVENT_SUBCLASS_ANY, pres_event_handler,
+		 NULL) != SWITCH_STATUS_SUCCESS) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
 		return SWITCH_STATUS_GENERR;
 	}
 
-	if (switch_event_bind((char *) modname, SWITCH_EVENT_ROSTER, SWITCH_EVENT_SUBCLASS_ANY, roster_event_handler, NULL) != SWITCH_STATUS_SUCCESS) {
+	if (switch_event_bind((char *) modname, SWITCH_EVENT_ROSTER, SWITCH_EVENT_SUBCLASS_ANY, roster_event_handler, NULL)
+		!= SWITCH_STATUS_SUCCESS) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
 		return SWITCH_STATUS_GENERR;
 	}
@@ -1733,7 +1763,7 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_mod
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static ldl_status handle_loop(ldl_handle_t *handle)
+static ldl_status handle_loop(ldl_handle_t * handle)
 {
 	if (!globals.running) {
 		return LDL_STATUS_FALSE;
@@ -1745,16 +1775,11 @@ static switch_status_t init_profile(struct mdl_profile *profile, uint8_t login)
 {
 	if (profile &&
 		profile->login &&
-		profile->password &&
-		profile->dialplan &&
-		profile->message &&
-		profile->ip &&
-		profile->name &&
-		profile->exten) {
+		profile->password && profile->dialplan && profile->message && profile->ip && profile->name && profile->exten) {
 		ldl_handle_t *handle;
 
 		if (switch_test_flag(profile, TFLAG_TIMER) && !profile->timer_name) {
-			profile->timer_name = switch_core_strdup(module_pool, "soft");			
+			profile->timer_name = switch_core_strdup(module_pool, "soft");
 		}
 
 		if (login) {
@@ -1764,21 +1789,20 @@ static switch_status_t init_profile(struct mdl_profile *profile, uint8_t login)
 								profile->server,
 								profile->user_flags,
 								profile->message,
-								handle_loop,
-								handle_signalling,
-								handle_response,
-								profile) == LDL_STATUS_SUCCESS) {
+								handle_loop, handle_signalling, handle_response, profile) == LDL_STATUS_SUCCESS) {
 				profile->handle = handle;
-				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Started Thread for %s@%s\n", profile->login, profile->dialplan);
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Started Thread for %s@%s\n", profile->login,
+								  profile->dialplan);
 				switch_core_hash_insert(globals.profile_hash, profile->name, profile);
 				handle_thread_launch(handle);
 			}
 		} else {
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Created Profile for %s@%s\n", profile->login, profile->dialplan);
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Created Profile for %s@%s\n", profile->login,
+							  profile->dialplan);
 			switch_core_hash_insert(globals.profile_hash, profile->name, profile);
 		}
 	} else {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, 
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
 						  "Invalid Profile\n"
 						  "login[%s]\n"
 						  "pass[%s]\n"
@@ -1789,11 +1813,7 @@ static switch_status_t init_profile(struct mdl_profile *profile, uint8_t login)
 						  "exten[%s]\n",
 						  profile->login,
 						  profile->password,
-						  profile->dialplan,
-						  profile->message,
-						  profile->ip,
-						  profile->name,
-						  profile->exten);
+						  profile->dialplan, profile->message, profile->ip, profile->name, profile->exten);
 
 		return SWITCH_STATUS_FALSE;
 	}
@@ -1812,7 +1832,7 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_shutdown(void)
 		while (globals.handles > 0) {
 			switch_yield(100000);
 			x++;
-			if(x > 10) {
+			if (x > 10) {
 				break;
 			}
 		}
@@ -1826,13 +1846,13 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_shutdown(void)
 
 static void set_profile_val(struct mdl_profile *profile, char *var, char *val)
 {
-	
+
 	if (!strcasecmp(var, "login")) {
 		profile->login = switch_core_strdup(module_pool, val);
 	} else if (!strcasecmp(var, "password")) {
 		profile->password = switch_core_strdup(module_pool, val);
 	} else if (!strcasecmp(var, "use-rtp-timer") && switch_true(val)) {
-	  	switch_set_flag(profile, TFLAG_TIMER);
+		switch_set_flag(profile, TFLAG_TIMER);
 	} else if (!strcasecmp(var, "dialplan")) {
 		profile->dialplan = switch_core_strdup(module_pool, val);
 	} else if (!strcasecmp(var, "auto-reply")) {
@@ -1908,7 +1928,7 @@ static switch_status_t dl_logout(char *profile_name, switch_core_session_t *sess
 
 static switch_status_t dl_login(char *arg, switch_core_session_t *session, switch_stream_handle_t *stream)
 {
-	char *argv[10] = {0};
+	char *argv[10] = { 0 };
 	int argc = 0;
 	char *var, *val, *myarg;
 	struct mdl_profile *profile = NULL;
@@ -1918,10 +1938,10 @@ static switch_status_t dl_login(char *arg, switch_core_session_t *session, switc
 		return SWITCH_STATUS_FALSE;
 	}
 
-    if (switch_strlen_zero(arg)) {
-        stream->write_function(stream, "USAGE: %s\n", login_api_interface.syntax);
-        return SWITCH_STATUS_SUCCESS;
-    }
+	if (switch_strlen_zero(arg)) {
+		stream->write_function(stream, "USAGE: %s\n", login_api_interface.syntax);
+		return SWITCH_STATUS_SUCCESS;
+	}
 
 	myarg = strdup(arg);
 
@@ -1947,7 +1967,7 @@ static switch_status_t dl_login(char *arg, switch_core_session_t *session, switc
 	} else {
 		profile = switch_core_alloc(module_pool, sizeof(*profile));
 
-		for(x = 0; x < argc; x++) {
+		for (x = 0; x < argc; x++) {
 			var = argv[x];
 			if ((val = strchr(var, '='))) {
 				*val++ = '\0';
@@ -1955,7 +1975,7 @@ static switch_status_t dl_login(char *arg, switch_core_session_t *session, switc
 			}
 		}
 	}
-	
+
 
 	if (profile && init_profile(profile, 1) == SWITCH_STATUS_SUCCESS) {
 		stream->write_function(stream, "OK\n");
@@ -1975,10 +1995,10 @@ static switch_status_t load_config(void)
 
 	memset(&globals, 0, sizeof(globals));
 	globals.running = 1;
-    
-    switch_find_local_ip(globals.guess_ip, sizeof(globals.guess_ip), AF_INET);
 
-	switch_core_hash_init(&globals.profile_hash, module_pool);	
+	switch_find_local_ip(globals.guess_ip, sizeof(globals.guess_ip), AF_INET);
+
+	switch_core_hash_init(&globals.profile_hash, module_pool);
 
 	if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
@@ -2003,10 +2023,11 @@ static switch_status_t load_config(void)
 			}
 		}
 	}
-	
+
 	if (!(xmlint = switch_xml_child(cfg, "profile"))) {
 		if ((xmlint = switch_xml_child(cfg, "interface"))) {
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "!!!!!!! DEPRICATION WARNING 'interface' is now 'profile' !!!!!!!\n");
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
+							  "!!!!!!! DEPRICATION WARNING 'interface' is now 'profile' !!!!!!!\n");
 		}
 	}
 
@@ -2022,7 +2043,7 @@ static switch_status_t load_config(void)
 				globals.init = 1;
 			}
 
-			if(!profile) {
+			if (!profile) {
 				profile = switch_core_alloc(module_pool, sizeof(*profile));
 			}
 			set_profile_val(profile, var, val);
@@ -2093,17 +2114,17 @@ static void execute_sql(char *dbname, char *sql, switch_mutex_t *mutex)
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening DB %s\n", dbname);
 		goto end;
 	}
-	
+
 	switch_core_db_persistant_execute(db, sql, 25);
 	switch_core_db_close(db);
 
- end:
+  end:
 	if (mutex) {
 		switch_mutex_unlock(mutex);
 	}
 }
 
-static void do_vcard(ldl_handle_t *handle, char *to, char *from, char *id)
+static void do_vcard(ldl_handle_t * handle, char *to, char *from, char *id)
 {
 	char *params = NULL, *real_to, *to_user, *xmlstr = NULL, *to_host = NULL;
 	switch_xml_t domain, xml = NULL, user, vcard;
@@ -2123,22 +2144,18 @@ static void do_vcard(ldl_handle_t *handle, char *to, char *from, char *id)
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
 		goto end;
 	}
-	
+
 	if (!to_host) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Missing Host!\n");
 		goto end;
 	}
 
-	if (!(params = switch_mprintf("to=%s@%s&from=%s&object=vcard",
-								  to_user,
-								  to_host,
-								  from
-								  ))) {
+	if (!(params = switch_mprintf("to=%s@%s&from=%s&object=vcard", to_user, to_host, from))) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
 		goto end;
 	}
 
-	
+
 	if (switch_xml_locate("directory", "domain", "name", to_host, &xml, &domain, params) != SWITCH_STATUS_SUCCESS) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "can't find domain for [%s@%s]\n", to_user, to_host);
 		goto end;
@@ -2150,7 +2167,8 @@ static void do_vcard(ldl_handle_t *handle, char *to, char *from, char *id)
 	}
 
 	if (!(vcard = switch_xml_child(user, "vcard"))) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "can't find  tag for user [%s@%s]\n", to_user, to_host);
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "can't find  tag for user [%s@%s]\n", to_user,
+						  to_host);
 		goto end;
 	}
 
@@ -2162,19 +2180,21 @@ static void do_vcard(ldl_handle_t *handle, char *to, char *from, char *id)
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
 	}
 
- end:
-	if (xml) switch_xml_free(xml);
+  end:
+	if (xml)
+		switch_xml_free(xml);
 	switch_safe_free(to_user);
 	switch_safe_free(params);
 	switch_safe_free(xmlstr);
 }
 
-static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsession, ldl_signal_t dl_signal, char *to, char *from, char *subject, char *msg)
+static ldl_status handle_signalling(ldl_handle_t * handle, ldl_session_t * dlsession, ldl_signal_t dl_signal, char *to,
+									char *from, char *subject, char *msg)
 {
 	struct mdl_profile *profile = NULL;
 	switch_core_session_t *session = NULL;
 	switch_channel_t *channel = NULL;
-    struct private_object *tech_pvt = NULL;
+	struct private_object *tech_pvt = NULL;
 	switch_event_t *event;
 	ldl_status status = LDL_STATUS_SUCCESS;
 	char *sql;
@@ -2189,7 +2209,7 @@ static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsessi
 
 	if (!dlsession) {
 		if (profile->user_flags & LDL_FLAG_COMPONENT) {
-			switch(dl_signal) {
+			switch (dl_signal) {
 			case LDL_SIGNAL_VCARD:
 				do_vcard(handle, to, from, subject);
 				break;
@@ -2203,9 +2223,10 @@ static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsessi
 				break;
 
 			case LDL_SIGNAL_SUBSCRIBE:
-				
+
 				if ((sql = switch_mprintf("delete from subscriptions where sub_from='%q' and sub_to='%q';\n"
-										  "insert into subscriptions values('%q','%q','%q','%q');\n", from, to, from, to, msg, subject))) {
+										  "insert into subscriptions values('%q','%q','%q','%q');\n", from, to, from,
+										  to, msg, subject))) {
 					execute_sql(profile->dbname, sql, profile->mutex);
 					switch_core_db_free(sql);
 				}
@@ -2213,13 +2234,12 @@ static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsessi
 				if (is_special(to)) {
 					ldl_handle_send_presence(profile->handle, to, from, NULL, NULL, "Click To Call");
 				}
-
 #if 0
 				if (is_special(to)) {
 					if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
 						switch_event_add_header(event, SWITCH_STACK_BOTTOM, "proto", MDL_CHAT_PROTO);
 						switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", "%s", profile->login);
-						switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s",  to);
+						switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s", to);
 						//switch_event_add_header(event, SWITCH_STACK_BOTTOM, "rpid", "unknown");
 						switch_event_add_header(event, SWITCH_STACK_BOTTOM, "status", "Click To Call");
 						switch_event_fire(&event);
@@ -2236,34 +2256,36 @@ static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsessi
 				break;
 			case LDL_SIGNAL_PRESENCE_PROBE:
 				if (is_special(to)) {
-                    ldl_handle_send_presence(profile->handle, to, from, NULL, NULL, "Click To Call");
-                } else {
+					ldl_handle_send_presence(profile->handle, to, from, NULL, NULL, "Click To Call");
+				} else {
 					if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_PROBE) == SWITCH_STATUS_SUCCESS) {
 						switch_event_add_header(event, SWITCH_STACK_BOTTOM, "proto", MDL_CHAT_PROTO);
 						switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", "%s", profile->login);
-						switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s",  from);
-						switch_event_add_header(event, SWITCH_STACK_BOTTOM, "to", "%s",  to);
+						switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s", from);
+						switch_event_add_header(event, SWITCH_STACK_BOTTOM, "to", "%s", to);
 						switch_event_fire(&event);
 					}
-                }
-                break;
+				}
+				break;
 			case LDL_SIGNAL_PRESENCE_IN:
-				
-				if ((sql = switch_mprintf("update subscriptions set show='%q', status='%q' where sub_from='%q'", msg, subject, from))) {
+
+				if ((sql =
+					 switch_mprintf("update subscriptions set show='%q', status='%q' where sub_from='%q'", msg, subject,
+									from))) {
 					execute_sql(profile->dbname, sql, profile->mutex);
 					switch_core_db_free(sql);
 				}
-				
+
 				if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
 					switch_event_add_header(event, SWITCH_STACK_BOTTOM, "proto", MDL_CHAT_PROTO);
 					switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", "%s", profile->login);
-					switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s",  from);
+					switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s", from);
 					switch_event_add_header(event, SWITCH_STACK_BOTTOM, "rpid", "%s", msg);
 					switch_event_add_header(event, SWITCH_STACK_BOTTOM, "status", "%s", subject);
 					switch_event_fire(&event);
 				}
 
-				
+
 				if (is_special(to)) {
 					ldl_handle_send_presence(profile->handle, to, from, NULL, NULL, "Click To Call");
 				}
@@ -2272,7 +2294,7 @@ static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsessi
 					if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
 						switch_event_add_header(event, SWITCH_STACK_BOTTOM, "proto", MDL_CHAT_PROTO);
 						switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", "%s", profile->login);
-						switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s",  to);
+						switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s", to);
 						//switch_event_add_header(event, SWITCH_STACK_BOTTOM, "rpid", "unknown");
 						switch_event_add_header(event, SWITCH_STACK_BOTTOM, "status", "Click To Call");
 						switch_event_fire(&event);
@@ -2282,8 +2304,10 @@ static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsessi
 				break;
 
 			case LDL_SIGNAL_PRESENCE_OUT:
-				
-				if ((sql = switch_mprintf("update subscriptions set show='%q', status='%q' where sub_from='%q'", msg, subject, from))) {
+
+				if ((sql =
+					 switch_mprintf("update subscriptions set show='%q', status='%q' where sub_from='%q'", msg, subject,
+									from))) {
 					execute_sql(profile->dbname, sql, profile->mutex);
 					switch_core_db_free(sql);
 				}
@@ -2297,52 +2321,55 @@ static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsessi
 			default:
 				break;
 			}
-		} 
-
-		switch(dl_signal) {
-		case LDL_SIGNAL_MSG: {
-			switch_chat_interface_t *ci;
-			char *proto = MDL_CHAT_PROTO;
-			char *pproto = NULL, *ffrom = NULL;
-			char *hint;
-
-			if (profile->auto_reply) {
-				ldl_handle_send_msg(handle,
-									(profile->user_flags & LDL_FLAG_COMPONENT) ? to : ldl_handle_get_login(profile->handle),
-									from, "", profile->auto_reply);
-			}
-
-			if (strchr(to, '+')) {
-				pproto = strdup(to);
-				if ((to = strchr(pproto, '+'))) {
-					*to++ = '\0';
-				}
-				proto = pproto;
-			}
-
-			hint = from;
-
-			if (strchr(from, '/') && (ffrom = strdup(from))) {
-				char *p;
-				if ((p = strchr(ffrom, '/'))) {
-					*p = '\0';
-				}
-				from = ffrom;
-			}
-
-			if ((ci = switch_loadable_module_get_chat_interface(proto))) {
-				ci->chat_send(MDL_CHAT_PROTO, from, to, subject, msg, hint);
-			} else {
-				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Chat Interface [%s]!\n", proto);
-			}
-
-			switch_safe_free(pproto);
-			switch_safe_free(ffrom);
 		}
+
+		switch (dl_signal) {
+		case LDL_SIGNAL_MSG:{
+				switch_chat_interface_t *ci;
+				char *proto = MDL_CHAT_PROTO;
+				char *pproto = NULL, *ffrom = NULL;
+				char *hint;
+
+				if (profile->auto_reply) {
+					ldl_handle_send_msg(handle,
+										(profile->user_flags & LDL_FLAG_COMPONENT) ? to : ldl_handle_get_login(profile->
+																											   handle),
+										from, "", profile->auto_reply);
+				}
+
+				if (strchr(to, '+')) {
+					pproto = strdup(to);
+					if ((to = strchr(pproto, '+'))) {
+						*to++ = '\0';
+					}
+					proto = pproto;
+				}
+
+				hint = from;
+
+				if (strchr(from, '/') && (ffrom = strdup(from))) {
+					char *p;
+					if ((p = strchr(ffrom, '/'))) {
+						*p = '\0';
+					}
+					from = ffrom;
+				}
+
+				if ((ci = switch_loadable_module_get_chat_interface(proto))) {
+					ci->chat_send(MDL_CHAT_PROTO, from, to, subject, msg, hint);
+				} else {
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Chat Interface [%s]!\n", proto);
+				}
+
+				switch_safe_free(pproto);
+				switch_safe_free(ffrom);
+			}
 			break;
 		case LDL_SIGNAL_LOGIN_SUCCESS:
-			if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, DL_EVENT_LOGIN_SUCCESS) == SWITCH_STATUS_SUCCESS) {
-				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", "%s", ldl_handle_get_login(profile->handle));
+			if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, DL_EVENT_LOGIN_SUCCESS) ==
+				SWITCH_STATUS_SUCCESS) {
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", "%s",
+										ldl_handle_get_login(profile->handle));
 				switch_event_fire(&event);
 			}
 			if (profile->user_flags & LDL_FLAG_COMPONENT) {
@@ -2351,25 +2378,28 @@ static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsessi
 
 			break;
 		case LDL_SIGNAL_LOGIN_FAILURE:
-			if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, DL_EVENT_LOGIN_FAILURE) == SWITCH_STATUS_SUCCESS) {
-				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", "%s", ldl_handle_get_login(profile->handle));
+			if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, DL_EVENT_LOGIN_FAILURE) ==
+				SWITCH_STATUS_SUCCESS) {
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", "%s",
+										ldl_handle_get_login(profile->handle));
 				switch_event_fire(&event);
 			}
 			break;
 		case LDL_SIGNAL_CONNECTED:
 			if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, DL_EVENT_CONNECTED) == SWITCH_STATUS_SUCCESS) {
-				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", "%s", ldl_handle_get_login(profile->handle));
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", "%s",
+										ldl_handle_get_login(profile->handle));
 				switch_event_fire(&event);
 			}
 			break;
 		default:
 			break;
-			
+
 		}
 		status = LDL_STATUS_SUCCESS;
 		goto done;
 	}
-	
+
 
 	if ((session = ldl_session_get_private(dlsession))) {
 		tech_pvt = switch_core_session_get_private(session);
@@ -2377,11 +2407,13 @@ static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsessi
 
 		channel = switch_core_session_get_channel(session);
 		assert(channel != NULL);
-		
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "using Existing session for %s\n", ldl_session_get_id(dlsession));
+
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "using Existing session for %s\n",
+						  ldl_session_get_id(dlsession));
 
 		if (switch_channel_get_state(channel) >= CS_HANGUP) {
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Call %s is already over\n", switch_channel_get_name(channel));
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Call %s is already over\n",
+							  switch_channel_get_name(channel));
 			status = LDL_STATUS_FALSE;
 			goto done;
 		}
@@ -2394,8 +2426,9 @@ static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsessi
 		}
 		if ((session = switch_core_session_request(&channel_endpoint_interface, NULL)) != 0) {
 			switch_core_session_add_stream(session, NULL);
-			
-			if ((tech_pvt = (struct private_object *) switch_core_session_alloc(session, sizeof(struct private_object))) != 0) {
+
+			if ((tech_pvt =
+				 (struct private_object *) switch_core_session_alloc(session, sizeof(struct private_object))) != 0) {
 				memset(tech_pvt, 0, sizeof(*tech_pvt));
 				switch_mutex_init(&tech_pvt->flag_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
 				tech_pvt->flags |= globals.flags;
@@ -2411,11 +2444,12 @@ static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsessi
 				switch_set_flag_locked(tech_pvt, TFLAG_TRANSPORT_ACCEPT);
 			} else {
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Hey where is my memory pool?\n");
-				terminate_session(&session,  __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+				terminate_session(&session, __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 				status = LDL_STATUS_FALSE;
 				goto done;
 			}
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Creating a session for %s\n", ldl_session_get_id(dlsession));
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Creating a session for %s\n",
+							  ldl_session_get_id(dlsession));
 			ldl_session_set_private(dlsession, session);
 			tech_pvt->dlsession = dlsession;
 			switch_channel_set_name(channel, "DingaLing/new");
@@ -2428,9 +2462,9 @@ static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsessi
 
 	}
 
-	switch(dl_signal) {
+	switch (dl_signal) {
 	case LDL_SIGNAL_MSG:
-		if (msg) { 
+		if (msg) {
 			if (*msg == '+') {
 				switch_channel_queue_dtmf(channel, msg + 1);
 				switch_set_flag_locked(tech_pvt, TFLAG_DTMF);
@@ -2444,12 +2478,12 @@ static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsessi
 		if (switch_event_create(&event, SWITCH_EVENT_MESSAGE) == SWITCH_STATUS_SUCCESS) {
 			char *hint = NULL, *p, *freeme = NULL;
 
-			hint = from;			
+			hint = from;
 			if (strchr(from, '/')) {
 				freeme = strdup(from);
 				p = strchr(freeme, '/');
 				*p = '\0';
-				from = freeme;				
+				from = freeme;
 			}
 
 			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "proto", MDL_CHAT_PROTO);
@@ -2482,7 +2516,7 @@ static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsessi
 				if (!strcasecmp(msg, "accept")) {
 					switch_set_flag_locked(tech_pvt, TFLAG_ANSWER);
 					if (!do_candidates(tech_pvt, 0)) {
-						terminate_session(&session,  __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+						terminate_session(&session, __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 						status = LDL_STATUS_FALSE;
 						goto done;
 					}
@@ -2496,42 +2530,44 @@ static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsessi
 
 
 			if (!get_codecs(tech_pvt)) {
-				terminate_session(&session,  __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+				terminate_session(&session, __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 				status = LDL_STATUS_FALSE;
 				goto done;
 			}
 
-			
+
 			if (ldl_session_get_payloads(dlsession, &payloads, &len) == LDL_STATUS_SUCCESS) {
-                unsigned int x, y;
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%u payloads\n", len);
-				for(x = 0; x < len; x++) {
-					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Available Payload %s %u\n", payloads[x].name, payloads[x].id);
-					for(y = 0; y < tech_pvt->num_codecs; y++) {
+				unsigned int x, y;
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%u payloads\n", len);
+				for (x = 0; x < len; x++) {
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Available Payload %s %u\n",
+									  payloads[x].name, payloads[x].id);
+					for (y = 0; y < tech_pvt->num_codecs; y++) {
 						char *name = tech_pvt->codecs[y]->iananame;
 
 						if (!strncasecmp(name, "ilbc", 4)) {
 							name = "ilbc";
 						}
-						switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "compare %s %d/%d to %s %d/%d\n", 
-                                          payloads[x].name, payloads[x].id, payloads[x].rate,
-                                          name, tech_pvt->codecs[y]->ianacode, tech_pvt->codecs[y]->samples_per_second);
+						switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "compare %s %d/%d to %s %d/%d\n",
+										  payloads[x].name, payloads[x].id, payloads[x].rate,
+										  name, tech_pvt->codecs[y]->ianacode, tech_pvt->codecs[y]->samples_per_second);
 						if (tech_pvt->codecs[y]->ianacode > 95) {
 							match = strcasecmp(name, payloads[x].name) ? 0 : 1;
 						} else {
 							match = (payloads[x].id == tech_pvt->codecs[y]->ianacode) ? 1 : 0;
 						}
-						
+
 						if (match && payloads[x].rate == tech_pvt->codecs[y]->samples_per_second) {
 							tech_pvt->codec_index = y;
-							switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Choosing Payload index %u %s %u\n", y, payloads[x].name, payloads[x].id);
+							switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Choosing Payload index %u %s %u\n",
+											  y, payloads[x].name, payloads[x].id);
 							tech_pvt->codec_name = tech_pvt->codecs[y]->iananame;
 							tech_pvt->codec_num = tech_pvt->codecs[y]->ianacode;
-							tech_pvt->r_codec_num = (switch_payload_t)(payloads[x].id);
+							tech_pvt->r_codec_num = (switch_payload_t) (payloads[x].id);
 							tech_pvt->codec_rate = payloads[x].rate;
 							if (!switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) {
 								if (!do_describe(tech_pvt, 0)) {
-									terminate_session(&session,  __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+									terminate_session(&session, __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 									status = LDL_STATUS_FALSE;
 									goto done;
 								}
@@ -2543,14 +2579,14 @@ static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsessi
 				}
 				if (!match && !switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) {
 					if (!do_describe(tech_pvt, 0)) {
-						terminate_session(&session,  __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+						terminate_session(&session, __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 						status = LDL_STATUS_FALSE;
 						goto done;
 					}
 				}
 			}
 		}
-		
+
 		break;
 	case LDL_SIGNAL_CANDIDATES:
 		if (dl_signal) {
@@ -2566,41 +2602,32 @@ static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsessi
 				goto done;
 			}
 
-				
+
 			if (tech_pvt->remote_ip) {
-				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Already picked an IP [%s]\n", tech_pvt->remote_ip);
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Already picked an IP [%s]\n",
+								  tech_pvt->remote_ip);
 				break;
 			}
 
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%u candidates\n", len);
-			for(x = 0; x < len; x++) {
+			for (x = 0; x < len; x++) {
 				uint8_t lanaddr = 0;
 
 				if (profile->lanaddr) {
 					lanaddr = strncasecmp(candidates[x].address, profile->lanaddr, strlen(profile->lanaddr)) ? 0 : 1;
-				} 
+				}
 
-				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "candidates %s:%d\n", candidates[x].address, candidates[x].port);
-					
-				if (!strcasecmp(candidates[x].protocol, "udp") && (!strcasecmp(candidates[x].type, "local") || !strcasecmp(candidates[x].type, "stun")) && 
-					((profile->lanaddr && lanaddr) ||
-					 (strncasecmp(candidates[x].address, "10.", 3) && 
-					  strncasecmp(candidates[x].address, "192.168.", 8) &&
-					  strncasecmp(candidates[x].address, "127.", 4) &&
-					  strncasecmp(candidates[x].address, "255.", 4) &&
-					  strncasecmp(candidates[x].address, "0.", 2) &&
-					  strncasecmp(candidates[x].address, "1.", 2) &&
-					  strncasecmp(candidates[x].address, "2.", 2) &&
-					  strncasecmp(candidates[x].address, "172.16.", 7) &&
-					  strncasecmp(candidates[x].address, "172.17.", 7) &&
-					  strncasecmp(candidates[x].address, "172.18.", 7) &&
-					  strncasecmp(candidates[x].address, "172.19.", 7) &&
-					  strncasecmp(candidates[x].address, "172.2", 5) &&
-					  strncasecmp(candidates[x].address, "172.30.", 7) &&
-					  strncasecmp(candidates[x].address, "172.31.", 7)  &&
-					  strncasecmp(candidates[x].address, "192.0.2.", 8)  && // 192.0.0.0 - 192.0.127.255 is marked as reserved, should we filter all of them?
-					  strncasecmp(candidates[x].address, "169.254.", 8)
-					  ))) {
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "candidates %s:%d\n", candidates[x].address,
+								  candidates[x].port);
+
+				if (!strcasecmp(candidates[x].protocol, "udp") && (!strcasecmp(candidates[x].type, "local") || !strcasecmp(candidates[x].type, "stun")) && ((profile->lanaddr && lanaddr) || (strncasecmp(candidates[x].address, "10.", 3) && strncasecmp(candidates[x].address, "192.168.", 8) && strncasecmp(candidates[x].address, "127.", 4) && strncasecmp(candidates[x].address, "255.", 4) && strncasecmp(candidates[x].address, "0.", 2) && strncasecmp(candidates[x].address, "1.", 2) && strncasecmp(candidates[x].address, "2.", 2) && strncasecmp(candidates[x].address, "172.16.", 7) && strncasecmp(candidates[x].address, "172.17.", 7) && strncasecmp(candidates[x].address, "172.18.", 7) && strncasecmp(candidates[x].address, "172.19.", 7) && strncasecmp(candidates[x].address, "172.2", 5) && strncasecmp(candidates[x].address, "172.30.", 7) && strncasecmp(candidates[x].address, "172.31.", 7) && strncasecmp(candidates[x].address, "192.0.2.", 8) &&	// 192.0.0.0 - 192.0.127.255 is marked as reserved, should we filter all of them?
+																																															  strncasecmp
+																																															  (candidates
+																																															   [x].
+																																															   address,
+																																															   "169.254.",
+																																															   8)
+																																							))) {
 					ldl_payload_t payloads[5];
 					char *exten;
 					char *context;
@@ -2610,7 +2637,8 @@ static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsessi
 
 					memset(payloads, 0, sizeof(payloads));
 
-					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Acceptable Candidate %s:%d\n", candidates[x].address, candidates[x].port);
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Acceptable Candidate %s:%d\n",
+									  candidates[x].address, candidates[x].port);
 
 					if (!switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) {
 						switch_set_flag_locked(tech_pvt, TFLAG_TRANSPORT_ACCEPT);
@@ -2638,7 +2666,7 @@ static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsessi
 							}
 						}
 					}
-						
+
 					if (!(context = ldl_session_get_value(dlsession, "context"))) {
 						context = profile->context;
 					}
@@ -2655,7 +2683,7 @@ static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsessi
 					if (profile->context && !strcmp(profile->context, "_auto_")) {
 						context = profile->name;
 					}
-			
+
 					tech_pvt->them = switch_core_session_strdup(session, ldl_session_get_callee(dlsession));
 					tech_pvt->us = switch_core_session_strdup(session, ldl_session_get_caller(dlsession));
 
@@ -2673,22 +2701,25 @@ static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsessi
 
 						switch_safe_free(tmp);
 					}
-						
+
 					if (!tech_pvt->caller_profile) {
-						switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Creating an identity for %s %s <%s> %s\n", 
-										  ldl_session_get_id(dlsession), cid_name, cid_num, exten);
-			
+						switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
+										  "Creating an identity for %s %s <%s> %s\n", ldl_session_get_id(dlsession),
+										  cid_name, cid_num, exten);
+
 						if ((tech_pvt->caller_profile = switch_caller_profile_new(switch_core_session_get_pool(session),
 																				  ldl_handle_get_login(profile->handle),
 																				  profile->dialplan,
 																				  cid_name,
 																				  cid_num,
 																				  ldl_session_get_ip(dlsession),
-																				  ldl_session_get_value(dlsession, "ani"),
-																				  ldl_session_get_value(dlsession, "aniii"),
-																				  ldl_session_get_value(dlsession, "rdnis"),
-																				  (char *)modname,
-																				  context,
+																				  ldl_session_get_value(dlsession,
+																										"ani"),
+																				  ldl_session_get_value(dlsession,
+																										"aniii"),
+																				  ldl_session_get_value(dlsession,
+																										"rdnis"),
+																				  (char *) modname, context,
 																				  exten)) != 0) {
 							char name[128];
 							snprintf(name, sizeof(name), "DingaLing/%s", tech_pvt->caller_profile->destination_number);
@@ -2698,32 +2729,32 @@ static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsessi
 					}
 
 					switch_safe_free(them);
-						
+
 					if (lanaddr) {
 						switch_set_flag_locked(tech_pvt, TFLAG_LANADDR);
 					}
 
 					if (!get_codecs(tech_pvt)) {
-						terminate_session(&session,  __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+						terminate_session(&session, __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 						status = LDL_STATUS_FALSE;
 						goto done;
 					}
 
-						
+
 					tech_pvt->remote_ip = switch_core_session_strdup(session, candidates[x].address);
 					ldl_session_set_ip(dlsession, tech_pvt->remote_ip);
 					tech_pvt->remote_port = candidates[x].port;
 					tech_pvt->remote_user = switch_core_session_strdup(session, candidates[x].username);
 
-						
+
 					if (!switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) {
 						if (!do_candidates(tech_pvt, 0)) {
-							terminate_session(&session,  __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+							terminate_session(&session, __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 							status = LDL_STATUS_FALSE;
 							goto done;
 						}
 					}
-						
+
 					status = LDL_STATUS_SUCCESS;
 					goto done;
 				}
@@ -2731,18 +2762,18 @@ static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsessi
 		}
 		break;
 	case LDL_SIGNAL_REJECT:
-        if (channel) {
+		if (channel) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "reject %s\n", switch_channel_get_name(channel));
-			terminate_session(&session,  __LINE__, SWITCH_CAUSE_CALL_REJECTED);
+			terminate_session(&session, __LINE__, SWITCH_CAUSE_CALL_REJECTED);
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "End Call (Rejected)\n");
 			goto done;
 		}
-        break;
+		break;
 	case LDL_SIGNAL_ERROR:
 	case LDL_SIGNAL_TERMINATE:
 		if (channel) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "hungup %s\n", switch_channel_get_name(channel));
-			terminate_session(&session,  __LINE__, SWITCH_CAUSE_NORMAL_CLEARING);
+			terminate_session(&session, __LINE__, SWITCH_CAUSE_NORMAL_CLEARING);
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "End Call\n");
 			goto done;
 		}
@@ -2753,12 +2784,12 @@ static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsessi
 		break;
 	}
 
- done:
-	
+  done:
+
 	return status;
 }
 
-static ldl_status handle_response(ldl_handle_t *handle, char *id)
+static ldl_status handle_response(ldl_handle_t * handle, char *id)
 {
 	return LDL_STATUS_SUCCESS;
 }
diff --git a/src/mod/endpoints/mod_iax/mod_iax.c b/src/mod/endpoints/mod_iax/mod_iax.c
index 45f63195dc..4db2f1f142 100644
--- a/src/mod/endpoints/mod_iax/mod_iax.c
+++ b/src/mod/endpoints/mod_iax/mod_iax.c
@@ -98,9 +98,9 @@ typedef struct private_object private_t;
 
 
 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_rates_string, globals.codec_rates_string)
-SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_ip, globals.ip)
+	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_ip, globals.ip)
 
 
 	 static char *IAXNAMES[] =
@@ -209,9 +209,9 @@ typedef enum {
 	IAX_QUERY = 2
 } iax_io_t;
 
-static switch_status_t iax_set_codec(private_t *tech_pvt, struct iax_session *iax_session,
-								   unsigned int *format, unsigned int *cababilities, unsigned short *samprate,
-								   iax_io_t io)
+static switch_status_t iax_set_codec(private_t * tech_pvt, struct iax_session *iax_session,
+									 unsigned int *format, unsigned int *cababilities, unsigned short *samprate,
+									 iax_io_t io)
 {
 	char *dname = NULL;
 	//int rate = 8000;
@@ -225,15 +225,16 @@ static switch_status_t iax_set_codec(private_t *tech_pvt, struct iax_session *ia
 
 	if (globals.codec_string) {
 		if ((num_codecs = switch_loadable_module_get_codecs_sorted(codecs,
-																	SWITCH_MAX_CODECS,
-																	globals.codec_order,
-																	globals.codec_order_last)) <= 0) {
+																   SWITCH_MAX_CODECS,
+																   globals.codec_order,
+																   globals.codec_order_last)) <= 0) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "NO codecs?\n");
 			return SWITCH_STATUS_GENERR;
 		}
 	} else
 		if (((num_codecs =
-			 switch_loadable_module_get_codecs(switch_core_session_get_pool(tech_pvt->session), codecs, SWITCH_MAX_CODECS))) <= 0) {
+			  switch_loadable_module_get_codecs(switch_core_session_get_pool(tech_pvt->session), codecs,
+												SWITCH_MAX_CODECS))) <= 0) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "NO codecs?\n");
 		return SWITCH_STATUS_GENERR;
 	}
@@ -244,7 +245,7 @@ static switch_status_t iax_set_codec(private_t *tech_pvt, struct iax_session *ia
 			unsigned int codec = iana2ast(imp->ianacode);
 			if (io == IAX_QUERY && !(codec & local_cap)) {
 				iax_pref_codec_add(iax_session, codec);
-			}	
+			}
 			local_cap |= codec;
 		}
 	}
@@ -422,12 +423,13 @@ 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_loopback(switch_core_session_t *session);
 static switch_status_t channel_on_transmit(switch_core_session_t *session);
-static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *session, switch_caller_profile_t *outbound_profile,
+static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *session,
+													switch_caller_profile_t *outbound_profile,
 													switch_core_session_t **new_session, switch_memory_pool_t **pool);
 static switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t **frame, int timeout,
-										switch_io_flag_t flags, int stream_id);
+										  switch_io_flag_t flags, int stream_id);
 static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, int timeout,
-										 switch_io_flag_t flags, int stream_id);
+										   switch_io_flag_t flags, int stream_id);
 static switch_status_t channel_kill_channel(switch_core_session_t *session, int sig);
 
 
@@ -443,14 +445,14 @@ static void iax_out_cb(const char *s)
 	}
 }
 
-static void tech_init(private_t *tech_pvt, switch_core_session_t *session)
+static void tech_init(private_t * tech_pvt, switch_core_session_t *session)
 {
 	tech_pvt->read_frame.data = tech_pvt->databuf;
 	tech_pvt->read_frame.buflen = sizeof(tech_pvt->databuf);
 	switch_mutex_init(&tech_pvt->mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
-    switch_mutex_init(&tech_pvt->flag_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
-    switch_core_session_set_private(session, tech_pvt);
-    tech_pvt->session = session;
+	switch_mutex_init(&tech_pvt->flag_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
+	switch_core_session_set_private(session, tech_pvt);
+	tech_pvt->session = session;
 }
 
 /* 
@@ -559,7 +561,7 @@ static switch_status_t channel_on_hangup(switch_core_session_t *session)
 		globals.calls = 0;
 	}
 	switch_mutex_unlock(globals.mutex);
-		
+
 	return SWITCH_STATUS_SUCCESS;
 }
 
@@ -574,20 +576,20 @@ static switch_status_t channel_kill_channel(switch_core_session_t *session, int
 	tech_pvt = switch_core_session_get_private(session);
 	assert(tech_pvt != NULL);
 
-    switch(sig) {
-    case SWITCH_SIG_KILL:
-        switch_clear_flag_locked(tech_pvt, TFLAG_IO);
-        switch_clear_flag_locked(tech_pvt, TFLAG_VOICE);
-        switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
-        //switch_thread_cond_signal(tech_pvt->cond);
-        break;
-    case SWITCH_SIG_BREAK:
-        switch_set_flag_locked(tech_pvt, TFLAG_BREAK);
-        break;
-    default:
-        break;
-    }
-	
+	switch (sig) {
+	case SWITCH_SIG_KILL:
+		switch_clear_flag_locked(tech_pvt, TFLAG_IO);
+		switch_clear_flag_locked(tech_pvt, TFLAG_VOICE);
+		switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
+		//switch_thread_cond_signal(tech_pvt->cond);
+		break;
+	case SWITCH_SIG_BREAK:
+		switch_set_flag_locked(tech_pvt, TFLAG_BREAK);
+		break;
+	default:
+		break;
+	}
+
 	return SWITCH_STATUS_SUCCESS;
 }
 
@@ -641,33 +643,33 @@ static switch_status_t channel_send_dtmf(switch_core_session_t *session, char *d
 }
 
 static switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t **frame, int timeout,
-										switch_io_flag_t flags, int stream_id)
+										  switch_io_flag_t flags, int stream_id)
 {
 	switch_channel_t *channel = NULL;
 	private_t *tech_pvt = NULL;
 	switch_time_t started = switch_time_now();
 	unsigned int elapsed;
 	switch_byte_t *data;
-	
+
 	channel = switch_core_session_get_channel(session);
 	assert(channel != NULL);
 
 	tech_pvt = switch_core_session_get_private(session);
 	assert(tech_pvt != NULL);
-    tech_pvt->read_frame.flags = SFF_NONE;
-    *frame = NULL;
+	tech_pvt->read_frame.flags = SFF_NONE;
+	*frame = NULL;
 
 	while (switch_test_flag(tech_pvt, TFLAG_IO)) {
-        
-        if (!switch_test_flag(tech_pvt, TFLAG_CODEC)) {
-            switch_yield(1000);
-            continue;
-        }
+
+		if (!switch_test_flag(tech_pvt, TFLAG_CODEC)) {
+			switch_yield(1000);
+			continue;
+		}
 		//switch_thread_cond_wait(tech_pvt->cond, tech_pvt->mutex);
 		if (switch_test_flag(tech_pvt, TFLAG_BREAK)) {
-            switch_clear_flag(tech_pvt, TFLAG_BREAK);
-            goto cng;
-        }
+			switch_clear_flag(tech_pvt, TFLAG_BREAK);
+			goto cng;
+		}
 
 		if (!switch_test_flag(tech_pvt, TFLAG_IO)) {
 			return SWITCH_STATUS_FALSE;
@@ -688,12 +690,12 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
 		}
 
 		if (timeout > -1) {
-			elapsed = (unsigned int)((switch_time_now() - started) / 1000);
-			if (elapsed >= (unsigned int)timeout) {
+			elapsed = (unsigned int) ((switch_time_now() - started) / 1000);
+			if (elapsed >= (unsigned int) timeout) {
 				return SWITCH_STATUS_SUCCESS;
 			}
 		}
-		
+
 
 		switch_yield(1000);
 	}
@@ -701,19 +703,19 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
 
 	return SWITCH_STATUS_FALSE;
 
- cng:
+  cng:
 	data = (switch_byte_t *) tech_pvt->read_frame.data;
 	data[0] = 65;
 	data[1] = 0;
-    tech_pvt->read_frame.datalen = 2;
-    tech_pvt->read_frame.flags = SFF_CNG; 
-    *frame = &tech_pvt->read_frame;
-    return SWITCH_STATUS_SUCCESS;
-	
+	tech_pvt->read_frame.datalen = 2;
+	tech_pvt->read_frame.flags = SFF_CNG;
+	*frame = &tech_pvt->read_frame;
+	return SWITCH_STATUS_SUCCESS;
+
 }
 
 static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, int timeout,
-										 switch_io_flag_t flags, int stream_id)
+										   switch_io_flag_t flags, int stream_id)
 {
 	switch_channel_t *channel = NULL;
 	private_t *tech_pvt = NULL;
@@ -799,7 +801,8 @@ static const switch_loadable_module_interface_t channel_module_interface = {
 /* Make sure when you have 2 sessions in the same scope that you pass the appropriate one to the routines
 that allocate memory or you will have 1 channel with memory allocated from another channel's pool!
 */
-static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *session, switch_caller_profile_t *outbound_profile,
+static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *session,
+													switch_caller_profile_t *outbound_profile,
 													switch_core_session_t **new_session, switch_memory_pool_t **pool)
 {
 	if ((*new_session = switch_core_session_request(&channel_endpoint_interface, pool)) != 0) {
@@ -812,7 +815,7 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
 		switch_core_session_add_stream(*new_session, NULL);
 		if ((tech_pvt = (private_t *) switch_core_session_alloc(*new_session, sizeof(private_t))) != 0) {
 			channel = switch_core_session_get_channel(*new_session);
-            tech_init(tech_pvt, *new_session);
+			tech_init(tech_pvt, *new_session);
 		} else {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Hey where is my memory pool?\n");
 			switch_core_session_destroy(new_session);
@@ -863,7 +866,8 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
 
 }
 
-SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
+													   char *filename)
 {
 
 	if (switch_core_new_memory_pool(&module_pool) != SWITCH_STATUS_SUCCESS) {
@@ -871,7 +875,7 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_mod
 		return SWITCH_STATUS_TERM;
 	}
 
-	
+
 	/* connect my internal structure to the blank pointer passed to me */
 	*module_interface = &channel_module_interface;
 
@@ -943,18 +947,21 @@ static switch_status_t load_config(void)
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status_t tech_media(private_t *tech_pvt, struct iax_event *iaxevent)
+static switch_status_t tech_media(private_t * tech_pvt, struct iax_event *iaxevent)
 {
-    unsigned int cap = iax_session_get_capability(iaxevent->session);
-    unsigned int format = iaxevent->ies.format;
+	unsigned int cap = iax_session_get_capability(iaxevent->session);
+	unsigned int format = iaxevent->ies.format;
 	switch_status_t status = SWITCH_STATUS_SUCCESS;
-    
-    if (!switch_test_flag(tech_pvt, TFLAG_CODEC) && 
-        (status = iax_set_codec(tech_pvt, iaxevent->session, &format, &cap, &iaxevent->ies.samprate, IAX_SET)) != SWITCH_STATUS_SUCCESS) {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Codec Error %u %u\n", iaxevent->ies.format, iaxevent->ies.capability);
-    }
-    
-    return status;
+
+	if (!switch_test_flag(tech_pvt, TFLAG_CODEC) &&
+		(status =
+		 iax_set_codec(tech_pvt, iaxevent->session, &format, &cap, &iaxevent->ies.samprate,
+					   IAX_SET)) != SWITCH_STATUS_SUCCESS) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Codec Error %u %u\n", iaxevent->ies.format,
+						  iaxevent->ies.capability);
+	}
+
+	return status;
 }
 
 SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void)
@@ -994,7 +1001,7 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void)
 		/* Wait for an event. */
 		if ((iaxevent = iax_get_event(0)) == NULL) {
 			int waitlen = 0;
-			
+
 			if (globals.calls == 0) {
 				waitlen = 10000;
 			} else if (globals.calls < 10) {
@@ -1007,12 +1014,12 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void)
 			continue;
 		} else {
 			private_t *tech_pvt = NULL;
-            switch_channel_t *channel = NULL;
+			switch_channel_t *channel = NULL;
+
+			if ((tech_pvt = iax_get_private(iaxevent->session))) {
+				channel = switch_core_session_get_channel(tech_pvt->session);
+			}
 
-            if ((tech_pvt = iax_get_private(iaxevent->session))) {
-                channel = switch_core_session_get_channel(tech_pvt->session);
-            }
-            
 			if (globals.debug && iaxevent->etype != IAX_EVENT_VOICE) {
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Event %d [%s]!\n",
 								  iaxevent->etype, IAXNAMES[iaxevent->etype]);
@@ -1031,11 +1038,11 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void)
 				break;
 			case IAX_EVENT_ACCEPT:
 				if (channel && !switch_channel_test_flag(channel, CF_ANSWERED)) {
-                    if (tech_media(tech_pvt, iaxevent) == SWITCH_STATUS_SUCCESS) {
-                        switch_channel_mark_pre_answered(channel);
-                    } else {
-                        switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
-                    }
+					if (tech_media(tech_pvt, iaxevent) == SWITCH_STATUS_SUCCESS) {
+						switch_channel_mark_pre_answered(channel);
+					} else {
+						switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+					}
 				}
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Call accepted.\n");
 				break;
@@ -1052,32 +1059,34 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void)
 			case IAX_EVENT_ANSWER:
 				// the other side answered our call
 				if (channel) {
-                    if (tech_media(tech_pvt, iaxevent) == SWITCH_STATUS_SUCCESS) {
-                        if (switch_channel_test_flag(channel, CF_ANSWERED)) {
-                            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "WTF Mutiple Answer %s?\n", switch_channel_get_name(channel));
-						
-                        } else {
-                            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Answer %s\n", switch_channel_get_name(channel));
-                            switch_channel_mark_answered(channel);
-                        }
-                    } else {
-                        switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
-                    }
-                }
+					if (tech_media(tech_pvt, iaxevent) == SWITCH_STATUS_SUCCESS) {
+						if (switch_channel_test_flag(channel, CF_ANSWERED)) {
+							switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "WTF Mutiple Answer %s?\n",
+											  switch_channel_get_name(channel));
+
+						} else {
+							switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Answer %s\n",
+											  switch_channel_get_name(channel));
+							switch_channel_mark_answered(channel);
+						}
+					} else {
+						switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+					}
+				}
 				break;
 			case IAX_EVENT_CONNECT:
 				// incoming call detected
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE,
-									  "Incoming call connected %s, %s, %s %u/%u\n",
-									  iaxevent->ies.called_number,
-									  iaxevent->ies.calling_number,
-									  iaxevent->ies.calling_name, iaxevent->ies.format, iaxevent->ies.capability);
+								  "Incoming call connected %s, %s, %s %u/%u\n",
+								  iaxevent->ies.called_number,
+								  iaxevent->ies.calling_number,
+								  iaxevent->ies.calling_name, iaxevent->ies.format, iaxevent->ies.capability);
 
 				if (iaxevent) {
 					switch_core_session_t *session;
 
 					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "New Inbound Channel %s!\n",
-										  iaxevent->ies.calling_name);
+									  iaxevent->ies.calling_name);
 					if ((session = switch_core_session_request(&channel_endpoint_interface, NULL)) != 0) {
 						private_t *tech_pvt;
 						switch_channel_t *channel;
@@ -1085,7 +1094,7 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void)
 						switch_core_session_add_stream(session, NULL);
 						if ((tech_pvt = (private_t *) switch_core_session_alloc(session, sizeof(private_t))) != 0) {
 							channel = switch_core_session_get_channel(session);
-                            tech_init(tech_pvt, session);
+							tech_init(tech_pvt, session);
 						} else {
 							switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Hey where is my memory pool?\n");
 							switch_core_session_destroy(&session);
@@ -1100,9 +1109,9 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void)
 																				  iaxevent->ies.calling_number,
 																				  iax_get_peer_ip(iaxevent->session),
 																				  iaxevent->ies.calling_ani,
-																				  NULL, 
 																				  NULL,
-																				  (char *)modname,
+																				  NULL,
+																				  (char *) modname,
 																				  iaxevent->ies.called_context,
 																				  iaxevent->ies.called_number)) != 0) {
 							char name[128];
@@ -1141,11 +1150,15 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void)
 					switch_mutex_unlock(tech_pvt->flag_mutex);
 
 
-                    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Hangup %s\n", switch_channel_get_name(channel));
-                    switch_set_flag_locked(tech_pvt, TFLAG_HANGUP);
-                    switch_channel_hangup(channel, iaxevent->etype == IAX_EVENT_HANGUP ? SWITCH_CAUSE_NORMAL_CLEARING : SWITCH_CAUSE_FACILITY_REJECTED);
-                    //switch_thread_cond_signal(tech_pvt->cond);
-                    iaxevent->session = NULL;
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Hangup %s\n",
+									  switch_channel_get_name(channel));
+					switch_set_flag_locked(tech_pvt, TFLAG_HANGUP);
+					switch_channel_hangup(channel,
+										  iaxevent->etype ==
+										  IAX_EVENT_HANGUP ? SWITCH_CAUSE_NORMAL_CLEARING :
+										  SWITCH_CAUSE_FACILITY_REJECTED);
+					//switch_thread_cond_signal(tech_pvt->cond);
+					iaxevent->session = NULL;
 				}
 				break;
 			case IAX_EVENT_CNG:
@@ -1156,7 +1169,7 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void)
 				if (tech_pvt && (tech_pvt->read_frame.datalen = iaxevent->datalen) != 0) {
 					if (channel && switch_channel_get_state(channel) <= CS_HANGUP) {
 						int bytes, frames;
-						
+
 						if (!switch_test_flag(tech_pvt, TFLAG_CODEC)) {
 							//switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "audio with no codec yet!\n");
 							break;
@@ -1183,18 +1196,18 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void)
 				break;
 			case IAX_EVENT_DTMF:
 				if (channel) {
-                    char str[2] = { (char)iaxevent->subclass };
-                    if (globals.debug) {
-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "%s DTMF %s\n", str,
-                                          switch_channel_get_name(channel));
-                    }
-                    switch_channel_queue_dtmf(channel, str);
+					char str[2] = { (char) iaxevent->subclass };
+					if (globals.debug) {
+						switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "%s DTMF %s\n", str,
+										  switch_channel_get_name(channel));
+					}
+					switch_channel_queue_dtmf(channel, str);
 				}
 
 				break;
 			default:
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Don't know what to do with IAX event %d.\n",
-									  iaxevent->etype);
+								  iaxevent->etype);
 				break;
 			}
 
@@ -1216,7 +1229,7 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_shutdown(void)
 	running = -1;
 
 	if (globals.fd) {
-		/* Die Mutha $%#$@% Die Mutha $#%#$^ Die*/
+		/* Die Mutha $%#$@% Die Mutha $#%#$^ Die */
 		shutdown(globals.fd, 2);
 	}
 	iax_shutdown();
diff --git a/src/mod/endpoints/mod_portaudio/mod_portaudio.c b/src/mod/endpoints/mod_portaudio/mod_portaudio.c
index 027d75a7dc..0eb8da3933 100644
--- a/src/mod/endpoints/mod_portaudio/mod_portaudio.c
+++ b/src/mod/endpoints/mod_portaudio/mod_portaudio.c
@@ -48,13 +48,13 @@ static switch_memory_pool_t *module_pool = NULL;
 //#define SAMPLE_TYPE  paFloat32
 typedef short SAMPLE;
 
-typedef switch_status_t (*pa_command_t)(char **argv, int argc, switch_stream_handle_t *stream);
+typedef switch_status_t (*pa_command_t) (char **argv, int argc, switch_stream_handle_t *stream);
 
 typedef enum {
-    GFLAG_NONE = 0,
-    GFLAG_EAR = (1 << 0),
-    GFLAG_MOUTH = (1 << 1),
-    GFLAG_RING = (1 << 2)
+	GFLAG_NONE = 0,
+	GFLAG_EAR = (1 << 0),
+	GFLAG_MOUTH = (1 << 1),
+	GFLAG_RING = (1 << 2)
 } GFLAGS;
 
 typedef enum {
@@ -75,17 +75,17 @@ struct private_object {
 	switch_core_session_t *session;
 	switch_caller_profile_t *caller_profile;
 	char call_id[50];
-    int sample_rate;
-    int codec_ms;
+	int sample_rate;
+	int codec_ms;
 	switch_mutex_t *flag_mutex;
-    char *hold_file;
-    switch_file_handle_t fh;
-    switch_file_handle_t *hfh;
+	char *hold_file;
+	switch_file_handle_t fh;
+	switch_file_handle_t *hfh;
 	switch_frame_t hold_frame;
-    unsigned char holdbuf[SWITCH_RECOMMENDED_BUFFER_SIZE];
+	unsigned char holdbuf[SWITCH_RECOMMENDED_BUFFER_SIZE];
 	switch_codec_t write_codec;
-    switch_timer_t timer;
-    struct private_object *next;
+	switch_timer_t timer;
+	struct private_object *next;
 };
 
 typedef struct private_object private_t;
@@ -96,9 +96,9 @@ static struct {
 	char *cid_name;
 	char *cid_num;
 	char *dialplan;
-    char *ring_file;
-    char *hold_file;
-    char *timer_name;
+	char *ring_file;
+	char *hold_file;
+	char *timer_name;
 	int ringdev;
 	int indev;
 	int outdev;
@@ -114,13 +114,13 @@ static struct {
 	switch_codec_t read_codec;
 	switch_codec_t write_codec;
 	switch_frame_t read_frame;
-    switch_frame_t cng_frame;
+	switch_frame_t cng_frame;
 	unsigned char databuf[SWITCH_RECOMMENDED_BUFFER_SIZE];
 	unsigned char cngbuf[SWITCH_RECOMMENDED_BUFFER_SIZE];
-    private_t *call_list;
-    int ring_interval;
-    GFLAGS flags;
-    switch_timer_t timer;
+	private_t *call_list;
+	int ring_interval;
+	GFLAGS flags;
+	switch_timer_t timer;
 } globals;
 
 
@@ -129,37 +129,37 @@ static struct {
 
 
 SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_dialplan, globals.dialplan)
-SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_cid_name, globals.cid_name)
-SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_cid_num, globals.cid_num)
-SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_ring_file, globals.ring_file)
-SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_hold_file, globals.hold_file)
-SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_timer_name, globals.timer_name)
-
+	SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_cid_name, globals.cid_name)
+	SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_cid_num, globals.cid_num)
+	SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_ring_file, globals.ring_file)
+	SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_hold_file, globals.hold_file)
+	SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_timer_name, globals.timer_name)
 #define is_master(t) switch_test_flag(t, TFLAG_MASTER)
-static void add_pvt(private_t *tech_pvt, int master);
-static void remove_pvt(private_t *tech_pvt);
-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_ring(switch_core_session_t *session);
-static switch_status_t channel_on_loopback(switch_core_session_t *session);
-static switch_status_t channel_on_transmit(switch_core_session_t *session);
-static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *session,
-													switch_caller_profile_t *outbound_profile,
-													switch_core_session_t **new_session, switch_memory_pool_t **pool);
-static switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t **frame, int timeout,
-                                          switch_io_flag_t flags, int stream_id);
-static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, int timeout,
-                                           switch_io_flag_t flags, int stream_id);
-static switch_status_t channel_kill_channel(switch_core_session_t *session, int sig);
-static switch_status_t engage_device(int samplerate, int codec_ms);
-static switch_status_t engage_ring_device(int sample_rate, int channels);
-static void deactivate_ring_device(void);
-static int dump_info(void);
-static switch_status_t load_config(void);
-static int get_dev_by_name(char *name, 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 padep(char *dest, switch_core_session_t *session, switch_stream_handle_t *stream);
+	 static void add_pvt(private_t * tech_pvt, int master);
+	 static void remove_pvt(private_t * tech_pvt);
+	 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_ring(switch_core_session_t *session);
+	 static switch_status_t channel_on_loopback(switch_core_session_t *session);
+	 static switch_status_t channel_on_transmit(switch_core_session_t *session);
+	 static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *session,
+														 switch_caller_profile_t *outbound_profile,
+														 switch_core_session_t **new_session,
+														 switch_memory_pool_t **pool);
+	 static switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t **frame, int timeout,
+											   switch_io_flag_t flags, int stream_id);
+	 static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, int timeout,
+												switch_io_flag_t flags, int stream_id);
+	 static switch_status_t channel_kill_channel(switch_core_session_t *session, int sig);
+	 static switch_status_t engage_device(int samplerate, int codec_ms);
+	 static switch_status_t engage_ring_device(int sample_rate, int channels);
+	 static void deactivate_ring_device(void);
+	 static int dump_info(void);
+	 static switch_status_t load_config(void);
+	 static int get_dev_by_name(char *name, 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 padep(char *dest, switch_core_session_t *session, switch_stream_handle_t *stream);
 
 
 /* 
@@ -167,94 +167,97 @@ static switch_status_t padep(char *dest, switch_core_session_t *session, switch_
    returning SWITCH_STATUS_SUCCESS tells the core to execute the standard state method next
    so if you fully implement the state you can return SWITCH_STATUS_FALSE to skip it.
 */
-static switch_status_t channel_on_init(switch_core_session_t *session)
+	 static switch_status_t channel_on_init(switch_core_session_t *session)
 {
 	switch_channel_t *channel;
 	private_t *tech_pvt = NULL;
 	switch_time_t last;
 	int waitsec = globals.ring_interval * 1000000;
-    switch_file_handle_t fh = {0};
-    char *val, *ring_file = NULL, *hold_file = NULL;
-    int16_t abuf[2048];
+	switch_file_handle_t fh = { 0 };
+	char *val, *ring_file = NULL, *hold_file = NULL;
+	int16_t abuf[2048];
 
-    tech_pvt = switch_core_session_get_private(session);
+	tech_pvt = switch_core_session_get_private(session);
 	assert(tech_pvt != NULL);
 
 	channel = switch_core_session_get_channel(session);
 	assert(channel != NULL);
 
-    
+
 	last = switch_time_now() - waitsec;
 
 
 
-    if ((val = switch_channel_get_variable(channel, "pa_hold_file"))) {
-        hold_file = val;
-    } else {
-        hold_file = globals.hold_file;
-    }
+	if ((val = switch_channel_get_variable(channel, "pa_hold_file"))) {
+		hold_file = val;
+	} else {
+		hold_file = globals.hold_file;
+	}
 
-    if (hold_file) {
-        tech_pvt->hold_file = switch_core_session_strdup(session, hold_file);
-    }
+	if (hold_file) {
+		tech_pvt->hold_file = switch_core_session_strdup(session, hold_file);
+	}
 
 	if (switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) {
 
-        
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL INIT %d %d\n", switch_channel_get_name(channel),
-                          switch_channel_get_state(channel), switch_test_flag(tech_pvt, TFLAG_ANSWER));
-        
+
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL INIT %d %d\n",
+						  switch_channel_get_name(channel), switch_channel_get_state(channel),
+						  switch_test_flag(tech_pvt, TFLAG_ANSWER));
 
 
-        if (engage_device(tech_pvt->sample_rate, tech_pvt->codec_ms) != SWITCH_STATUS_SUCCESS) {
-            switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
-            return SWITCH_STATUS_FALSE;
-        }
 
-        if (switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) {
-            add_pvt(tech_pvt, PA_SLAVE);
+		if (engage_device(tech_pvt->sample_rate, tech_pvt->codec_ms) != SWITCH_STATUS_SUCCESS) {
+			switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+			return SWITCH_STATUS_FALSE;
+		}
 
-            ring_file = globals.ring_file;
-            if ((val = switch_channel_get_variable(channel, "pa_ring_file"))) {
-                ring_file = val;
-            }
+		if (switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) {
+			add_pvt(tech_pvt, PA_SLAVE);
 
-            if (switch_test_flag((&globals), GFLAG_RING)) {
-                ring_file = NULL;
-            }
-            switch_set_flag_locked((&globals), GFLAG_RING);
-            if (ring_file) {
-                if (switch_core_file_open(&fh,
-                                          ring_file,
+			ring_file = globals.ring_file;
+			if ((val = switch_channel_get_variable(channel, "pa_ring_file"))) {
+				ring_file = val;
+			}
+
+			if (switch_test_flag((&globals), GFLAG_RING)) {
+				ring_file = NULL;
+			}
+			switch_set_flag_locked((&globals), GFLAG_RING);
+			if (ring_file) {
+				if (switch_core_file_open(&fh,
+										  ring_file,
 										  globals.read_codec.implementation->number_of_channels,
 										  globals.read_codec.implementation->samples_per_second,
-                                          SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT,
-                                          NULL) == SWITCH_STATUS_SUCCESS) {
-            
-                    if (engage_ring_device(fh.samplerate, fh.channels) != SWITCH_STATUS_SUCCESS) {
-                        switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Ring Error!\n");
-                        switch_core_file_close(&fh);
-                        return SWITCH_STATUS_GENERR;
-                    }
-                } else {
-                    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot open %s, disabling ring file!\n", ring_file);
-                    ring_file = NULL;
-                }
-            }
-        }
+										  SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT,
+										  NULL) == SWITCH_STATUS_SUCCESS) {
+
+					if (engage_ring_device(fh.samplerate, fh.channels) != SWITCH_STATUS_SUCCESS) {
+						switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+						switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Ring Error!\n");
+						switch_core_file_close(&fh);
+						return SWITCH_STATUS_GENERR;
+					}
+				} else {
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot open %s, disabling ring file!\n",
+									  ring_file);
+					ring_file = NULL;
+				}
+			}
+		}
 
 		switch_core_session_queue_indication(session, SWITCH_MESSAGE_INDICATE_RINGING);
 		switch_channel_mark_ring_ready(channel);
-		
+
 		while (switch_channel_get_state(channel) == CS_INIT && !switch_test_flag(tech_pvt, TFLAG_ANSWER)) {
 			if (switch_time_now() - last >= waitsec) {
 				char buf[512];
 				switch_event_t *event;
-                
+
 				snprintf(buf, sizeof(buf), "BRRRRING! BRRRRING! call %s\n", tech_pvt->call_id);
 
-				if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, MY_EVENT_RINGING) == SWITCH_STATUS_SUCCESS) {
+				if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, MY_EVENT_RINGING) ==
+					SWITCH_STATUS_SUCCESS) {
 					switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_info", "%s", buf);
 					switch_event_add_header(event, SWITCH_STACK_BOTTOM, "call_id", "%s", tech_pvt->call_id);
 					switch_channel_event_set_data(channel, event);
@@ -263,46 +266,46 @@ static switch_status_t channel_on_init(switch_core_session_t *session)
 
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s\n", buf);
 				last = switch_time_now();
-                if (ring_file) {
-                    unsigned int pos = 0;
-                    switch_core_file_seek(&fh, &pos, 0, SEEK_SET);				 
-                    for (;;) {
-                        switch_size_t olen = 1024;
-                        switch_core_file_read(&fh, abuf, &olen);
-                        if (olen == 0) {
-                            break;
-                        }
-                        WriteAudioStream(globals.ring_stream, abuf, (long)olen);
-                    }
-                }
-            }
+				if (ring_file) {
+					unsigned int pos = 0;
+					switch_core_file_seek(&fh, &pos, 0, SEEK_SET);
+					for (;;) {
+						switch_size_t olen = 1024;
+						switch_core_file_read(&fh, abuf, &olen);
+						if (olen == 0) {
+							break;
+						}
+						WriteAudioStream(globals.ring_stream, abuf, (long) olen);
+					}
+				}
+			}
 
-            switch_yield(globals.read_codec.implementation->microseconds_per_frame);
+			switch_yield(globals.read_codec.implementation->microseconds_per_frame);
 
-        }
-        switch_clear_flag_locked((&globals), GFLAG_RING);
-    }
-
-    if (ring_file) {
-        deactivate_ring_device();
-        switch_core_file_close(&fh);
-        switch_core_codec_destroy(&tech_pvt->write_codec);
-		switch_core_timer_destroy(&tech_pvt->timer);
-    }
-
-	if (switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) {
-        if (!switch_test_flag(tech_pvt, TFLAG_ANSWER)) {
-            switch_channel_hangup(channel, SWITCH_CAUSE_NO_ANSWER);
-            return SWITCH_STATUS_SUCCESS;
-        }
+		}
+		switch_clear_flag_locked((&globals), GFLAG_RING);
 	}
 
-    switch_set_flag_locked(tech_pvt, TFLAG_IO);
+	if (ring_file) {
+		deactivate_ring_device();
+		switch_core_file_close(&fh);
+		switch_core_codec_destroy(&tech_pvt->write_codec);
+		switch_core_timer_destroy(&tech_pvt->timer);
+	}
 
-    /* Move Channel's State Machine to RING */
-    switch_channel_set_state(channel, CS_RING);
-	
-    return SWITCH_STATUS_SUCCESS;
+	if (switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) {
+		if (!switch_test_flag(tech_pvt, TFLAG_ANSWER)) {
+			switch_channel_hangup(channel, SWITCH_CAUSE_NO_ANSWER);
+			return SWITCH_STATUS_SUCCESS;
+		}
+	}
+
+	switch_set_flag_locked(tech_pvt, TFLAG_IO);
+
+	/* Move Channel's State Machine to RING */
+	switch_channel_set_state(channel, CS_RING);
+
+	return SWITCH_STATUS_SUCCESS;
 
 }
 
@@ -363,72 +366,72 @@ static void deactivate_ring_device(void)
 
 
 
-static void add_pvt(private_t *tech_pvt, int master) 
+static void add_pvt(private_t * tech_pvt, int master)
 {
-    private_t *tp;
-    uint8_t in_list = 0;
+	private_t *tp;
+	uint8_t in_list = 0;
 
-    switch_mutex_lock(globals.pvt_lock);
+	switch_mutex_lock(globals.pvt_lock);
 
-    if (switch_strlen_zero(tech_pvt->call_id)) {
-        snprintf(tech_pvt->call_id, sizeof(tech_pvt->call_id), "%d", ++globals.call_id);
-        switch_core_hash_insert(globals.call_hash, tech_pvt->call_id, tech_pvt);
-        switch_core_session_set_read_codec(tech_pvt->session, &globals.read_codec);
-        switch_core_session_set_write_codec(tech_pvt->session, &globals.write_codec);
-    }
+	if (switch_strlen_zero(tech_pvt->call_id)) {
+		snprintf(tech_pvt->call_id, sizeof(tech_pvt->call_id), "%d", ++globals.call_id);
+		switch_core_hash_insert(globals.call_hash, tech_pvt->call_id, tech_pvt);
+		switch_core_session_set_read_codec(tech_pvt->session, &globals.read_codec);
+		switch_core_session_set_write_codec(tech_pvt->session, &globals.write_codec);
+	}
 
-    for (tp = globals.call_list; tp; tp = tp->next) {
-        if (tp == tech_pvt) {
-            in_list = 1;
-        }
-        if (master) {
-            switch_clear_flag_locked(tp, TFLAG_MASTER);
-        }
-    }
+	for (tp = globals.call_list; tp; tp = tp->next) {
+		if (tp == tech_pvt) {
+			in_list = 1;
+		}
+		if (master) {
+			switch_clear_flag_locked(tp, TFLAG_MASTER);
+		}
+	}
 
 
-    if (master) {
-        if (!in_list) {
-            tech_pvt->next = globals.call_list;
-            globals.call_list = tech_pvt;
-        }
-        switch_set_flag_locked(tech_pvt, TFLAG_MASTER);
+	if (master) {
+		if (!in_list) {
+			tech_pvt->next = globals.call_list;
+			globals.call_list = tech_pvt;
+		}
+		switch_set_flag_locked(tech_pvt, TFLAG_MASTER);
 
-    } else if (!in_list) {
-        for (tp = globals.call_list; tp && tp->next; tp = tp->next);
-        if (tp) {
-            tp->next = tech_pvt;
-        } else {
-            globals.call_list = tech_pvt;
-        }
-    }
+	} else if (!in_list) {
+		for (tp = globals.call_list; tp && tp->next; tp = tp->next);
+		if (tp) {
+			tp->next = tech_pvt;
+		} else {
+			globals.call_list = tech_pvt;
+		}
+	}
 
 	switch_mutex_unlock(globals.pvt_lock);
 }
 
-static void remove_pvt(private_t *tech_pvt) 
+static void remove_pvt(private_t * tech_pvt)
 {
-    private_t *tp, *last = NULL;
+	private_t *tp, *last = NULL;
 
 	switch_mutex_lock(globals.pvt_lock);
-    for (tp = globals.call_list; tp; tp = tp->next) {
-        switch_clear_flag_locked(tp, TFLAG_MASTER);
-        if (tp == tech_pvt) {
-            if (last) {
-                last->next = tp->next;
-            } else {
-                globals.call_list = tp->next;
-            }
-        }
-        last = tp;
-    }
+	for (tp = globals.call_list; tp; tp = tp->next) {
+		switch_clear_flag_locked(tp, TFLAG_MASTER);
+		if (tp == tech_pvt) {
+			if (last) {
+				last->next = tp->next;
+			} else {
+				globals.call_list = tp->next;
+			}
+		}
+		last = tp;
+	}
 
-    if (globals.call_list) {
-        switch_set_flag_locked(globals.call_list, TFLAG_MASTER);
-    } else {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "No more channels, deactivating audio\n");
-        deactivate_audio_device();
-    }
+	if (globals.call_list) {
+		switch_set_flag_locked(globals.call_list, TFLAG_MASTER);
+	} else {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "No more channels, deactivating audio\n");
+		deactivate_audio_device();
+	}
 
 	switch_mutex_unlock(globals.pvt_lock);
 }
@@ -444,17 +447,17 @@ static switch_status_t channel_on_hangup(switch_core_session_t *session)
 	tech_pvt = switch_core_session_get_private(session);
 	assert(tech_pvt != NULL);
 
-    remove_pvt(tech_pvt);
+	remove_pvt(tech_pvt);
 
 	switch_clear_flag_locked(tech_pvt, TFLAG_IO);
 	switch_set_flag_locked(tech_pvt, TFLAG_HUP);
 
 	switch_core_hash_delete(globals.call_hash, tech_pvt->call_id);
 
-    if (tech_pvt->hfh) {
-        tech_pvt->hfh = NULL;
-        switch_core_file_close(&tech_pvt->fh);
-    }
+	if (tech_pvt->hfh) {
+		tech_pvt->hfh = NULL;
+		switch_core_file_close(&tech_pvt->fh);
+	}
 
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL HANGUP\n", switch_channel_get_name(channel));
 
@@ -472,14 +475,14 @@ static switch_status_t channel_kill_channel(switch_core_session_t *session, int
 	tech_pvt = switch_core_session_get_private(session);
 	assert(tech_pvt != NULL);
 
-    switch (sig) {
-    case SWITCH_SIG_KILL:
-        switch_set_flag_locked(tech_pvt, TFLAG_HUP);
-        switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
-        break;
-    default:
-        break;
-    }
+	switch (sig) {
+	case SWITCH_SIG_KILL:
+		switch_set_flag_locked(tech_pvt, TFLAG_HUP);
+		switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
+		break;
+	default:
+		break;
+	}
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL KILL\n", switch_channel_get_name(channel));
 
 
@@ -543,7 +546,7 @@ static switch_status_t channel_send_dtmf(switch_core_session_t *session, char *d
 }
 
 static switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t **frame, int timeout,
-                                          switch_io_flag_t flags, int stream_id)
+										  switch_io_flag_t flags, int stream_id)
 {
 	switch_channel_t *channel = NULL;
 	private_t *tech_pvt = NULL;
@@ -557,94 +560,96 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
 	assert(tech_pvt != NULL);
 
 	if (!globals.audio_stream) {
-        return SWITCH_STATUS_FALSE;
-    }
+		return SWITCH_STATUS_FALSE;
+	}
 
-    if (switch_test_flag(tech_pvt, TFLAG_HUP)) {
-        return SWITCH_STATUS_FALSE;
-    }
-    
-    if (!switch_test_flag(tech_pvt, TFLAG_IO)) {
-        goto cng;
-    }
+	if (switch_test_flag(tech_pvt, TFLAG_HUP)) {
+		return SWITCH_STATUS_FALSE;
+	}
 
-    if (!is_master(tech_pvt)) {
-        if (tech_pvt->hold_file) {
-            if (!tech_pvt->hfh) {
-                int codec_ms = tech_pvt->codec_ms ? tech_pvt->codec_ms : globals.codec_ms;
-                int sample_rate = tech_pvt->sample_rate ? tech_pvt->sample_rate : globals.sample_rate;
+	if (!switch_test_flag(tech_pvt, TFLAG_IO)) {
+		goto cng;
+	}
 
-                if (switch_core_codec_init(&tech_pvt->write_codec,
-                                           "L16",
-                                           NULL,
-                                           sample_rate,
-                                           codec_ms,
-                                           1,
-                                           SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
-                                           NULL,
-                                           switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
-                    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n");
-                    switch_core_codec_destroy(&globals.read_codec);
-                    tech_pvt->hold_file = NULL;
-                    goto cng;
-                }
+	if (!is_master(tech_pvt)) {
+		if (tech_pvt->hold_file) {
+			if (!tech_pvt->hfh) {
+				int codec_ms = tech_pvt->codec_ms ? tech_pvt->codec_ms : globals.codec_ms;
+				int sample_rate = tech_pvt->sample_rate ? tech_pvt->sample_rate : globals.sample_rate;
 
-                if (switch_core_file_open(&tech_pvt->fh,
-                                          tech_pvt->hold_file,
+				if (switch_core_codec_init(&tech_pvt->write_codec,
+										   "L16",
+										   NULL,
+										   sample_rate,
+										   codec_ms,
+										   1,
+										   SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
+										   NULL,
+										   switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n");
+					switch_core_codec_destroy(&globals.read_codec);
+					tech_pvt->hold_file = NULL;
+					goto cng;
+				}
+
+				if (switch_core_file_open(&tech_pvt->fh,
+										  tech_pvt->hold_file,
 										  globals.read_codec.implementation->number_of_channels,
-                                          globals.read_codec.implementation->samples_per_second,
-                                          SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT,
-                                          switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
-                    switch_core_codec_destroy(&tech_pvt->write_codec);
-                    tech_pvt->hold_file = NULL;
-                    goto cng;
-                }
+										  globals.read_codec.implementation->samples_per_second,
+										  SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT,
+										  switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
+					switch_core_codec_destroy(&tech_pvt->write_codec);
+					tech_pvt->hold_file = NULL;
+					goto cng;
+				}
 
-                tech_pvt->hfh = &tech_pvt->fh;
-                tech_pvt->hold_frame.data = tech_pvt->holdbuf;
-                tech_pvt->hold_frame.buflen = sizeof(tech_pvt->holdbuf);
-                tech_pvt->hold_frame.rate = sample_rate;
-                tech_pvt->hold_frame.codec = &tech_pvt->write_codec;
-            }
-            
-            goto hold;
-        }
-    cng:
-        switch_yield(globals.read_codec.implementation->microseconds_per_frame);
-        *frame = &globals.cng_frame;
+				tech_pvt->hfh = &tech_pvt->fh;
+				tech_pvt->hold_frame.data = tech_pvt->holdbuf;
+				tech_pvt->hold_frame.buflen = sizeof(tech_pvt->holdbuf);
+				tech_pvt->hold_frame.rate = sample_rate;
+				tech_pvt->hold_frame.codec = &tech_pvt->write_codec;
+			}
+
+			goto hold;
+		}
+	  cng:
+		switch_yield(globals.read_codec.implementation->microseconds_per_frame);
+		*frame = &globals.cng_frame;
 		return SWITCH_STATUS_SUCCESS;
 
-    hold:
+	  hold:
 
-        {
-            switch_size_t olen = globals.read_codec.implementation->samples_per_frame;
+		{
+			switch_size_t olen = globals.read_codec.implementation->samples_per_frame;
 			if (switch_core_timer_next(&tech_pvt->timer) != SWITCH_STATUS_SUCCESS) {
-                switch_core_file_close(&tech_pvt->fh);
-                switch_core_codec_destroy(&tech_pvt->write_codec);
-                goto cng;
+				switch_core_file_close(&tech_pvt->fh);
+				switch_core_codec_destroy(&tech_pvt->write_codec);
+				goto cng;
 			}
-            switch_core_file_read(tech_pvt->hfh, tech_pvt->hold_frame.data, &olen);
-            
-            if (olen == 0) {
-                unsigned int pos = 0;
-                switch_core_file_seek(tech_pvt->hfh, &pos, 0, SEEK_SET);				 
-                goto cng;
-            }
-            
-            
-            tech_pvt->hold_frame.datalen = (uint32_t)(olen * sizeof(int16_t));
-            tech_pvt->hold_frame.samples = (uint32_t)olen;
-			tech_pvt->hold_frame.timestamp = tech_pvt->timer.samplecount;
-            *frame = &tech_pvt->hold_frame;
-            
-        }
+			switch_core_file_read(tech_pvt->hfh, tech_pvt->hold_frame.data, &olen);
 
-		return SWITCH_STATUS_SUCCESS;        
-    }
+			if (olen == 0) {
+				unsigned int pos = 0;
+				switch_core_file_seek(tech_pvt->hfh, &pos, 0, SEEK_SET);
+				goto cng;
+			}
+
+
+			tech_pvt->hold_frame.datalen = (uint32_t) (olen * sizeof(int16_t));
+			tech_pvt->hold_frame.samples = (uint32_t) olen;
+			tech_pvt->hold_frame.timestamp = tech_pvt->timer.samplecount;
+			*frame = &tech_pvt->hold_frame;
+
+		}
+
+		return SWITCH_STATUS_SUCCESS;
+	}
 
 	switch_mutex_lock(globals.device_lock);
 
-    if ((samples = ReadAudioStream(globals.audio_stream, globals.read_frame.data, globals.read_codec.implementation->samples_per_frame)) != 0) {
+	if ((samples =
+		 ReadAudioStream(globals.audio_stream, globals.read_frame.data,
+						 globals.read_codec.implementation->samples_per_frame)) != 0) {
 		globals.read_frame.datalen = samples * 2;
 		globals.read_frame.samples = samples;
 
@@ -652,9 +657,9 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
 		globals.read_frame.timestamp = globals.timer.samplecount;
 		*frame = &globals.read_frame;
 
-        if (!switch_test_flag((&globals), GFLAG_MOUTH)) {
-            memset(globals.read_frame.data, 255, globals.read_frame.datalen);
-        }
+		if (!switch_test_flag((&globals), GFLAG_MOUTH)) {
+			memset(globals.read_frame.data, 255, globals.read_frame.datalen);
+		}
 
 		status = SWITCH_STATUS_SUCCESS;
 	}
@@ -664,7 +669,7 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
 }
 
 static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, int timeout,
-                                           switch_io_flag_t flags, int stream_id)
+										   switch_io_flag_t flags, int stream_id)
 {
 	switch_channel_t *channel = NULL;
 	private_t *tech_pvt = NULL;
@@ -676,21 +681,21 @@ static switch_status_t channel_write_frame(switch_core_session_t *session, switc
 	assert(tech_pvt != NULL);
 
 	if (!globals.audio_stream) {
-        return SWITCH_STATUS_FALSE;
-    }
+		return SWITCH_STATUS_FALSE;
+	}
 
-    if (switch_test_flag(tech_pvt, TFLAG_HUP)) {
-        return SWITCH_STATUS_FALSE;
-    }
+	if (switch_test_flag(tech_pvt, TFLAG_HUP)) {
+		return SWITCH_STATUS_FALSE;
+	}
 
-    if (!is_master(tech_pvt) || !switch_test_flag(tech_pvt, TFLAG_IO)) {
-		return SWITCH_STATUS_SUCCESS;        
-    }
+	if (!is_master(tech_pvt) || !switch_test_flag(tech_pvt, TFLAG_IO)) {
+		return SWITCH_STATUS_SUCCESS;
+	}
 
 	if (globals.audio_stream) {
-        if (switch_test_flag((&globals), GFLAG_EAR)) {
-            WriteAudioStream(globals.audio_stream, (short *) frame->data, (int) (frame->datalen / sizeof(SAMPLE)));
-        }
+		if (switch_test_flag((&globals), GFLAG_EAR)) {
+			WriteAudioStream(globals.audio_stream, (short *) frame->data, (int) (frame->datalen / sizeof(SAMPLE)));
+		}
 		status = SWITCH_STATUS_SUCCESS;
 	}
 
@@ -716,16 +721,16 @@ static switch_status_t channel_receive_message(switch_core_session_t *session, s
 {
 	switch_channel_t *channel;
 	private_t *tech_pvt;
-			
+
 	channel = switch_core_session_get_channel(session);
 	assert(channel != NULL);
-			
+
 	tech_pvt = switch_core_session_get_private(session);
 	assert(tech_pvt != NULL);
 
 
 	switch (msg->message_id) {
-	case SWITCH_MESSAGE_INDICATE_PROGRESS: 
+	case SWITCH_MESSAGE_INDICATE_PROGRESS:
 		{
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Engage Early Media\n");
 			switch_set_flag_locked(tech_pvt, TFLAG_IO);
@@ -737,43 +742,43 @@ static switch_status_t channel_receive_message(switch_core_session_t *session, s
 }
 
 static switch_api_interface_t send_dtmf_interface = {
-    /*.interface_name */ "padtmf",
-    /*.desc */ "DEPRICATED (see 'pa')",
-    /*.function */ padep,
-    /*.syntax */ "DEPRICATED (see 'pa')",
-    /*.next */ NULL
+	/*.interface_name */ "padtmf",
+	/*.desc */ "DEPRICATED (see 'pa')",
+	/*.function */ padep,
+	/*.syntax */ "DEPRICATED (see 'pa')",
+	/*.next */ NULL
 };
 
 static switch_api_interface_t answer_call_interface = {
-    /*.interface_name */ "paoffhook",
-    /*.desc */ "DEPRICATED (see 'pa')",
-    /*.function */ padep,
-    /*.syntax */ "DEPRICATED (see 'pa')",
-    /*.next */ &send_dtmf_interface
+	/*.interface_name */ "paoffhook",
+	/*.desc */ "DEPRICATED (see 'pa')",
+	/*.function */ padep,
+	/*.syntax */ "DEPRICATED (see 'pa')",
+	/*.next */ &send_dtmf_interface
 };
 
 static switch_api_interface_t channel_info_interface = {
-    /*.interface_name */ "painfo",
-    /*.desc */ "DEPRICATED (see 'pa')",
-    /*.function */ padep,
-    /*.syntax */ "DEPRICATED (see 'pa')",
-    /*.next */ &answer_call_interface
+	/*.interface_name */ "painfo",
+	/*.desc */ "DEPRICATED (see 'pa')",
+	/*.function */ padep,
+	/*.syntax */ "DEPRICATED (see 'pa')",
+	/*.next */ &answer_call_interface
 };
 
 static switch_api_interface_t channel_hup_interface = {
-    /*.interface_name */ "pahup",
-    /*.desc */ "DEPRICATED (see 'pa')",
-    /*.function */ padep,
-    /*.syntax */ "DEPRICATED (see 'pa')",
-    /*.next */ &channel_info_interface
+	/*.interface_name */ "pahup",
+	/*.desc */ "DEPRICATED (see 'pa')",
+	/*.function */ padep,
+	/*.syntax */ "DEPRICATED (see 'pa')",
+	/*.next */ &channel_info_interface
 };
 
 static switch_api_interface_t channel_call_interface = {
-    /*.interface_name */ "pacall",
-    /*.desc */ "DEPRICATED (see 'pa')",
-    /*.function */ padep,
-    /*.syntax */ "DEPRICATED (see 'pa')",
-    /*.next */ &channel_hup_interface
+	/*.interface_name */ "pacall",
+	/*.desc */ "DEPRICATED (see 'pa')",
+	/*.function */ padep,
+	/*.syntax */ "DEPRICATED (see 'pa')",
+	/*.next */ &channel_hup_interface
 };
 
 static switch_api_interface_t channel_api_interface = {
@@ -802,7 +807,7 @@ static const switch_io_routines_t channel_io_routines = {
 	/*.waitfor_read */ channel_waitfor_read,
 	/*.waitfor_write */ channel_waitfor_write,
 	/*.send_dtmf */ channel_send_dtmf,
-	/*.receive_message*/ channel_receive_message
+	/*.receive_message */ channel_receive_message
 };
 
 static const switch_endpoint_interface_t channel_endpoint_interface = {
@@ -826,7 +831,8 @@ static const switch_loadable_module_interface_t channel_module_interface = {
 /* Make sure when you have 2 sessions in the same scope that you pass the appropriate one to the routines
    that allocate memory or you will have 1 channel with memory allocated from another channel's pool!
 */
-static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *session, switch_caller_profile_t *outbound_profile,
+static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *session,
+													switch_caller_profile_t *outbound_profile,
 													switch_core_session_t **new_session, switch_memory_pool_t **pool)
 {
 
@@ -837,12 +843,12 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
 
 		switch_core_session_add_stream(*new_session, NULL);
 		if ((tech_pvt = (private_t *) switch_core_session_alloc(*new_session, sizeof(private_t))) != 0) {
-			memset(tech_pvt, 0, sizeof(*tech_pvt));            
+			memset(tech_pvt, 0, sizeof(*tech_pvt));
 			switch_mutex_init(&tech_pvt->flag_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(*new_session));
 			channel = switch_core_session_get_channel(*new_session);
 			switch_core_session_set_private(*new_session, tech_pvt);
 			tech_pvt->session = *new_session;
-            globals.flags = GFLAG_EAR | GFLAG_MOUTH;
+			globals.flags = GFLAG_EAR | GFLAG_MOUTH;
 		} else {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Hey where is my memory pool?\n");
 			switch_core_session_destroy(new_session);
@@ -851,9 +857,10 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
 
 		if (outbound_profile) {
 			char name[128];
-            char *id = !switch_strlen_zero(outbound_profile->caller_id_number) ? outbound_profile->caller_id_number : "na";
+			char *id =
+				!switch_strlen_zero(outbound_profile->caller_id_number) ? outbound_profile->caller_id_number : "na";
 			snprintf(name, sizeof(name), "PortAudio/%s", id);
-					 
+
 			switch_channel_set_name(channel, name);
 
 			caller_profile = switch_caller_profile_clone(*new_session, outbound_profile);
@@ -876,10 +883,11 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
 }
 
 
-SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
+													   char *filename)
 {
 
-    switch_status_t status;
+	switch_status_t status;
 
 	if (switch_core_new_memory_pool(&module_pool) != SWITCH_STATUS_SUCCESS) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "OH OH no pool\n");
@@ -889,17 +897,18 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_mod
 	Pa_Initialize();
 
 	if (dump_info()) {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't find any audio devices!\n");
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't find any audio devices!\n");
 		return SWITCH_STATUS_TERM;
-    }
+	}
 
 	if ((status = load_config()) != SWITCH_STATUS_SUCCESS) {
-        return status;
-    }
+		return status;
+	}
 
 
-    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Input Device: %d, Output Device: %d, Ring Device: %d Sample Rate: %d MS: %d\n", 
-                      globals.indev, globals.outdev, globals.ringdev, globals.sample_rate, globals.codec_ms);
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
+					  "Input Device: %d, Output Device: %d, Ring Device: %d Sample Rate: %d MS: %d\n", globals.indev,
+					  globals.outdev, globals.ringdev, globals.sample_rate, globals.codec_ms);
 
 
 	switch_core_hash_init(&globals.call_hash, module_pool);
@@ -919,7 +928,7 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_mod
 	globals.cng_frame.data = globals.cngbuf;
 	globals.cng_frame.buflen = sizeof(globals.cngbuf);
 	globals.cng_frame.datalen = sizeof(globals.cngbuf);
-    switch_set_flag((&globals.cng_frame), SFF_CNG);
+	switch_set_flag((&globals.cng_frame), SFF_CNG);
 
 	/* connect my internal structure to the blank pointer passed to me */
 	*module_interface = &channel_module_interface;
@@ -933,7 +942,7 @@ static switch_status_t load_config(void)
 {
 	char *cf = "portaudio.conf";
 	switch_xml_t cfg, xml, settings, param;
-    switch_status_t status = SWITCH_STATUS_SUCCESS;
+	switch_status_t status = SWITCH_STATUS_SUCCESS;
 
 	if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
@@ -941,7 +950,7 @@ static switch_status_t load_config(void)
 	}
 
 	memset(&globals, 0, sizeof(globals));
-    globals.indev = globals.outdev = globals.ringdev = -1;
+	globals.indev = globals.outdev = globals.ringdev = -1;
 
 	if ((settings = switch_xml_child(cfg, "settings"))) {
 		for (param = switch_xml_child(settings, "param"); param; param = param->next) {
@@ -951,7 +960,7 @@ static switch_status_t load_config(void)
 			if (!strcmp(var, "debug")) {
 				globals.debug = atoi(val);
 			} else if (!strcmp(var, "ring-interval")) {
-                globals.ring_interval = atoi(val);
+				globals.ring_interval = atoi(val);
 			} else if (!strcmp(var, "ring-file")) {
 				set_global_ring_file(val);
 			} else if (!strcmp(var, "hold-file")) {
@@ -986,7 +995,7 @@ static switch_status_t load_config(void)
 				} else {
 					globals.ringdev = get_dev_by_name(val, 0);
 				}
-            }
+			}
 		}
 	}
 
@@ -1005,37 +1014,38 @@ static switch_status_t load_config(void)
 	if (!globals.ring_interval) {
 		globals.ring_interval = 5;
 	}
-    
-    if (!globals.timer_name) {
-        set_global_timer_name("soft");
-    }
 
-    if (globals.indev < 0) {
-        globals.indev = get_dev_by_name(NULL, 1);
-        if (globals.indev > -1) {
-            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Switching to default input device!\n");
-        } else {
-            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot find an input device!\n");
-            status = SWITCH_STATUS_GENERR;            
-        }
-    }
+	if (!globals.timer_name) {
+		set_global_timer_name("soft");
+	}
 
-    if (globals.outdev < 0) {
-        globals.outdev = get_dev_by_name(NULL, 0);
-        if (globals.outdev > -1) {
-            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Switching to default output device!\n");
-        } else {
-            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot find an input device!\n");
-            status = SWITCH_STATUS_GENERR;            
-        }
-    }
+	if (globals.indev < 0) {
+		globals.indev = get_dev_by_name(NULL, 1);
+		if (globals.indev > -1) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Switching to default input device!\n");
+		} else {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot find an input device!\n");
+			status = SWITCH_STATUS_GENERR;
+		}
+	}
 
-    if (globals.ringdev < 0) {
-        if (globals.outdev > -1) {
-            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid ring device configured using output device!\n");
-            globals.ringdev = globals.outdev;
-        } 
-    }
+	if (globals.outdev < 0) {
+		globals.outdev = get_dev_by_name(NULL, 0);
+		if (globals.outdev > -1) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Switching to default output device!\n");
+		} else {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot find an input device!\n");
+			status = SWITCH_STATUS_GENERR;
+		}
+	}
+
+	if (globals.ringdev < 0) {
+		if (globals.outdev > -1) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+							  "Invalid ring device configured using output device!\n");
+			globals.ringdev = globals.outdev;
+		}
+	}
 
 	switch_xml_free(xml);
 
@@ -1060,18 +1070,18 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_shutdown(void)
 
 static int get_dev_by_number(int number, int in)
 {
-    int numDevices = Pa_GetDeviceCount();
+	int numDevices = Pa_GetDeviceCount();
 	const PaDeviceInfo *pdi;
 
-    if (number > -1 && number < numDevices && (pdi = Pa_GetDeviceInfo(number))) {
-        if (in && pdi->maxInputChannels) {
-            return number;
-        } else if (!in && pdi->maxOutputChannels) {
-            return number;
-        }
-    }
-    
-    return -1;
+	if (number > -1 && number < numDevices && (pdi = Pa_GetDeviceInfo(number))) {
+		if (in && pdi->maxInputChannels) {
+			return number;
+		} else if (!in && pdi->maxOutputChannels) {
+			return number;
+		}
+	}
+
+	return -1;
 }
 
 static int get_dev_by_name(char *name, int in)
@@ -1082,20 +1092,21 @@ static int get_dev_by_name(char *name, int in)
 	numDevices = Pa_GetDeviceCount();
 
 	if (numDevices < 0) {
-		switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR, "ERROR: Pa_CountDevices returned 0x%x\n", numDevices);
+		switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR, "ERROR: Pa_CountDevices returned 0x%x\n",
+						  numDevices);
 		return -2;
 	}
 
 	for (i = 0; i < numDevices; i++) {
-        int match = 0;
+		int match = 0;
 		pdi = Pa_GetDeviceInfo(i);
-        
+
 		if (switch_strlen_zero(name)) {
-            match = 1;
-        } else if (strstr(pdi->name, name)) {
-            match = 1;
-        }
-        
+			match = 1;
+		} else if (strstr(pdi->name, name)) {
+			match = 1;
+		}
+
 		if (match) {
 			if (in && pdi->maxInputChannels) {
 				return i;
@@ -1105,213 +1116,221 @@ static int get_dev_by_name(char *name, int in)
 		}
 	}
 
-    if (switch_strlen_zero(name)) {
-        return -1;
-    }
+	if (switch_strlen_zero(name)) {
+		return -1;
+	}
 
 	return get_dev_by_name(NULL, in);
 }
 
 
 /*******************************************************************/
-static void PrintSupportedStandardSampleRates(const PaStreamParameters *inputParameters,
-                                              const PaStreamParameters *outputParameters)
+static void PrintSupportedStandardSampleRates(const PaStreamParameters * inputParameters,
+											  const PaStreamParameters * outputParameters)
 {
-    int i, printCount, cr = 7;
-    PaError err;
-    static double standardSampleRates[] = { 8000.0, 9600.0, 11025.0, 12000.0, 16000.0, 22050.0, 24000.0, 32000.0,
-                                            44100.0, 48000.0, 88200.0, 96000.0, 192000.0, -1};
+	int i, printCount, cr = 7;
+	PaError err;
+	static double standardSampleRates[] = { 8000.0, 9600.0, 11025.0, 12000.0, 16000.0, 22050.0, 24000.0, 32000.0,
+		44100.0, 48000.0, 88200.0, 96000.0, 192000.0, -1
+	};
 
-    printCount = cr;
-    for(i=0; standardSampleRates[i] > 0; i++) {
-        err = Pa_IsFormatSupported(inputParameters, outputParameters, standardSampleRates[i]);
-        if (err == paFormatIsSupported) {
-            if (printCount == cr) {
-                printCount = 0;
-                switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO,  "\n\t%0.2f", standardSampleRates[i]);
-            } else {
-                switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO,  ", %0.2f", standardSampleRates[i]);
-            }
-            printCount++;
-        }
-    }
-    if (!printCount) {
-        switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO,  " None\n");
-    } else {
-        switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO,  "\n");
-    }
+	printCount = cr;
+	for (i = 0; standardSampleRates[i] > 0; i++) {
+		err = Pa_IsFormatSupported(inputParameters, outputParameters, standardSampleRates[i]);
+		if (err == paFormatIsSupported) {
+			if (printCount == cr) {
+				printCount = 0;
+				switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, "\n\t%0.2f", standardSampleRates[i]);
+			} else {
+				switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, ", %0.2f", standardSampleRates[i]);
+			}
+			printCount++;
+		}
+	}
+	if (!printCount) {
+		switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, " None\n");
+	} else {
+		switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, "\n");
+	}
 }
+
 /*******************************************************************/
 
 static switch_status_t devlist(char **argv, int argc, switch_stream_handle_t *stream)
 {
-	int     i, numDevices;
-    const   PaDeviceInfo *deviceInfo;
-            
-    numDevices = Pa_GetDeviceCount();
-    if (numDevices < 0) {
+	int i, numDevices;
+	const PaDeviceInfo *deviceInfo;
+
+	numDevices = Pa_GetDeviceCount();
+	if (numDevices < 0) {
 		return SWITCH_STATUS_SUCCESS;
-    }
-	for(i=0; iwrite_function(stream, "%d;%s;%d;%d\n", i, deviceInfo->name, deviceInfo->maxInputChannels, deviceInfo->maxOutputChannels);
+	}
+	for (i = 0; i < numDevices; i++) {
+		deviceInfo = Pa_GetDeviceInfo(i);
+		stream->write_function(stream, "%d;%s;%d;%d\n", i, deviceInfo->name, deviceInfo->maxInputChannels,
+							   deviceInfo->maxOutputChannels);
 	}
 
-    return SWITCH_STATUS_SUCCESS;
+	return SWITCH_STATUS_SUCCESS;
 }
 
 static int dump_info(void)
 {
-    int     i, numDevices, defaultDisplayed;
-    const   PaDeviceInfo *deviceInfo;
-    PaStreamParameters inputParameters, outputParameters;
-    PaError err;
-    const char *line = "--------------------------------------------------------------------------------\n";
-    
+	int i, numDevices, defaultDisplayed;
+	const PaDeviceInfo *deviceInfo;
+	PaStreamParameters inputParameters, outputParameters;
+	PaError err;
+	const char *line = "--------------------------------------------------------------------------------\n";
 
 
-    switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO,  "PortAudio version number = %d\nPortAudio version text = '%s'\n",
-                      Pa_GetVersion(), Pa_GetVersionText());
+
+	switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO,
+					  "PortAudio version number = %d\nPortAudio version text = '%s'\n", Pa_GetVersion(),
+					  Pa_GetVersionText());
 	if (globals.audio_stream) {
-		switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO,  "ERROR: Cannot use this command this while a call is in progress\n");
+		switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO,
+						  "ERROR: Cannot use this command this while a call is in progress\n");
 		return 0;
 	}
-            
-    numDevices = Pa_GetDeviceCount();
-    if (numDevices < 0) {
-        switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO,  "ERROR: Pa_CountDevices returned 0x%x\n", numDevices);
-        err = numDevices;
-        goto error;
-    }
-    
-    switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO,  "Number of devices = %d\n", numDevices);
-    for(i=0; ihostApi)->defaultInputDevice) {
-            
-            const PaHostApiInfo *hostInfo = Pa_GetHostApiInfo(deviceInfo->hostApi);
-            switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO,  "**Default %s Input", hostInfo->name);
-            defaultDisplayed = 1;
-        }
-        
-        if (i == Pa_GetDefaultOutputDevice()) {
-            switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO,  "**Default Output");
-            defaultDisplayed = 1;
 
-        } else if (i == Pa_GetHostApiInfo(deviceInfo->hostApi)->defaultOutputDevice) {
+	numDevices = Pa_GetDeviceCount();
+	if (numDevices < 0) {
+		switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, "ERROR: Pa_CountDevices returned 0x%x\n",
+						  numDevices);
+		err = numDevices;
+		goto error;
+	}
 
-            const PaHostApiInfo *hostInfo = Pa_GetHostApiInfo(deviceInfo->hostApi);
-            switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO,  "**Default %s Output", hostInfo->name);
-            defaultDisplayed = 1;
-        }
+	switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, "Number of devices = %d\n", numDevices);
+	for (i = 0; i < numDevices; i++) {
+		switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, "%s", line);
+		deviceInfo = Pa_GetDeviceInfo(i);
+		switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, "Device #%d ", i);
 
-        if (defaultDisplayed) {
-            switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO,  "** | ");
-        }
-        /* print device info fields */
-        switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO,  "Name: %s\n", deviceInfo->name);
-        switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO,  "Host: %s | ",  Pa_GetHostApiInfo(deviceInfo->hostApi)->name);
-        switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO,  "inputs: %d | ", deviceInfo->maxInputChannels );
-        switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO,  "outputs: %d | ", deviceInfo->maxOutputChannels );
+		/* Mark global and API specific default devices */
+		defaultDisplayed = 0;
+		if (i == Pa_GetDefaultInputDevice()) {
+			switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, "**Default Input");
+			defaultDisplayed = 1;
 
-        switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO,  "Default rate: %8.2f\n", deviceInfo->defaultSampleRate);
+		} else if (i == Pa_GetHostApiInfo(deviceInfo->hostApi)->defaultInputDevice) {
 
-        /* poll for standard sample rates */
-        inputParameters.device = i;
-        inputParameters.channelCount = deviceInfo->maxInputChannels;
-        inputParameters.sampleFormat = paInt16;
-        inputParameters.suggestedLatency = 0; /* ignored by Pa_IsFormatSupported() */
-        inputParameters.hostApiSpecificStreamInfo = NULL;
-        
-        outputParameters.device = i;
-        outputParameters.channelCount = deviceInfo->maxOutputChannels;
-        outputParameters.sampleFormat = paInt16;
-        outputParameters.suggestedLatency = 0; /* ignored by Pa_IsFormatSupported() */
-        outputParameters.hostApiSpecificStreamInfo = NULL;
+			const PaHostApiInfo *hostInfo = Pa_GetHostApiInfo(deviceInfo->hostApi);
+			switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, "**Default %s Input", hostInfo->name);
+			defaultDisplayed = 1;
+		}
 
-        if (inputParameters.channelCount > 0) {
+		if (i == Pa_GetDefaultOutputDevice()) {
+			switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, "**Default Output");
+			defaultDisplayed = 1;
 
-            switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, "half-duplex 16 bit %d channel input rates:",
-                              inputParameters.channelCount);
-            PrintSupportedStandardSampleRates(&inputParameters, NULL);
-        }
+		} else if (i == Pa_GetHostApiInfo(deviceInfo->hostApi)->defaultOutputDevice) {
 
-        if (outputParameters.channelCount > 0) {
-            switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, "half-duplex 16 bit %d channel output rates:",
-                              outputParameters.channelCount);
-            PrintSupportedStandardSampleRates(NULL, &outputParameters);
-        }
+			const PaHostApiInfo *hostInfo = Pa_GetHostApiInfo(deviceInfo->hostApi);
+			switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, "**Default %s Output", hostInfo->name);
+			defaultDisplayed = 1;
+		}
 
-        if (inputParameters.channelCount > 0 && outputParameters.channelCount > 0) {
+		if (defaultDisplayed) {
+			switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, "** | ");
+		}
+		/* print device info fields */
+		switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, "Name: %s\n", deviceInfo->name);
+		switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, "Host: %s | ",
+						  Pa_GetHostApiInfo(deviceInfo->hostApi)->name);
+		switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, "inputs: %d | ", deviceInfo->maxInputChannels);
+		switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, "outputs: %d | ", deviceInfo->maxOutputChannels);
 
-            switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, "full-duplex 16 bit %d channel input, %d channel output rates:",
-                              inputParameters.channelCount, outputParameters.channelCount);
-            PrintSupportedStandardSampleRates(&inputParameters, &outputParameters);
-        }
-    }
+		switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, "Default rate: %8.2f\n",
+						  deviceInfo->defaultSampleRate);
 
-    switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, "%s", line);
-    
-    return 0;
+		/* poll for standard sample rates */
+		inputParameters.device = i;
+		inputParameters.channelCount = deviceInfo->maxInputChannels;
+		inputParameters.sampleFormat = paInt16;
+		inputParameters.suggestedLatency = 0;	/* ignored by Pa_IsFormatSupported() */
+		inputParameters.hostApiSpecificStreamInfo = NULL;
 
- error:
-    switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR,  "An error occured while using the portaudio stream\n");
-    switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR,  "Error number: %d\n", err);
-    switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR,  "Error message: %s\n", Pa_GetErrorText(err));
-    return err;
+		outputParameters.device = i;
+		outputParameters.channelCount = deviceInfo->maxOutputChannels;
+		outputParameters.sampleFormat = paInt16;
+		outputParameters.suggestedLatency = 0;	/* ignored by Pa_IsFormatSupported() */
+		outputParameters.hostApiSpecificStreamInfo = NULL;
+
+		if (inputParameters.channelCount > 0) {
+
+			switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, "half-duplex 16 bit %d channel input rates:",
+							  inputParameters.channelCount);
+			PrintSupportedStandardSampleRates(&inputParameters, NULL);
+		}
+
+		if (outputParameters.channelCount > 0) {
+			switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, "half-duplex 16 bit %d channel output rates:",
+							  outputParameters.channelCount);
+			PrintSupportedStandardSampleRates(NULL, &outputParameters);
+		}
+
+		if (inputParameters.channelCount > 0 && outputParameters.channelCount > 0) {
+
+			switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO,
+							  "full-duplex 16 bit %d channel input, %d channel output rates:",
+							  inputParameters.channelCount, outputParameters.channelCount);
+			PrintSupportedStandardSampleRates(&inputParameters, &outputParameters);
+		}
+	}
+
+	switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, "%s", line);
+
+	return 0;
+
+  error:
+	switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR,
+					  "An error occured while using the portaudio stream\n");
+	switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR, "Error number: %d\n", err);
+	switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR, "Error message: %s\n", Pa_GetErrorText(err));
+	return err;
 }
 
 
 
 static switch_status_t engage_device(int sample_rate, int codec_ms)
 {
-    PaStreamParameters inputParameters, outputParameters;
+	PaStreamParameters inputParameters, outputParameters;
 	PaError err;
 
-    if (!globals.audio_stream) {
-        if (!sample_rate) {
-            sample_rate = globals.sample_rate;
-        }
-        if (!codec_ms) {
-            codec_ms = globals.codec_ms;
-        }
+	if (!globals.audio_stream) {
+		if (!sample_rate) {
+			sample_rate = globals.sample_rate;
+		}
+		if (!codec_ms) {
+			codec_ms = globals.codec_ms;
+		}
+
+		if (switch_core_codec_init(&globals.read_codec,
+								   "L16",
+								   NULL,
+								   sample_rate,
+								   codec_ms,
+								   1,
+								   SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
+								   NULL, NULL) != SWITCH_STATUS_SUCCESS) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n");
+			return SWITCH_STATUS_FALSE;
+		} else {
+			if (switch_core_codec_init(&globals.write_codec,
+									   "L16",
+									   NULL,
+									   sample_rate,
+									   codec_ms,
+									   1,
+									   SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
+									   NULL, NULL) != SWITCH_STATUS_SUCCESS) {
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n");
+				switch_core_codec_destroy(&globals.read_codec);
+				return SWITCH_STATUS_FALSE;
+			}
+		}
 
-        if (switch_core_codec_init(&globals.read_codec,
-                                   "L16",
-                                   NULL,
-                                   sample_rate,
-                                   codec_ms,
-                                   1,
-                                   SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
-                                   NULL, 
-                                   NULL) != SWITCH_STATUS_SUCCESS) {
-            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n");
-            return SWITCH_STATUS_FALSE;
-        } else {
-            if (switch_core_codec_init(&globals.write_codec,
-                                       "L16",
-                                       NULL,
-                                       sample_rate,
-                                       codec_ms,
-                                       1,
-                                       SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
-                                       NULL,
-                                       NULL) != SWITCH_STATUS_SUCCESS) {
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n");
-                switch_core_codec_destroy(&globals.read_codec);
-                return SWITCH_STATUS_FALSE;
-            }
-        }
-		
 		if (switch_core_timer_init(&globals.timer,
 								   globals.timer_name,
 								   codec_ms,
@@ -1322,46 +1341,46 @@ static switch_status_t engage_device(int sample_rate, int codec_ms)
 			switch_core_codec_destroy(&globals.write_codec);
 			return SWITCH_STATUS_FALSE;
 		}
-                
 
 
 
 
-        globals.read_frame.rate = sample_rate;
-        globals.read_frame.codec = &globals.read_codec;
+
+		globals.read_frame.rate = sample_rate;
+		globals.read_frame.codec = &globals.read_codec;
 
 
 
-        switch_mutex_lock(globals.device_lock);
-        /* LOCKED ***************************************************************************************************/
-        inputParameters.device = globals.indev;
-        inputParameters.channelCount = 1;
-        inputParameters.sampleFormat = SAMPLE_TYPE;
-        inputParameters.suggestedLatency = Pa_GetDeviceInfo(inputParameters.device)->defaultLowInputLatency;
-        inputParameters.hostApiSpecificStreamInfo = NULL;
+		switch_mutex_lock(globals.device_lock);
+		/* LOCKED ************************************************************************************************** */
+		inputParameters.device = globals.indev;
+		inputParameters.channelCount = 1;
+		inputParameters.sampleFormat = SAMPLE_TYPE;
+		inputParameters.suggestedLatency = Pa_GetDeviceInfo(inputParameters.device)->defaultLowInputLatency;
+		inputParameters.hostApiSpecificStreamInfo = NULL;
 
-        outputParameters.device = globals.outdev;
-        outputParameters.channelCount = 1;
-        outputParameters.sampleFormat =  SAMPLE_TYPE;
-        outputParameters.suggestedLatency = Pa_GetDeviceInfo(outputParameters.device)->defaultLowOutputLatency;
-        outputParameters.hostApiSpecificStreamInfo = NULL;
-        err = OpenAudioStream(&globals.audio_stream, &inputParameters, &outputParameters, sample_rate, paClipOff);
-        /* UNLOCKED **************************************************************************************************/
-        switch_mutex_unlock(globals.device_lock);
+		outputParameters.device = globals.outdev;
+		outputParameters.channelCount = 1;
+		outputParameters.sampleFormat = SAMPLE_TYPE;
+		outputParameters.suggestedLatency = Pa_GetDeviceInfo(outputParameters.device)->defaultLowOutputLatency;
+		outputParameters.hostApiSpecificStreamInfo = NULL;
+		err = OpenAudioStream(&globals.audio_stream, &inputParameters, &outputParameters, sample_rate, paClipOff);
+		/* UNLOCKED ************************************************************************************************* */
+		switch_mutex_unlock(globals.device_lock);
 
 
-        if (err != paNoError) {
-            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't open audio device!\n");
-            switch_core_codec_destroy(&globals.read_codec);
-            switch_core_codec_destroy(&globals.write_codec);
+		if (err != paNoError) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't open audio device!\n");
+			switch_core_codec_destroy(&globals.read_codec);
+			switch_core_codec_destroy(&globals.write_codec);
 
-            return SWITCH_STATUS_FALSE;
-        }
-    }
+			return SWITCH_STATUS_FALSE;
+		}
+	}
 
 
 
-    return SWITCH_STATUS_SUCCESS;
+	return SWITCH_STATUS_SUCCESS;
 
 
 }
@@ -1370,34 +1389,35 @@ static switch_status_t engage_device(int sample_rate, int codec_ms)
 static switch_status_t engage_ring_device(int sample_rate, int channels)
 {
 	//int codec_ms = 20;
-    PaStreamParameters outputParameters;
+	PaStreamParameters outputParameters;
 	PaError err;
 
-    if (!globals.ring_stream) {
-        if (!sample_rate) {
-            sample_rate = globals.sample_rate;
-        }
+	if (!globals.ring_stream) {
+		if (!sample_rate) {
+			sample_rate = globals.sample_rate;
+		}
 
-        switch_mutex_lock(globals.device_lock);
-        /* LOCKED ***************************************************************************************************/
-        outputParameters.device = globals.ringdev;
-        outputParameters.channelCount = channels;
-        outputParameters.sampleFormat =  SAMPLE_TYPE;
-        outputParameters.suggestedLatency = Pa_GetDeviceInfo(outputParameters.device)->defaultLowOutputLatency;
-        outputParameters.hostApiSpecificStreamInfo = NULL;
-        err = OpenAudioStream(&globals.ring_stream, NULL, &outputParameters, sample_rate, paClipOff);
-        /* UNLOCKED **************************************************************************************************/
-        switch_mutex_unlock(globals.device_lock);
+		switch_mutex_lock(globals.device_lock);
+		/* LOCKED ************************************************************************************************** */
+		outputParameters.device = globals.ringdev;
+		outputParameters.channelCount = channels;
+		outputParameters.sampleFormat = SAMPLE_TYPE;
+		outputParameters.suggestedLatency = Pa_GetDeviceInfo(outputParameters.device)->defaultLowOutputLatency;
+		outputParameters.hostApiSpecificStreamInfo = NULL;
+		err = OpenAudioStream(&globals.ring_stream, NULL, &outputParameters, sample_rate, paClipOff);
+		/* UNLOCKED ************************************************************************************************* */
+		switch_mutex_unlock(globals.device_lock);
 
 
-        if (err != paNoError) {
-            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't open ring device!\n");
-            return SWITCH_STATUS_FALSE;
-        }
-    }
+		if (err != paNoError) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't open ring device!\n");
+			return SWITCH_STATUS_FALSE;
+		}
+	}
 
-    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Engage ring device! rate: %d channels %d\n", sample_rate, channels);
-    return SWITCH_STATUS_SUCCESS;
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Engage ring device! rate: %d channels %d\n", sample_rate,
+					  channels);
+	return SWITCH_STATUS_SUCCESS;
 }
 
 
@@ -1405,64 +1425,64 @@ static switch_status_t engage_ring_device(int sample_rate, int channels)
 
 static switch_status_t dtmf_call(char **argv, int argc, switch_stream_handle_t *stream)
 {
-    char *dtmf = argv[0];
+	char *dtmf = argv[0];
 
-    if (switch_strlen_zero(dtmf)) {
-        stream->write_function(stream, "No DTMF Supplied!\n");
-    } else {
-        switch_mutex_lock(globals.pvt_lock);
-        if (globals.call_list) {
-            switch_channel_t *channel = switch_core_session_get_channel(globals.call_list->session);
-            switch_channel_queue_dtmf(channel, dtmf);
-        }
-        switch_mutex_unlock(globals.pvt_lock);
-    }
+	if (switch_strlen_zero(dtmf)) {
+		stream->write_function(stream, "No DTMF Supplied!\n");
+	} else {
+		switch_mutex_lock(globals.pvt_lock);
+		if (globals.call_list) {
+			switch_channel_t *channel = switch_core_session_get_channel(globals.call_list->session);
+			switch_channel_queue_dtmf(channel, dtmf);
+		}
+		switch_mutex_unlock(globals.pvt_lock);
+	}
 
-    return SWITCH_STATUS_SUCCESS;
+	return SWITCH_STATUS_SUCCESS;
 }
 
 static switch_status_t switch_call(char **argv, int argc, switch_stream_handle_t *stream)
 {
-    private_t *tp,*tech_pvt = NULL;
-    char *callid = argv[0];
-    uint8_t one_call = 0;
+	private_t *tp, *tech_pvt = NULL;
+	char *callid = argv[0];
+	uint8_t one_call = 0;
 
-    switch_mutex_lock(globals.pvt_lock);
-    if (switch_strlen_zero(callid)) {
-        if (globals.call_list) {
-            if (globals.call_list->next) {
-                tech_pvt = globals.call_list->next;
-            } else {
-                tech_pvt = globals.call_list;
-                one_call = 1;
-            }
-        }
-    } else if (!strcasecmp(callid, "none")) {
-        for (tp = globals.call_list; tp; tp = tp->next) {
-            switch_clear_flag_locked(tp, TFLAG_MASTER);
-        }
-        stream->write_function(stream, "OK\n");
-        goto done;
-    } else {
-        tech_pvt = switch_core_hash_find(globals.call_hash, callid);
-    }
+	switch_mutex_lock(globals.pvt_lock);
+	if (switch_strlen_zero(callid)) {
+		if (globals.call_list) {
+			if (globals.call_list->next) {
+				tech_pvt = globals.call_list->next;
+			} else {
+				tech_pvt = globals.call_list;
+				one_call = 1;
+			}
+		}
+	} else if (!strcasecmp(callid, "none")) {
+		for (tp = globals.call_list; tp; tp = tp->next) {
+			switch_clear_flag_locked(tp, TFLAG_MASTER);
+		}
+		stream->write_function(stream, "OK\n");
+		goto done;
+	} else {
+		tech_pvt = switch_core_hash_find(globals.call_hash, callid);
+	}
 
 	if (tech_pvt) {
-        if (tech_pvt == globals.call_list && !tech_pvt->next) {
-            one_call = 1;
-        }
+		if (tech_pvt == globals.call_list && !tech_pvt->next) {
+			one_call = 1;
+		}
 
-        if (!one_call) {
-            remove_pvt(tech_pvt);
-        }
-        add_pvt(tech_pvt, PA_MASTER);
-        stream->write_function(stream, "OK\n");
+		if (!one_call) {
+			remove_pvt(tech_pvt);
+		}
+		add_pvt(tech_pvt, PA_MASTER);
+		stream->write_function(stream, "OK\n");
 	} else {
 		stream->write_function(stream, "NO SUCH CALL\n");
 	}
 
- done:
-    switch_mutex_unlock(globals.pvt_lock);
+  done:
+	switch_mutex_unlock(globals.pvt_lock);
 
 	return SWITCH_STATUS_SUCCESS;
 
@@ -1470,24 +1490,24 @@ static switch_status_t switch_call(char **argv, int argc, switch_stream_handle_t
 
 static switch_status_t hangup_call(char **argv, int argc, switch_stream_handle_t *stream)
 {
-    private_t *tech_pvt;
-    char *callid = argv[0];
-    
-    switch_mutex_lock(globals.pvt_lock);
-    if (switch_strlen_zero(callid)) {
-        tech_pvt = globals.call_list;
-    } else {
-        tech_pvt = switch_core_hash_find(globals.call_hash, callid);
-    }
+	private_t *tech_pvt;
+	char *callid = argv[0];
+
+	switch_mutex_lock(globals.pvt_lock);
+	if (switch_strlen_zero(callid)) {
+		tech_pvt = globals.call_list;
+	} else {
+		tech_pvt = switch_core_hash_find(globals.call_hash, callid);
+	}
 
 	if (tech_pvt) {
 		switch_channel_hangup(switch_core_session_get_channel(tech_pvt->session), SWITCH_CAUSE_NORMAL_CLEARING);
-        //switch_set_flag_locked(tech_pvt, TFLAG_HUP);
+		//switch_set_flag_locked(tech_pvt, TFLAG_HUP);
 		stream->write_function(stream, "OK\n");
 	} else {
 		stream->write_function(stream, "NO SUCH CALL\n");
 	}
-    switch_mutex_unlock(globals.pvt_lock);
+	switch_mutex_unlock(globals.pvt_lock);
 
 	return SWITCH_STATUS_SUCCESS;
 
@@ -1495,43 +1515,43 @@ static switch_status_t hangup_call(char **argv, int argc, switch_stream_handle_t
 
 static switch_status_t answer_call(char **argv, int argc, switch_stream_handle_t *stream)
 {
-    private_t *tp;
-    int x = 0;
-    char *callid = argv[0];
-    
-    switch_mutex_lock(globals.pvt_lock);
+	private_t *tp;
+	int x = 0;
+	char *callid = argv[0];
 
-    if (!switch_strlen_zero(callid)) {
-        if ((tp = switch_core_hash_find(globals.call_hash, callid))) {
-            if (switch_test_flag(tp, TFLAG_ANSWER)) {
-                stream->write_function(stream, "CALL ALREADY ANSWERED\n");
-            } else {
-                switch_channel_t *channel = switch_core_session_get_channel(tp->session);
-                switch_set_flag_locked(tp, TFLAG_ANSWER);
-                switch_channel_answer(channel);
-                add_pvt(tp, PA_MASTER);
-            }
-        } else {
-            stream->write_function(stream, "NO SUCH CALL\n");
-        }
+	switch_mutex_lock(globals.pvt_lock);
 
-        goto done;
-    }
+	if (!switch_strlen_zero(callid)) {
+		if ((tp = switch_core_hash_find(globals.call_hash, callid))) {
+			if (switch_test_flag(tp, TFLAG_ANSWER)) {
+				stream->write_function(stream, "CALL ALREADY ANSWERED\n");
+			} else {
+				switch_channel_t *channel = switch_core_session_get_channel(tp->session);
+				switch_set_flag_locked(tp, TFLAG_ANSWER);
+				switch_channel_answer(channel);
+				add_pvt(tp, PA_MASTER);
+			}
+		} else {
+			stream->write_function(stream, "NO SUCH CALL\n");
+		}
 
-    for (tp = globals.call_list; tp; tp = tp->next) {
-        if (!switch_test_flag(tp, TFLAG_ANSWER)) {
-            switch_channel_t *channel = switch_core_session_get_channel(tp->session);
-            switch_set_flag_locked(tp, TFLAG_ANSWER);
-            switch_channel_answer(channel);
-            add_pvt(tp, PA_MASTER);
-            x++;
-            break;
-        }
-	} 
- done:
-    switch_mutex_unlock(globals.pvt_lock);
+		goto done;
+	}
 
-    stream->write_function(stream, "Answered %d channels.\n", x);    
+	for (tp = globals.call_list; tp; tp = tp->next) {
+		if (!switch_test_flag(tp, TFLAG_ANSWER)) {
+			switch_channel_t *channel = switch_core_session_get_channel(tp->session);
+			switch_set_flag_locked(tp, TFLAG_ANSWER);
+			switch_channel_answer(channel);
+			add_pvt(tp, PA_MASTER);
+			x++;
+			break;
+		}
+	}
+  done:
+	switch_mutex_unlock(globals.pvt_lock);
+
+	stream->write_function(stream, "Answered %d channels.\n", x);
 
 
 	return SWITCH_STATUS_SUCCESS;
@@ -1540,113 +1560,110 @@ static switch_status_t answer_call(char **argv, int argc, switch_stream_handle_t
 
 static switch_status_t do_flags(char **argv, int argc, switch_stream_handle_t *stream)
 {
-    char *action = argv[0];
-    char *flag_str = argv[1];
-    GFLAGS flags = GFLAG_NONE;
-    char *p;
-    int x = 0;
+	char *action = argv[0];
+	char *flag_str = argv[1];
+	GFLAGS flags = GFLAG_NONE;
+	char *p;
+	int x = 0;
 
-    if (argc < 2) {
-        goto desc;
-    }
+	if (argc < 2) {
+		goto desc;
+	}
 
-    for (x = 1; x < argc; x++) {
-        flag_str = argv[x];
-        for(p = flag_str; *p; p++) {
-            *p = (char)tolower(*p);
-        }
-    
-        if (strstr(flag_str, "ear")) {
-            flags |= GFLAG_EAR;
-        } 
-        if (strstr(flag_str, "mouth")) {
-            flags |= GFLAG_MOUTH;
-        }
-    }
+	for (x = 1; x < argc; x++) {
+		flag_str = argv[x];
+		for (p = flag_str; *p; p++) {
+			*p = (char) tolower(*p);
+		}
 
-    if (!strcasecmp(action, "on")) {
-        if (flags & GFLAG_EAR) {
-            switch_set_flag((&globals), GFLAG_EAR);
-        }
-        if (flags & GFLAG_MOUTH) {
-            switch_set_flag((&globals), GFLAG_MOUTH);
-        }
-    } else if (!strcasecmp(action, "off")) {
-        if (flags & GFLAG_EAR) {
-            switch_clear_flag((&globals), GFLAG_EAR);
-        }
-        if (flags & GFLAG_MOUTH) {
-            switch_clear_flag((&globals), GFLAG_MOUTH);
-        }
-    } else {
-        goto bad;
-    }
+		if (strstr(flag_str, "ear")) {
+			flags |= GFLAG_EAR;
+		}
+		if (strstr(flag_str, "mouth")) {
+			flags |= GFLAG_MOUTH;
+		}
+	}
 
- desc:
-    x = 0;
-    stream->write_function(stream, "FLAGS: ");
-    if (switch_test_flag((&globals), GFLAG_EAR)) {
-        stream->write_function(stream, "ear");
-        x++;
-    }
-    if (switch_test_flag((&globals), GFLAG_MOUTH)) {
-        stream->write_function(stream, "%smouth", x ? "|" : "");
-        x++;
-    }
-    if (!x) {
-        stream->write_function(stream, "none");
-    }
+	if (!strcasecmp(action, "on")) {
+		if (flags & GFLAG_EAR) {
+			switch_set_flag((&globals), GFLAG_EAR);
+		}
+		if (flags & GFLAG_MOUTH) {
+			switch_set_flag((&globals), GFLAG_MOUTH);
+		}
+	} else if (!strcasecmp(action, "off")) {
+		if (flags & GFLAG_EAR) {
+			switch_clear_flag((&globals), GFLAG_EAR);
+		}
+		if (flags & GFLAG_MOUTH) {
+			switch_clear_flag((&globals), GFLAG_MOUTH);
+		}
+	} else {
+		goto bad;
+	}
 
-    goto done;
+  desc:
+	x = 0;
+	stream->write_function(stream, "FLAGS: ");
+	if (switch_test_flag((&globals), GFLAG_EAR)) {
+		stream->write_function(stream, "ear");
+		x++;
+	}
+	if (switch_test_flag((&globals), GFLAG_MOUTH)) {
+		stream->write_function(stream, "%smouth", x ? "|" : "");
+		x++;
+	}
+	if (!x) {
+		stream->write_function(stream, "none");
+	}
 
- bad:
-    stream->write_function(stream, "Usage: flags [on|off] \n");    
- done:
-    return SWITCH_STATUS_SUCCESS;
+	goto done;
+
+  bad:
+	stream->write_function(stream, "Usage: flags [on|off] \n");
+  done:
+	return SWITCH_STATUS_SUCCESS;
 }
 
 static switch_status_t list_calls(char **argv, int argc, switch_stream_handle_t *stream)
 {
-    private_t *tp;
-    int x = 0;
-    char *cid_name = "n/a";
-    char *cid_num = "n/a";
-    
-    switch_mutex_lock(globals.pvt_lock);
-    for (tp = globals.call_list; tp; tp = tp->next) {
+	private_t *tp;
+	int x = 0;
+	char *cid_name = "n/a";
+	char *cid_num = "n/a";
+
+	switch_mutex_lock(globals.pvt_lock);
+	for (tp = globals.call_list; tp; tp = tp->next) {
 		switch_channel_t *channel;
-        switch_caller_profile_t *profile;
-        x++;
-        channel = switch_core_session_get_channel(tp->session);        
-        
-        if ((profile = switch_channel_get_caller_profile(channel))) {
-            if (profile->originatee_caller_profile) {
-                cid_name = "Outbound Call";
-                cid_num = profile->originatee_caller_profile->destination_number;
-            } else {
-                cid_name = profile->caller_id_name;
-                cid_num = profile->caller_id_number;
-            }
-        }
+		switch_caller_profile_t *profile;
+		x++;
+		channel = switch_core_session_get_channel(tp->session);
 
-        stream->write_function(stream, "%s %s [%s (%s)] %s\n", tp->call_id, switch_channel_get_name(channel),
-                               cid_name,
-                               cid_num,
-                               switch_test_flag(tp, TFLAG_MASTER) ? "active" : "hold"
-                               );
-    }
-    switch_mutex_unlock(globals.pvt_lock);
+		if ((profile = switch_channel_get_caller_profile(channel))) {
+			if (profile->originatee_caller_profile) {
+				cid_name = "Outbound Call";
+				cid_num = profile->originatee_caller_profile->destination_number;
+			} else {
+				cid_name = profile->caller_id_name;
+				cid_num = profile->caller_id_number;
+			}
+		}
 
-    stream->write_function(stream, "\n%d call%s\n", x, x == 1 ? "" : "s");
+		stream->write_function(stream, "%s %s [%s (%s)] %s\n", tp->call_id, switch_channel_get_name(channel),
+							   cid_name, cid_num, switch_test_flag(tp, TFLAG_MASTER) ? "active" : "hold");
+	}
+	switch_mutex_unlock(globals.pvt_lock);
 
-    return SWITCH_STATUS_SUCCESS;
+	stream->write_function(stream, "\n%d call%s\n", x, x == 1 ? "" : "s");
+
+	return SWITCH_STATUS_SUCCESS;
 }
 
 static switch_status_t place_call(char **argv, int argc, switch_stream_handle_t *stream)
 {
 	switch_core_session_t *session;
 	switch_status_t status = SWITCH_STATUS_SUCCESS;
-    char *dest = NULL;
+	char *dest = NULL;
 
 	if (!argv[0]) {
 		stream->write_function(stream, "FAIL:Usage: call \n");
@@ -1657,9 +1674,9 @@ static switch_status_t place_call(char **argv, int argc, switch_stream_handle_t
 	if ((session = switch_core_session_request(&channel_endpoint_interface, NULL)) != 0) {
 		private_t *tech_pvt;
 		switch_channel_t *channel;
-        char *dialplan = globals.dialplan;
-        char *cid_name = globals.cid_name;
-        char *cid_num = globals.cid_num;        
+		char *dialplan = globals.dialplan;
+		char *cid_name = globals.cid_name;
+		char *cid_num = globals.cid_num;
 
 		switch_core_session_add_stream(session, NULL);
 		if ((tech_pvt = (private_t *) switch_core_session_alloc(session, sizeof(private_t))) != 0) {
@@ -1668,7 +1685,7 @@ static switch_status_t place_call(char **argv, int argc, switch_stream_handle_t
 			channel = switch_core_session_get_channel(session);
 			switch_core_session_set_private(session, tech_pvt);
 			tech_pvt->session = session;
-            globals.flags = GFLAG_EAR | GFLAG_MOUTH;
+			globals.flags = GFLAG_EAR | GFLAG_MOUTH;
 		} else {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Hey where is my memory pool?\n");
 			switch_core_session_destroy(&session);
@@ -1676,48 +1693,51 @@ static switch_status_t place_call(char **argv, int argc, switch_stream_handle_t
 		}
 
 		if (!switch_strlen_zero(argv[1])) {
-            dialplan = argv[1];
-        }
+			dialplan = argv[1];
+		}
 
-        if (!switch_strlen_zero(argv[2])) {
-            cid_num = argv[2];
-        }
+		if (!switch_strlen_zero(argv[2])) {
+			cid_num = argv[2];
+		}
 
-        if (!switch_strlen_zero(argv[3])) {
-            cid_name = argv[3];
-        }
+		if (!switch_strlen_zero(argv[3])) {
+			cid_name = argv[3];
+		}
 
-        if (!switch_strlen_zero(argv[4])) {
-            tech_pvt->sample_rate = atoi(argv[4]);
-        }
+		if (!switch_strlen_zero(argv[4])) {
+			tech_pvt->sample_rate = atoi(argv[4]);
+		}
 
-        if (!switch_strlen_zero(argv[4])) {
-            tech_pvt->codec_ms = atoi(argv[5]);
-        }
+		if (!switch_strlen_zero(argv[4])) {
+			tech_pvt->codec_ms = atoi(argv[5]);
+		}
 
 		if ((tech_pvt->caller_profile = switch_caller_profile_new(switch_core_session_get_pool(session),
 																  NULL,
 																  dialplan,
-                                                                  cid_name,
+																  cid_name,
 																  cid_num,
-                                                                  NULL, NULL, NULL, NULL, (char *)modname, NULL, dest)) != 0) {
+																  NULL, NULL, NULL, NULL, (char *) modname, NULL,
+																  dest)) != 0) {
 			char name[128];
 			snprintf(name, sizeof(name), "PortAudio/%s",
-					 tech_pvt->caller_profile->destination_number ? tech_pvt->caller_profile->destination_number : modname);
+					 tech_pvt->caller_profile->destination_number ? tech_pvt->caller_profile->
+					 destination_number : modname);
 			switch_channel_set_name(channel, name);
 
 			switch_channel_set_caller_profile(channel, tech_pvt->caller_profile);
 		}
 		tech_pvt->session = session;
 		if ((status = engage_device(tech_pvt->sample_rate, tech_pvt->codec_ms)) == SWITCH_STATUS_SUCCESS) {
-            switch_set_flag_locked(tech_pvt, TFLAG_ANSWER);
-            switch_channel_mark_answered(channel);
+			switch_set_flag_locked(tech_pvt, TFLAG_ANSWER);
+			switch_channel_mark_answered(channel);
 			switch_channel_set_state(channel, CS_INIT);
 			switch_core_session_thread_launch(tech_pvt->session);
-            add_pvt(tech_pvt, PA_MASTER);
-			stream->write_function(stream, "SUCCESS:%s:%s\n", tech_pvt->call_id, switch_core_session_get_uuid(tech_pvt->session));
+			add_pvt(tech_pvt, PA_MASTER);
+			stream->write_function(stream, "SUCCESS:%s:%s\n", tech_pvt->call_id,
+								   switch_core_session_get_uuid(tech_pvt->session));
 		} else {
-            switch_core_session_destroy(&session);
+			switch_core_session_destroy(&session);
 			stream->write_function(stream, "FAIL:Device Error!\n");
 		}
 	}
@@ -1727,72 +1747,72 @@ static switch_status_t place_call(char **argv, int argc, switch_stream_handle_t
 
 static switch_status_t padep(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");
-    return SWITCH_STATUS_SUCCESS;
+	stream->write_function(stream, "This command no longer exists (try 'pa help')\n");
+	return SWITCH_STATUS_SUCCESS;
 }
 
 static switch_status_t pa_cmd(char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
 {
-    char *argv[1024] = {0};
-    int argc = 0;
-    char *mycmd = NULL, *devname = NULL;
-    switch_status_t status = SWITCH_STATUS_SUCCESS;
-    pa_command_t func = NULL;
-    int lead = 1, devval = 0;
-    const char *usage_string = "USAGE:\n"
-        "--------------------------------------------------------------------------------\n"
-        "pa help\n"
-        "pa dump\n"
-        "pa call  [   ]\n"
-        "pa answer []\n"
-        "pa hangup []\n"
-        "pa list\n"
-        "pa switch [|none]\n"
-        "pa dtmf \n"
-        "pa flags [on|off] [ear] [mouth]\n"
+	char *argv[1024] = { 0 };
+	int argc = 0;
+	char *mycmd = NULL, *devname = NULL;
+	switch_status_t status = SWITCH_STATUS_SUCCESS;
+	pa_command_t func = NULL;
+	int lead = 1, devval = 0;
+	const char *usage_string = "USAGE:\n"
+		"--------------------------------------------------------------------------------\n"
+		"pa help\n"
+		"pa dump\n"
+		"pa call  [   ]\n"
+		"pa answer []\n"
+		"pa hangup []\n"
+		"pa list\n"
+		"pa switch [|none]\n"
+		"pa dtmf \n"
+		"pa flags [on|off] [ear] [mouth]\n"
 		"pa devlist\n"
 		"pa indev [#|\n"
 		"pa outdev [#|\n"
 		"pa ringdev [#|\n"
-        "--------------------------------------------------------------------------------\n";
+		"--------------------------------------------------------------------------------\n";
 
-    if (switch_strlen_zero(cmd)) {
-        stream->write_function(stream, "%s", usage_string);
-        goto done;
-    }
+	if (switch_strlen_zero(cmd)) {
+		stream->write_function(stream, "%s", usage_string);
+		goto done;
+	}
 
-    if (!(mycmd = strdup(cmd))) {
-        status = SWITCH_STATUS_MEMERR;
-        goto done;
-    }
-    
-    if (!(argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) {
-        stream->write_function(stream, "%s", usage_string);
-        goto done;
-    }
-    
-    if (!strcasecmp(argv[0], "call")) {
-        func = place_call;
-    } else if (!strcasecmp(argv[0], "help")) {
-        stream->write_function(stream, "%s", usage_string);
-        goto done;
-    } else if (!strcasecmp(argv[0], "devlist")) {
+	if (!(mycmd = strdup(cmd))) {
+		status = SWITCH_STATUS_MEMERR;
+		goto done;
+	}
+
+	if (!(argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) {
+		stream->write_function(stream, "%s", usage_string);
+		goto done;
+	}
+
+	if (!strcasecmp(argv[0], "call")) {
+		func = place_call;
+	} else if (!strcasecmp(argv[0], "help")) {
+		stream->write_function(stream, "%s", usage_string);
+		goto done;
+	} else if (!strcasecmp(argv[0], "devlist")) {
 		func = devlist;
-    } else if (!strcasecmp(argv[0], "dump")) {
-        dump_info();
-        goto done;
-    } else if (!strcasecmp(argv[0], "list")) {
-        func = list_calls;
-    } else if (!strcasecmp(argv[0], "flags")) {
-        func = do_flags;
-    } else if (!strcasecmp(argv[0], "hangup")) {
-        func = hangup_call;
-    } else if (!strcasecmp(argv[0], "answer")) {
-        func = answer_call;
-    } else if (!strcasecmp(argv[0], "switch")) {
-        func = switch_call;
-    } else if (!strcasecmp(argv[0], "dtmf")) {
-        func = dtmf_call;
+	} else if (!strcasecmp(argv[0], "dump")) {
+		dump_info();
+		goto done;
+	} else if (!strcasecmp(argv[0], "list")) {
+		func = list_calls;
+	} else if (!strcasecmp(argv[0], "flags")) {
+		func = do_flags;
+	} else if (!strcasecmp(argv[0], "hangup")) {
+		func = hangup_call;
+	} else if (!strcasecmp(argv[0], "answer")) {
+		func = answer_call;
+	} else if (!strcasecmp(argv[0], "switch")) {
+		func = switch_call;
+	} else if (!strcasecmp(argv[0], "dtmf")) {
+		func = dtmf_call;
 	} else if (argv[1] && !strcmp(argv[0], "indev")) {
 		if (*argv[1] == '#') {
 			devval = get_dev_by_number(atoi(argv[1] + 1), 1);
@@ -1810,7 +1830,7 @@ static switch_status_t pa_cmd(char *cmd, switch_core_session_t *isession, switch
 			devval = get_dev_by_name(argv[1], 0);
 		}
 		devname = "outdev";
-		if (devval > 0)  {
+		if (devval > 0) {
 			globals.outdev = devval;
 		}
 	} else if (argv[1] && !strcmp(argv[0], "ringdev")) {
@@ -1823,11 +1843,11 @@ static switch_status_t pa_cmd(char *cmd, switch_core_session_t *isession, switch
 		if (devval > 0) {
 			globals.ringdev = devval;
 		}
-    }
-    
-    if (func) {
-        status = func(&argv[lead], argc - lead, stream);
-    } else {
+	}
+
+	if (func) {
+		status = func(&argv[lead], argc - lead, stream);
+	} else {
 		if (devname) {
 			if (devval > 0) {
 				stream->write_function(stream, "%s set to %d\n", devname, devval);
@@ -1837,13 +1857,13 @@ static switch_status_t pa_cmd(char *cmd, switch_core_session_t *isession, switch
 		} else {
 			stream->write_function(stream, "Unknown Command [%s]\n", argv[0]);
 		}
-    }
+	}
 
- done:
+  done:
 
-    switch_safe_free(mycmd);
+	switch_safe_free(mycmd);
 
-    return status;
+	return status;
 }
 
 
diff --git a/src/mod/endpoints/mod_portaudio/pa_ringbuffer.c b/src/mod/endpoints/mod_portaudio/pa_ringbuffer.c
index 2d46ceeedd..bb999a8e74 100644
--- a/src/mod/endpoints/mod_portaudio/pa_ringbuffer.c
+++ b/src/mod/endpoints/mod_portaudio/pa_ringbuffer.c
@@ -81,17 +81,17 @@
 #   define PaUtil_WriteMemoryBarrier()
 #else
 
-#if defined(__APPLE__) //|| defined(__FreeBSD__)
+#if defined(__APPLE__)			//|| defined(__FreeBSD__)
 #   include 
-    /* Here are the memory barrier functions. Mac OS X and FreeBSD only provide
-       full memory barriers, so the three types of barriers are the same. */
+	/* Here are the memory barrier functions. Mac OS X and FreeBSD only provide
+	   full memory barriers, so the three types of barriers are the same. */
 #   define PaUtil_FullMemoryBarrier()  OSMemoryBarrier()
 #   define PaUtil_ReadMemoryBarrier()  OSMemoryBarrier()
 #   define PaUtil_WriteMemoryBarrier() OSMemoryBarrier()
 #elif defined(__GNUC__)
 
-    /* GCC understands volatile asm and "memory" to mean it
-     * should not reorder memory read/writes */
+	/* GCC understands volatile asm and "memory" to mean it
+	 * should not reorder memory read/writes */
 #   if defined( __PPC__ )
 #      define PaUtil_FullMemoryBarrier()  __asm__ volatile("sync":::"memory")
 #      define PaUtil_ReadMemoryBarrier()  __asm__ volatile("sync":::"memory")
@@ -123,37 +123,39 @@
  * Initialize FIFO.
  * numBytes must be power of 2, returns -1 if not.
  */
-long PaUtil_InitializeRingBuffer( PaUtilRingBuffer *rbuf, long numBytes, void *dataPtr )
+long PaUtil_InitializeRingBuffer(PaUtilRingBuffer * rbuf, long numBytes, void *dataPtr)
 {
-    if( ((numBytes-1) & numBytes) != 0) return -1; /* Not Power of two. */
-    rbuf->bufferSize = numBytes;
-    rbuf->buffer = (char *)dataPtr;
-    PaUtil_FlushRingBuffer( rbuf );
-    rbuf->bigMask = (numBytes*2)-1;
-    rbuf->smallMask = (numBytes)-1;
-    return 0;
+	if (((numBytes - 1) & numBytes) != 0)
+		return -1;				/* Not Power of two. */
+	rbuf->bufferSize = numBytes;
+	rbuf->buffer = (char *) dataPtr;
+	PaUtil_FlushRingBuffer(rbuf);
+	rbuf->bigMask = (numBytes * 2) - 1;
+	rbuf->smallMask = (numBytes) - 1;
+	return 0;
 }
 
 /***************************************************************************
 ** Return number of bytes available for reading. */
-long PaUtil_GetRingBufferReadAvailable( PaUtilRingBuffer *rbuf )
+long PaUtil_GetRingBufferReadAvailable(PaUtilRingBuffer * rbuf)
 {
-    PaUtil_ReadMemoryBarrier();
-    return ( (rbuf->writeIndex - rbuf->readIndex) & rbuf->bigMask );
+	PaUtil_ReadMemoryBarrier();
+	return ((rbuf->writeIndex - rbuf->readIndex) & rbuf->bigMask);
 }
+
 /***************************************************************************
 ** Return number of bytes available for writing. */
-long PaUtil_GetRingBufferWriteAvailable( PaUtilRingBuffer *rbuf )
+long PaUtil_GetRingBufferWriteAvailable(PaUtilRingBuffer * rbuf)
 {
-    /* Since we are calling PaUtil_GetRingBufferReadAvailable, we don't need an aditional MB */
-    return ( rbuf->bufferSize - PaUtil_GetRingBufferReadAvailable(rbuf));
+	/* Since we are calling PaUtil_GetRingBufferReadAvailable, we don't need an aditional MB */
+	return (rbuf->bufferSize - PaUtil_GetRingBufferReadAvailable(rbuf));
 }
 
 /***************************************************************************
 ** Clear buffer. Should only be called when buffer is NOT being read. */
-void PaUtil_FlushRingBuffer( PaUtilRingBuffer *rbuf )
+void PaUtil_FlushRingBuffer(PaUtilRingBuffer * rbuf)
 {
-    rbuf->writeIndex = rbuf->readIndex = 0;
+	rbuf->writeIndex = rbuf->readIndex = 0;
 }
 
 /***************************************************************************
@@ -162,42 +164,39 @@ void PaUtil_FlushRingBuffer( PaUtilRingBuffer *rbuf )
 ** If non-contiguous, size2 will be the size of second region.
 ** Returns room available to be written or numBytes, whichever is smaller.
 */
-long PaUtil_GetRingBufferWriteRegions( PaUtilRingBuffer *rbuf, long numBytes,
-                                       void **dataPtr1, long *sizePtr1,
-                                       void **dataPtr2, long *sizePtr2 )
+long PaUtil_GetRingBufferWriteRegions(PaUtilRingBuffer * rbuf, long numBytes,
+									  void **dataPtr1, long *sizePtr1, void **dataPtr2, long *sizePtr2)
 {
-    long   index;
-    long   available = PaUtil_GetRingBufferWriteAvailable( rbuf );
-    if( numBytes > available ) numBytes = available;
-    /* Check to see if write is not contiguous. */
-    index = rbuf->writeIndex & rbuf->smallMask;
-    if( (index + numBytes) > rbuf->bufferSize )
-    {
-        /* Write data in two blocks that wrap the buffer. */
-        long   firstHalf = rbuf->bufferSize - index;
-        *dataPtr1 = &rbuf->buffer[index];
-        *sizePtr1 = firstHalf;
-        *dataPtr2 = &rbuf->buffer[0];
-        *sizePtr2 = numBytes - firstHalf;
-    }
-    else
-    {
-        *dataPtr1 = &rbuf->buffer[index];
-        *sizePtr1 = numBytes;
-        *dataPtr2 = NULL;
-        *sizePtr2 = 0;
-    }
-    return numBytes;
+	long index;
+	long available = PaUtil_GetRingBufferWriteAvailable(rbuf);
+	if (numBytes > available)
+		numBytes = available;
+	/* Check to see if write is not contiguous. */
+	index = rbuf->writeIndex & rbuf->smallMask;
+	if ((index + numBytes) > rbuf->bufferSize) {
+		/* Write data in two blocks that wrap the buffer. */
+		long firstHalf = rbuf->bufferSize - index;
+		*dataPtr1 = &rbuf->buffer[index];
+		*sizePtr1 = firstHalf;
+		*dataPtr2 = &rbuf->buffer[0];
+		*sizePtr2 = numBytes - firstHalf;
+	} else {
+		*dataPtr1 = &rbuf->buffer[index];
+		*sizePtr1 = numBytes;
+		*dataPtr2 = NULL;
+		*sizePtr2 = 0;
+	}
+	return numBytes;
 }
 
 
 /***************************************************************************
 */
-long PaUtil_AdvanceRingBufferWriteIndex( PaUtilRingBuffer *rbuf, long numBytes )
+long PaUtil_AdvanceRingBufferWriteIndex(PaUtilRingBuffer * rbuf, long numBytes)
 {
-    /* we need to ensure that previous writes are seen before we update the write index */
-    PaUtil_WriteMemoryBarrier();
-    return rbuf->writeIndex = (rbuf->writeIndex + numBytes) & rbuf->bigMask;
+	/* we need to ensure that previous writes are seen before we update the write index */
+	PaUtil_WriteMemoryBarrier();
+	return rbuf->writeIndex = (rbuf->writeIndex + numBytes) & rbuf->bigMask;
 }
 
 /***************************************************************************
@@ -206,81 +205,73 @@ long PaUtil_AdvanceRingBufferWriteIndex( PaUtilRingBuffer *rbuf, long numBytes )
 ** If non-contiguous, size2 will be the size of second region.
 ** Returns room available to be written or numBytes, whichever is smaller.
 */
-long PaUtil_GetRingBufferReadRegions( PaUtilRingBuffer *rbuf, long numBytes,
-                                void **dataPtr1, long *sizePtr1,
-                                void **dataPtr2, long *sizePtr2 )
+long PaUtil_GetRingBufferReadRegions(PaUtilRingBuffer * rbuf, long numBytes,
+									 void **dataPtr1, long *sizePtr1, void **dataPtr2, long *sizePtr2)
 {
-    long   index;
-    long   available = PaUtil_GetRingBufferReadAvailable( rbuf );
-    if( numBytes > available ) numBytes = available;
-    /* Check to see if read is not contiguous. */
-    index = rbuf->readIndex & rbuf->smallMask;
-    if( (index + numBytes) > rbuf->bufferSize )
-    {
-        /* Write data in two blocks that wrap the buffer. */
-        long firstHalf = rbuf->bufferSize - index;
-        *dataPtr1 = &rbuf->buffer[index];
-        *sizePtr1 = firstHalf;
-        *dataPtr2 = &rbuf->buffer[0];
-        *sizePtr2 = numBytes - firstHalf;
-    }
-    else
-    {
-        *dataPtr1 = &rbuf->buffer[index];
-        *sizePtr1 = numBytes;
-        *dataPtr2 = NULL;
-        *sizePtr2 = 0;
-    }
-    return numBytes;
+	long index;
+	long available = PaUtil_GetRingBufferReadAvailable(rbuf);
+	if (numBytes > available)
+		numBytes = available;
+	/* Check to see if read is not contiguous. */
+	index = rbuf->readIndex & rbuf->smallMask;
+	if ((index + numBytes) > rbuf->bufferSize) {
+		/* Write data in two blocks that wrap the buffer. */
+		long firstHalf = rbuf->bufferSize - index;
+		*dataPtr1 = &rbuf->buffer[index];
+		*sizePtr1 = firstHalf;
+		*dataPtr2 = &rbuf->buffer[0];
+		*sizePtr2 = numBytes - firstHalf;
+	} else {
+		*dataPtr1 = &rbuf->buffer[index];
+		*sizePtr1 = numBytes;
+		*dataPtr2 = NULL;
+		*sizePtr2 = 0;
+	}
+	return numBytes;
 }
+
 /***************************************************************************
 */
-long PaUtil_AdvanceRingBufferReadIndex( PaUtilRingBuffer *rbuf, long numBytes )
+long PaUtil_AdvanceRingBufferReadIndex(PaUtilRingBuffer * rbuf, long numBytes)
 {
-    /* we need to ensure that previous writes are always seen before updating the index. */
-    PaUtil_WriteMemoryBarrier();
-    return rbuf->readIndex = (rbuf->readIndex + numBytes) & rbuf->bigMask;
+	/* we need to ensure that previous writes are always seen before updating the index. */
+	PaUtil_WriteMemoryBarrier();
+	return rbuf->readIndex = (rbuf->readIndex + numBytes) & rbuf->bigMask;
 }
 
 /***************************************************************************
 ** Return bytes written. */
-long PaUtil_WriteRingBuffer( PaUtilRingBuffer *rbuf, const void *data, long numBytes )
+long PaUtil_WriteRingBuffer(PaUtilRingBuffer * rbuf, const void *data, long numBytes)
 {
-    long size1, size2, numWritten;
-    void *data1, *data2;
-    numWritten = PaUtil_GetRingBufferWriteRegions( rbuf, numBytes, &data1, &size1, &data2, &size2 );
-    if( size2 > 0 )
-    {
+	long size1, size2, numWritten;
+	void *data1, *data2;
+	numWritten = PaUtil_GetRingBufferWriteRegions(rbuf, numBytes, &data1, &size1, &data2, &size2);
+	if (size2 > 0) {
 
-        memcpy( data1, data, size1 );
-        data = ((char *)data) + size1;
-        memcpy( data2, data, size2 );
-    }
-    else
-    {
-        memcpy( data1, data, size1 );
-    }
-    PaUtil_AdvanceRingBufferWriteIndex( rbuf, numWritten );
-    return numWritten;
+		memcpy(data1, data, size1);
+		data = ((char *) data) + size1;
+		memcpy(data2, data, size2);
+	} else {
+		memcpy(data1, data, size1);
+	}
+	PaUtil_AdvanceRingBufferWriteIndex(rbuf, numWritten);
+	return numWritten;
 }
 
 /***************************************************************************
 ** Return bytes read. */
-long PaUtil_ReadRingBuffer( PaUtilRingBuffer *rbuf, void *data, long numBytes )
+long PaUtil_ReadRingBuffer(PaUtilRingBuffer * rbuf, void *data, long numBytes)
 {
-    long size1, size2, numRead;
-    void *data1, *data2;
-    numRead = PaUtil_GetRingBufferReadRegions( rbuf, numBytes, &data1, &size1, &data2, &size2 );
-    if( size2 > 0 )
-    {
-        memcpy( data, data1, size1 );
-        data = ((char *)data) + size1;
-        memcpy( data, data2, size2 );
-    }
-    else
-    {
-        memcpy( data, data1, size1 );
-    }
-    PaUtil_AdvanceRingBufferReadIndex( rbuf, numRead );
-    return numRead;
+	long size1, size2, numRead;
+	void *data1, *data2;
+	numRead = PaUtil_GetRingBufferReadRegions(rbuf, numBytes, &data1, &size1, &data2, &size2);
+	if (size2 > 0) {
+		memcpy(data, data1, size1);
+		data = ((char *) data) + size1;
+		memcpy(data, data2, size2);
+	} else {
+		memcpy(data, data1, size1);
+	}
+	PaUtil_AdvanceRingBufferReadIndex(rbuf, numRead);
+	return numRead;
 }
diff --git a/src/mod/endpoints/mod_portaudio/pa_ringbuffer.h b/src/mod/endpoints/mod_portaudio/pa_ringbuffer.h
index b380889815..cacc1de675 100644
--- a/src/mod/endpoints/mod_portaudio/pa_ringbuffer.h
+++ b/src/mod/endpoints/mod_portaudio/pa_ringbuffer.h
@@ -51,19 +51,17 @@
 */
 
 #ifdef __cplusplus
-extern "C"
-{
-#endif /* __cplusplus */
+extern "C" {
+#endif							/* __cplusplus */
 
-typedef struct PaUtilRingBuffer
-{
-    long   bufferSize; /* Number of bytes in FIFO. Power of 2. Set by PaUtil_InitRingBuffer. */
-    long   writeIndex; /* Index of next writable byte. Set by PaUtil_AdvanceRingBufferWriteIndex. */
-    long   readIndex;  /* Index of next readable byte. Set by PaUtil_AdvanceRingBufferReadIndex. */
-    long   bigMask;    /* Used for wrapping indices with extra bit to distinguish full/empty. */
-    long   smallMask;  /* Used for fitting indices to buffer. */
-    char  *buffer;
-}PaUtilRingBuffer;
+	typedef struct PaUtilRingBuffer {
+		long bufferSize;		/* Number of bytes in FIFO. Power of 2. Set by PaUtil_InitRingBuffer. */
+		long writeIndex;		/* Index of next writable byte. Set by PaUtil_AdvanceRingBufferWriteIndex. */
+		long readIndex;			/* Index of next readable byte. Set by PaUtil_AdvanceRingBufferReadIndex. */
+		long bigMask;			/* Used for wrapping indices with extra bit to distinguish full/empty. */
+		long smallMask;			/* Used for fitting indices to buffer. */
+		char *buffer;
+	} PaUtilRingBuffer;
 
 /** Initialize Ring Buffer.
 
@@ -76,13 +74,13 @@ typedef struct PaUtilRingBuffer
 
  @return -1 if numBytes is not a power of 2, otherwise 0.
 */
-long PaUtil_InitializeRingBuffer( PaUtilRingBuffer *rbuf, long numBytes, void *dataPtr );
+	long PaUtil_InitializeRingBuffer(PaUtilRingBuffer * rbuf, long numBytes, void *dataPtr);
 
 /** Clear buffer. Should only be called when buffer is NOT being read.
 
  @param rbuf The ring buffer.
 */
-void PaUtil_FlushRingBuffer( PaUtilRingBuffer *rbuf );
+	void PaUtil_FlushRingBuffer(PaUtilRingBuffer * rbuf);
 
 /** Retrieve the number of bytes available in the ring buffer for writing.
 
@@ -90,7 +88,7 @@ void PaUtil_FlushRingBuffer( PaUtilRingBuffer *rbuf );
 
  @return The number of bytes available for writing.
 */
-long PaUtil_GetRingBufferWriteAvailable( PaUtilRingBuffer *rbuf );
+	long PaUtil_GetRingBufferWriteAvailable(PaUtilRingBuffer * rbuf);
 
 /** Retrieve the number of bytes available in the ring buffer for reading.
 
@@ -98,7 +96,7 @@ long PaUtil_GetRingBufferWriteAvailable( PaUtilRingBuffer *rbuf );
 
  @return The number of bytes available for reading.
 */
-long PaUtil_GetRingBufferReadAvailable( PaUtilRingBuffer *rbuf );
+	long PaUtil_GetRingBufferReadAvailable(PaUtilRingBuffer * rbuf);
 
 /** Write data to the ring buffer.
 
@@ -110,7 +108,7 @@ long PaUtil_GetRingBufferReadAvailable( PaUtilRingBuffer *rbuf );
 
  @return The number of bytes written.
 */
-long PaUtil_WriteRingBuffer( PaUtilRingBuffer *rbuf, const void *data, long numBytes );
+	long PaUtil_WriteRingBuffer(PaUtilRingBuffer * rbuf, const void *data, long numBytes);
 
 /** Read data from the ring buffer.
 
@@ -122,7 +120,7 @@ long PaUtil_WriteRingBuffer( PaUtilRingBuffer *rbuf, const void *data, long numB
 
  @return The number of bytes read.
 */
-long PaUtil_ReadRingBuffer( PaUtilRingBuffer *rbuf, void *data, long numBytes );
+	long PaUtil_ReadRingBuffer(PaUtilRingBuffer * rbuf, void *data, long numBytes);
 
 /** Get address of region(s) to which we can write data.
 
@@ -144,9 +142,8 @@ long PaUtil_ReadRingBuffer( PaUtilRingBuffer *rbuf, void *data, long numBytes );
 
  @return The room available to be written or numBytes, whichever is smaller.
 */
-long PaUtil_GetRingBufferWriteRegions( PaUtilRingBuffer *rbuf, long numBytes,
-                                       void **dataPtr1, long *sizePtr1,
-                                       void **dataPtr2, long *sizePtr2 );
+	long PaUtil_GetRingBufferWriteRegions(PaUtilRingBuffer * rbuf, long numBytes,
+										  void **dataPtr1, long *sizePtr1, void **dataPtr2, long *sizePtr2);
 
 /** Advance the write index to the next location to be written.
 
@@ -156,7 +153,7 @@ long PaUtil_GetRingBufferWriteRegions( PaUtilRingBuffer *rbuf, long numBytes,
 
  @return The new position.
 */
-long PaUtil_AdvanceRingBufferWriteIndex( PaUtilRingBuffer *rbuf, long numBytes );
+	long PaUtil_AdvanceRingBufferWriteIndex(PaUtilRingBuffer * rbuf, long numBytes);
 
 /** Get address of region(s) from which we can write data.
 
@@ -178,9 +175,8 @@ long PaUtil_AdvanceRingBufferWriteIndex( PaUtilRingBuffer *rbuf, long numBytes )
 
  @return The number of bytes available for reading.
 */
-long PaUtil_GetRingBufferReadRegions( PaUtilRingBuffer *rbuf, long numBytes,
-                                      void **dataPtr1, long *sizePtr1,
-                                      void **dataPtr2, long *sizePtr2 );
+	long PaUtil_GetRingBufferReadRegions(PaUtilRingBuffer * rbuf, long numBytes,
+										 void **dataPtr1, long *sizePtr1, void **dataPtr2, long *sizePtr2);
 
 /** Advance the read index to the next location to be read.
 
@@ -190,9 +186,9 @@ long PaUtil_GetRingBufferReadRegions( PaUtilRingBuffer *rbuf, long numBytes,
 
  @return The new position.
 */
-long PaUtil_AdvanceRingBufferReadIndex( PaUtilRingBuffer *rbuf, long numBytes );
+	long PaUtil_AdvanceRingBufferReadIndex(PaUtilRingBuffer * rbuf, long numBytes);
 
 #ifdef __cplusplus
 }
-#endif /* __cplusplus */
-#endif /* PA_RINGBUFFER_H */
+#endif							/* __cplusplus */
+#endif							/* PA_RINGBUFFER_H */
diff --git a/src/mod/endpoints/mod_portaudio/pablio.c b/src/mod/endpoints/mod_portaudio/pablio.c
index c9de237a48..592571158e 100644
--- a/src/mod/endpoints/mod_portaudio/pablio.c
+++ b/src/mod/endpoints/mod_portaudio/pablio.c
@@ -59,13 +59,12 @@
 /******** Prototypes ****************************************************/
 /************************************************************************/
 
-static int blockingIOCallback( const void *inputBuffer, void *outputBuffer,
-                               unsigned long framesPerBuffer,
-							   const PaStreamCallbackTimeInfo* timeInfo,
-							   PaStreamCallbackFlags statusFlags,
-							   void *userData );
-static PaError PABLIO_InitFIFO( PaUtilRingBuffer *rbuf, long numFrames, long bytesPerFrame );
-static PaError PABLIO_TermFIFO( PaUtilRingBuffer *rbuf );
+static int blockingIOCallback(const void *inputBuffer, void *outputBuffer,
+							  unsigned long framesPerBuffer,
+							  const PaStreamCallbackTimeInfo * timeInfo,
+							  PaStreamCallbackFlags statusFlags, void *userData);
+static PaError PABLIO_InitFIFO(PaUtilRingBuffer * rbuf, long numFrames, long bytesPerFrame);
+static PaError PABLIO_TermFIFO(PaUtilRingBuffer * rbuf);
 
 /************************************************************************/
 /******** Functions *****************************************************/
@@ -74,122 +73,120 @@ static PaError PABLIO_TermFIFO( PaUtilRingBuffer *rbuf );
 /* Called from PortAudio.
  * Read and write data only if there is room in FIFOs.
  */
-static int blockingIOCallback( const void *inputBuffer, void *outputBuffer,
-                               unsigned long framesPerBuffer,
-                               const PaStreamCallbackTimeInfo* timeInfo,
-							   PaStreamCallbackFlags statusFlags,
-							   void *userData )
+static int blockingIOCallback(const void *inputBuffer, void *outputBuffer,
+							  unsigned long framesPerBuffer,
+							  const PaStreamCallbackTimeInfo * timeInfo,
+							  PaStreamCallbackFlags statusFlags, void *userData)
 {
-    PABLIO_Stream *data = (PABLIO_Stream*)userData;
-    long numBytes = data->bytesPerFrame * framesPerBuffer;
+	PABLIO_Stream *data = (PABLIO_Stream *) userData;
+	long numBytes = data->bytesPerFrame * framesPerBuffer;
 
-    /* This may get called with NULL inputBuffer during initial setup. */
-    if( inputBuffer != NULL )
-    {
-        PaUtil_WriteRingBuffer( &data->inFIFO, inputBuffer, numBytes );
-    }
-    if( outputBuffer != NULL )
-    {
-        int i;
-        int numRead = PaUtil_ReadRingBuffer( &data->outFIFO, outputBuffer, numBytes );
-        /* Zero out remainder of buffer if we run out of data. */
-        for( i=numRead; iinFIFO, inputBuffer, numBytes);
+	}
+	if (outputBuffer != NULL) {
+		int i;
+		int numRead = PaUtil_ReadRingBuffer(&data->outFIFO, outputBuffer, numBytes);
+		/* Zero out remainder of buffer if we run out of data. */
+		for (i = numRead; i < numBytes; i++) {
+			((char *) outputBuffer)[i] = 0;
+		}
+	}
 
-    return 0;
+	return 0;
 }
 
 /* Allocate buffer. */
-static PaError PABLIO_InitFIFO( PaUtilRingBuffer *rbuf, long numFrames, long bytesPerFrame )
+static PaError PABLIO_InitFIFO(PaUtilRingBuffer * rbuf, long numFrames, long bytesPerFrame)
 {
-    long numBytes = numFrames * bytesPerFrame;
-    char *buffer = (char *) malloc( numBytes );
-    if( buffer == NULL ) return paInsufficientMemory;
-    memset( buffer, 0, numBytes );
-    return (PaError) PaUtil_InitializeRingBuffer( rbuf, numBytes, buffer );
+	long numBytes = numFrames * bytesPerFrame;
+	char *buffer = (char *) malloc(numBytes);
+	if (buffer == NULL)
+		return paInsufficientMemory;
+	memset(buffer, 0, numBytes);
+	return (PaError) PaUtil_InitializeRingBuffer(rbuf, numBytes, buffer);
 }
 
 /* Free buffer. */
-static PaError PABLIO_TermFIFO( PaUtilRingBuffer *rbuf )
+static PaError PABLIO_TermFIFO(PaUtilRingBuffer * rbuf)
 {
-    if( rbuf->buffer ) free( rbuf->buffer );
-    rbuf->buffer = NULL;
-    return paNoError;
+	if (rbuf->buffer)
+		free(rbuf->buffer);
+	rbuf->buffer = NULL;
+	return paNoError;
 }
 
 /************************************************************
  * Write data to ring buffer.
  * Will not return until all the data has been written.
  */
-long WriteAudioStream( PABLIO_Stream *aStream, void *data, long numFrames )
+long WriteAudioStream(PABLIO_Stream * aStream, void *data, long numFrames)
 {
-    long bytesWritten;
-    char *p = (char *) data;
-    long numBytes = aStream->bytesPerFrame * numFrames;
-    while( numBytes > 0)
-    {
-        bytesWritten = PaUtil_WriteRingBuffer( &aStream->outFIFO, p, numBytes );
-        numBytes -= bytesWritten;
-        p += bytesWritten;
-        if( numBytes > 0) Pa_Sleep(10);
-    }
-    return numFrames;
+	long bytesWritten;
+	char *p = (char *) data;
+	long numBytes = aStream->bytesPerFrame * numFrames;
+	while (numBytes > 0) {
+		bytesWritten = PaUtil_WriteRingBuffer(&aStream->outFIFO, p, numBytes);
+		numBytes -= bytesWritten;
+		p += bytesWritten;
+		if (numBytes > 0)
+			Pa_Sleep(10);
+	}
+	return numFrames;
 }
 
 /************************************************************
  * Read data from ring buffer.
  * Will not return until all the data has been read.
  */
-long ReadAudioStream( PABLIO_Stream *aStream, void *data, long numFrames )
+long ReadAudioStream(PABLIO_Stream * aStream, void *data, long numFrames)
 {
-    long bytesRead;
-    char *p = (char *) data;
-    long numBytes = aStream->bytesPerFrame * numFrames;
+	long bytesRead;
+	char *p = (char *) data;
+	long numBytes = aStream->bytesPerFrame * numFrames;
 
-    while( numBytes > 0)
-    {
-        bytesRead = PaUtil_ReadRingBuffer( &aStream->inFIFO, p, numBytes );
-        numBytes -= bytesRead;
-        p += bytesRead;
-        if( numBytes > 0) Pa_Sleep(10);
-    }
-    return numFrames;
+	while (numBytes > 0) {
+		bytesRead = PaUtil_ReadRingBuffer(&aStream->inFIFO, p, numBytes);
+		numBytes -= bytesRead;
+		p += bytesRead;
+		if (numBytes > 0)
+			Pa_Sleep(10);
+	}
+	return numFrames;
 }
 
 /************************************************************
  * Return the number of frames that could be written to the stream without
  * having to wait.
  */
-long GetAudioStreamWriteable( PABLIO_Stream *aStream )
+long GetAudioStreamWriteable(PABLIO_Stream * aStream)
 {
-    int bytesEmpty = PaUtil_GetRingBufferWriteAvailable( &aStream->outFIFO );
-    return bytesEmpty / aStream->bytesPerFrame;
+	int bytesEmpty = PaUtil_GetRingBufferWriteAvailable(&aStream->outFIFO);
+	return bytesEmpty / aStream->bytesPerFrame;
 }
 
 /************************************************************
  * Return the number of frames that are available to be read from the
  * stream without having to wait.
  */
-long GetAudioStreamReadable( PABLIO_Stream *aStream )
+long GetAudioStreamReadable(PABLIO_Stream * aStream)
 {
-    int bytesFull = PaUtil_GetRingBufferReadAvailable( &aStream->inFIFO );
-    return bytesFull / aStream->bytesPerFrame;
+	int bytesFull = PaUtil_GetRingBufferReadAvailable(&aStream->inFIFO);
+	return bytesFull / aStream->bytesPerFrame;
 }
 
 /************************************************************/
-static unsigned long RoundUpToNextPowerOf2( unsigned long n )
+static unsigned long RoundUpToNextPowerOf2(unsigned long n)
 {
-    long numBits = 0;
-    if( ((n-1) & n) == 0) return n; /* Already Power of two. */
-    while( n > 0 )
-    {
-        n= n>>1;
-        numBits++;
-    }
-    return (1< 0) {
+		n = n >> 1;
+		numBits++;
+	}
+	return (1 << numBits);
 }
 
 /************************************************************
@@ -197,27 +194,27 @@ static unsigned long RoundUpToNextPowerOf2( unsigned long n )
  * Allocates PABLIO_Stream structure.
  *
  */
-PaError OpenAudioStream( PABLIO_Stream **rwblPtr, 
-						 const PaStreamParameters *inputParameters,
-						 const PaStreamParameters *outputParameters,
-						 double sampleRate,
-						 PaStreamFlags streamFlags)
+PaError OpenAudioStream(PABLIO_Stream ** rwblPtr,
+						const PaStreamParameters * inputParameters,
+						const PaStreamParameters * outputParameters, double sampleRate, PaStreamFlags streamFlags)
 {
-    long   bytesPerSample;
-    PaError err;
-    PABLIO_Stream *aStream;
-    long   numFrames;
+	long bytesPerSample;
+	PaError err;
+	PABLIO_Stream *aStream;
+	long numFrames;
 	long numBytes;
 	int channels = 1;
 
-    /* Allocate PABLIO_Stream structure for caller. */
-    aStream = (PABLIO_Stream *) malloc( sizeof(PABLIO_Stream) );
-    if( aStream == NULL ) return paInsufficientMemory;
-    memset( aStream, 0, sizeof(PABLIO_Stream) );
+	/* Allocate PABLIO_Stream structure for caller. */
+	aStream = (PABLIO_Stream *) malloc(sizeof(PABLIO_Stream));
+	if (aStream == NULL)
+		return paInsufficientMemory;
+	memset(aStream, 0, sizeof(PABLIO_Stream));
 
-    /* Initialize PortAudio  */
-    err = Pa_Initialize();
-    if( err != paNoError ) goto error;
+	/* Initialize PortAudio  */
+	err = Pa_Initialize();
+	if (err != paNoError)
+		goto error;
 
 	if (inputParameters) {
 		channels = inputParameters->channelCount;
@@ -225,81 +222,79 @@ PaError OpenAudioStream( PABLIO_Stream **rwblPtr,
 		channels = outputParameters->channelCount;
 	}
 
-    numFrames = 4 * FRAMES_PER_BUFFER;
-    numFrames = RoundUpToNextPowerOf2( numFrames );
+	numFrames = 4 * FRAMES_PER_BUFFER;
+	numFrames = RoundUpToNextPowerOf2(numFrames);
 
 	bytesPerSample = 2;
 	aStream->samplesPerFrame = channels;
-    aStream->bytesPerFrame = bytesPerSample * aStream->samplesPerFrame;
+	aStream->bytesPerFrame = bytesPerSample * aStream->samplesPerFrame;
 
-    /* Initialize Ring Buffers */
+	/* Initialize Ring Buffers */
 
 	if (inputParameters) {
-		err = PABLIO_InitFIFO( &aStream->inFIFO, numFrames, aStream->bytesPerFrame );
-		if( err != paNoError ) goto error;
+		err = PABLIO_InitFIFO(&aStream->inFIFO, numFrames, aStream->bytesPerFrame);
+		if (err != paNoError)
+			goto error;
 	}
 
 	if (outputParameters) {
-		err = PABLIO_InitFIFO( &aStream->outFIFO, numFrames, aStream->bytesPerFrame );
-		if( err != paNoError ) goto error;
+		err = PABLIO_InitFIFO(&aStream->outFIFO, numFrames, aStream->bytesPerFrame);
+		if (err != paNoError)
+			goto error;
 	}
 
 	/* Make Write FIFO appear full initially. */
-	numBytes = PaUtil_GetRingBufferWriteAvailable( &aStream->outFIFO );
-	PaUtil_AdvanceRingBufferWriteIndex( &aStream->outFIFO, numBytes );
-	
+	numBytes = PaUtil_GetRingBufferWriteAvailable(&aStream->outFIFO);
+	PaUtil_AdvanceRingBufferWriteIndex(&aStream->outFIFO, numBytes);
 
-    /* Open a PortAudio stream that we will use to communicate with the underlying
-     * audio drivers. */
-    err = Pa_OpenStream(
-              &aStream->stream,
-			  inputParameters,
-              outputParameters,
-			  sampleRate,
-              FRAMES_PER_BUFFER,
-			  streamFlags,
-              blockingIOCallback,
-              aStream );
-    if( err != paNoError ) goto error;
 
-    err = Pa_StartStream( aStream->stream );
-    if( err != paNoError ) goto error;
-    *rwblPtr = aStream;
-    return paNoError;
+	/* Open a PortAudio stream that we will use to communicate with the underlying
+	 * audio drivers. */
+	err = Pa_OpenStream(&aStream->stream,
+						inputParameters,
+						outputParameters, sampleRate, FRAMES_PER_BUFFER, streamFlags, blockingIOCallback, aStream);
+	if (err != paNoError)
+		goto error;
 
-error:
-    CloseAudioStream( aStream );
-    *rwblPtr = NULL;
-    return err;
+	err = Pa_StartStream(aStream->stream);
+	if (err != paNoError)
+		goto error;
+	*rwblPtr = aStream;
+	return paNoError;
+
+  error:
+	CloseAudioStream(aStream);
+	*rwblPtr = NULL;
+	return err;
 }
 
 /************************************************************/
-PaError CloseAudioStream( PABLIO_Stream *aStream )
+PaError CloseAudioStream(PABLIO_Stream * aStream)
 {
-    PaError err;
-    int bytesEmpty;
-    int byteSize = aStream->outFIFO.bufferSize;
+	PaError err;
+	int bytesEmpty;
+	int byteSize = aStream->outFIFO.bufferSize;
 
-    /* If we are writing data, make sure we play everything written. */
-    if( byteSize > 0 )
-    {
-        bytesEmpty = PaUtil_GetRingBufferWriteAvailable( &aStream->outFIFO );
-        while( bytesEmpty < byteSize )
-        {
-            Pa_Sleep( 10 );
-            bytesEmpty = PaUtil_GetRingBufferWriteAvailable( &aStream->outFIFO );
-        }
-    }
+	/* If we are writing data, make sure we play everything written. */
+	if (byteSize > 0) {
+		bytesEmpty = PaUtil_GetRingBufferWriteAvailable(&aStream->outFIFO);
+		while (bytesEmpty < byteSize) {
+			Pa_Sleep(10);
+			bytesEmpty = PaUtil_GetRingBufferWriteAvailable(&aStream->outFIFO);
+		}
+	}
 
-    err = Pa_StopStream( aStream->stream );
-    if( err != paNoError ) goto error;
-    err = Pa_CloseStream( aStream->stream );
-    if( err != paNoError ) goto error;
-    Pa_Terminate();
+	err = Pa_StopStream(aStream->stream);
+	if (err != paNoError)
+		goto error;
+	err = Pa_CloseStream(aStream->stream);
+	if (err != paNoError)
+		goto error;
+	Pa_Terminate();
 
-error:
-    PABLIO_TermFIFO( &aStream->inFIFO );
-    PABLIO_TermFIFO( &aStream->outFIFO );
-    free( aStream );
-    return err;
+  error:
+	PABLIO_TermFIFO(&aStream->inFIFO);
+	PABLIO_TermFIFO(&aStream->outFIFO);
+	free(aStream);
+	return err;
 }
diff --git a/src/mod/endpoints/mod_portaudio/pablio.h b/src/mod/endpoints/mod_portaudio/pablio.h
index 0db1156b14..336f76cbc3 100644
--- a/src/mod/endpoints/mod_portaudio/pablio.h
+++ b/src/mod/endpoints/mod_portaudio/pablio.h
@@ -2,9 +2,8 @@
 #define _PABLIO_H
 
 #ifdef __cplusplus
-extern "C"
-{
-#endif /* __cplusplus */
+extern "C" {
+#endif							/* __cplusplus */
 
 /*
  * $Id: pablio.h 1083 2006-08-23 07:30:49Z rossb $
@@ -57,15 +56,13 @@ extern "C"
 
 #include 
 
-typedef struct
-{
-    PaUtilRingBuffer   inFIFO;
-    PaUtilRingBuffer   outFIFO;
-    PaStream *stream;
-    int          bytesPerFrame;
-    int          samplesPerFrame;
-}
-PABLIO_Stream;
+	typedef struct {
+		PaUtilRingBuffer inFIFO;
+		PaUtilRingBuffer outFIFO;
+		PaStream *stream;
+		int bytesPerFrame;
+		int samplesPerFrame;
+	} PABLIO_Stream;
 
 /* Values for flags for OpenAudioStream(). */
 #define PABLIO_READ     (1<<0)
@@ -78,25 +75,25 @@ PABLIO_Stream;
  * Write data to ring buffer.
  * Will not return until all the data has been written.
  */
-long WriteAudioStream( PABLIO_Stream *aStream, void *data, long numFrames );
+	long WriteAudioStream(PABLIO_Stream * aStream, void *data, long numFrames);
 
 /************************************************************
  * Read data from ring buffer.
  * Will not return until all the data has been read.
  */
-long ReadAudioStream( PABLIO_Stream *aStream, void *data, long numFrames );
+	long ReadAudioStream(PABLIO_Stream * aStream, void *data, long numFrames);
 
 /************************************************************
  * Return the number of frames that could be written to the stream without
  * having to wait.
  */
-long GetAudioStreamWriteable( PABLIO_Stream *aStream );
+	long GetAudioStreamWriteable(PABLIO_Stream * aStream);
 
 /************************************************************
  * Return the number of frames that are available to be read from the
  * stream without having to wait.
  */
-long GetAudioStreamReadable( PABLIO_Stream *aStream );
+	long GetAudioStreamReadable(PABLIO_Stream * aStream);
 
 /************************************************************
  * Opens a PortAudio stream with default characteristics.
@@ -106,15 +103,14 @@ long GetAudioStreamReadable( PABLIO_Stream *aStream );
  *    PABLIO_READ, PABLIO_WRITE, or PABLIO_READ_WRITE,
  *    and either PABLIO_MONO or PABLIO_STEREO
  */
-PaError OpenAudioStream( PABLIO_Stream **rwblPtr, 
-						 const PaStreamParameters *inputParameters,
-						 const PaStreamParameters *outputParameters,
-						 double sampleRate,
-						 PaStreamCallbackFlags statusFlags);
+	PaError OpenAudioStream(PABLIO_Stream ** rwblPtr,
+							const PaStreamParameters * inputParameters,
+							const PaStreamParameters * outputParameters,
+							double sampleRate, PaStreamCallbackFlags statusFlags);
 
-PaError CloseAudioStream( PABLIO_Stream *aStream );
+	PaError CloseAudioStream(PABLIO_Stream * aStream);
 
 #ifdef __cplusplus
 }
-#endif /* __cplusplus */
-#endif /* _PABLIO_H */
+#endif							/* __cplusplus */
+#endif							/* _PABLIO_H */
diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c
index 16776ec8f7..75fa985a3a 100644
--- a/src/mod/endpoints/mod_sofia/mod_sofia.c
+++ b/src/mod/endpoints/mod_sofia/mod_sofia.c
@@ -41,7 +41,7 @@
 /*************************************************************************************************************************************************************/
 #define HAVE_APR
 #include 
-static const switch_state_handler_table_t noop_state_handler = {0};
+static const switch_state_handler_table_t noop_state_handler = { 0 };
 struct outbound_reg;
 typedef struct outbound_reg outbound_reg_t;
 
@@ -50,7 +50,7 @@ typedef struct sofia_profile sofia_profile_t;
 #define NUA_MAGIC_T sofia_profile_t
 
 struct sofia_private {
-    char uuid[SWITCH_UUID_FORMATTED_LENGTH + 1];
+	char uuid[SWITCH_UUID_FORMATTED_LENGTH + 1];
 	outbound_reg_t *gateway;
 };
 
@@ -87,40 +87,31 @@ static char silence_data[13] = "";
 
 
 static char reg_sql[] =
-"CREATE TABLE sip_registrations (\n"
-"   user            VARCHAR(255),\n"
-"   host            VARCHAR(255),\n"
-"   contact         VARCHAR(1024),\n"
-"   status          VARCHAR(255),\n"
-"   rpid            VARCHAR(255),\n"
-"   expires         INTEGER(8)"
-");\n";
+	"CREATE TABLE sip_registrations (\n"
+	"   user            VARCHAR(255),\n"
+	"   host            VARCHAR(255),\n"
+	"   contact         VARCHAR(1024),\n"
+	"   status          VARCHAR(255),\n" "   rpid            VARCHAR(255),\n" "   expires         INTEGER(8)" ");\n";
 
 
 static char sub_sql[] =
-"CREATE TABLE sip_subscriptions (\n"
-"   proto           VARCHAR(255),\n"
-"   user            VARCHAR(255),\n"
-"   host            VARCHAR(255),\n"
-"   sub_to_user     VARCHAR(255),\n"
-"   sub_to_host     VARCHAR(255),\n"
-"   event           VARCHAR(255),\n"
-"   contact         VARCHAR(1024),\n"
-"   call_id         VARCHAR(255),\n"
-"   full_from       VARCHAR(255),\n"
-"   full_via        VARCHAR(255),\n"
-"   expires         INTEGER(8)"
-");\n";
+	"CREATE TABLE sip_subscriptions (\n"
+	"   proto           VARCHAR(255),\n"
+	"   user            VARCHAR(255),\n"
+	"   host            VARCHAR(255),\n"
+	"   sub_to_user     VARCHAR(255),\n"
+	"   sub_to_host     VARCHAR(255),\n"
+	"   event           VARCHAR(255),\n"
+	"   contact         VARCHAR(1024),\n"
+	"   call_id         VARCHAR(255),\n"
+	"   full_from       VARCHAR(255),\n" "   full_via        VARCHAR(255),\n" "   expires         INTEGER(8)" ");\n";
 
 
 static char auth_sql[] =
-"CREATE TABLE sip_authentication (\n"
-"   user            VARCHAR(255),\n"
-"   host            VARCHAR(255),\n"
-"   passwd            VARCHAR(255),\n"
-"   nonce           VARCHAR(255),\n"
-"   expires         INTEGER(8)"
-");\n";
+	"CREATE TABLE sip_authentication (\n"
+	"   user            VARCHAR(255),\n"
+	"   host            VARCHAR(255),\n"
+	"   passwd            VARCHAR(255),\n" "   nonce           VARCHAR(255),\n" "   expires         INTEGER(8)" ");\n";
 
 static const char modname[] = "mod_sofia";
 #define STRLEN 15
@@ -148,7 +139,7 @@ typedef enum {
 	PFLAG_FULL_ID = (1 << 3),
 	PFLAG_PRESENCE = (1 << 4),
 	PFLAG_PASS_RFC2833 = (1 << 5),
-    PFLAG_DISABLE_TRANSCODING = (1 << 6)
+	PFLAG_DISABLE_TRANSCODING = (1 << 6)
 } PFLAGS;
 
 typedef enum {
@@ -163,9 +154,9 @@ typedef enum {
 	TFLAG_ANS = (1 << 8),
 	TFLAG_EARLY_MEDIA = (1 << 9),
 	TFLAG_SECURE = (1 << 10),
-	TFLAG_VAD_IN = ( 1 << 11),
-	TFLAG_VAD_OUT = ( 1 << 12),
-	TFLAG_VAD = ( 1 << 13),
+	TFLAG_VAD_IN = (1 << 11),
+	TFLAG_VAD_OUT = (1 << 12),
+	TFLAG_VAD = (1 << 13),
 	TFLAG_TIMER = (1 << 14),
 	TFLAG_READY = (1 << 15),
 	TFLAG_REINVITE = (1 << 16),
@@ -186,7 +177,7 @@ static struct {
 	uint32_t callid;
 	int32_t running;
 	switch_mutex_t *mutex;
-    char guess_ip[80];
+	char guess_ip[80];
 } globals;
 
 typedef enum {
@@ -250,7 +241,7 @@ struct sofia_profile {
 	unsigned int flags;
 	unsigned int pflags;
 	uint32_t max_calls;
-    uint32_t nonce_ttl;
+	uint32_t nonce_ttl;
 	nua_t *nua;
 	switch_memory_pool_t *pool;
 	su_root_t *s_root;
@@ -318,7 +309,7 @@ struct private_object {
 	char *chat_from;
 	char *chat_to;
 	char *e_dest;
-    char *call_id;
+	char *call_id;
 	unsigned long rm_rate;
 	switch_payload_t pt;
 	switch_mutex_t *flag_mutex;
@@ -342,7 +333,8 @@ static switch_status_t sofia_on_loopback(switch_core_session_t *session);
 
 static switch_status_t sofia_on_transmit(switch_core_session_t *session);
 
-static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session, switch_caller_profile_t *outbound_profile,
+static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session,
+												  switch_caller_profile_t *outbound_profile,
 												  switch_core_session_t **new_session, switch_memory_pool_t **pool);
 
 static switch_status_t sofia_read_frame(switch_core_session_t *session, switch_frame_t **frame, int timeout,
@@ -355,83 +347,63 @@ static switch_status_t config_sofia(int reload);
 
 static switch_status_t sofia_kill_channel(switch_core_session_t *session, int sig);
 
-static switch_status_t activate_rtp(private_object_t *tech_pvt);
+static switch_status_t activate_rtp(private_object_t * tech_pvt);
 
-static void deactivate_rtp(private_object_t *tech_pvt);
+static void deactivate_rtp(private_object_t * tech_pvt);
 
-static void set_local_sdp(private_object_t *tech_pvt, char *ip, uint32_t port, char *sr, int force);
+static void set_local_sdp(private_object_t * tech_pvt, char *ip, uint32_t port, char *sr, int force);
 
-static void tech_set_codecs(private_object_t *tech_pvt);
+static void tech_set_codecs(private_object_t * tech_pvt);
 
 static void attach_private(switch_core_session_t *session,
-                           sofia_profile_t *profile,
-                           private_object_t *tech_pvt,
-                           const char *channame);
+						   sofia_profile_t * profile, private_object_t * tech_pvt, const char *channame);
 
 static void terminate_session(switch_core_session_t **session, switch_call_cause_t cause, int line);
 
-static switch_status_t tech_choose_port(private_object_t *tech_pvt);
+static switch_status_t tech_choose_port(private_object_t * tech_pvt);
 
 static switch_status_t do_invite(switch_core_session_t *session);
 
-static uint8_t negotiate_sdp(switch_core_session_t *session, sdp_session_t *sdp);
+static uint8_t negotiate_sdp(switch_core_session_t *session, sdp_session_t * sdp);
 
 static char *get_auth_data(char *dbname, char *nonce, char *npassword, size_t len, switch_mutex_t *mutex);
 
-static void establish_presence(sofia_profile_t *profile);
+static void establish_presence(sofia_profile_t * profile);
 
 static void sip_i_state(int status,
-                        char const *phrase,
-                        nua_t *nua,
-                        sofia_profile_t *profile,
-                        nua_handle_t *nh,
-						sofia_private_t *sofia_private,
-                        sip_t const *sip,
-                        tagi_t tags[]);
+						char const *phrase,
+						nua_t * nua,
+						sofia_profile_t * profile,
+						nua_handle_t * nh, sofia_private_t * sofia_private, sip_t const *sip, tagi_t tags[]);
 
 
-static void sip_i_refer(nua_t *nua,
-						sofia_profile_t *profile,
-						nua_handle_t *nh,
-                        switch_core_session_t *session,
-						sip_t const *sip,
-						tagi_t tags[]);
+static void sip_i_refer(nua_t * nua,
+						sofia_profile_t * profile,
+						nua_handle_t * nh, switch_core_session_t *session, sip_t const *sip, tagi_t tags[]);
 
-static void sip_i_info(nua_t *nua,
-                       sofia_profile_t *profile,
-                       nua_handle_t *nh,
-                       switch_core_session_t *session,
-                       sip_t const *sip,
-                       tagi_t tags[]);
+static void sip_i_info(nua_t * nua,
+					   sofia_profile_t * profile,
+					   nua_handle_t * nh, switch_core_session_t *session, sip_t const *sip, tagi_t tags[]);
 
-static void sip_i_invite(nua_t *nua,
-                         sofia_profile_t *profile,
-                         nua_handle_t *nh,
-						 sofia_private_t *sofia_private,
-                         sip_t const *sip,
-                         tagi_t tags[]);
+static void sip_i_invite(nua_t * nua,
+						 sofia_profile_t * profile,
+						 nua_handle_t * nh, sofia_private_t * sofia_private, sip_t const *sip, tagi_t tags[]);
 
-static void sip_i_register(nua_t *nua,
-						   sofia_profile_t *profile,
-						   nua_handle_t *nh,
-						   sofia_private_t *sofia_private,
-						   sip_t const *sip,
-						   tagi_t tags[]);
+static void sip_i_register(nua_t * nua,
+						   sofia_profile_t * profile,
+						   nua_handle_t * nh, sofia_private_t * sofia_private, sip_t const *sip, tagi_t tags[]);
 
-static void event_callback(nua_event_t   event,
-                           int           status,
-                           char const   *phrase,
-                           nua_t        *nua,
-                           sofia_profile_t  *profile,
-                           nua_handle_t *nh,
-						   sofia_private_t *sofia_private,
-                           sip_t const  *sip,
-                           tagi_t        tags[]);
+static void event_callback(nua_event_t event,
+						   int status,
+						   char const *phrase,
+						   nua_t * nua,
+						   sofia_profile_t * profile,
+						   nua_handle_t * nh, sofia_private_t * sofia_private, sip_t const *sip, tagi_t tags[]);
 
 
 static void *SWITCH_THREAD_FUNC profile_thread_run(switch_thread_t *thread, void *obj);
 
-static void launch_profile_thread(sofia_profile_t *profile);
+static void launch_profile_thread(sofia_profile_t * profile);
 
 static switch_status_t chat_send(char *proto, char *from, char *to, char *subject, char *body, char *hint);
 
@@ -456,10 +428,10 @@ static sofia_profile_t *find_profile(char *key)
 	return profile;
 }
 
-static void add_profile(char *key, sofia_profile_t *profile)
+static void add_profile(char *key, sofia_profile_t * profile)
 {
 	switch_mutex_lock(globals.hash_mutex);
-	switch_core_hash_insert(globals.profile_hash, key, profile);	
+	switch_core_hash_insert(globals.profile_hash, key, profile);
 	switch_mutex_unlock(globals.hash_mutex);
 }
 
@@ -474,7 +446,7 @@ static outbound_reg_t *find_gateway(char *key)
 	return gateway;
 }
 
-static void add_gateway(char *key, outbound_reg_t *gateway)
+static void add_gateway(char *key, outbound_reg_t * gateway)
 {
 	switch_mutex_lock(globals.hash_mutex);
 	switch_core_hash_insert(globals.gateway_hash, key, gateway);
@@ -494,12 +466,13 @@ static char *get_url_from_contact(char *buf, uint8_t to_dup)
 
 		*e = '\0';
 	}
-	
+
 	return url;
 }
 
 
-static auth_res_t parse_auth(sofia_profile_t *profile, sip_authorization_t const *authorization, const char *regstr, char *np, size_t nplen)
+static auth_res_t parse_auth(sofia_profile_t * profile, sip_authorization_t const *authorization, const char *regstr,
+							 char *np, size_t nplen)
 {
 	int indexnum;
 	const char *cur;
@@ -513,14 +486,14 @@ static auth_res_t parse_auth(sofia_profile_t *profile, sip_authorization_t const
 	nonce = uri = qop = cnonce = nc = response = NULL;
 
 	if (authorization->au_params) {
-		for(indexnum = 0; (cur=authorization->au_params[indexnum]); indexnum++) {
-			char *var, *val, *p, *work; 
+		for (indexnum = 0; (cur = authorization->au_params[indexnum]); indexnum++) {
+			char *var, *val, *p, *work;
 			var = val = work = NULL;
 			if ((work = strdup(cur))) {
 				var = work;
 				if ((val = strchr(var, '='))) {
 					*val++ = '\0';
-					while(*val == '"') {
+					while (*val == '"') {
 						*val++ = '\0';
 					}
 					if ((p = strchr(val, '"'))) {
@@ -547,7 +520,7 @@ static auth_res_t parse_auth(sofia_profile_t *profile, sip_authorization_t const
 						cnt++;
 					}
 				}
-				
+
 				free(work);
 			}
 		}
@@ -562,7 +535,7 @@ static auth_res_t parse_auth(sofia_profile_t *profile, sip_authorization_t const
 		if (!get_auth_data(profile->dbname, nonce, np, nplen, profile->ireg_mutex)) {
 			ret = AUTH_STALE;
 			goto end;
-		} 
+		}
 	}
 
 	npassword = np;
@@ -588,9 +561,9 @@ static auth_res_t parse_auth(sofia_profile_t *profile, sip_authorization_t const
 		}
 	}
 
- end:
-    switch_safe_free(input);
-    switch_safe_free(input2);
+  end:
+	switch_safe_free(input);
+	switch_safe_free(input2);
 	switch_safe_free(nonce);
 	switch_safe_free(uri);
 	switch_safe_free(qop);
@@ -618,7 +591,7 @@ static void execute_sql(char *dbname, char *sql, switch_mutex_t *mutex)
 	switch_core_db_persistant_execute(db, sql, 25);
 	switch_core_db_close(db);
 
- end:
+  end:
 	if (mutex) {
 		switch_mutex_unlock(mutex);
 	}
@@ -631,7 +604,8 @@ struct callback_t {
 	int matches;
 };
 
-static int find_callback(void *pArg, int argc, char **argv, char **columnNames){
+static int find_callback(void *pArg, int argc, char **argv, char **columnNames)
+{
 	struct callback_t *cbt = (struct callback_t *) pArg;
 
 	switch_copy_string(cbt->val, argv[0], cbt->len);
@@ -639,10 +613,11 @@ static int find_callback(void *pArg, int argc, char **argv, char **columnNames){
 	return 0;
 }
 
-static int del_callback(void *pArg, int argc, char **argv, char **columnNames){
+static int del_callback(void *pArg, int argc, char **argv, char **columnNames)
+{
 	switch_event_t *s_event;
 
-	if (argc >=3 ) {
+	if (argc >= 3) {
 		if (switch_event_create_subclass(&s_event, SWITCH_EVENT_CUSTOM, MY_EVENT_EXPIRE) == SWITCH_STATUS_SUCCESS) {
 			switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "profile-name", "%s", argv[0]);
 			switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "user", "%s", argv[1]);
@@ -655,7 +630,7 @@ static int del_callback(void *pArg, int argc, char **argv, char **columnNames){
 	return 0;
 }
 
-static void check_expire(switch_core_db_t *db, sofia_profile_t *profile, time_t now)
+static void check_expire(switch_core_db_t *db, sofia_profile_t * profile, time_t now)
 {
 	char sql[1024];
 	char *errmsg;
@@ -666,7 +641,8 @@ static void check_expire(switch_core_db_t *db, sofia_profile_t *profile, time_t
 	}
 
 	switch_mutex_lock(profile->ireg_mutex);
-	snprintf(sql, sizeof(sql), "select '%s',* from sip_registrations where expires > 0 and expires < %ld", profile->name, (long) now);	
+	snprintf(sql, sizeof(sql), "select '%s',* from sip_registrations where expires > 0 and expires < %ld",
+			 profile->name, (long) now);
 	switch_core_db_exec(db, sql, del_callback, NULL, &errmsg);
 
 	if (errmsg) {
@@ -674,7 +650,7 @@ static void check_expire(switch_core_db_t *db, sofia_profile_t *profile, time_t
 		switch_safe_free(errmsg);
 		errmsg = NULL;
 	}
-	
+
 	snprintf(sql, sizeof(sql), "delete from sip_registrations where expires > 0 and expires < %ld", (long) now);
 	switch_core_db_persistant_execute(db, sql, 1000);
 	snprintf(sql, sizeof(sql), "delete from sip_authentication where expires > 0 and expires < %ld", (long) now);
@@ -686,15 +662,15 @@ static void check_expire(switch_core_db_t *db, sofia_profile_t *profile, time_t
 
 }
 
-static char *find_reg_url(sofia_profile_t *profile, const char *user, const char *host, char *val, switch_size_t len)
+static char *find_reg_url(sofia_profile_t * profile, const char *user, const char *host, char *val, switch_size_t len)
 {
 	char *errmsg;
-	struct callback_t cbt = {0};
+	struct callback_t cbt = { 0 };
 	switch_core_db_t *db;
 
 	if (!user) {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Called with null user!\n");
-        return NULL;
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Called with null user!\n");
+		return NULL;
 	}
 
 	if (!(db = switch_core_db_open_file(profile->dbname))) {
@@ -706,9 +682,9 @@ static char *find_reg_url(sofia_profile_t *profile, const char *user, const char
 	cbt.len = len;
 	switch_mutex_lock(profile->ireg_mutex);
 	if (host) {
-		snprintf(val, len, "select contact from sip_registrations where user='%s' and host='%s'", user, host);	
+		snprintf(val, len, "select contact from sip_registrations where user='%s' and host='%s'", user, host);
 	} else {
-		snprintf(val, len, "select contact from sip_registrations where user='%s'", user);	
+		snprintf(val, len, "select contact from sip_registrations where user='%s'", user);
 	}
 
 	switch_core_db_exec(db, val, find_callback, &cbt, &errmsg);
@@ -722,19 +698,19 @@ static char *find_reg_url(sofia_profile_t *profile, const char *user, const char
 	switch_mutex_unlock(profile->ireg_mutex);
 
 	switch_core_db_close(db);
-    if (cbt.matches) {
-        return val;
-    } else {
-        return NULL;
-    }
+	if (cbt.matches) {
+		return val;
+	} else {
+		return NULL;
+	}
 }
 
 
-static void set_local_sdp(private_object_t *tech_pvt, char *ip, uint32_t port, char *sr, int force)
+static void set_local_sdp(private_object_t * tech_pvt, char *ip, uint32_t port, char *sr, int force)
 {
 	char buf[2048];
 	switch_time_t now = switch_time_now();
-    int ptime = 0;
+	int ptime = 0;
 	int rate = 0;
 
 	if (!force && !ip && !sr && switch_test_flag(tech_pvt, TFLAG_NOMEDIA)) {
@@ -755,23 +731,11 @@ static void set_local_sdp(private_object_t *tech_pvt, char *ip, uint32_t port, c
 		sr = "sendrecv";
 	}
 
-	snprintf(buf, sizeof(buf), 
+	snprintf(buf, sizeof(buf),
 			 "v=0\n"
-			 "o=FreeSWITCH %d%"SWITCH_TIME_T_FMT" %d%"SWITCH_TIME_T_FMT" IN IP4 %s\n"
+			 "o=FreeSWITCH %d%" SWITCH_TIME_T_FMT " %d%" SWITCH_TIME_T_FMT " IN IP4 %s\n"
 			 "s=FreeSWITCH\n"
-			 "c=IN IP4 %s\n"
-			 "t=0 0\n"
-			 "a=%s\n"
-			 "m=audio %d RTP/AVP",
-			 port,
-			 now,
-			 port,
-			 now,
-			 ip,
-			 ip,
-			 sr,
-			 port
-			 );
+			 "c=IN IP4 %s\n" "t=0 0\n" "a=%s\n" "m=audio %d RTP/AVP", port, now, port, now, ip, ip, sr, port);
 
 	if (tech_pvt->rm_encoding) {
 		snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), " %d", tech_pvt->pt);
@@ -781,9 +745,9 @@ static void set_local_sdp(private_object_t *tech_pvt, char *ip, uint32_t port, c
 			const switch_codec_implementation_t *imp = tech_pvt->codecs[i];
 
 			snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), " %d", imp->ianacode);
-            if (!ptime) {
-                ptime = imp->microseconds_per_frame / 1000;
-            }
+			if (!ptime) {
+				ptime = imp->microseconds_per_frame / 1000;
+			}
 		}
 	}
 
@@ -799,12 +763,13 @@ static void set_local_sdp(private_object_t *tech_pvt, char *ip, uint32_t port, c
 
 	if (tech_pvt->rm_encoding) {
 		rate = tech_pvt->rm_rate;
-		snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=rtpmap:%d %s/%ld\n", tech_pvt->pt, tech_pvt->rm_encoding, tech_pvt->rm_rate);
+		snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=rtpmap:%d %s/%ld\n", tech_pvt->pt,
+				 tech_pvt->rm_encoding, tech_pvt->rm_rate);
 		if (tech_pvt->fmtp_out) {
 			snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=fmtp:%d %s\n", tech_pvt->pt, tech_pvt->fmtp_out);
 		}
-		if (tech_pvt->read_codec.implementation && ! ptime) {
-            ptime = tech_pvt->read_codec.implementation->microseconds_per_frame / 1000;
+		if (tech_pvt->read_codec.implementation && !ptime) {
+			ptime = tech_pvt->read_codec.implementation->microseconds_per_frame / 1000;
 		}
 
 	} else if (tech_pvt->num_codecs) {
@@ -812,27 +777,30 @@ static void set_local_sdp(private_object_t *tech_pvt, char *ip, uint32_t port, c
 		for (i = 0; i < tech_pvt->num_codecs; i++) {
 			const switch_codec_implementation_t *imp = tech_pvt->codecs[i];
 			uint32_t rfc_3551_sucks = imp->samples_per_second;
-			
+
 			if (!rate) {
 				rate = imp->samples_per_second;
 			}
-            if (ptime && ptime != imp->microseconds_per_frame / 1000) {
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "ptime %u != advertised ptime %u\n", imp->microseconds_per_frame / 1000, ptime);
-            }
-			
+			if (ptime && ptime != imp->microseconds_per_frame / 1000) {
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "ptime %u != advertised ptime %u\n",
+								  imp->microseconds_per_frame / 1000, ptime);
+			}
+
 			if (rfc_3551_sucks && imp->ianacode == 9) {
 				rfc_3551_sucks = 8000;
 			}
 
-			snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=rtpmap:%d %s/%d\n", imp->ianacode, imp->iananame, rfc_3551_sucks);
+			snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=rtpmap:%d %s/%d\n", imp->ianacode, imp->iananame,
+					 rfc_3551_sucks);
 			if (imp->fmtp) {
 				snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=fmtp:%d %s\n", imp->ianacode, imp->fmtp);
 			}
 		}
 	}
-	
+
 	if (tech_pvt->te > 95) {
-		snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=rtpmap:%d telephone-event/8000\na=fmtp:%d 0-16\n", tech_pvt->te, tech_pvt->te);
+		snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=rtpmap:%d telephone-event/8000\na=fmtp:%d 0-16\n",
+				 tech_pvt->te, tech_pvt->te);
 	}
 	if (tech_pvt->cng_pt) {
 		snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=rtpmap:%d CN/%d\n", tech_pvt->cng_pt, rate);
@@ -840,18 +808,18 @@ static void set_local_sdp(private_object_t *tech_pvt, char *ip, uint32_t port, c
 			tech_pvt->cng_pt = 0;
 		}
 	}
-    if (ptime) {
-        snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=ptime:%d\n", ptime);
-    }
+	if (ptime) {
+		snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=ptime:%d\n", ptime);
+	}
 
 	tech_pvt->local_sdp_str = switch_core_session_strdup(tech_pvt->session, buf);
 }
 
-static void tech_set_codecs(private_object_t *tech_pvt)
+static void tech_set_codecs(private_object_t * tech_pvt)
 {
-    switch_channel_t *channel;
-    char *abs, *codec_string = NULL;
-    char *ocodec = NULL;
+	switch_channel_t *channel;
+	char *abs, *codec_string = NULL;
+	char *ocodec = NULL;
 
 	if (switch_test_flag(tech_pvt, TFLAG_NOMEDIA)) {
 		return;
@@ -861,53 +829,52 @@ static void tech_set_codecs(private_object_t *tech_pvt)
 		return;
 	}
 
-    assert(tech_pvt->session != NULL);
+	assert(tech_pvt->session != NULL);
 
-    channel = switch_core_session_get_channel(tech_pvt->session);
-    assert (channel != NULL);
+	channel = switch_core_session_get_channel(tech_pvt->session);
+	assert(channel != NULL);
 
 
-    if ((abs = switch_channel_get_variable(channel, "absolute_codec_string"))) {
-        codec_string = abs;
-    } else {
-        if (!(codec_string = switch_channel_get_variable(channel, "codec_string"))) {
+	if ((abs = switch_channel_get_variable(channel, "absolute_codec_string"))) {
+		codec_string = abs;
+	} else {
+		if (!(codec_string = switch_channel_get_variable(channel, "codec_string"))) {
 			if (tech_pvt->profile->codec_string) {
 				codec_string = tech_pvt->profile->codec_string;
 			}
-        }
-        
-        if ((ocodec = switch_channel_get_variable(channel, SWITCH_ORIGINATOR_CODEC_VARIABLE))) {
-            if (!codec_string || (tech_pvt->profile->pflags & PFLAG_DISABLE_TRANSCODING)) {
-                codec_string = ocodec;
-            } else {
+		}
+
+		if ((ocodec = switch_channel_get_variable(channel, SWITCH_ORIGINATOR_CODEC_VARIABLE))) {
+			if (!codec_string || (tech_pvt->profile->pflags & PFLAG_DISABLE_TRANSCODING)) {
+				codec_string = ocodec;
+			} else {
 				if (!(codec_string = switch_core_session_sprintf(tech_pvt->session, "%s,%s", ocodec, codec_string))) {
 					codec_string = ocodec;
 				}
-            }
-        }
-    }
+			}
+		}
+	}
 
 	if (codec_string) {
 		char *tmp_codec_string;
 		if ((tmp_codec_string = switch_core_session_strdup(tech_pvt->session, codec_string))) {
-			tech_pvt->codec_order_last = switch_separate_string(tmp_codec_string, ',', tech_pvt->codec_order, SWITCH_MAX_CODECS);
-			tech_pvt->num_codecs = switch_loadable_module_get_codecs_sorted(tech_pvt->codecs,
-																			SWITCH_MAX_CODECS,
-																			tech_pvt->codec_order,
-																			tech_pvt->codec_order_last);
+			tech_pvt->codec_order_last =
+				switch_separate_string(tmp_codec_string, ',', tech_pvt->codec_order, SWITCH_MAX_CODECS);
+			tech_pvt->num_codecs =
+				switch_loadable_module_get_codecs_sorted(tech_pvt->codecs, SWITCH_MAX_CODECS, tech_pvt->codec_order,
+														 tech_pvt->codec_order_last);
 		}
 	} else {
-		tech_pvt->num_codecs = switch_loadable_module_get_codecs(switch_core_session_get_pool(tech_pvt->session), tech_pvt->codecs,
-																 sizeof(tech_pvt->codecs) / sizeof(tech_pvt->codecs[0]));
+		tech_pvt->num_codecs =
+			switch_loadable_module_get_codecs(switch_core_session_get_pool(tech_pvt->session), tech_pvt->codecs,
+											  sizeof(tech_pvt->codecs) / sizeof(tech_pvt->codecs[0]));
 	}
 
 }
 
 
 static void attach_private(switch_core_session_t *session,
-						   sofia_profile_t *profile,
-						   private_object_t *tech_pvt,
-						   const char *channame)
+						   sofia_profile_t * profile, private_object_t * tech_pvt, const char *channame)
 {
 	switch_channel_t *channel;
 	char name[256];
@@ -918,9 +885,9 @@ static void attach_private(switch_core_session_t *session,
 
 	switch_core_session_add_stream(session, NULL);
 	channel = switch_core_session_get_channel(session);
-	
+
 	//switch_channel_set_flag(channel, CF_ACCEPT_CNG);
-	
+
 	switch_mutex_init(&tech_pvt->flag_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
 	switch_mutex_lock(tech_pvt->flag_mutex);
 	tech_pvt->flags = profile->flags;
@@ -940,47 +907,45 @@ static void attach_private(switch_core_session_t *session,
 
 	tech_pvt->session = session;
 	tech_pvt->home = su_home_new(sizeof(*tech_pvt->home));
-	
+
 	switch_core_session_set_private(session, tech_pvt);
 
 
 	snprintf(name, sizeof(name), "sofia/%s/%s", profile->name, channame);
-    switch_channel_set_name(channel, name);
+	switch_channel_set_name(channel, name);
 	//tech_set_codecs(tech_pvt);
 
 }
 
 static void terminate_session(switch_core_session_t **session, switch_call_cause_t cause, int line)
 {
-    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Term called from line: %d\n", line);
-    if (*session) {
-        switch_channel_t *channel = switch_core_session_get_channel(*session);
-        struct private_object *tech_pvt = NULL;
-        unsigned running = switch_core_session_running(*session);
-        tech_pvt = switch_core_session_get_private(*session);
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Term called from line: %d\n", line);
+	if (*session) {
+		switch_channel_t *channel = switch_core_session_get_channel(*session);
+		struct private_object *tech_pvt = NULL;
+		unsigned running = switch_core_session_running(*session);
+		tech_pvt = switch_core_session_get_private(*session);
 
-        if (running) {
-            switch_channel_hangup(channel, cause);
-        } else {
-            if (tech_pvt) {
-                sofia_on_hangup(*session);
-            }
-            if (session && *session) {
-                switch_core_session_destroy(session);
-            }
-        }
-    }
+		if (running) {
+			switch_channel_hangup(channel, cause);
+		} else {
+			if (tech_pvt) {
+				sofia_on_hangup(*session);
+			}
+			if (session && *session) {
+				switch_core_session_destroy(session);
+			}
+		}
+	}
 }
 
 
 
-static switch_status_t sofia_ext_address_lookup(char **ip, 
-												  switch_port_t *port,
-												  char *sourceip,
-												  switch_memory_pool_t *pool)
+static switch_status_t sofia_ext_address_lookup(char **ip,
+												switch_port_t *port, char *sourceip, switch_memory_pool_t *pool)
 {
 	char *error;
-	
+
 	if (!sourceip) {
 		return SWITCH_STATUS_FALSE;
 	}
@@ -991,13 +956,9 @@ static switch_status_t sofia_ext_address_lookup(char **ip,
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Stun Failed! NO STUN SERVER\n");
 			return SWITCH_STATUS_FALSE;
 		}
-		if (switch_stun_lookup(ip,
-							   port,
-							   stun_ip,
-							   SWITCH_STUN_DEFAULT_PORT,
-							   &error,
-							   pool) != SWITCH_STATUS_SUCCESS) {
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Stun Failed! %s:%d [%s]\n", stun_ip, SWITCH_STUN_DEFAULT_PORT, error);
+		if (switch_stun_lookup(ip, port, stun_ip, SWITCH_STUN_DEFAULT_PORT, &error, pool) != SWITCH_STATUS_SUCCESS) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Stun Failed! %s:%d [%s]\n", stun_ip,
+							  SWITCH_STUN_DEFAULT_PORT, error);
 			return SWITCH_STATUS_FALSE;
 		}
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Stun Success [%s]:[%d]\n", *ip, *port);
@@ -1008,7 +969,7 @@ static switch_status_t sofia_ext_address_lookup(char **ip,
 }
 
 
-static switch_status_t tech_choose_port(private_object_t *tech_pvt)
+static switch_status_t tech_choose_port(private_object_t * tech_pvt)
 {
 	char *ip = tech_pvt->profile->rtpip;
 	switch_channel_t *channel;
@@ -1016,22 +977,22 @@ static switch_status_t tech_choose_port(private_object_t *tech_pvt)
 	char tmp[50];
 
 	channel = switch_core_session_get_channel(tech_pvt->session);
-	
+
 	if (switch_test_flag(tech_pvt, TFLAG_NOMEDIA) || tech_pvt->adv_sdp_audio_port) {
 		return SWITCH_STATUS_SUCCESS;
 	}
-	
+
 	tech_pvt->local_sdp_audio_ip = ip;
 	tech_pvt->local_sdp_audio_port = switch_rtp_request_port();
 	sdp_port = tech_pvt->local_sdp_audio_port;
 
 	if (tech_pvt->profile->extrtpip) {
 		if (sofia_ext_address_lookup(&ip,
-									&sdp_port,
-									tech_pvt->profile->extrtpip,
-									switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
-				terminate_session(&tech_pvt->session, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER, __LINE__);
-				return SWITCH_STATUS_FALSE;
+									 &sdp_port,
+									 tech_pvt->profile->extrtpip,
+									 switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
+			terminate_session(&tech_pvt->session, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER, __LINE__);
+			return SWITCH_STATUS_FALSE;
 		}
 	}
 
@@ -1041,7 +1002,7 @@ static switch_status_t tech_choose_port(private_object_t *tech_pvt)
 	snprintf(tmp, sizeof(tmp), "%d", sdp_port);
 	switch_channel_set_variable(channel, SWITCH_LOCAL_MEDIA_IP_VARIABLE, tech_pvt->adv_sdp_audio_ip);
 	switch_channel_set_variable(channel, SWITCH_LOCAL_MEDIA_PORT_VARIABLE, tmp);
-	
+
 
 	return SWITCH_STATUS_SUCCESS;
 }
@@ -1055,12 +1016,12 @@ static switch_status_t do_invite(switch_core_session_t *session)
 	char *forwardbuf;
 	int forwardval;
 	private_object_t *tech_pvt;
-    switch_channel_t *channel = NULL;
+	switch_channel_t *channel = NULL;
 	switch_caller_profile_t *caller_profile;
 	char *cid_name, *cid_num;
 	char *e_dest = NULL;
 	const char *holdstr = "";
-	switch_stream_handle_t stream = {0};
+	switch_stream_handle_t stream = { 0 };
 	switch_hash_index_t *hi;
 	void *vval;
 	char *extra_headers = NULL;
@@ -1068,26 +1029,27 @@ static switch_status_t do_invite(switch_core_session_t *session)
 	switch_status_t status = SWITCH_STATUS_FALSE;
 	char *rep;
 
-    channel = switch_core_session_get_channel(session);
-    assert(channel != NULL);
+	channel = switch_core_session_get_channel(session);
+	assert(channel != NULL);
 
 	rep = switch_channel_get_variable(channel, SOFIA_REPLACES_HEADER);
 
-    tech_pvt = (private_object_t *) switch_core_session_get_private(session);
-    assert(tech_pvt != NULL);
+	tech_pvt = (private_object_t *) switch_core_session_get_private(session);
+	assert(tech_pvt != NULL);
 
 	caller_profile = switch_channel_get_caller_profile(channel);
 
 	cid_name = (char *) caller_profile->caller_id_name;
 	cid_num = (char *) caller_profile->caller_id_number;
-    tech_set_codecs(tech_pvt);
+	tech_set_codecs(tech_pvt);
 
 	if (!tech_pvt->from_str) {
-		tech_pvt->from_str = switch_core_session_sprintf(tech_pvt->session, "\"%s\" ", 
+		tech_pvt->from_str = switch_core_session_sprintf(tech_pvt->session, "\"%s\" ",
 														 cid_name,
 														 cid_num,
-														 tech_pvt->profile->extsipip ? tech_pvt->profile->extsipip : tech_pvt->profile->sipip);
-		
+														 tech_pvt->profile->extsipip ? tech_pvt->profile->
+														 extsipip : tech_pvt->profile->sipip);
+
 	}
 
 	if (!tech_pvt->from_str) {
@@ -1110,7 +1072,7 @@ static switch_status_t do_invite(switch_core_session_t *session)
 	if (tech_choose_port(tech_pvt) != SWITCH_STATUS_SUCCESS) {
 		return status;
 	}
-        
+
 	set_local_sdp(tech_pvt, NULL, 0, NULL, 0);
 
 	switch_set_flag_locked(tech_pvt, TFLAG_READY);
@@ -1131,25 +1093,26 @@ static switch_status_t do_invite(switch_core_session_t *session)
 			screen = "yes";
 		}
 
-		snprintf(rpid, sizeof(rpid) - 1, "Remote-Party-ID: %s;party=calling;screen=%s;privacy=%s", tech_pvt->from_str, screen, priv);
-								
+		snprintf(rpid, sizeof(rpid) - 1, "Remote-Party-ID: %s;party=calling;screen=%s;privacy=%s", tech_pvt->from_str,
+				 screen, priv);
+
 	}
 
 	if (!tech_pvt->nh) {
-		char *url =  get_url_from_contact(tech_pvt->dest, 1);
+		char *url = get_url_from_contact(tech_pvt->dest, 1);
 		tech_pvt->nh = nua_handle(tech_pvt->profile->nua, NULL,
 								  NUTAG_URL(url),
 								  SIPTAG_TO_STR(tech_pvt->dest_to),
 								  SIPTAG_FROM_STR(tech_pvt->from_str),
-								  SIPTAG_CONTACT_STR(tech_pvt->profile->url),
-								  TAG_END());
+								  SIPTAG_CONTACT_STR(tech_pvt->profile->url), TAG_END());
 		switch_safe_free(url);
 
 		if (!(tech_pvt->sofia_private = malloc(sizeof(*tech_pvt->sofia_private)))) {
 			abort();
 		}
 		memset(tech_pvt->sofia_private, 0, sizeof(*tech_pvt->sofia_private));
-		switch_copy_string(tech_pvt->sofia_private->uuid, switch_core_session_get_uuid(session), sizeof(tech_pvt->sofia_private->uuid));
+		switch_copy_string(tech_pvt->sofia_private->uuid, switch_core_session_get_uuid(session),
+						   sizeof(tech_pvt->sofia_private->uuid));
 		nua_handle_bind(tech_pvt->nh, tech_pvt->sofia_private);
 
 	}
@@ -1168,14 +1131,15 @@ static switch_status_t do_invite(switch_core_session_t *session)
 		tech_pvt->chat_to = tech_pvt->dest;
 		tech_pvt->hash_key = switch_core_session_strdup(tech_pvt->session, hash_key);
 		switch_core_hash_insert(tech_pvt->profile->chat_hash, tech_pvt->hash_key, tech_pvt);
-		free(e_dest);			
+		free(e_dest);
 	}
 
 	holdstr = switch_test_flag(tech_pvt, TFLAG_SIP_HOLD) ? "*" : "";
 
 
 	SWITCH_STANDARD_STREAM(stream);
-	for (hi = switch_channel_variable_first(channel, switch_core_session_get_pool(tech_pvt->session)); hi; hi = switch_hash_next(hi)) {
+	for (hi = switch_channel_variable_first(channel, switch_core_session_get_pool(tech_pvt->session)); hi;
+		 hi = switch_hash_next(hi)) {
 		switch_hash_this(hi, &vvar, NULL, &vval);
 		if (vvar && vval) {
 			const char *name = vvar;
@@ -1187,7 +1151,7 @@ static switch_status_t do_invite(switch_core_session_t *session)
 			}
 		}
 	}
-		
+
 	if (stream.data) {
 		extra_headers = stream.data;
 	}
@@ -1196,19 +1160,17 @@ static switch_status_t do_invite(switch_core_session_t *session)
 			   TAG_IF(!switch_strlen_zero(rpid), SIPTAG_HEADER_STR(rpid)),
 			   TAG_IF(!switch_strlen_zero(alert_info), SIPTAG_HEADER_STR(alert_info)),
 			   TAG_IF(!switch_strlen_zero(extra_headers), SIPTAG_HEADER_STR(extra_headers)),
-			   TAG_IF(!switch_strlen_zero(max_forwards),SIPTAG_MAX_FORWARDS_STR(max_forwards)),
+			   TAG_IF(!switch_strlen_zero(max_forwards), SIPTAG_MAX_FORWARDS_STR(max_forwards)),
 			   //SIPTAG_CONTACT_STR(tech_pvt->profile->url),
 			   SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str),
 			   SOATAG_RTP_SORT(SOA_RTP_SORT_REMOTE),
 			   SOATAG_RTP_SELECT(SOA_RTP_SELECT_ALL),
-			   TAG_IF(rep, SIPTAG_REPLACES_STR(rep)),
-			   SOATAG_HOLD(holdstr),
-			   TAG_END());
-		
+			   TAG_IF(rep, SIPTAG_REPLACES_STR(rep)), SOATAG_HOLD(holdstr), TAG_END());
+
 	switch_safe_free(stream.data);
 
 	return SWITCH_STATUS_SUCCESS;
-	
+
 }
 
 
@@ -1217,34 +1179,33 @@ static void do_xfer_invite(switch_core_session_t *session)
 {
 	char rpid[1024];
 	private_object_t *tech_pvt;
-    switch_channel_t *channel = NULL;
+	switch_channel_t *channel = NULL;
 	switch_caller_profile_t *caller_profile;
 
-    channel = switch_core_session_get_channel(session);
-    assert(channel != NULL);
+	channel = switch_core_session_get_channel(session);
+	assert(channel != NULL);
 
-    tech_pvt = (private_object_t *) switch_core_session_get_private(session);
-    assert(tech_pvt != NULL);
+	tech_pvt = (private_object_t *) switch_core_session_get_private(session);
+	assert(tech_pvt != NULL);
 
 	caller_profile = switch_channel_get_caller_profile(channel);
 
-	
 
-	if ((tech_pvt->from_str = switch_core_session_sprintf(session, "\"%s\" ", 
-														 (char *) caller_profile->caller_id_name, 
-														 (char *) caller_profile->caller_id_number,
-														 tech_pvt->profile->extsipip ? tech_pvt->profile->extsipip : tech_pvt->profile->sipip
-														 ))) {
+
+	if ((tech_pvt->from_str = switch_core_session_sprintf(session, "\"%s\" ",
+														  (char *) caller_profile->caller_id_name,
+														  (char *) caller_profile->caller_id_number,
+														  tech_pvt->profile->extsipip ? tech_pvt->profile->
+														  extsipip : tech_pvt->profile->sipip))) {
 
 		char *rep = switch_channel_get_variable(channel, SOFIA_REPLACES_HEADER);
 
 		tech_pvt->nh2 = nua_handle(tech_pvt->profile->nua, NULL,
-								  SIPTAG_TO_STR(tech_pvt->dest),
-								  SIPTAG_FROM_STR(tech_pvt->from_str),
-								  SIPTAG_CONTACT_STR(tech_pvt->profile->url),
-								  TAG_END());
-			
-        
+								   SIPTAG_TO_STR(tech_pvt->dest),
+								   SIPTAG_FROM_STR(tech_pvt->from_str),
+								   SIPTAG_CONTACT_STR(tech_pvt->profile->url), TAG_END());
+
+
 		nua_handle_bind(tech_pvt->nh2, tech_pvt->sofia_private);
 
 		nua_invite(tech_pvt->nh2,
@@ -1252,16 +1213,14 @@ static void do_xfer_invite(switch_core_session_t *session)
 				   SIPTAG_CONTACT_STR(tech_pvt->profile->url),
 				   SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str),
 				   SOATAG_RTP_SORT(SOA_RTP_SORT_REMOTE),
-				   SOATAG_RTP_SELECT(SOA_RTP_SELECT_ALL),
-				   TAG_IF(rep, SIPTAG_REPLACES_STR(rep)),
-				   TAG_END());
+				   SOATAG_RTP_SELECT(SOA_RTP_SELECT_ALL), TAG_IF(rep, SIPTAG_REPLACES_STR(rep)), TAG_END());
 	} else {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Memory Error!\n");
 	}
-	
+
 }
 
-static void tech_absorb_sdp(private_object_t *tech_pvt)
+static void tech_absorb_sdp(private_object_t * tech_pvt)
 {
 	switch_channel_t *channel;
 	char *sdp_str;
@@ -1275,9 +1234,9 @@ static void tech_absorb_sdp(private_object_t *tech_pvt)
 		sdp_media_t *m;
 		sdp_connection_t *connection;
 
-		if ((parser = sdp_parse(tech_pvt->home, sdp_str, (int)strlen(sdp_str), 0))) {
+		if ((parser = sdp_parse(tech_pvt->home, sdp_str, (int) strlen(sdp_str), 0))) {
 			if ((sdp = sdp_session(parser))) {
-				for (m = sdp->sdp_media; m ; m = m->m_next) {
+				for (m = sdp->sdp_media; m; m = m->m_next) {
 					if (m->m_type != sdp_media_audio) {
 						continue;
 					}
@@ -1288,16 +1247,17 @@ static void tech_absorb_sdp(private_object_t *tech_pvt)
 					}
 
 					if (connection) {
-						tech_pvt->proxy_sdp_audio_ip = switch_core_session_strdup(tech_pvt->session, connection->c_address);
+						tech_pvt->proxy_sdp_audio_ip =
+							switch_core_session_strdup(tech_pvt->session, connection->c_address);
 					}
-					tech_pvt->proxy_sdp_audio_port = (switch_port_t)m->m_port;
+					tech_pvt->proxy_sdp_audio_port = (switch_port_t) m->m_port;
 					if (tech_pvt->proxy_sdp_audio_ip && tech_pvt->proxy_sdp_audio_port) {
 						break;
 					}
 				}
 			}
 			sdp_parser_free(parser);
-		}	
+		}
 		tech_pvt->local_sdp_str = switch_core_session_strdup(tech_pvt->session, sdp_str);
 	}
 }
@@ -1311,7 +1271,7 @@ static switch_status_t sofia_on_init(switch_core_session_t *session)
 {
 	private_object_t *tech_pvt;
 	switch_channel_t *channel = NULL;
-	
+
 	channel = switch_core_session_get_channel(session);
 	assert(channel != NULL);
 
@@ -1331,7 +1291,7 @@ static switch_status_t sofia_on_init(switch_core_session_t *session)
 			return SWITCH_STATUS_FALSE;
 		}
 	}
-	
+
 	/* Move Channel's State Machine to RING */
 	switch_channel_set_state(channel, CS_RING);
 	return SWITCH_STATUS_SUCCESS;
@@ -1371,7 +1331,8 @@ static switch_status_t sofia_on_execute(switch_core_session_t *session)
 }
 
 // map QSIG cause codes to SIP from RFC4497 section 8.4.1
-static int hangup_cause_to_sip(switch_call_cause_t cause) {
+static int hangup_cause_to_sip(switch_call_cause_t cause)
+{
 	switch (cause) {
 	case SWITCH_CAUSE_NO_ROUTE_TRANSIT_NET:
 	case SWITCH_CAUSE_NO_ROUTE_DESTINATION:
@@ -1405,7 +1366,7 @@ static int hangup_cause_to_sip(switch_call_cause_t cause) {
 		return 503;
 	case SWITCH_CAUSE_OUTGOING_CALL_BARRED:
 	case SWITCH_CAUSE_INCOMING_CALL_BARRED:
-	case SWITCH_CAUSE_BEARERCAPABILITY_NOTAUTH: 
+	case SWITCH_CAUSE_BEARERCAPABILITY_NOTAUTH:
 		return 403;
 	case SWITCH_CAUSE_BEARERCAPABILITY_NOTAVAIL:
 		return 503;
@@ -1445,7 +1406,7 @@ static switch_status_t sofia_on_hangup(switch_core_session_t *session)
 
 	deactivate_rtp(tech_pvt);
 
-	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Channel %s hanging up, cause: %s\n", 
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Channel %s hanging up, cause: %s\n",
 					  switch_channel_get_name(channel), switch_channel_cause2str(cause));
 
 	if (tech_pvt->hash_key) {
@@ -1461,14 +1422,17 @@ static switch_status_t sofia_on_hangup(switch_core_session_t *session)
 	if (tech_pvt->nh) {
 		if (!switch_test_flag(tech_pvt, TFLAG_BYE)) {
 			if (switch_test_flag(tech_pvt, TFLAG_ANS)) {
-				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Sending BYE to %s\n", switch_channel_get_name(channel));
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Sending BYE to %s\n",
+								  switch_channel_get_name(channel));
 				nua_bye(tech_pvt->nh, TAG_END());
 			} else {
 				if (!switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) {
-					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Responding to INVITE with: %d\n", sip_cause);
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Responding to INVITE with: %d\n",
+									  sip_cause);
 					nua_respond(tech_pvt->nh, sip_cause, NULL, TAG_END());
 				} else {
-					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Sending CANCEL to %s\n", switch_channel_get_name(channel));
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Sending CANCEL to %s\n",
+									  switch_channel_get_name(channel));
 					nua_cancel(tech_pvt->nh, TAG_END());
 				}
 			}
@@ -1483,9 +1447,9 @@ static switch_status_t sofia_on_hangup(switch_core_session_t *session)
 		tech_pvt->home = NULL;
 	}
 
-    if (tech_pvt->sofia_private) {
-        *tech_pvt->sofia_private->uuid = '\0';
-    }
+	if (tech_pvt->sofia_private) {
+		*tech_pvt->sofia_private->uuid = '\0';
+	}
 
 	return SWITCH_STATUS_SUCCESS;
 }
@@ -1502,9 +1466,9 @@ static switch_status_t sofia_on_transmit(switch_core_session_t *session)
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static void deactivate_rtp(private_object_t *tech_pvt)
+static void deactivate_rtp(private_object_t * tech_pvt)
 {
-	int loops = 0;//, sock = -1;
+	int loops = 0;				//, sock = -1;
 	if (switch_rtp_ready(tech_pvt->rtp_session)) {
 		while (loops < 10 && (switch_test_flag(tech_pvt, TFLAG_READING) || switch_test_flag(tech_pvt, TFLAG_WRITING))) {
 			switch_yield(10000);
@@ -1514,7 +1478,7 @@ static void deactivate_rtp(private_object_t *tech_pvt)
 	}
 }
 
-static switch_status_t tech_set_codec(private_object_t *tech_pvt, int force)
+static switch_status_t tech_set_codec(private_object_t * tech_pvt, int force)
 {
 	switch_channel_t *channel;
 
@@ -1527,9 +1491,9 @@ static switch_status_t tech_set_codec(private_object_t *tech_pvt, int force)
 
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Changing Codec from %s to %s\n",
 							  tech_pvt->read_codec.implementation->iananame, tech_pvt->rm_encoding);
-		switch_core_codec_destroy(&tech_pvt->read_codec);
-		switch_core_codec_destroy(&tech_pvt->write_codec);
-		switch_core_session_reset(tech_pvt->session);
+			switch_core_codec_destroy(&tech_pvt->read_codec);
+			switch_core_codec_destroy(&tech_pvt->write_codec);
+			switch_core_session_reset(tech_pvt->session);
 		} else {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Already using %s\n",
 							  tech_pvt->read_codec.implementation->iananame);
@@ -1546,15 +1510,14 @@ static switch_status_t tech_set_codec(private_object_t *tech_pvt, int force)
 		return SWITCH_STATUS_FALSE;
 	}
 
-	if (switch_core_codec_init(&tech_pvt->read_codec,  
+	if (switch_core_codec_init(&tech_pvt->read_codec,
 							   tech_pvt->rm_encoding,
 							   tech_pvt->rm_fmtp,
 							   tech_pvt->rm_rate,
 							   tech_pvt->codec_ms,
 							   1,
 							   SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE | tech_pvt->profile->codec_flags,
-							   NULL,
-							   switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
+							   NULL, switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n");
 		terminate_session(&tech_pvt->session, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER, __LINE__);
 		return SWITCH_STATUS_FALSE;
@@ -1566,8 +1529,7 @@ static switch_status_t tech_set_codec(private_object_t *tech_pvt, int force)
 								   tech_pvt->codec_ms,
 								   1,
 								   SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE | tech_pvt->profile->codec_flags,
-								   NULL,
-								   switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
+								   NULL, switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n");
 			terminate_session(&tech_pvt->session, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER, __LINE__);
 			return SWITCH_STATUS_FALSE;
@@ -1579,7 +1541,7 @@ static switch_status_t tech_set_codec(private_object_t *tech_pvt, int force)
 							  switch_channel_get_name(channel),
 							  tech_pvt->rm_encoding, tech_pvt->rm_rate, tech_pvt->codec_ms);
 			tech_pvt->read_frame.codec = &tech_pvt->read_codec;
-				
+
 			switch_core_session_set_read_codec(tech_pvt->session, &tech_pvt->read_codec);
 			switch_core_session_set_write_codec(tech_pvt->session, &tech_pvt->write_codec);
 			tech_pvt->fmtp_out = switch_core_session_strdup(tech_pvt->session, tech_pvt->write_codec.fmtp_out);
@@ -1589,12 +1551,12 @@ static switch_status_t tech_set_codec(private_object_t *tech_pvt, int force)
 }
 
 
-static switch_status_t activate_rtp(private_object_t *tech_pvt)
+static switch_status_t activate_rtp(private_object_t * tech_pvt)
 {
 	int bw, ms;
 	switch_channel_t *channel;
 	const char *err = NULL;
-    char *val = NULL;
+	char *val = NULL;
 	switch_rtp_flag_t flags;
 	switch_status_t status;
 	char tmp[50];
@@ -1614,7 +1576,7 @@ static switch_status_t activate_rtp(private_object_t *tech_pvt)
 	if ((status = tech_set_codec(tech_pvt, 0)) != SWITCH_STATUS_SUCCESS) {
 		return status;
 	}
-	
+
 	bw = tech_pvt->read_codec.implementation->bits_per_second;
 	ms = tech_pvt->read_codec.implementation->microseconds_per_frame;
 
@@ -1624,9 +1586,10 @@ static switch_status_t activate_rtp(private_object_t *tech_pvt)
 		flags |= SWITCH_RTP_FLAG_BUGGY_2833;
 	}
 
-    if ((tech_pvt->profile->pflags & PFLAG_PASS_RFC2833) || ((val = switch_channel_get_variable(channel, "pass_rfc2833")) && switch_true(val))) {
-        flags |= SWITCH_RTP_FLAG_PASS_RFC2833;
-    }
+	if ((tech_pvt->profile->pflags & PFLAG_PASS_RFC2833)
+		|| ((val = switch_channel_get_variable(channel, "pass_rfc2833")) && switch_true(val))) {
+		flags |= SWITCH_RTP_FLAG_PASS_RFC2833;
+	}
 
 	if (tech_pvt->cng_pt) {
 		flags |= SWITCH_RTP_FLAG_AUTO_CNG;
@@ -1638,26 +1601,24 @@ static switch_status_t activate_rtp(private_object_t *tech_pvt)
 					  tech_pvt->local_sdp_audio_port,
 					  tech_pvt->remote_sdp_audio_ip,
 					  tech_pvt->remote_sdp_audio_port,
-					  tech_pvt->agreed_pt,
-					  tech_pvt->read_codec.implementation->microseconds_per_frame / 1000);
+					  tech_pvt->agreed_pt, tech_pvt->read_codec.implementation->microseconds_per_frame / 1000);
 
 	snprintf(tmp, sizeof(tmp), "%d", tech_pvt->remote_sdp_audio_port);
 	switch_channel_set_variable(channel, SWITCH_LOCAL_MEDIA_IP_VARIABLE, tech_pvt->adv_sdp_audio_ip);
 	switch_channel_set_variable(channel, SWITCH_LOCAL_MEDIA_PORT_VARIABLE, tmp);
-	
+
 	if (tech_pvt->rtp_session && switch_test_flag(tech_pvt, TFLAG_REINVITE)) {
 		switch_clear_flag_locked(tech_pvt, TFLAG_REINVITE);
-		
+
 		if (switch_rtp_set_remote_address(tech_pvt->rtp_session,
 										  tech_pvt->remote_sdp_audio_ip,
-										  tech_pvt->remote_sdp_audio_port,
-										  &err) != SWITCH_STATUS_SUCCESS) {
+										  tech_pvt->remote_sdp_audio_port, &err) != SWITCH_STATUS_SUCCESS) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "RTP REPORTS ERROR: [%s]\n", err);
 		} else {
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "RTP CHANGING DEST TO: [%s:%d]\n", 
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "RTP CHANGING DEST TO: [%s:%d]\n",
 							  tech_pvt->remote_sdp_audio_ip, tech_pvt->remote_sdp_audio_port);
-            /* Reactivate the NAT buster flag. */
-            switch_rtp_set_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_AUTOADJ);
+			/* Reactivate the NAT buster flag. */
+			switch_rtp_set_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_AUTOADJ);
 		}
 		return SWITCH_STATUS_SUCCESS;
 	}
@@ -1672,9 +1633,8 @@ static switch_status_t activate_rtp(private_object_t *tech_pvt)
 										   (switch_rtp_flag_t) flags,
 										   NULL,
 										   tech_pvt->profile->timer_name,
-										   &err,
-										   switch_core_session_get_pool(tech_pvt->session));
-	
+										   &err, switch_core_session_get_pool(tech_pvt->session));
+
 	if (switch_rtp_ready(tech_pvt->rtp_session)) {
 		uint8_t vad_in = switch_test_flag(tech_pvt, TFLAG_VAD_IN) ? 1 : 0;
 		uint8_t vad_out = switch_test_flag(tech_pvt, TFLAG_VAD_OUT) ? 1 : 0;
@@ -1683,13 +1643,14 @@ static switch_status_t activate_rtp(private_object_t *tech_pvt)
 		tech_pvt->ssrc = switch_rtp_get_ssrc(tech_pvt->rtp_session);
 		switch_set_flag_locked(tech_pvt, TFLAG_RTP);
 		switch_set_flag_locked(tech_pvt, TFLAG_IO);
-		
+
 		if ((vad_in && inb) || (vad_out && !inb)) {
-			switch_rtp_enable_vad(tech_pvt->rtp_session, tech_pvt->session, &tech_pvt->read_codec, SWITCH_VAD_FLAG_TALKING);
+			switch_rtp_enable_vad(tech_pvt->rtp_session, tech_pvt->session, &tech_pvt->read_codec,
+								  SWITCH_VAD_FLAG_TALKING);
 			switch_set_flag_locked(tech_pvt, TFLAG_VAD);
-            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "RTP Engage VAD for %s ( %s %s )\n", 
-                              switch_channel_get_name(switch_core_session_get_channel(tech_pvt->session)),
-                              vad_in ? "in" : "", vad_out ? "out" : "");
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "RTP Engage VAD for %s ( %s %s )\n",
+							  switch_channel_get_name(switch_core_session_get_channel(tech_pvt->session)),
+							  vad_in ? "in" : "", vad_out ? "out" : "");
 		}
 
 		if (tech_pvt->te) {
@@ -1698,53 +1659,53 @@ static switch_status_t activate_rtp(private_object_t *tech_pvt)
 		if (tech_pvt->cng_pt) {
 			switch_rtp_set_cng_pt(tech_pvt->rtp_session, tech_pvt->cng_pt);
 		}
-		
+
 	} else {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "RTP REPORTS ERROR: [%s]\n", err);
 		terminate_session(&tech_pvt->session, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER, __LINE__);
 		switch_clear_flag_locked(tech_pvt, TFLAG_IO);
 		return SWITCH_STATUS_FALSE;
 	}
-		
+
 	switch_set_flag_locked(tech_pvt, TFLAG_IO);
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status_t tech_media(private_object_t *tech_pvt, char *r_sdp)
+static switch_status_t tech_media(private_object_t * tech_pvt, char *r_sdp)
 {
-    sdp_parser_t *parser = sdp_parse(tech_pvt->home, r_sdp, (int)strlen(r_sdp), 0);
-    sdp_session_t *sdp;
-    uint8_t match = 0;
-    switch_channel_t *channel = switch_core_session_get_channel(tech_pvt->session);
+	sdp_parser_t *parser = sdp_parse(tech_pvt->home, r_sdp, (int) strlen(r_sdp), 0);
+	sdp_session_t *sdp;
+	uint8_t match = 0;
+	switch_channel_t *channel = switch_core_session_get_channel(tech_pvt->session);
 
-    assert(tech_pvt != NULL);
+	assert(tech_pvt != NULL);
 
-    if (switch_strlen_zero(r_sdp)) {
-        return SWITCH_STATUS_FALSE;
-    }
+	if (switch_strlen_zero(r_sdp)) {
+		return SWITCH_STATUS_FALSE;
+	}
 
-    if (tech_pvt->num_codecs) {
-        if ((sdp = sdp_session(parser))) {
-            match = negotiate_sdp(tech_pvt->session, sdp);
-        }
-    }
+	if (tech_pvt->num_codecs) {
+		if ((sdp = sdp_session(parser))) {
+			match = negotiate_sdp(tech_pvt->session, sdp);
+		}
+	}
 
-    if (parser) {
-        sdp_parser_free(parser);
-    }
+	if (parser) {
+		sdp_parser_free(parser);
+	}
 
-    if (match) {
-        if (tech_choose_port(tech_pvt) != SWITCH_STATUS_SUCCESS) {
-            return SWITCH_STATUS_FALSE;
-        }
-        activate_rtp(tech_pvt);
-        switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "EARLY MEDIA");
-        switch_set_flag_locked(tech_pvt, TFLAG_EARLY_MEDIA);
-        switch_channel_mark_pre_answered(channel);
-        return SWITCH_STATUS_SUCCESS;
-    }
-    
-    return SWITCH_STATUS_FALSE;
+	if (match) {
+		if (tech_choose_port(tech_pvt) != SWITCH_STATUS_SUCCESS) {
+			return SWITCH_STATUS_FALSE;
+		}
+		activate_rtp(tech_pvt);
+		switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "EARLY MEDIA");
+		switch_set_flag_locked(tech_pvt, TFLAG_EARLY_MEDIA);
+		switch_channel_mark_pre_answered(channel);
+		return SWITCH_STATUS_SUCCESS;
+	}
+
+	return SWITCH_STATUS_FALSE;
 }
 
 
@@ -1762,7 +1723,7 @@ static switch_status_t sofia_answer_channel(switch_core_session_t *session)
 
 	tech_pvt = (private_object_t *) switch_core_session_get_private(session);
 	assert(tech_pvt != NULL);
-    
+
 	if (!switch_test_flag(tech_pvt, TFLAG_ANS) && !switch_channel_test_flag(channel, CF_OUTBOUND)) {
 		switch_set_flag_locked(tech_pvt, TFLAG_ANS);
 
@@ -1776,7 +1737,8 @@ static switch_status_t sofia_answer_channel(switch_core_session_t *session)
 			if (switch_test_flag(tech_pvt, TFLAG_LATE_NEGOTIATION)) {
 				char *r_sdp = switch_channel_get_variable(channel, SWITCH_R_SDP_VARIABLE);
 				if (tech_media(tech_pvt, r_sdp) != SWITCH_STATUS_SUCCESS) {
-					switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "CODEC NEGOTIATION ERROR");
+					switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE,
+												"CODEC NEGOTIATION ERROR");
 					nua_respond(tech_pvt->nh, SIP_488_NOT_ACCEPTABLE, TAG_END());
 					return SWITCH_STATUS_FALSE;
 				}
@@ -1789,22 +1751,19 @@ static switch_status_t sofia_answer_channel(switch_core_session_t *session)
 
 			set_local_sdp(tech_pvt, NULL, 0, NULL, 0);
 			activate_rtp(tech_pvt);
-		
+
 			if (tech_pvt->nh) {
 				if (tech_pvt->local_sdp_str) {
 					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Local SDP %s:\n%s\n",
-									  switch_channel_get_name(channel),
-								  tech_pvt->local_sdp_str);
+									  switch_channel_get_name(channel), tech_pvt->local_sdp_str);
 				}
 			}
 		}
-		nua_respond(tech_pvt->nh, SIP_200_OK, 
+		nua_respond(tech_pvt->nh, SIP_200_OK,
 					SIPTAG_CONTACT_STR(tech_pvt->profile->url),
 					SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str),
-					SOATAG_AUDIO_AUX("cn telephone-event"),
-					NUTAG_INCLUDE_EXTRA_SDP(1),
-					TAG_END());
-	} 
+					SOATAG_AUDIO_AUX("cn telephone-event"), NUTAG_INCLUDE_EXTRA_SDP(1), TAG_END());
+	}
 
 	return SWITCH_STATUS_SUCCESS;
 }
@@ -1816,7 +1775,7 @@ static switch_status_t sofia_read_frame(switch_core_session_t *session, switch_f
 	private_object_t *tech_pvt = NULL;
 	switch_channel_t *channel = NULL;
 	int payload = 0;
-	
+
 	channel = switch_core_session_get_channel(session);
 	assert(channel != NULL);
 
@@ -1839,9 +1798,9 @@ static switch_status_t sofia_read_frame(switch_core_session_t *session, switch_f
 	tech_pvt->read_frame.datalen = 0;
 	switch_set_flag_locked(tech_pvt, TFLAG_READING);
 
-#if 0	
+#if 0
 	if (tech_pvt->last_read) {
-		elapsed = (unsigned int)((switch_time_now() - tech_pvt->last_read) / 1000);
+		elapsed = (unsigned int) ((switch_time_now() - tech_pvt->last_read) / 1000);
 		if (elapsed > 60000) {
 			return SWITCH_STATUS_TIMEOUT;
 		}
@@ -1868,20 +1827,20 @@ static switch_status_t sofia_read_frame(switch_core_session_t *session, switch_f
 				return SWITCH_STATUS_FALSE;
 			}
 
-			
-			
+
+
 			payload = tech_pvt->read_frame.payload;
 
 #if 0
-			elapsed = (unsigned int)((switch_time_now() - started) / 1000);
+			elapsed = (unsigned int) ((switch_time_now() - started) / 1000);
 
 			if (timeout > -1) {
-				if (elapsed >= (unsigned int)timeout) {
+				if (elapsed >= (unsigned int) timeout) {
 					return SWITCH_STATUS_BREAK;
 				}
 			}
-			
-			elapsed = (unsigned int)((switch_time_now() - last_act) / 1000);
+
+			elapsed = (unsigned int) ((switch_time_now() - last_act) / 1000);
 			if (elapsed >= hard_timeout) {
 				return SWITCH_STATUS_BREAK;
 			}
@@ -1894,20 +1853,21 @@ static switch_status_t sofia_read_frame(switch_core_session_t *session, switch_f
 
 
 			if (tech_pvt->read_frame.datalen > 0) {
-                size_t bytes = 0;
-                int frames = 1;
+				size_t bytes = 0;
+				int frames = 1;
 
-                if (!switch_test_flag((&tech_pvt->read_frame), SFF_CNG)) {
-                    if ((bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame)) {
-                        frames = (tech_pvt->read_frame.datalen / bytes);
-                    }
-                    tech_pvt->read_frame.samples = (int) (frames * tech_pvt->read_codec.implementation->samples_per_frame);
-                }
+				if (!switch_test_flag((&tech_pvt->read_frame), SFF_CNG)) {
+					if ((bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame)) {
+						frames = (tech_pvt->read_frame.datalen / bytes);
+					}
+					tech_pvt->read_frame.samples =
+						(int) (frames * tech_pvt->read_codec.implementation->samples_per_frame);
+				}
 				break;
 			}
 		}
 	}
-	
+
 	switch_clear_flag_locked(tech_pvt, TFLAG_READING);
 
 	if (tech_pvt->read_frame.datalen == 0) {
@@ -1966,16 +1926,11 @@ static switch_status_t sofia_write_frame(switch_core_session_t *session, switch_
 
 		samples = frames * tech_pvt->read_codec.implementation->samples_per_frame;
 	}
-
 #if 0
 	printf("%s %s->%s send %d bytes %d samples in %d frames ts=%d\n",
 		   switch_channel_get_name(channel),
 		   tech_pvt->local_sdp_audio_ip,
-		   tech_pvt->remote_sdp_audio_ip,
-		   frame->datalen,
-		   samples,
-		   frames,
-		   tech_pvt->timestamp_send);
+		   tech_pvt->remote_sdp_audio_ip, frame->datalen, samples, frames, tech_pvt->timestamp_send);
 #endif
 
 	tech_pvt->timestamp_send += samples;
@@ -2000,22 +1955,22 @@ static switch_status_t sofia_kill_channel(switch_core_session_t *session, int si
 	assert(tech_pvt != NULL);
 
 
-    switch(sig) {
-    case SWITCH_SIG_BREAK:
-        if (switch_rtp_ready(tech_pvt->rtp_session)) {
+	switch (sig) {
+	case SWITCH_SIG_BREAK:
+		if (switch_rtp_ready(tech_pvt->rtp_session)) {
 			switch_rtp_set_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_BREAK);
 		}
-        break;
-    case SWITCH_SIG_KILL:
-    default:
-        switch_clear_flag_locked(tech_pvt, TFLAG_IO);
-        switch_set_flag_locked(tech_pvt, TFLAG_HUP);
+		break;
+	case SWITCH_SIG_KILL:
+	default:
+		switch_clear_flag_locked(tech_pvt, TFLAG_IO);
+		switch_set_flag_locked(tech_pvt, TFLAG_HUP);
 
-        if (switch_rtp_ready(tech_pvt->rtp_session)) {
-            switch_rtp_kill_socket(tech_pvt->rtp_session);
-        }
-        break;
-    }
+		if (switch_rtp_ready(tech_pvt->rtp_session)) {
+			switch_rtp_kill_socket(tech_pvt->rtp_session);
+		}
+		break;
+	}
 
 	return SWITCH_STATUS_SUCCESS;
 
@@ -2056,78 +2011,80 @@ static switch_status_t sofia_send_dtmf(switch_core_session_t *session, char *dig
 	private_object_t *tech_pvt;
 
 	tech_pvt = (private_object_t *) switch_core_session_get_private(session);
-    assert(tech_pvt != NULL);
+	assert(tech_pvt != NULL);
 
 	return switch_rtp_queue_rfc2833(tech_pvt->rtp_session,
 									digits,
-									tech_pvt->profile->dtmf_duration * (tech_pvt->read_codec.implementation->samples_per_second / 1000));
-	
+									tech_pvt->profile->dtmf_duration *
+									(tech_pvt->read_codec.implementation->samples_per_second / 1000));
+
 }
 
 static switch_status_t sofia_receive_message(switch_core_session_t *session, switch_core_session_message_t *msg)
 {
 	switch_channel_t *channel;
 	private_object_t *tech_pvt;
-    switch_status_t status;
+	switch_status_t status;
 
 	channel = switch_core_session_get_channel(session);
 	assert(channel != NULL);
-			
+
 	tech_pvt = (private_object_t *) switch_core_session_get_private(session);
 	assert(tech_pvt != NULL);
 
 
 	switch (msg->message_id) {
-	case SWITCH_MESSAGE_INDICATE_NOMEDIA: {
-		char *uuid;
-		switch_core_session_t *other_session;
-		switch_channel_t *other_channel;
-		char *ip = NULL, *port = NULL;
+	case SWITCH_MESSAGE_INDICATE_NOMEDIA:{
+			char *uuid;
+			switch_core_session_t *other_session;
+			switch_channel_t *other_channel;
+			char *ip = NULL, *port = NULL;
 
-		switch_set_flag_locked(tech_pvt, TFLAG_NOMEDIA);
-		tech_pvt->local_sdp_str = NULL;
-		if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE)) && (other_session = switch_core_session_locate(uuid))) {
-			other_channel = switch_core_session_get_channel(other_session);
-			ip = switch_channel_get_variable(other_channel, SWITCH_REMOTE_MEDIA_IP_VARIABLE);
-			port = switch_channel_get_variable(other_channel, SWITCH_REMOTE_MEDIA_PORT_VARIABLE);
-			switch_core_session_rwunlock(other_session);
-			if (ip && port) {
-				set_local_sdp(tech_pvt, ip, atoi(port), NULL, 1);
+			switch_set_flag_locked(tech_pvt, TFLAG_NOMEDIA);
+			tech_pvt->local_sdp_str = NULL;
+			if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))
+				&& (other_session = switch_core_session_locate(uuid))) {
+				other_channel = switch_core_session_get_channel(other_session);
+				ip = switch_channel_get_variable(other_channel, SWITCH_REMOTE_MEDIA_IP_VARIABLE);
+				port = switch_channel_get_variable(other_channel, SWITCH_REMOTE_MEDIA_PORT_VARIABLE);
+				switch_core_session_rwunlock(other_session);
+				if (ip && port) {
+					set_local_sdp(tech_pvt, ip, atoi(port), NULL, 1);
+				}
+			}
+			if (!tech_pvt->local_sdp_str) {
+				tech_absorb_sdp(tech_pvt);
+			}
+			do_invite(session);
+		}
+		break;
+	case SWITCH_MESSAGE_INDICATE_MEDIA:{
+			switch_clear_flag_locked(tech_pvt, TFLAG_NOMEDIA);
+			tech_pvt->local_sdp_str = NULL;
+			if (!switch_rtp_ready(tech_pvt->rtp_session)) {
+				tech_set_codecs(tech_pvt);
+				if ((status = tech_choose_port(tech_pvt)) != SWITCH_STATUS_SUCCESS) {
+					return status;
+				}
+			}
+			set_local_sdp(tech_pvt, NULL, 0, NULL, 1);
+			do_invite(session);
+			while (!switch_rtp_ready(tech_pvt->rtp_session) && switch_channel_get_state(channel) < CS_HANGUP) {
+				switch_yield(1000);
 			}
 		}
-		if (!tech_pvt->local_sdp_str) {
-			tech_absorb_sdp(tech_pvt);
-		}
-		do_invite(session);
-	}
-		break;
-	case SWITCH_MESSAGE_INDICATE_MEDIA: {
-		switch_clear_flag_locked(tech_pvt, TFLAG_NOMEDIA);
-		tech_pvt->local_sdp_str = NULL;
-		if (!switch_rtp_ready(tech_pvt->rtp_session)) {
-			tech_set_codecs(tech_pvt);
-			if ((status=tech_choose_port(tech_pvt)) != SWITCH_STATUS_SUCCESS) {
-                return status;
-            }
-		}
-		set_local_sdp(tech_pvt, NULL, 0, NULL, 1);
-		do_invite(session);
-		while (!switch_rtp_ready(tech_pvt->rtp_session) && switch_channel_get_state(channel) < CS_HANGUP) {
-			switch_yield(1000);
-		}
-	}
 		break;
 
-	case SWITCH_MESSAGE_INDICATE_HOLD: {
-		switch_set_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
-		do_invite(session);
-	}
+	case SWITCH_MESSAGE_INDICATE_HOLD:{
+			switch_set_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
+			do_invite(session);
+		}
 		break;
 
-	case SWITCH_MESSAGE_INDICATE_UNHOLD: {
-		switch_clear_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
-		do_invite(session);
-	}
+	case SWITCH_MESSAGE_INDICATE_UNHOLD:{
+			switch_clear_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
+			do_invite(session);
+		}
 		break;
 	case SWITCH_MESSAGE_INDICATE_BRIDGE:
 
@@ -2141,17 +2098,19 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
 					private_object_t *b_tech_pvt = switch_core_session_get_private(b_session);
 
 					switch_set_flag_locked(a_tech_pvt, TFLAG_REINVITE);
-					a_tech_pvt->remote_sdp_audio_ip = switch_core_session_strdup(a_session, b_tech_pvt->remote_sdp_audio_ip);
+					a_tech_pvt->remote_sdp_audio_ip =
+						switch_core_session_strdup(a_session, b_tech_pvt->remote_sdp_audio_ip);
 					a_tech_pvt->remote_sdp_audio_port = b_tech_pvt->remote_sdp_audio_port;
-					a_tech_pvt->local_sdp_audio_ip = switch_core_session_strdup(a_session, b_tech_pvt->local_sdp_audio_ip);
+					a_tech_pvt->local_sdp_audio_ip =
+						switch_core_session_strdup(a_session, b_tech_pvt->local_sdp_audio_ip);
 					a_tech_pvt->local_sdp_audio_port = b_tech_pvt->local_sdp_audio_port;
 					activate_rtp(a_tech_pvt);
-					
+
 					b_tech_pvt->kick = switch_core_session_strdup(b_session, tech_pvt->xferto);
-                    switch_core_session_rwunlock(a_session);
+					switch_core_session_rwunlock(a_session);
 				}
 
-				
+
 				msg->pointer_arg = NULL;
 				return SWITCH_STATUS_FALSE;
 			}
@@ -2168,7 +2127,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
 		}
 		break;
 	case SWITCH_MESSAGE_INDICATE_REDIRECT:
-		if(msg->string_arg) {
+		if (msg->string_arg) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Re-directing to %s\n", msg->string_arg);
 			nua_respond(tech_pvt->nh, SIP_302_MOVED_TEMPORARILY, SIPTAG_CONTACT_STR(msg->string_arg), TAG_END());
 		}
@@ -2176,47 +2135,48 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
 	case SWITCH_MESSAGE_INDICATE_RINGING:
 		nua_respond(tech_pvt->nh, SIP_180_RINGING, SIPTAG_CONTACT_STR(tech_pvt->profile->url), TAG_END());
 		break;
-	case SWITCH_MESSAGE_INDICATE_PROGRESS: {
-		if (!switch_test_flag(tech_pvt, TFLAG_ANS)) {
-			switch_set_flag_locked(tech_pvt, TFLAG_EARLY_MEDIA);
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Asked to send early media by %s\n", msg->from);
+	case SWITCH_MESSAGE_INDICATE_PROGRESS:{
+			if (!switch_test_flag(tech_pvt, TFLAG_ANS)) {
+				switch_set_flag_locked(tech_pvt, TFLAG_EARLY_MEDIA);
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Asked to send early media by %s\n", msg->from);
 
-			/* Transmit 183 Progress with SDP */
-			if (switch_channel_test_flag(channel, CF_NOMEDIA)) {
-				char *sdp = NULL;
-				switch_set_flag_locked(tech_pvt, TFLAG_NOMEDIA);
-				if ((sdp = switch_channel_get_variable(channel, SWITCH_B_SDP_VARIABLE))) {
-					tech_pvt->local_sdp_str = switch_core_session_strdup(session, sdp);
-				}
-			} else {
-				if (switch_test_flag(tech_pvt, TFLAG_LATE_NEGOTIATION)) {
-					char *r_sdp = switch_channel_get_variable(channel, SWITCH_R_SDP_VARIABLE);
-					if (tech_media(tech_pvt, r_sdp) != SWITCH_STATUS_SUCCESS) {
-						switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "CODEC NEGOTIATION ERROR");
-						nua_respond(tech_pvt->nh, SIP_488_NOT_ACCEPTABLE, TAG_END());
-						return SWITCH_STATUS_FALSE;
+				/* Transmit 183 Progress with SDP */
+				if (switch_channel_test_flag(channel, CF_NOMEDIA)) {
+					char *sdp = NULL;
+					switch_set_flag_locked(tech_pvt, TFLAG_NOMEDIA);
+					if ((sdp = switch_channel_get_variable(channel, SWITCH_B_SDP_VARIABLE))) {
+						tech_pvt->local_sdp_str = switch_core_session_strdup(session, sdp);
+					}
+				} else {
+					if (switch_test_flag(tech_pvt, TFLAG_LATE_NEGOTIATION)) {
+						char *r_sdp = switch_channel_get_variable(channel, SWITCH_R_SDP_VARIABLE);
+						if (tech_media(tech_pvt, r_sdp) != SWITCH_STATUS_SUCCESS) {
+							switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE,
+														"CODEC NEGOTIATION ERROR");
+							nua_respond(tech_pvt->nh, SIP_488_NOT_ACCEPTABLE, TAG_END());
+							return SWITCH_STATUS_FALSE;
+						}
+						switch_clear_flag_locked(tech_pvt, TFLAG_LATE_NEGOTIATION);
+					}
+
+					if ((status = tech_choose_port(tech_pvt)) != SWITCH_STATUS_SUCCESS) {
+						return status;
+					}
+					set_local_sdp(tech_pvt, NULL, 0, NULL, 0);
+					activate_rtp(tech_pvt);
+					if (tech_pvt->local_sdp_str) {
+						switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Ring SDP:\n%s\n",
+										  tech_pvt->local_sdp_str);
 					}
-					switch_clear_flag_locked(tech_pvt, TFLAG_LATE_NEGOTIATION);
 				}
 
-				if ((status=tech_choose_port(tech_pvt)) != SWITCH_STATUS_SUCCESS) {
-					return status;
-				}
-				set_local_sdp(tech_pvt, NULL, 0, NULL, 0);
-				activate_rtp(tech_pvt);
-				if (tech_pvt->local_sdp_str) {
-					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Ring SDP:\n%s\n", tech_pvt->local_sdp_str);
-				}
+				nua_respond(tech_pvt->nh,
+							SIP_183_SESSION_PROGRESS,
+							SIPTAG_CONTACT_STR(tech_pvt->profile->url),
+							SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str),
+							SOATAG_AUDIO_AUX("cn telephone-event"), TAG_END());
 			}
-			
-			nua_respond(tech_pvt->nh,
-						SIP_183_SESSION_PROGRESS,
-						SIPTAG_CONTACT_STR(tech_pvt->profile->url),
-						SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str),
-						SOATAG_AUDIO_AUX("cn telephone-event"),
-						TAG_END());
-	    }
-	}
+		}
 		break;
 	default:
 		break;
@@ -2228,15 +2188,15 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
 static switch_status_t sofia_receive_event(switch_core_session_t *session, switch_event_t *event)
 {
 	switch_channel_t *channel;
-    struct private_object *tech_pvt;
+	struct private_object *tech_pvt;
 	char *body;
 	nua_handle_t *msg_nh;
 
-    channel = switch_core_session_get_channel(session);
-    assert(channel != NULL);
+	channel = switch_core_session_get_channel(session);
+	assert(channel != NULL);
 
-    tech_pvt = switch_core_session_get_private(session);
-    assert(tech_pvt != NULL);
+	tech_pvt = switch_core_session_get_private(session);
+	assert(tech_pvt != NULL);
 
 
 	if (!(body = switch_event_get_body(event))) {
@@ -2247,14 +2207,9 @@ static switch_status_t sofia_receive_event(switch_core_session_t *session, switc
 		msg_nh = nua_handle(tech_pvt->profile->nua, NULL,
 							SIPTAG_FROM_STR(tech_pvt->chat_from),
 							NUTAG_URL(tech_pvt->chat_to),
-							SIPTAG_TO_STR(tech_pvt->chat_to),
-							SIPTAG_CONTACT_STR(tech_pvt->profile->url),
-							TAG_END());
+							SIPTAG_TO_STR(tech_pvt->chat_to), SIPTAG_CONTACT_STR(tech_pvt->profile->url), TAG_END());
 
-		nua_message(msg_nh,
-					SIPTAG_CONTENT_TYPE_STR("text/html"),
-					SIPTAG_PAYLOAD_STR(body),
-					TAG_END());
+		nua_message(msg_nh, SIPTAG_CONTENT_TYPE_STR("text/html"), SIPTAG_PAYLOAD_STR(body), TAG_END());
 	}
 
 	return SWITCH_STATUS_SUCCESS;
@@ -2268,9 +2223,9 @@ static const switch_io_routines_t sofia_io_routines = {
 	/*.kill_channel */ sofia_kill_channel,
 	/*.waitfor_read */ sofia_waitfor_read,
 	/*.waitfor_read */ sofia_waitfor_write,
-	/*.send_dtmf*/ sofia_send_dtmf,
-	/*.receive_message*/ sofia_receive_message,
-	/*.receive_event*/ sofia_receive_event
+	/*.send_dtmf */ sofia_send_dtmf,
+	/*.receive_message */ sofia_receive_message,
+	/*.receive_event */ sofia_receive_event
 };
 
 static const switch_state_handler_table_t sofia_event_handlers = {
@@ -2293,17 +2248,18 @@ static const switch_endpoint_interface_t sofia_endpoint_interface = {
 static const switch_chat_interface_t sofia_chat_interface = {
 	/*.name */ SOFIA_CHAT_PROTO,
 	/*.chat_send */ chat_send,
-	
+
 };
 
-static switch_status_t sofia_manage(char *relative_oid, switch_management_action_t action, char *data, switch_size_t datalen)
+static switch_status_t sofia_manage(char *relative_oid, switch_management_action_t action, char *data,
+									switch_size_t datalen)
 {
 	return SWITCH_STATUS_SUCCESS;
 }
 
 static const switch_management_interface_t sofia_management_interface = {
-	/*.relative_oid*/ "1",
-	/*.management_function*/ sofia_manage
+	/*.relative_oid */ "1",
+	/*.management_function */ sofia_manage
 };
 
 static const switch_loadable_module_interface_t sofia_module_interface = {
@@ -2339,19 +2295,20 @@ static void logger(void *logarg, char const *fmt, va_list ap)
 		data = (char *) malloc(2048);
 		if (data) {
 			vsnprintf(data, 2048, fmt, ap);
-		} else { 
+		} else {
 			return;
 		}
 #endif
 	}
 	if (data) {
-		switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_CONSOLE, (char*) "%s", data);
+		switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_CONSOLE, (char *) "%s", data);
 		free(data);
 	}
 }
 
 
-static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session, switch_caller_profile_t *outbound_profile,
+static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session,
+												  switch_caller_profile_t *outbound_profile,
 												  switch_core_session_t **new_session, switch_memory_pool_t **pool)
 {
 	switch_call_cause_t cause = SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
@@ -2378,12 +2335,12 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session
 
 	data = switch_core_session_strdup(nsession, outbound_profile->destination_number);
 	profile_name = data;
-	
+
 	if (!strncasecmp(profile_name, "gateway", 7)) {
 		char *gw;
 		outbound_reg_t *gateway_ptr;
 
-		
+
 		if (!(gw = strchr(profile_name, '/'))) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid URL\n");
 			terminate_session(&nsession, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER, __LINE__);
@@ -2392,7 +2349,7 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session
 		}
 
 		*gw++ = '\0';
-		
+
 		if (!(dest = strchr(gw, '/'))) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid URL\n");
 			terminate_session(&nsession, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER, __LINE__);
@@ -2408,7 +2365,7 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session
 			cause = SWITCH_CAUSE_INVALID_NUMBER_FORMAT;
 			goto done;
 		}
-		
+
 		profile = gateway_ptr->profile;
 		tech_pvt->from_str = switch_core_session_strdup(nsession, gateway_ptr->register_from);
 		if (!strchr(dest, '@')) {
@@ -2428,7 +2385,7 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session
 		if (!(profile = find_profile(profile_name))) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Profile\n");
 			terminate_session(&nsession, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER, __LINE__);
-			cause =  SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
+			cause = SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
 			goto done;
 		}
 
@@ -2445,9 +2402,10 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session
 			*host++ = '\0';
 			if (find_reg_url(profile, dest, host, buf, sizeof(buf))) {
 				tech_pvt->dest = switch_core_session_strdup(nsession, buf);
-				
+
 			} else {
-				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Cannot locate registered user %s@%s\n", dest, host);
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Cannot locate registered user %s@%s\n", dest,
+								  host);
 				cause = SWITCH_CAUSE_NO_ROUTE_DESTINATION;
 				terminate_session(&nsession, cause, __LINE__);
 				goto done;
@@ -2457,9 +2415,10 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session
 			tech_pvt->e_dest = switch_core_session_strdup(nsession, dest);
 			if (find_reg_url(profile, dest, profile_name, buf, sizeof(buf))) {
 				tech_pvt->dest = switch_core_session_strdup(nsession, buf);
-				
+
 			} else {
-				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Cannot locate registered user %s@%s\n", dest, profile_name);
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Cannot locate registered user %s@%s\n", dest,
+								  profile_name);
 				cause = SWITCH_CAUSE_NO_ROUTE_DESTINATION;
 				terminate_session(&nsession, cause, __LINE__);
 				goto done;
@@ -2492,7 +2451,7 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session
 		if (switch_core_session_compare(session, nsession)) {
 			/* It's another sofia channel! so lets cache what they use as a pt for telephone event so 
 			   we can keep it the same
-			*/
+			 */
 			private_object_t *ctech_pvt;
 			ctech_pvt = switch_core_session_get_private(session);
 			assert(ctech_pvt != NULL);
@@ -2501,12 +2460,12 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session
 		}
 	}
 
- done:
+  done:
 	return cause;
 }
 
 
-static uint8_t negotiate_sdp(switch_core_session_t *session, sdp_session_t *sdp)
+static uint8_t negotiate_sdp(switch_core_session_t *session, sdp_session_t * sdp)
 {
 	uint8_t match = 0;
 	switch_payload_t te = 0, cng_pt = 0;
@@ -2514,13 +2473,13 @@ static uint8_t negotiate_sdp(switch_core_session_t *session, sdp_session_t *sdp)
 	sdp_media_t *m;
 	sdp_attribute_t *a;
 	switch_channel_t *channel;
-    int ptime = 0, dptime = 0;
+	int ptime = 0, dptime = 0;
 
 	tech_pvt = switch_core_session_get_private(session);
 	assert(tech_pvt != NULL);
 
 	channel = switch_core_session_get_channel(session);
-	
+
 	if ((tech_pvt->origin = switch_core_session_strdup(session, (char *) sdp->sdp_origin->o_username))) {
 		if (strstr(tech_pvt->origin, "CiscoSystemsSIP-GW-UserAgent")) {
 			switch_set_flag_locked(tech_pvt, TFLAG_BUGGY_2833);
@@ -2534,19 +2493,19 @@ static uint8_t negotiate_sdp(switch_core_session_t *session, sdp_session_t *sdp)
 		} else if (!strcasecmp(a->a_name, "sendrecv")) {
 			switch_clear_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
 		} else if (!strcasecmp(a->a_name, "ptime")) {
-            dptime = atoi(a->a_value);
+			dptime = atoi(a->a_value);
 		}
 	}
 
-	for (m = sdp->sdp_media; m ; m = m->m_next) {
-        sdp_connection_t *connection;
+	for (m = sdp->sdp_media; m; m = m->m_next) {
+		sdp_connection_t *connection;
 
-        ptime = dptime;
-        for (a = m->m_attributes; a; a = a->a_next) {
-            if (!strcasecmp(a->a_name, "ptime") && a->a_value) {
-                ptime = atoi(a->a_value);
-            }
-        }
+		ptime = dptime;
+		for (a = m->m_attributes; a; a = a->a_next) {
+			if (!strcasecmp(a->a_name, "ptime") && a->a_value) {
+				ptime = atoi(a->a_value);
+			}
+		}
 
 		if (m->m_type == sdp_media_audio) {
 			sdp_rtpmap_t *map;
@@ -2557,23 +2516,24 @@ static uint8_t negotiate_sdp(switch_core_session_t *session, sdp_session_t *sdp)
 			}
 
 			if (!connection) {
-				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot find a c= line in the sdp at media or session level!\n");
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+								  "Cannot find a c= line in the sdp at media or session level!\n");
 				match = 0;
 				break;
 			}
 
 			for (map = m->m_rtpmaps; map; map = map->rm_next) {
 				int32_t i;
-                const switch_codec_implementation_t *mimp = NULL, *near_match = NULL;
-				const char * rm_encoding;
+				const switch_codec_implementation_t *mimp = NULL, *near_match = NULL;
+				const char *rm_encoding;
+
 
-				
 				if (!(rm_encoding = map->rm_encoding)) {
 					rm_encoding = "";
 				}
-				
+
 				if (!te && !strcasecmp(rm_encoding, "telephone-event")) {
-					te = tech_pvt->te = (switch_payload_t)map->rm_pt;
+					te = tech_pvt->te = (switch_payload_t) map->rm_pt;
 					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Set 2833 dtmf payload to %u\n", te);
 					if (tech_pvt->rtp_session) {
 						switch_rtp_set_telephony_event(tech_pvt->rtp_session, tech_pvt->te);
@@ -2581,14 +2541,15 @@ static uint8_t negotiate_sdp(switch_core_session_t *session, sdp_session_t *sdp)
 				}
 
 				if (!cng_pt && !strcasecmp(rm_encoding, "CN")) {
-					cng_pt = tech_pvt->cng_pt = (switch_payload_t)map->rm_pt;
-					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Set comfort noise payload to %u\n", cng_pt);
+					cng_pt = tech_pvt->cng_pt = (switch_payload_t) map->rm_pt;
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Set comfort noise payload to %u\n",
+									  cng_pt);
 					if (tech_pvt->rtp_session) {
 						switch_rtp_set_cng_pt(tech_pvt->rtp_session, tech_pvt->cng_pt);
 						switch_rtp_set_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_AUTO_CNG);
 					}
 				}
-				
+
 				if (match) {
 					if (te && cng_pt) {
 						break;
@@ -2598,7 +2559,7 @@ static uint8_t negotiate_sdp(switch_core_session_t *session, sdp_session_t *sdp)
 
 				for (i = 0; i < tech_pvt->num_codecs; i++) {
 					const switch_codec_implementation_t *imp = tech_pvt->codecs[i];
-					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Codec Compare [%s:%d]/[%s:%d]\n", 
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Codec Compare [%s:%d]/[%s:%d]\n",
 									  rm_encoding, map->rm_pt, imp->iananame, imp->ianacode);
 					if (map->rm_pt < 96) {
 						match = (map->rm_pt == imp->ianacode) ? 1 : 0;
@@ -2607,61 +2568,61 @@ static uint8_t negotiate_sdp(switch_core_session_t *session, sdp_session_t *sdp)
 					}
 
 					if (match && (map->rm_rate == imp->samples_per_second)) {
-                        if (ptime && ptime * 1000 != imp->microseconds_per_frame) {
-                            near_match = imp;
-                            match = 0;
-                            continue;
-                        }
-                        mimp = imp;
+						if (ptime && ptime * 1000 != imp->microseconds_per_frame) {
+							near_match = imp;
+							match = 0;
+							continue;
+						}
+						mimp = imp;
 						break;
 					} else {
 						match = 0;
 					}
-                }
-                
-                if (!match && near_match) {
-                    const switch_codec_implementation_t *search[1];
-                    char *prefs[1];
-                    char tmp[80];
-                    int num;
-                    
-                    snprintf(tmp, sizeof(tmp), "%s@%uk@%ui",
-                             near_match->iananame,
-                             near_match->samples_per_second,
-                             ptime);
+				}
 
-                    prefs[0] = tmp;
-                    num = switch_loadable_module_get_codecs_sorted(search, 1, prefs, 1);
+				if (!match && near_match) {
+					const switch_codec_implementation_t *search[1];
+					char *prefs[1];
+					char tmp[80];
+					int num;
 
-                    if (num) {
-                        mimp = search[0];
-                    } else {
-                        mimp = near_match;
-                    }
+					snprintf(tmp, sizeof(tmp), "%s@%uk@%ui",
+							 near_match->iananame, near_match->samples_per_second, ptime);
 
-                    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Substituting codec %s@%ums\n", 
-                                      mimp->iananame, mimp->microseconds_per_frame / 1000 );
-                    match = 1;
-                }
+					prefs[0] = tmp;
+					num = switch_loadable_module_get_codecs_sorted(search, 1, prefs, 1);
+
+					if (num) {
+						mimp = search[0];
+					} else {
+						mimp = near_match;
+					}
+
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Substituting codec %s@%ums\n",
+									  mimp->iananame, mimp->microseconds_per_frame / 1000);
+					match = 1;
+				}
+
+				if (mimp) {
+					if ((tech_pvt->rm_encoding = switch_core_session_strdup(session, (char *) rm_encoding))) {
+						char tmp[50];
+						tech_pvt->pt = (switch_payload_t) map->rm_pt;
+						tech_pvt->rm_rate = map->rm_rate;
+						tech_pvt->codec_ms = mimp->microseconds_per_frame / 1000;
+						tech_pvt->remote_sdp_audio_ip =
+							switch_core_session_strdup(session, (char *) connection->c_address);
+						tech_pvt->rm_fmtp = switch_core_session_strdup(session, (char *) map->rm_fmtp);
+						tech_pvt->remote_sdp_audio_port = (switch_port_t) m->m_port;
+						tech_pvt->agreed_pt = (switch_payload_t) map->rm_pt;
+						snprintf(tmp, sizeof(tmp), "%d", tech_pvt->remote_sdp_audio_port);
+						switch_channel_set_variable(channel, SWITCH_REMOTE_MEDIA_IP_VARIABLE,
+													tech_pvt->remote_sdp_audio_ip);
+						switch_channel_set_variable(channel, SWITCH_REMOTE_MEDIA_PORT_VARIABLE, tmp);
+					} else {
+						match = 0;
+					}
+				}
 
-                if (mimp) {
-                    if ((tech_pvt->rm_encoding = switch_core_session_strdup(session, (char *)rm_encoding))) {
-                        char tmp[50];
-                        tech_pvt->pt = (switch_payload_t)map->rm_pt;
-                        tech_pvt->rm_rate = map->rm_rate;
-                        tech_pvt->codec_ms = mimp->microseconds_per_frame / 1000;
-                        tech_pvt->remote_sdp_audio_ip = switch_core_session_strdup(session, (char *)connection->c_address);
-                        tech_pvt->rm_fmtp = switch_core_session_strdup(session, (char *)map->rm_fmtp);
-                        tech_pvt->remote_sdp_audio_port = (switch_port_t)m->m_port;
-                        tech_pvt->agreed_pt = (switch_payload_t)map->rm_pt;
-                        snprintf(tmp, sizeof(tmp), "%d", tech_pvt->remote_sdp_audio_port);
-                        switch_channel_set_variable(channel, SWITCH_REMOTE_MEDIA_IP_VARIABLE, tech_pvt->remote_sdp_audio_ip);
-                        switch_channel_set_variable(channel, SWITCH_REMOTE_MEDIA_PORT_VARIABLE, tmp);
-                    } else {
-                        match = 0;
-                    }
-                }
-                
 				if (match) {
 					if (tech_set_codec(tech_pvt, 1) != SWITCH_STATUS_SUCCESS) {
 						match = 0;
@@ -2675,26 +2636,27 @@ static uint8_t negotiate_sdp(switch_core_session_t *session, sdp_session_t *sdp)
 }
 
 // map sip responses to QSIG cause codes ala RFC4497 section 8.4.4
-static switch_call_cause_t sip_cause_to_freeswitch(int status) {
+static switch_call_cause_t sip_cause_to_freeswitch(int status)
+{
 	switch (status) {
 	case 200:
 		return SWITCH_CAUSE_NORMAL_CLEARING;
 	case 401:
-	case 402: 
+	case 402:
 	case 403:
 	case 407:
 	case 603:
 		return SWITCH_CAUSE_CALL_REJECTED;
 	case 404:
 	case 485:
-	case 604:	
+	case 604:
 		return SWITCH_CAUSE_NO_ROUTE_DESTINATION;
-	case 408: 
+	case 408:
 	case 504:
 		return SWITCH_CAUSE_RECOVERY_ON_TIMER_EXPIRE;
-	case 410: 
+	case 410:
 		return SWITCH_CAUSE_NUMBER_CHANGED;
-	case 413: 
+	case 413:
 	case 414:
 	case 416:
 	case 420:
@@ -2732,7 +2694,7 @@ static switch_call_cause_t sip_cause_to_freeswitch(int status) {
 	case 487:
 		return SWITCH_CAUSE_ORIGINATOR_CANCEL;
 
-	default: 
+	default:
 		return SWITCH_CAUSE_NORMAL_UNSPECIFIED;
 
 	}
@@ -2744,9 +2706,7 @@ static void set_hash_key(char *hash_key, int32_t len, sip_t const *sip)
 
 	snprintf(hash_key, len, "%s%s%s",
 			 (char *) sip->sip_from->a_url->url_user,
-			 (char *) sip->sip_from->a_url->url_host,
-			 (char *) sip->sip_to->a_url->url_user
-			 );	
+			 (char *) sip->sip_from->a_url->url_host, (char *) sip->sip_to->a_url->url_user);
 
 
 #if 0
@@ -2755,29 +2715,25 @@ static void set_hash_key(char *hash_key, int32_t len, sip_t const *sip)
 			 (char *) sip->sip_to->a_url->url_user,
 			 (char *) sip->sip_to->a_url->url_host,
 			 (char *) sip->sip_to->a_url->url_params,
-			 
 			 (char *) sip->sip_from->a_url->url_user,
-			 (char *) sip->sip_from->a_url->url_host,
-			 (char *) sip->sip_from->a_url->url_params
-			 );	
+			 (char *) sip->sip_from->a_url->url_host, (char *) sip->sip_from->a_url->url_params);
 #endif
 
 }
 
-static void set_chat_hash(private_object_t *tech_pvt, sip_t const *sip)
+static void set_chat_hash(private_object_t * tech_pvt, sip_t const *sip)
 {
 	char hash_key[256] = "";
 	char buf[512];
 
 	if (tech_pvt->hash_key || !sip || !sip->sip_from ||
-		!sip->sip_from->a_url ||
-		!sip->sip_from->a_url->url_user ||
-		!sip->sip_from->a_url->url_host) {
+		!sip->sip_from->a_url || !sip->sip_from->a_url->url_user || !sip->sip_from->a_url->url_host) {
 		return;
 	}
 
-	if (find_reg_url(tech_pvt->profile, sip->sip_from->a_url->url_user, sip->sip_from->a_url->url_host, buf, sizeof(buf))) {
-		tech_pvt->chat_from = sip_header_as_string(tech_pvt->home, (const sip_header_t *)sip->sip_to);
+	if (find_reg_url
+		(tech_pvt->profile, sip->sip_from->a_url->url_user, sip->sip_from->a_url->url_host, buf, sizeof(buf))) {
+		tech_pvt->chat_from = sip_header_as_string(tech_pvt->home, (const sip_header_t *) sip->sip_to);
 		tech_pvt->chat_to = switch_core_session_strdup(tech_pvt->session, buf);
 		set_hash_key(hash_key, sizeof(hash_key), sip);
 	} else {
@@ -2791,13 +2747,10 @@ static void set_chat_hash(private_object_t *tech_pvt, sip_t const *sip)
 
 
 static void sip_i_message(int status,
-						char const *phrase, 
-						nua_t *nua,
-						sofia_profile_t *profile,
-						nua_handle_t *nh,
-						sofia_private_t *sofia_private,
-						sip_t const *sip,
-						tagi_t tags[])
+						  char const *phrase,
+						  nua_t * nua,
+						  sofia_profile_t * profile,
+						  nua_handle_t * nh, sofia_private_t * sofia_private, sip_t const *sip, tagi_t tags[])
 {
 	if (sip) {
 		sip_from_t const *from = sip->sip_from;
@@ -2812,7 +2765,7 @@ static void sip_i_message(int status,
 		char *msg = NULL;
 
 		if (sip->sip_content_type) {
-			if (strstr((char*)sip->sip_content_type->c_subtype, "composing")) {
+			if (strstr((char *) sip->sip_content_type->c_subtype, "composing")) {
 				return;
 			}
 		}
@@ -2827,7 +2780,7 @@ static void sip_i_message(int status,
 			to_host = (char *) to->a_url->url_host;
 		}
 
-        
+
 		if (!to_user) {
 			return;
 		}
@@ -2840,7 +2793,7 @@ static void sip_i_message(int status,
 			subject = sip_subject->g_value;
 		}
 
-		if (nh) {			
+		if (nh) {
 			char hash_key[512];
 			private_object_t *tech_pvt;
 			switch_channel_t *channel;
@@ -2850,20 +2803,20 @@ static void sip_i_message(int status,
 			char *p;
 			char *full_from;
 			char proto[512] = SOFIA_CHAT_PROTO;
-			
-			full_from = sip_header_as_string(profile->home, (void *)sip->sip_from);
 
-			if ((p=strchr(to_user, '+'))) {
+			full_from = sip_header_as_string(profile->home, (void *) sip->sip_from);
+
+			if ((p = strchr(to_user, '+'))) {
 				switch_copy_string(proto, to_user, sizeof(proto));
 				p = strchr(proto, '+');
 				*p++ = '\0';
-				
+
 				if ((to_addr = strdup(p))) {
-					if((p = strchr(to_addr, '+'))) {
+					if ((p = strchr(to_addr, '+'))) {
 						*p = '@';
 					}
 				}
-				
+
 			} else {
 				to_addr = switch_mprintf("%s@%s", to_user, to_host);
 			}
@@ -2890,13 +2843,14 @@ static void sip_i_message(int status,
 				}
 			} else {
 				switch_chat_interface_t *ci;
-				
+
 				if ((ci = switch_loadable_module_get_chat_interface(proto))) {
 					ci->chat_send(SOFIA_CHAT_PROTO, from_addr, to_addr, "", msg, full_from);
 				} else {
-					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Chat Interface [%s]!\n", proto ? proto : "(none)");
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Chat Interface [%s]!\n",
+									  proto ? proto : "(none)");
 				}
-				
+
 			}
 			switch_safe_free(to_addr);
 			switch_safe_free(from_addr);
@@ -2908,43 +2862,39 @@ static void sip_i_message(int status,
 	}
 }
 
-static void pass_sdp(private_object_t *tech_pvt, char *sdp) 
+static void pass_sdp(private_object_t * tech_pvt, char *sdp)
 {
 	char *val;
 	switch_channel_t *channel;
 	switch_core_session_t *other_session;
 	switch_channel_t *other_channel;
-	
+
 	channel = switch_core_session_get_channel(tech_pvt->session);
 	assert(channel != NULL);
-	
-	if ((val = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE)) && (other_session = switch_core_session_locate(val))) {
+
+	if ((val = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))
+		&& (other_session = switch_core_session_locate(val))) {
 		other_channel = switch_core_session_get_channel(other_session);
 		assert(other_channel != NULL);
 		switch_channel_set_variable(other_channel, SWITCH_B_SDP_VARIABLE, sdp);
 
-		if (!switch_test_flag(tech_pvt, TFLAG_CHANGE_MEDIA) && (
-			switch_channel_test_flag(other_channel, CF_OUTBOUND) && 
-			//switch_channel_test_flag(other_channel, CF_NOMEDIA) && 
-			switch_channel_test_flag(channel, CF_OUTBOUND) && 
-			switch_channel_test_flag(channel, CF_NOMEDIA))) {
+		if (!switch_test_flag(tech_pvt, TFLAG_CHANGE_MEDIA) && (switch_channel_test_flag(other_channel, CF_OUTBOUND) &&
+																//switch_channel_test_flag(other_channel, CF_NOMEDIA) && 
+																switch_channel_test_flag(channel, CF_OUTBOUND) &&
+																switch_channel_test_flag(channel, CF_NOMEDIA))) {
 			switch_ivr_nomedia(val, SMF_FORCE);
 			switch_set_flag_locked(tech_pvt, TFLAG_CHANGE_MEDIA);
 		}
-		
+
 		switch_core_session_rwunlock(other_session);
 	}
 }
 
 static void sip_i_state(int status,
-						char const *phrase, 
-						nua_t *nua,
-						sofia_profile_t *profile,
-						nua_handle_t *nh,
-						sofia_private_t *sofia_private,
-						sip_t const *sip,
-						tagi_t tags[])
-	 
+						char const *phrase,
+						nua_t * nua,
+						sofia_profile_t * profile,
+						nua_handle_t * nh, sofia_private_t * sofia_private, sip_t const *sip, tagi_t tags[])
 {
 	const char *l_sdp = NULL, *r_sdp = NULL;
 	int offer_recv = 0, answer_recv = 0, offer_sent = 0, answer_sent = 0;
@@ -2959,26 +2909,24 @@ static void sip_i_state(int status,
 	char st[80] = "";
 
 
-    if (sofia_private) {
-        if (!switch_strlen_zero(sofia_private->uuid)) {
-            if (!(session = switch_core_session_locate(sofia_private->uuid))) {
-                /* too late */
-                return;            
-            }
-        }
-    }
+	if (sofia_private) {
+		if (!switch_strlen_zero(sofia_private->uuid)) {
+			if (!(session = switch_core_session_locate(sofia_private->uuid))) {
+				/* too late */
+				return;
+			}
+		}
+	}
 
-	
-	tl_gets(tags, 
+
+	tl_gets(tags,
 			NUTAG_CALLSTATE_REF(ss_state),
 			NUTAG_OFFER_RECV_REF(offer_recv),
 			NUTAG_ANSWER_RECV_REF(answer_recv),
 			NUTAG_OFFER_SENT_REF(offer_sent),
 			NUTAG_ANSWER_SENT_REF(answer_sent),
 			SIPTAG_REPLACES_STR_REF(replaces_str),
-			SOATAG_LOCAL_SDP_STR_REF(l_sdp),
-			SOATAG_REMOTE_SDP_STR_REF(r_sdp),
-			TAG_END()); 
+			SOATAG_LOCAL_SDP_STR_REF(l_sdp), SOATAG_REMOTE_SDP_STR_REF(r_sdp), TAG_END());
 
 	if (session) {
 		channel = switch_core_session_get_channel(session);
@@ -2986,21 +2934,20 @@ static void sip_i_state(int status,
 
 		tech_pvt = switch_core_session_get_private(session);
 		assert(tech_pvt != NULL);
-        assert(tech_pvt->nh != NULL);
+		assert(tech_pvt->nh != NULL);
 
 		if (switch_channel_test_flag(channel, CF_NOMEDIA)) {
-            switch_set_flag(tech_pvt, TFLAG_NOMEDIA);
-        }
+			switch_set_flag(tech_pvt, TFLAG_NOMEDIA);
+		}
 
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Channel %s entering state [%s]\n", 
-						  switch_channel_get_name(channel),
-						  nua_callstate_name(ss_state));
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Channel %s entering state [%s]\n",
+						  switch_channel_get_name(channel), nua_callstate_name(ss_state));
 
 		if (r_sdp) {
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Remote SDP:\n%s\n", r_sdp);			
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Remote SDP:\n%s\n", r_sdp);
 			tech_pvt->remote_sdp_str = switch_core_session_strdup(session, r_sdp);
 			switch_channel_set_variable(channel, SWITCH_R_SDP_VARIABLE, r_sdp);
-			pass_sdp(tech_pvt, (char *)r_sdp);
+			pass_sdp(tech_pvt, (char *) r_sdp);
 
 		}
 	}
@@ -3009,7 +2956,7 @@ static void sip_i_state(int status,
 		goto done;
 	}
 
-	switch ((enum nua_callstate)ss_state) {
+	switch ((enum nua_callstate) ss_state) {
 	case nua_callstate_init:
 		break;
 	case nua_callstate_authenticating:
@@ -3022,14 +2969,15 @@ static void sip_i_state(int status,
 				switch_channel_mark_ring_ready(channel);
 				if (!switch_channel_test_flag(channel, CF_GEN_RINGBACK)) {
 					if (switch_test_flag(tech_pvt, TFLAG_NOMEDIA)) {
-						if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE)) && (other_session = switch_core_session_locate(uuid))) {
+						if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))
+							&& (other_session = switch_core_session_locate(uuid))) {
 							switch_core_session_message_t msg;
 							msg.message_id = SWITCH_MESSAGE_INDICATE_RINGING;
 							msg.from = __FILE__;
 							switch_core_session_receive_message(other_session, &msg);
 							switch_core_session_rwunlock(other_session);
 						}
-						
+
 					} else {
 						switch_core_session_queue_indication(session, SWITCH_MESSAGE_INDICATE_RINGING);
 					}
@@ -3039,40 +2987,43 @@ static void sip_i_state(int status,
 			if (r_sdp) {
 				if (switch_test_flag(tech_pvt, TFLAG_NOMEDIA)) {
 					switch_set_flag_locked(tech_pvt, TFLAG_EARLY_MEDIA);
-                    switch_channel_mark_pre_answered(channel);
-					if (!switch_channel_test_flag(channel, CF_GEN_RINGBACK) && 
-						(uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE)) && (other_session = switch_core_session_locate(uuid))) {
+					switch_channel_mark_pre_answered(channel);
+					if (!switch_channel_test_flag(channel, CF_GEN_RINGBACK) &&
+						(uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))
+						&& (other_session = switch_core_session_locate(uuid))) {
 						other_channel = switch_core_session_get_channel(other_session);
 						if (!switch_channel_get_variable(other_channel, SWITCH_B_SDP_VARIABLE)) {
 							switch_channel_set_variable(other_channel, SWITCH_B_SDP_VARIABLE, r_sdp);
 						}
-						
+
 						switch_channel_pre_answer(other_channel);
 						switch_core_session_rwunlock(other_session);
 					}
-                    goto done;
+					goto done;
 				} else {
 					if (switch_test_flag(tech_pvt, TFLAG_LATE_NEGOTIATION)) {
-						switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "DELAYED NEGOTIATION");
+						switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE,
+													"DELAYED NEGOTIATION");
 					} else {
-						if (tech_media(tech_pvt, (char *)r_sdp) != SWITCH_STATUS_SUCCESS) {
-							switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "CODEC NEGOTIATION ERROR");
+						if (tech_media(tech_pvt, (char *) r_sdp) != SWITCH_STATUS_SUCCESS) {
+							switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE,
+														"CODEC NEGOTIATION ERROR");
 							nua_respond(nh, SIP_488_NOT_ACCEPTABLE, TAG_END());
 						}
 					}
 					goto done;
-                }
+				}
 			}
 		}
 		break;
 	case nua_callstate_completing:
 		nua_ack(nh, TAG_END());
 		break;
-	case nua_callstate_received: 
+	case nua_callstate_received:
 
 		if (session && switch_core_session_running(session)) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Re-Entering Call State Received!\n");
-            goto done;
+			goto done;
 		}
 
 		if (channel) {
@@ -3082,12 +3033,12 @@ static void sip_i_state(int status,
 					switch_channel_set_state(channel, CS_INIT);
 					switch_set_flag_locked(tech_pvt, TFLAG_READY);
 					switch_core_session_thread_launch(session);
-                    goto done;
+					goto done;
 				} else {
-					sdp_parser_t *parser = sdp_parse(tech_pvt->home, r_sdp, (int)strlen(r_sdp), 0);
+					sdp_parser_t *parser = sdp_parse(tech_pvt->home, r_sdp, (int) strlen(r_sdp), 0);
 					sdp_session_t *sdp;
 					uint8_t match = 0;
-				
+
 					if (tech_pvt->num_codecs) {
 						if ((sdp = sdp_session(parser))) {
 							match = negotiate_sdp(session, sdp);
@@ -3106,11 +3057,13 @@ static void sip_i_state(int status,
 						switch_set_flag_locked(tech_pvt, TFLAG_READY);
 
 						switch_core_session_thread_launch(session);
-						
-						if (replaces_str && (replaces = sip_replaces_make(tech_pvt->home, replaces_str)) && (bnh = nua_handle_by_replaces(nua, replaces))) {
+
+						if (replaces_str && (replaces = sip_replaces_make(tech_pvt->home, replaces_str))
+							&& (bnh = nua_handle_by_replaces(nua, replaces))) {
 							sofia_private_t *b_private;
 
-							switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Processing Replaces Attended Transfer\n");
+							switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
+											  "Processing Replaces Attended Transfer\n");
 							while (switch_channel_get_state(channel) < CS_EXECUTE) {
 								switch_yield(10000);
 							}
@@ -3121,27 +3074,30 @@ static void sip_i_state(int status,
 
 								if (br_b) {
 									switch_ivr_uuid_bridge(br_a, br_b);
-									switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "ATTENDED_TRANSFER");
+									switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE,
+																"ATTENDED_TRANSFER");
 									switch_channel_hangup(channel, SWITCH_CAUSE_ATTENDED_TRANSFER);
 								} else {
-									switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "ATTENDED_TRANSFER_ERROR");
+									switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE,
+																"ATTENDED_TRANSFER_ERROR");
 									switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 								}
 							} else {
-								switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "ATTENDED_TRANSFER_ERROR");
+								switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE,
+															"ATTENDED_TRANSFER_ERROR");
 								switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 							}
 							nua_handle_unref(bnh);
 						}
-                        goto done;
+						goto done;
 					}
 
 					switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "NO CODECS");
-					nua_respond(nh, SIP_488_NOT_ACCEPTABLE, 
-								TAG_END());
+					nua_respond(nh, SIP_488_NOT_ACCEPTABLE, TAG_END());
 				}
 			} else {
-				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Invite with no SDP activating no-media-mode\n");
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE,
+								  "Invite with no SDP activating no-media-mode\n");
 				switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "RECEIVED_NOSDP");
 
 				switch_set_flag(tech_pvt, TFLAG_LATE_NEGOTIATION);
@@ -3154,16 +3110,16 @@ static void sip_i_state(int status,
 			}
 		}
 
-		break;		
+		break;
 	case nua_callstate_early:
 		break;
 	case nua_callstate_completed:
 		if (tech_pvt && r_sdp) {
 			if (r_sdp) {
 				if (switch_test_flag(tech_pvt, TFLAG_NOMEDIA)) {
-                    goto done;
+					goto done;
 				} else {
-					sdp_parser_t *parser = sdp_parse(tech_pvt->home, r_sdp, (int)strlen(r_sdp), 0);
+					sdp_parser_t *parser = sdp_parse(tech_pvt->home, r_sdp, (int) strlen(r_sdp), 0);
 					sdp_session_t *sdp;
 					uint8_t match = 0;
 
@@ -3174,8 +3130,8 @@ static void sip_i_state(int status,
 					}
 					if (match) {
 						if (tech_choose_port(tech_pvt) != SWITCH_STATUS_SUCCESS) {
-                            goto done;
-                        }
+							goto done;
+						}
 						set_local_sdp(tech_pvt, NULL, 0, NULL, 0);
 						switch_set_flag_locked(tech_pvt, TFLAG_REINVITE);
 						activate_rtp(tech_pvt);
@@ -3195,20 +3151,21 @@ static void sip_i_state(int status,
 			tech_pvt->nh = tech_pvt->nh2;
 			tech_pvt->nh2 = NULL;
 			if (tech_choose_port(tech_pvt) == SWITCH_STATUS_SUCCESS) {
-                activate_rtp(tech_pvt);
-            }
+				activate_rtp(tech_pvt);
+			}
 			goto done;
 		}
 
 		if (channel) {
 			if (switch_test_flag(tech_pvt, TFLAG_EARLY_MEDIA)) {
 				switch_set_flag_locked(tech_pvt, TFLAG_ANS);
-                switch_channel_mark_answered(channel);
-                if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE)) && (other_session = switch_core_session_locate(uuid))) {
-                    other_channel = switch_core_session_get_channel(other_session);
-                    switch_channel_answer(other_channel);
-                    switch_core_session_rwunlock(other_session);
-                }
+				switch_channel_mark_answered(channel);
+				if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))
+					&& (other_session = switch_core_session_locate(uuid))) {
+					other_channel = switch_core_session_get_channel(other_session);
+					switch_channel_answer(other_channel);
+					switch_core_session_rwunlock(other_session);
+				}
 				goto done;
 			}
 
@@ -3218,8 +3175,9 @@ static void sip_i_state(int status,
 			if (r_sdp) {
 				if (switch_test_flag(tech_pvt, TFLAG_NOMEDIA)) {
 					switch_set_flag_locked(tech_pvt, TFLAG_ANS);
-                    switch_channel_mark_answered(channel);
-					if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE)) && (other_session = switch_core_session_locate(uuid))) {
+					switch_channel_mark_answered(channel);
+					if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))
+						&& (other_session = switch_core_session_locate(uuid))) {
 						other_channel = switch_core_session_get_channel(other_session);
 						if (!switch_channel_get_variable(other_channel, SWITCH_B_SDP_VARIABLE)) {
 							switch_channel_set_variable(other_channel, SWITCH_B_SDP_VARIABLE, r_sdp);
@@ -3229,7 +3187,7 @@ static void sip_i_state(int status,
 					}
 					goto done;
 				} else {
-					sdp_parser_t *parser = sdp_parse(tech_pvt->home, r_sdp, (int)strlen(r_sdp), 0);
+					sdp_parser_t *parser = sdp_parse(tech_pvt->home, r_sdp, (int) strlen(r_sdp), 0);
 					sdp_session_t *sdp;
 					uint8_t match = 0;
 
@@ -3247,26 +3205,26 @@ static void sip_i_state(int status,
 					if (match) {
 						switch_set_flag_locked(tech_pvt, TFLAG_ANS);
 						if (tech_choose_port(tech_pvt) == SWITCH_STATUS_SUCCESS) {
-                            activate_rtp(tech_pvt);
-                            switch_channel_mark_answered(channel);
-                            goto done;
-                        }
+							activate_rtp(tech_pvt);
+							switch_channel_mark_answered(channel);
+							goto done;
+						}
 					}
-					
+
 					switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "NO CODECS");
 					nua_respond(nh, SIP_488_NOT_ACCEPTABLE, TAG_END());
 				}
 			}
-			
+
 		}
-		
+
 		break;
 	case nua_callstate_terminating:
 		break;
-	case nua_callstate_terminated: 
+	case nua_callstate_terminated:
 		if (session) {
 			if (!switch_test_flag(tech_pvt, TFLAG_BYE)) {
-                
+
 				switch_set_flag_locked(tech_pvt, TFLAG_BYE);
 				if (switch_test_flag(tech_pvt, TFLAG_NOHUP)) {
 					switch_clear_flag_locked(tech_pvt, TFLAG_NOHUP);
@@ -3277,27 +3235,27 @@ static void sip_i_state(int status,
 				}
 			}
 
-            if (tech_pvt->sofia_private) {
-                free(tech_pvt->sofia_private);
-                tech_pvt->sofia_private = NULL;
-            }
+			if (tech_pvt->sofia_private) {
+				free(tech_pvt->sofia_private);
+				tech_pvt->sofia_private = NULL;
+			}
 			tech_pvt->nh = NULL;
 		} else if (sofia_private) {
-            free(sofia_private);
-        }
+			free(sofia_private);
+		}
 
 		if (nh) {
-            nua_handle_bind(nh, NULL);
+			nua_handle_bind(nh, NULL);
 			nua_handle_destroy(nh);
 		}
 		break;
 	}
 
- done:
+  done:
 
-    if (session) {
-        switch_core_session_rwunlock(session);
-    }
+	if (session) {
+		switch_core_session_rwunlock(session);
+	}
 }
 
 
@@ -3333,7 +3291,7 @@ static char *get_auth_data(char *dbname, char *nonce, char *npassword, size_t le
 
 			if (result == SWITCH_CORE_DB_ROW) {
 				if ((colcount = switch_core_db_column_count(stmt))) {
-					switch_copy_string(npassword, (char *)switch_core_db_column_text(stmt, 0), len);
+					switch_copy_string(npassword, (char *) switch_core_db_column_text(stmt, 0), len);
 					ret = npassword;
 				}
 				break;
@@ -3344,16 +3302,16 @@ static char *get_auth_data(char *dbname, char *nonce, char *npassword, size_t le
 			}
 			break;
 		}
-			
+
 		switch_core_db_finalize(stmt);
 	}
-	
 
- fail:
+
+  fail:
 
 	switch_core_db_close(db);
 
- end:
+  end:
 	if (mutex) {
 		switch_mutex_unlock(mutex);
 	}
@@ -3361,7 +3319,7 @@ static char *get_auth_data(char *dbname, char *nonce, char *npassword, size_t le
 	if (sql) {
 		switch_safe_free(sql);
 	}
-	
+
 	return ret;
 }
 
@@ -3371,13 +3329,9 @@ typedef enum {
 	REG_INVITE
 } sofia_regtype_t;
 
-static uint8_t handle_register(nua_t *nua,
-							   sofia_profile_t *profile,
-							   nua_handle_t *nh,
-							   sip_t const *sip,
-							   sofia_regtype_t regtype,
-							   char *key,
-							   uint32_t keylen)
+static uint8_t handle_register(nua_t * nua,
+							   sofia_profile_t * profile,
+							   nua_handle_t * nh, sip_t const *sip, sofia_regtype_t regtype, char *key, uint32_t keylen)
 {
 	sip_from_t const *from = NULL;
 	sip_expires_t const *expires = NULL;
@@ -3414,7 +3368,8 @@ static uint8_t handle_register(nua_t *nua,
 	}
 
 	if (!from_user || !from_host) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can not do authorization without a complete from header\n");
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+						  "Can not do authorization without a complete from header\n");
 		nua_respond(nh, SIP_500_INTERNAL_SERVER_ERROR, TAG_END());
 		return 1;
 	}
@@ -3431,25 +3386,25 @@ static uint8_t handle_register(nua_t *nua,
 				}
 			}
 		}
-		
+
 		if (!port) {
 			port = SOFIA_DEFAULT_PORT;
 		}
 
 		if (contact->m_url->url_params) {
-			snprintf(contact_str, sizeof(contact_str), "%s ", 
+			snprintf(contact_str, sizeof(contact_str), "%s ",
 					 display, contact->m_url->url_user, contact->m_url->url_host, port, contact->m_url->url_params);
 		} else {
-			snprintf(contact_str, sizeof(contact_str), "%s ", 
+			snprintf(contact_str, sizeof(contact_str), "%s ",
 					 display, contact->m_url->url_user, contact->m_url->url_host, port);
 		}
 	}
-	
+
 	if (expires) {
 		exptime = expires->ex_delta;
 	} else if (contact->m_expires) {
 		exptime = atol(contact->m_expires);
-	} 
+	}
 
 	if (regtype == REG_REGISTER) {
 		authorization = sip->sip_authorization;
@@ -3462,14 +3417,14 @@ static uint8_t handle_register(nua_t *nua,
 	}
 
 	if (authorization) {
-		if ((auth_res = parse_auth(profile, authorization, sip->sip_request->rq_method_name, key, keylen)) == AUTH_STALE) {
-            stale = 1;
-        }
+		if ((auth_res =
+			 parse_auth(profile, authorization, sip->sip_request->rq_method_name, key, keylen)) == AUTH_STALE) {
+			stale = 1;
+		}
 
 		if (auth_res != AUTH_OK && !stale) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "send %s for [%s@%s]\n",
-							  forbidden ? "forbidden" : "challange",
-							  from_user, from_host);
+							  forbidden ? "forbidden" : "challange", from_user, from_host);
 			if (auth_res == AUTH_FORBIDDEN) {
 				nua_respond(nh, SIP_403_FORBIDDEN, NUTAG_WITH_THIS(nua), TAG_END());
 			} else {
@@ -3477,50 +3432,49 @@ static uint8_t handle_register(nua_t *nua,
 			}
 			return 1;
 		}
-	} 
+	}
 
 	if (!authorization || stale) {
-		snprintf(params, sizeof(params), "from_user=%s&from_host=%s&contact=%s",
-				 from_user,
-				 from_host,
-				 contact_str
-				 );
+		snprintf(params, sizeof(params), "from_user=%s&from_host=%s&contact=%s", from_user, from_host, contact_str);
+
 
-		
 		if (switch_xml_locate("directory", "domain", "name", from_host, &xml, &domain, params) != SWITCH_STATUS_SUCCESS) {
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "can't find domain for [%s@%s]\n", from_user, from_host);
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "can't find domain for [%s@%s]\n", from_user,
+							  from_host);
 			nua_respond(nh, SIP_401_UNAUTHORIZED, NUTAG_WITH_THIS(nua), SIPTAG_CONTACT(contact), TAG_END());
 			return 1;
 		}
 
 		if (!(user = switch_xml_find_child(domain, "user", "id", from_user))) {
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "can't find user [%s@%s]\n", from_user, from_host);
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "can't find user [%s@%s]\n", from_user,
+							  from_host);
 			nua_respond(nh, SIP_401_UNAUTHORIZED, NUTAG_WITH_THIS(nua), SIPTAG_CONTACT(contact), TAG_END());
 			switch_xml_free(xml);
 			return 1;
 		}
 
 		if (!(xparams = switch_xml_child(user, "params"))) {
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "can't find params for user [%s@%s]\n", from_user, from_host);
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "can't find params for user [%s@%s]\n", from_user,
+							  from_host);
 			nua_respond(nh, SIP_401_UNAUTHORIZED, NUTAG_WITH_THIS(nua), SIPTAG_CONTACT(contact), TAG_END());
 			switch_xml_free(xml);
 			return 1;
 		}
-	
+
 
 		for (param = switch_xml_child(xparams, "param"); param; param = param->next) {
 			const char *var = switch_xml_attr_soft(param, "name");
 			const char *val = switch_xml_attr_soft(param, "value");
-		
+
 			if (!strcasecmp(var, "password")) {
 				passwd = val;
 			}
 
 			if (!strcasecmp(var, "a1-hash")) {
-                a1_hash = val;
+				a1_hash = val;
 			}
 		}
-	
+
 		if (passwd || a1_hash) {
 			switch_uuid_t uuid;
 			char uuid_str[SWITCH_UUID_FORMATTED_LENGTH + 1];
@@ -3530,43 +3484,36 @@ static uint8_t handle_register(nua_t *nua,
 			char hexdigest[2 * SU_MD5_DIGEST_SIZE + 1];
 			char *input;
 
-            if (!a1_hash) {
-                input = switch_mprintf("%s:%s:%s", from_user, from_host, passwd);
-                su_md5_init(&ctx);
-                su_md5_strupdate(&ctx, input);
-                su_md5_hexdigest(&ctx, hexdigest);
-                su_md5_deinit(&ctx);
-                switch_safe_free(input);
+			if (!a1_hash) {
+				input = switch_mprintf("%s:%s:%s", from_user, from_host, passwd);
+				su_md5_init(&ctx);
+				su_md5_strupdate(&ctx, input);
+				su_md5_hexdigest(&ctx, hexdigest);
+				su_md5_deinit(&ctx);
+				switch_safe_free(input);
 
-                switch_uuid_get(&uuid);
-                switch_uuid_format(uuid_str, &uuid);
-                a1_hash = hexdigest;
-            }
+				switch_uuid_get(&uuid);
+				switch_uuid_format(uuid_str, &uuid);
+				a1_hash = hexdigest;
+			}
 
 			sql = switch_mprintf("delete from sip_authentication where user='%q' and host='%q';\n"
-                                 "insert into sip_authentication values('%q','%q','%q','%q', %ld)",
-                                 from_user,
-                                 from_host,
-                                 from_user,
-                                 from_host,
-                                 a1_hash,
-                                 uuid_str,
-                                 time(NULL) + profile->nonce_ttl);
-			auth_str = switch_mprintf("Digest realm=\"%q\", nonce=\"%q\",%s algorithm=MD5, qop=\"auth\"", from_host, uuid_str, 
-											  stale ? " stale=\"true\"," : "");
+								 "insert into sip_authentication values('%q','%q','%q','%q', %ld)",
+								 from_user,
+								 from_host, from_user, from_host, a1_hash, uuid_str, time(NULL) + profile->nonce_ttl);
+			auth_str =
+				switch_mprintf("Digest realm=\"%q\", nonce=\"%q\",%s algorithm=MD5, qop=\"auth\"", from_host, uuid_str,
+							   stale ? " stale=\"true\"," : "");
 
 
 			if (regtype == REG_REGISTER) {
-				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Requesting Registration from: [%s@%s]\n", from_user, from_host);
-				nua_respond(nh, SIP_401_UNAUTHORIZED,
-							NUTAG_WITH_THIS(nua),
-							SIPTAG_WWW_AUTHENTICATE_STR(auth_str),
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Requesting Registration from: [%s@%s]\n",
+								  from_user, from_host);
+				nua_respond(nh, SIP_401_UNAUTHORIZED, NUTAG_WITH_THIS(nua), SIPTAG_WWW_AUTHENTICATE_STR(auth_str),
 							TAG_END());
 			} else if (regtype == REG_INVITE) {
 				nua_respond(nh, SIP_407_PROXY_AUTH_REQUIRED,
-							NUTAG_WITH_THIS(nua),
-							SIPTAG_PROXY_AUTHENTICATE_STR(auth_str),
-							TAG_END());
+							NUTAG_WITH_THIS(nua), SIPTAG_PROXY_AUTHENTICATE_STR(auth_str), TAG_END());
 
 			}
 
@@ -3577,32 +3524,26 @@ static uint8_t handle_register(nua_t *nua,
 		} else {
 			ret = 0;
 		}
-		
+
 		switch_xml_free(xml);
 
 		if (ret) {
 			return ret;
 		}
 	}
- reg:
+  reg:
 
 	if (exptime) {
 		if (!find_reg_url(profile, from_user, from_host, buf, sizeof(buf))) {
-			sql = switch_mprintf("insert into sip_registrations values ('%q','%q','%q','Registered', '%q', %ld)", 
-								 from_user,
-								 from_host,
-								 contact_str,
-								 rpid,
-								 (long) time(NULL) + (long)exptime * 2);
+			sql = switch_mprintf("insert into sip_registrations values ('%q','%q','%q','Registered', '%q', %ld)",
+								 from_user, from_host, contact_str, rpid, (long) time(NULL) + (long) exptime * 2);
 
 		} else {
-			sql = switch_mprintf("update sip_registrations set contact='%q', expires=%ld, rpid='%q' where user='%q' and host='%q'",
-								 contact_str,
-								 (long) time(NULL) + (long)exptime * 2,
-								 rpid,
-								 from_user,
-								 from_host);
-		
+			sql =
+				switch_mprintf
+				("update sip_registrations set contact='%q', expires=%ld, rpid='%q' where user='%q' and host='%q'",
+				 contact_str, (long) time(NULL) + (long) exptime * 2, rpid, from_user, from_host);
+
 		}
 
 		if (switch_event_create_subclass(&s_event, SWITCH_EVENT_CUSTOM, MY_EVENT_REGISTER) == SWITCH_STATUS_SUCCESS) {
@@ -3611,7 +3552,7 @@ static uint8_t handle_register(nua_t *nua,
 			switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "from-host", "%s", from_host);
 			switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "contact", "%s", contact_str);
 			switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "rpid", "%s", rpid);
-			switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "expires", "%ld", (long)exptime);
+			switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "expires", "%ld", (long) exptime);
 			switch_event_fire(&s_event);
 		}
 
@@ -3620,13 +3561,10 @@ static uint8_t handle_register(nua_t *nua,
 			switch_safe_free(sql);
 			sql = NULL;
 		}
-	
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Register:\nFrom:    [%s@%s]\nContact: [%s]\nExpires: [%ld]\n", 
-						  from_user, 
-						  from_host,
-					  contact_str,
-					  (long)exptime
-					  );
+
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
+						  "Register:\nFrom:    [%s@%s]\nContact: [%s]\nExpires: [%ld]\n", from_user, from_host,
+						  contact_str, (long) exptime);
 
 
 		if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
@@ -3634,7 +3572,7 @@ static uint8_t handle_register(nua_t *nua,
 			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", "%s", profile->url);
 			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "rpid", "%s", rpid);
 			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", from_user, from_host);
-			
+
 			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "status", "Registered");
 			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_type", "presence");
 			switch_event_fire(&event);
@@ -3648,8 +3586,9 @@ static uint8_t handle_register(nua_t *nua,
 		if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_OUT) == SWITCH_STATUS_SUCCESS) {
 			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "proto", "sip");
 			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", "%s", profile->url);
-			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s+%s@%s", SOFIA_CHAT_PROTO, from_user, from_host);
-		
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s+%s@%s", SOFIA_CHAT_PROTO, from_user,
+									from_host);
+
 			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "status", "unavailable");
 			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "rpid", "%s", rpid);
 			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_type", "presence");
@@ -3665,9 +3604,7 @@ static uint8_t handle_register(nua_t *nua,
 	}
 
 	if (regtype == REG_REGISTER) {
-		nua_respond(nh, SIP_200_OK, SIPTAG_CONTACT(contact),
-					NUTAG_WITH_THIS(nua),
-					TAG_END());
+		nua_respond(nh, SIP_200_OK, SIPTAG_CONTACT(contact), NUTAG_WITH_THIS(nua), TAG_END());
 		return 1;
 	}
 
@@ -3761,11 +3698,11 @@ static int sub_callback(void *pArg, int argc, char **argv, char **columnNames)
 		open = "closed";
 	}
 
-    if (!strcasecmp(sub_to_host, host)) {
-        /* same host */
+	if (!strcasecmp(sub_to_host, host)) {
+		/* same host */
 		id = switch_mprintf("sip:%s+%s@%s", proto, sub_to_user, sub_to_host);
 	} else if (strcasecmp(proto, SOFIA_CHAT_PROTO)) {
-		/*encapsulate*/
+		/*encapsulate */
 		id = switch_mprintf("sip:%s+%s+%s@%s", proto, sub_to_user, sub_to_host, host);
 	} else {
 		id = switch_mprintf("sip:%s@%s", sub_to_user, sub_to_host);
@@ -3773,25 +3710,23 @@ static int sub_callback(void *pArg, int argc, char **argv, char **columnNames)
 
 	to = switch_mprintf("sip:%s@%s", user, host);
 	pl = switch_mprintf("\r\n"
-								"\r\n"
-								"\r\n"
-								"\r\n"
-								"%s\r\n"
-								"\r\n"
-								"\r\n"
-								"\r\n"
-								"\r\n"
-								"\r\n"
-								"%s\r\n"
-								"", id, open, rpid, note);
+						"\r\n"
+						"\r\n"
+						"\r\n"
+						"%s\r\n"
+						"\r\n"
+						"\r\n"
+						"\r\n"
+						"\r\n"
+						"\r\n" "%s\r\n" "", id, open, rpid, note);
 
-	
 
-	nh = nua_handle(profile->nua, NULL,	TAG_END());
+
+	nh = nua_handle(profile->nua, NULL, TAG_END());
 	tmp = contact;
 	contact = get_url_from_contact(tmp, 0);
 
@@ -3804,9 +3739,7 @@ static int sub_callback(void *pArg, int argc, char **argv, char **columnNames)
 			   SIPTAG_VIA_STR(full_via),
 			   SIPTAG_SUBSCRIPTION_STATE_STR("active;expires=3600"),
 			   SIPTAG_EVENT_STR(event),
-			   SIPTAG_CONTENT_TYPE_STR("application/pidf+xml"),
-			   SIPTAG_PAYLOAD_STR(pl),
-			   TAG_END());
+			   SIPTAG_CONTENT_TYPE_STR("application/pidf+xml"), SIPTAG_PAYLOAD_STR(pl), TAG_END());
 
 	switch_safe_free(id);
 	switch_safe_free(note);
@@ -3817,496 +3750,466 @@ static int sub_callback(void *pArg, int argc, char **argv, char **columnNames)
 }
 
 static void sip_i_subscribe(int status,
-						char const *phrase, 
-						nua_t *nua,
-						sofia_profile_t *profile,
-						nua_handle_t *nh,
-						sofia_private_t *sofia_private,
-						sip_t const *sip,
-						tagi_t tags[])
+							char const *phrase,
+							nua_t * nua,
+							sofia_profile_t * profile,
+							nua_handle_t * nh, sofia_private_t * sofia_private, sip_t const *sip, tagi_t tags[])
 {
-		if (sip) {
-			long exp, exp_raw;
-			sip_to_t const *to = sip->sip_to;
-			sip_from_t const *from = sip->sip_from;
-			sip_contact_t const *contact = sip->sip_contact;
-			char *from_user = NULL;
-			char *from_host = NULL;
-			char *to_user = NULL;
-			char *to_host = NULL;
-			char *sql, *event = NULL;
-			char *proto = "sip";
-			char *d_user = NULL;
-			char *contact_str = "";
-			char *call_id = NULL;
-			char *to_str = NULL;
-			char *full_from = NULL;
-			char *full_via = NULL;
-			switch_core_db_t *db;
-			char *errmsg;
-			char *sstr;
-			const char *display = "\"user\"";
-			switch_event_t *sevent;
+	if (sip) {
+		long exp, exp_raw;
+		sip_to_t const *to = sip->sip_to;
+		sip_from_t const *from = sip->sip_from;
+		sip_contact_t const *contact = sip->sip_contact;
+		char *from_user = NULL;
+		char *from_host = NULL;
+		char *to_user = NULL;
+		char *to_host = NULL;
+		char *sql, *event = NULL;
+		char *proto = "sip";
+		char *d_user = NULL;
+		char *contact_str = "";
+		char *call_id = NULL;
+		char *to_str = NULL;
+		char *full_from = NULL;
+		char *full_via = NULL;
+		switch_core_db_t *db;
+		char *errmsg;
+		char *sstr;
+		const char *display = "\"user\"";
+		switch_event_t *sevent;
 
-			if (contact) {
-				char *port = (char *) contact->m_url->url_port;
+		if (contact) {
+			char *port = (char *) contact->m_url->url_port;
 
-				display = contact->m_display;
-				
-				if (switch_strlen_zero(display)) {
-					if (from) {
-						display = from->a_display;
-						if (switch_strlen_zero(display)) {
-							display = "\"user\"";
-						}
-					}
-				} else {
-					display = "\"user\"";
-				}
+			display = contact->m_display;
 
-				if (!port) {
-					port = SOFIA_DEFAULT_PORT;
-				}
-
-				if (contact->m_url->url_params) {
-					contact_str = switch_mprintf("%s ", 
-												 display,
-												 contact->m_url->url_user,
-												 contact->m_url->url_host, port, contact->m_url->url_params);
-				} else {
-					contact_str = switch_mprintf("%s ", 
-												 display,
-												 contact->m_url->url_user,
-												 contact->m_url->url_host, port);
-				}
-			}
-			
-			if (to) {
-				to_str = switch_mprintf("sip:%s@%s", to->a_url->url_user, to->a_url->url_host);//, to->a_url->url_port);
-			}
-
-			if (to) {
-				to_user = (char *) to->a_url->url_user;
-				to_host = (char *) to->a_url->url_host;
-			}
-
-
-			if (strstr(to_user, "ext+") || strstr(to_user, "user+") || strstr(to_user, "conf+")) {
-				char proto[80];
-				char *p;
-
-				switch_copy_string(proto, to_user, sizeof(proto));
-				if ((p = strchr(proto, '+'))) {
-					*p = '\0';
-				}
-				
-				if (switch_event_create(&sevent, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
-					switch_event_add_header(sevent, SWITCH_STACK_BOTTOM, "proto", SOFIA_CHAT_PROTO);
-					switch_event_add_header(sevent, SWITCH_STACK_BOTTOM, "login", "%s", profile->name);
-					switch_event_add_header(sevent, SWITCH_STACK_BOTTOM, "from", "%s@%s",  to_user, to_host);
-					switch_event_add_header(sevent, SWITCH_STACK_BOTTOM, "rpid", "unknown");
-					switch_event_add_header(sevent, SWITCH_STACK_BOTTOM, "status", "Click To Call");
-					switch_event_fire(&sevent);
-				}
-			}
-
-			if (strchr(to_user, '+')) {
-				char *h;
-				if ((proto = (d_user = strdup(to_user)))) {
-					if ((to_user = strchr(d_user, '+'))) {
-						*to_user++ = '\0';
-						if ((h = strchr(to_user, '+')) || (h = strchr(to_user, '@'))) {
-							*h++ = '\0';
-							to_host = h;
-						}
+			if (switch_strlen_zero(display)) {
+				if (from) {
+					display = from->a_display;
+					if (switch_strlen_zero(display)) {
+						display = "\"user\"";
 					}
 				}
+			} else {
+				display = "\"user\"";
+			}
 
-				if (!(proto && to_user && to_host)) {
-					nua_respond(nh, SIP_404_NOT_FOUND, NUTAG_WITH_THIS(nua), TAG_END());
-					goto end;
+			if (!port) {
+				port = SOFIA_DEFAULT_PORT;
+			}
+
+			if (contact->m_url->url_params) {
+				contact_str = switch_mprintf("%s ",
+											 display,
+											 contact->m_url->url_user,
+											 contact->m_url->url_host, port, contact->m_url->url_params);
+			} else {
+				contact_str = switch_mprintf("%s ",
+											 display, contact->m_url->url_user, contact->m_url->url_host, port);
+			}
+		}
+
+		if (to) {
+			to_str = switch_mprintf("sip:%s@%s", to->a_url->url_user, to->a_url->url_host);	//, to->a_url->url_port);
+		}
+
+		if (to) {
+			to_user = (char *) to->a_url->url_user;
+			to_host = (char *) to->a_url->url_host;
+		}
+
+
+		if (strstr(to_user, "ext+") || strstr(to_user, "user+") || strstr(to_user, "conf+")) {
+			char proto[80];
+			char *p;
+
+			switch_copy_string(proto, to_user, sizeof(proto));
+			if ((p = strchr(proto, '+'))) {
+				*p = '\0';
+			}
+
+			if (switch_event_create(&sevent, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
+				switch_event_add_header(sevent, SWITCH_STACK_BOTTOM, "proto", SOFIA_CHAT_PROTO);
+				switch_event_add_header(sevent, SWITCH_STACK_BOTTOM, "login", "%s", profile->name);
+				switch_event_add_header(sevent, SWITCH_STACK_BOTTOM, "from", "%s@%s", to_user, to_host);
+				switch_event_add_header(sevent, SWITCH_STACK_BOTTOM, "rpid", "unknown");
+				switch_event_add_header(sevent, SWITCH_STACK_BOTTOM, "status", "Click To Call");
+				switch_event_fire(&sevent);
+			}
+		}
+
+		if (strchr(to_user, '+')) {
+			char *h;
+			if ((proto = (d_user = strdup(to_user)))) {
+				if ((to_user = strchr(d_user, '+'))) {
+					*to_user++ = '\0';
+					if ((h = strchr(to_user, '+')) || (h = strchr(to_user, '@'))) {
+						*h++ = '\0';
+						to_host = h;
+					}
 				}
 			}
 
-			call_id = sip_header_as_string(profile->home, (void *)sip->sip_call_id);
-			event = sip_header_as_string(profile->home, (void *)sip->sip_event);
-			full_from = sip_header_as_string(profile->home, (void *)sip->sip_from);
-			full_via = sip_header_as_string(profile->home, (void *)sip->sip_via);
-
-			exp_raw = (sip->sip_expires ? sip->sip_expires->ex_delta : 3600);
-			exp = (long) time(NULL) + exp_raw;
-			
-            if (sip && sip->sip_from) {
-                from_user = (char *) sip->sip_from->a_url->url_user;
-                from_host = (char *) sip->sip_from->a_url->url_host;
-            } else {
-                from_user = "n/a";
-                from_host = "n/a";
-            }
-
-			if ((sql = switch_mprintf("delete from sip_subscriptions where "
-											  "proto='%q' and user='%q' and host='%q' and sub_to_user='%q' and sub_to_host='%q' and event='%q';\n"
-											  "insert into sip_subscriptions values ('%q','%q','%q','%q','%q','%q','%q','%q','%q','%q',%ld)",
-											  proto,
-											  from_user,
-											  from_host,
-											  to_user,
-											  to_host,
-											  event,
-											  proto,
-											  from_user,
-											  from_host,
-											  to_user,
-											  to_host,
-											  event,
-											  contact_str,
-											  call_id,
-											  full_from,
-											  full_via,
-											  exp
-									  ))) {
-				execute_sql(profile->dbname, sql, profile->ireg_mutex);
-				switch_safe_free(sql);
-			}
-
-			sstr = switch_mprintf("active;expires=%ld", exp_raw);
-
-			nua_respond(nh, SIP_202_ACCEPTED,
-						NUTAG_WITH_THIS(nua),
-						SIPTAG_SUBSCRIPTION_STATE_STR(sstr),
-						SIPTAG_FROM(sip->sip_to),
-						SIPTAG_TO(sip->sip_from),
-						SIPTAG_CONTACT_STR(to_str),
-						TAG_END());
-
-
-
-			switch_safe_free(sstr);
-			
-			if (!(db = switch_core_db_open_file(profile->dbname))) {
-				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening DB %s\n", profile->dbname);
+			if (!(proto && to_user && to_host)) {
+				nua_respond(nh, SIP_404_NOT_FOUND, NUTAG_WITH_THIS(nua), TAG_END());
 				goto end;
 			}
-			if ((sql = switch_mprintf("select * from sip_subscriptions where user='%q' and host='%q'", 
-									  to_user, to_host, to_user, to_host))) {
-				switch_mutex_lock(profile->ireg_mutex);
-				switch_core_db_exec(db, sql, sub_reg_callback, profile, &errmsg);
-				switch_mutex_unlock(profile->ireg_mutex);
-				switch_safe_free(sql);
-			}
-			switch_core_db_close(db);
-		end:
-		
-			if (event) {
-				su_free(profile->home, event);
-			}
-			if (call_id) {
-				su_free(profile->home, call_id);
-			}
-			if (full_from) {
-				su_free(profile->home, full_from);
-			}
-			if (full_via) {
-				su_free(profile->home, full_via);
-			}
-
-			switch_safe_free(d_user);
-			switch_safe_free(to_str);
-			switch_safe_free(contact_str);
 		}
+
+		call_id = sip_header_as_string(profile->home, (void *) sip->sip_call_id);
+		event = sip_header_as_string(profile->home, (void *) sip->sip_event);
+		full_from = sip_header_as_string(profile->home, (void *) sip->sip_from);
+		full_via = sip_header_as_string(profile->home, (void *) sip->sip_via);
+
+		exp_raw = (sip->sip_expires ? sip->sip_expires->ex_delta : 3600);
+		exp = (long) time(NULL) + exp_raw;
+
+		if (sip && sip->sip_from) {
+			from_user = (char *) sip->sip_from->a_url->url_user;
+			from_host = (char *) sip->sip_from->a_url->url_host;
+		} else {
+			from_user = "n/a";
+			from_host = "n/a";
+		}
+
+		if ((sql = switch_mprintf("delete from sip_subscriptions where "
+								  "proto='%q' and user='%q' and host='%q' and sub_to_user='%q' and sub_to_host='%q' and event='%q';\n"
+								  "insert into sip_subscriptions values ('%q','%q','%q','%q','%q','%q','%q','%q','%q','%q',%ld)",
+								  proto,
+								  from_user,
+								  from_host,
+								  to_user,
+								  to_host,
+								  event,
+								  proto,
+								  from_user,
+								  from_host,
+								  to_user, to_host, event, contact_str, call_id, full_from, full_via, exp))) {
+			execute_sql(profile->dbname, sql, profile->ireg_mutex);
+			switch_safe_free(sql);
+		}
+
+		sstr = switch_mprintf("active;expires=%ld", exp_raw);
+
+		nua_respond(nh, SIP_202_ACCEPTED,
+					NUTAG_WITH_THIS(nua),
+					SIPTAG_SUBSCRIPTION_STATE_STR(sstr),
+					SIPTAG_FROM(sip->sip_to), SIPTAG_TO(sip->sip_from), SIPTAG_CONTACT_STR(to_str), TAG_END());
+
+
+
+		switch_safe_free(sstr);
+
+		if (!(db = switch_core_db_open_file(profile->dbname))) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening DB %s\n", profile->dbname);
+			goto end;
+		}
+		if ((sql = switch_mprintf("select * from sip_subscriptions where user='%q' and host='%q'",
+								  to_user, to_host, to_user, to_host))) {
+			switch_mutex_lock(profile->ireg_mutex);
+			switch_core_db_exec(db, sql, sub_reg_callback, profile, &errmsg);
+			switch_mutex_unlock(profile->ireg_mutex);
+			switch_safe_free(sql);
+		}
+		switch_core_db_close(db);
+	  end:
+
+		if (event) {
+			su_free(profile->home, event);
+		}
+		if (call_id) {
+			su_free(profile->home, call_id);
+		}
+		if (full_from) {
+			su_free(profile->home, full_from);
+		}
+		if (full_via) {
+			su_free(profile->home, full_via);
+		}
+
+		switch_safe_free(d_user);
+		switch_safe_free(to_str);
+		switch_safe_free(contact_str);
+	}
 }
 
 static void sip_r_subscribe(int status,
-						char const *phrase, 
-						nua_t *nua,
-						sofia_profile_t *profile,
-						nua_handle_t *nh,
-						sofia_private_t *sofia_private,
-						sip_t const *sip,
-						tagi_t tags[])
+							char const *phrase,
+							nua_t * nua,
+							sofia_profile_t * profile,
+							nua_handle_t * nh, sofia_private_t * sofia_private, sip_t const *sip, tagi_t tags[])
 {
 
 }
 
 
 /*---------------------------------------*/
-static void sip_i_refer(nua_t *nua,
-						sofia_profile_t *profile,
-						nua_handle_t *nh,
-                        switch_core_session_t *session,
-						sip_t const *sip,
-						tagi_t tags[])
+static void sip_i_refer(nua_t * nua,
+						sofia_profile_t * profile,
+						nua_handle_t * nh, switch_core_session_t *session, sip_t const *sip, tagi_t tags[])
 {
 	/* Incoming refer */
 	sip_from_t const *from;
 	sip_to_t const *to;
 	sip_refer_to_t const *refer_to;
-    private_object_t *tech_pvt = NULL;
-    char *etmp = NULL, *exten = NULL;
-    switch_channel_t *channel_a = NULL, *channel_b = NULL;
+	private_object_t *tech_pvt = NULL;
+	char *etmp = NULL, *exten = NULL;
+	switch_channel_t *channel_a = NULL, *channel_b = NULL;
 
-    tech_pvt = switch_core_session_get_private(session);
-    channel_a = switch_core_session_get_channel(session);
+	tech_pvt = switch_core_session_get_private(session);
+	channel_a = switch_core_session_get_channel(session);
 
-    if (!sip->sip_cseq || !(etmp = switch_mprintf("refer;id=%u", sip->sip_cseq->cs_seq))) {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Memory Error!\n");
-        goto done;
-    }
+	if (!sip->sip_cseq || !(etmp = switch_mprintf("refer;id=%u", sip->sip_cseq->cs_seq))) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Memory Error!\n");
+		goto done;
+	}
 
 
-    if (switch_channel_test_flag(channel_a, CF_NOMEDIA)) {
-        nua_notify(tech_pvt->nh, SIPTAG_CONTENT_TYPE_STR("message/sipfrag"),
-                   NUTAG_SUBSTATE(nua_substate_terminated),
-                   SIPTAG_PAYLOAD_STR("SIP/2.0 403 Forbidden"),
-                   SIPTAG_EVENT_STR(etmp),
-                   TAG_END());
-        goto done;
-    }
-		
-    from = sip->sip_from;
-    to = sip->sip_to;
+	if (switch_channel_test_flag(channel_a, CF_NOMEDIA)) {
+		nua_notify(tech_pvt->nh, SIPTAG_CONTENT_TYPE_STR("message/sipfrag"),
+				   NUTAG_SUBSTATE(nua_substate_terminated),
+				   SIPTAG_PAYLOAD_STR("SIP/2.0 403 Forbidden"), SIPTAG_EVENT_STR(etmp), TAG_END());
+		goto done;
+	}
 
-    if ((refer_to = sip->sip_refer_to)) {
-        if (profile->pflags & PFLAG_FULL_ID) {
-            exten = switch_mprintf("%s@%s", (char *) refer_to->r_url->url_user, (char *) refer_to->r_url->url_host);
-        } else {
-            exten = (char *) refer_to->r_url->url_user;
-        }
+	from = sip->sip_from;
+	to = sip->sip_to;
 
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Process REFER to [%s@%s]\n", exten, (char *) refer_to->r_url->url_host);
+	if ((refer_to = sip->sip_refer_to)) {
+		if (profile->pflags & PFLAG_FULL_ID) {
+			exten = switch_mprintf("%s@%s", (char *) refer_to->r_url->url_user, (char *) refer_to->r_url->url_host);
+		} else {
+			exten = (char *) refer_to->r_url->url_user;
+		}
 
-        if (refer_to->r_url->url_headers) {
-            sip_replaces_t *replaces;
-            nua_handle_t *bnh;
-            char *rep;
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Process REFER to [%s@%s]\n", exten,
+						  (char *) refer_to->r_url->url_host);
 
-            if ((rep = strchr(refer_to->r_url->url_headers, '='))) {
-                char *br_a = NULL, *br_b = NULL;
-                char *buf;
-                rep++;
+		if (refer_to->r_url->url_headers) {
+			sip_replaces_t *replaces;
+			nua_handle_t *bnh;
+			char *rep;
 
-					
+			if ((rep = strchr(refer_to->r_url->url_headers, '='))) {
+				char *br_a = NULL, *br_b = NULL;
+				char *buf;
+				rep++;
 
-                if ((buf = switch_core_session_alloc(session, strlen(rep) + 1))) {
-                    rep = url_unescape(buf, (const char *) rep); 
-                    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Replaces: [%s]\n", rep);
-                } else {
-                    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Memory Error!\n");
-                    goto done;
-                }
-                if ((replaces = sip_replaces_make(tech_pvt->home, rep)) && (bnh = nua_handle_by_replaces(nua, replaces))) {
-                    sofia_private_t *b_private = NULL;
-                    private_object_t *b_tech_pvt = NULL;
-                    switch_core_session_t *b_session = NULL;
 
-                    switch_channel_set_variable(channel_a, SOFIA_REPLACES_HEADER, rep);	
-                    if ((b_private = nua_handle_magic(bnh))) {
-                        if (!(b_session = switch_core_session_locate(b_private->uuid))) {
-                            goto done;
-                        }
-                        b_tech_pvt = (private_object_t *) switch_core_session_get_private(b_session);
-                        channel_b = switch_core_session_get_channel(b_session);
-				
-                        br_a = switch_channel_get_variable(channel_a, SWITCH_SIGNAL_BOND_VARIABLE);
-                        br_b = switch_channel_get_variable(channel_b, SWITCH_SIGNAL_BOND_VARIABLE);
 
-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Attended Transfer [%s][%s]\n", br_a, br_b);
-                            
-                        if (br_a && br_b) {
-                            switch_ivr_uuid_bridge(br_a, br_b);
-                            switch_channel_set_variable(channel_b, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "ATTENDED_TRANSFER");
-                            switch_set_flag_locked(tech_pvt, TFLAG_BYE);
-                            switch_set_flag_locked(b_tech_pvt, TFLAG_BYE);
-                            nua_notify(tech_pvt->nh, SIPTAG_CONTENT_TYPE_STR("message/sipfrag"),
-                                       NUTAG_SUBSTATE(nua_substate_terminated),
-                                       SIPTAG_PAYLOAD_STR("SIP/2.0 200 OK"),
-                                       SIPTAG_EVENT_STR(etmp),
-                                       TAG_END());
-                                
-                        } else {
-                            if (!br_a && !br_b) {
-                                switch_set_flag_locked(tech_pvt, TFLAG_NOHUP);
-                                switch_set_flag_locked(b_tech_pvt, TFLAG_XFER);
-                                b_tech_pvt->xferto = switch_core_session_strdup(b_session, switch_core_session_get_uuid(session));
-                            } else if (!br_a && br_b) {
-                                switch_core_session_t *br_b_session;
+				if ((buf = switch_core_session_alloc(session, strlen(rep) + 1))) {
+					rep = url_unescape(buf, (const char *) rep);
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Replaces: [%s]\n", rep);
+				} else {
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Memory Error!\n");
+					goto done;
+				}
+				if ((replaces = sip_replaces_make(tech_pvt->home, rep))
+					&& (bnh = nua_handle_by_replaces(nua, replaces))) {
+					sofia_private_t *b_private = NULL;
+					private_object_t *b_tech_pvt = NULL;
+					switch_core_session_t *b_session = NULL;
 
-                                if ((br_b_session = switch_core_session_locate(br_b))) {
-                                    private_object_t *br_b_tech_pvt = switch_core_session_get_private(br_b_session);
-                                    switch_channel_t *br_b_channel = switch_core_session_get_channel(br_b_session);
-                                    
-                                    switch_set_flag_locked(tech_pvt, TFLAG_NOHUP);
-										
-                                    switch_channel_clear_state_handler(br_b_channel, NULL);
-                                    switch_channel_set_state_flag(br_b_channel, CF_TRANSFER);
-                                    switch_channel_set_state(br_b_channel, CS_TRANSMIT);
+					switch_channel_set_variable(channel_a, SOFIA_REPLACES_HEADER, rep);
+					if ((b_private = nua_handle_magic(bnh))) {
+						if (!(b_session = switch_core_session_locate(b_private->uuid))) {
+							goto done;
+						}
+						b_tech_pvt = (private_object_t *) switch_core_session_get_private(b_session);
+						channel_b = switch_core_session_get_channel(b_session);
 
-                                    switch_set_flag_locked(tech_pvt, TFLAG_REINVITE);
-                                    tech_pvt->local_sdp_audio_ip = switch_core_session_strdup(session, b_tech_pvt->local_sdp_audio_ip);
-                                    tech_pvt->local_sdp_audio_port = b_tech_pvt->local_sdp_audio_port;
+						br_a = switch_channel_get_variable(channel_a, SWITCH_SIGNAL_BOND_VARIABLE);
+						br_b = switch_channel_get_variable(channel_b, SWITCH_SIGNAL_BOND_VARIABLE);
 
-                                    tech_pvt->remote_sdp_audio_ip = switch_core_session_strdup(session, br_b_tech_pvt->remote_sdp_audio_ip);
-                                    tech_pvt->remote_sdp_audio_port = br_b_tech_pvt->remote_sdp_audio_port;
-                                    activate_rtp(tech_pvt);
-	
-                                    br_b_tech_pvt->kick = switch_core_session_strdup(br_b_session, switch_core_session_get_uuid(session));
-										
+						switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Attended Transfer [%s][%s]\n", br_a,
+										  br_b);
 
-                                    switch_core_session_rwunlock(br_b_session);
-                                }
+						if (br_a && br_b) {
+							switch_ivr_uuid_bridge(br_a, br_b);
+							switch_channel_set_variable(channel_b, SWITCH_ENDPOINT_DISPOSITION_VARIABLE,
+														"ATTENDED_TRANSFER");
+							switch_set_flag_locked(tech_pvt, TFLAG_BYE);
+							switch_set_flag_locked(b_tech_pvt, TFLAG_BYE);
+							nua_notify(tech_pvt->nh, SIPTAG_CONTENT_TYPE_STR("message/sipfrag"),
+									   NUTAG_SUBSTATE(nua_substate_terminated),
+									   SIPTAG_PAYLOAD_STR("SIP/2.0 200 OK"), SIPTAG_EVENT_STR(etmp), TAG_END());
 
-                                switch_channel_hangup(channel_b, SWITCH_CAUSE_ATTENDED_TRANSFER);
-                            }
-                            switch_set_flag_locked(tech_pvt, TFLAG_BYE);
-                            nua_notify(tech_pvt->nh, SIPTAG_CONTENT_TYPE_STR("message/sipfrag"),
-                                       NUTAG_SUBSTATE(nua_substate_terminated),
-                                       SIPTAG_PAYLOAD_STR("SIP/2.0 200 OK"),
-                                       SIPTAG_EVENT_STR(etmp),
-                                       TAG_END());
+						} else {
+							if (!br_a && !br_b) {
+								switch_set_flag_locked(tech_pvt, TFLAG_NOHUP);
+								switch_set_flag_locked(b_tech_pvt, TFLAG_XFER);
+								b_tech_pvt->xferto =
+									switch_core_session_strdup(b_session, switch_core_session_get_uuid(session));
+							} else if (!br_a && br_b) {
+								switch_core_session_t *br_b_session;
 
-                        }
-                        if (b_session) {
-                            switch_core_session_rwunlock(b_session);
-                        }
-                    }
-                    nua_handle_unref(bnh);
-                } else { /* the other channel is on a different box, we have to go find them */
-                    if (exten && (br_a = switch_channel_get_variable(channel_a, SWITCH_SIGNAL_BOND_VARIABLE))) {
-                        switch_core_session_t *a_session;
-                        switch_channel_t *channel = switch_core_session_get_channel(session);
-							
-                        if ((a_session = switch_core_session_locate(br_a))) {
-                            switch_core_session_t *tsession;
-                            switch_call_cause_t cause = SWITCH_CAUSE_NORMAL_CLEARING;
-                            uint32_t timeout = 60;
-                            char *tuuid_str;
+								if ((br_b_session = switch_core_session_locate(br_b))) {
+									private_object_t *br_b_tech_pvt = switch_core_session_get_private(br_b_session);
+									switch_channel_t *br_b_channel = switch_core_session_get_channel(br_b_session);
 
-                            channel = switch_core_session_get_channel(a_session);
+									switch_set_flag_locked(tech_pvt, TFLAG_NOHUP);
 
-                            exten = switch_mprintf("sofia/%s/%s@%s:%s", 
-                                                   profile->name,
-                                                   (char *) refer_to->r_url->url_user,
-                                                   (char *) refer_to->r_url->url_host,
-                                                   refer_to->r_url->url_port
-                                                   );
+									switch_channel_clear_state_handler(br_b_channel, NULL);
+									switch_channel_set_state_flag(br_b_channel, CF_TRANSFER);
+									switch_channel_set_state(br_b_channel, CS_TRANSMIT);
 
-                            switch_channel_set_variable(channel, SOFIA_REPLACES_HEADER, rep);
-								
-                            if (switch_ivr_originate(a_session,
-                                                     &tsession,
-                                                     &cause,
-                                                     exten,
-                                                     timeout,
-                                                     &noop_state_handler,
-                                                     NULL,
-                                                     NULL,
-                                                     NULL) != SWITCH_STATUS_SUCCESS) {
-                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot Create Outgoing Channel! [%s]\n", exten);
-                                nua_notify(tech_pvt->nh, SIPTAG_CONTENT_TYPE_STR("message/sipfrag"),
-                                           NUTAG_SUBSTATE(nua_substate_terminated),
-                                           SIPTAG_PAYLOAD_STR("SIP/2.0 403 Forbidden"),
-                                           SIPTAG_EVENT_STR(etmp),
-                                           TAG_END());
-                                goto done;
-                            } 
+									switch_set_flag_locked(tech_pvt, TFLAG_REINVITE);
+									tech_pvt->local_sdp_audio_ip =
+										switch_core_session_strdup(session, b_tech_pvt->local_sdp_audio_ip);
+									tech_pvt->local_sdp_audio_port = b_tech_pvt->local_sdp_audio_port;
 
-                            switch_core_session_rwunlock(a_session);
-                            tuuid_str = switch_core_session_get_uuid(tsession);
-                            switch_ivr_uuid_bridge(br_a, tuuid_str);
-                            switch_channel_set_variable(channel_a, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "ATTENDED_TRANSFER");
-                            switch_set_flag_locked(tech_pvt, TFLAG_BYE);
-                            nua_notify(tech_pvt->nh, SIPTAG_CONTENT_TYPE_STR("message/sipfrag"),
-                                       NUTAG_SUBSTATE(nua_substate_terminated),
-                                       SIPTAG_PAYLOAD_STR("SIP/2.0 200 OK"),
-                                       SIPTAG_EVENT_STR(etmp),
-                                       TAG_END());
-                        } else {
-                            goto error;
-                        }
+									tech_pvt->remote_sdp_audio_ip =
+										switch_core_session_strdup(session, br_b_tech_pvt->remote_sdp_audio_ip);
+									tech_pvt->remote_sdp_audio_port = br_b_tech_pvt->remote_sdp_audio_port;
+									activate_rtp(tech_pvt);
 
-                    } else { error:
-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Transfer! [%s]\n", br_a);
-                        switch_channel_set_variable(channel_a, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "ATTENDED_TRANSFER_ERROR");
-                        nua_notify(tech_pvt->nh, SIPTAG_CONTENT_TYPE_STR("message/sipfrag"),
-                                   NUTAG_SUBSTATE(nua_substate_terminated),
-                                   SIPTAG_PAYLOAD_STR("SIP/2.0 403 Forbidden"),
-                                   SIPTAG_EVENT_STR(etmp),
-                                   TAG_END());
-                    }
-                }
-            } else {
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot parse Replaces!\n");
-            }
-            goto done;
-        }
+									br_b_tech_pvt->kick =
+										switch_core_session_strdup(br_b_session, switch_core_session_get_uuid(session));
 
-    } else {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing Refer-To\n");
-        goto done;
-    }
 
-    if (exten) {
-        switch_channel_t *channel = switch_core_session_get_channel(session);
-        char *br;
-				
-        if ((br = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))) {
-            switch_core_session_t *b_session;
-				
-            if ((b_session = switch_core_session_locate(br))) {
-                switch_channel_set_variable(channel, "TRANSFER_FALLBACK", from->a_user);
-                switch_ivr_session_transfer(b_session, exten, profile->dialplan, profile->context);
-                switch_core_session_rwunlock(b_session);
-            } 
+									switch_core_session_rwunlock(br_b_session);
+								}
 
-            switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "BLIND_TRANSFER");
-                
-            /*
-              nua_notify(tech_pvt->nh, SIPTAG_CONTENT_TYPE_STR("message/sipfrag"),
-              NUTAG_SUBSTATE(nua_substate_terminated),
-              SIPTAG_PAYLOAD_STR("SIP/2.0 200 OK"),
-              SIPTAG_EVENT_STR(etmp),
-              TAG_END());
-            */
-        } else {
-            exten = switch_mprintf("sip:%s@%s:%s", 
-                                   (char *) refer_to->r_url->url_user,
-                                   (char *) refer_to->r_url->url_host,
-                                   refer_to->r_url->url_port);
-            tech_pvt->dest = switch_core_session_strdup(session, exten);
-				
-				
-            switch_set_flag_locked(tech_pvt, TFLAG_NOHUP);
+								switch_channel_hangup(channel_b, SWITCH_CAUSE_ATTENDED_TRANSFER);
+							}
+							switch_set_flag_locked(tech_pvt, TFLAG_BYE);
+							nua_notify(tech_pvt->nh, SIPTAG_CONTENT_TYPE_STR("message/sipfrag"),
+									   NUTAG_SUBSTATE(nua_substate_terminated),
+									   SIPTAG_PAYLOAD_STR("SIP/2.0 200 OK"), SIPTAG_EVENT_STR(etmp), TAG_END());
 
-            /*
-              nua_notify(tech_pvt->nh, SIPTAG_CONTENT_TYPE_STR("message/sipfrag"),
-              NUTAG_SUBSTATE(nua_substate_terminated),
-              SIPTAG_PAYLOAD_STR("SIP/2.0 200 OK"),
-              SIPTAG_EVENT_STR(etmp),
-              TAG_END());
-            */
-            do_xfer_invite(session);
+						}
+						if (b_session) {
+							switch_core_session_rwunlock(b_session);
+						}
+					}
+					nua_handle_unref(bnh);
+				} else {		/* the other channel is on a different box, we have to go find them */
+					if (exten && (br_a = switch_channel_get_variable(channel_a, SWITCH_SIGNAL_BOND_VARIABLE))) {
+						switch_core_session_t *a_session;
+						switch_channel_t *channel = switch_core_session_get_channel(session);
 
-        }
-    }
+						if ((a_session = switch_core_session_locate(br_a))) {
+							switch_core_session_t *tsession;
+							switch_call_cause_t cause = SWITCH_CAUSE_NORMAL_CLEARING;
+							uint32_t timeout = 60;
+							char *tuuid_str;
+
+							channel = switch_core_session_get_channel(a_session);
+
+							exten = switch_mprintf("sofia/%s/%s@%s:%s",
+												   profile->name,
+												   (char *) refer_to->r_url->url_user,
+												   (char *) refer_to->r_url->url_host, refer_to->r_url->url_port);
+
+							switch_channel_set_variable(channel, SOFIA_REPLACES_HEADER, rep);
+
+							if (switch_ivr_originate(a_session,
+													 &tsession,
+													 &cause,
+													 exten,
+													 timeout,
+													 &noop_state_handler, NULL, NULL, NULL) != SWITCH_STATUS_SUCCESS) {
+								switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+												  "Cannot Create Outgoing Channel! [%s]\n", exten);
+								nua_notify(tech_pvt->nh, SIPTAG_CONTENT_TYPE_STR("message/sipfrag"),
+										   NUTAG_SUBSTATE(nua_substate_terminated),
+										   SIPTAG_PAYLOAD_STR("SIP/2.0 403 Forbidden"), SIPTAG_EVENT_STR(etmp),
+										   TAG_END());
+								goto done;
+							}
+
+							switch_core_session_rwunlock(a_session);
+							tuuid_str = switch_core_session_get_uuid(tsession);
+							switch_ivr_uuid_bridge(br_a, tuuid_str);
+							switch_channel_set_variable(channel_a, SWITCH_ENDPOINT_DISPOSITION_VARIABLE,
+														"ATTENDED_TRANSFER");
+							switch_set_flag_locked(tech_pvt, TFLAG_BYE);
+							nua_notify(tech_pvt->nh, SIPTAG_CONTENT_TYPE_STR("message/sipfrag"),
+									   NUTAG_SUBSTATE(nua_substate_terminated),
+									   SIPTAG_PAYLOAD_STR("SIP/2.0 200 OK"), SIPTAG_EVENT_STR(etmp), TAG_END());
+						} else {
+							goto error;
+						}
+
+					} else {
+					  error:
+						switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Transfer! [%s]\n", br_a);
+						switch_channel_set_variable(channel_a, SWITCH_ENDPOINT_DISPOSITION_VARIABLE,
+													"ATTENDED_TRANSFER_ERROR");
+						nua_notify(tech_pvt->nh, SIPTAG_CONTENT_TYPE_STR("message/sipfrag"),
+								   NUTAG_SUBSTATE(nua_substate_terminated), SIPTAG_PAYLOAD_STR("SIP/2.0 403 Forbidden"),
+								   SIPTAG_EVENT_STR(etmp), TAG_END());
+					}
+				}
+			} else {
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot parse Replaces!\n");
+			}
+			goto done;
+		}
+
+	} else {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing Refer-To\n");
+		goto done;
+	}
+
+	if (exten) {
+		switch_channel_t *channel = switch_core_session_get_channel(session);
+		char *br;
+
+		if ((br = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))) {
+			switch_core_session_t *b_session;
+
+			if ((b_session = switch_core_session_locate(br))) {
+				switch_channel_set_variable(channel, "TRANSFER_FALLBACK", from->a_user);
+				switch_ivr_session_transfer(b_session, exten, profile->dialplan, profile->context);
+				switch_core_session_rwunlock(b_session);
+			}
+
+			switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "BLIND_TRANSFER");
+
+			/*
+			   nua_notify(tech_pvt->nh, SIPTAG_CONTENT_TYPE_STR("message/sipfrag"),
+			   NUTAG_SUBSTATE(nua_substate_terminated),
+			   SIPTAG_PAYLOAD_STR("SIP/2.0 200 OK"),
+			   SIPTAG_EVENT_STR(etmp),
+			   TAG_END());
+			 */
+		} else {
+			exten = switch_mprintf("sip:%s@%s:%s",
+								   (char *) refer_to->r_url->url_user,
+								   (char *) refer_to->r_url->url_host, refer_to->r_url->url_port);
+			tech_pvt->dest = switch_core_session_strdup(session, exten);
+
+
+			switch_set_flag_locked(tech_pvt, TFLAG_NOHUP);
+
+			/*
+			   nua_notify(tech_pvt->nh, SIPTAG_CONTENT_TYPE_STR("message/sipfrag"),
+			   NUTAG_SUBSTATE(nua_substate_terminated),
+			   SIPTAG_PAYLOAD_STR("SIP/2.0 200 OK"),
+			   SIPTAG_EVENT_STR(etmp),
+			   TAG_END());
+			 */
+			do_xfer_invite(session);
+
+		}
+	}
+
+  done:
+	if (exten && strchr(exten, '@')) {
+		switch_safe_free(exten);
+	}
+	if (etmp) {
+		switch_safe_free(etmp);
+	}
 
- done:
-    if (exten && strchr(exten, '@')) {
-        switch_safe_free(exten);
-    }
-    if (etmp) {
-        switch_safe_free(etmp);
-    }
-	
 
 }
 
 
-static void sip_i_publish(nua_t *nua, 
-						  sofia_profile_t *profile,
-						  nua_handle_t *nh, 
-						  sofia_private_t *sofia_private,
-						  sip_t const *sip,
-						  tagi_t tags[])
+static void sip_i_publish(nua_t * nua,
+						  sofia_profile_t * profile,
+						  nua_handle_t * nh, sofia_private_t * sofia_private, sip_t const *sip, tagi_t tags[])
 {
 	if (sip) {
 		sip_from_t const *from = sip->sip_from;
@@ -4329,11 +4232,12 @@ static void sip_i_publish(nua_t *nua,
 
 			if ((xml = switch_xml_parse_str(payload->pl_data, strlen(payload->pl_data)))) {
 				char *status_txt = "", *note_txt = "";
-				
-				if ((tuple = switch_xml_child(xml, "tuple")) && (status = switch_xml_child(tuple, "status")) && (basic = switch_xml_child(status, "basic"))) {
+
+				if ((tuple = switch_xml_child(xml, "tuple")) && (status = switch_xml_child(tuple, "status"))
+					&& (basic = switch_xml_child(status, "basic"))) {
 					status_txt = basic->txt;
 				}
-					
+
 				if ((person = switch_xml_child(xml, "dm:person")) && (note = switch_xml_child(person, "dm:note"))) {
 					note_txt = note->txt;
 				}
@@ -4356,14 +4260,15 @@ static void sip_i_publish(nua_t *nua,
 						note_txt = "Unavailable";
 					}
 				}
-				
-				if ((sql = switch_mprintf("update sip_registrations set status='%q',rpid='%q' where user='%q' and host='%q'", 
-										  note_txt, rpid, from_user, from_host))) {
+
+				if ((sql =
+					 switch_mprintf("update sip_registrations set status='%q',rpid='%q' where user='%q' and host='%q'",
+									note_txt, rpid, from_user, from_host))) {
 					execute_sql(profile->dbname, sql, profile->ireg_mutex);
 					switch_safe_free(sql);
 				}
-				
-				event_type = sip_header_as_string(profile->home, (void *)sip->sip_event);
+
+				event_type = sip_header_as_string(profile->home, (void *) sip->sip_event);
 
 				if (in) {
 					if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
@@ -4371,7 +4276,7 @@ static void sip_i_publish(nua_t *nua,
 						switch_event_add_header(event, SWITCH_STACK_BOTTOM, "rpid", "%s", rpid);
 						switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", "%s", profile->url);
 						switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", from_user, from_host);
-						
+
 						switch_event_add_header(event, SWITCH_STACK_BOTTOM, "status", "%s", note_txt);
 						switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_type", "%s", event_type);
 						switch_event_fire(&event);
@@ -4390,25 +4295,23 @@ static void sip_i_publish(nua_t *nua,
 
 				if (event_type) {
 					su_free(profile->home, event_type);
-				}				
+				}
 
 				switch_xml_free(xml);
 			}
-			
+
 		}
-		
+
 	}
 
 	nua_respond(nh, SIP_200_OK, NUTAG_WITH_THIS(nua), TAG_END());
 
 }
 
-static void sip_i_info(nua_t *nua,
-                       sofia_profile_t *profile,
-                       nua_handle_t *nh,
-                       switch_core_session_t *session,
-                       sip_t const *sip,
-                       tagi_t tags[]) {
+static void sip_i_info(nua_t * nua,
+					   sofia_profile_t * profile,
+					   nua_handle_t * nh, switch_core_session_t *session, sip_t const *sip, tagi_t tags[])
+{
 
 	//placeholder for string searching
 	char *signal_ptr;
@@ -4417,10 +4320,10 @@ static void sip_i_info(nua_t *nua,
 	signal_ptr = strstr(sip->sip_payload->pl_data, "Signal=");
 
 	//See if we found a match
-	if(signal_ptr) {
+	if (signal_ptr) {
 		struct private_object *tech_pvt = NULL;
 		switch_channel_t *channel = NULL;
-		char dtmf_digit[2] = {0,0};
+		char dtmf_digit[2] = { 0, 0 };
 
 		//Get the channel
 		channel = switch_core_session_get_channel(session);
@@ -4442,19 +4345,19 @@ static void sip_i_info(nua_t *nua,
 
 		//queue it up
 		switch_channel_queue_dtmf(channel, dtmf_digit);
-		
+
 		//print debug info
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "INFO DTMF(%s)\n", dtmf_digit);
 
-	} else { //unknown info type
+	} else {					//unknown info type
 		sip_from_t const *from;
 
 		from = sip->sip_from;
 
 		//print in the logs if something comes through we don't understand
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Unknown INFO Recieved: %s%s" URL_PRINT_FORMAT "[%s]\n",
-		                  from->a_display ? from->a_display : "", from->a_display ? " " : "",
-		                  URL_PRINT_ARGS(from->a_url), sip->sip_payload->pl_data);
+						  from->a_display ? from->a_display : "", from->a_display ? " " : "",
+						  URL_PRINT_ARGS(from->a_url), sip->sip_payload->pl_data);
 	}
 
 	return;
@@ -4462,7 +4365,8 @@ static void sip_i_info(nua_t *nua,
 
 
 #define url_set_chanvars(session, url, varprefix) _url_set_chanvars(session, url, #varprefix "_user", #varprefix "_host", #varprefix "_port", #varprefix "_uri")
-static const char * _url_set_chanvars(switch_core_session_t *session, url_t *url, const char * user_var, const char * host_var, const char * port_var, const char * uri_var)
+static const char *_url_set_chanvars(switch_core_session_t *session, url_t * url, const char *user_var,
+									 const char *host_var, const char *port_var, const char *uri_var)
 {
 	const char *user = NULL, *host = NULL, *port = NULL;
 	char *uri = NULL;
@@ -4496,22 +4400,22 @@ static const char * _url_set_chanvars(switch_core_session_t *session, url_t *url
 	return uri;
 }
 
-static void process_rpid(sip_unknown_t *un, private_object_t *tech_pvt)
+static void process_rpid(sip_unknown_t * un, private_object_t * tech_pvt)
 {
 	int argc, x, screen = 1;
 	char *mydata, *argv[10] = { 0 };
-	if (!switch_strlen_zero(un->un_value)) { 
+	if (!switch_strlen_zero(un->un_value)) {
 		if ((mydata = strdup(un->un_value))) {
-			argc = switch_separate_string(mydata, ';', argv, (sizeof(argv) / sizeof(argv[0]))); 
+			argc = switch_separate_string(mydata, ';', argv, (sizeof(argv) / sizeof(argv[0])));
 
 			// Do We really need this at this time 
 			// clid_uri = argv[0];
 
-			for (x=1; x < argc && argv[x]; x++){
+			for (x = 1; x < argc && argv[x]; x++) {
 				// we dont need to do anything with party yet we should only be seeing party=calling here anyway
 				// maybe thats a dangerous assumption bit oh well yell at me later
 				// if (!strncasecmp(argv[x], "party", 5)) {
-				//	party = argv[x];
+				//  party = argv[x];
 				// } else 
 				if (!strncasecmp(argv[x], "privacy=", 8)) {
 					char *arg = argv[x] + 9;
@@ -4542,12 +4446,9 @@ static void process_rpid(sip_unknown_t *un, private_object_t *tech_pvt)
 	}
 }
 
-static void sip_i_invite(nua_t *nua, 
-						 sofia_profile_t *profile,
-						 nua_handle_t *nh, 
-						 sofia_private_t *sofia_private,
-						 sip_t const *sip,
-						 tagi_t tags[])
+static void sip_i_invite(nua_t * nua,
+						 sofia_profile_t * profile,
+						 nua_handle_t * nh, sofia_private_t * sofia_private, sip_t const *sip, tagi_t tags[])
 {
 	switch_core_session_t *session = NULL;
 	char key[128] = "";
@@ -4597,7 +4498,8 @@ static void sip_i_invite(nua_t *nua,
 		tech_pvt->key = switch_core_session_strdup(session, key);
 	}
 
-	get_addr(network_ip, sizeof(network_ip), &((struct sockaddr_in *)msg_addrinfo(nua_current_request(nua))->ai_addr)->sin_addr);
+	get_addr(network_ip, sizeof(network_ip),
+			 &((struct sockaddr_in *) msg_addrinfo(nua_current_request(nua))->ai_addr)->sin_addr);
 
 	channel = switch_core_session_get_channel(session);
 
@@ -4608,7 +4510,7 @@ static void sip_i_invite(nua_t *nua,
 
 		if (!switch_strlen_zero(from_user)) {
 			if (*from_user == '+') {
-				switch_channel_set_variable(channel, "sip_from_user_stripped", (const char *)(from_user+1));
+				switch_channel_set_variable(channel, "sip_from_user_stripped", (const char *) (from_user + 1));
 			} else {
 				switch_channel_set_variable(channel, "sip_from_user_stripped", from_user);
 			}
@@ -4632,8 +4534,8 @@ static void sip_i_invite(nua_t *nua,
 	}
 
 	if (sip->sip_request->rq_url) {
-		const char * req_uri = url_set_chanvars(session, sip->sip_request->rq_url, sip_req);
-		if (profile->pflags & PFLAG_FULL_ID)  {
+		const char *req_uri = url_set_chanvars(session, sip->sip_request->rq_url, sip_req);
+		if (profile->pflags & PFLAG_FULL_ID) {
 			destination_number = req_uri;
 		} else {
 			destination_number = sip->sip_request->rq_url->url_user;
@@ -4685,19 +4587,19 @@ static void sip_i_invite(nua_t *nua,
 		switch_channel_set_variable(channel, SWITCH_MAX_FORWARDS_VARIABLE, max_forwards);
 	}
 
-	
+
 	if (sip->sip_request->rq_url) {
 		outbound_reg_t *gateway;
 		char *from_key = switch_core_session_sprintf(session, "sip:%s@%s",
 													 (char *) sip->sip_request->rq_url->url_user,
 													 (char *) sip->sip_request->rq_url->url_host);
-		
+
 		if ((gateway = find_gateway(from_key))) {
 			context = gateway->register_context;
 			switch_channel_set_variable(channel, "sip_gateway", gateway->name);
 		}
 	}
-	
+
 
 	if (!context) {
 		if (profile->context && !strcasecmp(profile->context, "_domain_")) {
@@ -4708,30 +4610,25 @@ static void sip_i_invite(nua_t *nua,
 	}
 
 	tech_pvt->caller_profile = switch_caller_profile_new(switch_core_session_get_pool(session),
-														from_user,
-														profile->dialplan,
-														displayname,
-														from_user,
-														network_ip,
-														NULL,
-														NULL,
-														NULL,
-														modname,
-														context,
-														destination_number);
+														 from_user,
+														 profile->dialplan,
+														 displayname,
+														 from_user,
+														 network_ip,
+														 NULL, NULL, NULL, modname, context, destination_number);
 
 	if (tech_pvt->caller_profile) {
-				
+
 		/* Loop thru unknown Headers Here so we can do something with them */
-		for (un=sip->sip_unknown; un; un=un->un_next) {
+		for (un = sip->sip_unknown; un; un = un->un_next) {
 			if (!strncasecmp(un->un_name, "Alert-Info", 10)) {
-				if (!switch_strlen_zero(un->un_value)) { 
+				if (!switch_strlen_zero(un->un_value)) {
 					switch_channel_set_variable(channel, "alert_info", un->un_value);
 				}
 			} else if (!strncasecmp(un->un_name, "Remote-Party-ID", 15)) {
 				process_rpid(un, tech_pvt);
 			} else if (!strncasecmp(un->un_name, "X-", 2)) {
-				if (!switch_strlen_zero(un->un_value)) { 
+				if (!switch_strlen_zero(un->un_value)) {
 					char *new_name;
 					if ((new_name = switch_mprintf("%s%s", SOFIA_SIP_HEADER_PREFIX, un->un_name))) {
 						switch_channel_set_variable(channel, new_name, un->un_value);
@@ -4748,19 +4645,17 @@ static void sip_i_invite(nua_t *nua,
 		abort();
 	}
 	memset(tech_pvt->sofia_private, 0, sizeof(*tech_pvt->sofia_private));
-	switch_copy_string(tech_pvt->sofia_private->uuid, switch_core_session_get_uuid(session), sizeof(tech_pvt->sofia_private->uuid));
+	switch_copy_string(tech_pvt->sofia_private->uuid, switch_core_session_get_uuid(session),
+					   sizeof(tech_pvt->sofia_private->uuid));
 	nua_handle_bind(nh, tech_pvt->sofia_private);
 	tech_pvt->nh = nh;
 }
 
-static void sip_i_register(nua_t *nua,
-						   sofia_profile_t *profile,
-						   nua_handle_t *nh,
-						   sofia_private_t *sofia_private,
-						   sip_t const *sip,
-						   tagi_t tags[])
+static void sip_i_register(nua_t * nua,
+						   sofia_profile_t * profile,
+						   nua_handle_t * nh, sofia_private_t * sofia_private, sip_t const *sip, tagi_t tags[])
 {
-    char key[128] = "";
+	char key[128] = "";
 
 	if (!sip || !sip->sip_request || !sip->sip_request->rq_method_name) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Received an invalid packet!\n");
@@ -4780,14 +4675,11 @@ static void sip_i_register(nua_t *nua,
 
 static void sip_i_options(int status,
 						  char const *phrase,
-						  nua_t *nua,
-						  sofia_profile_t *profile,
-						  nua_handle_t *nh,
-						  sofia_private_t *sofia_private,
-						  sip_t const *sip,
-						  tagi_t tags[])
+						  nua_t * nua,
+						  sofia_profile_t * profile,
+						  nua_handle_t * nh, sofia_private_t * sofia_private, sip_t const *sip, tagi_t tags[])
 {
-	nua_respond(nh, SIP_200_OK, 
+	nua_respond(nh, SIP_200_OK,
 				//SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str),
 				//SOATAG_AUDIO_AUX("cn telephone-event"),
 				//NUTAG_INCLUDE_EXTRA_SDP(1),
@@ -4797,24 +4689,22 @@ static void sip_i_options(int status,
 
 static void sip_r_register(int status,
 						   char const *phrase,
-						   nua_t *nua,
-						   sofia_profile_t *profile,
-						   nua_handle_t *nh,
-						   sofia_private_t *sofia_private,
-						   sip_t const *sip,
-						   tagi_t tags[])
+						   nua_t * nua,
+						   sofia_profile_t * profile,
+						   nua_handle_t * nh, sofia_private_t * sofia_private, sip_t const *sip, tagi_t tags[])
 {
 	if (sofia_private && sofia_private->gateway) {
 		switch (status) {
 		case 200:
 			if (sip && sip->sip_contact && sip->sip_contact->m_expires) {
 				char *new_expires = (char *) sip->sip_contact->m_expires;
-				uint32_t expi = (uint32_t)atoi(new_expires);
-				
+				uint32_t expi = (uint32_t) atoi(new_expires);
+
 				if (expi != sofia_private->gateway->freq) {
 					sofia_private->gateway->freq = expi;
 					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE,
-									  "Changing expire time to %d by request of proxy %s\n", expi, sofia_private->gateway->register_proxy);
+									  "Changing expire time to %d by request of proxy %s\n", expi,
+									  sofia_private->gateway->register_proxy);
 				}
 
 			}
@@ -4831,24 +4721,21 @@ static void sip_r_register(int status,
 }
 
 static void sip_r_challenge(int status,
-                            char const *phrase,
-                            nua_t *nua,
-                            sofia_profile_t *profile,
-                            nua_handle_t *nh,
-                            switch_core_session_t *session,
-                            sip_t const *sip,
-                            tagi_t tags[])
+							char const *phrase,
+							nua_t * nua,
+							sofia_profile_t * profile,
+							nua_handle_t * nh, switch_core_session_t *session, sip_t const *sip, tagi_t tags[])
 {
 	outbound_reg_t *gateway = NULL;
 	sip_www_authenticate_t const *authenticate = NULL;
-	char const *realm = NULL; 
+	char const *realm = NULL;
 	char *p = NULL, *duprealm = NULL, *qrealm = NULL;
 	char const *scheme = NULL;
 	int indexnum;
 	char *cur;
 	char authentication[256] = "";
 	int ss_state;
-	
+
 	if (session) {
 		private_object_t *tech_pvt;
 		if ((tech_pvt = switch_core_session_get_private(session)) && switch_test_flag(tech_pvt, TFLAG_REFER)) {
@@ -4868,7 +4755,7 @@ static void sip_r_challenge(int status,
 	}
 	scheme = (char const *) authenticate->au_scheme;
 	if (authenticate->au_params) {
-		for(indexnum = 0; (cur=(char*)authenticate->au_params[indexnum]); indexnum++) {
+		for (indexnum = 0; (cur = (char *) authenticate->au_params[indexnum]); indexnum++) {
 			if ((realm = strstr(cur, "realm="))) {
 				realm += 6;
 				break;
@@ -4886,30 +4773,31 @@ static void sip_r_challenge(int status,
 
 		if ((duprealm = strdup(realm))) {
 			qrealm = duprealm;
-	
-			while(*qrealm && *qrealm == '"') {
+
+			while (*qrealm && *qrealm == '"') {
 				qrealm++;
 			}
 
 			if ((p = strchr(qrealm, '"'))) {
 				*p = '\0';
 			}
-			
+
 			if (sip->sip_from) {
-				char *from_key = switch_mprintf("sip:%s@%s", 
+				char *from_key = switch_mprintf("sip:%s@%s",
 												(char *) sip->sip_from->a_url->url_user,
 												(char *) sip->sip_from->a_url->url_host);
 
 				if (!(gateway = find_gateway(from_key))) {
 					gateway = find_gateway(qrealm);
-				} 
-				
+				}
+
 				switch_safe_free(from_key);
 			}
 
 			if (!gateway) {
 				for (gateway_ptr = profile->gateways; gateway_ptr; gateway_ptr = gateway_ptr->next) {
-					if (scheme && qrealm && !strcasecmp(gateway_ptr->register_scheme, scheme) && !strcasecmp(gateway_ptr->register_realm, qrealm)) {
+					if (scheme && qrealm && !strcasecmp(gateway_ptr->register_scheme, scheme)
+						&& !strcasecmp(gateway_ptr->register_realm, qrealm)) {
 						gateway = gateway_ptr;
 						break;
 					}
@@ -4917,7 +4805,8 @@ static void sip_r_challenge(int status,
 			}
 
 			if (!gateway) {
-				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No Match for Scheme [%s] Realm [%s]\n", scheme, qrealm);
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No Match for Scheme [%s] Realm [%s]\n", scheme,
+								  qrealm);
 				return;
 			}
 			switch_safe_free(duprealm);
@@ -4926,80 +4815,73 @@ static void sip_r_challenge(int status,
 			return;
 		}
 	}
-		
-	snprintf(authentication, sizeof(authentication), "%s:%s:%s:%s", scheme, realm, 
-			 gateway->register_username,
-			 gateway->register_password);
-		
+
+	snprintf(authentication, sizeof(authentication), "%s:%s:%s:%s", scheme, realm,
+			 gateway->register_username, gateway->register_password);
+
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Authenticating '%s' with '%s'.\n",
 					  profile->username, authentication);
-		
-		
+
+
 	ss_state = nua_callstate_authenticating;
-		
-	tl_gets(tags,
-			NUTAG_CALLSTATE_REF(ss_state),
-			SIPTAG_WWW_AUTHENTICATE_REF(authenticate),
-			TAG_END());
-		
+
+	tl_gets(tags, NUTAG_CALLSTATE_REF(ss_state), SIPTAG_WWW_AUTHENTICATE_REF(authenticate), TAG_END());
+
 	nua_authenticate(nh, SIPTAG_EXPIRES_STR(gateway->expires_str), NUTAG_AUTH(authentication), TAG_END());
-	
+
 }
 
 static void event_callback(nua_event_t event,
 						   int status,
 						   char const *phrase,
-						   nua_t *nua,
-						   sofia_profile_t *profile,
-						   nua_handle_t *nh,
-						   sofia_private_t *sofia_private,
-						   sip_t const *sip,
-						   tagi_t tags[])
+						   nua_t * nua,
+						   sofia_profile_t * profile,
+						   nua_handle_t * nh, sofia_private_t * sofia_private, sip_t const *sip, tagi_t tags[])
 {
 	struct private_object *tech_pvt = NULL;
 	auth_res_t auth_res = AUTH_FORBIDDEN;
 	switch_core_session_t *session = NULL;
-    switch_channel_t *channel = NULL;
+	switch_channel_t *channel = NULL;
 
-    if (sofia_private) {
-        if (!switch_strlen_zero(sofia_private->uuid)) {
+	if (sofia_private) {
+		if (!switch_strlen_zero(sofia_private->uuid)) {
 
-            if ((session = switch_core_session_locate(sofia_private->uuid))) {
-                tech_pvt = switch_core_session_get_private(session);
-                channel = switch_core_session_get_channel(tech_pvt->session);
-                if (switch_channel_test_flag(channel, CF_NOMEDIA)) {
-                    switch_set_flag(tech_pvt, TFLAG_NOMEDIA);
-                }
-                if (!tech_pvt->call_id && sip && sip->sip_call_id && sip->sip_call_id->i_id) {
-                    tech_pvt->call_id = switch_core_session_strdup(session, (char *)sip->sip_call_id->i_id);
-                    switch_channel_set_variable(channel, "sip_call_id", tech_pvt->call_id);
-                }
-            } else {
-                /* too late */
-                return;            
-            }
-        }
-    }
+			if ((session = switch_core_session_locate(sofia_private->uuid))) {
+				tech_pvt = switch_core_session_get_private(session);
+				channel = switch_core_session_get_channel(tech_pvt->session);
+				if (switch_channel_test_flag(channel, CF_NOMEDIA)) {
+					switch_set_flag(tech_pvt, TFLAG_NOMEDIA);
+				}
+				if (!tech_pvt->call_id && sip && sip->sip_call_id && sip->sip_call_id->i_id) {
+					tech_pvt->call_id = switch_core_session_strdup(session, (char *) sip->sip_call_id->i_id);
+					switch_channel_set_variable(channel, "sip_call_id", tech_pvt->call_id);
+				}
+			} else {
+				/* too late */
+				return;
+			}
+		}
+	}
 
 
 	if (status != 100 && status != 200) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "event [%s] status [%d][%s] session: %s\n",
-						  nua_event_name (event), status, phrase,
-						  session ? switch_channel_get_name(channel) : "n/a"
-						  );
+						  nua_event_name(event), status, phrase, session ? switch_channel_get_name(channel) : "n/a");
 	}
 
 	if ((profile->pflags & PFLAG_AUTH_ALL) && tech_pvt && tech_pvt->key && sip) {
 		sip_authorization_t const *authorization = NULL;
 
-        if (sip->sip_authorization) {
+		if (sip->sip_authorization) {
 			authorization = sip->sip_authorization;
 		} else if (sip->sip_proxy_authorization) {
 			authorization = sip->sip_proxy_authorization;
 		}
 
 		if (authorization) {
-			auth_res = parse_auth(profile, authorization, (char *)sip->sip_request->rq_method_name, tech_pvt->key, strlen(tech_pvt->key));
+			auth_res =
+				parse_auth(profile, authorization, (char *) sip->sip_request->rq_method_name, tech_pvt->key,
+						   strlen(tech_pvt->key));
 		}
 
 		if (auth_res != AUTH_OK) {
@@ -5017,46 +4899,46 @@ static void event_callback(nua_event_t event,
 		sip_r_challenge(status, phrase, nua, profile, nh, session, sip, tags);
 		goto done;
 	}
-	
+
 	switch (event) {
-	case nua_r_shutdown:    
-	case nua_r_get_params:    
+	case nua_r_shutdown:
+	case nua_r_get_params:
 	case nua_r_invite:
-    case nua_r_unregister:
-    case nua_r_options:
+	case nua_r_unregister:
+	case nua_r_options:
 	case nua_i_fork:
 	case nua_r_info:
-    case nua_r_bye:
+	case nua_r_bye:
 	case nua_i_bye:
 	case nua_r_unsubscribe:
 	case nua_r_publish:
 	case nua_r_message:
 	case nua_r_notify:
-    case nua_i_notify:
+	case nua_i_notify:
 	case nua_i_cancel:
 	case nua_i_error:
 	case nua_i_active:
 	case nua_i_ack:
 	case nua_i_terminated:
 	case nua_r_set_params:
-        break;
+		break;
 	case nua_r_register:
 		sip_r_register(status, phrase, nua, profile, nh, sofia_private, sip, tags);
 		break;
 	case nua_i_options:
 		sip_i_options(status, phrase, nua, profile, nh, sofia_private, sip, tags);
 		break;
-    case nua_i_invite:
-        if (!session) {
-            sip_i_invite(nua, profile, nh, sofia_private, sip, tags);
-        }
+	case nua_i_invite:
+		if (!session) {
+			sip_i_invite(nua, profile, nh, sofia_private, sip, tags);
+		}
 		break;
 	case nua_i_publish:
 		sip_i_publish(nua, profile, nh, sofia_private, sip, tags);
 		break;
-    case nua_i_register:
- 		sip_i_register (nua, profile, nh, sofia_private, sip, tags);
-        break;
+	case nua_i_register:
+		sip_i_register(nua, profile, nh, sofia_private, sip, tags);
+		break;
 	case nua_i_prack:
 		break;
 	case nua_i_state:
@@ -5071,11 +4953,11 @@ static void event_callback(nua_event_t event,
 	case nua_r_refer:
 		break;
 	case nua_i_refer:
-        if (session) {
-            sip_i_refer(nua, profile, nh, session, sip, tags);
-        }
+		if (session) {
+			sip_i_refer(nua, profile, nh, session, sip, tags);
+		}
 		break;
-    case nua_r_subscribe:
+	case nua_r_subscribe:
 		sip_r_subscribe(status, phrase, nua, profile, nh, sofia_private, sip, tags);
 		break;
 	case nua_i_subscribe:
@@ -5083,15 +4965,16 @@ static void event_callback(nua_event_t event,
 		break;
 	default:
 		if (status > 100) {
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s: unknown event %d: %03d %s\n", 
-							  nua_event_name (event), event, status, phrase);
-        } else {
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s: unknown event %d\n", nua_event_name (event), event);
-        }
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s: unknown event %d: %03d %s\n",
+							  nua_event_name(event), event, status, phrase);
+		} else {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s: unknown event %d\n", nua_event_name(event),
+							  event);
+		}
 		break;
 	}
 
- done:
+  done:
 
 	if (session) {
 		switch_core_session_rwunlock(session);
@@ -5099,44 +4982,44 @@ static void event_callback(nua_event_t event,
 }
 
 
-static void unreg(sofia_profile_t *profile)
+static void unreg(sofia_profile_t * profile)
 {
 	outbound_reg_t *gateway_ptr;
-    for (gateway_ptr = profile->gateways; gateway_ptr; gateway_ptr = gateway_ptr->next) {
-        if (gateway_ptr->sofia_private) {
-            free(gateway_ptr->sofia_private);
-            nua_handle_bind(gateway_ptr->nh, NULL);
-            gateway_ptr->sofia_private = NULL;
-        }
+	for (gateway_ptr = profile->gateways; gateway_ptr; gateway_ptr = gateway_ptr->next) {
+		if (gateway_ptr->sofia_private) {
+			free(gateway_ptr->sofia_private);
+			nua_handle_bind(gateway_ptr->nh, NULL);
+			gateway_ptr->sofia_private = NULL;
+		}
 		nua_handle_destroy(gateway_ptr->nh);
 	}
 }
 
-static void check_gateway(sofia_profile_t *profile, time_t now)
+static void check_gateway(sofia_profile_t * profile, time_t now)
 {
 	outbound_reg_t *gateway_ptr;
 	for (gateway_ptr = profile->gateways; gateway_ptr; gateway_ptr = gateway_ptr->next) {
 		int ss_state = nua_callstate_authenticating;
 		reg_state_t ostate = gateway_ptr->state;
 
-		switch(ostate) {
+		switch (ostate) {
 		case REG_STATE_REGISTER:
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE,  "registered %s\n", gateway_ptr->name);
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "registered %s\n", gateway_ptr->name);
 			gateway_ptr->expires = now + gateway_ptr->freq;
 			gateway_ptr->state = REG_STATE_REGED;
 			break;
 		case REG_STATE_UNREGED:
 			if ((gateway_ptr->nh = nua_handle(gateway_ptr->profile->nua, NULL,
-										NUTAG_URL(gateway_ptr->register_proxy),
-										SIPTAG_TO_STR(gateway_ptr->register_to),
-										NUTAG_CALLSTATE_REF(ss_state),
-										SIPTAG_FROM_STR(gateway_ptr->register_from), TAG_END()))) {
-				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE,  "registering %s\n", gateway_ptr->name);	
-                
-                if (!(gateway_ptr->sofia_private = malloc(sizeof(*gateway_ptr->sofia_private)))) {
-                    abort();
-                }
-                memset(gateway_ptr->sofia_private, 0, sizeof(*gateway_ptr->sofia_private));
+											  NUTAG_URL(gateway_ptr->register_proxy),
+											  SIPTAG_TO_STR(gateway_ptr->register_to),
+											  NUTAG_CALLSTATE_REF(ss_state),
+											  SIPTAG_FROM_STR(gateway_ptr->register_from), TAG_END()))) {
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "registering %s\n", gateway_ptr->name);
+
+				if (!(gateway_ptr->sofia_private = malloc(sizeof(*gateway_ptr->sofia_private)))) {
+					abort();
+				}
+				memset(gateway_ptr->sofia_private, 0, sizeof(*gateway_ptr->sofia_private));
 
 				gateway_ptr->sofia_private->gateway = gateway_ptr;
 				nua_handle_bind(gateway_ptr->nh, gateway_ptr->sofia_private);
@@ -5147,13 +5030,11 @@ static void check_gateway(sofia_profile_t *profile, time_t now)
 							 SIPTAG_EXPIRES_STR(gateway_ptr->expires_str),
 							 NUTAG_REGISTRAR(gateway_ptr->register_proxy),
 							 NUTAG_OUTBOUND("no-options-keepalive"),
-							 NUTAG_OUTBOUND("no-validate"),
-							 NUTAG_KEEPALIVE(0),
-							 TAG_NULL());
+							 NUTAG_OUTBOUND("no-validate"), NUTAG_KEEPALIVE(0), TAG_NULL());
 				gateway_ptr->retry = now + 10;
 				gateway_ptr->state = REG_STATE_TRYING;
 			} else {
-				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,  "Error registering %s\n", gateway_ptr->name);
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error registering %s\n", gateway_ptr->name);
 				gateway_ptr->state = REG_STATE_FAILED;
 			}
 			break;
@@ -5189,15 +5070,13 @@ static void *SWITCH_THREAD_FUNC profile_thread_run(switch_thread_t *thread, void
 	profile->s_root = su_root_create(NULL);
 	profile->home = su_home_new(sizeof(*profile->home));
 
-	profile->nua = nua_create(profile->s_root, /* Event loop */
-							  event_callback, /* Callback for processing events */
-							  profile, /* Additional data to pass to callback */
-							  NUTAG_URL(profile->bindurl),
-							  NTATAG_UDP_MTU(65536),
-							  TAG_END()); /* Last tag should always finish the sequence */
+	profile->nua = nua_create(profile->s_root,	/* Event loop */
+							  event_callback,	/* Callback for processing events */
+							  profile,	/* Additional data to pass to callback */
+							  NUTAG_URL(profile->bindurl), NTATAG_UDP_MTU(65536), TAG_END());	/* Last tag should always finish the sequence */
 
 	nua_set_params(profile->nua,
-				   //NUTAG_EARLY_MEDIA(1),				   
+				   //NUTAG_EARLY_MEDIA(1),                 
 				   NUTAG_AUTOANSWER(0),
 				   NUTAG_AUTOALERT(0),
 				   NUTAG_ALLOW("REGISTER"),
@@ -5209,20 +5088,17 @@ static void *SWITCH_THREAD_FUNC profile_thread_run(switch_thread_t *thread, void
 				   TAG_IF((profile->pflags & PFLAG_PRESENCE), NUTAG_ENABLEMESSAGE(1)),
 				   TAG_IF((profile->pflags & PFLAG_PRESENCE), NUTAG_ALLOW_EVENTS("presence")),
 				   TAG_IF((profile->pflags & PFLAG_PRESENCE), NUTAG_ALLOW_EVENTS("presence.winfo")),
-				   SIPTAG_SUPPORTED_STR("100rel, precondition"),
-				   SIPTAG_USER_AGENT_STR(SOFIA_USER_AGENT),
-				   TAG_END());
-				   
+				   SIPTAG_SUPPORTED_STR("100rel, precondition"), SIPTAG_USER_AGENT_STR(SOFIA_USER_AGENT), TAG_END());
+
 
 	for (node = profile->aliases; node; node = node->next) {
-		node->nua = nua_create(profile->s_root, /* Event loop */
-							   event_callback, /* Callback for processing events */
-							   profile, /* Additional data to pass to callback */
-							   NUTAG_URL(node->url),
-							   TAG_END()); /* Last tag should always finish the sequence */
+		node->nua = nua_create(profile->s_root,	/* Event loop */
+							   event_callback,	/* Callback for processing events */
+							   profile,	/* Additional data to pass to callback */
+							   NUTAG_URL(node->url), TAG_END());	/* Last tag should always finish the sequence */
 
 		nua_set_params(node->nua,
-				   NUTAG_EARLY_MEDIA(1),				   
+					   NUTAG_EARLY_MEDIA(1),
 					   NUTAG_AUTOANSWER(0),
 					   NUTAG_AUTOALERT(0),
 					   NUTAG_ALLOW("REGISTER"),
@@ -5231,9 +5107,8 @@ static void *SWITCH_THREAD_FUNC profile_thread_run(switch_thread_t *thread, void
 					   TAG_IF((profile->pflags & PFLAG_PRESENCE), NUTAG_ALLOW("PUBLISH")),
 					   TAG_IF((profile->pflags & PFLAG_PRESENCE), NUTAG_ENABLEMESSAGE(1)),
 					   SIPTAG_SUPPORTED_STR("100rel, precondition"),
-					   SIPTAG_USER_AGENT_STR(SOFIA_USER_AGENT),
-					   TAG_END());
-		
+					   SIPTAG_USER_AGENT_STR(SOFIA_USER_AGENT), TAG_END());
+
 	}
 
 
@@ -5277,7 +5152,7 @@ static void *SWITCH_THREAD_FUNC profile_thread_run(switch_thread_t *thread, void
 		establish_presence(profile);
 	}
 
-	while(globals.running == 1) {
+	while (globals.running == 1) {
 		if (++ireg_loops >= IREG_SECONDS) {
 			check_expire(db, profile, time(NULL));
 			ireg_loops = 0;
@@ -5294,7 +5169,7 @@ static void *SWITCH_THREAD_FUNC profile_thread_run(switch_thread_t *thread, void
 	switch_core_db_close(db);
 	unreg(profile);
 	su_home_unref(profile->home);
-	
+
 
 	if (switch_event_create(&s_event, SWITCH_EVENT_UNPUBLISH) == SWITCH_STATUS_SUCCESS) {
 		switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "service", "_sip._udp");
@@ -5308,15 +5183,15 @@ static void *SWITCH_THREAD_FUNC profile_thread_run(switch_thread_t *thread, void
 	switch_mutex_lock(globals.mutex);
 	globals.running = 0;
 	switch_mutex_unlock(globals.mutex);
-	
+
 	return NULL;
 }
 
-static void launch_profile_thread(sofia_profile_t *profile)
+static void launch_profile_thread(sofia_profile_t * profile)
 {
 	switch_thread_t *thread;
 	switch_threadattr_t *thd_attr = NULL;
-	
+
 	switch_threadattr_create(&thd_attr, profile->pool);
 	switch_threadattr_detach_set(thd_attr, 1);
 	switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
@@ -5362,7 +5237,7 @@ static switch_status_t config_sofia(int reload)
 				char *xprofilename = (char *) switch_xml_attr_soft(xprofile, "name");
 				switch_memory_pool_t *pool = NULL;
 
-				
+
 				/* Setup the pool */
 				if ((status = switch_core_new_memory_pool(&pool)) != SWITCH_STATUS_SUCCESS) {
 					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
@@ -5377,7 +5252,7 @@ static switch_status_t config_sofia(int reload)
 				if (!xprofilename) {
 					xprofilename = "unnamed";
 				}
-		
+
 				profile->pool = pool;
 
 				profile->name = switch_core_strdup(profile->pool, xprofilename);
@@ -5385,7 +5260,7 @@ static switch_status_t config_sofia(int reload)
 				profile->dbname = switch_core_strdup(profile->pool, url);
 				switch_core_hash_init(&profile->chat_hash, profile->pool);
 
-				profile->dtmf_duration = 100;		
+				profile->dtmf_duration = 100;
 				profile->codec_ms = 20;
 
 				for (param = switch_xml_child(settings, "param"); param; param = param->next) {
@@ -5418,21 +5293,21 @@ static switch_status_t config_sofia(int reload)
 							switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invald option %s for VAD\n", val);
 						}
 					} else if (!strcasecmp(var, "ext-rtp-ip")) {
-						profile->extrtpip = switch_core_strdup(profile->pool, strcasecmp(val, "auto") ? val : globals.guess_ip);
+						profile->extrtpip =
+							switch_core_strdup(profile->pool, strcasecmp(val, "auto") ? val : globals.guess_ip);
 					} else if (!strcasecmp(var, "rtp-ip")) {
-						profile->rtpip = switch_core_strdup(profile->pool, strcasecmp(val, "auto") ? val : globals.guess_ip);
+						profile->rtpip =
+							switch_core_strdup(profile->pool, strcasecmp(val, "auto") ? val : globals.guess_ip);
 					} else if (!strcasecmp(var, "sip-ip")) {
-						profile->sipip = switch_core_strdup(profile->pool, strcasecmp(val, "auto") ? val : globals.guess_ip);
+						profile->sipip =
+							switch_core_strdup(profile->pool, strcasecmp(val, "auto") ? val : globals.guess_ip);
 					} else if (!strcasecmp(var, "ext-sip-ip")) {
 						if (!strcasecmp(val, "auto")) {
 							profile->extsipip = switch_core_strdup(profile->pool, globals.guess_ip);
 						} else {
 							char *ip = NULL;
 							switch_port_t port = 0;
-							if (sofia_ext_address_lookup(&ip,
-														&port,
-														val,
-														profile->pool) == SWITCH_STATUS_SUCCESS) {
+							if (sofia_ext_address_lookup(&ip, &port, val, profile->pool) == SWITCH_STATUS_SUCCESS) {
 
 								if (ip) {
 									profile->extsipip = switch_core_strdup(profile->pool, ip);
@@ -5461,7 +5336,7 @@ static switch_status_t config_sofia(int reload)
 							profile->pflags |= PFLAG_AUTH_CALLS;
 						}
 					} else if (!strcasecmp(var, "nonce-ttl")) {
-                        profile->nonce_ttl = atoi(val);
+						profile->nonce_ttl = atoi(val);
 					} else if (!strcasecmp(var, "accept-blind-reg")) {
 						if (switch_true(val)) {
 							profile->pflags |= PFLAG_BLIND_REG;
@@ -5477,7 +5352,7 @@ static switch_status_t config_sofia(int reload)
 					} else if (!strcasecmp(var, "bitpacking")) {
 						if (!strcasecmp(val, "aal2")) {
 							profile->codec_flags = SWITCH_CODEC_FLAG_AAL2;
-						} 
+						}
 					} else if (!strcasecmp(var, "username")) {
 						profile->username = switch_core_strdup(profile->pool, val);
 					} else if (!strcasecmp(var, "context")) {
@@ -5508,25 +5383,25 @@ static switch_status_t config_sofia(int reload)
 					}
 				}
 
-                if (!profile->cng_pt) {
+				if (!profile->cng_pt) {
 					profile->cng_pt = SWITCH_RTP_CNG_PAYLOAD;
 				}
 
-                if (!profile->sipip) {
-                    profile->sipip = switch_core_strdup(profile->pool, globals.guess_ip);
-                }
+				if (!profile->sipip) {
+					profile->sipip = switch_core_strdup(profile->pool, globals.guess_ip);
+				}
 
-                if (!profile->rtpip) {
-                    profile->rtpip = switch_core_strdup(profile->pool, globals.guess_ip);
-                }
+				if (!profile->rtpip) {
+					profile->rtpip = switch_core_strdup(profile->pool, globals.guess_ip);
+				}
 
-                if (profile->nonce_ttl < 60) {
-                    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Setting nonce TTL to 60 seconds\n");
-                    profile->nonce_ttl = 60;
-                }
+				if (profile->nonce_ttl < 60) {
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Setting nonce TTL to 60 seconds\n");
+					profile->nonce_ttl = 60;
+				}
 
 				if (switch_test_flag(profile, TFLAG_TIMER) && !profile->timer_name) {
-					profile->timer_name = switch_core_strdup(profile->pool, "soft");			
+					profile->timer_name = switch_core_strdup(profile->pool, "soft");
 				}
 
 				if (!profile->username) {
@@ -5550,48 +5425,48 @@ static switch_status_t config_sofia(int reload)
 					profile->sipdomain = switch_core_strdup(profile->pool, profile->sipip);
 				}
 				if (profile->extsipip) {
-					profile->url = switch_core_sprintf(profile->pool, "sip:mod_sofia@%s:%d", profile->extsipip, profile->sip_port);
+					profile->url =
+						switch_core_sprintf(profile->pool, "sip:mod_sofia@%s:%d", profile->extsipip, profile->sip_port);
 					profile->bindurl = switch_core_sprintf(profile->pool, "%s;maddr=%s", profile->url, profile->sipip);
 				} else {
-					profile->url = switch_core_sprintf(profile->pool, "sip:mod_sofia@%s:%d", profile->sipip, profile->sip_port);
+					profile->url =
+						switch_core_sprintf(profile->pool, "sip:mod_sofia@%s:%d", profile->sipip, profile->sip_port);
 					profile->bindurl = profile->url;
 				}
 			}
 			if (profile) {
 				if ((gateways_tag = switch_xml_child(xprofile, "registrations"))) {
-					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, 
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT,
 									  "The  syntax has been discontinued, please see the new syntax in the default configuration examples\n");
 				}
 
 				if ((gateways_tag = switch_xml_child(xprofile, "gateways"))) {
-					for (gateway_tag = switch_xml_child(gateways_tag, "gateway"); gateway_tag; gateway_tag = gateway_tag->next) {
+					for (gateway_tag = switch_xml_child(gateways_tag, "gateway"); gateway_tag;
+						 gateway_tag = gateway_tag->next) {
 						char *name = (char *) switch_xml_attr_soft(gateway_tag, "name");
 						outbound_reg_t *gateway;
-						
+
 						if (switch_strlen_zero(name)) {
 							name = "anonymous";
 						}
-						
+
 						if ((gateway = switch_core_alloc(profile->pool, sizeof(*gateway)))) {
 							char *scheme = "Digest",
 								*realm = NULL,
 								*username = NULL,
 								*password = NULL,
-								*extension = NULL,
-								*proxy = NULL,
-								*context = "default",
-								*expire_seconds = "3600";
+								*extension = NULL, *proxy = NULL, *context = "default", *expire_seconds = "3600";
 
 							gateway->pool = profile->pool;
 							gateway->profile = profile;
 							gateway->name = switch_core_strdup(gateway->pool, name);
 							gateway->freq = 0;
-							
-							
+
+
 							for (param = switch_xml_child(gateway_tag, "param"); param; param = param->next) {
 								char *var = (char *) switch_xml_attr_soft(param, "name");
 								char *val = (char *) switch_xml_attr_soft(param, "value");
-								
+
 								if (!strcmp(var, "scheme")) {
 									scheme = val;
 								} else if (!strcmp(var, "realm")) {
@@ -5614,23 +5489,25 @@ static switch_status_t config_sofia(int reload)
 							if (switch_strlen_zero(realm)) {
 								realm = name;
 							}
-							
+
 							if (switch_strlen_zero(username)) {
-								switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ERROR: username param is REQUIRED!\n");
+								switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+												  "ERROR: username param is REQUIRED!\n");
 								switch_xml_free(xml);
 								goto skip;
 							}
-							
+
 							if (switch_strlen_zero(password)) {
-								switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ERROR: password param is REQUIRED!\n");
+								switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+												  "ERROR: password param is REQUIRED!\n");
 								switch_xml_free(xml);
 								goto skip;
 							}
-							
+
 							if (switch_strlen_zero(extension)) {
 								extension = username;
 							}
-							
+
 							if (switch_strlen_zero(proxy)) {
 								proxy = realm;
 							}
@@ -5642,34 +5519,40 @@ static switch_status_t config_sofia(int reload)
 							gateway->register_password = switch_core_strdup(gateway->pool, password);
 							gateway->register_from = switch_core_sprintf(gateway->pool, "sip:%s@%s", username, realm);
 							gateway->register_contact = switch_core_sprintf(gateway->pool,
-																			"sip:%s@%s:%d", extension, profile->sipip, profile->sip_port);
-								
+																			"sip:%s@%s:%d", extension, profile->sipip,
+																			profile->sip_port);
+
 							if (!strncasecmp(proxy, "sip:", 4)) {
 								gateway->register_proxy = switch_core_strdup(gateway->pool, proxy);
-								gateway->register_to = switch_core_sprintf(gateway->pool, "sip:%s@%s", username, proxy + 4);
+								gateway->register_to =
+									switch_core_sprintf(gateway->pool, "sip:%s@%s", username, proxy + 4);
 							} else {
 								gateway->register_proxy = switch_core_sprintf(gateway->pool, "sip:%s", proxy);
 								gateway->register_to = switch_core_sprintf(gateway->pool, "sip:%s@%s", username, proxy);
 							}
-							
+
 							gateway->expires_str = switch_core_strdup(gateway->pool, expire_seconds);
-							
+
 							if ((gateway->freq = atoi(gateway->expires_str)) < 5) {
-                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
-												  "Invalid Freq: %d.  Setting Register-Frequency to 3600\n", gateway->freq);
-                                gateway->freq = 3600;
-                            }
-                            gateway->freq -= 2;
+								switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
+												  "Invalid Freq: %d.  Setting Register-Frequency to 3600\n",
+												  gateway->freq);
+								gateway->freq = 3600;
+							}
+							gateway->freq -= 2;
 
 							gateway->next = profile->gateways;
 							profile->gateways = gateway;
 
 							if (find_gateway(gateway->name)) {
-								switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Ignoring duplicate gateway '%s'\n", gateway->name);
+								switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
+												  "Ignoring duplicate gateway '%s'\n", gateway->name);
 							} else if (find_gateway(gateway->register_from)) {
-								switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Ignoring duplicate uri '%s'\n", gateway->register_from);
+								switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
+												  "Ignoring duplicate uri '%s'\n", gateway->register_from);
 							} else if (find_gateway(gateway->register_contact)) {
-								switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Ignoring duplicate contact '%s'\n", gateway->register_from);
+								switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
+												  "Ignoring duplicate contact '%s'\n", gateway->register_from);
 							} else {
 								add_gateway(gateway->name, gateway);
 								add_gateway(gateway->register_from, gateway);
@@ -5677,22 +5560,24 @@ static switch_status_t config_sofia(int reload)
 							}
 						}
 
-					skip:
+					  skip:
 						assert(gateway_tag);
 					}
 				}
 
 				if (profile->sipip) {
-					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Started Profile %s [%s]\n", profile->name, url);
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Started Profile %s [%s]\n", profile->name,
+									  url);
 					launch_profile_thread(profile);
 				} else {
-					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Unable to start Profile %s due to no configured sip-ip\n", profile->name);
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE,
+									  "Unable to start Profile %s due to no configured sip-ip\n", profile->name);
 				}
 				profile = NULL;
 			}
 		}
 	}
- done:
+  done:
 	if (xml) {
 		switch_xml_free(xml);
 	}
@@ -5711,7 +5596,7 @@ static void event_handler(switch_event_t *event)
 		char *contact_str = switch_event_get_header(event, "orig-contact");
 		char *exp_str = switch_event_get_header(event, "orig-expires");
 		char *rpid = switch_event_get_header(event, "orig-rpid");
-		long expires = (long)time(NULL) + atol(exp_str);
+		long expires = (long) time(NULL) + atol(exp_str);
 		char *profile_name = switch_event_get_header(event, "orig-profile-name");
 		sofia_profile_t *profile;
 		char buf[512];
@@ -5727,27 +5612,21 @@ static void event_handler(switch_event_t *event)
 
 
 		if (!find_reg_url(profile, from_user, from_host, buf, sizeof(buf))) {
-			sql = switch_mprintf("insert into sip_registrations values ('%q','%q','%q','Regestered', '%q', %ld)", 
-								 from_user,
-								 from_host,
-								 contact_str,
-								 rpid,
-								 expires);
+			sql = switch_mprintf("insert into sip_registrations values ('%q','%q','%q','Regestered', '%q', %ld)",
+								 from_user, from_host, contact_str, rpid, expires);
 		} else {
-			sql = switch_mprintf("update sip_registrations set contact='%q', rpid='%q', expires=%ld where user='%q' and host='%q'",
-								 contact_str,
-								 rpid,
-								 expires,
-								 from_user,
-								 from_host);
-			
+			sql =
+				switch_mprintf
+				("update sip_registrations set contact='%q', rpid='%q', expires=%ld where user='%q' and host='%q'",
+				 contact_str, rpid, expires, from_user, from_host);
+
 		}
-	
+
 		if (sql) {
 			execute_sql(profile->dbname, sql, profile->ireg_mutex);
 			switch_safe_free(sql);
 			sql = NULL;
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Propagating registration for %s@%s->%s\n", 
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Propagating registration for %s@%s->%s\n",
 							  from_user, from_host, contact_str);
 
 		}
@@ -5769,18 +5648,15 @@ static switch_status_t chat_send(char *proto, char *from, char *to, char *subjec
 		if ((host = strchr(user, '@'))) {
 			*host++ = '\0';
 		}
-		
+
 		if (!host || !(profile = find_profile(host))) {
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Chat proto [%s]\nfrom [%s]\nto [%s]\n%s\nInvalid Profile %s\n", 
-                              proto,
-                              from,
-                              to,
-                              body ? body : "[no body]",
-                              host ? host : "NULL");
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+							  "Chat proto [%s]\nfrom [%s]\nto [%s]\n%s\nInvalid Profile %s\n", proto, from, to,
+							  body ? body : "[no body]", host ? host : "NULL");
 			return SWITCH_STATUS_FALSE;
 		}
 
-        if (!find_reg_url(profile, user, host, buf, sizeof(buf))) {
+		if (!find_reg_url(profile, user, host, buf, sizeof(buf))) {
 			return SWITCH_STATUS_FALSE;
 		}
 
@@ -5799,48 +5675,42 @@ static switch_status_t chat_send(char *proto, char *from, char *to, char *subjec
 				fu = strdup(fp);
 				*p = '+';
 			}
-			
-			ffrom = switch_mprintf("\"%s\" ", fu, proto, fp, profile->name);			
+
+			ffrom = switch_mprintf("\"%s\" ", fu, proto, fp, profile->name);
 			from = ffrom;
 			switch_safe_free(fu);
 			switch_safe_free(fp);
 		}
 
 		contact = get_url_from_contact(buf, 1);
-		msg_nh = nua_handle(profile->nua, NULL,
-							SIPTAG_FROM_STR(from),
-							NUTAG_URL(contact),
-							SIPTAG_TO_STR(buf), // if this cries, add contact here too, change the 1 to 0 and omit the safe_free
-							SIPTAG_CONTACT_STR(profile->url),
-							TAG_END());
+		msg_nh = nua_handle(profile->nua, NULL, SIPTAG_FROM_STR(from), NUTAG_URL(contact), SIPTAG_TO_STR(buf),	// if this cries, add contact here too, change the 1 to 0 and omit the safe_free
+							SIPTAG_CONTACT_STR(profile->url), TAG_END());
 
 		switch_safe_free(contact);
 
 
-		nua_message(msg_nh,
-					SIPTAG_CONTENT_TYPE_STR("text/html"),
-					SIPTAG_PAYLOAD_STR(body),
-					TAG_END());
-		
-		
+		nua_message(msg_nh, SIPTAG_CONTENT_TYPE_STR("text/html"), SIPTAG_PAYLOAD_STR(body), TAG_END());
+
+
 		switch_safe_free(ffrom);
 		free(user);
 	}
-		
+
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static void cancel_presence(void) 
+static void cancel_presence(void)
 {
 	char *sql, *errmsg = NULL;
 	switch_core_db_t *db;
 	sofia_profile_t *profile;
 	switch_hash_index_t *hi;
-    void *val;
+	void *val;
 
 	if ((sql = switch_mprintf("select 0,'unavailable','unavailable',* from sip_subscriptions where event='presence'"))) {
 		switch_mutex_lock(globals.hash_mutex);
-		for (hi = switch_hash_first(switch_hash_pool_get(globals.profile_hash), globals.profile_hash); hi; hi = switch_hash_next(hi)) {
+		for (hi = switch_hash_first(switch_hash_pool_get(globals.profile_hash), globals.profile_hash); hi;
+			 hi = switch_hash_next(hi)) {
 			switch_hash_this(hi, NULL, NULL, &val);
 			profile = (sofia_profile_t *) val;
 			if (!(profile->pflags & PFLAG_PRESENCE)) {
@@ -5861,7 +5731,7 @@ static void cancel_presence(void)
 	switch_mutex_unlock(globals.hash_mutex);
 }
 
-static void establish_presence(sofia_profile_t *profile) 
+static void establish_presence(sofia_profile_t * profile)
 {
 	char *sql, *errmsg = NULL;
 	switch_core_db_t *db;
@@ -5907,7 +5777,7 @@ static char *translate_rpid(char *in, char *ext)
 	if (!in) {
 		return NULL;
 	}
-	
+
 	if (!strcasecmp(in, "dnd")) {
 		r = "busy";
 	}
@@ -5915,7 +5785,7 @@ static char *translate_rpid(char *in, char *ext)
 	if (ext && !strcasecmp(ext, "away")) {
 		r = "idle";
 	}
-	
+
 	return r;
 }
 
@@ -5923,11 +5793,11 @@ static void pres_event_handler(switch_event_t *event)
 {
 	sofia_profile_t *profile;
 	switch_hash_index_t *hi;
-    void *val;
+	void *val;
 	char *from = switch_event_get_header(event, "from");
 	char *proto = switch_event_get_header(event, "proto");
 	char *rpid = switch_event_get_header(event, "rpid");
-	char *status= switch_event_get_header(event, "status");
+	char *status = switch_event_get_header(event, "status");
 	char *event_type = switch_event_get_header(event, "event_type");
 	//char *event_subtype = switch_event_get_header(event, "event_subtype");
 	char *sql = NULL;
@@ -5946,7 +5816,7 @@ static void pres_event_handler(switch_event_t *event)
 
 	if (rpid) {
 		rpid = translate_rpid(rpid, status);
-	} 
+	}
 
 	if (!status) {
 		status = "Available";
@@ -5969,13 +5839,17 @@ static void pres_event_handler(switch_event_t *event)
 	if (event->event_id == SWITCH_EVENT_ROSTER) {
 
 		if (from) {
-			sql = switch_mprintf("select 1,'%q','%q',* from sip_subscriptions where event='presence' and full_from like '%%%q%%'", status, rpid, from);
+			sql =
+				switch_mprintf
+				("select 1,'%q','%q',* from sip_subscriptions where event='presence' and full_from like '%%%q%%'",
+				 status, rpid, from);
 		} else {
 			sql = switch_mprintf("select 1,'%q','%q',* from sip_subscriptions where event='presence'", status, rpid);
 		}
 
 		switch_mutex_lock(globals.hash_mutex);
-		for (hi = switch_hash_first(switch_hash_pool_get(globals.profile_hash), globals.profile_hash); hi; hi = switch_hash_next(hi)) {
+		for (hi = switch_hash_first(switch_hash_pool_get(globals.profile_hash), globals.profile_hash); hi;
+			 hi = switch_hash_next(hi)) {
 			switch_hash_this(hi, NULL, NULL, &val);
 			profile = (sofia_profile_t *) val;
 			if (!(profile->pflags & PFLAG_PRESENCE)) {
@@ -6000,7 +5874,7 @@ static void pres_event_handler(switch_event_t *event)
 	}
 
 	if (switch_strlen_zero(event_type)) {
-		event_type="presence";
+		event_type = "presence";
 	}
 
 	if ((user = strdup(from))) {
@@ -6019,69 +5893,75 @@ static void pres_event_handler(switch_event_t *event)
 		} else {
 			euser = user;
 		}
-		
+
 	} else {
 		return;
 	}
 
 
-	switch(event->event_id) {
-    case SWITCH_EVENT_PRESENCE_PROBE: 
-        if (proto) {
-            switch_core_db_t *db = NULL;
-            char *to = switch_event_get_header(event, "to");
-            char *user, *euser, *host, *p;
+	switch (event->event_id) {
+	case SWITCH_EVENT_PRESENCE_PROBE:
+		if (proto) {
+			switch_core_db_t *db = NULL;
+			char *to = switch_event_get_header(event, "to");
+			char *user, *euser, *host, *p;
 
-            if (!to || !(user = strdup(to))) {
-                return;
-            }
+			if (!to || !(user = strdup(to))) {
+				return;
+			}
 
-            if ((host = strchr(user, '@'))) {
-                *host++ = '\0';
-            }
-            euser = user;
-            if ((p = strchr(euser, '+'))) {
-                euser = (p+1);
-            }
+			if ((host = strchr(user, '@'))) {
+				*host++ = '\0';
+			}
+			euser = user;
+			if ((p = strchr(euser, '+'))) {
+				euser = (p + 1);
+			}
 
-            if (euser && host && 
-                (sql = switch_mprintf("select user,host,status,rpid,'' from sip_registrations where user='%q' and host='%q'", euser, host)) &&
-                (profile = find_profile(host))) {
-                if (!(db = switch_core_db_open_file(profile->dbname))) {
-                    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening DB %s\n", profile->dbname);
-                    switch_safe_free(user);
-                    switch_safe_free(sql);
-                    return;
-                }
+			if (euser && host &&
+				(sql =
+				 switch_mprintf("select user,host,status,rpid,'' from sip_registrations where user='%q' and host='%q'",
+								euser, host)) && (profile = find_profile(host))) {
+				if (!(db = switch_core_db_open_file(profile->dbname))) {
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening DB %s\n", profile->dbname);
+					switch_safe_free(user);
+					switch_safe_free(sql);
+					return;
+				}
 
-                switch_mutex_lock(profile->ireg_mutex);
-                switch_core_db_exec(db, sql, resub_callback, profile, &errmsg);
-                switch_mutex_unlock(profile->ireg_mutex);
-                switch_safe_free(sql);
-            }
-            switch_safe_free(user);
-            switch_core_db_close(db);
-        }
-        return;
+				switch_mutex_lock(profile->ireg_mutex);
+				switch_core_db_exec(db, sql, resub_callback, profile, &errmsg);
+				switch_mutex_unlock(profile->ireg_mutex);
+				switch_safe_free(sql);
+			}
+			switch_safe_free(user);
+			switch_core_db_close(db);
+		}
+		return;
 	case SWITCH_EVENT_PRESENCE_IN:
-		sql = switch_mprintf("select 1,'%q','%q',* from sip_subscriptions where proto='%q' and event='%q' and sub_to_user='%q' and sub_to_host='%q'", 
-							 status , rpid, proto, event_type, euser, host);
+		sql =
+			switch_mprintf
+			("select 1,'%q','%q',* from sip_subscriptions where proto='%q' and event='%q' and sub_to_user='%q' and sub_to_host='%q'",
+			 status, rpid, proto, event_type, euser, host);
 		break;
 	case SWITCH_EVENT_PRESENCE_OUT:
-		sql = switch_mprintf("select 0,'%q','%q',* from sip_subscriptions where proto='%q' and event='%q' and sub_to_user='%q' and sub_to_host='%q'", 
-							 status, rpid, proto, event_type, euser, host);
+		sql =
+			switch_mprintf
+			("select 0,'%q','%q',* from sip_subscriptions where proto='%q' and event='%q' and sub_to_user='%q' and sub_to_host='%q'",
+			 status, rpid, proto, event_type, euser, host);
 		break;
 	default:
 		break;
 	}
 
 	switch_mutex_lock(globals.hash_mutex);
-    for (hi = switch_hash_first(switch_hash_pool_get(globals.profile_hash), globals.profile_hash); hi; hi = switch_hash_next(hi)) {
-        switch_hash_this(hi, NULL, NULL, &val);
-        profile = (sofia_profile_t *) val;
-        if (!(profile->pflags & PFLAG_PRESENCE)) {
+	for (hi = switch_hash_first(switch_hash_pool_get(globals.profile_hash), globals.profile_hash); hi;
+		 hi = switch_hash_next(hi)) {
+		switch_hash_this(hi, NULL, NULL, &val);
+		profile = (sofia_profile_t *) val;
+		if (!(profile->pflags & PFLAG_PRESENCE)) {
 			continue;
-        }
+		}
 
 		if (sql) {
 			if (!(db = switch_core_db_open_file(profile->dbname))) {
@@ -6091,7 +5971,7 @@ static void pres_event_handler(switch_event_t *event)
 			switch_mutex_lock(profile->ireg_mutex);
 			switch_core_db_exec(db, sql, sub_callback, profile, &errmsg);
 			switch_mutex_unlock(profile->ireg_mutex);
-			
+
 			switch_core_db_close(db);
 		}
 	}
@@ -6102,7 +5982,8 @@ static void pres_event_handler(switch_event_t *event)
 }
 
 
-SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
+													   char *filename)
 {
 
 	silence_frame.data = silence_data;
@@ -6119,9 +6000,10 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_mod
 	memset(&globals, 0, sizeof(globals));
 	switch_mutex_init(&globals.mutex, SWITCH_MUTEX_NESTED, module_pool);
 
-    switch_find_local_ip(globals.guess_ip, sizeof(globals.guess_ip), AF_INET);
+	switch_find_local_ip(globals.guess_ip, sizeof(globals.guess_ip), AF_INET);
 
-	if (switch_event_bind((char *) modname, SWITCH_EVENT_CUSTOM, MULTICAST_EVENT, event_handler, NULL) != SWITCH_STATUS_SUCCESS) {
+	if (switch_event_bind((char *) modname, SWITCH_EVENT_CUSTOM, MULTICAST_EVENT, event_handler, NULL) !=
+		SWITCH_STATUS_SUCCESS) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
 		return SWITCH_STATUS_TERM;
 	}
@@ -6137,22 +6019,29 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_mod
 	config_sofia(0);
 
 
-	if (switch_event_bind((char *) modname, SWITCH_EVENT_PRESENCE_IN, SWITCH_EVENT_SUBCLASS_ANY, pres_event_handler, NULL) != SWITCH_STATUS_SUCCESS) {
+	if (switch_event_bind
+		((char *) modname, SWITCH_EVENT_PRESENCE_IN, SWITCH_EVENT_SUBCLASS_ANY, pres_event_handler,
+		 NULL) != SWITCH_STATUS_SUCCESS) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
 		return SWITCH_STATUS_GENERR;
 	}
 
-	if (switch_event_bind((char *) modname, SWITCH_EVENT_PRESENCE_OUT, SWITCH_EVENT_SUBCLASS_ANY, pres_event_handler, NULL) != SWITCH_STATUS_SUCCESS) {
+	if (switch_event_bind
+		((char *) modname, SWITCH_EVENT_PRESENCE_OUT, SWITCH_EVENT_SUBCLASS_ANY, pres_event_handler,
+		 NULL) != SWITCH_STATUS_SUCCESS) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
 		return SWITCH_STATUS_GENERR;
 	}
 
-	if (switch_event_bind((char *) modname, SWITCH_EVENT_PRESENCE_PROBE, SWITCH_EVENT_SUBCLASS_ANY, pres_event_handler, NULL) != SWITCH_STATUS_SUCCESS) {
+	if (switch_event_bind
+		((char *) modname, SWITCH_EVENT_PRESENCE_PROBE, SWITCH_EVENT_SUBCLASS_ANY, pres_event_handler,
+		 NULL) != SWITCH_STATUS_SUCCESS) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
 		return SWITCH_STATUS_GENERR;
 	}
 
-	if (switch_event_bind((char *) modname, SWITCH_EVENT_ROSTER, SWITCH_EVENT_SUBCLASS_ANY, pres_event_handler, NULL) != SWITCH_STATUS_SUCCESS) {
+	if (switch_event_bind((char *) modname, SWITCH_EVENT_ROSTER, SWITCH_EVENT_SUBCLASS_ANY, pres_event_handler, NULL) !=
+		SWITCH_STATUS_SUCCESS) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
 		return SWITCH_STATUS_GENERR;
 	}
@@ -6176,7 +6065,7 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_shutdown(void)
 	}
 	switch_mutex_unlock(globals.mutex);
 
-	while(globals.running) {
+	while (globals.running) {
 		switch_yield(1000);
 	}
 
diff --git a/src/mod/endpoints/mod_wanpipe/libsangoma/g711.h b/src/mod/endpoints/mod_wanpipe/libsangoma/g711.h
index 78099cd1c8..390e53eed0 100644
--- a/src/mod/endpoints/mod_wanpipe/libsangoma/g711.h
+++ b/src/mod/endpoints/mod_wanpipe/libsangoma/g711.h
@@ -50,137 +50,110 @@ extern "C" {
 #ifndef __inline__
 #define __inline__ __inline
 #endif
-typedef unsigned __int8 uint8_t;
-typedef __int16 int16_t;
-typedef __int32 int32_t;
-typedef unsigned __int16 uint16_t;
+	typedef unsigned __int8 uint8_t;
+	typedef __int16 int16_t;
+	typedef __int32 int32_t;
+	typedef unsigned __int16 uint16_t;
 #endif
 
 #if defined(__i386__)
 /*! \brief Find the bit position of the highest set bit in a word
     \param bits The word to be searched
     \return The bit number of the highest set bit, or -1 if the word is zero. */
-static __inline__ int top_bit(unsigned int bits)
-{
-    int res;
+	static __inline__ int top_bit(unsigned int bits) {
+		int res;
 
-    __asm__ __volatile__(" movl $-1,%%edx;\n"
-                         " bsrl %%eax,%%edx;\n"
-                         : "=d" (res)
-                         : "a" (bits));
-    return res;
-}
-/*- End of function --------------------------------------------------------*/
+		__asm__ __volatile__(" movl $-1,%%edx;\n" " bsrl %%eax,%%edx;\n":"=d"(res)
+							 :"a"    (bits));
+		        return res;
+	}
+	/*- End of function --------------------------------------------------------*//*! \brief Find the bit position of the lowest set bit in a word
+	   \param bits The word to be searched
+	   \return The bit number of the lowest set bit, or -1 if the word is zero. */
+		static __inline__ int bottom_bit(unsigned int bits) {
+		int res;
 
-/*! \brief Find the bit position of the lowest set bit in a word
-    \param bits The word to be searched
-    \return The bit number of the lowest set bit, or -1 if the word is zero. */
-static __inline__ int bottom_bit(unsigned int bits)
-{
-    int res;
-
-    __asm__ __volatile__(" movl $-1,%%edx;\n"
-                         " bsfl %%eax,%%edx;\n"
-                         : "=d" (res)
-                         : "a" (bits));
-    return res;
-}
+		__asm__ __volatile__(" movl $-1,%%edx;\n" " bsfl %%eax,%%edx;\n":"=d"(res)
+							 :"a"    (bits));
+		return res;
+	}
 /*- End of function --------------------------------------------------------*/
 #elif defined(__x86_64__)
-static __inline__ int top_bit(unsigned int bits)
-{
-    int res;
+	static __inline__ int top_bit(unsigned int bits) {
+		int res;
 
-    __asm__ __volatile__(" movq $-1,%%rdx;\n"
-                         " bsrq %%rax,%%rdx;\n"
-                         : "=d" (res)
-                         : "a" (bits));
-    return res;
-}
+		__asm__ __volatile__(" movq $-1,%%rdx;\n" " bsrq %%rax,%%rdx;\n":"=d"(res)
+							 :"a"    (bits));
+		        return res;
+	}
 /*- End of function --------------------------------------------------------*/
+		static __inline__ int bottom_bit(unsigned int bits) {
+		int res;
 
-static __inline__ int bottom_bit(unsigned int bits)
-{
-    int res;
-
-    __asm__ __volatile__(" movq $-1,%%rdx;\n"
-                         " bsfq %%rax,%%rdx;\n"
-                         : "=d" (res)
-                         : "a" (bits));
-    return res;
-}
+		__asm__ __volatile__(" movq $-1,%%rdx;\n" " bsfq %%rax,%%rdx;\n":"=d"(res)
+							 :"a"    (bits));
+		return res;
+	}
 /*- End of function --------------------------------------------------------*/
 #else
-static __inline__ int top_bit(unsigned int bits)
-{
-    int i;
-    
-    if (bits == 0)
-        return -1;
-    i = 0;
-    if (bits & 0xFFFF0000)
-    {
-        bits &= 0xFFFF0000;
-        i += 16;
-    }
-    if (bits & 0xFF00FF00)
-    {
-        bits &= 0xFF00FF00;
-        i += 8;
-    }
-    if (bits & 0xF0F0F0F0)
-    {
-        bits &= 0xF0F0F0F0;
-        i += 4;
-    }
-    if (bits & 0xCCCCCCCC)
-    {
-        bits &= 0xCCCCCCCC;
-        i += 2;
-    }
-    if (bits & 0xAAAAAAAA)
-    {
-        bits &= 0xAAAAAAAA;
-        i += 1;
-    }
-    return i;
-}
+	static __inline__ int top_bit(unsigned int bits) {
+		int i;
+
+		if  (bits == 0)
+			return -1;
+		    i = 0;
+		if  (bits & 0xFFFF0000) {
+			bits &= 0xFFFF0000;
+			i += 16;
+		}
+		if     (bits & 0xFF00FF00) {
+			bits &= 0xFF00FF00;
+			i += 8;
+		}
+		if (bits & 0xF0F0F0F0) {
+			bits &= 0xF0F0F0F0;
+			i += 4;
+		}
+		if (bits & 0xCCCCCCCC) {
+			bits &= 0xCCCCCCCC;
+			i += 2;
+		}
+		if (bits & 0xAAAAAAAA) {
+			bits &= 0xAAAAAAAA;
+			i += 1;
+		}
+		return i;
+	}
 /*- End of function --------------------------------------------------------*/
 
-static __inline__ int bottom_bit(unsigned int bits)
-{
-    int i;
-    
-    if (bits == 0)
-        return -1;
-    i = 32;
-    if (bits & 0x0000FFFF)
-    {
-        bits &= 0x0000FFFF;
-        i -= 16;
-    }
-    if (bits & 0x00FF00FF)
-    {
-        bits &= 0x00FF00FF;
-        i -= 8;
-    }
-    if (bits & 0x0F0F0F0F)
-    {
-        bits &= 0x0F0F0F0F;
-        i -= 4;
-    }
-    if (bits & 0x33333333)
-    {
-        bits &= 0x33333333;
-        i -= 2;
-    }
-    if (bits & 0x55555555)
-    {
-        bits &= 0x55555555;
-        i -= 1;
-    }
-    return i;
-}
+	static __inline__ int bottom_bit(unsigned int bits) {
+		int i;
+
+		if (bits == 0)
+			return -1;
+		i = 32;
+		if (bits & 0x0000FFFF) {
+			bits &= 0x0000FFFF;
+			i -= 16;
+		}
+		if (bits & 0x00FF00FF) {
+			bits &= 0x00FF00FF;
+			i -= 8;
+		}
+		if (bits & 0x0F0F0F0F) {
+			bits &= 0x0F0F0F0F;
+			i -= 4;
+		}
+		if (bits & 0x33333333) {
+			bits &= 0x33333333;
+			i -= 2;
+		}
+		if (bits & 0x55555555) {
+			bits &= 0x55555555;
+			i -= 1;
+		}
+		return i;
+	}
 /*- End of function --------------------------------------------------------*/
 #endif
 
@@ -194,7 +167,7 @@ static __inline__ int bottom_bit(unsigned int bits)
  *      segment, but a little inline assembly can fix that on an i386, x86_64 and
  *      many other modern processors.
  */
- 
+
 /*
  * Mu-law is basically as follows:
  *
@@ -222,66 +195,61 @@ static __inline__ int bottom_bit(unsigned int bits)
  */
 
 //#define ULAW_ZEROTRAP                 /* turn on the trap as per the MIL-STD */
-#define ULAW_BIAS        0x84           /* Bias for linear code. */
+#define ULAW_BIAS        0x84	/* Bias for linear code. */
 
 /*! \brief Encode a linear sample to u-law
     \param linear The sample to encode.
     \return The u-law value.
 */
-static __inline__ uint8_t linear_to_ulaw(int linear)
-{
-    uint8_t u_val;
-    int mask;
-    int seg;
+	static __inline__ uint8_t linear_to_ulaw(int linear) {
+		uint8_t u_val;
+		int mask;
+		int seg;
 
-    /* Get the sign and the magnitude of the value. */
-    if (linear < 0)
-    {
-        linear = ULAW_BIAS - linear;
-        mask = 0x7F;
-    }
-    else
-    {
-        linear = ULAW_BIAS + linear;
-        mask = 0xFF;
-    }
+		/* Get the sign and the magnitude of the value. */
+		if (linear < 0) {
+			linear = ULAW_BIAS - linear;
+			mask = 0x7F;
+		} else {
+			linear = ULAW_BIAS + linear;
+			mask = 0xFF;
+		}
 
-    seg = top_bit(linear | 0xFF) - 7;
+		seg = top_bit(linear | 0xFF) - 7;
 
-    /*
-     * Combine the sign, segment, quantization bits,
-     * and complement the code word.
-     */
-    if (seg >= 8)
-        u_val = (uint8_t) (0x7F ^ mask);
-    else
-        u_val = (uint8_t) (((seg << 4) | ((linear >> (seg + 3)) & 0xF)) ^ mask);
+		/*
+		 * Combine the sign, segment, quantization bits,
+		 * and complement the code word.
+		 */
+		if (seg >= 8)
+			u_val = (uint8_t) (0x7F ^ mask);
+		else
+			u_val = (uint8_t) (((seg << 4) | ((linear >> (seg + 3)) & 0xF)) ^ mask);
 #ifdef ULAW_ZEROTRAP
-    /* Optional ITU trap */
-    if (u_val == 0)
-        u_val = 0x02;
+		/* Optional ITU trap */
+		if (u_val == 0)
+			u_val = 0x02;
 #endif
-    return  u_val;
-}
+		return u_val;
+	}
 /*- End of function --------------------------------------------------------*/
 
 /*! \brief Decode an u-law sample to a linear value.
     \param ulaw The u-law sample to decode.
     \return The linear value.
 */
-static __inline__ int16_t ulaw_to_linear(uint8_t ulaw)
-{
-    int t;
-    
-    /* Complement to obtain normal u-law value. */
-    ulaw = ~ulaw;
-    /*
-     * Extract and bias the quantization bits. Then
-     * shift up by the segment number and subtract out the bias.
-     */
-    t = (((ulaw & 0x0F) << 3) + ULAW_BIAS) << (((int) ulaw & 0x70) >> 4);
-    return  (int16_t) ((ulaw & 0x80)  ?  (ULAW_BIAS - t)  :  (t - ULAW_BIAS));
-}
+	static __inline__ int16_t ulaw_to_linear(uint8_t ulaw) {
+		int t;
+
+		/* Complement to obtain normal u-law value. */
+		ulaw = ~ulaw;
+		/*
+		 * Extract and bias the quantization bits. Then
+		 * shift up by the segment number and subtract out the bias.
+		 */
+		t = (((ulaw & 0x0F) << 3) + ULAW_BIAS) << (((int) ulaw & 0x70) >> 4);
+		return (int16_t) ((ulaw & 0x80) ? (ULAW_BIAS - t) : (t - ULAW_BIAS));
+	}
 /*- End of function --------------------------------------------------------*/
 
 /*
@@ -308,71 +276,64 @@ static __inline__ int16_t ulaw_to_linear(uint8_t ulaw)
     \param linear The sample to encode.
     \return The A-law value.
 */
-static __inline__ uint8_t linear_to_alaw(int linear)
-{
-    int mask;
-    int seg;
-    
-    if (linear >= 0)
-    {
-        /* Sign (bit 7) bit = 1 */
-        mask = ALAW_AMI_MASK | 0x80;
-    }
-    else
-    {
-        /* Sign (bit 7) bit = 0 */
-        mask = ALAW_AMI_MASK;
-        linear = -linear - 8;
-    }
+	static __inline__ uint8_t linear_to_alaw(int linear) {
+		int mask;
+		int seg;
 
-    /* Convert the scaled magnitude to segment number. */
-    seg = top_bit(linear | 0xFF) - 7;
-    if (seg >= 8)
-    {
-        if (linear >= 0)
-        {
-            /* Out of range. Return maximum value. */
-            return (uint8_t) (0x7F ^ mask);
-        }
-        /* We must be just a tiny step below zero */
-        return (uint8_t) (0x00 ^ mask);
-    }
-    /* Combine the sign, segment, and quantization bits. */
-    return (uint8_t) (((seg << 4) | ((linear >> ((seg)  ?  (seg + 3)  :  4)) & 0x0F)) ^ mask);
-}
+		if (linear >= 0) {
+			/* Sign (bit 7) bit = 1 */
+			mask = ALAW_AMI_MASK | 0x80;
+		} else {
+			/* Sign (bit 7) bit = 0 */
+			mask = ALAW_AMI_MASK;
+			linear = -linear - 8;
+		}
+
+		/* Convert the scaled magnitude to segment number. */
+		seg = top_bit(linear | 0xFF) - 7;
+		if (seg >= 8) {
+			if (linear >= 0) {
+				/* Out of range. Return maximum value. */
+				return (uint8_t) (0x7F ^ mask);
+			}
+			/* We must be just a tiny step below zero */
+			return (uint8_t) (0x00 ^ mask);
+		}
+		/* Combine the sign, segment, and quantization bits. */
+		return (uint8_t) (((seg << 4) | ((linear >> ((seg) ? (seg + 3) : 4)) & 0x0F)) ^ mask);
+	}
 /*- End of function --------------------------------------------------------*/
 
 /*! \brief Decode an A-law sample to a linear value.
     \param alaw The A-law sample to decode.
     \return The linear value.
 */
-static __inline__ int16_t alaw_to_linear(uint8_t alaw)
-{
-    int i;
-    int seg;
+	static __inline__ int16_t alaw_to_linear(uint8_t alaw) {
+		int i;
+		int seg;
 
-    alaw ^= ALAW_AMI_MASK;
-    i = ((alaw & 0x0F) << 4);
-    seg = (((int) alaw & 0x70) >> 4);
-    if (seg)
-        i = (i + 0x108) << (seg - 1);
-    else
-        i += 8;
-    return (int16_t) ((alaw & 0x80)  ?  i  :  -i);
-}
+		alaw ^= ALAW_AMI_MASK;
+		i = ((alaw & 0x0F) << 4);
+		seg = (((int) alaw & 0x70) >> 4);
+		if (seg)
+			i = (i + 0x108) << (seg - 1);
+		else
+			i += 8;
+		return (int16_t) ((alaw & 0x80) ? i : -i);
+	}
 /*- End of function --------------------------------------------------------*/
 
 /*! \brief Transcode from A-law to u-law, using the procedure defined in G.711.
     \param alaw The A-law sample to transcode.
     \return The best matching u-law value.
 */
-uint8_t alaw_to_ulaw(uint8_t alaw);
+	uint8_t alaw_to_ulaw(uint8_t alaw);
 
 /*! \brief Transcode from u-law to A-law, using the procedure defined in G.711.
     \param alaw The u-law sample to transcode.
     \return The best matching A-law value.
 */
-uint8_t ulaw_to_alaw(uint8_t ulaw);
+	uint8_t ulaw_to_alaw(uint8_t ulaw);
 
 #ifdef __cplusplus
 }
diff --git a/src/mod/endpoints/mod_wanpipe/libsangoma/libsangoma.c b/src/mod/endpoints/mod_wanpipe/libsangoma/libsangoma.c
index 22dcfb074e..43fecb2f2a 100644
--- a/src/mod/endpoints/mod_wanpipe/libsangoma/libsangoma.c
+++ b/src/mod/endpoints/mod_wanpipe/libsangoma/libsangoma.c
@@ -23,99 +23,96 @@
 #define DFT_CARD "wanpipe1"
 
 #if defined(WIN32)
-//extern int	verbose;
+//extern int    verbose;
 
 #define DEV_NAME_LEN	100
 char device_name[DEV_NAME_LEN];
 
 /* IOCTL management structures and variables*/
-wan_udp_hdr_t	wan_udp;
+wan_udp_hdr_t wan_udp;
 
 #include "win_api_common.h"
 
 static wan_cmd_api_t api_cmd;
-static api_tx_hdr_t *tx_hdr = (api_tx_hdr_t *)api_cmd.data;
+static api_tx_hdr_t *tx_hdr = (api_tx_hdr_t *) api_cmd.data;
 
 /* keeps the LAST (and single) event received */
 static wp_tdm_api_rx_hdr_t last_tdm_api_event_buffer;
 
-#endif	/* WIN32 */
+#endif /* WIN32 */
 
-void sangoma_socket_close(sng_fd_t *sp) 
+void sangoma_socket_close(sng_fd_t * sp)
 {
 #if defined(WIN32)
-	if(	*sp != INVALID_HANDLE_VALUE){
+	if (*sp != INVALID_HANDLE_VALUE) {
 		CloseHandle(*sp);
 		*sp = INVALID_HANDLE_VALUE;
 	}
 #else
-    if (*sp > -1) {
-	close(*sp);
-	*sp = -1;
-    }
+	if (*sp > -1) {
+		close(*sp);
+		*sp = -1;
+	}
 #endif
 }
 
 int sangoma_socket_waitfor(sng_fd_t fd, int timeout, int flags)
 {
 #if defined(WIN32)
-	API_POLL_STRUCT	api_poll;
+	API_POLL_STRUCT api_poll;
 
 	memset(&api_poll, 0x00, sizeof(API_POLL_STRUCT));
-	
+
 	api_poll.user_flags_bitmap = flags;
 
-	if(DoApiPollCommand(fd, &api_poll)){
+	if (DoApiPollCommand(fd, &api_poll)) {
 		//failed
 		return 0;
 	}
 
-	switch(api_poll.operation_status)
-	{
-		case SANG_STATUS_RX_DATA_AVAILABLE:
-			break;
+	switch (api_poll.operation_status) {
+	case SANG_STATUS_RX_DATA_AVAILABLE:
+		break;
 
-		default:
-			prn(1, "Error: sangoma_socket_waitfor(): Unknown Operation Status: %d\n", 
-				api_poll.operation_status);
-			return 0;
-	}//switch()
+	default:
+		prn(1, "Error: sangoma_socket_waitfor(): Unknown Operation Status: %d\n", api_poll.operation_status);
+		return 0;
+	}							//switch()
 
-	if(api_poll.poll_events_bitmap == 0){
-		prn(1, "Error: invalid Poll Events bitmap: 0x%X\n",
-			api_poll.poll_events_bitmap);
+	if (api_poll.poll_events_bitmap == 0) {
+		prn(1, "Error: invalid Poll Events bitmap: 0x%X\n", api_poll.poll_events_bitmap);
 	}
 	return api_poll.poll_events_bitmap;
 #else
-    struct pollfd pfds[1];
-    int res;
+	struct pollfd pfds[1];
+	int res;
 
-    memset(&pfds[0], 0, sizeof(pfds[0]));
-    pfds[0].fd = fd;
-    pfds[0].events = flags;
-    res = poll(pfds, 1, timeout);
-    if (res > 0) {
-	if ((pfds[0].revents & POLLERR)) {
-		res = -1;
-	} else if((pfds[0].revents)) {
-		res = 1;
+	memset(&pfds[0], 0, sizeof(pfds[0]));
+	pfds[0].fd = fd;
+	pfds[0].events = flags;
+	res = poll(pfds, 1, timeout);
+	if (res > 0) {
+		if ((pfds[0].revents & POLLERR)) {
+			res = -1;
+		} else if ((pfds[0].revents)) {
+			res = 1;
+		}
 	}
-    }
 
-    return res;
+	return res;
 #endif
 }
 
 
 int sangoma_span_chan_toif(int span, int chan, char *interface_name)
 {
- 	sprintf(interface_name,"s%ic%i",span,chan);
+	sprintf(interface_name, "s%ic%i", span, chan);
 	return 0;
 }
 
 int sangoma_interface_toi(char *interface_name, int *span, int *chan)
 {
-	char *p=NULL, *sp = NULL, *ch = NULL;
+	char *p = NULL, *sp = NULL, *ch = NULL;
 	int ret = 0;
 	char data[FNAME_LEN];
 
@@ -131,7 +128,7 @@ int sangoma_interface_toi(char *interface_name, int *span, int *chan)
 			}
 		}
 
-		if(ch && sp) {
+		if (ch && sp) {
 			*span = atoi(sp);
 			*chan = atoi(ch);
 			ret = 1;
@@ -162,7 +159,7 @@ int sangoma_span_chan_fromif(char *interface_name, int *span, int *chan)
 			}
 		}
 
-		if(ch && sp) {
+		if (ch && sp) {
 			*span = atoi(sp);
 			*chan = atoi(ch);
 			ret = 1;
@@ -175,132 +172,124 @@ int sangoma_span_chan_fromif(char *interface_name, int *span, int *chan)
 	return ret;
 }
 
-sng_fd_t sangoma_open_tdmapi_span_chan(int span, int chan) 
+sng_fd_t sangoma_open_tdmapi_span_chan(int span, int chan)
 {
-   	char fname[FNAME_LEN];
+	char fname[FNAME_LEN];
 #if defined(WIN32)
 
 	//NOTE: under Windows Interfaces are zero based but 'chan' is 1 based.
-	//		Subtract 1 from 'chan'.
-	_snprintf(fname , FNAME_LEN, "\\\\.\\WANPIPE%d_IF%d", span, chan - 1);
+	//      Subtract 1 from 'chan'.
+	_snprintf(fname, FNAME_LEN, "\\\\.\\WANPIPE%d_IF%d", span, chan - 1);
 
 	//prn(verbose, "Opening device: %s...\n", fname);
 
-	return CreateFile(	fname, 
-						GENERIC_READ | GENERIC_WRITE, 
-						FILE_SHARE_READ | FILE_SHARE_WRITE,
-						(LPSECURITY_ATTRIBUTES)NULL, 
-						OPEN_EXISTING,
-						FILE_FLAG_NO_BUFFERING | FILE_FLAG_WRITE_THROUGH,
-						(HANDLE)NULL
-						);
+	return CreateFile(fname,
+					  GENERIC_READ | GENERIC_WRITE,
+					  FILE_SHARE_READ | FILE_SHARE_WRITE,
+					  (LPSECURITY_ATTRIBUTES) NULL,
+					  OPEN_EXISTING, FILE_FLAG_NO_BUFFERING | FILE_FLAG_WRITE_THROUGH, (HANDLE) NULL);
 #else
-  	int fd=-1;
+	int fd = -1;
 
-	sprintf(fname,"/dev/wptdm_s%dc%d",span,chan);
+	sprintf(fname, "/dev/wptdm_s%dc%d", span, chan);
 
 	fd = open(fname, O_RDWR);
 
-	return fd;  
+	return fd;
 #endif
-}            
-
-sng_fd_t sangoma_create_socket_by_name(char *device, char *card) 
-{
-	int span,chan;
-	sangoma_interface_toi(device,&span,&chan);
-	
-	return sangoma_open_tdmapi_span_chan(span,chan);
 }
 
-          
-sng_fd_t sangoma_open_tdmapi_span(int span) 
+sng_fd_t sangoma_create_socket_by_name(char *device, char *card)
 {
-    int i=0;
+	int span, chan;
+	sangoma_interface_toi(device, &span, &chan);
+
+	return sangoma_open_tdmapi_span_chan(span, chan);
+}
+
+
+sng_fd_t sangoma_open_tdmapi_span(int span)
+{
+	int i = 0;
 #if defined(WIN32)
 	sng_fd_t fd = INVALID_HANDLE_VALUE;
 
-	for(i = 1; i < 32; i++){
-		if((fd = sangoma_open_tdmapi_span_chan(span, i)) == INVALID_HANDLE_VALUE){
+	for (i = 1; i < 32; i++) {
+		if ((fd = sangoma_open_tdmapi_span_chan(span, i)) == INVALID_HANDLE_VALUE) {
 			//prn(verbose, "Span: %d, chan: %d: is not running, consider 'busy'\n",
-			//	span, i);
+			//  span, i);
 			continue;
 		}
-
 		//get the open handle counter
-		wan_udp.wan_udphdr_command = GET_OPEN_HANDLES_COUNTER; 
+		wan_udp.wan_udphdr_command = GET_OPEN_HANDLES_COUNTER;
 		wan_udp.wan_udphdr_data_len = 0;
 
 		DoManagementCommand(fd, &wan_udp);
-		if(wan_udp.wan_udphdr_return_code){
-			prn(1, "Error: command GET_OPEN_HANDLES_COUNTER failed! Span: %d, chan: %d\n",
-				span, i);
+		if (wan_udp.wan_udphdr_return_code) {
+			prn(1, "Error: command GET_OPEN_HANDLES_COUNTER failed! Span: %d, chan: %d\n", span, i);
 			//don't forget to close!! otherwize counter will stay incremented.
 			sangoma_socket_close(&fd);
 			continue;
 		}
-
 		//prn(verbose, "open handles counter: %d\n", *(int*)&wan_udp.wan_udphdr_data[0]);
-		if(*(int*)&wan_udp.wan_udphdr_data[0] == 1){
+		if (*(int *) &wan_udp.wan_udphdr_data[0] == 1) {
 			//this is the only process using this chan/span, so it is 'free'
 			//prn(verbose, "Found 'free' Span: %d, chan: %d\n",span, i);
 			break;
 		}
 		//don't forget to close!! otherwize counter will stay incremented.
 		sangoma_socket_close(&fd);
-	}//for()
+	}							//for()
 
 #else
-    unsigned char fname[FNAME_LEN];
-	int fd=0;
-	for (i=1;i<32;i++){
-		sprintf(fname,"/dev/wptdm_s%dc%d",span,i);
+	unsigned char fname[FNAME_LEN];
+	int fd = 0;
+	for (i = 1; i < 32; i++) {
+		sprintf(fname, "/dev/wptdm_s%dc%d", span, i);
 		fd = open(fname, O_RDWR);
-		if (fd < 0){
-         	continue;
+		if (fd < 0) {
+			continue;
 		}
 		break;
 	}
-#endif	
-    return fd;  
-}      
+#endif
+	return fd;
+}
 
 int sangoma_readmsg_tdm(sng_fd_t fd, void *hdrbuf, int hdrlen, void *databuf, int datalen, int flag)
 {
-	int rx_len=0;
+	int rx_len = 0;
 
 #if defined(WIN32)
-	static RX_DATA_STRUCT	rx_data;
-	api_header_t			*pri;
-	wp_tdm_api_rx_hdr_t		*tdm_api_rx_hdr;
-	wp_tdm_api_rx_hdr_t		*user_buf = (wp_tdm_api_rx_hdr_t*)hdrbuf;
+	static RX_DATA_STRUCT rx_data;
+	api_header_t *pri;
+	wp_tdm_api_rx_hdr_t *tdm_api_rx_hdr;
+	wp_tdm_api_rx_hdr_t *user_buf = (wp_tdm_api_rx_hdr_t *) hdrbuf;
 
-	if(hdrlen != sizeof(wp_tdm_api_rx_hdr_t)){
+	if (hdrlen != sizeof(wp_tdm_api_rx_hdr_t)) {
 		//error
 		prn(1, "Error: sangoma_readmsg_tdm(): invalid size of user's 'header buffer'.\
 Should be 'sizeof(wp_tdm_api_rx_hdr_t)'.\n");
 		return -1;
 	}
 
-	if(DoReadCommand(fd, &rx_data) ){
+	if (DoReadCommand(fd, &rx_data)) {
 		//error
 		prn(1, "Error: DoReadCommand() failed! Check messages log.\n");
 		return -1;
 	}
-
 	//use our special buffer at rxdata to hold received data
 	pri = &rx_data.api_header;
-	tdm_api_rx_hdr = (wp_tdm_api_rx_hdr_t*)rx_data.data;
+	tdm_api_rx_hdr = (wp_tdm_api_rx_hdr_t *) rx_data.data;
 
 	user_buf->wp_tdm_api_event_type = pri->operation_status;
 
-	switch(pri->operation_status)
-	{
+	switch (pri->operation_status) {
 	case SANG_STATUS_RX_DATA_AVAILABLE:
 		//prn(verbose, "SANG_STATUS_RX_DATA_AVAILABLE\n");
 
-		if(pri->data_length > datalen){
-			rx_len=0;
+		if (pri->data_length > datalen) {
+			rx_len = 0;
 			break;
 		}
 		memcpy(databuf, rx_data.data, pri->data_length);
@@ -315,12 +304,11 @@ Should be 'sizeof(wp_tdm_api_rx_hdr_t)'.\n");
 		rx_len = pri->data_length;
 
 		//make copy for use with sangoma_tdm_read_event() - indirect access.
-		memcpy(	&last_tdm_api_event_buffer,	tdm_api_rx_hdr, sizeof(wp_tdm_api_rx_hdr_t));
+		memcpy(&last_tdm_api_event_buffer, tdm_api_rx_hdr, sizeof(wp_tdm_api_rx_hdr_t));
 		break;
 
 	default:
-		switch(pri->operation_status)
-		{
+		switch (pri->operation_status) {
 		case SANG_STATUS_RX_DATA_TIMEOUT:
 			//no data in READ_CMD_TIMEOUT, try again.
 			prn(1, "Error: Timeout on read.\n");
@@ -344,43 +332,43 @@ Should be 'sizeof(wp_tdm_api_rx_hdr_t)'.\n");
 		default:
 			prn(1, "Rx:Unknown Operation Status: %d\n", pri->operation_status);
 			break;
-		}//switch()
+		}						//switch()
 		return 0;
-	}//switch()
+	}							//switch()
 
 #else
 	struct msghdr msg;
 	struct iovec iov[2];
 
-	memset(&msg,0,sizeof(struct msghdr));
+	memset(&msg, 0, sizeof(struct msghdr));
 
-	iov[0].iov_len=hdrlen;
-	iov[0].iov_base=hdrbuf;
+	iov[0].iov_len = hdrlen;
+	iov[0].iov_base = hdrbuf;
 
-	iov[1].iov_len=datalen;
-	iov[1].iov_base=databuf;
+	iov[1].iov_len = datalen;
+	iov[1].iov_base = databuf;
 
-	msg.msg_iovlen=2;
-	msg.msg_iov=iov;
+	msg.msg_iovlen = 2;
+	msg.msg_iov = iov;
 
-	rx_len = read(fd,&msg,datalen+hdrlen);
+	rx_len = read(fd, &msg, datalen + hdrlen);
 
-	if (rx_len <= sizeof(wp_tdm_api_rx_hdr_t)){
+	if (rx_len <= sizeof(wp_tdm_api_rx_hdr_t)) {
 		return -EINVAL;
 	}
 
-	rx_len-=sizeof(wp_tdm_api_rx_hdr_t);
+	rx_len -= sizeof(wp_tdm_api_rx_hdr_t);
 #endif
-    return rx_len;
-}                    
+	return rx_len;
+}
 
 int sangoma_writemsg_tdm(sng_fd_t fd, void *hdrbuf, int hdrlen, void *databuf, unsigned short datalen, int flag)
 {
 	int bsent;
 
 #if defined(WIN32)
-	static TX_DATA_STRUCT	local_tx_data;
-	api_header_t			*pri;
+	static TX_DATA_STRUCT local_tx_data;
+	api_header_t *pri;
 
 	pri = &local_tx_data.api_header;
 
@@ -388,36 +376,35 @@ int sangoma_writemsg_tdm(sng_fd_t fd, void *hdrbuf, int hdrlen, void *databuf, u
 	memcpy(local_tx_data.data, databuf, pri->data_length);
 
 	//queue data for transmission
-	if(	DoWriteCommand(fd, &local_tx_data)){
+	if (DoWriteCommand(fd, &local_tx_data)) {
 		//error
 		prn(1, "Error: DoWriteCommand() failed!! Check messages log.\n");
 		return -1;
 	}
 
-	bsent=0;
+	bsent = 0;
 	//check that frame was transmitted
-	switch(local_tx_data.api_header.operation_status)
-	{
+	switch (local_tx_data.api_header.operation_status) {
 	case SANG_STATUS_SUCCESS:
 		bsent = datalen;
 		break;
-				
+
 	case SANG_STATUS_TX_TIMEOUT:
 		//error
 		prn(1, "****** Error: SANG_STATUS_TX_TIMEOUT ******\n");
 		//Check messages log or look at statistics.
 		break;
-				
+
 	case SANG_STATUS_TX_DATA_TOO_LONG:
 		//Attempt to transmit data longer than the pre-configured maximum.
 		//Maximum length is set in 'Interface Properties',
 		//in the 'Device Manager'.
 		prn(1, "****** SANG_STATUS_TX_DATA_TOO_LONG ******\n");
 		break;
-				
+
 	case SANG_STATUS_TX_DATA_TOO_SHORT:
 		//Minimum is 1 byte  for Primary   port,
-		//			 2 bytes for Secondary port
+		//           2 bytes for Secondary port
 		prn(1, "****** SANG_STATUS_TX_DATA_TOO_SHORT ******\n");
 		break;
 
@@ -430,28 +417,27 @@ int sangoma_writemsg_tdm(sng_fd_t fd, void *hdrbuf, int hdrlen, void *databuf, u
 		break;
 
 	default:
-		prn(1, "Unknown return code (0x%X) on transmission!\n",
-			local_tx_data.api_header.operation_status);
+		prn(1, "Unknown return code (0x%X) on transmission!\n", local_tx_data.api_header.operation_status);
 		break;
-	}//switch()
+	}							//switch()
 #else
 	struct msghdr msg;
 	struct iovec iov[2];
 
-	memset(&msg,0,sizeof(struct msghdr));
+	memset(&msg, 0, sizeof(struct msghdr));
 
-	iov[0].iov_len=hdrlen;
-	iov[0].iov_base=hdrbuf;
+	iov[0].iov_len = hdrlen;
+	iov[0].iov_base = hdrbuf;
 
-	iov[1].iov_len=datalen;
-	iov[1].iov_base=databuf;
+	iov[1].iov_len = datalen;
+	iov[1].iov_base = databuf;
 
-	msg.msg_iovlen=2;
-	msg.msg_iov=iov;
+	msg.msg_iovlen = 2;
+	msg.msg_iov = iov;
 
-	bsent = write(fd,&msg,datalen+hdrlen);
-	if (bsent > 0){
-		bsent-=sizeof(wp_tdm_api_tx_hdr_t);
+	bsent = write(fd, &msg, datalen + hdrlen);
+	if (bsent > 0) {
+		bsent -= sizeof(wp_tdm_api_tx_hdr_t);
 	}
 #endif
 	return bsent;
@@ -464,17 +450,17 @@ int sangoma_writemsg_tdm(sng_fd_t fd, void *hdrbuf, int hdrlen, void *databuf, u
  * Execute TDM command
  *
  */
-static int sangoma_tdm_cmd_exec(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api)
+static int sangoma_tdm_cmd_exec(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api)
 {
 	int err;
 
 #if defined(WIN32)
 	err = tdmv_api_ioctl(fd, &tdm_api->wp_tdm_cmd);
 #else
-	err = ioctl(fd,SIOC_WANPIPE_TDM_API,&tdm_api->wp_tdm_cmd);
-	if (err < 0){
+	err = ioctl(fd, SIOC_WANPIPE_TDM_API, &tdm_api->wp_tdm_cmd);
+	if (err < 0) {
 		char tmp[50];
-		sprintf(tmp,"TDM API: CMD: %i\n",tdm_api->wp_tdm_cmd.cmd);
+		sprintf(tmp, "TDM API: CMD: %i\n", tdm_api->wp_tdm_cmd.cmd);
 		perror(tmp);
 		return -1;
 	}
@@ -486,40 +472,36 @@ static int sangoma_tdm_cmd_exec(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api)
  * Get Full TDM API configuration per channel
  *
  */
-int sangoma_get_full_cfg(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api)
+int sangoma_get_full_cfg(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api)
 {
 	int err;
 
 	tdm_api->wp_tdm_cmd.cmd = SIOC_WP_TDM_GET_FULL_CFG;
 
-	err=sangoma_tdm_cmd_exec(fd,tdm_api);
-	if (err){
+	err = sangoma_tdm_cmd_exec(fd, tdm_api);
+	if (err) {
 		return err;
 	}
 
 	printf("TDM API CFG:\n");
-	printf("\thw_tdm_coding:\t%d\n",tdm_api->wp_tdm_cmd.hw_tdm_coding);
-	printf("\tusr_mtu_mru:\t%d\n",tdm_api->wp_tdm_cmd.hw_mtu_mru);
-	printf("\tusr_period:\t%d\n",tdm_api->wp_tdm_cmd.usr_period);
-	printf("\ttdm_codec:\t%d\n",tdm_api->wp_tdm_cmd.tdm_codec);
-	printf("\tpower_level:\t%d\n",tdm_api->wp_tdm_cmd.power_level);
-	printf("\trx_disable:\t%d\n",tdm_api->wp_tdm_cmd.rx_disable);
-	printf("\ttx_disable:\t%d\n",tdm_api->wp_tdm_cmd.tx_disable);
-	printf("\tusr_mtu_mru:\t%d\n",tdm_api->wp_tdm_cmd.usr_mtu_mru);
-	printf("\tidle flag:\t0x%02X\n",tdm_api->wp_tdm_cmd.idle_flag);
-	printf("\tfe alarms:\t0x%02X\n",tdm_api->wp_tdm_cmd.fe_alarms);
-	
-	printf("\trx pkt\t%d\ttx pkt\t%d\n",tdm_api->wp_tdm_cmd.stats.rx_packets,
-				tdm_api->wp_tdm_cmd.stats.tx_packets);
-	printf("\trx err\t%d\ttx err\t%d\n",
-				tdm_api->wp_tdm_cmd.stats.rx_errors,
-				tdm_api->wp_tdm_cmd.stats.tx_errors);
+	printf("\thw_tdm_coding:\t%d\n", tdm_api->wp_tdm_cmd.hw_tdm_coding);
+	printf("\tusr_mtu_mru:\t%d\n", tdm_api->wp_tdm_cmd.hw_mtu_mru);
+	printf("\tusr_period:\t%d\n", tdm_api->wp_tdm_cmd.usr_period);
+	printf("\ttdm_codec:\t%d\n", tdm_api->wp_tdm_cmd.tdm_codec);
+	printf("\tpower_level:\t%d\n", tdm_api->wp_tdm_cmd.power_level);
+	printf("\trx_disable:\t%d\n", tdm_api->wp_tdm_cmd.rx_disable);
+	printf("\ttx_disable:\t%d\n", tdm_api->wp_tdm_cmd.tx_disable);
+	printf("\tusr_mtu_mru:\t%d\n", tdm_api->wp_tdm_cmd.usr_mtu_mru);
+	printf("\tidle flag:\t0x%02X\n", tdm_api->wp_tdm_cmd.idle_flag);
+	printf("\tfe alarms:\t0x%02X\n", tdm_api->wp_tdm_cmd.fe_alarms);
+
+	printf("\trx pkt\t%d\ttx pkt\t%d\n", tdm_api->wp_tdm_cmd.stats.rx_packets, tdm_api->wp_tdm_cmd.stats.tx_packets);
+	printf("\trx err\t%d\ttx err\t%d\n", tdm_api->wp_tdm_cmd.stats.rx_errors, tdm_api->wp_tdm_cmd.stats.tx_errors);
 #ifndef __WINDOWS__
 	printf("\trx ovr\t%d\ttx idl\t%d\n",
-				tdm_api->wp_tdm_cmd.stats.rx_fifo_errors,
-				tdm_api->wp_tdm_cmd.stats.tx_carrier_errors);
-#endif				
-	
+		   tdm_api->wp_tdm_cmd.stats.rx_fifo_errors, tdm_api->wp_tdm_cmd.stats.tx_carrier_errors);
+#endif
+
 	return 0;
 }
 
@@ -535,14 +517,14 @@ int sangoma_get_full_cfg(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api)
  * }
  *
  */
-int sangoma_tdm_set_codec(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api, int codec)
+int sangoma_tdm_set_codec(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api, int codec)
 {
 	int err;
 
 	tdm_api->wp_tdm_cmd.cmd = SIOC_WP_TDM_SET_CODEC;
 	tdm_api->wp_tdm_cmd.tdm_codec = codec;
 
-	err=sangoma_tdm_cmd_exec(fd,tdm_api);
+	err = sangoma_tdm_cmd_exec(fd, tdm_api);
 
 	return err;
 }
@@ -559,18 +541,18 @@ int sangoma_tdm_set_codec(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api, int codec)
  * }
  *
  */
-int sangoma_tdm_get_codec(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api)
+int sangoma_tdm_get_codec(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api)
 {
 	int err;
 
 	tdm_api->wp_tdm_cmd.cmd = SIOC_WP_TDM_GET_CODEC;
 
-	err=sangoma_tdm_cmd_exec(fd,tdm_api);
-	if (err){
+	err = sangoma_tdm_cmd_exec(fd, tdm_api);
+	if (err) {
 		return err;
 	}
 
-	return tdm_api->wp_tdm_cmd.tdm_codec;	
+	return tdm_api->wp_tdm_cmd.tdm_codec;
 }
 
 
@@ -581,14 +563,14 @@ int sangoma_tdm_get_codec(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api)
  *  10,20,30,40,50 ms      
  *
  */
-int sangoma_tdm_set_usr_period(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api, int period)
+int sangoma_tdm_set_usr_period(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api, int period)
 {
 	int err;
 
 	tdm_api->wp_tdm_cmd.cmd = SIOC_WP_TDM_SET_USR_PERIOD;
 	tdm_api->wp_tdm_cmd.usr_period = period;
 
-	err=sangoma_tdm_cmd_exec(fd,tdm_api);
+	err = sangoma_tdm_cmd_exec(fd, tdm_api);
 
 	return err;
 }
@@ -600,14 +582,14 @@ int sangoma_tdm_set_usr_period(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api, int peri
  *  10,20,30,40,50 ms      
  *
  */
-int sangoma_tdm_get_usr_period(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api)
+int sangoma_tdm_get_usr_period(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api)
 {
 	int err;
 
 	tdm_api->wp_tdm_cmd.cmd = SIOC_WP_TDM_GET_USR_PERIOD;
 
-	err=sangoma_tdm_cmd_exec(fd,tdm_api);
-	if (err){
+	err = sangoma_tdm_cmd_exec(fd, tdm_api);
+	if (err) {
 		return err;
 	}
 
@@ -620,15 +602,15 @@ int sangoma_tdm_get_usr_period(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api)
  * Coding Format will be ULAW/ALAW based on T1/E1 
  */
 
-int sangoma_tdm_get_hw_coding(int fd, wanpipe_tdm_api_t *tdm_api)
+int sangoma_tdm_get_hw_coding(int fd, wanpipe_tdm_api_t * tdm_api)
 {
-        int err;
-        tdm_api->wp_tdm_cmd.cmd = SIOC_WP_TDM_GET_HW_CODING;
-        err=sangoma_tdm_cmd_exec(fd,tdm_api);
-        if (err){
-                return err;
-        }
-        return tdm_api->wp_tdm_cmd.hw_tdm_coding;
+	int err;
+	tdm_api->wp_tdm_cmd.cmd = SIOC_WP_TDM_GET_HW_CODING;
+	err = sangoma_tdm_cmd_exec(fd, tdm_api);
+	if (err) {
+		return err;
+	}
+	return tdm_api->wp_tdm_cmd.hw_tdm_coding;
 }
 
 
@@ -638,14 +620,14 @@ int sangoma_tdm_get_hw_coding(int fd, wanpipe_tdm_api_t *tdm_api)
  * The USER MTU/MRU values will change each time a PERIOD
  * or CODEC is adjusted.
  */
-int sangoma_tdm_get_usr_mtu_mru(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api)
+int sangoma_tdm_get_usr_mtu_mru(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api)
 {
 	int err;
 
 	tdm_api->wp_tdm_cmd.cmd = SIOC_WP_TDM_GET_USR_MTU_MRU;
 
-	err=sangoma_tdm_cmd_exec(fd,tdm_api);
-	if (err){
+	err = sangoma_tdm_cmd_exec(fd, tdm_api);
+	if (err) {
 		return err;
 	}
 
@@ -658,14 +640,14 @@ int sangoma_tdm_get_usr_mtu_mru(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api)
  * This option is not implemented yet
  *
  */
-int sangoma_tdm_set_power_level(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api, int power)
+int sangoma_tdm_set_power_level(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api, int power)
 {
 	int err;
 
 	tdm_api->wp_tdm_cmd.cmd = SIOC_WP_TDM_SET_POWER_LEVEL;
 	tdm_api->wp_tdm_cmd.power_level = power;
 
-	err=sangoma_tdm_cmd_exec(fd,tdm_api);
+	err = sangoma_tdm_cmd_exec(fd, tdm_api);
 
 	return err;
 }
@@ -676,42 +658,43 @@ int sangoma_tdm_set_power_level(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api, int pow
  * This option is not implemented yet
  *
  */
-int sangoma_tdm_get_power_level(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api)
+int sangoma_tdm_get_power_level(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api)
 {
 	int err;
 
 	tdm_api->wp_tdm_cmd.cmd = SIOC_WP_TDM_GET_POWER_LEVEL;
 
-	err=sangoma_tdm_cmd_exec(fd,tdm_api);
-	if (err){
+	err = sangoma_tdm_cmd_exec(fd, tdm_api);
+	if (err) {
 		return err;
 	}
 
 	return tdm_api->wp_tdm_cmd.power_level;
 }
 
-int sangoma_tdm_flush_bufs(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api)
+int sangoma_tdm_flush_bufs(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api)
 {
 #if 0
 	tdm_api->wp_tdm_cmd.cmd = SIOC_WP_TDM_FLUSH_BUFFERS;
 
-	err=sangoma_tdm_cmd_exec(fd,tdm_api);
-	if (err){
+	err = sangoma_tdm_cmd_exec(fd, tdm_api);
+	if (err) {
 		return err;
 	}
 #endif
 	return 0;
 }
 
-int sangoma_tdm_enable_rbs_events(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api, int poll_in_sec) {
-	
+int sangoma_tdm_enable_rbs_events(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api, int poll_in_sec)
+{
+
 	int err;
-	
+
 	tdm_api->wp_tdm_cmd.cmd = SIOC_WP_TDM_ENABLE_RBS_EVENTS;
-	tdm_api->wp_tdm_cmd.rbs_poll=poll_in_sec; 
-	
-	err=sangoma_tdm_cmd_exec(fd,tdm_api);
-	if (err){
+	tdm_api->wp_tdm_cmd.rbs_poll = poll_in_sec;
+
+	err = sangoma_tdm_cmd_exec(fd, tdm_api);
+	if (err) {
 		return err;
 	}
 
@@ -719,185 +702,181 @@ int sangoma_tdm_enable_rbs_events(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api, int p
 }
 
 
-int sangoma_tdm_disable_rbs_events(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api) {
+int sangoma_tdm_disable_rbs_events(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api)
+{
 
 	int err;
 	tdm_api->wp_tdm_cmd.cmd = SIOC_WP_TDM_DISABLE_RBS_EVENTS;
-	
-	err=sangoma_tdm_cmd_exec(fd,tdm_api);
-	if (err){
+
+	err = sangoma_tdm_cmd_exec(fd, tdm_api);
+	if (err) {
 		return err;
 	}
 
 	return 0;
 }
 
-int sangoma_tdm_write_rbs(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api, unsigned char rbs) 
+int sangoma_tdm_write_rbs(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api, unsigned char rbs)
 {
-	
+
 	int err;
 	tdm_api->wp_tdm_cmd.cmd = SIOC_WP_TDM_WRITE_RBS_BITS;
-	tdm_api->wp_tdm_cmd.rbs_tx_bits=rbs; 
-	
-	err=sangoma_tdm_cmd_exec(fd,tdm_api);
-	if (err){
+	tdm_api->wp_tdm_cmd.rbs_tx_bits = rbs;
+
+	err = sangoma_tdm_cmd_exec(fd, tdm_api);
+	if (err) {
 		return err;
 	}
 
 	return 0;
-}        
+}
 
-int sangoma_tdm_read_event(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api) 
+int sangoma_tdm_read_event(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api)
 {
 	wp_tdm_api_rx_hdr_t *rx_event;
 
-#if defined(WIN32)	
+#if defined(WIN32)
 	rx_event = &last_tdm_api_event_buffer;
 #else
 	int err;
 
 	tdm_api->wp_tdm_cmd.cmd = SIOC_WP_TDM_READ_EVENT;
-	
-	err=sangoma_tdm_cmd_exec(fd,tdm_api);
-	if (err){
+
+	err = sangoma_tdm_cmd_exec(fd, tdm_api);
+	if (err) {
 		return err;
 	}
 
 	rx_event = &tdm_api->wp_tdm_cmd.event;
 #endif
 
-	switch (rx_event->wp_tdm_api_event_type){
-	
+	switch (rx_event->wp_tdm_api_event_type) {
+
 	case WP_TDM_EVENT_RBS:
-		printf("%d: GOT RBS EVENT %p\n",(int)fd,tdm_api->wp_tdm_event.wp_rbs_event);
+		printf("%d: GOT RBS EVENT %p\n", (int) fd, tdm_api->wp_tdm_event.wp_rbs_event);
 		if (tdm_api->wp_tdm_event.wp_rbs_event) {
-			tdm_api->wp_tdm_event.wp_rbs_event(fd,rx_event->wp_tdm_api_event_rbs_rx_bits);
+			tdm_api->wp_tdm_event.wp_rbs_event(fd, rx_event->wp_tdm_api_event_rbs_rx_bits);
 		}
-		
+
 		break;
-		
+
 	case WP_TDM_EVENT_DTMF:
-		printf("%d: GOT DTMF EVENT\n",(int)fd);
+		printf("%d: GOT DTMF EVENT\n", (int) fd);
 		if (tdm_api->wp_tdm_event.wp_dtmf_event) {
 			tdm_api->wp_tdm_event.wp_dtmf_event(fd,
-						rx_event->wp_tdm_api_event_dtmf_digit,
-						rx_event->wp_tdm_api_event_dtmf_type,
-						rx_event->wp_tdm_api_event_dtmf_port);
+												rx_event->wp_tdm_api_event_dtmf_digit,
+												rx_event->wp_tdm_api_event_dtmf_type,
+												rx_event->wp_tdm_api_event_dtmf_port);
 		}
 		break;
-		
+
 	case WP_TDM_EVENT_RXHOOK:
-		printf("%d: GOT RXHOOK EVENT\n",(int)fd);
+		printf("%d: GOT RXHOOK EVENT\n", (int) fd);
 		if (tdm_api->wp_tdm_event.wp_rxhook_event) {
-			tdm_api->wp_tdm_event.wp_rxhook_event(fd,
-						rx_event->wp_tdm_api_event_rxhook_state);
+			tdm_api->wp_tdm_event.wp_rxhook_event(fd, rx_event->wp_tdm_api_event_rxhook_state);
 		}
 		break;
 
 	case WP_TDM_EVENT_RING_DETECT:
-		printf("%d: GOT RXRING EVENT\n",(int)fd);
+		printf("%d: GOT RXRING EVENT\n", (int) fd);
 		if (tdm_api->wp_tdm_event.wp_rxring_event) {
-			tdm_api->wp_tdm_event.wp_rxring_event(fd,
-						rx_event->wp_tdm_api_event_ring_state);
+			tdm_api->wp_tdm_event.wp_rxring_event(fd, rx_event->wp_tdm_api_event_ring_state);
 		}
 		break;
 
 	case WP_TDM_EVENT_RING_TRIP:
-		printf("%d: GOT RING TRIP EVENT\n",(int)fd);
+		printf("%d: GOT RING TRIP EVENT\n", (int) fd);
 		if (tdm_api->wp_tdm_event.wp_ringtrip_event) {
-			tdm_api->wp_tdm_event.wp_ringtrip_event(fd,
-						rx_event->wp_tdm_api_event_ring_state);
+			tdm_api->wp_tdm_event.wp_ringtrip_event(fd, rx_event->wp_tdm_api_event_ring_state);
 		}
 		break;
 
 	case WP_TDM_EVENT_FE_ALARM:
-		printf("%d: GOT FE ALARMS EVENT %i\n",(int)fd,
-				rx_event->wp_tdm_api_event_fe_alarm);
+		printf("%d: GOT FE ALARMS EVENT %i\n", (int) fd, rx_event->wp_tdm_api_event_fe_alarm);
 		if (tdm_api->wp_tdm_event.wp_fe_alarm_event) {
-			tdm_api->wp_tdm_event.wp_fe_alarm_event(fd,
-						rx_event->wp_tdm_api_event_fe_alarm);
-		}    
-		
+			tdm_api->wp_tdm_event.wp_fe_alarm_event(fd, rx_event->wp_tdm_api_event_fe_alarm);
+		}
+
 	default:
-		printf("%d: Unknown TDM event!", (int)fd);
+		printf("%d: Unknown TDM event!", (int) fd);
 		break;
 	}
-	
-	return 0;
-}        
 
-int sangoma_tdm_enable_dtmf_events(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api)
+	return 0;
+}
+
+int sangoma_tdm_enable_dtmf_events(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api)
 {
 	int err;
-	
+
 	tdm_api->wp_tdm_cmd.cmd = SIOC_WP_TDM_ENABLE_DTMF_EVENTS;
-	err=sangoma_tdm_cmd_exec(fd,tdm_api);
-	if (err){
+	err = sangoma_tdm_cmd_exec(fd, tdm_api);
+	if (err) {
 		return err;
 	}
 
 	return 0;
 }
 
-int sangoma_tdm_disable_dtmf_events(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api) 
+int sangoma_tdm_disable_dtmf_events(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api)
 {
 	int err;
 
 	tdm_api->wp_tdm_cmd.cmd = SIOC_WP_TDM_DISABLE_DTMF_EVENTS;
-	err=sangoma_tdm_cmd_exec(fd,tdm_api);
-	if (err){
+	err = sangoma_tdm_cmd_exec(fd, tdm_api);
+	if (err) {
 		return err;
 	}
 
 	return 0;
 }
 
-int sangoma_tdm_enable_rm_dtmf_events(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api) 
+int sangoma_tdm_enable_rm_dtmf_events(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api)
 {
 	int err;
-	
+
 	tdm_api->wp_tdm_cmd.cmd = SIOC_WP_TDM_ENABLE_RM_DTMF_EVENTS;
-	err=sangoma_tdm_cmd_exec(fd,tdm_api);
-	if (err){
+	err = sangoma_tdm_cmd_exec(fd, tdm_api);
+	if (err) {
 		return err;
 	}
 
 	return 0;
 }
 
-int sangoma_tdm_disable_rm_dtmf_events(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api) 
+int sangoma_tdm_disable_rm_dtmf_events(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api)
 {
 	int err;
 
 	tdm_api->wp_tdm_cmd.cmd = SIOC_WP_TDM_DISABLE_RM_DTMF_EVENTS;
-	err=sangoma_tdm_cmd_exec(fd,tdm_api);
-	if (err){
+	err = sangoma_tdm_cmd_exec(fd, tdm_api);
+	if (err) {
 		return err;
 	}
 
 	return 0;
 }
 
-int sangoma_tdm_enable_rxhook_events(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api) 
+int sangoma_tdm_enable_rxhook_events(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api)
 {
 	int err;
 
 	tdm_api->wp_tdm_cmd.cmd = SIOC_WP_TDM_ENABLE_RXHOOK_EVENTS;
-	err=sangoma_tdm_cmd_exec(fd,tdm_api);
-	if (err){
+	err = sangoma_tdm_cmd_exec(fd, tdm_api);
+	if (err) {
 		return err;
 	}
 
 	return 0;
 }
 
-int sangoma_tdm_disable_rxhook_events(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api) 
+int sangoma_tdm_disable_rxhook_events(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api)
 {
 	int err;
 
 	tdm_api->wp_tdm_cmd.cmd = SIOC_WP_TDM_DISABLE_RXHOOK_EVENTS;
-	err=sangoma_tdm_cmd_exec(fd,tdm_api);
-	if (err){
+	err = sangoma_tdm_cmd_exec(fd, tdm_api);
+	if (err) {
 		return err;
 	}
 
@@ -908,18 +887,18 @@ int sangoma_tdm_disable_rxhook_events(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api)
  * GET Front End Alarms
  * 
  */
-int sangoma_tdm_get_fe_alarms(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api)
+int sangoma_tdm_get_fe_alarms(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api)
 {
 	int err;
 
 	tdm_api->wp_tdm_cmd.cmd = SIOC_WP_TDM_GET_FE_ALARMS;
 
-	err=sangoma_tdm_cmd_exec(fd,tdm_api);
-	if (err){
+	err = sangoma_tdm_cmd_exec(fd, tdm_api);
+	if (err) {
 		return err;
 	}
 
 	return tdm_api->wp_tdm_cmd.fe_alarms;
-}         
+}
 
 #endif /* WANPIPE_TDM_API */
diff --git a/src/mod/endpoints/mod_wanpipe/libsangoma/libsangoma.h b/src/mod/endpoints/mod_wanpipe/libsangoma/libsangoma.h
index 29d153eaf8..1f385b3908 100644
--- a/src/mod/endpoints/mod_wanpipe/libsangoma/libsangoma.h
+++ b/src/mod/endpoints/mod_wanpipe/libsangoma/libsangoma.h
@@ -34,7 +34,7 @@ typedef unsigned __int32 u_int32_t;
 #ifdef WANPIPE_TDM_API
 #include 	//for TDMV API
 #endif
-#include //return codes
+#include 	//return codes
 #include 			//for IOCTL codes
 #include 		//RBS definitions
 #include 			//TE1 macros
@@ -94,7 +94,7 @@ sng_fd_t sangoma_create_socket_by_name(char *device, char *card);
 /* Open Span/Chan devices
  * open_tdmapi_span_chan: open device based on span chan values 
  * sangoma_open_tdmapi_span: open first available device on span
- */     
+ */
 
 sng_fd_t sangoma_open_tdmapi_span_chan(int span, int chan);
 sng_fd_t sangoma_open_tdmapi_span(int span);
@@ -104,67 +104,65 @@ sng_fd_t sangoma_open_tdmapi_span(int span);
 /* Device Rx/Tx functions 
  * writemsg_tdm: 	tx header + data from separate buffers 
  * readmsg_tdm: 	rx header + data to separate buffers
- */    
-int sangoma_writemsg_tdm(sng_fd_t fd, void *hdrbuf, int hdrlen, 
-						 void *databuf, unsigned short datalen, int flag);
-int sangoma_readmsg_tdm(sng_fd_t fd, void *hdrbuf, int hdrlen, 
-						void *databuf, int datalen, int flag);
+ */
+int sangoma_writemsg_tdm(sng_fd_t fd, void *hdrbuf, int hdrlen, void *databuf, unsigned short datalen, int flag);
+int sangoma_readmsg_tdm(sng_fd_t fd, void *hdrbuf, int hdrlen, void *databuf, int datalen, int flag);
 
 #define sangoma_readmsg_socket sangoma_readmsg_tdm
 #define sangoma_sendmsg_socket sangoma_writemsg_tdm
 
 #ifdef WANPIPE_TDM_API
 
-void sangoma_socket_close(sng_fd_t *sp);
+void sangoma_socket_close(sng_fd_t * sp);
 int sangoma_socket_waitfor(sng_fd_t fd, int timeout, int flags);
 
 /* Get Full TDM API configuration per chan */
-int sangoma_get_full_cfg(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api);
+int sangoma_get_full_cfg(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api);
 
 /* Get/Set TDM Codec per chan */
-int sangoma_tdm_set_codec(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api, int codec);
-int sangoma_tdm_get_codec(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api);
+int sangoma_tdm_set_codec(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api, int codec);
+int sangoma_tdm_get_codec(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api);
 
 /* Get/Set USR Tx/Rx Period in milliseconds */
-int sangoma_tdm_set_usr_period(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api, int period);
-int sangoma_tdm_get_usr_period(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api);
+int sangoma_tdm_set_usr_period(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api, int period);
+int sangoma_tdm_get_usr_period(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api);
 
 /* Get user MTU/MRU values in bytes */
-int sangoma_tdm_get_usr_mtu_mru(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api);
+int sangoma_tdm_get_usr_mtu_mru(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api);
 
 /* Not supported yet */
-int sangoma_tdm_set_power_level(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api, int power);
-int sangoma_tdm_get_power_level(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api);
+int sangoma_tdm_set_power_level(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api, int power);
+int sangoma_tdm_get_power_level(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api);
 
 /* Flush buffers from current channel */
-int sangoma_tdm_flush_bufs(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api);
+int sangoma_tdm_flush_bufs(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api);
 
-int sangoma_tdm_enable_rbs_events(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api, int poll_in_sec);
-int sangoma_tdm_disable_rbs_events(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api);
+int sangoma_tdm_enable_rbs_events(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api, int poll_in_sec);
+int sangoma_tdm_disable_rbs_events(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api);
 
-int sangoma_tdm_write_rbs(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api, unsigned char rbs);
+int sangoma_tdm_write_rbs(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api, unsigned char rbs);
 
-int sangoma_tdm_read_event(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api);
+int sangoma_tdm_read_event(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api);
 
 /* DTMF Detection on Octasic chip */
-int sangoma_tdm_enable_dtmf_events(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api);
-int sangoma_tdm_disable_dtmf_events(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api);
+int sangoma_tdm_enable_dtmf_events(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api);
+int sangoma_tdm_disable_dtmf_events(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api);
 
 /* DTMF Detection on A200 (SLIC) chip */
-int sangoma_tdm_enable_rm_dtmf_events(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api);
-int sangoma_tdm_disable_rm_dtmf_events(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api);
+int sangoma_tdm_enable_rm_dtmf_events(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api);
+int sangoma_tdm_disable_rm_dtmf_events(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api);
 
 /* On/Off hook events on A200 (Analog) card */
-int sangoma_tdm_enable_rxhook_events(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api);
-int sangoma_tdm_disable_rxhook_events(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api);
+int sangoma_tdm_enable_rxhook_events(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api);
+int sangoma_tdm_disable_rxhook_events(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api);
 
-int sangoma_tdm_get_fe_alarms(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api);
+int sangoma_tdm_get_fe_alarms(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api);
 
 #ifndef LIBSANGOMA_GET_HWCODING
 #define LIBSANGOMA_GET_HWCODING 1
 #endif
-int sangoma_tdm_get_hw_coding(int fd, wanpipe_tdm_api_t *tdm_api);
+int sangoma_tdm_get_hw_coding(int fd, wanpipe_tdm_api_t * tdm_api);
 
-#endif 	/* WANPIPE_TDM_API */
+#endif /* WANPIPE_TDM_API */
 
 #endif
diff --git a/src/mod/endpoints/mod_wanpipe/libsangoma/sangoma_pri.c b/src/mod/endpoints/mod_wanpipe/libsangoma/sangoma_pri.c
index 7979a1a63b..b631247c58 100644
--- a/src/mod/endpoints/mod_wanpipe/libsangoma/sangoma_pri.c
+++ b/src/mod/endpoints/mod_wanpipe/libsangoma/sangoma_pri.c
@@ -23,20 +23,21 @@
 static __inline int gettimeofday(struct timeval *tp, void *nothing)
 {
 #ifdef WITHOUT_MM_LIB
-  SYSTEMTIME st;
-  time_t tt;
-  struct tm tmtm;
-  /* mktime converts local to UTC */
-  GetLocalTime (&st);
-  tmtm.tm_sec = st.wSecond;
-  tmtm.tm_min = st.wMinute;
-  tmtm.tm_hour = st.wHour;
-  tmtm.tm_mday = st.wDay;
-  tmtm.tm_mon = st.wMonth - 1;
-  tmtm.tm_year = st.wYear - 1900;  tmtm.tm_isdst = -1;
-  tt = mktime (&tmtm);
-  tp->tv_sec = tt;
-  tp->tv_usec = st.wMilliseconds * 1000;
+	SYSTEMTIME st;
+	time_t tt;
+	struct tm tmtm;
+	/* mktime converts local to UTC */
+	GetLocalTime(&st);
+	tmtm.tm_sec = st.wSecond;
+	tmtm.tm_min = st.wMinute;
+	tmtm.tm_hour = st.wHour;
+	tmtm.tm_mday = st.wDay;
+	tmtm.tm_mon = st.wMonth - 1;
+	tmtm.tm_year = st.wYear - 1900;
+	tmtm.tm_isdst = -1;
+	tt = mktime(&tmtm);
+	tp->tv_sec = tt;
+	tp->tv_usec = st.wMilliseconds * 1000;
 #else
   /**
    ** The earlier time calculations using GetLocalTime
@@ -44,18 +45,18 @@ static __inline int gettimeofday(struct timeval *tp, void *nothing)
    ** of multimedia apis offer a better time resolution
    ** of 1ms.Need to link against winmm.lib for this
    **/
-  unsigned long Ticks = 0;
-  unsigned long Sec =0;
-  unsigned long Usec = 0;
-  Ticks = timeGetTime();
+	unsigned long Ticks = 0;
+	unsigned long Sec = 0;
+	unsigned long Usec = 0;
+	Ticks = timeGetTime();
 
-  Sec = Ticks/1000;
-  Usec = (Ticks - (Sec*1000))*1000;
-  tp->tv_sec = Sec;
-  tp->tv_usec = Usec;
+	Sec = Ticks / 1000;
+	Usec = (Ticks - (Sec * 1000)) * 1000;
+	tp->tv_sec = Sec;
+	tp->tv_usec = Usec;
 #endif /* WITHOUT_MM_LIB */
-  (void)nothing;
-  return 0;
+	(void) nothing;
+	return 0;
 }
 #endif /* WIN32 */
 #endif /* HAVE_GETTIMEOFDAY */
@@ -84,37 +85,37 @@ static struct sangoma_pri_event_list SANGOMA_PRI_EVENT_LIST[] = {
 
 
 char *sangoma_pri_event_str(sangoma_pri_event_t event_id)
-{ 
+{
 	return SANGOMA_PRI_EVENT_LIST[event_id].name;
 }
 
 static int __pri_sangoma_read(struct pri *pri, void *buf, int buflen)
 {
 	unsigned char tmpbuf[sizeof(wp_tdm_api_rx_hdr_t)];
-	
+
 
 	/* NOTE: This code will be different for A104 
 	 *       A104   receives data + 2byte CRC + 1 byte flag 
-	 *       A101/2 receives data only */ 
-	
-	int res = sangoma_readmsg_socket((sng_fd_t)(pri->fd), 
-					 tmpbuf, sizeof(wp_tdm_api_rx_hdr_t), 
-					 buf, buflen, 
-					 0);
-	if (res > 0){
+	 *       A101/2 receives data only */
+
+	int res = sangoma_readmsg_socket((sng_fd_t) (pri->fd),
+									 tmpbuf, sizeof(wp_tdm_api_rx_hdr_t),
+									 buf, buflen,
+									 0);
+	if (res > 0) {
 #ifdef WANPIPE_LEGACY_A104
 		/* Prior 2.3.4 release A104 API passed up
-                 * 3 extra bytes: 2 CRC + 1 FLAG,
-                 * PRI is expecting only 2 CRC bytes, thus we
-                 * must remove 1 flag byte */
+		 * 3 extra bytes: 2 CRC + 1 FLAG,
+		 * PRI is expecting only 2 CRC bytes, thus we
+		 * must remove 1 flag byte */
 		res--;
 #else
-		/* Add 2 byte CRC and set it to ZERO */ 
-		memset(&((unsigned char*)buf)[res],0,2);
-		res+=2;
+		/* Add 2 byte CRC and set it to ZERO */
+		memset(&((unsigned char *) buf)[res], 0, 2);
+		res += 2;
 #endif
-	}else{
-		res=0;
+	} else {
+		res = 0;
 	}
 
 	return res;
@@ -126,25 +127,23 @@ static int __pri_sangoma_write(struct pri *pri, void *buf, int buflen)
 	int res;
 
 
-	memset(&tmpbuf[0],0,sizeof(wp_tdm_api_rx_hdr_t));	
+	memset(&tmpbuf[0], 0, sizeof(wp_tdm_api_rx_hdr_t));
 
-	if (buflen < 1){
+	if (buflen < 1) {
 		/* HDLC Frame must be greater than 2byte CRC */
-		fprintf(stderr,"%s: Got short frame %i\n",__FUNCTION__,buflen);
+		fprintf(stderr, "%s: Got short frame %i\n", __FUNCTION__, buflen);
 		return 0;
 	}
 
 	/* FIXME: This might cause problems with other libraries
 	 * We must remove 2 bytes from buflen because
 	 * libpri sends 2 fake CRC bytes */
-	res=sangoma_sendmsg_socket((sng_fd_t)(pri->fd),
-				   tmpbuf, sizeof(wp_tdm_api_rx_hdr_t),
-				   buf, (unsigned short)buflen-2,
-				   0);	
-	if (res > 0){
-		res=buflen;
+	res = sangoma_sendmsg_socket((sng_fd_t) (pri->fd),
+								 tmpbuf, sizeof(wp_tdm_api_rx_hdr_t), buf, (unsigned short) buflen - 2, 0);
+	if (res > 0) {
+		res = buflen;
 	}
-	
+
 	return res;
 }
 
@@ -155,10 +154,10 @@ int sangoma_init_pri(struct sangoma_pri *spri, int span, int dchan, int swtype,
 
 	memset(spri, 0, sizeof(struct sangoma_pri));
 
-	if((dfd = sangoma_open_tdmapi_span_chan(span, dchan)) < 0) {
+	if ((dfd = sangoma_open_tdmapi_span_chan(span, dchan)) < 0) {
 		fprintf(stderr, "Unable to open DCHAN %d for span %d (%s)\n", dchan, span, strerror(errno));
 	} else {
-		  if ((spri->pri = pri_new_cb((int)dfd, node, swtype, __pri_sangoma_read, __pri_sangoma_write, NULL))){
+		if ((spri->pri = pri_new_cb((int) dfd, node, swtype, __pri_sangoma_read, __pri_sangoma_write, NULL))) {
 			spri->span = span;
 			pri_set_debug(spri->pri, debug);
 			ret = 0;
@@ -173,10 +172,10 @@ int sangoma_init_pri(struct sangoma_pri *spri, int span, int dchan, int swtype,
 int sangoma_one_loop(struct sangoma_pri *spri)
 {
 	fd_set rfds, efds;
-	struct timeval now = {0,0}, *next;
+	struct timeval now = { 0, 0 }, *next;
 	pri_event *event;
-    int sel;
-	
+	int sel;
+
 	if (spri->on_loop) {
 		spri->on_loop(spri);
 	}
@@ -223,10 +222,11 @@ int sangoma_one_loop(struct sangoma_pri *spri)
 	if (event) {
 		event_handler handler;
 		/* 0 is catchall event handler */
-		if ((handler = spri->eventmap[event->e] ? spri->eventmap[event->e] : spri->eventmap[0] ? spri->eventmap[0] : NULL)) {
+		if ((handler =
+			 spri->eventmap[event->e] ? spri->eventmap[event->e] : spri->eventmap[0] ? spri->eventmap[0] : NULL)) {
 			handler(spri, event->e, event);
 		} else {
-			fprintf(stderr,"No event handler found for event %d.\n", event->e);
+			fprintf(stderr, "No event handler found for event %d.\n", event->e);
 		}
 	}
 
@@ -237,23 +237,22 @@ int sangoma_run_pri(struct sangoma_pri *spri)
 {
 	int ret = 0;
 
-	for (;;){
-		ret=sangoma_one_loop(spri);
-		if (ret < 0){
+	for (;;) {
+		ret = sangoma_one_loop(spri);
+		if (ret < 0) {
 
-#ifndef WIN32 //This needs to be adressed fror WIN32 still
-			if (errno == EINTR){
+#ifndef WIN32					//This needs to be adressed fror WIN32 still
+			if (errno == EINTR) {
 				/* Igonore an interrupted system call */
 				continue;
 			}
-#endif	
-			printf("Error = %i\n",ret);
+#endif
+			printf("Error = %i\n", ret);
 			perror("Sangoma Run Pri: ");
-			break;		
+			break;
 		}
 	}
 
 	return ret;
 
 }
-
diff --git a/src/mod/endpoints/mod_wanpipe/libsangoma/sangoma_pri.h b/src/mod/endpoints/mod_wanpipe/libsangoma/sangoma_pri.h
index 247b1fe3b4..7aed00b07e 100644
--- a/src/mod/endpoints/mod_wanpipe/libsangoma/sangoma_pri.h
+++ b/src/mod/endpoints/mod_wanpipe/libsangoma/sangoma_pri.h
@@ -50,7 +50,7 @@ typedef enum {
 
 typedef enum {
 	SANGOMA_PRI_SWITCH_UNKNOWN = PRI_SWITCH_UNKNOWN,
-	SANGOMA_PRI_SWITCH_NI2 = PRI_SWITCH_NI2,	   		
+	SANGOMA_PRI_SWITCH_NI2 = PRI_SWITCH_NI2,
 	SANGOMA_PRI_SWITCH_DMS100 = PRI_SWITCH_DMS100,
 	SANGOMA_PRI_SWITCH_LUCENT5E = PRI_SWITCH_LUCENT5E,
 	SANGOMA_PRI_SWITCH_ATT4ESS = PRI_SWITCH_ATT4ESS,
@@ -67,8 +67,8 @@ typedef enum {
 } sangoma_pri_flag_t;
 
 struct sangoma_pri;
-typedef int (*event_handler)(struct sangoma_pri *, sangoma_pri_event_t, pri_event *);
-typedef int (*loop_handler)(struct sangoma_pri *);
+typedef int (*event_handler) (struct sangoma_pri *, sangoma_pri_event_t, pri_event *);
+typedef int (*loop_handler) (struct sangoma_pri *);
 #define MAX_EVENT 18
 
 struct sangoma_pri {
@@ -77,7 +77,7 @@ struct sangoma_pri {
 	int dchan;
 	unsigned int flags;
 	void *private_info;
-	event_handler eventmap[MAX_EVENT+1];
+	event_handler eventmap[MAX_EVENT + 1];
 	loop_handler on_loop;
 };
 
diff --git a/src/mod/endpoints/mod_wanpipe/libsangoma/win_api_common.h b/src/mod/endpoints/mod_wanpipe/libsangoma/win_api_common.h
index 367420aa40..962f41db1c 100644
--- a/src/mod/endpoints/mod_wanpipe/libsangoma/win_api_common.h
+++ b/src/mod/endpoints/mod_wanpipe/libsangoma/win_api_common.h
@@ -11,228 +11,159 @@
 #ifndef _WIN_API_COMMON_H
 #define _WIN_API_COMMON_H
 
-static 
-int 
-tdmv_api_ioctl(
-	HANDLE fd, 
-	wanpipe_tdm_api_cmd_t *tdm_api_cmd
-	)
+static
+int tdmv_api_ioctl(HANDLE fd, wanpipe_tdm_api_cmd_t * tdm_api_cmd)
 {
-	DWORD			ln;
-    unsigned char	id = 0;
-	int				err = 0;
+	DWORD ln;
+	unsigned char id = 0;
+	int err = 0;
 
 	wan_udp.wan_udphdr_request_reply = 0x01;
-	wan_udp.wan_udphdr_id			 = id;
-   	wan_udp.wan_udphdr_return_code	 = WAN_UDP_TIMEOUT_CMD;
+	wan_udp.wan_udphdr_id = id;
+	wan_udp.wan_udphdr_return_code = WAN_UDP_TIMEOUT_CMD;
 
-	wan_udp.wan_udphdr_command	= WAN_TDMV_API_IOCTL;
-	wan_udp.wan_udphdr_data_len	= sizeof(wanpipe_tdm_api_cmd_t);
+	wan_udp.wan_udphdr_command = WAN_TDMV_API_IOCTL;
+	wan_udp.wan_udphdr_data_len = sizeof(wanpipe_tdm_api_cmd_t);
 
 	//copy data from caller's buffer to driver's buffer
-	memcpy(	wan_udp.wan_udphdr_data, 
-			(void*)tdm_api_cmd,
-			sizeof(wanpipe_tdm_api_cmd_t));
+	memcpy(wan_udp.wan_udphdr_data, (void *) tdm_api_cmd, sizeof(wanpipe_tdm_api_cmd_t));
 
-	if(DeviceIoControl(
-			fd,
-			IoctlManagementCommand,
-			(LPVOID)&wan_udp,
-			sizeof(wan_udp_hdr_t),
-			(LPVOID)&wan_udp,
-			sizeof(wan_udp_hdr_t),
-			(LPDWORD)(&ln),
-			(LPOVERLAPPED)NULL
-			) == FALSE){
+	if (DeviceIoControl(fd,
+						IoctlManagementCommand,
+						(LPVOID) & wan_udp,
+						sizeof(wan_udp_hdr_t),
+						(LPVOID) & wan_udp, sizeof(wan_udp_hdr_t), (LPDWORD) (&ln), (LPOVERLAPPED) NULL) == FALSE) {
 		//actual ioctl failed
 		err = 1;
 		prn(1, "Error: tdmv_api_ioctl(): DeviceIoControl failed!!\n");
 		return err;
-	}else{
+	} else {
 		err = 0;
 	}
 
-	if(wan_udp.wan_udphdr_return_code != WAN_CMD_OK){
+	if (wan_udp.wan_udphdr_return_code != WAN_CMD_OK) {
 		//ioctl ok, but command failed
-		prn(1, "Error: tdmv_api_ioctl(): command failed! Return code: 0x%X.\n",
-			wan_udp.wan_udphdr_return_code);
+		prn(1, "Error: tdmv_api_ioctl(): command failed! Return code: 0x%X.\n", wan_udp.wan_udphdr_return_code);
 		return 2;
 	}
-
 	//copy data from driver's buffer to caller's buffer
-	memcpy(	(void*)tdm_api_cmd,
-			wan_udp.wan_udphdr_data, 
-			sizeof(wanpipe_tdm_api_cmd_t));
+	memcpy((void *) tdm_api_cmd, wan_udp.wan_udphdr_data, sizeof(wanpipe_tdm_api_cmd_t));
 	return 0;
 }
 
-static 
-int 
-wanpipe_api_ioctl(
-	HANDLE fd,
-	wan_cmd_api_t *api_cmd
-	)
+static
+int wanpipe_api_ioctl(HANDLE fd, wan_cmd_api_t * api_cmd)
 {
-	DWORD			ln;
-    unsigned char	id = 0;
-	int				err = 0;
+	DWORD ln;
+	unsigned char id = 0;
+	int err = 0;
 
 	wan_udp.wan_udphdr_request_reply = 0x01;
-	wan_udp.wan_udphdr_id			 = id;
-   	wan_udp.wan_udphdr_return_code   = WAN_UDP_TIMEOUT_CMD;
+	wan_udp.wan_udphdr_id = id;
+	wan_udp.wan_udphdr_return_code = WAN_UDP_TIMEOUT_CMD;
 
-	wan_udp.wan_udphdr_command	= SIOC_WANPIPE_API;
-	wan_udp.wan_udphdr_data_len	= sizeof(wan_cmd_api_t);
+	wan_udp.wan_udphdr_command = SIOC_WANPIPE_API;
+	wan_udp.wan_udphdr_data_len = sizeof(wan_cmd_api_t);
 
 	//copy data from caller's buffer to driver's buffer
-	memcpy(	wan_udp.wan_udphdr_data, 
-			(void*)api_cmd,
-			sizeof(wan_cmd_api_t));
+	memcpy(wan_udp.wan_udphdr_data, (void *) api_cmd, sizeof(wan_cmd_api_t));
 
-	if(DeviceIoControl(
-			fd,
-			IoctlManagementCommand,
-			(LPVOID)&wan_udp,
-			sizeof(wan_udp_hdr_t),
-			(LPVOID)&wan_udp,
-			sizeof(wan_udp_hdr_t),
-			(LPDWORD)(&ln),
-			(LPOVERLAPPED)NULL
-			) == FALSE){
+	if (DeviceIoControl(fd,
+						IoctlManagementCommand,
+						(LPVOID) & wan_udp,
+						sizeof(wan_udp_hdr_t),
+						(LPVOID) & wan_udp, sizeof(wan_udp_hdr_t), (LPDWORD) (&ln), (LPOVERLAPPED) NULL) == FALSE) {
 		err = 1;
 		prn(1, "Error: wanpipe_api_ioctl(): DeviceIoControl failed!!\n");
 		return err;
-	}else{
+	} else {
 		err = 0;
 	}
 
-	if(wan_udp.wan_udphdr_return_code != WAN_CMD_OK){
-		prn(1, "Error: wanpipe_api_ioctl(): command failed! Return code: 0x%X.\n",
-			wan_udp.wan_udphdr_return_code);
+	if (wan_udp.wan_udphdr_return_code != WAN_CMD_OK) {
+		prn(1, "Error: wanpipe_api_ioctl(): command failed! Return code: 0x%X.\n", wan_udp.wan_udphdr_return_code);
 		return 2;
 	}
-
 	//copy data from driver's buffer to caller's buffer
-	memcpy(	(void*)api_cmd,
-			wan_udp.wan_udphdr_data, 
-			sizeof(wan_cmd_api_t));
+	memcpy((void *) api_cmd, wan_udp.wan_udphdr_data, sizeof(wan_cmd_api_t));
 	return 0;
 }
 
 // Blocking read command. If used after DoApiPollCommand(),
 // it will return immediatly, without blocking.
-static 
-USHORT 
-DoReadCommand(
-	HANDLE drv, 
-	RX_DATA_STRUCT * pRx
-	)
+static USHORT DoReadCommand(HANDLE drv, RX_DATA_STRUCT * pRx)
 {
 	DWORD ln;
 
-	if (DeviceIoControl(
-			drv,
-			IoctlReadCommand,
-			(LPVOID)NULL,
-			0L,
-			(LPVOID)pRx,
-			sizeof(RX_DATA_STRUCT),
-			(LPDWORD)(&ln),
-			(LPOVERLAPPED)NULL
-			) == FALSE){
+	if (DeviceIoControl(drv,
+						IoctlReadCommand,
+						(LPVOID) NULL,
+						0L, (LPVOID) pRx, sizeof(RX_DATA_STRUCT), (LPDWORD) (&ln), (LPOVERLAPPED) NULL) == FALSE) {
 		//check messages log
 		prn(1, "Error: DoReadCommand(): DeviceIoControl failed!\n");
 		return 1;
-	}else{
+	} else {
 		return 0;
 	}
 }
 
 // Blocking write command. If used after DoApiPollCommand(),
 // it will return immediatly, without blocking.
-static
-UCHAR 
-DoWriteCommand(
-	HANDLE drv, 
-	TX_DATA_STRUCT * pTx
-	)
+static UCHAR DoWriteCommand(HANDLE drv, TX_DATA_STRUCT * pTx)
 {
 	DWORD ln;
 
-	if(DeviceIoControl(
-			drv,
-			IoctlWriteCommand,
-			(LPVOID)pTx,
-			(ULONG)sizeof(TX_DATA_STRUCT),
-			(LPVOID)pTx,
-			sizeof(TX_DATA_STRUCT),
-			(LPDWORD)(&ln),
-			(LPOVERLAPPED)NULL
-			) == FALSE){
+	if (DeviceIoControl(drv,
+						IoctlWriteCommand,
+						(LPVOID) pTx,
+						(ULONG) sizeof(TX_DATA_STRUCT),
+						(LPVOID) pTx, sizeof(TX_DATA_STRUCT), (LPDWORD) (&ln), (LPOVERLAPPED) NULL) == FALSE) {
 		//check messages log
 		prn(1, "Error: DoWriteCommand(): DeviceIoControl failed!\n");
 		return 1;
-	}else{
+	} else {
 		return 0;
 	}
 }
 
 // Blocking API Poll command.
-static
-USHORT 
-DoApiPollCommand(
-	HANDLE drv, 
-	API_POLL_STRUCT *api_poll_ptr
-	)
+static USHORT DoApiPollCommand(HANDLE drv, API_POLL_STRUCT * api_poll_ptr)
 {
 	DWORD ln;
 
-	if (DeviceIoControl(
-			drv,
-			IoctlApiPoll,
-			(LPVOID)NULL,
-			0L,
-			(LPVOID)api_poll_ptr,
-			sizeof(API_POLL_STRUCT),
-			(LPDWORD)(&ln),
-			(LPOVERLAPPED)NULL
-						) == FALSE){
+	if (DeviceIoControl(drv,
+						IoctlApiPoll,
+						(LPVOID) NULL,
+						0L,
+						(LPVOID) api_poll_ptr,
+						sizeof(API_POLL_STRUCT), (LPDWORD) (&ln), (LPOVERLAPPED) NULL) == FALSE) {
 		//check messages log
 		prn(1, "Error: DoApiPollCommand(): DeviceIoControl failed!\n");
 		return 1;
-	}else{
+	} else {
 		return 0;
 	}
 }
 
 static
-int 
-DoManagementCommand(
-	HANDLE drv, 
-	wan_udp_hdr_t* wan_udp
-	)
+int DoManagementCommand(HANDLE drv, wan_udp_hdr_t * wan_udp)
 {
 	DWORD ln;
-    static unsigned char id = 0;
+	static unsigned char id = 0;
 
 	wan_udp->wan_udphdr_request_reply = 0x01;
 	wan_udp->wan_udphdr_id = id++;
-   	wan_udp->wan_udphdr_return_code = WAN_UDP_TIMEOUT_CMD;
+	wan_udp->wan_udphdr_return_code = WAN_UDP_TIMEOUT_CMD;
 
-	if(DeviceIoControl(
-			drv,
-			IoctlManagementCommand,
-			(LPVOID)wan_udp,
-			sizeof(wan_udp_hdr_t),
-			(LPVOID)wan_udp,
-			sizeof(wan_udp_hdr_t),
-			(LPDWORD)(&ln),
-			(LPOVERLAPPED)NULL
-						) == FALSE){
+	if (DeviceIoControl(drv,
+						IoctlManagementCommand,
+						(LPVOID) wan_udp,
+						sizeof(wan_udp_hdr_t),
+						(LPVOID) wan_udp, sizeof(wan_udp_hdr_t), (LPDWORD) (&ln), (LPOVERLAPPED) NULL) == FALSE) {
 		//check messages log
 		prn(1, "Error: DoManagementCommand(): DeviceIoControl failed!\n");
 		return 1;
-	}else{
+	} else {
 		return 0;
 	}
 }
diff --git a/src/mod/endpoints/mod_wanpipe/mod_wanpipe.c b/src/mod/endpoints/mod_wanpipe/mod_wanpipe.c
index 250f9ef9ba..7f0327a9bb 100644
--- a/src/mod/endpoints/mod_wanpipe/mod_wanpipe.c
+++ b/src/mod/endpoints/mod_wanpipe/mod_wanpipe.c
@@ -80,8 +80,8 @@ struct channel_map {
 	char map[SANGOMA_MAX_CHAN_PER_SPAN][SWITCH_UUID_FORMATTED_LENGTH + 1];
 };
 
-unsigned int txseq=0;
-unsigned int rxseq=0;
+unsigned int txseq = 0;
+unsigned int rxseq = 0;
 
 #define SETUP_LEN CORE_MAX_CHAN_PER_SPAN*CORE_MAX_SPANS+1
 
@@ -99,7 +99,7 @@ struct ss7boost_handle {
 
 typedef struct ss7boost_handle ss7boost_handle_t;
 
-static int isup_exec_command(ss7boost_handle_t *ss7boost_handle, int span, int chan, int id, int cmd, int cause);
+static int isup_exec_command(ss7boost_handle_t * ss7boost_handle, int span, int chan, int id, int cmd, int cause);
 
 static struct {
 	int debug;
@@ -210,38 +210,38 @@ typedef struct private_object private_object_t;
 
 
 
-static int local_sangoma_tdm_read_event(sng_fd_t fd, wp_tdm_api_rx_hdr_t *rx_event)
+static int local_sangoma_tdm_read_event(sng_fd_t fd, wp_tdm_api_rx_hdr_t * rx_event)
 {
 	wanpipe_tdm_api_t tdm_api[1];
-	
+
 #if defined(WIN32)
-    rx_event = &last_tdm_api_event_buffer;
+	rx_event = &last_tdm_api_event_buffer;
 #else
-    int err;
+	int err;
 
-    tdm_api->wp_tdm_cmd.cmd = SIOC_WP_TDM_READ_EVENT;
+	tdm_api->wp_tdm_cmd.cmd = SIOC_WP_TDM_READ_EVENT;
 
-    if ((err = sangoma_tdm_cmd_exec(fd, tdm_api))) {
-        return err;
-    }
+	if ((err = sangoma_tdm_cmd_exec(fd, tdm_api))) {
+		return err;
+	}
 
-    rx_event = &tdm_api->wp_tdm_cmd.event;
+	rx_event = &tdm_api->wp_tdm_cmd.event;
 #endif
 
 	return 0;
 }
 
-static int analog_set_state(analog_channel_t *alc, analog_state_t state)
+static int analog_set_state(analog_channel_t * alc, analog_state_t state)
 {
 	alc->state = state;
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Changing State to %d\n", state);
 }
 
-static void analog_check_state(analog_channel_t *alc)
+static void analog_check_state(analog_channel_t * alc)
 {
 	wanpipe_tdm_api_t tdm_api;
 
-	switch(alc->state) {
+	switch (alc->state) {
 	case ANALOG_STATE_DOWN:
 		sangoma_tdm_enable_rxhook_events(alc->sock->fd, &tdm_api);
 		analog_set_state(alc, ANALOG_STATE_ONHOOK);
@@ -251,11 +251,11 @@ static void analog_check_state(analog_channel_t *alc)
 	}
 }
 
-static void analog_parse_event(analog_channel_t *alc)
+static void analog_parse_event(analog_channel_t * alc)
 {
 	wp_tdm_api_rx_hdr_t rx_event;
 	int err = local_sangoma_tdm_read_event(alc->sock->fd, &rx_event);
-	
+
 	if (err < 0) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error reading event!\n");
 		return;
@@ -272,18 +272,18 @@ static void analog_parse_event(analog_channel_t *alc)
 static void *SWITCH_THREAD_FUNC fxs_thread_run(switch_thread_t *thread, void *obj)
 {
 
-	for(;;) {
+	for (;;) {
 		int i = 0, sel_on = -1;
 		fd_set oob;
 		FD_ZERO(&oob);
-		
-		for(i = 0; i < globals.fxs_index; i++) {
+
+		for (i = 0; i < globals.fxs_index; i++) {
 			int fd;
 			assert(FXS_ANALOG_CHANNELS[i]);
 			assert(FXS_ANALOG_CHANNELS[i]->sock);
 
 			fd = FXS_ANALOG_CHANNELS[i]->sock->fd;
-			
+
 			analog_check_state(FXS_ANALOG_CHANNELS[i]);
 
 			FD_SET(fd, &oob);
@@ -295,7 +295,7 @@ static void *SWITCH_THREAD_FUNC fxs_thread_run(switch_thread_t *thread, void *ob
 
 		if (sel_on > -1) {
 			if (select(++sel_on, NULL, NULL, &oob, NULL)) {
-				for(i = 0; i < globals.fxs_index; i++) {
+				for (i = 0; i < globals.fxs_index; i++) {
 					int fd = FXS_ANALOG_CHANNELS[i]->sock->fd;
 					if (FD_ISSET(fd, &oob)) {
 						analog_parse_event(FXS_ANALOG_CHANNELS[i]);
@@ -307,7 +307,7 @@ static void *SWITCH_THREAD_FUNC fxs_thread_run(switch_thread_t *thread, void *ob
 }
 
 
-static int wp_close(private_object_t *tech_pvt)
+static int wp_close(private_object_t * tech_pvt)
 {
 	int ret = 0;
 
@@ -317,16 +317,16 @@ static int wp_close(private_object_t *tech_pvt)
 		ret = 1;
 	}
 	switch_mutex_unlock(globals.hash_mutex);
-	
+
 	return ret;
 }
 
-static wpsock_t *wp_open(private_object_t *tech_pvt, int span, int chan)
+static wpsock_t *wp_open(private_object_t * tech_pvt, int span, int chan)
 {
 	sng_fd_t fd;
 	wpsock_t *sock;
 	char name[25];
-	
+
 	snprintf(name, sizeof(name), "s%dc%d", span, chan);
 
 	switch_mutex_lock(globals.hash_mutex);
@@ -364,7 +364,7 @@ static int wp_restart(int span, int chan)
 	wpsock_t *sock;
 	sng_fd_t fd;
 	char name[25];
-	
+
 	snprintf(name, sizeof(name), "s%dc%d", span, chan);
 
 	switch_mutex_lock(globals.hash_mutex);
@@ -380,7 +380,7 @@ static int wp_restart(int span, int chan)
 		sangoma_socket_close(&fd);
 		return 0;
 	}
-	
+
 	return -1;
 }
 
@@ -444,7 +444,7 @@ static int str2dp(char *dp)
 	if (!strcasecmp(dp, "local"))
 		return PRI_LOCAL_ISDN;
 	if (!strcasecmp(dp, "private"))
-		return PRI_PRIVATE;		
+		return PRI_PRIVATE;
 	if (!strcasecmp(dp, "unknown"))
 		return PRI_UNKNOWN;
 
@@ -460,26 +460,27 @@ static switch_status_t wanpipe_on_init(switch_core_session_t *session);
 static switch_status_t wanpipe_on_hangup(switch_core_session_t *session);
 static switch_status_t wanpipe_on_loopback(switch_core_session_t *session);
 static switch_status_t wanpipe_on_transmit(switch_core_session_t *session);
-static switch_call_cause_t wanpipe_outgoing_channel(switch_core_session_t *session, switch_caller_profile_t *outbound_profile,
+static switch_call_cause_t wanpipe_outgoing_channel(switch_core_session_t *session,
+													switch_caller_profile_t *outbound_profile,
 													switch_core_session_t **new_session, switch_memory_pool_t **pool);
 static switch_status_t wanpipe_read_frame(switch_core_session_t *session, switch_frame_t **frame, int timeout,
-										switch_io_flag_t flags, int stream_id);
+										  switch_io_flag_t flags, int stream_id);
 static switch_status_t wanpipe_write_frame(switch_core_session_t *session, switch_frame_t *frame, int timeout,
-										 switch_io_flag_t flags, int stream_id);
-static int on_info(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event *pevent);
-static int on_hangup(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event *pevent);
-static int on_ring(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event *pevent);
+										   switch_io_flag_t flags, int stream_id);
+static int on_info(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event * pevent);
+static int on_hangup(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event * pevent);
+static int on_ring(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event * pevent);
 static int check_flags(struct sangoma_pri *spri);
-static int on_restart(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event *pevent);
-static int on_anything(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event *pevent);
+static int on_restart(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event * pevent);
+static int on_anything(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event * pevent);
 static void *SWITCH_THREAD_FUNC pri_thread_run(switch_thread_t *thread, void *obj);
 static switch_status_t config_wanpipe(int reload);
 
 
-static switch_status_t wanpipe_codec_init(private_object_t *tech_pvt)
+static switch_status_t wanpipe_codec_init(private_object_t * tech_pvt)
 {
 	int err = 0;
-	wanpipe_tdm_api_t tdm_api = {{0}};
+	wanpipe_tdm_api_t tdm_api = { {0} };
 	unsigned int rate = 8000;
 	switch_channel_t *channel = NULL;
 
@@ -492,22 +493,26 @@ static switch_status_t wanpipe_codec_init(private_object_t *tech_pvt)
 	assert(channel != NULL);
 
 	err = sangoma_tdm_set_codec(tech_pvt->wpsock->fd, &tdm_api, WP_SLINEAR);
-	
+
 	sangoma_tdm_set_usr_period(tech_pvt->wpsock->fd, &tdm_api, globals.samples_per_frame / 8);
 	tech_pvt->frame_size = sangoma_tdm_get_usr_mtu_mru(tech_pvt->wpsock->fd, &tdm_api);
 
 	if (switch_core_codec_init
-		(&tech_pvt->read_codec, "L16", NULL, rate, globals.samples_per_frame / 8, 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,
+		(&tech_pvt->read_codec, "L16", NULL, rate, globals.samples_per_frame / 8, 1,
+		 SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,
 		 switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%s Cannot set read codec\n", switch_channel_get_name(channel));
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%s Cannot set read codec\n",
+						  switch_channel_get_name(channel));
 		switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 		return SWITCH_STATUS_FALSE;
 	}
 
 	if (switch_core_codec_init
-		(&tech_pvt->write_codec, "L16", NULL, rate, globals.samples_per_frame / 8, 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,
+		(&tech_pvt->write_codec, "L16", NULL, rate, globals.samples_per_frame / 8, 1,
+		 SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,
 		 switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%s Cannot set read codec\n", switch_channel_get_name(channel));
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%s Cannot set read codec\n",
+						  switch_channel_get_name(channel));
 		switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 		return SWITCH_STATUS_FALSE;
 	}
@@ -516,25 +521,25 @@ static switch_status_t wanpipe_codec_init(private_object_t *tech_pvt)
 	switch_core_session_set_read_codec(tech_pvt->session, &tech_pvt->read_codec);
 	switch_core_session_set_write_codec(tech_pvt->session, &tech_pvt->write_codec);
 
-#ifdef DOTRACE	
-						tech_pvt->fd = open("/tmp/wp-in.raw", O_WRONLY | O_TRUNC | O_CREAT);
-						tech_pvt->fd2 = open("/tmp/wp-out.raw", O_WRONLY | O_TRUNC | O_CREAT);
+#ifdef DOTRACE
+	tech_pvt->fd = open("/tmp/wp-in.raw", O_WRONLY | O_TRUNC | O_CREAT);
+	tech_pvt->fd2 = open("/tmp/wp-out.raw", O_WRONLY | O_TRUNC | O_CREAT);
 #endif
 
 	/* Setup artificial DTMF stuff */
 	memset(&tech_pvt->tone_session, 0, sizeof(tech_pvt->tone_session));
 	teletone_init_session(&tech_pvt->tone_session, 1024, NULL, NULL);
-	
+
 	if (globals.debug) {
 		tech_pvt->tone_session.debug = globals.debug;
 		tech_pvt->tone_session.debug_stream = stdout;
 	}
-	
+
 	tech_pvt->tone_session.rate = rate;
 	tech_pvt->tone_session.duration = globals.dtmf_on * (tech_pvt->tone_session.rate / 1000);
 	tech_pvt->tone_session.wait = globals.dtmf_off * (tech_pvt->tone_session.rate / 1000);
-	
-	teletone_dtmf_detect_init (&tech_pvt->dtmf_detect, rate);
+
+	teletone_dtmf_detect_init(&tech_pvt->dtmf_detect, rate);
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Audio init %s\n", switch_channel_get_name(channel));
 
 	switch_set_flag(tech_pvt, TFLAG_CODEC);
@@ -563,46 +568,49 @@ static switch_status_t wanpipe_on_init(switch_core_session_t *session)
 
 	tech_pvt->read_frame.data = tech_pvt->databuf;
 
-	if (tech_pvt->ss7boost_handle)  {
+	if (tech_pvt->ss7boost_handle) {
 		if (switch_channel_test_flag(channel, CF_OUTBOUND)) {
 			ss7boost_client_event_t event;
 
 			event.calling_number_presentation = tech_pvt->boost_pres;
 			event.trunk_group = tech_pvt->boost_trunk_group;
-		
+
 			switch_mutex_lock(tech_pvt->ss7boost_handle->mutex);
 			tech_pvt->setup_index = ++tech_pvt->ss7boost_handle->setup_index;
 			if (tech_pvt->ss7boost_handle->setup_index == SETUP_LEN - 1) {
 				tech_pvt->ss7boost_handle->setup_index = 0;
 			}
 			switch_mutex_unlock(tech_pvt->ss7boost_handle->mutex);
-		
+
 			switch_copy_string(tech_pvt->ss7boost_handle->setup_array[tech_pvt->setup_index],
-							   switch_core_session_get_uuid(session), 
+							   switch_core_session_get_uuid(session),
 							   sizeof(tech_pvt->ss7boost_handle->setup_array[tech_pvt->setup_index]));
-		
-			
-			ss7boost_client_call_init(&event, tech_pvt->caller_profile->caller_id_number, tech_pvt->caller_profile->destination_number, tech_pvt->setup_index);
-			
+
+
+			ss7boost_client_call_init(&event, tech_pvt->caller_profile->caller_id_number,
+									  tech_pvt->caller_profile->destination_number, tech_pvt->setup_index);
+
 			if (ss7boost_client_connection_write(&tech_pvt->ss7boost_handle->mcon, &event) <= 0) {
-				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Critical System Error: Failed to tx on ISUP socket [%s]\n", strerror(errno));
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+								  "Critical System Error: Failed to tx on ISUP socket [%s]\n", strerror(errno));
 			}
-			
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Call Called Event TG=%d\n", tech_pvt->boost_trunk_group);
+
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Call Called Event TG=%d\n",
+							  tech_pvt->boost_trunk_group);
 			goto done;
 		}
-	} 
+	}
 
 	if ((status = wanpipe_codec_init(tech_pvt)) != SWITCH_STATUS_SUCCESS) {
 		switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 		return status;
 	}
-	
+
 	if (switch_test_flag(tech_pvt, TFLAG_NOSIG)) {
 		switch_channel_mark_answered(channel);
 	}
 
- done:
+  done:
 
 	/* Move Channel's State Machine to RING */
 	switch_channel_set_state(channel, CS_RING);
@@ -622,7 +630,7 @@ static switch_status_t wanpipe_on_ring(switch_core_session_t *session)
 
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "WANPIPE RING\n");
 
-	
+
 
 	return SWITCH_STATUS_SUCCESS;
 }
@@ -633,7 +641,7 @@ static switch_status_t wanpipe_on_hangup(switch_core_session_t *session)
 	switch_channel_t *channel = NULL;
 	struct channel_map *chanmap = NULL;
 
-	
+
 	channel = switch_core_session_get_channel(session);
 	assert(channel != NULL);
 
@@ -658,9 +666,7 @@ static switch_status_t wanpipe_on_hangup(switch_core_session_t *session)
 			isup_exec_command(tech_pvt->ss7boost_handle,
 							  tech_pvt->boost_span_number,
 							  tech_pvt->boost_chan_number,
-							  -1,
-							  SIGBOOST_EVENT_CALL_STOPPED,
-							  SIGBOOST_RELEASE_CAUSE_NORMAL);
+							  -1, SIGBOOST_EVENT_CALL_STOPPED, SIGBOOST_RELEASE_CAUSE_NORMAL);
 		}
 	} else if (tech_pvt->spri) {
 		chanmap = tech_pvt->spri->private_info;
@@ -673,7 +679,7 @@ static switch_status_t wanpipe_on_hangup(switch_core_session_t *session)
 		switch_mutex_lock(globals.channel_mutex);
 		*chanmap->map[tech_pvt->callno] = '\0';
 		switch_mutex_unlock(globals.channel_mutex);
-		
+
 	}
 
 	switch_set_flag_locked(tech_pvt, TFLAG_BYE);
@@ -681,7 +687,7 @@ static switch_status_t wanpipe_on_hangup(switch_core_session_t *session)
 	teletone_destroy_session(&tech_pvt->tone_session);
 
 	switch_buffer_destroy(&tech_pvt->dtmf_buffer);
-	
+
 	return SWITCH_STATUS_SUCCESS;
 }
 
@@ -727,10 +733,7 @@ static switch_status_t wanpipe_answer_channel(switch_core_session_t *session)
 	} else if (tech_pvt->ss7boost_handle) {
 		isup_exec_command(tech_pvt->ss7boost_handle,
 						  tech_pvt->boost_span_number,
-						  tech_pvt->boost_chan_number,
-						  -1,
-						  SIGBOOST_EVENT_CALL_ANSWERED,
-						  0);
+						  tech_pvt->boost_chan_number, -1, SIGBOOST_EVENT_CALL_ANSWERED, 0);
 	}
 
 	return SWITCH_STATUS_SUCCESS;
@@ -739,7 +742,7 @@ static switch_status_t wanpipe_answer_channel(switch_core_session_t *session)
 
 
 static switch_status_t wanpipe_read_frame(switch_core_session_t *session, switch_frame_t **frame, int timeout,
-										switch_io_flag_t flags, int stream_id)
+										  switch_io_flag_t flags, int stream_id)
 {
 	private_object_t *tech_pvt;
 	switch_channel_t *channel = NULL;
@@ -772,8 +775,9 @@ static switch_status_t wanpipe_read_frame(switch_core_session_t *session, switch
 		}
 
 		if ((bread = sangoma_readmsg_socket(tech_pvt->wpsock->fd,
-										  &tech_pvt->hdrframe,
-										  sizeof(tech_pvt->hdrframe), bp, sizeof(tech_pvt->databuf) - bytes, 0)) < 0) {
+											&tech_pvt->hdrframe,
+											sizeof(tech_pvt->hdrframe), bp, sizeof(tech_pvt->databuf) - bytes,
+											0)) < 0) {
 			if (errno == EBUSY) {
 				continue;
 			} else {
@@ -792,10 +796,10 @@ static switch_status_t wanpipe_read_frame(switch_core_session_t *session, switch
 	tech_pvt->read_frame.datalen = bytes;
 	tech_pvt->read_frame.samples = bytes / 2;
 
-	teletone_dtmf_detect (&tech_pvt->dtmf_detect, tech_pvt->read_frame.data, tech_pvt->read_frame.samples);
+	teletone_dtmf_detect(&tech_pvt->dtmf_detect, tech_pvt->read_frame.data, tech_pvt->read_frame.samples);
 	teletone_dtmf_get(&tech_pvt->dtmf_detect, digit_str, sizeof(digit_str));
-	
-	if(digit_str[0]) {
+
+	if (digit_str[0]) {
 		switch_channel_queue_dtmf(channel, digit_str);
 		if (globals.debug) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "DTMF DETECTED: [%s]\n", digit_str);
@@ -809,8 +813,7 @@ static switch_status_t wanpipe_read_frame(switch_core_session_t *session, switch
 		memset(tech_pvt->read_frame.data, 0, tech_pvt->read_frame.datalen);
 		tech_pvt->skip_read_frames--;
 	}
-
-#ifdef DOTRACE	
+#ifdef DOTRACE
 	write(tech_pvt->fd2, tech_pvt->read_frame.data, (int) tech_pvt->read_frame.datalen);
 #endif
 	//printf("read %d\n", tech_pvt->read_frame.datalen);
@@ -819,7 +822,7 @@ static switch_status_t wanpipe_read_frame(switch_core_session_t *session, switch
 }
 
 static switch_status_t wanpipe_write_frame(switch_core_session_t *session, switch_frame_t *frame, int timeout,
-										 switch_io_flag_t flags, int stream_id)
+										   switch_io_flag_t flags, int stream_id)
 {
 	private_object_t *tech_pvt;
 	uint32_t dtmf_blen;
@@ -836,25 +839,26 @@ static switch_status_t wanpipe_write_frame(switch_core_session_t *session, switc
 	if (tech_pvt->dtmf_buffer && (dtmf_blen = switch_buffer_inuse(tech_pvt->dtmf_buffer))) {
 		uint32_t len = dtmf_blen > frame->datalen ? frame->datalen : dtmf_blen;
 
-		switch_buffer_read(tech_pvt->dtmf_buffer, tech_pvt->auxbuf, len);		
+		switch_buffer_read(tech_pvt->dtmf_buffer, tech_pvt->auxbuf, len);
 		if (len < frame->datalen) {
 			uint8_t *data = frame->data;
 			memcpy(data + len, tech_pvt->auxbuf + len, frame->datalen - len);
 		}
-		data= tech_pvt->auxbuf;
-	} 
-	
+		data = tech_pvt->auxbuf;
+	}
+
 	if (tech_pvt->skip_write_frames) {
 		tech_pvt->skip_write_frames--;
 		return SWITCH_STATUS_SUCCESS;
 	}
-
 #ifdef DOTRACE
 	write(tech_pvt->fd, data, frame->datalen);
 #endif
 
-	result = sangoma_sendmsg_socket(tech_pvt->wpsock->fd, &tech_pvt->hdrframe, sizeof(tech_pvt->hdrframe), data, frame->datalen, 0);
-	
+	result =
+		sangoma_sendmsg_socket(tech_pvt->wpsock->fd, &tech_pvt->hdrframe, sizeof(tech_pvt->hdrframe), data,
+							   frame->datalen, 0);
+
 	if (result < 0 && errno != EBUSY) {
 		return SWITCH_STATUS_GENERR;
 	}
@@ -886,13 +890,13 @@ static switch_status_t wanpipe_send_dtmf(switch_core_session_t *session, char *d
 		}
 	}
 	for (cur = digits; *cur; cur++) {
-		if ((wrote = teletone_mux_tones(&tech_pvt->tone_session, &tech_pvt->tone_session.TONES[(int)*cur]))) {
+		if ((wrote = teletone_mux_tones(&tech_pvt->tone_session, &tech_pvt->tone_session.TONES[(int) *cur]))) {
 			switch_buffer_write(tech_pvt->dtmf_buffer, tech_pvt->tone_session.buffer, wrote * 2);
 		}
 	}
 
 	tech_pvt->skip_read_frames = 200;
-	
+
 	return status;
 }
 
@@ -903,7 +907,7 @@ static switch_status_t wanpipe_receive_message(switch_core_session_t *session, s
 
 	channel = switch_core_session_get_channel(session);
 	assert(channel != NULL);
-			
+
 	tech_pvt = (private_object_t *) switch_core_session_get_private(session);
 	assert(tech_pvt != NULL);
 
@@ -945,7 +949,7 @@ static switch_status_t wanpipe_kill_channel(switch_core_session_t *session, int
 	tech_pvt = switch_core_session_get_private(session);
 	assert(tech_pvt != NULL);
 
-	switch(sig) {
+	switch (sig) {
 	case SWITCH_SIG_KILL:
 		switch_clear_flag_locked(tech_pvt, TFLAG_MEDIA);
 		break;
@@ -968,8 +972,8 @@ static const switch_io_routines_t wanpipe_io_routines = {
 	/*.kill_channel */ wanpipe_kill_channel,
 	/*.waitfor_read */ NULL,
 	/*.waitfor_read */ NULL,
-	/*.send_dtmf*/ wanpipe_send_dtmf,
-	/*.receive_message*/ wanpipe_receive_message
+	/*.send_dtmf */ wanpipe_send_dtmf,
+	/*.receive_message */ wanpipe_receive_message
 };
 
 static const switch_state_handler_table_t wanpipe_state_handlers = {
@@ -999,7 +1003,8 @@ static const switch_loadable_module_interface_t wanpipe_module_interface = {
 };
 
 
-static switch_call_cause_t wanpipe_outgoing_channel(switch_core_session_t *session, switch_caller_profile_t *outbound_profile,
+static switch_call_cause_t wanpipe_outgoing_channel(switch_core_session_t *session,
+													switch_caller_profile_t *outbound_profile,
 													switch_core_session_t **new_session, switch_memory_pool_t **pool)
 {
 	char *bchan = NULL;
@@ -1008,7 +1013,7 @@ static switch_call_cause_t wanpipe_outgoing_channel(switch_core_session_t *sessi
 	char *dest;
 	int ready = 0, is_pri = 0, is_boost = 0, is_raw = 0;
 	switch_call_cause_t cause = SWITCH_CAUSE_SUCCESS;
-	
+
 	if (!outbound_profile) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Doh! no caller profile\n");
 		cause = SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
@@ -1022,7 +1027,7 @@ static switch_call_cause_t wanpipe_outgoing_channel(switch_core_session_t *sessi
 		cause = SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
 		goto error;
 	}
-	
+
 	*dest++ = '\0';
 
 	if (!strcasecmp(protocol, "raw")) {
@@ -1041,7 +1046,7 @@ static switch_call_cause_t wanpipe_outgoing_channel(switch_core_session_t *sessi
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error No SS7BOOST Spans Configured.\n");
 		}
 	}
-	
+
 	if (!ready) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot Continue!\n");
 		cause = SWITCH_CAUSE_NETWORK_OUT_OF_ORDER;
@@ -1075,7 +1080,7 @@ static switch_call_cause_t wanpipe_outgoing_channel(switch_core_session_t *sessi
 			goto error;
 		}
 
-		
+
 		caller_profile = switch_caller_profile_clone(*new_session, outbound_profile);
 
 		if (is_pri) {
@@ -1131,14 +1136,15 @@ static switch_call_cause_t wanpipe_outgoing_channel(switch_core_session_t *sessi
 
 			if (sangoma_span_chan_fromif(bchan, &span, &chan)) {
 				if (!wp_open(tech_pvt, span, chan)) {
-					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't open fd for s%dc%d! [%s]\n", span, chan, strerror(errno));
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't open fd for s%dc%d! [%s]\n", span,
+									  chan, strerror(errno));
 					switch_core_session_destroy(new_session);
 					cause = SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
 					goto error;
 				}
 				switch_set_flag_locked(tech_pvt, TFLAG_NOSIG);
 				snprintf(name, sizeof(name), "wanpipe/%s/nosig", bchan);
-				switch_channel_set_name(channel, name);			
+				switch_channel_set_name(channel, name);
 				switch_channel_set_caller_profile(channel, caller_profile);
 			} else {
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid address\n");
@@ -1160,19 +1166,21 @@ static switch_call_cause_t wanpipe_outgoing_channel(switch_core_session_t *sessi
 
 				if (SPANS[span] && (spri = &SPANS[span]->spri) && switch_test_flag(spri, SANGOMA_PRI_READY)) {
 					chanmap = spri->private_info;
-						
+
 					if (autochan > 0) {
-						for(callno = 1; callno < SANGOMA_MAX_CHAN_PER_SPAN; callno++) {
-							if ((SPANS[span]->bchans & (1 << callno)) && ! *chanmap->map[callno]) {
-								switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Choosing channel s%dc%d\n", span, callno);
+						for (callno = 1; callno < SANGOMA_MAX_CHAN_PER_SPAN; callno++) {
+							if ((SPANS[span]->bchans & (1 << callno)) && !*chanmap->map[callno]) {
+								switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Choosing channel s%dc%d\n",
+												  span, callno);
 								goto done;
 							}
 						}
 						callno = 0;
 					} else if (autochan < 0) {
-						for(callno = SANGOMA_MAX_CHAN_PER_SPAN; callno > 0; callno--) {
-							if ((SPANS[span]->bchans & (1 << callno)) && ! *chanmap->map[callno]) {
-								switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Choosing channel s%dc%d\n", span, callno);
+						for (callno = SANGOMA_MAX_CHAN_PER_SPAN; callno > 0; callno--) {
+							if ((SPANS[span]->bchans & (1 << callno)) && !*chanmap->map[callno]) {
+								switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Choosing channel s%dc%d\n",
+												  span, callno);
 								goto done;
 							}
 						}
@@ -1186,7 +1194,7 @@ static switch_call_cause_t wanpipe_outgoing_channel(switch_core_session_t *sessi
 					span--;
 				}
 			}
-		done:
+		  done:
 			switch_mutex_unlock(globals.channel_mutex);
 
 			if (!spri || callno == 0 || callno == (SANGOMA_MAX_CHAN_PER_SPAN)) {
@@ -1195,14 +1203,15 @@ static switch_call_cause_t wanpipe_outgoing_channel(switch_core_session_t *sessi
 				cause = SWITCH_CAUSE_SWITCH_CONGESTION;
 				goto error;
 			}
-				
+
 			tech_pvt->callno = callno;
-				
+
 			if (spri && (tech_pvt->call = pri_new_call(spri->pri))) {
 				struct pri_sr *sr;
-					
-				snprintf(name, sizeof(name), "wanpipe/pri/s%dc%d/%s", spri->span, callno, caller_profile->destination_number);
-				switch_channel_set_name(channel, name);			
+
+				snprintf(name, sizeof(name), "wanpipe/pri/s%dc%d/%s", spri->span, callno,
+						 caller_profile->destination_number);
+				switch_channel_set_name(channel, name);
 				switch_channel_set_caller_profile(channel, caller_profile);
 				sr = pri_sr_new();
 				pri_sr_set_channel(sr, callno, 0, 0);
@@ -1211,15 +1220,13 @@ static switch_call_cause_t wanpipe_outgoing_channel(switch_core_session_t *sessi
 				pri_sr_set_caller(sr,
 								  caller_profile->caller_id_number,
 								  caller_profile->caller_id_name,
-								  SPANS[span]->dp,
-								  PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN);
+								  SPANS[span]->dp, PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN);
 				pri_sr_set_redirecting(sr,
 									   caller_profile->caller_id_number,
 									   SPANS[span]->dp,
-									   PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN,
-									   PRI_REDIR_UNCONDITIONAL);
-				
-				if (pri_setup(spri->pri, tech_pvt->call , sr)) {
+									   PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN, PRI_REDIR_UNCONDITIONAL);
+
+				if (pri_setup(spri->pri, tech_pvt->call, sr)) {
 					switch_core_session_destroy(new_session);
 					pri_sr_free(sr);
 					cause = SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
@@ -1235,8 +1242,7 @@ static switch_call_cause_t wanpipe_outgoing_channel(switch_core_session_t *sessi
 				}
 				pri_sr_free(sr);
 				switch_copy_string(chanmap->map[callno],
-								   switch_core_session_get_uuid(*new_session),
-								   sizeof(chanmap->map[callno]));
+								   switch_core_session_get_uuid(*new_session), sizeof(chanmap->map[callno]));
 				tech_pvt->spri = spri;
 			}
 		} else if (is_boost) {
@@ -1245,8 +1251,8 @@ static switch_call_cause_t wanpipe_outgoing_channel(switch_core_session_t *sessi
 			if ((p = strchr(caller_profile->destination_number, '/'))) {
 				char *grp = caller_profile->destination_number;
 				*p = '\0';
-				caller_profile->destination_number = p+1;
-				tech_pvt->boost_trunk_group = atoi(grp+1) - 1;
+				caller_profile->destination_number = p + 1;
+				tech_pvt->boost_trunk_group = atoi(grp + 1) - 1;
 				if (tech_pvt->boost_trunk_group < 0) {
 					tech_pvt->boost_trunk_group = 0;
 				}
@@ -1269,7 +1275,7 @@ static switch_call_cause_t wanpipe_outgoing_channel(switch_core_session_t *sessi
 		cause = SWITCH_CAUSE_SUCCESS;
 	}
 
- error:
+  error:
 	switch_safe_free(protocol);
 	return cause;
 }
@@ -1298,7 +1304,8 @@ static void s_pri_message(struct pri *pri, char *s)
 }
 #endif
 
-SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **interface, char *filename)
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **interface,
+													   char *filename)
 {
 	switch_status_t status = SWITCH_STATUS_SUCCESS;
 
@@ -1331,7 +1338,7 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_mod
 
 /*event Handlers */
 
-static int on_info(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event *pevent)
+static int on_info(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event * pevent)
 {
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "number is: %s\n", pevent->ring.callednum);
 	if (strlen(pevent->ring.callednum) > 3) {
@@ -1341,7 +1348,7 @@ static int on_info(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri
 	return 0;
 }
 
-static int on_hangup(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event *pevent)
+static int on_hangup(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event * pevent)
 {
 	struct channel_map *chanmap;
 	switch_core_session_t *session;
@@ -1364,7 +1371,7 @@ static int on_hangup(struct sangoma_pri *spri, sangoma_pri_event_t event_type, p
 		tech_pvt->cause = pevent->hangup.cause;
 		switch_set_flag_locked(tech_pvt, TFLAG_BYE);
 		switch_channel_hangup(channel, tech_pvt->cause);
-		
+
 		switch_mutex_lock(globals.channel_mutex);
 		*chanmap->map[pevent->hangup.channel] = '\0';
 		switch_mutex_unlock(globals.channel_mutex);
@@ -1372,11 +1379,12 @@ static int on_hangup(struct sangoma_pri *spri, sangoma_pri_event_t event_type, p
 		switch_core_session_rwunlock(session);
 	}
 
-	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "-- Hanging up channel s%dc%d\n", spri->span, pevent->hangup.channel);
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "-- Hanging up channel s%dc%d\n", spri->span,
+					  pevent->hangup.channel);
 	return 0;
 }
 
-static int on_answer(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event *pevent)
+static int on_answer(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event * pevent)
 {
 	switch_core_session_t *session;
 	switch_channel_t *channel;
@@ -1386,20 +1394,22 @@ static int on_answer(struct sangoma_pri *spri, sangoma_pri_event_t event_type, p
 	chanmap = spri->private_info;
 
 	if ((session = switch_core_session_locate(chanmap->map[pevent->answer.channel]))) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "-- Answer on channel s%dc%d\n", spri->span, pevent->answer.channel);
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "-- Answer on channel s%dc%d\n", spri->span,
+						  pevent->answer.channel);
 		channel = switch_core_session_get_channel(session);
 		assert(channel != NULL);
 		switch_channel_mark_answered(channel);
 		switch_core_session_rwunlock(session);
 	} else {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "-- Answer on channel s%dc%d but it's not in use?\n", spri->span, pevent->answer.channel);
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "-- Answer on channel s%dc%d but it's not in use?\n",
+						  spri->span, pevent->answer.channel);
 	}
-	
+
 	return 0;
 }
 
 
-static int on_proceed(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event *pevent)
+static int on_proceed(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event * pevent)
 {
 	switch_core_session_t *session;
 	switch_channel_t *channel;
@@ -1410,11 +1420,12 @@ static int on_proceed(struct sangoma_pri *spri, sangoma_pri_event_t event_type,
 	if ((session = switch_core_session_locate(chanmap->map[pevent->proceeding.channel]))) {
 		switch_core_session_message_t *msg;
 
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "-- Proceeding on channel s%dc%d\n", spri->span, pevent->proceeding.channel);
-		
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "-- Proceeding on channel s%dc%d\n", spri->span,
+						  pevent->proceeding.channel);
+
 		channel = switch_core_session_get_channel(session);
 		assert(channel != NULL);
-		
+
 		if ((msg = malloc(sizeof(*msg)))) {
 			memset(msg, 0, sizeof(*msg));
 			msg->message_id = SWITCH_MESSAGE_INDICATE_PROGRESS;
@@ -1425,18 +1436,19 @@ static int on_proceed(struct sangoma_pri *spri, sangoma_pri_event_t event_type,
 		} else {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
 		}
-		
+
 		switch_core_session_rwunlock(session);
 	} else {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "-- Proceeding on channel s%dc%d but it's not in use?\n", 
-						  spri->span, pevent->proceeding.channel);
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE,
+						  "-- Proceeding on channel s%dc%d but it's not in use?\n", spri->span,
+						  pevent->proceeding.channel);
 	}
 
 	return 0;
 }
 
 
-static int on_ringing(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event *pevent)
+static int on_ringing(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event * pevent)
 {
 	switch_core_session_t *session;
 	switch_channel_t *channel;
@@ -1446,7 +1458,8 @@ static int on_ringing(struct sangoma_pri *spri, sangoma_pri_event_t event_type,
 	chanmap = spri->private_info;
 
 	if ((session = switch_core_session_locate(chanmap->map[pevent->ringing.channel]))) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "-- Ringing on channel s%dc%d\n", spri->span, pevent->ringing.channel);
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "-- Ringing on channel s%dc%d\n", spri->span,
+						  pevent->ringing.channel);
 		channel = switch_core_session_get_channel(session);
 		assert(channel != NULL);
 
@@ -1455,34 +1468,36 @@ static int on_ringing(struct sangoma_pri *spri, sangoma_pri_event_t event_type,
 
 		switch_core_session_rwunlock(session);
 	} else {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "-- Ringing on channel s%dc%d %s but it's not in use?\n", spri->span, pevent->ringing.channel, chanmap->map[pevent->ringing.channel]);
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
+						  "-- Ringing on channel s%dc%d %s but it's not in use?\n", spri->span, pevent->ringing.channel,
+						  chanmap->map[pevent->ringing.channel]);
 	}
 
 	return 0;
 }
 
 
-static int on_ring(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event *pevent)
+static int on_ring(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event * pevent)
 {
 	char name[128];
 	switch_core_session_t *session;
 	switch_channel_t *channel;
 	struct channel_map *chanmap;
 	int ret = 0;
-	
+
 	switch_mutex_lock(globals.channel_mutex);
 
 	chanmap = spri->private_info;
 	if (switch_core_session_locate(chanmap->map[pevent->ring.channel])) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "--Duplicate Ring on channel s%dc%d (ignored)\n",
-							  spri->span, pevent->ring.channel);
+						  spri->span, pevent->ring.channel);
 		switch_core_session_rwunlock(session);
 		ret = 0;
 		goto done;
 	}
 
-	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "-- Ring on channel s%dc%d (from %s to %s)\n", spri->span, pevent->ring.channel,
-						  pevent->ring.callingnum, pevent->ring.callednum);
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "-- Ring on channel s%dc%d (from %s to %s)\n", spri->span,
+					  pevent->ring.channel, pevent->ring.callingnum, pevent->ring.callednum);
 
 
 	pri_proceeding(spri->pri, pevent->ring.call, pevent->ring.channel, 0);
@@ -1516,8 +1531,7 @@ static int on_ring(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri
 		if ((tech_pvt->caller_profile = switch_caller_profile_new(switch_core_session_get_pool(session),
 																  NULL,
 																  globals.dialplan,
-																  "FreeSWITCH",
-																  pevent->ring.callingnum,
+																  "FreeSWITCH", pevent->ring.callingnum,
 #ifdef WIN32
 																  NULL,
 #else
@@ -1526,9 +1540,7 @@ static int on_ring(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri
 																  switch_strlen_zero(ani2str) ? NULL : ani2str,
 																  NULL,
 																  NULL,
-																  (char *)modname,
-																  NULL,
-																  pevent->ring.callednum))) {
+																  (char *) modname, NULL, pevent->ring.callednum))) {
 			switch_channel_set_caller_profile(channel, tech_pvt->caller_profile);
 		}
 
@@ -1539,7 +1551,7 @@ static int on_ring(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri
 		if (!tech_pvt->call) {
 			tech_pvt->call = pevent->ring.call;
 		}
-		
+
 		tech_pvt->callno = pevent->ring.channel;
 		tech_pvt->span = spri->span;
 
@@ -1547,17 +1559,18 @@ static int on_ring(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't open fd!\n");
 		}
 
-		switch_copy_string(chanmap->map[pevent->ring.channel], switch_core_session_get_uuid(session), sizeof(chanmap->map[pevent->ring.channel]));
-		
+		switch_copy_string(chanmap->map[pevent->ring.channel], switch_core_session_get_uuid(session),
+						   sizeof(chanmap->map[pevent->ring.channel]));
+
 		switch_channel_set_state(channel, CS_INIT);
 		switch_core_session_thread_launch(session);
 	} else {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot Create new Inbound Channel!\n");
 	}
 
- done:
+  done:
 	switch_mutex_unlock(globals.channel_mutex);
-	
+
 	return ret;
 }
 
@@ -1567,13 +1580,14 @@ static int check_flags(struct sangoma_pri *spri)
 	return 0;
 }
 
-static int on_restart(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event *pevent)
+static int on_restart(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event * pevent)
 {
 	switch_core_session_t *session;
 	struct channel_map *chanmap;
 
 
-	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "-- Restarting s%dc%d\n", spri->span, pevent->restart.channel);
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "-- Restarting s%dc%d\n", spri->span,
+					  pevent->restart.channel);
 
 	if (pevent->restart.channel < 1) {
 		return 0;
@@ -1581,21 +1595,22 @@ static int on_restart(struct sangoma_pri *spri, sangoma_pri_event_t event_type,
 
 
 	chanmap = spri->private_info;
-	
+
 	if ((session = switch_core_session_locate(chanmap->map[pevent->restart.channel]))) {
 		switch_channel_t *channel;
 		channel = switch_core_session_get_channel(session);
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Hanging Up channel %s\n", switch_channel_get_name(channel));
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Hanging Up channel %s\n",
+						  switch_channel_get_name(channel));
 		switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
 		switch_core_session_rwunlock(session);
 	}
-	
+
 	wp_restart(spri->span, pevent->restart.channel);
 
 	return 0;
 }
 
-static int on_dchan_up(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event *pevent)
+static int on_dchan_up(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event * pevent)
 {
 
 	if (!switch_test_flag(spri, SANGOMA_PRI_READY)) {
@@ -1606,22 +1621,22 @@ static int on_dchan_up(struct sangoma_pri *spri, sangoma_pri_event_t event_type,
 	return 0;
 }
 
-static int on_dchan_down(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event *pevent)
+static int on_dchan_down(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event * pevent)
 {
 
 	if (switch_test_flag(spri, SANGOMA_PRI_READY)) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Span %d D-Chan DOWN!\n", spri->span);
 		switch_clear_flag(spri, SANGOMA_PRI_READY);
 	}
-	
+
 	return 0;
 }
 
-static int on_anything(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event *pevent)
+static int on_anything(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event * pevent)
 {
 
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Caught Event span %d %u (%s)\n", spri->span, event_type,
-						  sangoma_pri_event_str(event_type));
+					  sangoma_pri_event_str(event_type));
 	return 0;
 }
 
@@ -1665,7 +1680,7 @@ static void pri_thread_launch(struct sangoma_pri *spri)
 {
 	switch_thread_t *thread;
 	switch_threadattr_t *thd_attr = NULL;
-	
+
 	switch_threadattr_create(&thd_attr, module_pool);
 	switch_threadattr_detach_set(thd_attr, 1);
 	switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
@@ -1674,7 +1689,7 @@ static void pri_thread_launch(struct sangoma_pri *spri)
 }
 
 
-static int isup_exec_command(ss7boost_handle_t *ss7boost_handle, int span, int chan, int id, int cmd, int cause)
+static int isup_exec_command(ss7boost_handle_t * ss7boost_handle, int span, int chan, int id, int cmd, int cause)
 {
 	ss7boost_client_event_t oevent;
 	int r = 0;
@@ -1682,12 +1697,12 @@ static int isup_exec_command(ss7boost_handle_t *ss7boost_handle, int span, int c
 	switch_mutex_lock(ss7boost_handle->mutex);
 	ss7boost_client_event_init(&oevent, cmd, chan, span);
 	oevent.release_cause = cause;
-	
+
 	if (id >= 0) {
 		oevent.call_setup_id = id;
 	}
-	
-	if (ss7boost_client_connection_write(&ss7boost_handle->mcon, &oevent) <= 0){
+
+	if (ss7boost_client_connection_write(&ss7boost_handle->mcon, &oevent) <= 0) {
 		r = -1;
 	}
 
@@ -1699,26 +1714,26 @@ static int isup_exec_command(ss7boost_handle_t *ss7boost_handle, int span, int c
 #ifdef USE_WAITFOR_SOCKET
 static int waitfor_socket(int fd, int timeout, int flags)
 {
-    struct pollfd pfds[1];
-    int res;
- 
-    memset(&pfds[0], 0, sizeof(pfds[0]));
-    pfds[0].fd = fd;
-    pfds[0].events = flags;
-    res = poll(pfds, 1, timeout);
+	struct pollfd pfds[1];
+	int res;
 
-    if (res > 0) {
-	if(pfds[0].revents & POLLIN) {
-		res = 1;
-	} else if ((pfds[0].revents & POLLERR)) {
-		res = -1;
-    	} else {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,"System Error: Poll Event Error no event!\n");
-		res = -1;
+	memset(&pfds[0], 0, sizeof(pfds[0]));
+	pfds[0].fd = fd;
+	pfds[0].events = flags;
+	res = poll(pfds, 1, timeout);
+
+	if (res > 0) {
+		if (pfds[0].revents & POLLIN) {
+			res = 1;
+		} else if ((pfds[0].revents & POLLERR)) {
+			res = -1;
+		} else {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "System Error: Poll Event Error no event!\n");
+			res = -1;
+		}
 	}
-    }
 
-    return res;
+	return res;
 }
 #endif
 
@@ -1736,7 +1751,7 @@ static void validate_number(unsigned char *s)
 }
 
 
-static void handle_call_stop(ss7boost_handle_t *ss7boost_handle, ss7boost_client_event_t *event)
+static void handle_call_stop(ss7boost_handle_t * ss7boost_handle, ss7boost_client_event_t * event)
 {
 	char *uuid = ss7boost_handle->span_chanmap[event->span].map[event->chan];
 
@@ -1746,7 +1761,7 @@ static void handle_call_stop(ss7boost_handle_t *ss7boost_handle, ss7boost_client
 		if ((session = switch_core_session_locate(uuid))) {
 			private_object_t *tech_pvt;
 			switch_channel_t *channel;
-	
+
 			channel = switch_core_session_get_channel(session);
 			assert(channel != NULL);
 
@@ -1758,19 +1773,14 @@ static void handle_call_stop(ss7boost_handle_t *ss7boost_handle, ss7boost_client
 		}
 		*uuid = '\0';
 
-	} 
+	}
 
-	isup_exec_command(ss7boost_handle,
-					  event->span, 
-					  event->chan, 
-					  -1,
-					  SIGBOOST_EVENT_CALL_STOPPED_ACK,
-					  0);
+	isup_exec_command(ss7boost_handle, event->span, event->chan, -1, SIGBOOST_EVENT_CALL_STOPPED_ACK, 0);
 
 
 }
 
-static void handle_call_start(ss7boost_handle_t *ss7boost_handle, ss7boost_client_event_t *event)
+static void handle_call_start(ss7boost_handle_t * ss7boost_handle, ss7boost_client_event_t * event)
 {
 	switch_core_session_t *session = NULL;
 	switch_channel_t *channel = NULL;
@@ -1778,15 +1788,11 @@ static void handle_call_start(ss7boost_handle_t *ss7boost_handle, ss7boost_clien
 
 	if (*ss7boost_handle->span_chanmap[event->span].map[event->chan]) {
 		isup_exec_command(ss7boost_handle,
-						  event->span, 
-						  event->chan, 
-						  -1,
-						  SIGBOOST_EVENT_CALL_START_NACK,
-						  SIGBOOST_RELEASE_CAUSE_BUSY);		
+						  event->span, event->chan, -1, SIGBOOST_EVENT_CALL_START_NACK, SIGBOOST_RELEASE_CAUSE_BUSY);
 		return;
 	}
 
-	
+
 	if ((session = switch_core_session_request(&wanpipe_endpoint_interface, NULL))) {
 		private_object_t *tech_pvt;
 
@@ -1796,7 +1802,7 @@ static void handle_call_start(ss7boost_handle_t *ss7boost_handle, ss7boost_clien
 			switch_mutex_init(&tech_pvt->flag_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
 			channel = switch_core_session_get_channel(session);
 			switch_core_session_set_private(session, tech_pvt);
-			sprintf(name, "wanpipe/ss7boost/s%dc%d", event->span+1, event->chan+1);
+			sprintf(name, "wanpipe/ss7boost/s%dc%d", event->span + 1, event->chan + 1);
 			switch_channel_set_name(channel, name);
 			tech_pvt->session = session;
 		} else {
@@ -1809,18 +1815,17 @@ static void handle_call_start(ss7boost_handle_t *ss7boost_handle, ss7boost_clien
 																  NULL,
 																  globals.dialplan,
 																  "FreeSWITCH(boost)",
-																  (char *)event->calling_number_digits,
+																  (char *) event->calling_number_digits,
 #ifdef WIN32
 																  NULL,
 #else
-																  (char *)event->calling_number_digits,
+																  (char *) event->calling_number_digits,
 #endif
 																  NULL,
 																  NULL,
 																  NULL,
-																  (char *)modname,
-																  NULL,
-																  (char *)event->called_number_digits))) {
+																  (char *) modname,
+																  NULL, (char *) event->called_number_digits))) {
 			switch_channel_set_caller_profile(channel, tech_pvt->caller_profile);
 		}
 
@@ -1832,88 +1837,78 @@ static void handle_call_start(ss7boost_handle_t *ss7boost_handle, ss7boost_clien
 		tech_pvt->boost_span_number = event->span;
 		tech_pvt->boost_chan_number = event->chan;
 		tech_pvt->boost_pres = event->calling_number_presentation;
-		
-		if (!wp_open(tech_pvt, event->span+1, event->chan+1)) {
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't open channel %d:%d\n", event->span+1, event->chan+1);
+
+		if (!wp_open(tech_pvt, event->span + 1, event->chan + 1)) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't open channel %d:%d\n", event->span + 1,
+							  event->chan + 1);
 			goto fail;
 		}
 
-		switch_copy_string(ss7boost_handle->span_chanmap[event->span].map[event->chan], switch_core_session_get_uuid(session), 
+		switch_copy_string(ss7boost_handle->span_chanmap[event->span].map[event->chan],
+						   switch_core_session_get_uuid(session),
 						   sizeof(ss7boost_handle->span_chanmap[event->span].map[event->chan]));
-		
+
 		switch_channel_set_state(channel, CS_INIT);
-		isup_exec_command(ss7boost_handle,
-						  event->span, 
-						  event->chan, 
-						  -1,
-						  SIGBOOST_EVENT_CALL_START_ACK,
-						  0);
+		isup_exec_command(ss7boost_handle, event->span, event->chan, -1, SIGBOOST_EVENT_CALL_START_ACK, 0);
 		switch_core_session_thread_launch(session);
 		return;
 	} else {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot Create new Inbound Channel!\n");
 	}
 
-	
- fail:
+
+  fail:
 	if (session) {
 		switch_core_session_destroy(&session);
 	}
 
 	isup_exec_command(ss7boost_handle,
-					  event->span, 
-					  event->chan, 
-					  -1,
-					  SIGBOOST_EVENT_CALL_STOPPED,
-					  SIGBOOST_RELEASE_CAUSE_BUSY);
+					  event->span, event->chan, -1, SIGBOOST_EVENT_CALL_STOPPED, SIGBOOST_RELEASE_CAUSE_BUSY);
 
 }
 
 
-static void handle_heartbeat(ss7boost_handle_t *ss7boost_handle, ss7boost_client_event_t *event)
+static void handle_heartbeat(ss7boost_handle_t * ss7boost_handle, ss7boost_client_event_t * event)
 {
 
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Heartbeat!\n");
 
-	isup_exec_command(ss7boost_handle,
-					  event->span, 
-					  event->chan, 
-					  -1,
-					  SIGBOOST_EVENT_HEARTBEAT,
-					  0);
+	isup_exec_command(ss7boost_handle, event->span, event->chan, -1, SIGBOOST_EVENT_HEARTBEAT, 0);
 }
 
 
-static void handle_call_start_ack(ss7boost_handle_t *ss7boost_handle, ss7boost_client_event_t *event)
+static void handle_call_start_ack(ss7boost_handle_t * ss7boost_handle, ss7boost_client_event_t * event)
 {
 	char *uuid = ss7boost_handle->setup_array[event->call_setup_id];
-	
+
 	if (*uuid) {
 		switch_core_session_t *session;
 
 		if ((session = switch_core_session_locate(uuid))) {
 			private_object_t *tech_pvt;
 			switch_channel_t *channel;
-	
+
 			channel = switch_core_session_get_channel(session);
 			assert(channel != NULL);
-			
+
 			tech_pvt = switch_core_session_get_private(session);
 			assert(tech_pvt != NULL);
-			
+
 			tech_pvt->ss7boost_handle = ss7boost_handle;
 			tech_pvt->boost_span_number = event->span;
 			tech_pvt->boost_chan_number = event->chan;
-			
-			switch_copy_string(ss7boost_handle->span_chanmap[event->span].map[event->chan], switch_core_session_get_uuid(session), 
+
+			switch_copy_string(ss7boost_handle->span_chanmap[event->span].map[event->chan],
+							   switch_core_session_get_uuid(session),
 							   sizeof(ss7boost_handle->span_chanmap[event->span].map[event->chan]));
 
 
 
 			if (!tech_pvt->wpsock) {
-				if (!wp_open(tech_pvt, tech_pvt->boost_span_number+1, tech_pvt->boost_chan_number+1)) {
-					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't open fd for s%dc%d! [%s]\n", 
-									  tech_pvt->boost_span_number+1, tech_pvt->boost_chan_number+1, strerror(errno));
+				if (!wp_open(tech_pvt, tech_pvt->boost_span_number + 1, tech_pvt->boost_chan_number + 1)) {
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't open fd for s%dc%d! [%s]\n",
+									  tech_pvt->boost_span_number + 1, tech_pvt->boost_chan_number + 1,
+									  strerror(errno));
 					switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 					return;
 				}
@@ -1924,29 +1919,29 @@ static void handle_call_start_ack(ss7boost_handle_t *ss7boost_handle, ss7boost_c
 			}
 
 			switch_channel_mark_pre_answered(channel);
-			
+
 			switch_core_session_rwunlock(session);
 		}
 		*uuid = '\0';
 	}
 }
 
-static void handle_call_start_nack_ack(ss7boost_handle_t *ss7boost_handle, ss7boost_client_event_t *event)
+static void handle_call_start_nack_ack(ss7boost_handle_t * ss7boost_handle, ss7boost_client_event_t * event)
 {
 	// WTF IS THIS! ?
 }
 
-static void handle_call_answer(ss7boost_handle_t *ss7boost_handle, ss7boost_client_event_t *event)
+static void handle_call_answer(ss7boost_handle_t * ss7boost_handle, ss7boost_client_event_t * event)
 {
 	char *uuid = ss7boost_handle->span_chanmap[event->span].map[event->chan];
 
 	if (*uuid) {
 		switch_core_session_t *session;
-		
+
 		if ((session = switch_core_session_locate(uuid))) {
 			private_object_t *tech_pvt;
 			switch_channel_t *channel;
-	
+
 			channel = switch_core_session_get_channel(session);
 			assert(channel != NULL);
 
@@ -1954,9 +1949,10 @@ static void handle_call_answer(ss7boost_handle_t *ss7boost_handle, ss7boost_clie
 			assert(tech_pvt != NULL);
 
 			if (!tech_pvt->wpsock) {
-				if (!wp_open(tech_pvt, tech_pvt->boost_span_number+1, tech_pvt->boost_chan_number+1)) {
-					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't open fd for s%dc%d! [%s]\n", 
-									  tech_pvt->boost_span_number+1, tech_pvt->boost_chan_number+1, strerror(errno));
+				if (!wp_open(tech_pvt, tech_pvt->boost_span_number + 1, tech_pvt->boost_chan_number + 1)) {
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't open fd for s%dc%d! [%s]\n",
+									  tech_pvt->boost_span_number + 1, tech_pvt->boost_chan_number + 1,
+									  strerror(errno));
 					switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 					return;
 				}
@@ -1965,7 +1961,7 @@ static void handle_call_answer(ss7boost_handle_t *ss7boost_handle, ss7boost_clie
 					return;
 				}
 			}
-			
+
 			switch_channel_mark_answered(channel);
 			switch_core_session_rwunlock(session);
 		} else {
@@ -1978,41 +1974,37 @@ static void handle_call_answer(ss7boost_handle_t *ss7boost_handle, ss7boost_clie
 	}
 }
 
-static void handle_call_stop_ack(ss7boost_handle_t *ss7boost_handle, ss7boost_client_event_t *event)
+static void handle_call_stop_ack(ss7boost_handle_t * ss7boost_handle, ss7boost_client_event_t * event)
 {
 	// TODO anything here?
 }
 
 
-static void handle_call_start_nack(ss7boost_handle_t *ss7boost_handle, ss7boost_client_event_t *event)
+static void handle_call_start_nack(ss7boost_handle_t * ss7boost_handle, ss7boost_client_event_t * event)
 {
 	char *uuid = ss7boost_handle->setup_array[event->call_setup_id];
-	
+
 	if (*uuid) {
 		switch_core_session_t *session;
 
 		if ((session = switch_core_session_locate(uuid))) {
 			private_object_t *tech_pvt;
 			switch_channel_t *channel;
-	
+
 			channel = switch_core_session_get_channel(session);
 			assert(channel != NULL);
-			
+
 			tech_pvt = switch_core_session_get_private(session);
 			assert(tech_pvt != NULL);
-			
+
 			tech_pvt->ss7boost_handle = ss7boost_handle;
 			tech_pvt->boost_span_number = event->span;
 			tech_pvt->boost_chan_number = event->chan;
-			
+
 			switch_channel_hangup(channel, event->release_cause);
-			
+
 			isup_exec_command(ss7boost_handle,
-							  event->span,
-							  event->chan, 
-							  event->call_setup_id,
-							  SIGBOOST_EVENT_CALL_START_NACK_ACK,
-							  0);
+							  event->span, event->chan, event->call_setup_id, SIGBOOST_EVENT_CALL_START_NACK_ACK, 0);
 
 			switch_core_session_rwunlock(session);
 		} else {
@@ -2022,14 +2014,14 @@ static void handle_call_start_nack(ss7boost_handle_t *ss7boost_handle, ss7boost_
 	}
 }
 
-static int parse_ss7_event(ss7boost_handle_t *ss7boost_handle, ss7boost_client_event_t *event)
+static int parse_ss7_event(ss7boost_handle_t * ss7boost_handle, ss7boost_client_event_t * event)
 {
 	int ret = 0;
 
 	switch_mutex_lock(ss7boost_handle->mutex);
-		
-	validate_number((unsigned char*)event->called_number_digits);
-	validate_number((unsigned char*)event->calling_number_digits);
+
+	validate_number((unsigned char *) event->called_number_digits);
+	validate_number((unsigned char *) event->calling_number_digits);
 
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
 					  "\nRX EVENT\n"
@@ -2048,21 +2040,16 @@ static int parse_ss7_event(ss7boost_handle_t *ss7boost_handle, ss7boost_client_e
 					  "\n",
 					  ss7boost_client_event_id_name(event->event_id),
 					  event->event_id,
-					  event->span+1,
-					  event->chan+1,
+					  event->span + 1,
+					  event->chan + 1,
 					  (event->called_number_digits_count ? (char *) event->called_number_digits : "N/A"),
 					  (event->calling_number_digits_count ? (char *) event->calling_number_digits : "N/A"),
 					  switch_channel_cause2str(event->release_cause),
-					  event->span+1,
-					  event->chan+1,
-					  event->event_id,
-					  event->call_setup_id,
-					  event->seqno
-					  );
-	
+					  event->span + 1, event->chan + 1, event->event_id, event->call_setup_id, event->seqno);
+
+
+	switch (event->event_id) {
 
-	switch(event->event_id) {
-	
 	case SIGBOOST_EVENT_CALL_START:
 		handle_call_start(ss7boost_handle, event);
 		break;
@@ -2088,7 +2075,7 @@ static int parse_ss7_event(ss7boost_handle_t *ss7boost_handle, ss7boost_client_e
 		handle_call_stop_ack(ss7boost_handle, event);
 		break;
 	default:
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Warning no handler implemented for [%s]\n", 
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Warning no handler implemented for [%s]\n",
 						  ss7boost_client_event_id_name(event->event_id));
 		break;
 	}
@@ -2102,61 +2089,56 @@ static void *SWITCH_THREAD_FUNC boost_thread_run(switch_thread_t *thread, void *
 	ss7boost_client_event_t *event;
 
 	if (ss7boost_client_connection_open(&ss7boost_handle->mcon,
-									ss7boost_handle->local_ip, 
-									ss7boost_handle->local_port,
-									ss7boost_handle->remote_ip,
-									ss7boost_handle->remote_port,
-									module_pool) != SWITCH_STATUS_SUCCESS) {
+										ss7boost_handle->local_ip,
+										ss7boost_handle->local_port,
+										ss7boost_handle->remote_ip,
+										ss7boost_handle->remote_port, module_pool) != SWITCH_STATUS_SUCCESS) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "FATAL ERROR CREATING CLIENT CONNECTION\n");
 		return NULL;
 	}
-			
-	isup_exec_command(ss7boost_handle,
-					  0,
-					  0, 
-					  -1,
-					  SIGBOOST_EVENT_SYSTEM_RESTART,
-					  0);
-	
-	
+
+	isup_exec_command(ss7boost_handle, 0, 0, -1, SIGBOOST_EVENT_SYSTEM_RESTART, 0);
+
+
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Monitor Thread Started\n");
-	
+
 	switch_mutex_lock(globals.hash_mutex);
 	globals.configured_boost_spans++;
 	switch_mutex_unlock(globals.hash_mutex);
 
 	globals.ss7boost_handle = ss7boost_handle;
-	
-	for(;;) {
+
+	for (;;) {
 		if (ss7boost_client_connection_read(&ss7boost_handle->mcon, &event) == SWITCH_STATUS_SUCCESS) {
-				struct timeval current;
-				struct timeval difftime;
-				gettimeofday(¤t,NULL);
-				timersub (¤t, &event->tv, &difftime);
-				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Socket Event [%s] T=%d:%d\n",
-								  ss7boost_client_event_id_name(event->event_id),
-								  (int)difftime.tv_sec, (int)difftime.tv_usec);
-				
-				parse_ss7_event(ss7boost_handle, event);
+			struct timeval current;
+			struct timeval difftime;
+			gettimeofday(¤t, NULL);
+			timersub(¤t, &event->tv, &difftime);
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Socket Event [%s] T=%d:%d\n",
+							  ss7boost_client_event_id_name(event->event_id),
+							  (int) difftime.tv_sec, (int) difftime.tv_usec);
+
+			parse_ss7_event(ss7boost_handle, event);
 		} else {
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error: Reading from Boost Socket! %s\n", strerror(errno));
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error: Reading from Boost Socket! %s\n",
+							  strerror(errno));
 			break;
 		}
 	}
 
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Close udp socket\n");
 	ss7boost_client_connection_close(&ss7boost_handle->mcon);
-	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Monitor Thread Ended\n");	
-	
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Monitor Thread Ended\n");
+
 
 	return NULL;
 }
 
-static void launch_ss7boost_handle(ss7boost_handle_t *ss7boost_handle)
+static void launch_ss7boost_handle(ss7boost_handle_t * ss7boost_handle)
 {
 	switch_thread_t *thread;
 	switch_threadattr_t *thd_attr = NULL;
-	
+
 	switch_threadattr_create(&thd_attr, module_pool);
 	switch_threadattr_detach_set(thd_attr, 1);
 	switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
@@ -2213,7 +2195,7 @@ static switch_status_t config_wanpipe(int reload)
 		for (param = switch_xml_child(span, "param"); param; param = param->next) {
 			char *var = (char *) switch_xml_attr_soft(param, "name");
 			char *val = (char *) switch_xml_attr_soft(param, "value");
-			
+
 			if (!strcasecmp(var, "local-ip")) {
 				local_ip = val;
 			} else if (!strcasecmp(var, "local-port")) {
@@ -2244,7 +2226,7 @@ static switch_status_t config_wanpipe(int reload)
 	}
 
 	analog_channels = switch_xml_child(cfg, "analog_channels");
-	for(channel = switch_xml_child(analog_channels, "channel"); channel; channel = channel->next) {
+	for (channel = switch_xml_child(analog_channels, "channel"); channel; channel = channel->next) {
 		char *c_type = (char *) switch_xml_attr(channel, "type");
 		char *c_dev = (char *) switch_xml_attr(channel, "device");
 		char *user = NULL;
@@ -2254,7 +2236,7 @@ static switch_status_t config_wanpipe(int reload)
 		analog_type_t a_type = ANALOG_TYPE_UNKNOWN;
 		wpsock_t *sock;
 		int chan, span;
-		
+
 		if (!c_type) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing required attribute 'type'\n");
 			continue;
@@ -2278,16 +2260,17 @@ static switch_status_t config_wanpipe(int reload)
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid device name '%s'\n", c_dev);
 			continue;
 		}
-		
+
 		if (!(sock = wp_open(NULL, span, chan))) {
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot open device '%s' (%s)\n", c_dev, strerror(errno));
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot open device '%s' (%s)\n", c_dev,
+							  strerror(errno));
 			continue;
 		}
 
 		for (param = switch_xml_child(channel, "param"); param; param = param->next) {
-            char *var = (char *) switch_xml_attr_soft(param, "name");
-            char *val = (char *) switch_xml_attr_soft(param, "value");
-			
+			char *var = (char *) switch_xml_attr_soft(param, "name");
+			char *val = (char *) switch_xml_attr_soft(param, "value");
+
 			if (!strcasecmp(var, "user")) {
 				user = var;
 			} else if (!strcasecmp(var, "domain")) {
@@ -2313,7 +2296,7 @@ static switch_status_t config_wanpipe(int reload)
 		if (cid_num) {
 			alc->cid_name = strdup(cid_num);
 		}
-		
+
 		alc->a_type = a_type;
 		alc->sock = sock;
 		alc->chan = chan;
@@ -2330,7 +2313,7 @@ static switch_status_t config_wanpipe(int reload)
 	if (globals.fxs_index) {
 		switch_thread_t *thread;
 		switch_threadattr_t *thd_attr = NULL;
-	
+
 		switch_threadattr_create(&thd_attr, module_pool);
 		switch_threadattr_detach_set(thd_attr, 1);
 		switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
@@ -2345,10 +2328,10 @@ static switch_status_t config_wanpipe(int reload)
 		int32_t i = 0;
 
 		current_span = 0;
-		
+
 		if (id) {
 			char *p;
-			
+
 			min_span = atoi(id);
 			if ((p = strchr(id, '-'))) {
 				p++;
@@ -2364,16 +2347,16 @@ static switch_status_t config_wanpipe(int reload)
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Missing SPAN ID!\n");
 			continue;
 		}
-		
+
 		for (i = min_span; i <= max_span; i++) {
 			current_span = i;
-			
+
 			if (current_span <= 0 || current_span > MAX_SPANS) {
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid SPAN %d!\n", current_span);
 				current_span = 0;
 				continue;
 			}
-			
+
 			if (!SPANS[current_span]) {
 				if (!(SPANS[current_span] = switch_core_alloc(module_pool, sizeof(*SPANS[current_span])))) {
 					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "MEMORY ERROR\n");
@@ -2381,12 +2364,12 @@ static switch_status_t config_wanpipe(int reload)
 				}
 				SPANS[current_span]->span = current_span;
 			}
-			
+
 
 			for (param = switch_xml_child(span, "param"); param; param = param->next) {
 				char *var = (char *) switch_xml_attr_soft(param, "name");
 				char *val = (char *) switch_xml_attr_soft(param, "value");
-			
+
 				if (!strcmp(var, "dchan")) {
 					SPANS[current_span]->dchan = atoi(val);
 				} else if (!strcmp(var, "bchan")) {
@@ -2399,7 +2382,7 @@ static switch_status_t config_wanpipe(int reload)
 						fromi = atoi(from);
 						toi = atoi(to);
 						if (fromi > 0 && toi > 0 && fromi < toi && fromi < MAX_SPANS && toi < MAX_SPANS) {
-							for(x = fromi; x <= toi; x++) {
+							for (x = fromi; x <= toi; x++) {
 								SPANS[current_span]->bchans |= (1 << x);
 							}
 						} else {
@@ -2433,7 +2416,7 @@ static switch_status_t config_wanpipe(int reload)
 
 
 	globals.configured_spans = 0;
-	for(current_span = 1; current_span < MAX_SPANS; current_span++) {
+	for (current_span = 1; current_span < MAX_SPANS; current_span++) {
 		if (SPANS[current_span]) {
 
 			if (!SPANS[current_span]->l1) {
@@ -2442,9 +2425,7 @@ static switch_status_t config_wanpipe(int reload)
 			if (sangoma_init_pri(&SPANS[current_span]->spri,
 								 current_span,
 								 SPANS[current_span]->dchan,
-								 SPANS[current_span]->pswitch,
-								 SPANS[current_span]->node,
-								 globals.debug)) {
+								 SPANS[current_span]->pswitch, SPANS[current_span]->node, globals.debug)) {
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Cannot launch span %d\n", current_span);
 				continue;
 			}
@@ -2461,6 +2442,3 @@ static switch_status_t config_wanpipe(int reload)
 	return SWITCH_STATUS_SUCCESS;
 
 }
-
-
-
diff --git a/src/mod/endpoints/mod_wanpipe/sigboost.h b/src/mod/endpoints/mod_wanpipe/sigboost.h
index 373671afa8..25cb8122bb 100644
--- a/src/mod/endpoints/mod_wanpipe/sigboost.h
+++ b/src/mod/endpoints/mod_wanpipe/sigboost.h
@@ -16,38 +16,35 @@
 
 #include 
 
-enum	e_sigboost_event_id_values
-{
-	SIGBOOST_EVENT_CALL_START			= 0x80, /*128*/
-	SIGBOOST_EVENT_CALL_START_ACK			= 0x81, /*129*/
-	SIGBOOST_EVENT_CALL_START_NACK			= 0x82, /*130*/
-	SIGBOOST_EVENT_CALL_START_NACK_ACK		= 0x83, /*131*/
-	SIGBOOST_EVENT_CALL_ANSWERED			= 0x84, /*132*/
-	SIGBOOST_EVENT_CALL_STOPPED			= 0x85, /*133*/
-	SIGBOOST_EVENT_CALL_STOPPED_ACK			= 0x86, /*134*/
-	SIGBOOST_EVENT_SYSTEM_RESTART			= 0x87, /*135*/
-	SIGBOOST_EVENT_HEARTBEAT			= 0x88, /*136*/
+enum e_sigboost_event_id_values {
+	SIGBOOST_EVENT_CALL_START = 0x80,	/*128 */
+	SIGBOOST_EVENT_CALL_START_ACK = 0x81,	/*129 */
+	SIGBOOST_EVENT_CALL_START_NACK = 0x82,	/*130 */
+	SIGBOOST_EVENT_CALL_START_NACK_ACK = 0x83,	/*131 */
+	SIGBOOST_EVENT_CALL_ANSWERED = 0x84,	/*132 */
+	SIGBOOST_EVENT_CALL_STOPPED = 0x85,	/*133 */
+	SIGBOOST_EVENT_CALL_STOPPED_ACK = 0x86,	/*134 */
+	SIGBOOST_EVENT_SYSTEM_RESTART = 0x87,	/*135 */
+	SIGBOOST_EVENT_HEARTBEAT = 0x88,	/*136 */
 };
 
-enum	e_sigboost_release_cause_values
-{
-	SIGBOOST_RELEASE_CAUSE_UNDEFINED		= 0x00,
-	SIGBOOST_RELEASE_CAUSE_NORMAL			= 0x90,
-	SIGBOOST_RELEASE_CAUSE_BUSY			= 0x91,
-	SIGBOOST_RELEASE_CAUSE_CALLED_NOT_EXIST		= 0x92,
-	SIGBOOST_RELEASE_CAUSE_CIRCUIT_RESET		= 0x93,
-	SIGBOOST_RELEASE_CAUSE_NOANSWER			= 0x94
+enum e_sigboost_release_cause_values {
+	SIGBOOST_RELEASE_CAUSE_UNDEFINED = 0x00,
+	SIGBOOST_RELEASE_CAUSE_NORMAL = 0x90,
+	SIGBOOST_RELEASE_CAUSE_BUSY = 0x91,
+	SIGBOOST_RELEASE_CAUSE_CALLED_NOT_EXIST = 0x92,
+	SIGBOOST_RELEASE_CAUSE_CIRCUIT_RESET = 0x93,
+	SIGBOOST_RELEASE_CAUSE_NOANSWER = 0x94
 };
 
-enum	e_sigboost_call_setup_ack_nack_cause_values
-{
-	SIGBOOST_CALL_SETUP_CIRCUIT_RESET		= 0x10,
-	SIGBOOST_CALL_SETUP_NACK_CKT_START_TIMEOUT	= 0x11,
-	SIGBOOST_CALL_SETUP_NACK_ALL_CKTS_BUSY		= 0x12,
-	SIGBOOST_CALL_SETUP_NACK_CALLED_NUM_TOO_BIG	= 0x13,
-	SIGBOOST_CALL_SETUP_NACK_CALLING_NUM_TOO_BIG	= 0x14,
-	SIGBOOST_CALL_SETUP_NACK_CALLED_NUM_TOO_SMALL	= 0x15,
-	SIGBOOST_CALL_SETUP_NACK_CALLING_NUM_TOO_SMALL	= 0x16,
+enum e_sigboost_call_setup_ack_nack_cause_values {
+	SIGBOOST_CALL_SETUP_CIRCUIT_RESET = 0x10,
+	SIGBOOST_CALL_SETUP_NACK_CKT_START_TIMEOUT = 0x11,
+	SIGBOOST_CALL_SETUP_NACK_ALL_CKTS_BUSY = 0x12,
+	SIGBOOST_CALL_SETUP_NACK_CALLED_NUM_TOO_BIG = 0x13,
+	SIGBOOST_CALL_SETUP_NACK_CALLING_NUM_TOO_BIG = 0x14,
+	SIGBOOST_CALL_SETUP_NACK_CALLED_NUM_TOO_SMALL = 0x15,
+	SIGBOOST_CALL_SETUP_NACK_CALLING_NUM_TOO_SMALL = 0x16,
 };
 
 #define MAX_DIALED_DIGITS	31
@@ -61,21 +58,20 @@ enum	e_sigboost_call_setup_ack_nack_cause_values
 /* 0..(MAX_PENDING_CALLS-1) is range of call_setup_id below */
 
 #pragma pack(1)
-typedef struct
-{
-	uint32_t	event_id;
-	uint32_t	seqno;
-	uint32_t	call_setup_id;
-	uint32_t	trunk_group;
-	uint32_t	span;
-	uint32_t	chan;
-	uint32_t	called_number_digits_count;
-	int8_t		called_number_digits [MAX_DIALED_DIGITS + 1]; /* it's a null terminated string */
-	uint32_t	calling_number_digits_count; /* it's an array */
-	int8_t		calling_number_digits [MAX_DIALED_DIGITS + 1]; /* it's a null terminated string */
-	uint32_t	release_cause;
-	struct timeval  tv;
-	uint32_t	calling_number_presentation;
+typedef struct {
+	uint32_t event_id;
+	uint32_t seqno;
+	uint32_t call_setup_id;
+	uint32_t trunk_group;
+	uint32_t span;
+	uint32_t chan;
+	uint32_t called_number_digits_count;
+	int8_t called_number_digits[MAX_DIALED_DIGITS + 1];	/* it's a null terminated string */
+	uint32_t calling_number_digits_count;	/* it's an array */
+	int8_t calling_number_digits[MAX_DIALED_DIGITS + 1];	/* it's a null terminated string */
+	uint32_t release_cause;
+	struct timeval tv;
+	uint32_t calling_number_presentation;
 } t_sigboost;
 #pragma pack()
 
diff --git a/src/mod/endpoints/mod_wanpipe/ss7boost_client.c b/src/mod/endpoints/mod_wanpipe/ss7boost_client.c
index 7fd56fb736..da8b28503c 100644
--- a/src/mod/endpoints/mod_wanpipe/ss7boost_client.c
+++ b/src/mod/endpoints/mod_wanpipe/ss7boost_client.c
@@ -52,23 +52,25 @@ static struct ss7boost_client_map ss7boost_client_table[] = {
 	{SIGBOOST_EVENT_CALL_STOPPED_ACK, "CALL_STOPPED_ACK"},
 	{SIGBOOST_EVENT_SYSTEM_RESTART, "SYSTEM_RESTART"},
 	{SIGBOOST_EVENT_HEARTBEAT, "HEARTBEAT"},
-}; 
+};
 
 
 
-static switch_status_t create_udp_socket(ss7boost_client_connection_t *mcon, char *local_ip, int local_port, char *ip, int port)
+static switch_status_t create_udp_socket(ss7boost_client_connection_t * mcon, char *local_ip, int local_port, char *ip,
+										 int port)
 {
 
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "connect %s:%d->%s:%d\n", local_ip, local_port, ip, port);
 
-	if (switch_sockaddr_info_get(&mcon->local_addr, local_ip, SWITCH_UNSPEC, local_port, 0, mcon->pool) != SWITCH_STATUS_SUCCESS) {
+	if (switch_sockaddr_info_get(&mcon->local_addr, local_ip, SWITCH_UNSPEC, local_port, 0, mcon->pool) !=
+		SWITCH_STATUS_SUCCESS) {
 		goto fail;
 	}
 
 	if (switch_sockaddr_info_get(&mcon->remote_addr, ip, SWITCH_UNSPEC, port, 0, mcon->pool) != SWITCH_STATUS_SUCCESS) {
 		goto fail;
 	}
-	
+
 	if (switch_socket_create(&mcon->socket, AF_INET, SOCK_DGRAM, 0, mcon->pool) == SWITCH_STATUS_SUCCESS) {
 		if (switch_socket_bind(mcon->socket, mcon->local_addr) != SWITCH_STATUS_SUCCESS) {
 			goto fail;
@@ -77,18 +79,20 @@ static switch_status_t create_udp_socket(ss7boost_client_connection_t *mcon, cha
 		goto fail;
 	}
 
-	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Created boost connection %s:%d->%s:%d\n", local_ip, local_port, ip, port);
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Created boost connection %s:%d->%s:%d\n", local_ip,
+					  local_port, ip, port);
 	return SWITCH_STATUS_SUCCESS;
 
- fail:
+  fail:
 
-	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Failure creating boost connection %s:%d->%s:%d\n", local_ip, local_port, ip, port);
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Failure creating boost connection %s:%d->%s:%d\n", local_ip,
+					  local_port, ip, port);
 	return SWITCH_STATUS_FALSE;
 }
 
 
 
-SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_close(ss7boost_client_connection_t *mcon)
+SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_close(ss7boost_client_connection_t * mcon)
 {
 	switch_socket_close(mcon->socket);
 	mcon->socket = NULL;
@@ -97,12 +101,10 @@ SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_close(ss7boost_client
 	return SWITCH_STATUS_SUCCESS;
 }
 
-SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_open(ss7boost_client_connection_t *mcon,
-															char *local_ip,
-															int local_port,
-															char *ip,
-															int port,
-															switch_memory_pool_t *pool)
+SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_open(ss7boost_client_connection_t * mcon,
+																char *local_ip,
+																int local_port,
+																char *ip, int port, switch_memory_pool_t *pool)
 {
 	memset(mcon, 0, sizeof(*mcon));
 	mcon->pool = pool;
@@ -111,32 +113,30 @@ SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_open(ss7boost_client_
 		switch_mutex_init(&mcon->mutex, SWITCH_MUTEX_NESTED, mcon->pool);
 		return SWITCH_STATUS_SUCCESS;
 	}
-	
+
 	memset(mcon, 0, sizeof(*mcon));
 	return SWITCH_STATUS_FALSE;
 }
 
-SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_read(ss7boost_client_connection_t *mcon, ss7boost_client_event_t **event)
+SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_read(ss7boost_client_connection_t * mcon,
+																ss7boost_client_event_t ** event)
 {
 	unsigned int fromlen = sizeof(struct sockaddr_in);
 	switch_size_t bytes = 0;
 
 	bytes = sizeof(mcon->event);
 
-	if (switch_socket_recvfrom(mcon->local_addr, mcon->socket, 0, (void *)&mcon->event, &bytes) != SWITCH_STATUS_SUCCESS) {
+	if (switch_socket_recvfrom(mcon->local_addr, mcon->socket, 0, (void *) &mcon->event, &bytes) !=
+		SWITCH_STATUS_SUCCESS) {
 		bytes = 0;
 	}
 
-	if (bytes == sizeof(mcon->event) || 
-            bytes == (sizeof(mcon->event)-sizeof(uint32_t))) {
+	if (bytes == sizeof(mcon->event) || bytes == (sizeof(mcon->event) - sizeof(uint32_t))) {
 		if (rxseq != mcon->event.seqno) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, 
-			"------------------------------------------\n");
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, 
-			"Critical Error: Invalid Sequence Number Expect=%i Rx=%i\n",
-			rxseq,mcon->event.seqno);
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, 
-			"------------------------------------------\n");
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "------------------------------------------\n");
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT,
+							  "Critical Error: Invalid Sequence Number Expect=%i Rx=%i\n", rxseq, mcon->event.seqno);
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "------------------------------------------\n");
 		}
 		rxseq++;
 
@@ -147,7 +147,8 @@ SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_read(ss7boost_client_
 	return SWITCH_STATUS_FALSE;
 }
 
-SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_write(ss7boost_client_connection_t *mcon, ss7boost_client_event_t *event)
+SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_write(ss7boost_client_connection_t * mcon,
+																 ss7boost_client_event_t * event)
 {
 	int err;
 	switch_size_t len;
@@ -158,23 +159,19 @@ SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_write(ss7boost_client
 	}
 
 	if (event->span < 0 || event->chan < 0 || event->span > 7 || event->chan > 30) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, 
-			"------------------------------------------\n");
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, 
-			"Critical Error: Invalid Span=%i Chan=%i\n",
-			event->span,event->chan);
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, 
-			"------------------------------------------\n");
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "------------------------------------------\n");
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT,
+						  "Critical Error: Invalid Span=%i Chan=%i\n", event->span, event->chan);
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "------------------------------------------\n");
 	}
-
 #ifdef WIN32
 	//TODO set the tv with win func
-#else 
-	gettimeofday(&event->tv,NULL);
+#else
+	gettimeofday(&event->tv, NULL);
 #endif
 
 	switch_mutex_lock(mcon->mutex);
-	event->seqno=txseq++;
+	event->seqno = txseq++;
 	len = sizeof(*event);
 	if (switch_socket_sendto(mcon->socket, mcon->remote_addr, 0, (void *) event, &len) != SWITCH_STATUS_SUCCESS) {
 		err = -1;
@@ -182,7 +179,8 @@ SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_write(ss7boost_client
 	switch_mutex_unlock(mcon->mutex);
 
 	if (len != sizeof(ss7boost_client_event_t)) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Write Error: [%d][%d][%s]\n", mcon->socket, errno, strerror(errno));
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Write Error: [%d][%d][%s]\n", mcon->socket, errno,
+						  strerror(errno));
 		err = -1;
 	}
 
@@ -204,42 +202,39 @@ SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_write(ss7boost_client
 					  "\n",
 					  ss7boost_client_event_id_name(event->event_id),
 					  event->event_id,
-					  event->span+1,
-					  event->chan+1,
+					  event->span + 1,
+					  event->chan + 1,
 					  (event->called_number_digits_count ? (char *) event->called_number_digits : "N/A"),
 					  (event->calling_number_digits_count ? (char *) event->calling_number_digits : "N/A"),
 					  event->release_cause,
-					  event->span+1,
-					  event->chan+1,
-					  event->event_id,
-					  event->call_setup_id,
-					  event->seqno
-					  );
+					  event->span + 1, event->chan + 1, event->event_id, event->call_setup_id, event->seqno);
 
 
 	return err ? SWITCH_STATUS_FALSE : SWITCH_STATUS_SUCCESS;
 }
 
-SWITCH_DECLARE(void) ss7boost_client_call_init(ss7boost_client_event_t *event, char *calling, char *called, int setup_id)
+SWITCH_DECLARE(void) ss7boost_client_call_init(ss7boost_client_event_t * event, char *calling, char *called,
+											   int setup_id)
 {
 	memset(event, 0, sizeof(ss7boost_client_event_t));
 	event->event_id = SIGBOOST_EVENT_CALL_START;
 
 	if (calling) {
-		strncpy((char*)event->calling_number_digits, calling, sizeof(event->calling_number_digits)-1);
+		strncpy((char *) event->calling_number_digits, calling, sizeof(event->calling_number_digits) - 1);
 		event->calling_number_digits_count = strlen(calling);
 	}
 
 	if (called) {
-		strncpy((char*)event->called_number_digits, called, sizeof(event->called_number_digits)-1);
+		strncpy((char *) event->called_number_digits, called, sizeof(event->called_number_digits) - 1);
 		event->called_number_digits_count = strlen(called);
 	}
-		
+
 	event->call_setup_id = setup_id;
-	
+
 }
 
-SWITCH_DECLARE(void) ss7boost_client_event_init(ss7boost_client_event_t *event, ss7boost_client_event_id_t event_id, int chan, int span) 
+SWITCH_DECLARE(void) ss7boost_client_event_init(ss7boost_client_event_t * event, ss7boost_client_event_id_t event_id,
+												int chan, int span)
 {
 	memset(event, 0, sizeof(ss7boost_client_event_t));
 	event->event_id = event_id;
@@ -252,7 +247,7 @@ SWITCH_DECLARE(char *) ss7boost_client_event_id_name(uint32_t event_id)
 	int x;
 	char *ret = NULL;
 
-	for (x = 0 ; x < sizeof(ss7boost_client_table)/sizeof(struct ss7boost_client_map); x++) {
+	for (x = 0; x < sizeof(ss7boost_client_table) / sizeof(struct ss7boost_client_map); x++) {
 		if (ss7boost_client_table[x].event_id == event_id) {
 			ret = ss7boost_client_table[x].name;
 			break;
diff --git a/src/mod/endpoints/mod_wanpipe/ss7boost_client.h b/src/mod/endpoints/mod_wanpipe/ss7boost_client.h
index 5f37886eab..80d530e501 100644
--- a/src/mod/endpoints/mod_wanpipe/ss7boost_client.h
+++ b/src/mod/endpoints/mod_wanpipe/ss7boost_client.h
@@ -70,7 +70,7 @@
 					(dest)->flags |= ((src)->flags & (flagz)); \
 					} while (0)
 
-typedef  t_sigboost ss7boost_client_event_t;
+typedef t_sigboost ss7boost_client_event_t;
 typedef uint32_t ss7boost_client_event_id_t;
 
 struct ss7boost_client_connection {
@@ -80,7 +80,7 @@ struct ss7boost_client_connection {
 	ss7boost_client_event_t event;
 	unsigned int flags;
 	switch_mutex_t *mutex;
-	switch_memory_pool_t * pool;
+	switch_memory_pool_t *pool;
 };
 
 typedef enum {
@@ -89,19 +89,19 @@ typedef enum {
 
 typedef struct ss7boost_client_connection ss7boost_client_connection_t;
 
-SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_close(ss7boost_client_connection_t *mcon);
-SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_open(ss7boost_client_connection_t *mcon,
-															char *local_ip,
-															int local_port,
-															char *ip,
-															int port,
-															switch_memory_pool_t *pool);
-SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_read(ss7boost_client_connection_t *mcon, ss7boost_client_event_t **event);
-SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_write(ss7boost_client_connection_t *mcon, ss7boost_client_event_t *event);
-SWITCH_DECLARE(void) ss7boost_client_event_init(ss7boost_client_event_t *event, ss7boost_client_event_id_t event_id, int chan, int span);
-SWITCH_DECLARE(void) ss7boost_client_call_init(ss7boost_client_event_t *event, char *calling, char *called, int setup_id);
+SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_close(ss7boost_client_connection_t * mcon);
+SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_open(ss7boost_client_connection_t * mcon,
+																char *local_ip,
+																int local_port,
+																char *ip, int port, switch_memory_pool_t *pool);
+SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_read(ss7boost_client_connection_t * mcon,
+																ss7boost_client_event_t ** event);
+SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_write(ss7boost_client_connection_t * mcon,
+																 ss7boost_client_event_t * event);
+SWITCH_DECLARE(void) ss7boost_client_event_init(ss7boost_client_event_t * event, ss7boost_client_event_id_t event_id,
+												int chan, int span);
+SWITCH_DECLARE(void) ss7boost_client_call_init(ss7boost_client_event_t * event, char *calling, char *called,
+											   int setup_id);
 SWITCH_DECLARE(char *) ss7boost_client_event_id_name(uint32_t event_id);
 
 #endif
-
-
diff --git a/src/mod/endpoints/mod_woomera/mod_woomera.c b/src/mod/endpoints/mod_woomera/mod_woomera.c
index 071dc7e320..63c79cd9e8 100644
--- a/src/mod/endpoints/mod_woomera/mod_woomera.c
+++ b/src/mod/endpoints/mod_woomera/mod_woomera.c
@@ -169,12 +169,13 @@ static switch_status_t woomera_on_hangup(switch_core_session_t *session);
 static switch_status_t woomera_on_ring(switch_core_session_t *session);
 static switch_status_t woomera_on_loopback(switch_core_session_t *session);
 static switch_status_t woomera_on_transmit(switch_core_session_t *session);
-static switch_call_cause_t woomera_outgoing_channel(switch_core_session_t *session, switch_caller_profile_t *outbound_profile,
+static switch_call_cause_t woomera_outgoing_channel(switch_core_session_t *session,
+													switch_caller_profile_t *outbound_profile,
 													switch_core_session_t **new_session, switch_memory_pool_t **pool);
 static switch_status_t woomera_read_frame(switch_core_session_t *session, switch_frame_t **frame, int timeout,
-											switch_io_flag_t flags, int stream_id);
+										  switch_io_flag_t flags, int stream_id);
 static switch_status_t woomera_write_frame(switch_core_session_t *session, switch_frame_t *frame, int timeout,
-											 switch_io_flag_t flags, int stream_id);
+										   switch_io_flag_t flags, int stream_id);
 static switch_status_t woomera_kill_channel(switch_core_session_t *session, int sig);
 static void tech_destroy(private_object * tech_pvt);
 static void woomera_printf(woomera_profile * profile, switch_socket_t *socket, char *fmt, ...);
@@ -213,7 +214,8 @@ static switch_status_t woomera_on_init(switch_core_session_t *session)
 	if (switch_core_codec_init
 		(&tech_pvt->read_codec, "L16", NULL, rate, 30, 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,
 		 switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%s Cannot set read codec\n", switch_channel_get_name(channel));
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%s Cannot set read codec\n",
+						  switch_channel_get_name(channel));
 		switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 		return SWITCH_STATUS_FALSE;
 	}
@@ -221,7 +223,8 @@ static switch_status_t woomera_on_init(switch_core_session_t *session)
 	if (switch_core_codec_init
 		(&tech_pvt->write_codec, "L16", NULL, rate, 30, 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,
 		 switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%s Cannot set read codec\n", switch_channel_get_name(channel));
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%s Cannot set read codec\n",
+						  switch_channel_get_name(channel));
 		switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 		return SWITCH_STATUS_FALSE;
 	}
@@ -327,19 +330,19 @@ static switch_status_t woomera_kill_channel(switch_core_session_t *session, int
 		return SWITCH_STATUS_FALSE;
 	}
 
-    switch(sig) {
-    case SWITCH_SIG_KILL:
-        udp_socket_close(tech_pvt);
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s WOOMERA KILL\n", switch_channel_get_name(channel));
-        break;
-    case SWITCH_SIG_BREAK:
-        {
-            const char p = 0;
-            switch_size_t len = sizeof(p);
-            switch_socket_sendto(tech_pvt->udp_socket, tech_pvt->udpwrite, 0, &p, &len);
-        }
-        break;
-    }
+	switch (sig) {
+	case SWITCH_SIG_KILL:
+		udp_socket_close(tech_pvt);
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s WOOMERA KILL\n", switch_channel_get_name(channel));
+		break;
+	case SWITCH_SIG_BREAK:
+		{
+			const char p = 0;
+			switch_size_t len = sizeof(p);
+			switch_socket_sendto(tech_pvt->udp_socket, tech_pvt->udpwrite, 0, &p, &len);
+		}
+		break;
+	}
 
 
 	return SWITCH_STATUS_SUCCESS;
@@ -375,11 +378,11 @@ static switch_status_t woomera_waitfor_write(switch_core_session_t *session, int
 	assert(tech_pvt != NULL);
 
 	return SWITCH_STATUS_SUCCESS;
-//	return switch_socket_waitfor(tech_pvt->write_poll, ms);
+//  return switch_socket_waitfor(tech_pvt->write_poll, ms);
 }
 
 static switch_status_t woomera_read_frame(switch_core_session_t *session, switch_frame_t **frame, int timeout,
-											switch_io_flag_t flags, int stream_id)
+										  switch_io_flag_t flags, int stream_id)
 {
 	switch_channel_t *channel = NULL;
 	struct private_object *tech_pvt = NULL;
@@ -404,8 +407,9 @@ static switch_status_t woomera_read_frame(switch_core_session_t *session, switch
 	*frame = pframe;
 
 	len = sizeof(tech_pvt->databuf);
-	if (switch_socket_recvfrom(tech_pvt->udpread, tech_pvt->udp_socket, 0, tech_pvt->databuf, &len) == SWITCH_STATUS_SUCCESS) {
-		pframe->datalen = (uint32_t)len;
+	if (switch_socket_recvfrom(tech_pvt->udpread, tech_pvt->udp_socket, 0, tech_pvt->databuf, &len) ==
+		SWITCH_STATUS_SUCCESS) {
+		pframe->datalen = (uint32_t) len;
 		pframe->samples = (int) pframe->datalen / 2;
 		return SWITCH_STATUS_SUCCESS;
 	}
@@ -414,13 +418,13 @@ static switch_status_t woomera_read_frame(switch_core_session_t *session, switch
 }
 
 static switch_status_t woomera_write_frame(switch_core_session_t *session, switch_frame_t *frame, int timeout,
-											 switch_io_flag_t flags, int stream_id)
+										   switch_io_flag_t flags, int stream_id)
 {
 	switch_channel_t *channel = NULL;
 	struct private_object *tech_pvt = NULL;
 	switch_size_t len;
 	//switch_frame_t *pframe;
-	
+
 	channel = switch_core_session_get_channel(session);
 	assert(channel != NULL);
 
@@ -430,11 +434,10 @@ static switch_status_t woomera_write_frame(switch_core_session_t *session, switc
 	if (!tech_pvt->udp_socket) {
 		return SWITCH_STATUS_GENERR;
 	}
-
 	//pframe = &tech_pvt->frame;
 	len = frame->datalen;
 	if (switch_socket_sendto(tech_pvt->udp_socket, tech_pvt->udpwrite, 0, frame->data, &len) == SWITCH_STATUS_SUCCESS) {
-		frame->datalen = (uint32_t)len;
+		frame->datalen = (uint32_t) len;
 		return SWITCH_STATUS_SUCCESS;
 	}
 
@@ -481,7 +484,8 @@ static const switch_loadable_module_interface_t woomera_module_interface = {
 /* Make sure when you have 2 sessions in the same scope that you pass the appropriate one to the routines
    that allocate memory or you will have 1 channel with memory allocated from another channel's pool!
 */
-static switch_call_cause_t woomera_outgoing_channel(switch_core_session_t *session, switch_caller_profile_t *outbound_profile,
+static switch_call_cause_t woomera_outgoing_channel(switch_core_session_t *session,
+													switch_caller_profile_t *outbound_profile,
 													switch_core_session_t **new_session, switch_memory_pool_t **pool)
 {
 	if ((*new_session = switch_core_session_request(&woomera_endpoint_interface, pool)) != 0) {
@@ -542,7 +546,8 @@ static void tech_destroy(private_object * tech_pvt)
 				   WOOMERA_RECORD_SEPERATOR);
 	if (woomera_message_parse
 		(tech_pvt->command_channel, &wmsg, WOOMERA_HARD_TIMEOUT, tech_pvt->profile, &tech_pvt->event_queue) < 0) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "{%s} Already Disconnected\n", tech_pvt->profile->name);
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "{%s} Already Disconnected\n",
+						  tech_pvt->profile->name);
 	}
 
 	woomera_printf(tech_pvt->profile, tech_pvt->command_channel, "bye%s", WOOMERA_RECORD_SEPERATOR);
@@ -570,7 +575,7 @@ static void woomera_printf(woomera_profile * profile, switch_socket_t *socket, c
 	} else {
 		if (profile && globals.debug) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Send Message: {%s} [%s/%d]\n%s\n%s", profile->name,
-								  profile->woomera_host, profile->woomera_port, WOOMERA_DEBUG_LINE, stuff);
+							  profile->woomera_host, profile->woomera_port, WOOMERA_DEBUG_LINE, stuff);
 		}
 		len = strlen(stuff);
 		switch_socket_send(socket, stuff, &len);
@@ -660,7 +665,7 @@ static int woomera_message_parse(switch_socket_t *fd, woomera_message * wmsg, in
 	bytes = 0;
 	while (!strstr(buf, WOOMERA_RECORD_SEPERATOR)) {
 		size_t len = 1;
-        switch_status_t status;
+		switch_status_t status;
 
 		if (!profile->thread_running) {
 			return -1;
@@ -668,16 +673,16 @@ static int woomera_message_parse(switch_socket_t *fd, woomera_message * wmsg, in
 
 		status = switch_socket_recv(fd, ptr, &len);
 
-        if (status == 70007) {
-            char bbuf = '\n';
-            switch_size_t blen = sizeof(bbuf);
-            switch_socket_send(fd, &bbuf, &blen);
-            continue;
-        }
-        
-        if (status != SWITCH_STATUS_SUCCESS) {
-                return -1;
-        }
+		if (status == 70007) {
+			char bbuf = '\n';
+			switch_size_t blen = sizeof(bbuf);
+			switch_socket_send(fd, &bbuf, &blen);
+			continue;
+		}
+
+		if (status != SWITCH_STATUS_SUCCESS) {
+			return -1;
+		}
 
 		ptr++;
 		bytes++;
@@ -687,7 +692,7 @@ static int woomera_message_parse(switch_socket_t *fd, woomera_message * wmsg, in
 
 	if (globals.debug) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Receive Message: {%s} [%s/%d]\n%s\n%s", profile->name,
-							  profile->woomera_host, profile->woomera_port, WOOMERA_DEBUG_LINE, buf);
+						  profile->woomera_host, profile->woomera_port, WOOMERA_DEBUG_LINE, buf);
 	}
 
 	while ((cur = next) != 0) {
@@ -775,7 +780,8 @@ static int woomera_message_parse(switch_socket_t *fd, woomera_message * wmsg, in
 
 	if (event_queue && switch_test_flag(wmsg, WFLAG_EVENT)) {
 		if (globals.debug) {
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Queue Event: {%s} [%s]\n", profile->name, wmsg->command);
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Queue Event: {%s} [%s]\n", profile->name,
+							  wmsg->command);
 		}
 		/* we don't want events we want a reply so we will stash them for later */
 		woomera_enqueue_event(event_queue, wmsg);
@@ -801,7 +807,8 @@ static int connect_woomera(switch_socket_t **new_sock, woomera_profile * profile
 
 	switch_sockaddr_t *sa;
 
-	if (switch_sockaddr_info_get(&sa, profile->woomera_host, AF_INET, profile->woomera_port, 0, module_pool) != SWITCH_STATUS_SUCCESS) {
+	if (switch_sockaddr_info_get(&sa, profile->woomera_host, AF_INET, profile->woomera_port, 0, module_pool) !=
+		SWITCH_STATUS_SUCCESS) {
 		return -1;
 	}
 
@@ -809,8 +816,8 @@ static int connect_woomera(switch_socket_t **new_sock, woomera_profile * profile
 		return -1;
 	}
 
-    switch_socket_timeout_set((*new_sock), 10000000);
-    switch_socket_opt_set((*new_sock), SWITCH_SO_KEEPALIVE, 1);
+	switch_socket_timeout_set((*new_sock), 10000000);
+	switch_socket_opt_set((*new_sock), SWITCH_SO_KEEPALIVE, 1);
 
 	/*
 	   status = switch_socket_bind((*new_sock), sa);
@@ -851,8 +858,8 @@ static int woomera_locate_socket(woomera_profile * profile, switch_socket_t **wo
 			if (!woomera_profile_thread_running(profile, 0, 0)) {
 				break;
 			}
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "{%s} Cannot Reconnect to Woomera! retry in 5 seconds\n",
-								  profile->name);
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
+							  "{%s} Cannot Reconnect to Woomera! retry in 5 seconds\n", profile->name);
 			switch_sleep(WOOMERA_RECONNECT_TIME);
 		}
 
@@ -861,7 +868,8 @@ static int woomera_locate_socket(woomera_profile * profile, switch_socket_t **wo
 				woomera_printf(profile, *woomera_socket, "LISTEN%s", WOOMERA_RECORD_SEPERATOR);
 				if (woomera_message_parse(*woomera_socket,
 										  &wmsg, WOOMERA_HARD_TIMEOUT, profile, &profile->event_queue) < 0) {
-					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ALERT, "{%s} HELP! Woomera is broken!\n", profile->name);
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ALERT, "{%s} HELP! Woomera is broken!\n",
+									  profile->name);
 					globals.panic = 1;
 					woomera_profile_thread_running(&default_profile, 1, 0);
 					switch_sleep(WOOMERA_RECONNECT_TIME);
@@ -890,7 +898,8 @@ static int tech_create_read_socket(private_object * tech_pvt)
 		tech_pvt->port = globals.next_woomera_port = WOOMERA_MIN_PORT;
 	}
 
-	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "connect %s:%d\n", tech_pvt->profile->audio_ip, tech_pvt->port);
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "connect %s:%d\n", tech_pvt->profile->audio_ip,
+					  tech_pvt->port);
 	//tech_pvt->udp_socket = create_udp_socket(tech_pvt->profile->audio_ip, tech_pvt->port, &tech_pvt->udpread, 0);
 
 	switch_sockaddr_info_get(&tech_pvt->udpread, tech_pvt->profile->audio_ip, SWITCH_UNSPEC, tech_pvt->port, 0, pool);
@@ -938,7 +947,7 @@ static int tech_activate(private_object * tech_pvt)
 			if (woomera_message_parse(tech_pvt->command_channel,
 									  &wmsg, WOOMERA_HARD_TIMEOUT, tech_pvt->profile, &tech_pvt->event_queue) < 0) {
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ALERT, "{%s} HELP! Woomera is broken!\n",
-									  tech_pvt->profile->name);
+								  tech_pvt->profile->name);
 				switch_set_flag_locked(tech_pvt, TFLAG_ABORT);
 				globals.panic = 1;
 			}
@@ -998,7 +1007,7 @@ static void *woomera_channel_thread_run(switch_thread_t *thread, void *obj)
 				(tech_pvt->command_channel, &wmsg, WOOMERA_HARD_TIMEOUT, tech_pvt->profile,
 				 &tech_pvt->event_queue) < 0) {
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ALERT, "{%s} HELP! Woomera is broken!\n",
-									  tech_pvt->profile->name);
+								  tech_pvt->profile->name);
 				switch_set_flag_locked(tech_pvt, TFLAG_ABORT);
 				globals.panic = 1;
 				continue;
@@ -1014,7 +1023,7 @@ static void *woomera_channel_thread_run(switch_thread_t *thread, void *obj)
 				(tech_pvt->command_channel, &wmsg, WOOMERA_HARD_TIMEOUT, tech_pvt->profile,
 				 &tech_pvt->event_queue) < 0) {
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ALERT, "{%s} HELP! Woomera is broken!\n",
-									  tech_pvt->profile->name);
+								  tech_pvt->profile->name);
 				switch_set_flag_locked(tech_pvt, TFLAG_ABORT);
 				globals.panic = 1;
 				continue;
@@ -1095,7 +1104,8 @@ static void *woomera_channel_thread_run(switch_thread_t *thread, void *obj)
 				if ((tech_pvt->caller_profile = switch_caller_profile_new(switch_core_session_get_pool(session),
 																		  NULL,
 																		  tech_pvt->profile->dialplan,
-																		  cid_name, cid_num, ip, NULL, NULL, NULL, (char *)modname, NULL, exten)) != 0) {
+																		  cid_name, cid_num, ip, NULL, NULL, NULL,
+																		  (char *) modname, NULL, exten)) != 0) {
 					char name[128];
 					snprintf(name, sizeof(name), "Woomera/%s-%04x", tech_pvt->caller_profile->destination_number,
 							 rand() & 0xffff);
@@ -1115,7 +1125,7 @@ static void *woomera_channel_thread_run(switch_thread_t *thread, void *obj)
 				if (woomera_message_parse(tech_pvt->command_channel,
 										  &wmsg, WOOMERA_HARD_TIMEOUT, tech_pvt->profile, &tech_pvt->event_queue) < 0) {
 					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ALERT, "{%s} HELP! Woomera is broken!\n",
-										  tech_pvt->profile->name);
+									  tech_pvt->profile->name);
 					switch_set_flag_locked(tech_pvt, TFLAG_ABORT);
 					globals.panic = 1;
 					continue;
@@ -1135,7 +1145,7 @@ static void *woomera_channel_thread_run(switch_thread_t *thread, void *obj)
 					if ((ptr = strchr(ip, '/')) != 0) {
 						*ptr = '\0';
 						ptr++;
-						port = (switch_port_t)atoi(ptr);
+						port = (switch_port_t) atoi(ptr);
 					}
 					/* Move Channel's State Machine to RING */
 					switch_channel_answer(channel);
@@ -1150,8 +1160,8 @@ static void *woomera_channel_thread_run(switch_thread_t *thread, void *obj)
 						SWITCH_STATUS_SUCCESS) {
 						if (globals.debug) {
 							switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
-												  WOOMERA_DEBUG_PREFIX "{%s} Cannot resolve %s\n",
-												  tech_pvt->profile->name, ip);
+											  WOOMERA_DEBUG_PREFIX "{%s} Cannot resolve %s\n",
+											  tech_pvt->profile->name, ip);
 						}
 						switch_channel_hangup(channel, SWITCH_CAUSE_NETWORK_OUT_OF_ORDER);
 					}
@@ -1160,12 +1170,12 @@ static void *woomera_channel_thread_run(switch_thread_t *thread, void *obj)
 		}
 		if (globals.debug > 2) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, WOOMERA_DEBUG_PREFIX "CHECK {%s}(%d)\n",
-								  tech_pvt->profile->name, res);
+							  tech_pvt->profile->name, res);
 		}
 	}
 	if (globals.debug > 1) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, WOOMERA_DEBUG_PREFIX "Monitor thread for %s done.\n",
-							  tech_pvt->profile->name);
+						  tech_pvt->profile->name);
 	}
 
 	return NULL;
@@ -1204,7 +1214,7 @@ static void *woomera_thread_run(void *obj)
 				break;
 			}
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Woomera Thread Up {%s} %s/%d\n", profile->name,
-								  profile->woomera_host, profile->woomera_port);
+							  profile->woomera_host, profile->woomera_port);
 
 		}
 
@@ -1221,18 +1231,18 @@ static void *woomera_thread_run(void *obj)
 
 		if ((((res = woomera_dequeue_event(&profile->event_queue, &wmsg)) != 0) ||
 			 ((res = woomera_message_parse(profile->woomera_socket, &wmsg,
-										  /* if we are not stingy with threads we can block forever */
-										  0, profile, NULL))) != 0)) {
+										   /* if we are not stingy with threads we can block forever */
+										   0, profile, NULL))) != 0)) {
 			if (res < 0) {
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ALERT, "{%s} HELP! I lost my connection to woomera!\n",
-									  profile->name);
+								  profile->name);
 				woomera_socket_close(&profile->woomera_socket);
 
 				//global_set_flag(TFLAG_ABORT);
 				globals.panic = 1;
 				continue;
 
-		/* Can't get to the following code --Commented out for now.*/
+				/* Can't get to the following code --Commented out for now. */
 /*				if (profile->woomera_socket) 
 					if (switch_test_flag(profile, PFLAG_INBOUND)) {
 						woomera_printf(profile, profile->woomera_socket, "LISTEN%s", WOOMERA_RECORD_SEPERATOR);
@@ -1268,9 +1278,11 @@ static void *woomera_thread_run(void *obj)
 					switch_core_session_add_stream(session, NULL);
 
 					if ((tech_pvt =
-						 (struct private_object *) switch_core_session_alloc(session, sizeof(struct private_object))) != 0) {
+						 (struct private_object *) switch_core_session_alloc(session,
+																			 sizeof(struct private_object))) != 0) {
 						memset(tech_pvt, 0, sizeof(*tech_pvt));
-						switch_mutex_init(&tech_pvt->flag_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
+						switch_mutex_init(&tech_pvt->flag_mutex, SWITCH_MUTEX_NESTED,
+										  switch_core_session_get_pool(session));
 						tech_pvt->profile = &default_profile;
 						channel = switch_core_session_get_channel(session);
 						switch_core_session_set_private(session, tech_pvt);
@@ -1287,7 +1299,8 @@ static void *woomera_thread_run(void *obj)
 		}
 
 		if (globals.debug > 2) {
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Main Thread {%s} Select Return %d\n", profile->name, res);
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Main Thread {%s} Select Return %d\n",
+							  profile->name, res);
 		}
 
 		switch_yield(100);
@@ -1326,7 +1339,8 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_shutdown(void)
 	return SWITCH_STATUS_SUCCESS;
 }
 
-SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
+													   char *filename)
 {
 
 	struct woomera_profile *profile = &default_profile;
@@ -1346,7 +1360,7 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_mod
 	strncpy(profile->dialplan, "default", sizeof(profile->dialplan) - 1);
 	strncpy(profile->audio_ip, "127.0.0.1", sizeof(profile->audio_ip) - 1);
 	strncpy(profile->woomera_host, "127.0.0.1", sizeof(profile->woomera_host) - 1);
-	profile->woomera_port = (switch_port_t)42420;
+	profile->woomera_port = (switch_port_t) 42420;
 
 	if ((settings = switch_xml_child(cfg, "settings"))) {
 		for (param = switch_xml_child(settings, "param"); param; param = param->next) {
@@ -1371,7 +1385,7 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_mod
 			} else if (!strcmp(var, "host")) {
 				strncpy(profile->woomera_host, val, sizeof(profile->woomera_host) - 1);
 			} else if (!strcmp(var, "port")) {
-				profile->woomera_port = (switch_port_t)atoi(val);
+				profile->woomera_port = (switch_port_t) atoi(val);
 			} else if (!strcmp(var, "disabled")) {
 				if (atoi(val) > 0) {
 					switch_set_flag(profile, PFLAG_DISABLED);
diff --git a/src/mod/event_handlers/mod_cdr/basecdr.h b/src/mod/event_handlers/mod_cdr/basecdr.h
index bd93038fd0..153591750a 100644
--- a/src/mod/event_handlers/mod_cdr/basecdr.h
+++ b/src/mod/event_handlers/mod_cdr/basecdr.h
@@ -46,8 +46,7 @@
 #include 
 #include 
 
-struct switch_mod_cdr_newchannel_t 
-{
+struct switch_mod_cdr_newchannel_t {
 	switch_core_session_t *session;
 	switch_channel_t *channel;
 	//switch_channel_timetable_t *timetable;
@@ -57,7 +56,7 @@ struct switch_mod_cdr_newchannel_t
 	//bool originate;
 };
 
-enum switch_mod_cdr_sql_types_t { CDR_INTEGER,CDR_STRING,CDR_DECIMAL,CDR_DOUBLE,CDR_TINY };
+enum switch_mod_cdr_sql_types_t { CDR_INTEGER, CDR_STRING, CDR_DECIMAL, CDR_DOUBLE, CDR_TINY };
 
 #ifdef WIN32
 #define STDCALL __stdcall
@@ -65,54 +64,54 @@ enum switch_mod_cdr_sql_types_t { CDR_INTEGER,CDR_STRING,CDR_DECIMAL,CDR_DOUBLE,
 #define STDCALL
 #endif
 
-typedef switch_status_t (STDCALL *modcdr_time_convert_t)(switch_time_exp_t*,switch_time_t);
+typedef switch_status_t (STDCALL * modcdr_time_convert_t) (switch_time_exp_t *, switch_time_t);
 
 class BaseCDR {
-	public:
-		BaseCDR();
-		virtual ~BaseCDR();
-		BaseCDR(switch_mod_cdr_newchannel_t *newchannel);
-		virtual void connect(switch_xml_t& cfg, switch_xml_t& xml, switch_xml_t& settings, switch_xml_t& param) = 0;
-		virtual void disconnect() = 0;
-		virtual bool process_record() = 0;
-		virtual bool is_activated() = 0;
-		virtual void tempdump_record() = 0;
-		virtual void reread_tempdumped_records() = 0;
-		virtual std::string get_display_name() = 0; // Get the module name
-	protected:
-		void parse_channel_variables_xconfig(std::string& unparsed,std::list& chanvarslist,bool fixed);
-		void parse_channel_variables_xconfig(std::string& unparsed,std::list& chanvarslist,std::vector& chanvars_fixed_types);  // Typically used for SQL types
-		void process_channel_variables(const std::list& stringlist,const std::list& fixedlist,switch_channel_t *channel,bool repeat = 1); //This is used for supplemental chanvars
-		void process_channel_variables(const std::list& stringlist,switch_channel_t *channel); // This is used for fixed chanvars
-		void escape_string(std::string& src);
-		std::string escape_chararray(char* src);
-		switch_time_t callstartdate;
-		switch_time_t callanswerdate;
-		switch_time_t callenddate;
-		switch_time_t calltransferdate;
-		switch_call_cause_t hangupcause;
-		char *hangupcause_text;
-		char clid[80];
-		bool originated;  // Did they originate this call?
-		char dialplan[80];
-		char myuuid[37]; // 36 + 1 to hold \0
-		char destuuid[37];
-		char src[80];
-		char dst[80];
-		char srcchannel[80];
-		char dstchannel[80];
-		char ani[80];
-		char aniii[80];
-		char network_addr[40];
-		char lastapp[80];
-		char lastdata[255]; 
-		switch_time_t billusec; // Yes, you heard me, we're measuring in microseconds
-		int disposition; // Currently 0 = Busy/Unanswered, 1 = Answered
-		int amaflags;
-		switch_core_session_t *coresession;
-		std::list > chanvars_fixed;
-		std::map chanvars_supp;
-		bool errorstate; // True if there is an error writing the log
+  public:
+	BaseCDR();
+	virtual ~ BaseCDR();
+	BaseCDR(switch_mod_cdr_newchannel_t * newchannel);
+	virtual void connect(switch_xml_t & cfg, switch_xml_t & xml, switch_xml_t & settings, switch_xml_t & param) = 0;
+	virtual void disconnect() = 0;
+	virtual bool process_record() = 0;
+	virtual bool is_activated() = 0;
+	virtual void tempdump_record() = 0;
+	virtual void reread_tempdumped_records() = 0;
+	virtual std::string get_display_name() = 0;	// Get the module name
+  protected:
+	void parse_channel_variables_xconfig(std::string & unparsed, std::list < std::string > &chanvarslist, bool fixed);
+	void parse_channel_variables_xconfig(std::string & unparsed, std::list < std::string > &chanvarslist, std::vector < switch_mod_cdr_sql_types_t > &chanvars_fixed_types);	// Typically used for SQL types
+	void process_channel_variables(const std::list < std::string > &stringlist, const std::list < std::string > &fixedlist, switch_channel_t *channel, bool repeat = 1);	//This is used for supplemental chanvars
+	void process_channel_variables(const std::list < std::string > &stringlist, switch_channel_t *channel);	// This is used for fixed chanvars
+	void escape_string(std::string & src);
+	     std::string escape_chararray(char *src);
+	switch_time_t callstartdate;
+	switch_time_t callanswerdate;
+	switch_time_t callenddate;
+	switch_time_t calltransferdate;
+	switch_call_cause_t hangupcause;
+	char *hangupcause_text;
+	char clid[80];
+	bool originated;			// Did they originate this call?
+	char dialplan[80];
+	char myuuid[37];			// 36 + 1 to hold \0
+	char destuuid[37];
+	char src[80];
+	char dst[80];
+	char srcchannel[80];
+	char dstchannel[80];
+	char ani[80];
+	char aniii[80];
+	char network_addr[40];
+	char lastapp[80];
+	char lastdata[255];
+	switch_time_t billusec;		// Yes, you heard me, we're measuring in microseconds
+	int disposition;			// Currently 0 = Busy/Unanswered, 1 = Answered
+	int amaflags;
+	switch_core_session_t *coresession;
+	                      std::list < std::pair < std::string, std::string > >chanvars_fixed;
+	                      std::map < std::string, std::string > chanvars_supp;
+	bool errorstate;			// True if there is an error writing the log
 };
 
 #endif
diff --git a/src/mod/event_handlers/mod_cdr/baseregistry.h b/src/mod/event_handlers/mod_cdr/baseregistry.h
index f7c2021650..2e652beb82 100644
--- a/src/mod/event_handlers/mod_cdr/baseregistry.h
+++ b/src/mod/event_handlers/mod_cdr/baseregistry.h
@@ -42,34 +42,32 @@
 #ifdef __cplusplus
 #include 
 
-template BaseCDR* basecdr_factory(switch_mod_cdr_newchannel_t *newchannel)
+template < class T > BaseCDR * basecdr_factory(switch_mod_cdr_newchannel_t * newchannel)
 {
 	return new T(newchannel);
 }
 
-typedef BaseCDR* (*basecdr_creator)(switch_mod_cdr_newchannel_t *newchannel);
+typedef BaseCDR *(*basecdr_creator) (switch_mod_cdr_newchannel_t * newchannel);
 
-class BaseRegistry
-{
-	private:
-		std::vector m_bases; // Stores all modules
-		std::vector active_bases; // Stores only active modules
-	public:
-		typedef std::vector::iterator iterator;
-		static BaseRegistry& get();
-		void add(basecdr_creator);
-		void reset_active(); // Clears the active vector for reloading of configuration.
-		void add_active(iterator);
-		iterator begin();
-		iterator end();
-		iterator active_begin();
-		iterator active_end();
+class BaseRegistry {
+  private:
+	std::vector < basecdr_creator > m_bases;	// Stores all modules
+	std::vector < basecdr_creator > active_bases;	// Stores only active modules
+  public:
+	typedef std::vector < basecdr_creator >::iterator iterator;
+	static BaseRegistry & get();
+	void add(basecdr_creator);
+	void reset_active();		// Clears the active vector for reloading of configuration.
+	void add_active(iterator);
+	iterator begin();
+	iterator end();
+	iterator active_begin();
+	iterator active_end();
 };
 
-class BaseRegistration
-{
-	public:
-		BaseRegistration(basecdr_creator);
+class BaseRegistration {
+  public:
+	BaseRegistration(basecdr_creator);
 };
 
 #define AUTO_REGISTER_BASECDR(basecdr) BaseRegistration _basecdr_registration_ ## basecdr(&basecdr_factory);
diff --git a/src/mod/event_handlers/mod_cdr/cdrcontainer.h b/src/mod/event_handlers/mod_cdr/cdrcontainer.h
index 5e2836522f..7e6c7d8e9c 100644
--- a/src/mod/event_handlers/mod_cdr/cdrcontainer.h
+++ b/src/mod/event_handlers/mod_cdr/cdrcontainer.h
@@ -51,11 +51,11 @@ CDRContainer::process_records() will iterate thru the queue and commit the recor
 extern "C" {
 #endif
 
-class CDRContainer {
-	public:
+	class CDRContainer {
+	  public:
 		CDRContainer();
 		CDRContainer(switch_memory_pool_t *module_pool);
-		~CDRContainer();
+		                    ~CDRContainer();
 		void add_cdr(switch_core_session_t *session);
 		void process_records();
 #ifdef SWITCH_QUEUE_ENHANCED
@@ -65,21 +65,19 @@ class CDRContainer {
 #endif
 		void active(switch_stream_handle_t *stream);
 		void available(switch_stream_handle_t *stream);
-	protected:
-	private:
-		switch_xml_t cfg, xml, settings, param;
+	  protected:
+	  private:
+		                       switch_xml_t cfg, xml, settings, param;
 		switch_queue_t *cdrqueue;
-		std::string tempfilepath;
+		               std::string tempfilepath;
 		char configfile[13];
 		bool queue_paused;
-};
+	};
 
 #ifdef __cplusplus
 }
 #endif
-
 #endif
-
 /* For Emacs:
  * Local Variables:
  * mode:c++
diff --git a/src/mod/event_handlers/mod_cdr/csvcdr.h b/src/mod/event_handlers/mod_cdr/csvcdr.h
index 7dca598b21..93281665dc 100644
--- a/src/mod/event_handlers/mod_cdr/csvcdr.h
+++ b/src/mod/event_handlers/mod_cdr/csvcdr.h
@@ -44,38 +44,38 @@
 #ifndef CSVCDR
 #define CSVCDR
 
-class CsvCDR : public BaseCDR {
-	public:
-		CsvCDR();
-		CsvCDR(switch_mod_cdr_newchannel_t *newchannel);
-		//CsvCDR(const CsvCDR& copyFrom);
-		virtual ~CsvCDR();
-		virtual bool process_record();
-		virtual void connect(switch_xml_t& cfg, switch_xml_t& xml, switch_xml_t& settings, switch_xml_t& param); // connect and disconnect need to be static because we're persisting connections until shutdown
-		virtual void disconnect();
-		virtual bool is_activated();
-		virtual void tempdump_record();
-		virtual void reread_tempdumped_records();
-		virtual std::string get_display_name();
+class CsvCDR:public BaseCDR {
+  public:
+	CsvCDR();
+	CsvCDR(switch_mod_cdr_newchannel_t * newchannel);
+	//CsvCDR(const CsvCDR& copyFrom);
+	virtual ~ CsvCDR();
+	virtual bool process_record();
+	virtual void connect(switch_xml_t & cfg, switch_xml_t & xml, switch_xml_t & settings, switch_xml_t & param);	// connect and disconnect need to be static because we're persisting connections until shutdown
+	virtual void disconnect();
+	virtual bool is_activated();
+	virtual void tempdump_record();
+	virtual void reread_tempdumped_records();
+	virtual std::string get_display_name();
 
-	private:
-		static bool activated; // Is this module activated?
-		static bool connectionstate; // What is the status of the connection?
-		static bool logchanvars;
-		static modcdr_time_convert_t convert_time;
-		static bool repeat_fixed_in_supp; // Repeat the fixed chanvars in the supplemental?
-		static std::string outputfile_path; // The directory we'll dump these into
-		static std::list chanvars_fixed_list; // Normally this would be used, but not in this class
-		static std::list chanvars_supp_list; // This will hold the list for all chanvars here
-		static std::string display_name;
-		char formattedcallstartdate[100];
-		char formattedcallanswerdate[100];
-		char formattedcalltransferdate[100];
-		char formattedcallenddate[100];
-		static std::ofstream outputfile;
-		static std::ofstream::pos_type filesize_limit;
-		void check_file_size_and_open(); // Checks the size of the file, and if it's greater than size allowed, rotates it.
-		void open_file();
+  private:
+	static bool activated;		// Is this module activated?
+	static bool connectionstate;	// What is the status of the connection?
+	static bool logchanvars;
+	static modcdr_time_convert_t convert_time;
+	static bool repeat_fixed_in_supp;	// Repeat the fixed chanvars in the supplemental?
+	static std::string outputfile_path;	// The directory we'll dump these into
+	static std::list < std::string > chanvars_fixed_list;	// Normally this would be used, but not in this class
+	static std::list < std::string > chanvars_supp_list;	// This will hold the list for all chanvars here
+	static std::string display_name;
+	char formattedcallstartdate[100];
+	char formattedcallanswerdate[100];
+	char formattedcalltransferdate[100];
+	char formattedcallenddate[100];
+	static std::ofstream outputfile;
+	static std::ofstream::pos_type filesize_limit;
+	void check_file_size_and_open();	// Checks the size of the file, and if it's greater than size allowed, rotates it.
+	void open_file();
 };
 
 #endif
diff --git a/src/mod/event_handlers/mod_cdr/curlcdr.h b/src/mod/event_handlers/mod_cdr/curlcdr.h
index f924178bb5..03b6d3a05b 100644
--- a/src/mod/event_handlers/mod_cdr/curlcdr.h
+++ b/src/mod/event_handlers/mod_cdr/curlcdr.h
@@ -50,37 +50,37 @@
 #ifndef CURLCDR
 #define CURLCDR
 
-class CurlCDR : public BaseCDR {
-	public:
-		CurlCDR();
-		CurlCDR(switch_mod_cdr_newchannel_t *newchannel);
-		//CurlCDR(const CurlCDR& copyFrom);
-		virtual ~CurlCDR();
-		virtual bool process_record();
-		virtual void connect(switch_xml_t& cfg, switch_xml_t& xml, switch_xml_t& settings, switch_xml_t& param); // connect and disconnect need to be static because we're persisting connections until shutdown
-		virtual void disconnect();
-		virtual bool is_activated();
-		virtual void tempdump_record();
-		virtual void reread_tempdumped_records();
-		virtual std::string get_display_name();
-    virtual std::string itos(int i);
-    virtual std::string lltos(long long ll);
+class CurlCDR:public BaseCDR {
+  public:
+	CurlCDR();
+	CurlCDR(switch_mod_cdr_newchannel_t * newchannel);
+	//CurlCDR(const CurlCDR& copyFrom);
+	virtual ~ CurlCDR();
+	virtual bool process_record();
+	virtual void connect(switch_xml_t & cfg, switch_xml_t & xml, switch_xml_t & settings, switch_xml_t & param);	// connect and disconnect need to be static because we're persisting connections until shutdown
+	virtual void disconnect();
+	virtual bool is_activated();
+	virtual void tempdump_record();
+	virtual void reread_tempdumped_records();
+	virtual std::string get_display_name();
+	virtual std::string itos(int i);
+	virtual std::string lltos(long long ll);
 
-	private:
-		static bool activated; // Is this module activated?
-		static bool connectionstate; // What is the status of the connection?
-		static bool logchanvars;
-		static modcdr_time_convert_t convert_time;
-		static const char *gateway_url; // The URL to send data to
-		static const char *gateway_credentials; // The credentials for http auth
-		static std::list chanvars_fixed_list; // Normally this would be used, but not in this class
-		static std::list chanvars_supp_list; // This will hold the list for all chanvars here
-		static std::string display_name;
-        static std::string postdata;
-		char formattedcallstartdate[100];
-		char formattedcallanswerdate[100];
-		char formattedcalltransferdate[100];
-		char formattedcallenddate[100];
+  private:
+	static bool activated;		// Is this module activated?
+	static bool connectionstate;	// What is the status of the connection?
+	static bool logchanvars;
+	static modcdr_time_convert_t convert_time;
+	static const char *gateway_url;	// The URL to send data to
+	static const char *gateway_credentials;	// The credentials for http auth
+	static std::list < std::string > chanvars_fixed_list;	// Normally this would be used, but not in this class
+	static std::list < std::string > chanvars_supp_list;	// This will hold the list for all chanvars here
+	static std::string display_name;
+	static std::string postdata;
+	char formattedcallstartdate[100];
+	char formattedcallanswerdate[100];
+	char formattedcalltransferdate[100];
+	char formattedcallenddate[100];
 };
 
 #endif
diff --git a/src/mod/event_handlers/mod_cdr/mysqlcdr.h b/src/mod/event_handlers/mod_cdr/mysqlcdr.h
index 13ba30d52e..6398578c0b 100644
--- a/src/mod/event_handlers/mod_cdr/mysqlcdr.h
+++ b/src/mod/event_handlers/mod_cdr/mysqlcdr.h
@@ -41,66 +41,66 @@
 #ifndef MYSQLCDR
 #define MYSQLCDR
 
-class MysqlCDR : public BaseCDR {
-	public:
-		MysqlCDR();
-		MysqlCDR(switch_mod_cdr_newchannel_t *newchannel);
-		//MysqlCDR(const MysqlCDR& copyFrom);
-		virtual ~MysqlCDR();
-		virtual bool process_record();
-		virtual void connect(switch_xml_t& cfg, switch_xml_t& xml, switch_xml_t& settings, switch_xml_t& param);
-		virtual void disconnect();
-		virtual bool is_activated();
-		virtual void tempdump_record();
-		virtual void reread_tempdumped_records();
-		virtual std::string get_display_name();
+class MysqlCDR:public BaseCDR {
+  public:
+	MysqlCDR();
+	MysqlCDR(switch_mod_cdr_newchannel_t * newchannel);
+	//MysqlCDR(const MysqlCDR& copyFrom);
+	virtual ~ MysqlCDR();
+	virtual bool process_record();
+	virtual void connect(switch_xml_t & cfg, switch_xml_t & xml, switch_xml_t & settings, switch_xml_t & param);
+	virtual void disconnect();
+	virtual bool is_activated();
+	virtual void tempdump_record();
+	virtual void reread_tempdumped_records();
+	virtual std::string get_display_name();
 
-	private:
-		static bool activated;
-		static char sql_query[1024];
-		static std::string tmp_sql_query; // Object must exist to bind the statement, this used for generating the sql
-		static char sql_query_chanvars[100];
-		static MYSQL *conn;
-		static MYSQL_STMT *stmt;
-		static MYSQL_STMT *stmt_chanvars;
-		static bool connectionstate;
-		static bool logchanvars;
-		static std::list chanvars_fixed_list;
-		static std::vector chanvars_fixed_types;
-		static std::list chanvars_supp_list; // The supplemental list
-		static bool repeat_fixed_in_supp;
-		static char hostname[255];
-		static char username[255];
-		static char dbname[255];
-		static char password[255];
-		static modcdr_time_convert_t convert_time;
-		static std::string display_name;
-		//static fstream tmpfile;
-		std::vector bindme;
-		//MYSQL_BIND *bindme;
-		MYSQL_TIME my_callstartdate;
-		MYSQL_TIME my_callanswerdate;
-		MYSQL_TIME my_calltransferdate;
-		MYSQL_TIME my_callenddate;
-		// Why all these long unsigned int's?  MySQL's prep statement API expects these to actually exist and not just be params passed to the function calls.  The are to measure the length of actual data in the char* arrays.
-		long unsigned int clid_length;
-		long unsigned int dialplan_length;
-		long unsigned int myuuid_length;
-		long unsigned int destuuid_length;
-		long unsigned int src_length;
-		long unsigned int dst_length;
-		long unsigned int srcchannel_length;
-		long unsigned int dstchannel_length;
-		long unsigned int ani_length;
-		long unsigned int aniii_length;
-		long unsigned int lastapp_length;
-		long unsigned int lastdata_length;
-		long unsigned int network_addr_length;
-		// Now a couple internal methods
-		template  void add_parameter(T& param, enum_field_types type, bool *is_null=0);
-		void add_string_parameter(char* param, long unsigned int& param_length, enum_field_types type, bool* is_null=0);
-		void set_mysql_time(switch_time_exp_t& param, MYSQL_TIME& destination);
-		void connect_to_database();
+  private:
+	static bool activated;
+	static char sql_query[1024];
+	static std::string tmp_sql_query;	// Object must exist to bind the statement, this used for generating the sql
+	static char sql_query_chanvars[100];
+	static MYSQL *conn;
+	static MYSQL_STMT *stmt;
+	static MYSQL_STMT *stmt_chanvars;
+	static bool connectionstate;
+	static bool logchanvars;
+	static std::list < std::string > chanvars_fixed_list;
+	static std::vector < switch_mod_cdr_sql_types_t > chanvars_fixed_types;
+	static std::list < std::string > chanvars_supp_list;	// The supplemental list
+	static bool repeat_fixed_in_supp;
+	static char hostname[255];
+	static char username[255];
+	static char dbname[255];
+	static char password[255];
+	static modcdr_time_convert_t convert_time;
+	static std::string display_name;
+	//static fstream tmpfile;
+	       std::vector < MYSQL_BIND > bindme;
+	//MYSQL_BIND *bindme;
+	MYSQL_TIME my_callstartdate;
+	MYSQL_TIME my_callanswerdate;
+	MYSQL_TIME my_calltransferdate;
+	MYSQL_TIME my_callenddate;
+	// Why all these long unsigned int's?  MySQL's prep statement API expects these to actually exist and not just be params passed to the function calls.  The are to measure the length of actual data in the char* arrays.
+	long unsigned int clid_length;
+	long unsigned int dialplan_length;
+	long unsigned int myuuid_length;
+	long unsigned int destuuid_length;
+	long unsigned int src_length;
+	long unsigned int dst_length;
+	long unsigned int srcchannel_length;
+	long unsigned int dstchannel_length;
+	long unsigned int ani_length;
+	long unsigned int aniii_length;
+	long unsigned int lastapp_length;
+	long unsigned int lastdata_length;
+	long unsigned int network_addr_length;
+	// Now a couple internal methods
+	    template < typename T > void add_parameter(T & param, enum_field_types type, bool * is_null = 0);
+	void add_string_parameter(char *param, long unsigned int ¶m_length, enum_field_types type, bool * is_null = 0);
+	void set_mysql_time(switch_time_exp_t ¶m, MYSQL_TIME & destination);
+	void connect_to_database();
 };
 
 #endif
diff --git a/src/mod/event_handlers/mod_cdr/odbccdr.h b/src/mod/event_handlers/mod_cdr/odbccdr.h
index c94c5f2c82..867a782c5c 100644
--- a/src/mod/event_handlers/mod_cdr/odbccdr.h
+++ b/src/mod/event_handlers/mod_cdr/odbccdr.h
@@ -52,53 +52,53 @@
 #ifndef ODBCCDR
 #define ODBCCDR
 
-class OdbcCDR : public BaseCDR {
-	public:
-		OdbcCDR();
-		OdbcCDR(switch_mod_cdr_newchannel_t *newchannel);
-		//OdbcCDR(const MysqlCDR& copyFrom);
-		virtual ~OdbcCDR();
-		virtual bool process_record();
-		virtual void connect(switch_xml_t& cfg, switch_xml_t& xml, switch_xml_t& settings, switch_xml_t& param);
-		virtual void disconnect();
-		virtual bool is_activated();
-		virtual void tempdump_record();
-		virtual void reread_tempdumped_records();
-		virtual std::string get_display_name();
+class OdbcCDR:public BaseCDR {
+  public:
+	OdbcCDR();
+	OdbcCDR(switch_mod_cdr_newchannel_t * newchannel);
+	//OdbcCDR(const MysqlCDR& copyFrom);
+	virtual ~ OdbcCDR();
+	virtual bool process_record();
+	virtual void connect(switch_xml_t & cfg, switch_xml_t & xml, switch_xml_t & settings, switch_xml_t & param);
+	virtual void disconnect();
+	virtual bool is_activated();
+	virtual void tempdump_record();
+	virtual void reread_tempdumped_records();
+	virtual std::string get_display_name();
 
-	private:
-		static bool activated;
-		static char sql_query[1024];
-		static modcdr_time_convert_t convert_time;
-		static std::string display_name;
-		static std::string tmp_sql_query; // Object must exist to bind the statement, this used for generating the sql
-		static char sql_query_chanvars[355];
-		static char sql_query_ping[10];
-		static bool connectionstate;
-		static bool logchanvars;
-		static SQLHENV ODBC_env;     /* global ODBC Environment */
-		static SQLHDBC ODBC_con;     /* global ODBC Connection Handle */
-		static SQLHSTMT ODBC_stmt;
-		static SQLHSTMT ODBC_stmt_chanvars;
-		static SQLHSTMT ODBC_stmt_ping;
-		static std::list chanvars_fixed_list;
-		static std::vector chanvars_fixed_types;
-		static std::list chanvars_supp_list; // The supplemental list
-		static bool repeat_fixed_in_supp;
-		static char dsn[255];
-		static char hostname[255];
-		static char username[255];
-		static char dbname[255];
-		static char password[255];
-		static char tablename[255];
-		static char tablename_chanvars[255];
-		//static fstream tmpfile;
-		char odbc_callstartdate[128];
-		char odbc_callanswerdate[128];
-		char odbc_calltransferdate[128];
-		char odbc_callenddate[128];
-		void disconnect_stage_1();
-		void connect_to_database();
+  private:
+	static bool activated;
+	static char sql_query[1024];
+	static modcdr_time_convert_t convert_time;
+	static std::string display_name;
+	static std::string tmp_sql_query;	// Object must exist to bind the statement, this used for generating the sql
+	static char sql_query_chanvars[355];
+	static char sql_query_ping[10];
+	static bool connectionstate;
+	static bool logchanvars;
+	static SQLHENV ODBC_env;	/* global ODBC Environment */
+	static SQLHDBC ODBC_con;	/* global ODBC Connection Handle */
+	static SQLHSTMT ODBC_stmt;
+	static SQLHSTMT ODBC_stmt_chanvars;
+	static SQLHSTMT ODBC_stmt_ping;
+	static std::list < std::string > chanvars_fixed_list;
+	static std::vector < switch_mod_cdr_sql_types_t > chanvars_fixed_types;
+	static std::list < std::string > chanvars_supp_list;	// The supplemental list
+	static bool repeat_fixed_in_supp;
+	static char dsn[255];
+	static char hostname[255];
+	static char username[255];
+	static char dbname[255];
+	static char password[255];
+	static char tablename[255];
+	static char tablename_chanvars[255];
+	//static fstream tmpfile;
+	char odbc_callstartdate[128];
+	char odbc_callanswerdate[128];
+	char odbc_calltransferdate[128];
+	char odbc_callenddate[128];
+	void disconnect_stage_1();
+	void connect_to_database();
 };
 
 #endif
diff --git a/src/mod/event_handlers/mod_cdr/pddcdr.h b/src/mod/event_handlers/mod_cdr/pddcdr.h
index 705b73c335..782be128b2 100644
--- a/src/mod/event_handlers/mod_cdr/pddcdr.h
+++ b/src/mod/event_handlers/mod_cdr/pddcdr.h
@@ -43,33 +43,33 @@
 #ifndef PDDCDR
 #define PDDMCDR
 
-class PddCDR : public BaseCDR {
-	public:
-		PddCDR();
-		PddCDR(switch_mod_cdr_newchannel_t *newchannel);
-		virtual ~PddCDR();
-		virtual bool process_record();
-		virtual void connect(switch_xml_t& cfg, switch_xml_t& xml, switch_xml_t& settings, switch_xml_t& param); // connect and disconnect need to be static because we're persisting connections until shutdown
-		virtual void disconnect();
-		virtual bool is_activated();
-		virtual void tempdump_record();
-		virtual void reread_tempdumped_records();
-		virtual std::string get_display_name();
-	private:
-		static bool activated; // Is this module activated?
-		static bool connectionstate; // What is the status of the connection?
-		static bool logchanvars;
-		static modcdr_time_convert_t convert_time;
-		static std::string outputfile_path; // The directory we'll dump these into
-		static std::list chanvars_fixed_list; // Normally this would be used, but not in this class
-		static std::list chanvars_supp_list; // This will hold the list for all chanvars here
-		static std::string display_name;
-		char formattedcallstartdate[100];
-		char formattedcallanswerdate[100];
-		char formattedcalltransferdate[100];
-		char formattedcallenddate[100];
-		std::string outputfile_name;
-		std::ofstream outputfile;
+class PddCDR:public BaseCDR {
+  public:
+	PddCDR();
+	PddCDR(switch_mod_cdr_newchannel_t * newchannel);
+	virtual ~ PddCDR();
+	virtual bool process_record();
+	virtual void connect(switch_xml_t & cfg, switch_xml_t & xml, switch_xml_t & settings, switch_xml_t & param);	// connect and disconnect need to be static because we're persisting connections until shutdown
+	virtual void disconnect();
+	virtual bool is_activated();
+	virtual void tempdump_record();
+	virtual void reread_tempdumped_records();
+	virtual std::string get_display_name();
+  private:
+	static bool activated;		// Is this module activated?
+	static bool connectionstate;	// What is the status of the connection?
+	static bool logchanvars;
+	static modcdr_time_convert_t convert_time;
+	static std::string outputfile_path;	// The directory we'll dump these into
+	static std::list < std::string > chanvars_fixed_list;	// Normally this would be used, but not in this class
+	static std::list < std::string > chanvars_supp_list;	// This will hold the list for all chanvars here
+	static std::string display_name;
+	char formattedcallstartdate[100];
+	char formattedcallanswerdate[100];
+	char formattedcalltransferdate[100];
+	char formattedcallenddate[100];
+	     std::string outputfile_name;
+	     std::ofstream outputfile;
 };
 
 #endif
diff --git a/src/mod/event_handlers/mod_cdr/sqlitecdr.h b/src/mod/event_handlers/mod_cdr/sqlitecdr.h
index 298213325e..ae266ac7d4 100644
--- a/src/mod/event_handlers/mod_cdr/sqlitecdr.h
+++ b/src/mod/event_handlers/mod_cdr/sqlitecdr.h
@@ -39,43 +39,43 @@
 #ifndef SQLITECDR
 #define SQLITECDR
 
-class SqliteCDR : public BaseCDR {
-	public:
-		SqliteCDR();
-		SqliteCDR(switch_mod_cdr_newchannel_t *newchannel);
-		//SqliteCDR(const SqliteCDR& copyFrom);
-		virtual ~SqliteCDR();
-		virtual bool process_record();
-		virtual void connect(switch_xml_t& cfg, switch_xml_t& xml, switch_xml_t& settings, switch_xml_t& param);
-		virtual void disconnect();
-		virtual bool is_activated();
-		virtual void tempdump_record();
-		virtual void reread_tempdumped_records();
-		virtual std::string get_display_name();
+class SqliteCDR:public BaseCDR {
+  public:
+	SqliteCDR();
+	SqliteCDR(switch_mod_cdr_newchannel_t * newchannel);
+	//SqliteCDR(const SqliteCDR& copyFrom);
+	virtual ~ SqliteCDR();
+	virtual bool process_record();
+	virtual void connect(switch_xml_t & cfg, switch_xml_t & xml, switch_xml_t & settings, switch_xml_t & param);
+	virtual void disconnect();
+	virtual bool is_activated();
+	virtual void tempdump_record();
+	virtual void reread_tempdumped_records();
+	virtual std::string get_display_name();
 
-	private:
-		static bool activated;
-		static char sql_query[1024];
-		static std::string tmp_sql_query; // Object must exist to bind the statement, this used for generating the sql
-		static char sql_query_chanvars[100];
-		static std::string db_filename;
-		static bool use_utc_time;
-		switch_time_t sqlite_callstartdate;
-		switch_time_t sqlite_callanswerdate;
-		switch_time_t sqlite_calltransferdate;
-		switch_time_t sqlite_callenddate;
-		static switch_core_db_t *db;
-		static switch_core_db_stmt_t *stmt;
-		static switch_core_db_stmt_t *stmt_chanvars;
-		static switch_core_db_stmt_t *stmt_begin;
-		static switch_core_db_stmt_t *stmt_commit;
-		static bool connectionstate;
-		static bool logchanvars;
-		static std::list chanvars_fixed_list;
-		static std::vector chanvars_fixed_types;
-		static std::list chanvars_supp_list; // The supplemental list
-		static bool repeat_fixed_in_supp;
-		static std::string display_name;
+  private:
+	static bool activated;
+	static char sql_query[1024];
+	static std::string tmp_sql_query;	// Object must exist to bind the statement, this used for generating the sql
+	static char sql_query_chanvars[100];
+	static std::string db_filename;
+	static bool use_utc_time;
+	switch_time_t sqlite_callstartdate;
+	switch_time_t sqlite_callanswerdate;
+	switch_time_t sqlite_calltransferdate;
+	switch_time_t sqlite_callenddate;
+	static switch_core_db_t *db;
+	static switch_core_db_stmt_t *stmt;
+	static switch_core_db_stmt_t *stmt_chanvars;
+	static switch_core_db_stmt_t *stmt_begin;
+	static switch_core_db_stmt_t *stmt_commit;
+	static bool connectionstate;
+	static bool logchanvars;
+	static std::list < std::string > chanvars_fixed_list;
+	static std::vector < switch_mod_cdr_sql_types_t > chanvars_fixed_types;
+	static std::list < std::string > chanvars_supp_list;	// The supplemental list
+	static bool repeat_fixed_in_supp;
+	static std::string display_name;
 };
 
 #endif
diff --git a/src/mod/event_handlers/mod_cdr/xmlcdr.h b/src/mod/event_handlers/mod_cdr/xmlcdr.h
index 79d696ff82..ef5f3900a7 100644
--- a/src/mod/event_handlers/mod_cdr/xmlcdr.h
+++ b/src/mod/event_handlers/mod_cdr/xmlcdr.h
@@ -43,34 +43,34 @@
 #ifndef XMLCDR
 #define XMLCDR
 
-class XmlCDR : public BaseCDR {
-	public:
-		XmlCDR();
-		XmlCDR(switch_mod_cdr_newchannel_t *newchannel);
-		virtual ~XmlCDR();
-		virtual bool process_record();
-		virtual void connect(switch_xml_t& cfg, switch_xml_t& xml, switch_xml_t& settings, switch_xml_t& param); // connect and disconnect need to be static because we're persisting connections until shutdown
-		virtual void disconnect();
-		virtual bool is_activated();
-		virtual void tempdump_record();
-		virtual void reread_tempdumped_records();
-		virtual std::string get_display_name();
+class XmlCDR:public BaseCDR {
+  public:
+	XmlCDR();
+	XmlCDR(switch_mod_cdr_newchannel_t * newchannel);
+	virtual ~ XmlCDR();
+	virtual bool process_record();
+	virtual void connect(switch_xml_t & cfg, switch_xml_t & xml, switch_xml_t & settings, switch_xml_t & param);	// connect and disconnect need to be static because we're persisting connections until shutdown
+	virtual void disconnect();
+	virtual bool is_activated();
+	virtual void tempdump_record();
+	virtual void reread_tempdumped_records();
+	virtual std::string get_display_name();
 
-	private:
-		static bool activated; // Is this module activated?
-		static bool connectionstate; // What is the status of the connection?
-		static bool logchanvars;
-		static modcdr_time_convert_t convert_time;
-		static std::string outputfile_path; // The directory we'll dump these into
-		static std::list chanvars_fixed_list; // Normally this would be used, but not in this class
-		static std::list chanvars_supp_list; // This will hold the list for all chanvars here
-		static std::string display_name;
-		char formattedcallstartdate[100];
-		char formattedcallanswerdate[100];
-		char formattedcalltransferdate[100];
-		char formattedcallenddate[100];
-		std::string outputfile_name;
-		std::ofstream outputfile;
+  private:
+	static bool activated;		// Is this module activated?
+	static bool connectionstate;	// What is the status of the connection?
+	static bool logchanvars;
+	static modcdr_time_convert_t convert_time;
+	static std::string outputfile_path;	// The directory we'll dump these into
+	static std::list < std::string > chanvars_fixed_list;	// Normally this would be used, but not in this class
+	static std::list < std::string > chanvars_supp_list;	// This will hold the list for all chanvars here
+	static std::string display_name;
+	char formattedcallstartdate[100];
+	char formattedcallanswerdate[100];
+	char formattedcalltransferdate[100];
+	char formattedcallenddate[100];
+	     std::string outputfile_name;
+	     std::ofstream outputfile;
 };
 
 #endif
diff --git a/src/mod/event_handlers/mod_event_multicast/mod_event_multicast.c b/src/mod/event_handlers/mod_event_multicast/mod_event_multicast.c
index cfc62fe08f..b390873dd6 100644
--- a/src/mod/event_handlers/mod_event_multicast/mod_event_multicast.c
+++ b/src/mod/event_handlers/mod_event_multicast/mod_event_multicast.c
@@ -46,17 +46,13 @@ static struct {
 	switch_sockaddr_t *addr;
 	switch_socket_t *udp_socket;
 	switch_hash_t *event_hash;
-	uint8_t event_list[SWITCH_EVENT_ALL+1];
+	uint8_t event_list[SWITCH_EVENT_ALL + 1];
 	int running;
 } globals;
 
 SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_address, globals.address)
-SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_bindings, globals.bindings)
-
-
+	SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_bindings, globals.bindings)
 #define MULTICAST_EVENT "multicast::event"
-
-
 	 static switch_status_t load_config(void)
 {
 	switch_status_t status = SWITCH_STATUS_SUCCESS;
@@ -80,7 +76,7 @@ SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_bindings, globals.bindings)
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass!");
 		return SWITCH_STATUS_GENERR;
 	}
-	
+
 	if ((settings = switch_xml_child(cfg, "settings"))) {
 		for (param = switch_xml_child(settings, "param"); param; param = param->next) {
 			char *var = (char *) switch_xml_attr_soft(param, "name");
@@ -91,7 +87,7 @@ SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_bindings, globals.bindings)
 			} else if (!strcasecmp(var, "bindings")) {
 				set_global_bindings(val);
 			} else if (!strcasecmp(var, "port")) {
-				globals.port = (switch_port_t)atoi(val);
+				globals.port = (switch_port_t) atoi(val);
 			}
 		}
 	}
@@ -100,13 +96,13 @@ SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_bindings, globals.bindings)
 
 
 	if (globals.bindings) {
-		for(cur = globals.bindings; cur; count++) {
+		for (cur = globals.bindings; cur; count++) {
 			switch_event_types_t type;
 
 			if ((next = strchr(cur, ' '))) {
 				*next++ = '\0';
 			}
-				
+
 			if (custom) {
 				switch_core_hash_insert_dup(globals.event_hash, cur, MARKER);
 			} else if (switch_name_event(cur, &type) == SWITCH_STATUS_SUCCESS) {
@@ -143,14 +139,14 @@ static void event_handler(switch_event_t *event)
 
 
 	if (event->subclass && !strcmp(event->subclass->name, MULTICAST_EVENT)) {
-		/* ignore our own events to avoid ping pong*/
+		/* ignore our own events to avoid ping pong */
 		return;
 	}
 
-	if (globals.event_list[(uint8_t)SWITCH_EVENT_ALL]) {
+	if (globals.event_list[(uint8_t) SWITCH_EVENT_ALL]) {
 		send = 1;
-	} else if ((globals.event_list[(uint8_t)event->event_id])) {
-		if (event->event_id != SWITCH_EVENT_CUSTOM || 
+	} else if ((globals.event_list[(uint8_t) event->event_id])) {
+		if (event->event_id != SWITCH_EVENT_CUSTOM ||
 			(event->subclass && switch_core_hash_find(globals.event_hash, event->subclass->name))) {
 			send = 1;
 		}
@@ -158,7 +154,7 @@ static void event_handler(switch_event_t *event)
 
 	if (send) {
 		char *packet;
-		
+
 		switch (event->event_id) {
 		case SWITCH_EVENT_LOG:
 			return;
@@ -188,7 +184,8 @@ static switch_loadable_module_interface_t event_test_module_interface = {
 };
 
 
-SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
+													   char *filename)
 {
 
 	memset(&globals, 0, sizeof(globals));
@@ -199,13 +196,14 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_mod
 	}
 
 	switch_core_hash_init(&globals.event_hash, module_pool);
-	
+
 	if (load_config() != SWITCH_STATUS_SUCCESS) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot Configure\n");
 		return SWITCH_STATUS_TERM;
 	}
 
-	if (switch_sockaddr_info_get(&globals.addr, globals.address, SWITCH_UNSPEC, globals.port, 0, module_pool) != SWITCH_STATUS_SUCCESS) {
+	if (switch_sockaddr_info_get(&globals.addr, globals.address, SWITCH_UNSPEC, globals.port, 0, module_pool) !=
+		SWITCH_STATUS_SUCCESS) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot find address\n");
 		return SWITCH_STATUS_TERM;
 	}
@@ -214,7 +212,7 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_mod
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Socket Error\n");
 		return SWITCH_STATUS_TERM;
 	}
-	
+
 	if (switch_socket_opt_set(globals.udp_socket, SWITCH_SO_REUSEADDR, 1) != SWITCH_STATUS_SUCCESS) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Socket Option Error\n");
 		switch_socket_close(globals.udp_socket);
@@ -224,7 +222,7 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_mod
 	if (switch_mcast_join(globals.udp_socket, globals.addr, NULL, NULL) != SWITCH_STATUS_SUCCESS) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Multicast Error\n");
 		switch_socket_close(globals.udp_socket);
-        return SWITCH_STATUS_TERM;
+		return SWITCH_STATUS_TERM;
 	}
 
 	if (switch_socket_bind(globals.udp_socket, globals.addr) != SWITCH_STATUS_SUCCESS) {
@@ -238,7 +236,7 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_mod
 	/* connect my internal structure to the blank pointer passed to me */
 	*module_interface = &event_test_module_interface;
 
-	
+
 	if (switch_event_bind((char *) modname, SWITCH_EVENT_ALL, SWITCH_EVENT_SUBCLASS_ANY, event_handler, NULL) !=
 		SWITCH_STATUS_SUCCESS) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
@@ -258,7 +256,7 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_shutdown(void)
 
 	switch_socket_shutdown(globals.udp_socket, SWITCH_SHUTDOWN_READWRITE);
 	globals.running = -1;
-	while(x < 100000 && globals.running) {
+	while (x < 100000 && globals.running) {
 		x++;
 		switch_yield(1000);
 	}
@@ -269,16 +267,16 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_shutdown(void)
 SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void)
 {
 	switch_event_t *local_event;
-	char buf[65536] = {0};
+	char buf[65536] = { 0 };
 	switch_sockaddr_t *addr;
 
 	switch_sockaddr_info_get(&addr, NULL, SWITCH_UNSPEC, 0, 0, module_pool);
 	globals.running = 1;
-	while(globals.running == 1) {
+	while (globals.running == 1) {
 		char *myaddr;
 		size_t len = sizeof(buf);
 		memset(buf, 0, len);
-		
+
 		switch_sockaddr_ip_get(&myaddr, globals.addr);
 
 		if (switch_socket_recvfrom(addr, globals.udp_socket, 0, buf, &len) == SWITCH_STATUS_SUCCESS) {
@@ -287,25 +285,25 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void)
 
 			memcpy(&host_hash, buf, sizeof(host_hash));
 			packet = buf + sizeof(host_hash);
-			
+
 			if (host_hash == globals.host_hash) {
 				continue;
 			}
-
 			//switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "\nEVENT %d\n--------------------------------\n%s\n", (int) len, packet);
-			if (switch_event_create_subclass(&local_event, SWITCH_EVENT_CUSTOM, MULTICAST_EVENT) == SWITCH_STATUS_SUCCESS) {
+			if (switch_event_create_subclass(&local_event, SWITCH_EVENT_CUSTOM, MULTICAST_EVENT) ==
+				SWITCH_STATUS_SUCCESS) {
 				char *var, *val, *term = NULL, tmpname[128];
 				switch_event_add_header(local_event, SWITCH_STACK_BOTTOM, "Multicast", "yes");
 				var = packet;
-				while(*var) {
+				while (*var) {
 					if ((val = strchr(var, ':')) != 0) {
 						*val++ = '\0';
-						while(*val == ' ') {
+						while (*val == ' ') {
 							val++;
 						}
-						if ((term = strchr(val, '\r')) != 0 || (term=strchr(val, '\n')) != 0) {
+						if ((term = strchr(val, '\r')) != 0 || (term = strchr(val, '\n')) != 0) {
 							*term = '\0';
-							while(*term == '\r' || *term == '\n') {
+							while (*term == '\r' || *term == '\n') {
 								term++;
 							}
 						}
@@ -315,18 +313,18 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void)
 					} else {
 						break;
 					}
-				} 
+				}
 
 				if (var && strlen(var) > 1) {
 					switch_event_add_body(local_event, var);
 				}
 
 				switch_event_fire(&local_event);
-			
+
 			}
 		}
 	}
-		
+
 	globals.running = 0;
 	return SWITCH_STATUS_TERM;
 }
diff --git a/src/mod/event_handlers/mod_event_socket/mod_event_socket.c b/src/mod/event_handlers/mod_event_socket/mod_event_socket.c
index d4a74504a7..d0f1f32bca 100644
--- a/src/mod/event_handlers/mod_event_socket/mod_event_socket.c
+++ b/src/mod/event_handlers/mod_event_socket/mod_event_socket.c
@@ -61,10 +61,10 @@ struct listener {
 	uint32_t flags;
 	switch_log_level_t level;
 	char *ebuf;
-	uint8_t event_list[SWITCH_EVENT_ALL+1];
+	uint8_t event_list[SWITCH_EVENT_ALL + 1];
 	switch_hash_t *event_hash;
 	switch_thread_rwlock_t *rwlock;
-    switch_core_session_t *session;
+	switch_core_session_t *session;
 	struct listener *next;
 };
 
@@ -86,15 +86,15 @@ static struct {
 } prefs;
 
 SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_pref_ip, prefs.ip)
-SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_pref_pass, prefs.password)
+	SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_pref_pass, prefs.password)
 
-static void *SWITCH_THREAD_FUNC listener_run(switch_thread_t *thread, void *obj);
-static void launch_listener_thread(listener_t *listener);
+	 static void *SWITCH_THREAD_FUNC listener_run(switch_thread_t *thread, void *obj);
+	 static void launch_listener_thread(listener_t * listener);
 
-static switch_status_t socket_logger(const switch_log_node_t *node, switch_log_level_t level)
+	 static switch_status_t socket_logger(const switch_log_node_t *node, switch_log_level_t level)
 {
 	listener_t *l;
-	
+
 	switch_mutex_lock(listen_list.mutex);
 	for (l = listen_list.listeners; l; l = l->next) {
 		if (switch_test_flag(l, LFLAG_LOG) && l->level >= node->level) {
@@ -121,7 +121,7 @@ static void event_handler(switch_event_t *event)
 	if (!listen_list.ready) {
 		return;
 	}
-	
+
 	switch_mutex_lock(listen_list.mutex);
 	for (l = listen_list.listeners; l; l = l->next) {
 		uint8_t send = 0;
@@ -130,21 +130,22 @@ static void event_handler(switch_event_t *event)
 			continue;
 		}
 
-        if (l->event_list[(uint8_t)SWITCH_EVENT_ALL]) {
+		if (l->event_list[(uint8_t) SWITCH_EVENT_ALL]) {
 			send = 1;
-		} else if ((l->event_list[(uint8_t)event->event_id])) {
-			if (event->event_id != SWITCH_EVENT_CUSTOM || (event->subclass && switch_core_hash_find(l->event_hash, event->subclass->name))) {
+		} else if ((l->event_list[(uint8_t) event->event_id])) {
+			if (event->event_id != SWITCH_EVENT_CUSTOM
+				|| (event->subclass && switch_core_hash_find(l->event_hash, event->subclass->name))) {
+				send = 1;
+			}
+		}
+
+		if (send && switch_test_flag(l, LFLAG_MYEVENTS)) {
+			char *uuid = switch_event_get_header(event, "unique-id");
+			if (!uuid || strcmp(uuid, switch_core_session_get_uuid(l->session))) {
 				send = 1;
 			}
 		}
 
-        if (send && switch_test_flag(l, LFLAG_MYEVENTS)) {
-            char *uuid = switch_event_get_header(event, "unique-id");
-            if (!uuid || strcmp(uuid, switch_core_session_get_uuid(l->session))) {
-                send = 1;
-            }
-        }
-        
 		if (send) {
 			if (switch_event_dup(&clone, event) == SWITCH_STATUS_SUCCESS) {
 				switch_queue_push(l->event_queue, clone);
@@ -159,101 +160,103 @@ static void event_handler(switch_event_t *event)
 
 static void socket_function(switch_core_session_t *session, char *data)
 {
-    char *host, *port_name;
-    switch_socket_t *new_sock;
-    switch_sockaddr_t *sa;
-    switch_port_t port = 8084;
-    listener_t *listener;
+	char *host, *port_name;
+	switch_socket_t *new_sock;
+	switch_sockaddr_t *sa;
+	switch_port_t port = 8084;
+	listener_t *listener;
 	int argc = 0, x = 0;
-	char *argv[80] = {0};
+	char *argv[80] = { 0 };
 	char *mydata;
 
 	if (data && (mydata = switch_core_session_strdup(session, data))) {
 		argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
-	} 
+	}
 
-    if (argc < 1) {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
-        return;
-    }
-
-    host = argv[0];
-
-    if (switch_strlen_zero(host)) {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing Host!\n");
-        return;
-    }
-
-    if ((port_name = strchr(host, ':'))) {
-        *port_name++ = '\0';
-        port = (switch_port_t)atoi(port_name);
-    }
-
-	if (switch_sockaddr_info_get(&sa, host, AF_INET, port, 0, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Socket Error!\n");
+	if (argc < 1) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
 		return;
 	}
 
-	if (switch_socket_create(&new_sock, AF_INET, SOCK_STREAM, SWITCH_PROTO_TCP, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Socket Error!\n");
+	host = argv[0];
+
+	if (switch_strlen_zero(host)) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing Host!\n");
 		return;
 	}
 
-    switch_socket_opt_set(new_sock, SWITCH_SO_KEEPALIVE, 1);
+	if ((port_name = strchr(host, ':'))) {
+		*port_name++ = '\0';
+		port = (switch_port_t) atoi(port_name);
+	}
+
+	if (switch_sockaddr_info_get(&sa, host, AF_INET, port, 0, switch_core_session_get_pool(session)) !=
+		SWITCH_STATUS_SUCCESS) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Socket Error!\n");
+		return;
+	}
+
+	if (switch_socket_create(&new_sock, AF_INET, SOCK_STREAM, SWITCH_PROTO_TCP, switch_core_session_get_pool(session))
+		!= SWITCH_STATUS_SUCCESS) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Socket Error!\n");
+		return;
+	}
+
+	switch_socket_opt_set(new_sock, SWITCH_SO_KEEPALIVE, 1);
 
 	if (switch_socket_connect(new_sock, sa) != SWITCH_STATUS_SUCCESS) {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Socket Error!\n");
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Socket Error!\n");
 		return;
 	}
 
 
-    if (!(listener = switch_core_session_alloc(session, sizeof(*listener)))) {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Memory Error\n");
-        return;
-    }
-		
-    switch_thread_rwlock_create(&listener->rwlock, switch_core_session_get_pool(session));
-    switch_queue_create(&listener->event_queue, SWITCH_CORE_QUEUE_LEN, switch_core_session_get_pool(session));
-    switch_queue_create(&listener->log_queue, SWITCH_CORE_QUEUE_LEN, switch_core_session_get_pool(session));
+	if (!(listener = switch_core_session_alloc(session, sizeof(*listener)))) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Memory Error\n");
+		return;
+	}
 
-    listener->sock = new_sock;
-    listener->pool = switch_core_session_get_pool(session);
-    listener->format = EVENT_FORMAT_PLAIN;
-    listener->session = session;
-    
-    switch_mutex_init(&listener->flag_mutex, SWITCH_MUTEX_NESTED, listener->pool);
-    switch_core_hash_init(&listener->event_hash, listener->pool);
-    switch_set_flag(listener, LFLAG_AUTHED);
-    for(x = 1; x < argc; x++) {
-        if (argv[x] && !strcasecmp(argv[x], "full")) {
-            switch_set_flag(listener, LFLAG_FULL);
-        } else if (argv[x] && !strcasecmp(argv[x], "async")) {
-            switch_set_flag(listener, LFLAG_ASYNC);
-        }
-    }
-    
-    if (switch_test_flag(listener, LFLAG_ASYNC)) {
-        launch_listener_thread(listener);
-        switch_ivr_park(session, NULL);
-    } else {
-        listener_run(NULL, (void*) listener);
-    }
+	switch_thread_rwlock_create(&listener->rwlock, switch_core_session_get_pool(session));
+	switch_queue_create(&listener->event_queue, SWITCH_CORE_QUEUE_LEN, switch_core_session_get_pool(session));
+	switch_queue_create(&listener->log_queue, SWITCH_CORE_QUEUE_LEN, switch_core_session_get_pool(session));
+
+	listener->sock = new_sock;
+	listener->pool = switch_core_session_get_pool(session);
+	listener->format = EVENT_FORMAT_PLAIN;
+	listener->session = session;
+
+	switch_mutex_init(&listener->flag_mutex, SWITCH_MUTEX_NESTED, listener->pool);
+	switch_core_hash_init(&listener->event_hash, listener->pool);
+	switch_set_flag(listener, LFLAG_AUTHED);
+	for (x = 1; x < argc; x++) {
+		if (argv[x] && !strcasecmp(argv[x], "full")) {
+			switch_set_flag(listener, LFLAG_FULL);
+		} else if (argv[x] && !strcasecmp(argv[x], "async")) {
+			switch_set_flag(listener, LFLAG_ASYNC);
+		}
+	}
+
+	if (switch_test_flag(listener, LFLAG_ASYNC)) {
+		launch_listener_thread(listener);
+		switch_ivr_park(session, NULL);
+	} else {
+		listener_run(NULL, (void *) listener);
+	}
+
+	while (switch_test_flag(listener, LFLAG_SESSION)) {
+		switch_yield(100000);
+	}
 
-    while(switch_test_flag(listener, LFLAG_SESSION)) {
-        switch_yield(100000);
-    }
-    
 }
 
 
 static const switch_application_interface_t socket_application_interface = {
-    /*.interface_name */ "socket",
-    /*.application_function */ socket_function,
-    /* long_desc */ "Connect to a socket",
-    /* short_desc */ "Connect to a socket",
-    /* syntax */ "[:]",
+	/*.interface_name */ "socket",
+	/*.application_function */ socket_function,
+	/* long_desc */ "Connect to a socket",
+	/* short_desc */ "Connect to a socket",
+	/* syntax */ "[:]",
 	/* flags */ SAF_SUPPORT_NOMEDIA,
-    /*.next */ NULL
+	/*.next */ NULL
 };
 
 
@@ -268,7 +271,8 @@ static switch_loadable_module_interface_t event_socket_module_interface = {
 };
 
 
-static void close_socket(switch_socket_t **sock) {
+static void close_socket(switch_socket_t **sock)
+{
 	switch_mutex_lock(listen_list.sock_mutex);
 	if (*sock) {
 		switch_socket_shutdown(*sock, SWITCH_SHUTDOWN_READWRITE);
@@ -299,7 +303,8 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_shutdown(void)
 
 
 
-SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
+													   char *filename)
 {
 	/* connect my internal structure to the blank pointer passed to me */
 	*module_interface = &event_socket_module_interface;
@@ -308,7 +313,7 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_mod
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static void add_listener(listener_t *listener) 
+static void add_listener(listener_t * listener)
 {
 	/* add me to the listeners so I get events */
 	switch_mutex_lock(listen_list.mutex);
@@ -317,7 +322,7 @@ static void add_listener(listener_t *listener)
 	switch_mutex_unlock(listen_list.mutex);
 }
 
-static void remove_listener(listener_t *listener)
+static void remove_listener(listener_t * listener)
 {
 	listener_t *l, *last = NULL;
 
@@ -343,7 +348,7 @@ static void strip_cr(char *s)
 	}
 }
 
-static switch_status_t read_packet(listener_t *listener, switch_event_t **event, uint32_t timeout) 
+static switch_status_t read_packet(listener_t * listener, switch_event_t **event, uint32_t timeout)
 {
 	switch_size_t mlen, bytes = 0;
 	char mbuf[2048] = "";
@@ -361,7 +366,7 @@ static switch_status_t read_packet(listener_t *listener, switch_event_t **event,
 	start = time(NULL);
 	ptr = mbuf;
 
-	while(listener->sock) {
+	while (listener->sock) {
 		uint8_t do_sleep = 1;
 		mlen = 1;
 		status = switch_socket_recv(listener->sock, ptr, &mlen);
@@ -370,16 +375,16 @@ static switch_status_t read_packet(listener_t *listener, switch_event_t **event,
 			return SWITCH_STATUS_FALSE;
 		}
 
-        if (listener->session && !switch_channel_ready(switch_core_session_get_channel(listener->session))) {
-            status = SWITCH_STATUS_FALSE;
-            break;
-        }
+		if (listener->session && !switch_channel_ready(switch_core_session_get_channel(listener->session))) {
+			status = SWITCH_STATUS_FALSE;
+			break;
+		}
 
 		if (mlen) {
 			bytes += mlen;
 			do_sleep = 0;
 
-			if (*mbuf == '\r' || *mbuf == '\n') { /* bah */
+			if (*mbuf == '\r' || *mbuf == '\n') {	/* bah */
 				ptr = mbuf;
 				mbuf[0] = '\0';
 				bytes = 0;
@@ -401,7 +406,7 @@ static switch_status_t read_packet(listener_t *listener, switch_event_t **event,
 				char *next;
 				char *cur = mbuf;
 				bytes = 0;
-				while(cur) {
+				while (cur) {
 					if ((next = strchr(cur, '\r')) || (next = strchr(cur, '\n'))) {
 						while (*next == '\r' || *next == '\n') {
 							next++;
@@ -418,30 +423,30 @@ static switch_status_t read_packet(listener_t *listener, switch_event_t **event,
 						if (!switch_strlen_zero(var)) {
 							if ((val = strchr(var, ':'))) {
 								*val++ = '\0';
-								while(*val == ' ') {
+								while (*val == ' ') {
 									val++;
 								}
-							} 
+							}
 							if (var && val) {
 								switch_event_add_header(*event, SWITCH_STACK_BOTTOM, var, "%s", val);
 							}
 						}
 					}
-					
+
 					cur = next;
 				}
 				break;
 			}
 		}
-        
+
 		if (timeout) {
-			elapsed = (uint32_t)(time(NULL) - start);
+			elapsed = (uint32_t) (time(NULL) - start);
 			if (elapsed >= timeout) {
 				switch_clear_flag_locked(listener, LFLAG_RUNNING);
 				return SWITCH_STATUS_FALSE;
 			}
 		}
-		
+
 		if (!*mbuf) {
 			if (switch_test_flag(listener, LFLAG_LOG)) {
 				if (switch_queue_trypop(listener->log_queue, &pop) == SWITCH_STATUS_SUCCESS) {
@@ -449,12 +454,13 @@ static switch_status_t read_packet(listener_t *listener, switch_event_t **event,
 
 
 					if (data) {
-						snprintf(buf, sizeof(buf), "Content-Type: log/data\nContent-Length: %"SWITCH_SSIZE_T_FMT"\n\n", strlen(data));
+						snprintf(buf, sizeof(buf),
+								 "Content-Type: log/data\nContent-Length: %" SWITCH_SSIZE_T_FMT "\n\n", strlen(data));
 						len = strlen(buf);
 						switch_socket_send(listener->sock, buf, &len);
 						len = strlen(data);
 						switch_socket_send(listener->sock, data, &len);
-					
+
 						free(data);
 					}
 					do_sleep = 0;
@@ -483,12 +489,11 @@ static switch_status_t read_packet(listener_t *listener, switch_event_t **event,
 							continue;
 						}
 					}
-			
+
 					len = strlen(listener->ebuf);
 
-					snprintf(hbuf, sizeof(hbuf), "Content-Length: %"SWITCH_SSIZE_T_FMT"\n" 
-							 "Content-Type: text/event-%s\n"
-							 "\n", len, etype);
+					snprintf(hbuf, sizeof(hbuf), "Content-Length: %" SWITCH_SSIZE_T_FMT "\n"
+							 "Content-Type: text/event-%s\n" "\n", len, etype);
 
 					len = strlen(hbuf);
 					switch_socket_send(listener->sock, hbuf, &len);
@@ -523,9 +528,9 @@ static void *SWITCH_THREAD_FUNC api_exec(switch_thread_t *thread, void *obj)
 {
 
 	struct api_command_struct *acs = (struct api_command_struct *) obj;
-	switch_stream_handle_t stream = {0};
-    char *reply, *freply = NULL;
-    switch_status_t status;
+	switch_stream_handle_t stream = { 0 };
+	char *reply, *freply = NULL;
+	switch_status_t status;
 
 	if (switch_thread_rwlock_tryrdlock(acs->listener->rwlock) != SWITCH_STATUS_SUCCESS) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error! cannot get read lock.\n");
@@ -535,42 +540,42 @@ static void *SWITCH_THREAD_FUNC api_exec(switch_thread_t *thread, void *obj)
 
 	SWITCH_STANDARD_STREAM(stream);
 
-    if ((status = switch_api_execute(acs->api_cmd, acs->arg, NULL, &stream)) == SWITCH_STATUS_SUCCESS) {
-        reply = stream.data;
-    } else {
-        freply = switch_mprintf("%s: Command not found!", acs->api_cmd);
-        reply = freply;
-    }
-        
-    if (!reply) {
-        reply = "Command returned no output!";
-    }
-    
-    if (acs->bg) {
-        switch_event_t *event;
-        
-        if (switch_event_create(&event, SWITCH_EVENT_BACKGROUND_JOB) == SWITCH_STATUS_SUCCESS) {
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Job-UUID", "%s", acs->uuid_str);
-            switch_event_add_body(event, "%s", reply);
-            switch_event_fire(&event);
-        }
-    } else {
-        switch_size_t rlen, blen;
-        char buf[1024] = "";
-        rlen = strlen(reply);			
-        snprintf(buf, sizeof(buf), "Content-Type: api/response\nContent-Length: %"SWITCH_SSIZE_T_FMT"\n\n", rlen);
-        blen = strlen(buf);
-        switch_socket_send(acs->listener->sock, buf, &blen);
-        switch_socket_send(acs->listener->sock, reply, &rlen);
-    }
-		
-    switch_safe_free(stream.data);
-    switch_safe_free(freply);
+	if ((status = switch_api_execute(acs->api_cmd, acs->arg, NULL, &stream)) == SWITCH_STATUS_SUCCESS) {
+		reply = stream.data;
+	} else {
+		freply = switch_mprintf("%s: Command not found!", acs->api_cmd);
+		reply = freply;
+	}
+
+	if (!reply) {
+		reply = "Command returned no output!";
+	}
+
+	if (acs->bg) {
+		switch_event_t *event;
+
+		if (switch_event_create(&event, SWITCH_EVENT_BACKGROUND_JOB) == SWITCH_STATUS_SUCCESS) {
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Job-UUID", "%s", acs->uuid_str);
+			switch_event_add_body(event, "%s", reply);
+			switch_event_fire(&event);
+		}
+	} else {
+		switch_size_t rlen, blen;
+		char buf[1024] = "";
+		rlen = strlen(reply);
+		snprintf(buf, sizeof(buf), "Content-Type: api/response\nContent-Length: %" SWITCH_SSIZE_T_FMT "\n\n", rlen);
+		blen = strlen(buf);
+		switch_socket_send(acs->listener->sock, buf, &blen);
+		switch_socket_send(acs->listener->sock, reply, &rlen);
+	}
+
+	switch_safe_free(stream.data);
+	switch_safe_free(freply);
 
 	switch_thread_rwlock_unlock(acs->listener->rwlock);
-	
 
- done:
+
+  done:
 	if (acs && acs->bg) {
 		if (acs->api_cmd) {
 			free(acs->api_cmd);
@@ -581,9 +586,9 @@ static void *SWITCH_THREAD_FUNC api_exec(switch_thread_t *thread, void *obj)
 		free(acs);
 	}
 	return NULL;
-	
+
 }
-static switch_status_t parse_command(listener_t *listener, switch_event_t *event, char *reply, uint32_t reply_len)
+static switch_status_t parse_command(listener_t * listener, switch_event_t *event, char *reply, uint32_t reply_len)
 {
 	switch_status_t status = SWITCH_STATUS_SUCCESS;
 	char *cmd = switch_event_get_header(event, "command");
@@ -618,70 +623,71 @@ static switch_status_t parse_command(listener_t *listener, switch_event_t *event
 	}
 
 
-    if (listener->session) {
-        switch_channel_t *channel = switch_core_session_get_channel(listener->session);
-        assert(channel != NULL);
+	if (listener->session) {
+		switch_channel_t *channel = switch_core_session_get_channel(listener->session);
+		assert(channel != NULL);
 
-        if (!strncasecmp(cmd, "connect", 7)) {
-            snprintf(reply, reply_len, "+OK");
-            goto done;
-        } else if (!strncasecmp(cmd, "sendmsg", 4)) {
-            if (switch_test_flag(listener, LFLAG_ASYNC)) {
-                if ((status = switch_core_session_queue_private_event(listener->session, &event)) == SWITCH_STATUS_SUCCESS) {
-                    snprintf(reply, reply_len, "+OK");
-                } else {
-                    snprintf(reply, reply_len, "-ERR memory error");
-                }
-            } else {
-                switch_ivr_parse_event(listener->session, event);
-                snprintf(reply, reply_len, "+OK");
-            }
-            goto done;
-        } else if (!strncasecmp(cmd, "getvar", 6)) {
-            char *arg;
-            char *val = "";
-            
-            strip_cr(cmd);
+		if (!strncasecmp(cmd, "connect", 7)) {
+			snprintf(reply, reply_len, "+OK");
+			goto done;
+		} else if (!strncasecmp(cmd, "sendmsg", 4)) {
+			if (switch_test_flag(listener, LFLAG_ASYNC)) {
+				if ((status =
+					 switch_core_session_queue_private_event(listener->session, &event)) == SWITCH_STATUS_SUCCESS) {
+					snprintf(reply, reply_len, "+OK");
+				} else {
+					snprintf(reply, reply_len, "-ERR memory error");
+				}
+			} else {
+				switch_ivr_parse_event(listener->session, event);
+				snprintf(reply, reply_len, "+OK");
+			}
+			goto done;
+		} else if (!strncasecmp(cmd, "getvar", 6)) {
+			char *arg;
+			char *val = "";
 
-            if ((arg = strchr(cmd, ' '))) {
-                *arg++ = '\0';
-                if (!(val = switch_channel_get_variable(channel, arg))) {
-                    val = "";
-                }
+			strip_cr(cmd);
 
-            }
-            snprintf(reply, reply_len, "%s", val);
-            goto done;
-        } else if (!strncasecmp(cmd, "myevents", 8)) {
-            listener->event_list[SWITCH_EVENT_CHANNEL_CREATE] = 1;
-            listener->event_list[SWITCH_EVENT_CHANNEL_DESTROY] = 1;
-            listener->event_list[SWITCH_EVENT_CHANNEL_STATE] = 1;
-            listener->event_list[SWITCH_EVENT_CHANNEL_ANSWER] = 1;
-            listener->event_list[SWITCH_EVENT_CHANNEL_HANGUP] = 1;
-            listener->event_list[SWITCH_EVENT_CHANNEL_EXECUTE] = 1;
-            listener->event_list[SWITCH_EVENT_CHANNEL_BRIDGE] = 1;
-            listener->event_list[SWITCH_EVENT_CHANNEL_UNBRIDGE] = 1;
-            listener->event_list[SWITCH_EVENT_CHANNEL_PROGRESS] = 1;
-            listener->event_list[SWITCH_EVENT_CHANNEL_OUTGOING] = 1;
-            listener->event_list[SWITCH_EVENT_CHANNEL_PARK] = 1;
-            listener->event_list[SWITCH_EVENT_CHANNEL_UNPARK] = 1;
-            listener->event_list[SWITCH_EVENT_TALK] = 1;
-            listener->event_list[SWITCH_EVENT_DTMF] = 1;
-            listener->event_list[SWITCH_EVENT_NOTALK] = 1;
-            listener->event_list[SWITCH_EVENT_DETECTED_SPEECH] = 1;
-            switch_set_flag_locked(listener, LFLAG_MYEVENTS);
-            switch_set_flag_locked(listener, LFLAG_EVENTS);
-            if (strstr(cmd, "xml") || strstr(cmd, "XML")) {
-                listener->format = EVENT_FORMAT_XML;
-            }
-            snprintf(reply, reply_len, "+OK Events Enabled");
-            goto done;
-        }
+			if ((arg = strchr(cmd, ' '))) {
+				*arg++ = '\0';
+				if (!(val = switch_channel_get_variable(channel, arg))) {
+					val = "";
+				}
 
-        if (!switch_test_flag(listener, LFLAG_FULL)) {
-            goto done;
-        }
-    }
+			}
+			snprintf(reply, reply_len, "%s", val);
+			goto done;
+		} else if (!strncasecmp(cmd, "myevents", 8)) {
+			listener->event_list[SWITCH_EVENT_CHANNEL_CREATE] = 1;
+			listener->event_list[SWITCH_EVENT_CHANNEL_DESTROY] = 1;
+			listener->event_list[SWITCH_EVENT_CHANNEL_STATE] = 1;
+			listener->event_list[SWITCH_EVENT_CHANNEL_ANSWER] = 1;
+			listener->event_list[SWITCH_EVENT_CHANNEL_HANGUP] = 1;
+			listener->event_list[SWITCH_EVENT_CHANNEL_EXECUTE] = 1;
+			listener->event_list[SWITCH_EVENT_CHANNEL_BRIDGE] = 1;
+			listener->event_list[SWITCH_EVENT_CHANNEL_UNBRIDGE] = 1;
+			listener->event_list[SWITCH_EVENT_CHANNEL_PROGRESS] = 1;
+			listener->event_list[SWITCH_EVENT_CHANNEL_OUTGOING] = 1;
+			listener->event_list[SWITCH_EVENT_CHANNEL_PARK] = 1;
+			listener->event_list[SWITCH_EVENT_CHANNEL_UNPARK] = 1;
+			listener->event_list[SWITCH_EVENT_TALK] = 1;
+			listener->event_list[SWITCH_EVENT_DTMF] = 1;
+			listener->event_list[SWITCH_EVENT_NOTALK] = 1;
+			listener->event_list[SWITCH_EVENT_DETECTED_SPEECH] = 1;
+			switch_set_flag_locked(listener, LFLAG_MYEVENTS);
+			switch_set_flag_locked(listener, LFLAG_EVENTS);
+			if (strstr(cmd, "xml") || strstr(cmd, "XML")) {
+				listener->format = EVENT_FORMAT_XML;
+			}
+			snprintf(reply, reply_len, "+OK Events Enabled");
+			goto done;
+		}
+
+		if (!switch_test_flag(listener, LFLAG_FULL)) {
+			goto done;
+		}
+	}
 
 	if (!strncasecmp(cmd, "sendevent", 9)) {
 		char *ename;
@@ -691,7 +697,7 @@ static switch_status_t parse_command(listener_t *listener, switch_event_t *event
 		if (*ename == '\r' || *ename == '\n') {
 			ename = NULL;
 		}
-		
+
 		if (ename) {
 			switch_event_types_t etype;
 			if (switch_name_event(ename, &etype) == SWITCH_STATUS_SUCCESS) {
@@ -707,7 +713,7 @@ static switch_status_t parse_command(listener_t *listener, switch_event_t *event
 		char *uuid = cmd + 8;
 
 		if (uuid) {
-			while(*uuid == ' ') {
+			while (*uuid == ' ') {
 				uuid++;
 			}
 
@@ -729,7 +735,7 @@ static switch_status_t parse_command(listener_t *listener, switch_event_t *event
 				session = NULL;
 			}
 		}
-		
+
 		if (session) {
 			if ((status = switch_core_session_queue_private_event(session, &event)) == SWITCH_STATUS_SUCCESS) {
 				snprintf(reply, reply_len, "+OK");
@@ -742,9 +748,9 @@ static switch_status_t parse_command(listener_t *listener, switch_event_t *event
 		}
 
 		goto done;
-	
+
 	} else if (!strncasecmp(cmd, "api ", 4)) {
-		struct api_command_struct acs = {0};
+		struct api_command_struct acs = { 0 };
 		char *api_cmd = cmd + 4;
 		char *arg = NULL;
 		strip_cr(api_cmd);
@@ -766,7 +772,7 @@ static switch_status_t parse_command(listener_t *listener, switch_event_t *event
 		struct api_command_struct *acs;
 		char *api_cmd = cmd + 6;
 		char *arg = NULL;
-        char *uuid_str = NULL;
+		char *uuid_str = NULL;
 		strip_cr(api_cmd);
 
 		if ((arg = strchr(api_cmd, ' '))) {
@@ -786,17 +792,17 @@ static switch_status_t parse_command(listener_t *listener, switch_event_t *event
 			if (arg) {
 				acs->arg = strdup(arg);
 			}
-			acs->bg = 1;	
+			acs->bg = 1;
 			switch_threadattr_create(&thd_attr, listener->pool);
 			switch_threadattr_detach_set(thd_attr, 1);
 			switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
 			switch_thread_create(&thread, thd_attr, api_exec, acs, listener->pool);
 			if ((uuid_str = switch_event_get_header(event, "job-uuid"))) {
-                switch_copy_string(acs->uuid_str, uuid_str, sizeof(acs->uuid_str));
-            } else {
-                switch_uuid_get(&uuid);
-                switch_uuid_format(acs->uuid_str, &uuid);
-            }
+				switch_copy_string(acs->uuid_str, uuid_str, sizeof(acs->uuid_str));
+			} else {
+				switch_uuid_get(&uuid);
+				switch_uuid_format(acs->uuid_str, &uuid);
+			}
 			snprintf(reply, reply_len, "+OK Job-UUID: %s", acs->uuid_str);
 		} else {
 			snprintf(reply, reply_len, "-ERR memory error!");
@@ -809,16 +815,15 @@ static switch_status_t parse_command(listener_t *listener, switch_event_t *event
 
 		//pull off the first newline/carriage return
 		strip_cr(cmd);
-		
+
 		//move past the command
 		level_s = cmd + 3;
 
 		//see if we got an argument
-		if(!switch_strlen_zero(level_s)) {
+		if (!switch_strlen_zero(level_s)) {
 			//if so move to the argument
 			level_s++;
 		}
-			
 		//see if we lined up on an argument or not
 		if (switch_strlen_zero(level_s)) {
 			level_s = "debug";
@@ -833,7 +838,7 @@ static switch_status_t parse_command(listener_t *listener, switch_event_t *event
 	} else if (!strncasecmp(cmd, "nolog", 5)) {
 		void *pop;
 		while (switch_queue_trypop(listener->log_queue, &pop) == SWITCH_STATUS_SUCCESS);
-		
+
 		if (switch_test_flag(listener, LFLAG_LOG)) {
 			switch_clear_flag_locked(listener, LFLAG_LOG);
 			snprintf(reply, reply_len, "+OK no longer logging");
@@ -844,18 +849,18 @@ static switch_status_t parse_command(listener_t *listener, switch_event_t *event
 		char *next, *cur;
 		uint32_t count = 0, key_count = 0;
 		uint8_t custom = 0;
-		
+
 		strip_cr(cmd);
 		cur = cmd + 5;
 
 		if (cur && (cur = strchr(cur, ' '))) {
-			for(cur++; cur; count++) {
+			for (cur++; cur; count++) {
 				switch_event_types_t type;
 
 				if ((next = strchr(cur, ' '))) {
 					*next++ = '\0';
 				}
-				
+
 				if (!count) {
 					if (!strcasecmp(cur, "xml")) {
 						listener->format = EVENT_FORMAT_XML;
@@ -882,10 +887,10 @@ static switch_status_t parse_command(listener_t *listener, switch_event_t *event
 					}
 				}
 
-			end:
+			  end:
 				cur = next;
 			}
-		} 
+		}
 
 		if (!key_count) {
 			snprintf(reply, reply_len, "-ERR no keywords supplied");
@@ -896,24 +901,25 @@ static switch_status_t parse_command(listener_t *listener, switch_event_t *event
 			switch_set_flag_locked(listener, LFLAG_EVENTS);
 		}
 
-		snprintf(reply, reply_len, "+OK event listener enabled %s", listener->format == EVENT_FORMAT_XML ? "xml" : "plain");
+		snprintf(reply, reply_len, "+OK event listener enabled %s",
+				 listener->format == EVENT_FORMAT_XML ? "xml" : "plain");
 
 	} else if (!strncasecmp(cmd, "nixevent", 8)) {
 		char *next, *cur;
 		uint32_t count = 0, key_count = 0;
 		uint8_t custom = 0;
-		
+
 		strip_cr(cmd);
 		cur = cmd + 5;
 
 		if (cur && (cur = strchr(cur, ' '))) {
-			for(cur++; cur; count++) {
+			for (cur++; cur; count++) {
 				switch_event_types_t type;
 
 				if ((next = strchr(cur, ' '))) {
 					*next++ = '\0';
 				}
-				
+
 				if (custom) {
 					switch_core_hash_delete(listener->event_hash, cur);
 				} else if (switch_name_event(cur, &type) == SWITCH_STATUS_SUCCESS) {
@@ -942,7 +948,7 @@ static switch_status_t parse_command(listener_t *listener, switch_event_t *event
 
 				cur = next;
 			}
-		} 
+		}
 
 		if (!key_count) {
 			snprintf(reply, reply_len, "-ERR no keywords supplied");
@@ -954,7 +960,7 @@ static switch_status_t parse_command(listener_t *listener, switch_event_t *event
 		}
 
 		snprintf(reply, reply_len, "+OK events nixed");
-		
+
 	} else if (!strncasecmp(cmd, "noevents", 8)) {
 		void *pop;
 		while (switch_queue_trypop(listener->event_queue, &pop) == SWITCH_STATUS_SUCCESS);
@@ -971,9 +977,9 @@ static switch_status_t parse_command(listener_t *listener, switch_event_t *event
 		} else {
 			snprintf(reply, reply_len, "-ERR not listening for events");
 		}
-	} 
-	
- done:
+	}
+
+  done:
 	if (event) {
 		switch_event_destroy(&event);
 	}
@@ -993,16 +999,16 @@ static void *SWITCH_THREAD_FUNC listener_run(switch_thread_t *thread, void *obj)
 	switch_status_t status;
 	switch_event_t *event;
 	char reply[512] = "";
-    switch_core_session_t *session = NULL;
-    switch_channel_t *channel = NULL;
-    
+	switch_core_session_t *session = NULL;
+	switch_channel_t *channel = NULL;
+
 
 	assert(listener != NULL);
 
-    if ((session = listener->session)) {
-        channel = switch_core_session_get_channel(session);
-        switch_core_session_read_lock(session);
-    }
+	if ((session = listener->session)) {
+		channel = switch_core_session_get_channel(session);
+		switch_core_session_read_lock(session);
+	}
 
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Connection Open\n");
 
@@ -1010,83 +1016,85 @@ static void *SWITCH_THREAD_FUNC listener_run(switch_thread_t *thread, void *obj)
 	switch_set_flag_locked(listener, LFLAG_RUNNING);
 	add_listener(listener);
 
-    if (session && switch_test_flag(listener, LFLAG_AUTHED)) {
-        switch_event_t *event = NULL, *call_event;
-        char *event_str;
-        
+	if (session && switch_test_flag(listener, LFLAG_AUTHED)) {
+		switch_event_t *event = NULL, *call_event;
+		char *event_str;
 
-        switch_set_flag_locked(listener, LFLAG_SESSION);
-        status = read_packet(listener, &event, 25);
 
-        if (status != SWITCH_STATUS_SUCCESS || !event) {
-            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Socket Error!\n");
-            switch_clear_flag_locked(listener, LFLAG_RUNNING);
-            goto done;
-        }
+		switch_set_flag_locked(listener, LFLAG_SESSION);
+		status = read_packet(listener, &event, 25);
 
-        if (switch_event_create(&call_event, SWITCH_EVENT_MESSAGE) != SWITCH_STATUS_SUCCESS) {
-            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
-            switch_clear_flag_locked(listener, LFLAG_RUNNING);
-            goto done;
-        }
+		if (status != SWITCH_STATUS_SUCCESS || !event) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Socket Error!\n");
+			switch_clear_flag_locked(listener, LFLAG_RUNNING);
+			goto done;
+		}
 
-        if (parse_command(listener, event, reply, sizeof(reply)) != SWITCH_STATUS_SUCCESS) {
-            switch_clear_flag_locked(listener, LFLAG_RUNNING);
-            goto done;
-        }
+		if (switch_event_create(&call_event, SWITCH_EVENT_MESSAGE) != SWITCH_STATUS_SUCCESS) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
+			switch_clear_flag_locked(listener, LFLAG_RUNNING);
+			goto done;
+		}
 
-        switch_caller_profile_event_set_data(switch_channel_get_caller_profile(channel), "Channel", call_event);
-        switch_channel_event_set_data(channel, call_event);
-        switch_event_add_header(call_event, SWITCH_STACK_BOTTOM, "Content-Type", "command/reply");
-        
-        switch_event_add_header(call_event, SWITCH_STACK_BOTTOM, "Socket-Mode", switch_test_flag(listener, LFLAG_ASYNC) ? "async" : "static");
-        switch_event_add_header(call_event, SWITCH_STACK_BOTTOM, "Control", switch_test_flag(listener, LFLAG_FULL) ? "full" : "single-channel");
-        
-        switch_event_serialize(call_event, &event_str);
-        if (!event_str) {
-            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
-            switch_clear_flag_locked(listener, LFLAG_RUNNING);
-            goto done;
-        }
-        len = strlen(event_str);
-        switch_socket_send(listener->sock, event_str, &len);
+		if (parse_command(listener, event, reply, sizeof(reply)) != SWITCH_STATUS_SUCCESS) {
+			switch_clear_flag_locked(listener, LFLAG_RUNNING);
+			goto done;
+		}
 
-        switch_safe_free(event_str);
-    } else {
-        snprintf(buf, sizeof(buf), "Content-Type: auth/request\n\n");
-		
-        len = strlen(buf);
-        switch_socket_send(listener->sock, buf, &len);
-		
-        while (!switch_test_flag(listener, LFLAG_AUTHED)) {
-            status = read_packet(listener, &event, 25);
-            if (status != SWITCH_STATUS_SUCCESS) {
-                goto done;
-            }
-            if (!event) {
-                continue;
-            }
+		switch_caller_profile_event_set_data(switch_channel_get_caller_profile(channel), "Channel", call_event);
+		switch_channel_event_set_data(channel, call_event);
+		switch_event_add_header(call_event, SWITCH_STACK_BOTTOM, "Content-Type", "command/reply");
 
-            if (parse_command(listener, event, reply, sizeof(reply)) != SWITCH_STATUS_SUCCESS) {
-                switch_clear_flag_locked(listener, LFLAG_RUNNING);
-                goto done;
-            }
-            if (!switch_strlen_zero(reply)) {
-                snprintf(buf, sizeof(buf), "Content-Type: command/reply\nReply-Text: %s\n\n", reply);
-                len = strlen(buf);
-                switch_socket_send(listener->sock, buf, &len);
-            }
-            break;
-        }
-    }
+		switch_event_add_header(call_event, SWITCH_STACK_BOTTOM, "Socket-Mode",
+								switch_test_flag(listener, LFLAG_ASYNC) ? "async" : "static");
+		switch_event_add_header(call_event, SWITCH_STACK_BOTTOM, "Control",
+								switch_test_flag(listener, LFLAG_FULL) ? "full" : "single-channel");
 
-	while(switch_test_flag(listener, LFLAG_RUNNING) && listen_list.ready) {
+		switch_event_serialize(call_event, &event_str);
+		if (!event_str) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
+			switch_clear_flag_locked(listener, LFLAG_RUNNING);
+			goto done;
+		}
+		len = strlen(event_str);
+		switch_socket_send(listener->sock, event_str, &len);
+
+		switch_safe_free(event_str);
+	} else {
+		snprintf(buf, sizeof(buf), "Content-Type: auth/request\n\n");
+
+		len = strlen(buf);
+		switch_socket_send(listener->sock, buf, &len);
+
+		while (!switch_test_flag(listener, LFLAG_AUTHED)) {
+			status = read_packet(listener, &event, 25);
+			if (status != SWITCH_STATUS_SUCCESS) {
+				goto done;
+			}
+			if (!event) {
+				continue;
+			}
+
+			if (parse_command(listener, event, reply, sizeof(reply)) != SWITCH_STATUS_SUCCESS) {
+				switch_clear_flag_locked(listener, LFLAG_RUNNING);
+				goto done;
+			}
+			if (!switch_strlen_zero(reply)) {
+				snprintf(buf, sizeof(buf), "Content-Type: command/reply\nReply-Text: %s\n\n", reply);
+				len = strlen(buf);
+				switch_socket_send(listener->sock, buf, &len);
+			}
+			break;
+		}
+	}
+
+	while (switch_test_flag(listener, LFLAG_RUNNING) && listen_list.ready) {
 		switch_event_t *event;
 
 		len = sizeof(buf);
 		memset(buf, 0, len);
 		status = read_packet(listener, &event, 0);
-		
+
 		if (status != SWITCH_STATUS_SUCCESS) {
 			break;
 		}
@@ -1105,10 +1113,10 @@ static void *SWITCH_THREAD_FUNC listener_run(switch_thread_t *thread, void *obj)
 			len = strlen(buf);
 			switch_socket_send(listener->sock, buf, &len);
 		}
-			
+
 	}
 
- done:
+  done:
 
 	remove_listener(listener);
 	close_socket(&listener->sock);
@@ -1117,29 +1125,29 @@ static void *SWITCH_THREAD_FUNC listener_run(switch_thread_t *thread, void *obj)
 
 	switch_thread_rwlock_wrlock(listener->rwlock);
 	switch_thread_rwlock_unlock(listener->rwlock);
-	
+
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Connection Closed\n");
 
-    if (session) {
-        switch_channel_clear_flag(switch_core_session_get_channel(session), CF_CONTROLLED);
-        switch_clear_flag_locked(listener, LFLAG_SESSION);
-        switch_core_session_rwunlock(session);
-    } else if (listener->pool) {
+	if (session) {
+		switch_channel_clear_flag(switch_core_session_get_channel(session), CF_CONTROLLED);
+		switch_clear_flag_locked(listener, LFLAG_SESSION);
+		switch_core_session_rwunlock(session);
+	} else if (listener->pool) {
 		switch_memory_pool_t *pool = listener->pool;
 		switch_core_destroy_memory_pool(&pool);
 	}
 
-    
+
 	return NULL;
 }
 
 
 /* Create a thread for the socket and launch it */
-static void launch_listener_thread(listener_t *listener)
+static void launch_listener_thread(listener_t * listener)
 {
 	switch_thread_t *thread;
 	switch_threadattr_t *thd_attr = NULL;
-	
+
 	switch_threadattr_create(&thd_attr, listener->pool);
 	switch_threadattr_detach_set(thd_attr, 1);
 	switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
@@ -1164,15 +1172,15 @@ static int config(void)
 				if (!strcmp(var, "listen-ip")) {
 					set_pref_ip(val);
 				} else if (!strcmp(var, "listen-port")) {
-					prefs.port = (uint16_t)atoi(val);
+					prefs.port = (uint16_t) atoi(val);
 				} else if (!strcmp(var, "password")) {
 					set_pref_pass(val);
-				} 
+				}
 			}
 		}
 		switch_xml_free(xml);
 	}
-	
+
 	if (switch_strlen_zero(prefs.ip)) {
 		set_pref_ip("127.0.0.1");
 	}
@@ -1192,9 +1200,9 @@ static int config(void)
 SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void)
 {
 	switch_memory_pool_t *pool = NULL, *listener_pool = NULL;
-    switch_status_t rv;
-    switch_sockaddr_t *sa;
-    switch_socket_t  *inbound_socket = NULL;
+	switch_status_t rv;
+	switch_sockaddr_t *sa;
+	switch_socket_t *inbound_socket = NULL;
 	listener_t *listener;
 
 	memset(&listen_list, 0, sizeof(listen_list));
@@ -1207,29 +1215,36 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void)
 
 	switch_mutex_init(&listen_list.mutex, SWITCH_MUTEX_NESTED, pool);
 	switch_mutex_init(&listen_list.sock_mutex, SWITCH_MUTEX_NESTED, pool);
-	
-	
-	for(;;) {
+
+
+	for (;;) {
 		rv = switch_sockaddr_info_get(&sa, prefs.ip, SWITCH_INET, prefs.port, 0, pool);
-		if (rv) goto fail;
-		rv = switch_socket_create(&listen_list.sock, switch_sockaddr_get_family(sa), SOCK_STREAM, SWITCH_PROTO_TCP, pool);
-		if (rv) goto sock_fail;
+		if (rv)
+			goto fail;
+		rv = switch_socket_create(&listen_list.sock, switch_sockaddr_get_family(sa), SOCK_STREAM, SWITCH_PROTO_TCP,
+								  pool);
+		if (rv)
+			goto sock_fail;
 		rv = switch_socket_opt_set(listen_list.sock, SWITCH_SO_REUSEADDR, 1);
-		if (rv) goto sock_fail;
+		if (rv)
+			goto sock_fail;
 		rv = switch_socket_bind(listen_list.sock, sa);
-		if (rv) goto sock_fail;
+		if (rv)
+			goto sock_fail;
 		rv = switch_socket_listen(listen_list.sock, 5);
-		if (rv) goto sock_fail;
+		if (rv)
+			goto sock_fail;
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Socket up listening on %s:%u\n", prefs.ip, prefs.port);
 		break;
-	sock_fail:
+	  sock_fail:
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Socket Error!\n");
 		switch_yield(100000);
 	}
 
 	listen_list.ready = 1;
 
-	if (switch_event_bind((char *) modname, SWITCH_EVENT_ALL, SWITCH_EVENT_SUBCLASS_ANY, event_handler, NULL) != SWITCH_STATUS_SUCCESS) {
+	if (switch_event_bind((char *) modname, SWITCH_EVENT_ALL, SWITCH_EVENT_SUBCLASS_ANY, event_handler, NULL) !=
+		SWITCH_STATUS_SUCCESS) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
 		return SWITCH_STATUS_GENERR;
 	}
@@ -1242,7 +1257,7 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void)
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "OH OH no pool\n");
 			goto fail;
 		}
-		
+
 		if ((rv = switch_socket_accept(&inbound_socket, listen_list.sock, listener_pool))) {
 			if (prefs.done) {
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Shutting Down\n");
@@ -1251,12 +1266,12 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void)
 			}
 			break;
 		}
-		
+
 		if (!(listener = switch_core_alloc(listener_pool, sizeof(*listener)))) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Memory Error\n");
 			break;
 		}
-		
+
 		switch_thread_rwlock_create(&listener->rwlock, listener_pool);
 		switch_queue_create(&listener->event_queue, SWITCH_CORE_QUEUE_LEN, listener_pool);
 		switch_queue_create(&listener->log_queue, SWITCH_CORE_QUEUE_LEN, listener_pool);
@@ -1268,7 +1283,7 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void)
 		switch_mutex_init(&listener->flag_mutex, SWITCH_MUTEX_NESTED, listener->pool);
 		switch_core_hash_init(&listener->event_hash, listener->pool);
 		launch_listener_thread(listener);
-		
+
 	}
 
 	close_socket(&listen_list.sock);
@@ -1281,7 +1296,7 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void)
 		switch_core_destroy_memory_pool(&listener_pool);
 	}
 
-	fail:
+  fail:
 	return SWITCH_STATUS_TERM;
 }
 
diff --git a/src/mod/event_handlers/mod_event_test/mod_event_test.c b/src/mod/event_handlers/mod_event_test/mod_event_test.c
index a53a8a9147..183bb76072 100644
--- a/src/mod/event_handlers/mod_event_test/mod_event_test.c
+++ b/src/mod/event_handlers/mod_event_test/mod_event_test.c
@@ -53,13 +53,15 @@ static void event_handler(switch_event_t *event)
 			dofree++;
 		}
 
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "\nEVENT (text version)\n--------------------------------\n%s", buf);
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "\nEVENT (xml version)\n--------------------------------\n%s\n", xmlstr);
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE,
+						  "\nEVENT (text version)\n--------------------------------\n%s", buf);
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE,
+						  "\nEVENT (xml version)\n--------------------------------\n%s\n", xmlstr);
 		break;
 	}
 
 	switch_safe_free(buf);
-	
+
 	if (dofree) {
 		if (xml) {
 			switch_xml_free(xml);
@@ -125,7 +127,8 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_shutdown(void)
 #endif
 
 
-SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
+													   char *filename)
 {
 	/* connect my internal structure to the blank pointer passed to me */
 	*module_interface = &event_test_module_interface;
@@ -140,7 +143,6 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_mod
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
 		return SWITCH_STATUS_GENERR;
 	}
-
 #ifdef TORTURE_ME
 	if (1) {
 		int x = 0;
diff --git a/src/mod/event_handlers/mod_xmpp_event/mod_xmpp_event.c b/src/mod/event_handlers/mod_xmpp_event/mod_xmpp_event.c
index e3f0e0f3fb..afee00b108 100644
--- a/src/mod/event_handlers/mod_xmpp_event/mod_xmpp_event.c
+++ b/src/mod/event_handlers/mod_xmpp_event/mod_xmpp_event.c
@@ -151,7 +151,7 @@ static int on_result(struct session *sess, ikspak * pak)
 {
 	iks *msg, *ctag;
 
-	msg = iks_make_pres (IKS_SHOW_AVAILABLE, "Available"); 
+	msg = iks_make_pres(IKS_SHOW_AVAILABLE, "Available");
 	ctag = iks_insert(msg, "c");
 	iks_insert_attrib(ctag, "node", "http://www.freeswitch.org/xmpp/client/caps");
 	iks_insert_attrib(ctag, "ver", "1.0.0.1");
@@ -159,7 +159,7 @@ static int on_result(struct session *sess, ikspak * pak)
 	iks_insert_attrib(ctag, "xmlns", "http://jabber.org/protocol/caps");
 
 	iks_send(sess->parser, msg);
-    iks_delete(msg);
+	iks_delete(msg);
 
 	return IKS_FILTER_EAT;
 }
@@ -231,16 +231,16 @@ static int on_stream(struct session *sess, int type, iks * node)
 }
 
 
-static int on_subscribe(void *user_data, ikspak *pak)
+static int on_subscribe(void *user_data, ikspak * pak)
 {
 	char *from = iks_find_attrib(pak->x, "from");
 	struct session *sess = (struct session *) user_data;
 
-	iks *msg = iks_make_s10n (IKS_TYPE_SUBSCRIBED, from, "mod_xmpp_event"); 
+	iks *msg = iks_make_s10n(IKS_TYPE_SUBSCRIBED, from, "mod_xmpp_event");
 	iks_send(sess->parser, msg);
 	iks_delete(msg);
-		
-	msg = iks_make_s10n (IKS_TYPE_SUBSCRIBE, from, "mod_xmpp_event"); 
+
+	msg = iks_make_s10n(IKS_TYPE_SUBSCRIBE, from, "mod_xmpp_event");
 	iks_send(sess->parser, msg);
 	iks_delete(msg);
 
@@ -251,7 +251,7 @@ static int on_msg(void *user_data, ikspak * pak)
 {
 	char *cmd = iks_find_cdata(pak->x, "body");
 	char *arg = NULL;
-	switch_stream_handle_t stream = {0};
+	switch_stream_handle_t stream = { 0 };
 	char retbuf[2048] = "";
 	char *p;
 	iks *msg;
@@ -272,12 +272,12 @@ static int on_msg(void *user_data, ikspak * pak)
 	stream.write_function = switch_console_stream_write;
 	switch_api_execute(cmd, arg, NULL, &stream);
 
-	
+
 	msg = iks_make_msg(IKS_TYPE_NONE, globals.target_jid, retbuf);
 	iks_insert_attrib(msg, "subject", "Reply");
 	iks_send(globals.session.parser, msg);
 	iks_delete(msg);
-	
+
 
 	return 0;
 }
@@ -315,9 +315,7 @@ static void j_setup_filter(struct session *sess)
 						IKS_RULE_SUBTYPE, IKS_TYPE_ERROR, IKS_RULE_ID, "auth", IKS_RULE_DONE);
 
 	iks_filter_add_rule(my_filter, on_subscribe, sess,
-						IKS_RULE_TYPE, IKS_PAK_S10N,
-						IKS_RULE_SUBTYPE, IKS_TYPE_SUBSCRIBE,
-						IKS_RULE_DONE);
+						IKS_RULE_TYPE, IKS_PAK_S10N, IKS_RULE_SUBTYPE, IKS_TYPE_SUBSCRIBE, IKS_RULE_DONE);
 
 }
 
@@ -405,7 +403,8 @@ static switch_loadable_module_interface_t xmpp_event_module_interface = {
 	/*.application_interface */ NULL
 };
 
-SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
+													   char *filename)
 {
 	/* connect my internal structure to the blank pointer passed to me */
 	*module_interface = &xmpp_event_module_interface;
diff --git a/src/mod/event_handlers/mod_zeroconf/mod_zeroconf.c b/src/mod/event_handlers/mod_zeroconf/mod_zeroconf.c
index bf583a2945..a9d707c2a8 100644
--- a/src/mod/event_handlers/mod_zeroconf/mod_zeroconf.c
+++ b/src/mod/event_handlers/mod_zeroconf/mod_zeroconf.c
@@ -52,55 +52,55 @@ static sw_result HOWL_API my_browser(sw_discovery discovery,
 									 sw_discovery_browse_status status,
 									 sw_uint32 interface_index,
 									 sw_const_string name,
-									 sw_const_string type,
-									 sw_const_string domain,
-									 sw_opaque_t extra) {
+									 sw_const_string type, sw_const_string domain, sw_opaque_t extra)
+{
 	//sw_discovery_resolve_id rid;
 
 	switch (status) {
-		case SW_DISCOVERY_BROWSE_INVALID:
+	case SW_DISCOVERY_BROWSE_INVALID:
 		{
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "browse reply: Invalid\n");
 		}
 		break;
 
-		case SW_DISCOVERY_BROWSE_RELEASE:
+	case SW_DISCOVERY_BROWSE_RELEASE:
 		{
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "browse reply: Release\n");
 		}
 		break;
 
-		case SW_DISCOVERY_BROWSE_ADD_DOMAIN:
+	case SW_DISCOVERY_BROWSE_ADD_DOMAIN:
 		{
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "browse reply: Add Domain\n");
 		}
 		break;
 
-		case SW_DISCOVERY_BROWSE_ADD_DEFAULT_DOMAIN:
+	case SW_DISCOVERY_BROWSE_ADD_DEFAULT_DOMAIN:
 		{
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "browse reply: Add Default Domain\n");
 		}
 		break;
 
-		case SW_DISCOVERY_BROWSE_REMOVE_DOMAIN:
+	case SW_DISCOVERY_BROWSE_REMOVE_DOMAIN:
 		{
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "browse reply: Remove Domain\n");
 		}
 		break;
 
-		case SW_DISCOVERY_BROWSE_REMOVE_SERVICE:
+	case SW_DISCOVERY_BROWSE_REMOVE_SERVICE:
 		{
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "browse reply: Remove Service\n");
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "remove service: 0x%x %s %s %s\n", interface_index, name, type, domain);
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "remove service: 0x%x %s %s %s\n", interface_index,
+							  name, type, domain);
 		}
 		break;
 
-		case SW_DISCOVERY_BROWSE_RESOLVED:
+	case SW_DISCOVERY_BROWSE_RESOLVED:
 		{
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "browse reply: Resolved\n");
 		}
 		break;
-		case SW_DISCOVERY_BROWSE_ADD_SERVICE:
+	case SW_DISCOVERY_BROWSE_ADD_SERVICE:
 		break;
 	}
 
@@ -108,17 +108,16 @@ static sw_result HOWL_API my_browser(sw_discovery discovery,
 }
 
 
-static sw_result HOWL_API my_service_reply(sw_discovery	discovery,
-   sw_discovery_oid	oid,
-   sw_discovery_publish_status status,
-   sw_opaque extra) {
+static sw_result HOWL_API my_service_reply(sw_discovery discovery,
+										   sw_discovery_oid oid, sw_discovery_publish_status status, sw_opaque extra)
+{
 	static sw_string status_text[] = {
 		"Started",
 		"Stopped",
 		"Name Collision",
 		"Invalid"
 	};
-	
+
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "publish reply: %s\n", status_text[status]);
 	return SW_OKAY;
 }
@@ -126,7 +125,7 @@ static sw_result HOWL_API my_service_reply(sw_discovery	discovery,
 
 static void event_handler(switch_event_t *event)
 {
-	sw_text_record text_record;	
+	sw_text_record text_record;
 	sw_result result;
 
 	switch (event->event_id) {
@@ -159,10 +158,10 @@ static void event_handler(switch_event_t *event)
 				service = "_freeswitch._tcp";
 			}
 			if (port) {
-				porti = (sw_port)atoi(port);				
+				porti = (sw_port) atoi(port);
 			}
 
-			switch_mutex_lock(globals.zc_lock);			
+			switch_mutex_lock(globals.zc_lock);
 			if ((result = sw_discovery_publish(globals.discovery,
 											   0,
 											   "freeswitch",
@@ -172,9 +171,7 @@ static void event_handler(switch_event_t *event)
 											   porti,
 											   sw_text_record_bytes(text_record),
 											   sw_text_record_len(text_record),
-											   my_service_reply,
-											   NULL,
-											   &globals.disc_id)) != SW_OKAY) {
+											   my_service_reply, NULL, &globals.disc_id)) != SW_OKAY) {
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "publish failed: %u\n", result);
 				sw_text_record_fina(text_record);
 				switch_mutex_unlock(globals.zc_lock);
@@ -183,7 +180,7 @@ static void event_handler(switch_event_t *event)
 			switch_mutex_unlock(globals.zc_lock);
 			sw_text_record_fina(text_record);
 		}
-		
+
 		break;
 	case SWITCH_EVENT_UNPUBLISH:
 
@@ -211,11 +208,11 @@ static switch_status_t load_config(void)
 		for (param = switch_xml_child(settings, "param"); param; param = param->next) {
 			char *var = (char *) switch_xml_attr_soft(param, "name");
 			char *val = (char *) switch_xml_attr_soft(param, "value");
-			
+
 			if (!strcmp(var, "browse")) {
 				if ((oid = switch_core_alloc(module_pool, sizeof(*oid))) != 0) {
 					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Bind browser to to %s\n", val);
-					switch_mutex_lock(globals.zc_lock);	
+					switch_mutex_lock(globals.zc_lock);
 					sw_discovery_browse(globals.discovery, 0, val, NULL, my_browser, NULL, oid);
 					switch_mutex_unlock(globals.zc_lock);
 					count++;
@@ -223,14 +220,16 @@ static switch_status_t load_config(void)
 					return SWITCH_STATUS_MEMERR;
 				}
 			} else if (!strcasecmp(var, "publish") && !strcasecmp(val, "yes")) {
-				if (switch_event_bind((char *) modname, SWITCH_EVENT_PUBLISH, SWITCH_EVENT_SUBCLASS_ANY, event_handler, NULL) !=
-					SWITCH_STATUS_SUCCESS) {
+				if (switch_event_bind
+					((char *) modname, SWITCH_EVENT_PUBLISH, SWITCH_EVENT_SUBCLASS_ANY, event_handler,
+					 NULL) != SWITCH_STATUS_SUCCESS) {
 					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
 					return SWITCH_STATUS_GENERR;
 				}
-				
-				if (switch_event_bind((char *) modname, SWITCH_EVENT_UNPUBLISH, SWITCH_EVENT_SUBCLASS_ANY, event_handler, NULL) !=
-					SWITCH_STATUS_SUCCESS) {
+
+				if (switch_event_bind
+					((char *) modname, SWITCH_EVENT_UNPUBLISH, SWITCH_EVENT_SUBCLASS_ANY, event_handler,
+					 NULL) != SWITCH_STATUS_SUCCESS) {
 					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
 					return SWITCH_STATUS_GENERR;
 				}
@@ -269,7 +268,8 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_shutdown(void)
 }
 
 
-SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
+													   char *filename)
 {
 
 	memset(&globals, 0, sizeof(globals));
@@ -289,7 +289,7 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_mod
 	if (load_config() != SWITCH_STATUS_SUCCESS) {
 		return SWITCH_STATUS_TERM;
 	}
-	
+
 	if (switch_event_reserve_subclass(MY_EVENT_PUBLISH) != SWITCH_STATUS_SUCCESS) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass!");
 		return SWITCH_STATUS_GENERR;
@@ -312,7 +312,7 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void)
 {
 
 	RUNNING = 1;
-	while(RUNNING == 1) {
+	while (RUNNING == 1) {
 		sw_uint32 ms;
 		ms = 100;
 		sw_discovery_step(globals.discovery, &ms);
diff --git a/src/mod/formats/mod_native_file/mod_native_file.c b/src/mod/formats/mod_native_file/mod_native_file.c
index 50b26bdc1e..c180c5c8be 100644
--- a/src/mod/formats/mod_native_file/mod_native_file.c
+++ b/src/mod/formats/mod_native_file/mod_native_file.c
@@ -63,7 +63,8 @@ static switch_status_t native_file_file_open(switch_file_handle_t *handle, char
 		flags |= SWITCH_FOPEN_READ;
 	}
 
-	if (switch_file_open(&context->fd, path, flags, SWITCH_FPROT_UREAD|SWITCH_FPROT_UWRITE, handle->memory_pool) != SWITCH_STATUS_SUCCESS) {
+	if (switch_file_open(&context->fd, path, flags, SWITCH_FPROT_UREAD | SWITCH_FPROT_UWRITE, handle->memory_pool) !=
+		SWITCH_STATUS_SUCCESS) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error opening %s\n", path);
 		return SWITCH_STATUS_GENERR;
 	}
@@ -78,7 +79,7 @@ static switch_status_t native_file_file_open(switch_file_handle_t *handle, char
 	handle->seekable = 1;
 	handle->speed = 0;
 	handle->private_info = context;
-	handle->flags |=  SWITCH_FILE_NATIVE;
+	handle->flags |= SWITCH_FILE_NATIVE;
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Opening File [%s] %dhz\n", path, handle->samplerate);
 
 
@@ -88,7 +89,7 @@ static switch_status_t native_file_file_open(switch_file_handle_t *handle, char
 static switch_status_t native_file_file_close(switch_file_handle_t *handle)
 {
 	native_file_context *context = handle->private_info;
-	
+
 	if (context->fd) {
 		switch_file_close(context->fd);
 		context->fd = NULL;
@@ -97,12 +98,13 @@ static switch_status_t native_file_file_close(switch_file_handle_t *handle)
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status_t native_file_file_seek(switch_file_handle_t *handle, unsigned int *cur_sample, int64_t samples, int whence)
+static switch_status_t native_file_file_seek(switch_file_handle_t *handle, unsigned int *cur_sample, int64_t samples,
+											 int whence)
 {
 	native_file_context *context = handle->private_info;
-	
+
 	switch_file_seek(context->fd, whence, &samples);
-	
+
 	return SWITCH_STATUS_FALSE;
 
 }
@@ -121,21 +123,23 @@ static switch_status_t native_file_file_write(switch_file_handle_t *handle, void
 	return switch_file_write(context->fd, data, len);
 }
 
-static switch_status_t native_file_file_set_string(switch_file_handle_t *handle, switch_audio_col_t col, const char *string)
+static switch_status_t native_file_file_set_string(switch_file_handle_t *handle, switch_audio_col_t col,
+												   const char *string)
 {
 	//native_file_context *context = handle->private_info;
 
 	return SWITCH_STATUS_FALSE;
 }
 
-static switch_status_t native_file_file_get_string(switch_file_handle_t *handle, switch_audio_col_t col, const char **string)
+static switch_status_t native_file_file_get_string(switch_file_handle_t *handle, switch_audio_col_t col,
+												   const char **string)
 {
 	return SWITCH_STATUS_FALSE;
 }
 
 /* Registration */
 
-static char *supported_formats[SWITCH_MAX_CODECS] = {0};
+static char *supported_formats[SWITCH_MAX_CODECS] = { 0 };
 
 static switch_file_interface_t native_file_file_interface = {
 	/*.interface_name */ modname,
@@ -163,14 +167,15 @@ static switch_loadable_module_interface_t native_file_module_interface = {
 
 
 
-SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
+													   char *filename)
 {
 
 	const switch_codec_implementation_t *codecs[SWITCH_MAX_CODECS];
 	uint32_t num_codecs = switch_loadable_module_get_codecs(NULL, codecs, sizeof(codecs) / sizeof(codecs[0]));
 	uint32_t x;
 
-	for (x = 0 ; x < num_codecs; x++) {
+	for (x = 0; x < num_codecs; x++) {
 		supported_formats[x] = codecs[x]->iananame;
 	}
 
diff --git a/src/mod/formats/mod_shout/common.c b/src/mod/formats/mod_shout/common.c
index 987d6d28a8..62ef6df6f8 100644
--- a/src/mod/formats/mod_shout/common.c
+++ b/src/mod/formats/mod_shout/common.c
@@ -9,47 +9,47 @@
 #include "mpg123.h"
 #include "mpglib.h"
 
-struct parameter param = { 1 , 1 , 0 , 0 };
+struct parameter param = { 1, 1, 0, 0 };
 
 int tabsel_123[2][3][16] = {
-   { {0,32,64,96,128,160,192,224,256,288,320,352,384,416,448,},
-     {0,32,48,56, 64, 80, 96,112,128,160,192,224,256,320,384,},
-     {0,32,40,48, 56, 64, 80, 96,112,128,160,192,224,256,320,} },
+	{{0, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448,},
+	 {0, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384,},
+	 {0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320,}},
 
-   { {0,32,48,56,64,80,96,112,128,144,160,176,192,224,256,},
-     {0,8,16,24,32,40,48,56,64,80,96,112,128,144,160,},
-     {0,8,16,24,32,40,48,56,64,80,96,112,128,144,160,} }
+	{{0, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256,},
+	 {0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160,},
+	 {0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160,}}
 };
 
 long freqs[9] = { 44100, 48000, 32000,
-                  22050, 24000, 16000 ,
-                  11025 , 12000 , 8000 };
+	22050, 24000, 16000,
+	11025, 12000, 8000
+};
 
 
 #if 0
 static void get_II_stuff(struct frame *fr)
 {
-  static int translate[3][2][16] = 
-   { { { 0,2,2,2,2,2,2,0,0,0,1,1,1,1,1,0 } ,
-       { 0,2,2,0,0,0,1,1,1,1,1,1,1,1,1,0 } } ,
-     { { 0,2,2,2,2,2,2,0,0,0,0,0,0,0,0,0 } ,
-       { 0,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0 } } ,
-     { { 0,3,3,3,3,3,3,0,0,0,1,1,1,1,1,0 } ,
-       { 0,3,3,0,0,0,1,1,1,1,1,1,1,1,1,0 } } };
+	static int translate[3][2][16] = { {{0, 2, 2, 2, 2, 2, 2, 0, 0, 0, 1, 1, 1, 1, 1, 0},
+										{0, 2, 2, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0}},
+	{{0, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+	 {0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
+	{{0, 3, 3, 3, 3, 3, 3, 0, 0, 0, 1, 1, 1, 1, 1, 0},
+	 {0, 3, 3, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0}}
+	};
 
-  int table,sblim;
-  static struct al_table *tables[5] = 
-       { alloc_0, alloc_1, alloc_2, alloc_3 , alloc_4 };
-  static int sblims[5] = { 27 , 30 , 8, 12 , 30 };
+	int table, sblim;
+	static struct al_table *tables[5] = { alloc_0, alloc_1, alloc_2, alloc_3, alloc_4 };
+	static int sblims[5] = { 27, 30, 8, 12, 30 };
 
-  if(fr->lsf)
-    table = 4;
-  else
-    table = translate[fr->sampling_frequency][2-fr->stereo][fr->bitrate_index];
-  sblim = sblims[table];
+	if (fr->lsf)
+		table = 4;
+	else
+		table = translate[fr->sampling_frequency][2 - fr->stereo][fr->bitrate_index];
+	sblim = sblims[table];
 
-  fr->alloc = tables[table];
-  fr->II_sblimit = sblim;
+	fr->alloc = tables[table];
+	fr->II_sblimit = sblim;
 }
 #endif
 
@@ -58,15 +58,15 @@ static void get_II_stuff(struct frame *fr)
 #if 0
 int head_check(unsigned long head)
 {
-    if( (head & 0xffe00000) != 0xffe00000)
-	return FALSE;
-    if(!((head>>17)&3))
-	return FALSE;
-    if( ((head>>12)&0xf) == 0xf)
-	return FALSE;
-    if( ((head>>10)&0x3) == 0x3 )
-	return FALSE;
-    return TRUE;
+	if ((head & 0xffe00000) != 0xffe00000)
+		return FALSE;
+	if (!((head >> 17) & 3))
+		return FALSE;
+	if (((head >> 12) & 0xf) == 0xf)
+		return FALSE;
+	if (((head >> 10) & 0x3) == 0x3)
+		return FALSE;
+	return TRUE;
 }
 #endif
 
@@ -75,190 +75,178 @@ int head_check(unsigned long head)
  * the code a header and write the information
  * into the frame structure
  */
-int decode_header(struct frame *fr,unsigned long newhead)
+int decode_header(struct frame *fr, unsigned long newhead)
 {
-    if( newhead & (1<<20) ) {
-      fr->lsf = (newhead & (1<<19)) ? 0x0 : 0x1;
-      fr->mpeg25 = 0;
-    }
-    else {
-      fr->lsf = 1;
-      fr->mpeg25 = 1;
-    }
-    
-    fr->lay = 4-((newhead>>17)&3);
-    if( ((newhead>>10)&0x3) == 0x3) {
-		debug_printf("%d Stream error\n",  __LINE__);
-      return (0);
-    }
-    if(fr->mpeg25) {
-      fr->sampling_frequency = 6 + ((newhead>>10)&0x3);
-    }
-    else
-      fr->sampling_frequency = ((newhead>>10)&0x3) + (fr->lsf*3);
-    fr->error_protection = ((newhead>>16)&0x1)^0x1;
+	if (newhead & (1 << 20)) {
+		fr->lsf = (newhead & (1 << 19)) ? 0x0 : 0x1;
+		fr->mpeg25 = 0;
+	} else {
+		fr->lsf = 1;
+		fr->mpeg25 = 1;
+	}
 
-    if(fr->mpeg25) /* allow Bitrate change for 2.5 ... */
-      fr->bitrate_index = ((newhead>>12)&0xf);
+	fr->lay = 4 - ((newhead >> 17) & 3);
+	if (((newhead >> 10) & 0x3) == 0x3) {
+		debug_printf("%d Stream error\n", __LINE__);
+		return (0);
+	}
+	if (fr->mpeg25) {
+		fr->sampling_frequency = 6 + ((newhead >> 10) & 0x3);
+	} else
+		fr->sampling_frequency = ((newhead >> 10) & 0x3) + (fr->lsf * 3);
+	fr->error_protection = ((newhead >> 16) & 0x1) ^ 0x1;
 
-    fr->bitrate_index = ((newhead>>12)&0xf);
-    fr->padding   = ((newhead>>9)&0x1);
-    fr->extension = ((newhead>>8)&0x1);
-    fr->mode      = ((newhead>>6)&0x3);
-    fr->mode_ext  = ((newhead>>4)&0x3);
-    fr->copyright = ((newhead>>3)&0x1);
-    fr->original  = ((newhead>>2)&0x1);
-    fr->emphasis  = newhead & 0x3;
+	if (fr->mpeg25)				/* allow Bitrate change for 2.5 ... */
+		fr->bitrate_index = ((newhead >> 12) & 0xf);
 
-    fr->stereo    = (fr->mode == MPG_MD_MONO) ? 1 : 2;
+	fr->bitrate_index = ((newhead >> 12) & 0xf);
+	fr->padding = ((newhead >> 9) & 0x1);
+	fr->extension = ((newhead >> 8) & 0x1);
+	fr->mode = ((newhead >> 6) & 0x3);
+	fr->mode_ext = ((newhead >> 4) & 0x3);
+	fr->copyright = ((newhead >> 3) & 0x1);
+	fr->original = ((newhead >> 2) & 0x1);
+	fr->emphasis = newhead & 0x3;
 
-    if(!fr->bitrate_index)
-    {
-		debug_printf("%d Free format not supported.\n",  __LINE__);
-      return (0);
-    }
+	fr->stereo = (fr->mode == MPG_MD_MONO) ? 1 : 2;
 
-    switch(fr->lay)
-    {
-      case 1:
+	if (!fr->bitrate_index) {
+		debug_printf("%d Free format not supported.\n", __LINE__);
+		return (0);
+	}
+
+	switch (fr->lay) {
+	case 1:
 #if 0
 		fr->do_layer = do_layer1;
-        fr->jsbound = (fr->mode == MPG_MD_JOINT_STEREO) ? 
-                         (fr->mode_ext<<2)+4 : 32;
-        fr->framesize  = (long) tabsel_123[fr->lsf][0][fr->bitrate_index] * 12000;
-        fr->framesize /= freqs[fr->sampling_frequency];
-        fr->framesize  = ((fr->framesize+fr->padding)<<2)-4;
+		fr->jsbound = (fr->mode == MPG_MD_JOINT_STEREO) ? (fr->mode_ext << 2) + 4 : 32;
+		fr->framesize = (long) tabsel_123[fr->lsf][0][fr->bitrate_index] * 12000;
+		fr->framesize /= freqs[fr->sampling_frequency];
+		fr->framesize = ((fr->framesize + fr->padding) << 2) - 4;
 #else
-        debug_printf("%d Layer 1 not supported!\n",  __LINE__);
+		debug_printf("%d Layer 1 not supported!\n", __LINE__);
 #endif
-        break;
-      case 2:
+		break;
+	case 2:
 #if 0
 		fr->do_layer = do_layer2;
-        get_II_stuff(fr);
-        fr->jsbound = (fr->mode == MPG_MD_JOINT_STEREO) ?
-                         (fr->mode_ext<<2)+4 : fr->II_sblimit;
-        fr->framesize = (long) tabsel_123[fr->lsf][1][fr->bitrate_index] * 144000;
-        fr->framesize /= freqs[fr->sampling_frequency];
-        fr->framesize += fr->padding - 4;
+		get_II_stuff(fr);
+		fr->jsbound = (fr->mode == MPG_MD_JOINT_STEREO) ? (fr->mode_ext << 2) + 4 : fr->II_sblimit;
+		fr->framesize = (long) tabsel_123[fr->lsf][1][fr->bitrate_index] * 144000;
+		fr->framesize /= freqs[fr->sampling_frequency];
+		fr->framesize += fr->padding - 4;
 #else
-        debug_printf("%d Layer 2 not supported!\n",  __LINE__);
+		debug_printf("%d Layer 2 not supported!\n", __LINE__);
 #endif
-        break;
-      case 3:
+		break;
+	case 3:
 #if 0
-        fr->do_layer = do_layer3;
-        if(fr->lsf)
-          ssize = (fr->stereo == 1) ? 9 : 17;
-        else
-          ssize = (fr->stereo == 1) ? 17 : 32;
+		fr->do_layer = do_layer3;
+		if (fr->lsf)
+			ssize = (fr->stereo == 1) ? 9 : 17;
+		else
+			ssize = (fr->stereo == 1) ? 17 : 32;
 #endif
 
 #if 0
-        if(fr->error_protection)
-          ssize += 2;
+		if (fr->error_protection)
+			ssize += 2;
 #endif
-          fr->framesize  = (long) tabsel_123[fr->lsf][2][fr->bitrate_index] * 144000;
-          fr->framesize /= freqs[fr->sampling_frequency]<<(fr->lsf);
-          fr->framesize = fr->framesize + fr->padding - 4;
-        break; 
-      default:
-		  debug_printf("%d Sorry, unknown layer type.\n",  __LINE__); 
-        return (0);
-    }
-    return 1;
+		fr->framesize = (long) tabsel_123[fr->lsf][2][fr->bitrate_index] * 144000;
+		fr->framesize /= freqs[fr->sampling_frequency] << (fr->lsf);
+		fr->framesize = fr->framesize + fr->padding - 4;
+		break;
+	default:
+		debug_printf("%d Sorry, unknown layer type.\n", __LINE__);
+		return (0);
+	}
+	return 1;
 }
 
 #if 0
 void print_header(struct frame *fr)
 {
 	static char *modes[4] = { "Stereo", "Joint-Stereo", "Dual-Channel", "Single-Channel" };
-	static char *layers[4] = { "Unknown" , "I", "II", "III" };
+	static char *layers[4] = { "Unknown", "I", "II", "III" };
 
-	debug_printf("MPEG %s, Layer: %s, Freq: %ld, mode: %s, modext: %d, BPF : %d\n", 
-		fr->mpeg25 ? "2.5" : (fr->lsf ? "2.0" : "1.0"),
-		layers[fr->lay],freqs[fr->sampling_frequency],
-		modes[fr->mode],fr->mode_ext,fr->framesize+4);
+	debug_printf("MPEG %s, Layer: %s, Freq: %ld, mode: %s, modext: %d, BPF : %d\n",
+				 fr->mpeg25 ? "2.5" : (fr->lsf ? "2.0" : "1.0"),
+				 layers[fr->lay], freqs[fr->sampling_frequency], modes[fr->mode], fr->mode_ext, fr->framesize + 4);
 	debug_printf("Channels: %d, copyright: %s, original: %s, CRC: %s, emphasis: %d.\n",
-		fr->stereo,fr->copyright?"Yes":"No",
-		fr->original?"Yes":"No",fr->error_protection?"Yes":"No",
-		fr->emphasis);
+				 fr->stereo, fr->copyright ? "Yes" : "No",
+				 fr->original ? "Yes" : "No", fr->error_protection ? "Yes" : "No", fr->emphasis);
 	debug_printf("Bitrate: %d Kbits/s, Extension value: %d\n",
-		tabsel_123[fr->lsf][fr->lay-1][fr->bitrate_index],fr->extension);
+				 tabsel_123[fr->lsf][fr->lay - 1][fr->bitrate_index], fr->extension);
 }
 
 void print_header_compact(struct frame *fr)
 {
 	static char *modes[4] = { "stereo", "joint-stereo", "dual-channel", "mono" };
-	static char *layers[4] = { "Unknown" , "I", "II", "III" };
- 
+	static char *layers[4] = { "Unknown", "I", "II", "III" };
+
 	debug_printf("MPEG %s layer %s, %d kbit/s, %ld Hz %s\n",
-		fr->mpeg25 ? "2.5" : (fr->lsf ? "2.0" : "1.0"),
-		layers[fr->lay],
-		tabsel_123[fr->lsf][fr->lay-1][fr->bitrate_index],
-		freqs[fr->sampling_frequency], modes[fr->mode]);
+				 fr->mpeg25 ? "2.5" : (fr->lsf ? "2.0" : "1.0"),
+				 layers[fr->lay],
+				 tabsel_123[fr->lsf][fr->lay - 1][fr->bitrate_index], freqs[fr->sampling_frequency], modes[fr->mode]);
 }
 
 #endif
 
 unsigned int getbits(struct mpstr *mp, int number_of_bits)
 {
-  unsigned long rval;
+	unsigned long rval;
 
-  if(!number_of_bits)
-    return 0;
+	if (!number_of_bits)
+		return 0;
 
-  {
-    rval = (mp->worksample).wordpointer[0];
-    rval <<= 8;
-    rval |= (mp->worksample).wordpointer[1];
-    rval <<= 8;
-    rval |= (mp->worksample).wordpointer[2];
-    rval <<= (mp->worksample).bitindex;
-    rval &= 0xffffff;
+	{
+		rval = (mp->worksample).wordpointer[0];
+		rval <<= 8;
+		rval |= (mp->worksample).wordpointer[1];
+		rval <<= 8;
+		rval |= (mp->worksample).wordpointer[2];
+		rval <<= (mp->worksample).bitindex;
+		rval &= 0xffffff;
 
-    (mp->worksample).bitindex += number_of_bits;
+		(mp->worksample).bitindex += number_of_bits;
 
-    rval >>= (24-number_of_bits);
+		rval >>= (24 - number_of_bits);
 
-    (mp->worksample).wordpointer += ((mp->worksample).bitindex>>3);
-    (mp->worksample).bitindex &= 7;
-  }
-  return rval;
+		(mp->worksample).wordpointer += ((mp->worksample).bitindex >> 3);
+		(mp->worksample).bitindex &= 7;
+	}
+	return rval;
 }
 
 unsigned int getbits_fast(struct mpstr *mp, int number_of_bits)
 {
-  unsigned long rval;
+	unsigned long rval;
 
-  {
-    rval = (mp->worksample).wordpointer[0];
-    rval <<= 8;	
-    rval |= (mp->worksample).wordpointer[1];
-    rval <<= (mp->worksample).bitindex;
-    rval &= 0xffff;
-    (mp->worksample).bitindex += number_of_bits;
+	{
+		rval = (mp->worksample).wordpointer[0];
+		rval <<= 8;
+		rval |= (mp->worksample).wordpointer[1];
+		rval <<= (mp->worksample).bitindex;
+		rval &= 0xffff;
+		(mp->worksample).bitindex += number_of_bits;
 
-    rval >>= (16-number_of_bits);
+		rval >>= (16 - number_of_bits);
 
-    (mp->worksample).wordpointer += ((mp->worksample).bitindex>>3);
-    (mp->worksample).bitindex &= 7;
-  }
-  return rval;
+		(mp->worksample).wordpointer += ((mp->worksample).bitindex >> 3);
+		(mp->worksample).bitindex &= 7;
+	}
+	return rval;
 }
 
 unsigned int get1bit(struct mpstr *mp)
 {
-  unsigned char rval;
+	unsigned char rval;
 
-  rval = *((mp->worksample).wordpointer) << (mp->worksample).bitindex;
+	rval = *((mp->worksample).wordpointer) << (mp->worksample).bitindex;
 
-  (mp->worksample).bitindex++;
-  (mp->worksample).wordpointer += ((mp->worksample).bitindex>>3);
-  (mp->worksample).bitindex &= 7;
+	(mp->worksample).bitindex++;
+	(mp->worksample).wordpointer += ((mp->worksample).bitindex >> 3);
+	(mp->worksample).bitindex &= 7;
 
-  return rval>>7;
+	return rval >> 7;
 }
-
-
-
diff --git a/src/mod/formats/mod_shout/dct64_i386.c b/src/mod/formats/mod_shout/dct64_i386.c
index c6b5d886c8..8140b9eb13 100644
--- a/src/mod/formats/mod_shout/dct64_i386.c
+++ b/src/mod/formats/mod_shout/dct64_i386.c
@@ -13,323 +13,322 @@
  * the call via dct64 is a trick to force GCC to use
  * (new) registers for the b1,b2 pointer to the bufs[xx] field
  */
-void dct64(real *a,real *b,real *c);
+void dct64(real * a, real * b, real * c);
 
-static void dct64_1(real *out0,real *out1,real *b1,real *b2,real *samples)
+static void dct64_1(real * out0, real * out1, real * b1, real * b2, real * samples)
 {
- {
-  register real *costab = pnts[0];
+	{
+		register real *costab = pnts[0];
 
-  b1[0x00] = samples[0x00] + samples[0x1F];
-  b1[0x01] = samples[0x01] + samples[0x1E];
-  b1[0x1F] = (samples[0x00] - samples[0x1F]) * costab[0x0];
-  b1[0x1E] = (samples[0x01] - samples[0x1E]) * costab[0x1];
+		b1[0x00] = samples[0x00] + samples[0x1F];
+		b1[0x01] = samples[0x01] + samples[0x1E];
+		b1[0x1F] = (samples[0x00] - samples[0x1F]) * costab[0x0];
+		b1[0x1E] = (samples[0x01] - samples[0x1E]) * costab[0x1];
 
-  b1[0x02] = samples[0x02] + samples[0x1D];
-  b1[0x03] = samples[0x03] + samples[0x1C];
-  b1[0x1D] = (samples[0x02] - samples[0x1D]) * costab[0x2];
-  b1[0x1C] = (samples[0x03] - samples[0x1C]) * costab[0x3];
+		b1[0x02] = samples[0x02] + samples[0x1D];
+		b1[0x03] = samples[0x03] + samples[0x1C];
+		b1[0x1D] = (samples[0x02] - samples[0x1D]) * costab[0x2];
+		b1[0x1C] = (samples[0x03] - samples[0x1C]) * costab[0x3];
 
-  b1[0x04] = samples[0x04] + samples[0x1B];
-  b1[0x05] = samples[0x05] + samples[0x1A];
-  b1[0x1B] = (samples[0x04] - samples[0x1B]) * costab[0x4];
-  b1[0x1A] = (samples[0x05] - samples[0x1A]) * costab[0x5];
+		b1[0x04] = samples[0x04] + samples[0x1B];
+		b1[0x05] = samples[0x05] + samples[0x1A];
+		b1[0x1B] = (samples[0x04] - samples[0x1B]) * costab[0x4];
+		b1[0x1A] = (samples[0x05] - samples[0x1A]) * costab[0x5];
 
-  b1[0x06] = samples[0x06] + samples[0x19];
-  b1[0x07] = samples[0x07] + samples[0x18];
-  b1[0x19] = (samples[0x06] - samples[0x19]) * costab[0x6];
-  b1[0x18] = (samples[0x07] - samples[0x18]) * costab[0x7];
+		b1[0x06] = samples[0x06] + samples[0x19];
+		b1[0x07] = samples[0x07] + samples[0x18];
+		b1[0x19] = (samples[0x06] - samples[0x19]) * costab[0x6];
+		b1[0x18] = (samples[0x07] - samples[0x18]) * costab[0x7];
 
-  b1[0x08] = samples[0x08] + samples[0x17];
-  b1[0x09] = samples[0x09] + samples[0x16];
-  b1[0x17] = (samples[0x08] - samples[0x17]) * costab[0x8];
-  b1[0x16] = (samples[0x09] - samples[0x16]) * costab[0x9];
+		b1[0x08] = samples[0x08] + samples[0x17];
+		b1[0x09] = samples[0x09] + samples[0x16];
+		b1[0x17] = (samples[0x08] - samples[0x17]) * costab[0x8];
+		b1[0x16] = (samples[0x09] - samples[0x16]) * costab[0x9];
 
-  b1[0x0A] = samples[0x0A] + samples[0x15];
-  b1[0x0B] = samples[0x0B] + samples[0x14];
-  b1[0x15] = (samples[0x0A] - samples[0x15]) * costab[0xA];
-  b1[0x14] = (samples[0x0B] - samples[0x14]) * costab[0xB];
+		b1[0x0A] = samples[0x0A] + samples[0x15];
+		b1[0x0B] = samples[0x0B] + samples[0x14];
+		b1[0x15] = (samples[0x0A] - samples[0x15]) * costab[0xA];
+		b1[0x14] = (samples[0x0B] - samples[0x14]) * costab[0xB];
 
-  b1[0x0C] = samples[0x0C] + samples[0x13];
-  b1[0x0D] = samples[0x0D] + samples[0x12];
-  b1[0x13] = (samples[0x0C] - samples[0x13]) * costab[0xC];
-  b1[0x12] = (samples[0x0D] - samples[0x12]) * costab[0xD];
+		b1[0x0C] = samples[0x0C] + samples[0x13];
+		b1[0x0D] = samples[0x0D] + samples[0x12];
+		b1[0x13] = (samples[0x0C] - samples[0x13]) * costab[0xC];
+		b1[0x12] = (samples[0x0D] - samples[0x12]) * costab[0xD];
 
-  b1[0x0E] = samples[0x0E] + samples[0x11];
-  b1[0x0F] = samples[0x0F] + samples[0x10];
-  b1[0x11] = (samples[0x0E] - samples[0x11]) * costab[0xE];
-  b1[0x10] = (samples[0x0F] - samples[0x10]) * costab[0xF];
+		b1[0x0E] = samples[0x0E] + samples[0x11];
+		b1[0x0F] = samples[0x0F] + samples[0x10];
+		b1[0x11] = (samples[0x0E] - samples[0x11]) * costab[0xE];
+		b1[0x10] = (samples[0x0F] - samples[0x10]) * costab[0xF];
 
- }
+	}
 
 
- {
-  register real *costab = pnts[1];
+	{
+		register real *costab = pnts[1];
 
-  b2[0x00] = b1[0x00] + b1[0x0F]; 
-  b2[0x01] = b1[0x01] + b1[0x0E]; 
-  b2[0x0F] = (b1[0x00] - b1[0x0F]) * costab[0];
-  b2[0x0E] = (b1[0x01] - b1[0x0E]) * costab[1];
+		b2[0x00] = b1[0x00] + b1[0x0F];
+		b2[0x01] = b1[0x01] + b1[0x0E];
+		b2[0x0F] = (b1[0x00] - b1[0x0F]) * costab[0];
+		b2[0x0E] = (b1[0x01] - b1[0x0E]) * costab[1];
 
-  b2[0x02] = b1[0x02] + b1[0x0D]; 
-  b2[0x03] = b1[0x03] + b1[0x0C]; 
-  b2[0x0D] = (b1[0x02] - b1[0x0D]) * costab[2];
-  b2[0x0C] = (b1[0x03] - b1[0x0C]) * costab[3];
+		b2[0x02] = b1[0x02] + b1[0x0D];
+		b2[0x03] = b1[0x03] + b1[0x0C];
+		b2[0x0D] = (b1[0x02] - b1[0x0D]) * costab[2];
+		b2[0x0C] = (b1[0x03] - b1[0x0C]) * costab[3];
 
-  b2[0x04] = b1[0x04] + b1[0x0B]; 
-  b2[0x05] = b1[0x05] + b1[0x0A]; 
-  b2[0x0B] = (b1[0x04] - b1[0x0B]) * costab[4];
-  b2[0x0A] = (b1[0x05] - b1[0x0A]) * costab[5];
+		b2[0x04] = b1[0x04] + b1[0x0B];
+		b2[0x05] = b1[0x05] + b1[0x0A];
+		b2[0x0B] = (b1[0x04] - b1[0x0B]) * costab[4];
+		b2[0x0A] = (b1[0x05] - b1[0x0A]) * costab[5];
 
-  b2[0x06] = b1[0x06] + b1[0x09]; 
-  b2[0x07] = b1[0x07] + b1[0x08]; 
-  b2[0x09] = (b1[0x06] - b1[0x09]) * costab[6];
-  b2[0x08] = (b1[0x07] - b1[0x08]) * costab[7];
+		b2[0x06] = b1[0x06] + b1[0x09];
+		b2[0x07] = b1[0x07] + b1[0x08];
+		b2[0x09] = (b1[0x06] - b1[0x09]) * costab[6];
+		b2[0x08] = (b1[0x07] - b1[0x08]) * costab[7];
 
-  /* */
+		/* */
 
-  b2[0x10] = b1[0x10] + b1[0x1F];
-  b2[0x11] = b1[0x11] + b1[0x1E];
-  b2[0x1F] = (b1[0x1F] - b1[0x10]) * costab[0];
-  b2[0x1E] = (b1[0x1E] - b1[0x11]) * costab[1];
+		b2[0x10] = b1[0x10] + b1[0x1F];
+		b2[0x11] = b1[0x11] + b1[0x1E];
+		b2[0x1F] = (b1[0x1F] - b1[0x10]) * costab[0];
+		b2[0x1E] = (b1[0x1E] - b1[0x11]) * costab[1];
 
-  b2[0x12] = b1[0x12] + b1[0x1D];
-  b2[0x13] = b1[0x13] + b1[0x1C];
-  b2[0x1D] = (b1[0x1D] - b1[0x12]) * costab[2];
-  b2[0x1C] = (b1[0x1C] - b1[0x13]) * costab[3];
+		b2[0x12] = b1[0x12] + b1[0x1D];
+		b2[0x13] = b1[0x13] + b1[0x1C];
+		b2[0x1D] = (b1[0x1D] - b1[0x12]) * costab[2];
+		b2[0x1C] = (b1[0x1C] - b1[0x13]) * costab[3];
 
-  b2[0x14] = b1[0x14] + b1[0x1B];
-  b2[0x15] = b1[0x15] + b1[0x1A];
-  b2[0x1B] = (b1[0x1B] - b1[0x14]) * costab[4];
-  b2[0x1A] = (b1[0x1A] - b1[0x15]) * costab[5];
+		b2[0x14] = b1[0x14] + b1[0x1B];
+		b2[0x15] = b1[0x15] + b1[0x1A];
+		b2[0x1B] = (b1[0x1B] - b1[0x14]) * costab[4];
+		b2[0x1A] = (b1[0x1A] - b1[0x15]) * costab[5];
 
-  b2[0x16] = b1[0x16] + b1[0x19];
-  b2[0x17] = b1[0x17] + b1[0x18];
-  b2[0x19] = (b1[0x19] - b1[0x16]) * costab[6];
-  b2[0x18] = (b1[0x18] - b1[0x17]) * costab[7];
- }
+		b2[0x16] = b1[0x16] + b1[0x19];
+		b2[0x17] = b1[0x17] + b1[0x18];
+		b2[0x19] = (b1[0x19] - b1[0x16]) * costab[6];
+		b2[0x18] = (b1[0x18] - b1[0x17]) * costab[7];
+	}
 
- {
-  register real *costab = pnts[2];
+	{
+		register real *costab = pnts[2];
 
-  b1[0x00] = b2[0x00] + b2[0x07];
-  b1[0x07] = (b2[0x00] - b2[0x07]) * costab[0];
-  b1[0x01] = b2[0x01] + b2[0x06];
-  b1[0x06] = (b2[0x01] - b2[0x06]) * costab[1];
-  b1[0x02] = b2[0x02] + b2[0x05];
-  b1[0x05] = (b2[0x02] - b2[0x05]) * costab[2];
-  b1[0x03] = b2[0x03] + b2[0x04];
-  b1[0x04] = (b2[0x03] - b2[0x04]) * costab[3];
+		b1[0x00] = b2[0x00] + b2[0x07];
+		b1[0x07] = (b2[0x00] - b2[0x07]) * costab[0];
+		b1[0x01] = b2[0x01] + b2[0x06];
+		b1[0x06] = (b2[0x01] - b2[0x06]) * costab[1];
+		b1[0x02] = b2[0x02] + b2[0x05];
+		b1[0x05] = (b2[0x02] - b2[0x05]) * costab[2];
+		b1[0x03] = b2[0x03] + b2[0x04];
+		b1[0x04] = (b2[0x03] - b2[0x04]) * costab[3];
 
-  b1[0x08] = b2[0x08] + b2[0x0F];
-  b1[0x0F] = (b2[0x0F] - b2[0x08]) * costab[0];
-  b1[0x09] = b2[0x09] + b2[0x0E];
-  b1[0x0E] = (b2[0x0E] - b2[0x09]) * costab[1];
-  b1[0x0A] = b2[0x0A] + b2[0x0D];
-  b1[0x0D] = (b2[0x0D] - b2[0x0A]) * costab[2];
-  b1[0x0B] = b2[0x0B] + b2[0x0C];
-  b1[0x0C] = (b2[0x0C] - b2[0x0B]) * costab[3];
+		b1[0x08] = b2[0x08] + b2[0x0F];
+		b1[0x0F] = (b2[0x0F] - b2[0x08]) * costab[0];
+		b1[0x09] = b2[0x09] + b2[0x0E];
+		b1[0x0E] = (b2[0x0E] - b2[0x09]) * costab[1];
+		b1[0x0A] = b2[0x0A] + b2[0x0D];
+		b1[0x0D] = (b2[0x0D] - b2[0x0A]) * costab[2];
+		b1[0x0B] = b2[0x0B] + b2[0x0C];
+		b1[0x0C] = (b2[0x0C] - b2[0x0B]) * costab[3];
 
-  b1[0x10] = b2[0x10] + b2[0x17];
-  b1[0x17] = (b2[0x10] - b2[0x17]) * costab[0];
-  b1[0x11] = b2[0x11] + b2[0x16];
-  b1[0x16] = (b2[0x11] - b2[0x16]) * costab[1];
-  b1[0x12] = b2[0x12] + b2[0x15];
-  b1[0x15] = (b2[0x12] - b2[0x15]) * costab[2];
-  b1[0x13] = b2[0x13] + b2[0x14];
-  b1[0x14] = (b2[0x13] - b2[0x14]) * costab[3];
+		b1[0x10] = b2[0x10] + b2[0x17];
+		b1[0x17] = (b2[0x10] - b2[0x17]) * costab[0];
+		b1[0x11] = b2[0x11] + b2[0x16];
+		b1[0x16] = (b2[0x11] - b2[0x16]) * costab[1];
+		b1[0x12] = b2[0x12] + b2[0x15];
+		b1[0x15] = (b2[0x12] - b2[0x15]) * costab[2];
+		b1[0x13] = b2[0x13] + b2[0x14];
+		b1[0x14] = (b2[0x13] - b2[0x14]) * costab[3];
 
-  b1[0x18] = b2[0x18] + b2[0x1F];
-  b1[0x1F] = (b2[0x1F] - b2[0x18]) * costab[0];
-  b1[0x19] = b2[0x19] + b2[0x1E];
-  b1[0x1E] = (b2[0x1E] - b2[0x19]) * costab[1];
-  b1[0x1A] = b2[0x1A] + b2[0x1D];
-  b1[0x1D] = (b2[0x1D] - b2[0x1A]) * costab[2];
-  b1[0x1B] = b2[0x1B] + b2[0x1C];
-  b1[0x1C] = (b2[0x1C] - b2[0x1B]) * costab[3];
- }
+		b1[0x18] = b2[0x18] + b2[0x1F];
+		b1[0x1F] = (b2[0x1F] - b2[0x18]) * costab[0];
+		b1[0x19] = b2[0x19] + b2[0x1E];
+		b1[0x1E] = (b2[0x1E] - b2[0x19]) * costab[1];
+		b1[0x1A] = b2[0x1A] + b2[0x1D];
+		b1[0x1D] = (b2[0x1D] - b2[0x1A]) * costab[2];
+		b1[0x1B] = b2[0x1B] + b2[0x1C];
+		b1[0x1C] = (b2[0x1C] - b2[0x1B]) * costab[3];
+	}
 
- {
-  register real const cos0 = pnts[3][0];
-  register real const cos1 = pnts[3][1];
+	{
+		register real const cos0 = pnts[3][0];
+		register real const cos1 = pnts[3][1];
 
-  b2[0x00] = b1[0x00] + b1[0x03];
-  b2[0x03] = (b1[0x00] - b1[0x03]) * cos0;
-  b2[0x01] = b1[0x01] + b1[0x02];
-  b2[0x02] = (b1[0x01] - b1[0x02]) * cos1;
+		b2[0x00] = b1[0x00] + b1[0x03];
+		b2[0x03] = (b1[0x00] - b1[0x03]) * cos0;
+		b2[0x01] = b1[0x01] + b1[0x02];
+		b2[0x02] = (b1[0x01] - b1[0x02]) * cos1;
 
-  b2[0x04] = b1[0x04] + b1[0x07];
-  b2[0x07] = (b1[0x07] - b1[0x04]) * cos0;
-  b2[0x05] = b1[0x05] + b1[0x06];
-  b2[0x06] = (b1[0x06] - b1[0x05]) * cos1;
+		b2[0x04] = b1[0x04] + b1[0x07];
+		b2[0x07] = (b1[0x07] - b1[0x04]) * cos0;
+		b2[0x05] = b1[0x05] + b1[0x06];
+		b2[0x06] = (b1[0x06] - b1[0x05]) * cos1;
 
-  b2[0x08] = b1[0x08] + b1[0x0B];
-  b2[0x0B] = (b1[0x08] - b1[0x0B]) * cos0;
-  b2[0x09] = b1[0x09] + b1[0x0A];
-  b2[0x0A] = (b1[0x09] - b1[0x0A]) * cos1;
-  
-  b2[0x0C] = b1[0x0C] + b1[0x0F];
-  b2[0x0F] = (b1[0x0F] - b1[0x0C]) * cos0;
-  b2[0x0D] = b1[0x0D] + b1[0x0E];
-  b2[0x0E] = (b1[0x0E] - b1[0x0D]) * cos1;
+		b2[0x08] = b1[0x08] + b1[0x0B];
+		b2[0x0B] = (b1[0x08] - b1[0x0B]) * cos0;
+		b2[0x09] = b1[0x09] + b1[0x0A];
+		b2[0x0A] = (b1[0x09] - b1[0x0A]) * cos1;
 
-  b2[0x10] = b1[0x10] + b1[0x13];
-  b2[0x13] = (b1[0x10] - b1[0x13]) * cos0;
-  b2[0x11] = b1[0x11] + b1[0x12];
-  b2[0x12] = (b1[0x11] - b1[0x12]) * cos1;
+		b2[0x0C] = b1[0x0C] + b1[0x0F];
+		b2[0x0F] = (b1[0x0F] - b1[0x0C]) * cos0;
+		b2[0x0D] = b1[0x0D] + b1[0x0E];
+		b2[0x0E] = (b1[0x0E] - b1[0x0D]) * cos1;
 
-  b2[0x14] = b1[0x14] + b1[0x17];
-  b2[0x17] = (b1[0x17] - b1[0x14]) * cos0;
-  b2[0x15] = b1[0x15] + b1[0x16];
-  b2[0x16] = (b1[0x16] - b1[0x15]) * cos1;
+		b2[0x10] = b1[0x10] + b1[0x13];
+		b2[0x13] = (b1[0x10] - b1[0x13]) * cos0;
+		b2[0x11] = b1[0x11] + b1[0x12];
+		b2[0x12] = (b1[0x11] - b1[0x12]) * cos1;
 
-  b2[0x18] = b1[0x18] + b1[0x1B];
-  b2[0x1B] = (b1[0x18] - b1[0x1B]) * cos0;
-  b2[0x19] = b1[0x19] + b1[0x1A];
-  b2[0x1A] = (b1[0x19] - b1[0x1A]) * cos1;
+		b2[0x14] = b1[0x14] + b1[0x17];
+		b2[0x17] = (b1[0x17] - b1[0x14]) * cos0;
+		b2[0x15] = b1[0x15] + b1[0x16];
+		b2[0x16] = (b1[0x16] - b1[0x15]) * cos1;
 
-  b2[0x1C] = b1[0x1C] + b1[0x1F];
-  b2[0x1F] = (b1[0x1F] - b1[0x1C]) * cos0;
-  b2[0x1D] = b1[0x1D] + b1[0x1E];
-  b2[0x1E] = (b1[0x1E] - b1[0x1D]) * cos1;
- }
+		b2[0x18] = b1[0x18] + b1[0x1B];
+		b2[0x1B] = (b1[0x18] - b1[0x1B]) * cos0;
+		b2[0x19] = b1[0x19] + b1[0x1A];
+		b2[0x1A] = (b1[0x19] - b1[0x1A]) * cos1;
 
- {
-  register real const cos0 = pnts[4][0];
+		b2[0x1C] = b1[0x1C] + b1[0x1F];
+		b2[0x1F] = (b1[0x1F] - b1[0x1C]) * cos0;
+		b2[0x1D] = b1[0x1D] + b1[0x1E];
+		b2[0x1E] = (b1[0x1E] - b1[0x1D]) * cos1;
+	}
 
-  b1[0x00] = b2[0x00] + b2[0x01];
-  b1[0x01] = (b2[0x00] - b2[0x01]) * cos0;
-  b1[0x02] = b2[0x02] + b2[0x03];
-  b1[0x03] = (b2[0x03] - b2[0x02]) * cos0;
-  b1[0x02] += b1[0x03];
+	{
+		register real const cos0 = pnts[4][0];
 
-  b1[0x04] = b2[0x04] + b2[0x05];
-  b1[0x05] = (b2[0x04] - b2[0x05]) * cos0;
-  b1[0x06] = b2[0x06] + b2[0x07];
-  b1[0x07] = (b2[0x07] - b2[0x06]) * cos0;
-  b1[0x06] += b1[0x07];
-  b1[0x04] += b1[0x06];
-  b1[0x06] += b1[0x05];
-  b1[0x05] += b1[0x07];
+		b1[0x00] = b2[0x00] + b2[0x01];
+		b1[0x01] = (b2[0x00] - b2[0x01]) * cos0;
+		b1[0x02] = b2[0x02] + b2[0x03];
+		b1[0x03] = (b2[0x03] - b2[0x02]) * cos0;
+		b1[0x02] += b1[0x03];
 
-  b1[0x08] = b2[0x08] + b2[0x09];
-  b1[0x09] = (b2[0x08] - b2[0x09]) * cos0;
-  b1[0x0A] = b2[0x0A] + b2[0x0B];
-  b1[0x0B] = (b2[0x0B] - b2[0x0A]) * cos0;
-  b1[0x0A] += b1[0x0B];
+		b1[0x04] = b2[0x04] + b2[0x05];
+		b1[0x05] = (b2[0x04] - b2[0x05]) * cos0;
+		b1[0x06] = b2[0x06] + b2[0x07];
+		b1[0x07] = (b2[0x07] - b2[0x06]) * cos0;
+		b1[0x06] += b1[0x07];
+		b1[0x04] += b1[0x06];
+		b1[0x06] += b1[0x05];
+		b1[0x05] += b1[0x07];
 
-  b1[0x0C] = b2[0x0C] + b2[0x0D];
-  b1[0x0D] = (b2[0x0C] - b2[0x0D]) * cos0;
-  b1[0x0E] = b2[0x0E] + b2[0x0F];
-  b1[0x0F] = (b2[0x0F] - b2[0x0E]) * cos0;
-  b1[0x0E] += b1[0x0F];
-  b1[0x0C] += b1[0x0E];
-  b1[0x0E] += b1[0x0D];
-  b1[0x0D] += b1[0x0F];
+		b1[0x08] = b2[0x08] + b2[0x09];
+		b1[0x09] = (b2[0x08] - b2[0x09]) * cos0;
+		b1[0x0A] = b2[0x0A] + b2[0x0B];
+		b1[0x0B] = (b2[0x0B] - b2[0x0A]) * cos0;
+		b1[0x0A] += b1[0x0B];
 
-  b1[0x10] = b2[0x10] + b2[0x11];
-  b1[0x11] = (b2[0x10] - b2[0x11]) * cos0;
-  b1[0x12] = b2[0x12] + b2[0x13];
-  b1[0x13] = (b2[0x13] - b2[0x12]) * cos0;
-  b1[0x12] += b1[0x13];
+		b1[0x0C] = b2[0x0C] + b2[0x0D];
+		b1[0x0D] = (b2[0x0C] - b2[0x0D]) * cos0;
+		b1[0x0E] = b2[0x0E] + b2[0x0F];
+		b1[0x0F] = (b2[0x0F] - b2[0x0E]) * cos0;
+		b1[0x0E] += b1[0x0F];
+		b1[0x0C] += b1[0x0E];
+		b1[0x0E] += b1[0x0D];
+		b1[0x0D] += b1[0x0F];
 
-  b1[0x14] = b2[0x14] + b2[0x15];
-  b1[0x15] = (b2[0x14] - b2[0x15]) * cos0;
-  b1[0x16] = b2[0x16] + b2[0x17];
-  b1[0x17] = (b2[0x17] - b2[0x16]) * cos0;
-  b1[0x16] += b1[0x17];
-  b1[0x14] += b1[0x16];
-  b1[0x16] += b1[0x15];
-  b1[0x15] += b1[0x17];
+		b1[0x10] = b2[0x10] + b2[0x11];
+		b1[0x11] = (b2[0x10] - b2[0x11]) * cos0;
+		b1[0x12] = b2[0x12] + b2[0x13];
+		b1[0x13] = (b2[0x13] - b2[0x12]) * cos0;
+		b1[0x12] += b1[0x13];
 
-  b1[0x18] = b2[0x18] + b2[0x19];
-  b1[0x19] = (b2[0x18] - b2[0x19]) * cos0;
-  b1[0x1A] = b2[0x1A] + b2[0x1B];
-  b1[0x1B] = (b2[0x1B] - b2[0x1A]) * cos0;
-  b1[0x1A] += b1[0x1B];
+		b1[0x14] = b2[0x14] + b2[0x15];
+		b1[0x15] = (b2[0x14] - b2[0x15]) * cos0;
+		b1[0x16] = b2[0x16] + b2[0x17];
+		b1[0x17] = (b2[0x17] - b2[0x16]) * cos0;
+		b1[0x16] += b1[0x17];
+		b1[0x14] += b1[0x16];
+		b1[0x16] += b1[0x15];
+		b1[0x15] += b1[0x17];
 
-  b1[0x1C] = b2[0x1C] + b2[0x1D];
-  b1[0x1D] = (b2[0x1C] - b2[0x1D]) * cos0;
-  b1[0x1E] = b2[0x1E] + b2[0x1F];
-  b1[0x1F] = (b2[0x1F] - b2[0x1E]) * cos0;
-  b1[0x1E] += b1[0x1F];
-  b1[0x1C] += b1[0x1E];
-  b1[0x1E] += b1[0x1D];
-  b1[0x1D] += b1[0x1F];
- }
+		b1[0x18] = b2[0x18] + b2[0x19];
+		b1[0x19] = (b2[0x18] - b2[0x19]) * cos0;
+		b1[0x1A] = b2[0x1A] + b2[0x1B];
+		b1[0x1B] = (b2[0x1B] - b2[0x1A]) * cos0;
+		b1[0x1A] += b1[0x1B];
 
- out0[0x10*16] = b1[0x00];
- out0[0x10*12] = b1[0x04];
- out0[0x10* 8] = b1[0x02];
- out0[0x10* 4] = b1[0x06];
- out0[0x10* 0] = b1[0x01];
- out1[0x10* 0] = b1[0x01];
- out1[0x10* 4] = b1[0x05];
- out1[0x10* 8] = b1[0x03];
- out1[0x10*12] = b1[0x07];
+		b1[0x1C] = b2[0x1C] + b2[0x1D];
+		b1[0x1D] = (b2[0x1C] - b2[0x1D]) * cos0;
+		b1[0x1E] = b2[0x1E] + b2[0x1F];
+		b1[0x1F] = (b2[0x1F] - b2[0x1E]) * cos0;
+		b1[0x1E] += b1[0x1F];
+		b1[0x1C] += b1[0x1E];
+		b1[0x1E] += b1[0x1D];
+		b1[0x1D] += b1[0x1F];
+	}
+
+	out0[0x10 * 16] = b1[0x00];
+	out0[0x10 * 12] = b1[0x04];
+	out0[0x10 * 8] = b1[0x02];
+	out0[0x10 * 4] = b1[0x06];
+	out0[0x10 * 0] = b1[0x01];
+	out1[0x10 * 0] = b1[0x01];
+	out1[0x10 * 4] = b1[0x05];
+	out1[0x10 * 8] = b1[0x03];
+	out1[0x10 * 12] = b1[0x07];
 
 #if 1
- out0[0x10*14] = b1[0x08] + b1[0x0C];
- out0[0x10*10] = b1[0x0C] + b1[0x0a];
- out0[0x10* 6] = b1[0x0A] + b1[0x0E];
- out0[0x10* 2] = b1[0x0E] + b1[0x09];
- out1[0x10* 2] = b1[0x09] + b1[0x0D];
- out1[0x10* 6] = b1[0x0D] + b1[0x0B];
- out1[0x10*10] = b1[0x0B] + b1[0x0F];
- out1[0x10*14] = b1[0x0F];
+	out0[0x10 * 14] = b1[0x08] + b1[0x0C];
+	out0[0x10 * 10] = b1[0x0C] + b1[0x0a];
+	out0[0x10 * 6] = b1[0x0A] + b1[0x0E];
+	out0[0x10 * 2] = b1[0x0E] + b1[0x09];
+	out1[0x10 * 2] = b1[0x09] + b1[0x0D];
+	out1[0x10 * 6] = b1[0x0D] + b1[0x0B];
+	out1[0x10 * 10] = b1[0x0B] + b1[0x0F];
+	out1[0x10 * 14] = b1[0x0F];
 #else
- b1[0x08] += b1[0x0C];
- out0[0x10*14] = b1[0x08];
- b1[0x0C] += b1[0x0a];
- out0[0x10*10] = b1[0x0C];
- b1[0x0A] += b1[0x0E];
- out0[0x10* 6] = b1[0x0A];
- b1[0x0E] += b1[0x09];
- out0[0x10* 2] = b1[0x0E];
- b1[0x09] += b1[0x0D];
- out1[0x10* 2] = b1[0x09];
- b1[0x0D] += b1[0x0B];
- out1[0x10* 6] = b1[0x0D];
- b1[0x0B] += b1[0x0F];
- out1[0x10*10] = b1[0x0B];
- out1[0x10*14] = b1[0x0F];
+	b1[0x08] += b1[0x0C];
+	out0[0x10 * 14] = b1[0x08];
+	b1[0x0C] += b1[0x0a];
+	out0[0x10 * 10] = b1[0x0C];
+	b1[0x0A] += b1[0x0E];
+	out0[0x10 * 6] = b1[0x0A];
+	b1[0x0E] += b1[0x09];
+	out0[0x10 * 2] = b1[0x0E];
+	b1[0x09] += b1[0x0D];
+	out1[0x10 * 2] = b1[0x09];
+	b1[0x0D] += b1[0x0B];
+	out1[0x10 * 6] = b1[0x0D];
+	b1[0x0B] += b1[0x0F];
+	out1[0x10 * 10] = b1[0x0B];
+	out1[0x10 * 14] = b1[0x0F];
 #endif
 
- { 
- real tmp;
- tmp = b1[0x18] + b1[0x1C];
- out0[0x10*15] = tmp + b1[0x10];
- out0[0x10*13] = tmp + b1[0x14];
- tmp = b1[0x1C] + b1[0x1A];
- out0[0x10*11] = tmp + b1[0x14];
- out0[0x10* 9] = tmp + b1[0x12];
- tmp = b1[0x1A] + b1[0x1E];
- out0[0x10* 7] = tmp + b1[0x12];
- out0[0x10* 5] = tmp + b1[0x16];
- tmp = b1[0x1E] + b1[0x19];
- out0[0x10* 3] = tmp + b1[0x16];
- out0[0x10* 1] = tmp + b1[0x11];
- tmp = b1[0x19] + b1[0x1D];
- out1[0x10* 1] = tmp + b1[0x11];
- out1[0x10* 3] = tmp + b1[0x15]; 
- tmp = b1[0x1D] + b1[0x1B];
- out1[0x10* 5] = tmp + b1[0x15];
- out1[0x10* 7] = tmp + b1[0x13];
- tmp = b1[0x1B] + b1[0x1F];
- out1[0x10* 9] = tmp + b1[0x13];
- out1[0x10*11] = tmp + b1[0x17];
- out1[0x10*13] = b1[0x17] + b1[0x1F];
- out1[0x10*15] = b1[0x1F];
- }
+	{
+		real tmp;
+		tmp = b1[0x18] + b1[0x1C];
+		out0[0x10 * 15] = tmp + b1[0x10];
+		out0[0x10 * 13] = tmp + b1[0x14];
+		tmp = b1[0x1C] + b1[0x1A];
+		out0[0x10 * 11] = tmp + b1[0x14];
+		out0[0x10 * 9] = tmp + b1[0x12];
+		tmp = b1[0x1A] + b1[0x1E];
+		out0[0x10 * 7] = tmp + b1[0x12];
+		out0[0x10 * 5] = tmp + b1[0x16];
+		tmp = b1[0x1E] + b1[0x19];
+		out0[0x10 * 3] = tmp + b1[0x16];
+		out0[0x10 * 1] = tmp + b1[0x11];
+		tmp = b1[0x19] + b1[0x1D];
+		out1[0x10 * 1] = tmp + b1[0x11];
+		out1[0x10 * 3] = tmp + b1[0x15];
+		tmp = b1[0x1D] + b1[0x1B];
+		out1[0x10 * 5] = tmp + b1[0x15];
+		out1[0x10 * 7] = tmp + b1[0x13];
+		tmp = b1[0x1B] + b1[0x1F];
+		out1[0x10 * 9] = tmp + b1[0x13];
+		out1[0x10 * 11] = tmp + b1[0x17];
+		out1[0x10 * 13] = b1[0x17] + b1[0x1F];
+		out1[0x10 * 15] = b1[0x1F];
+	}
 }
 
 /*
  * the call via dct64 is a trick to force GCC to use
  * (new) registers for the b1,b2 pointer to the bufs[xx] field
  */
-void dct64(real *a,real *b,real *c)
+void dct64(real * a, real * b, real * c)
 {
-  real bufs[0x40];
-  dct64_1(a,b,bufs,bufs+0x20,c);
+	real bufs[0x40];
+	dct64_1(a, b, bufs, bufs + 0x20, c);
 }
-
diff --git a/src/mod/formats/mod_shout/decode_i386.c b/src/mod/formats/mod_shout/decode_i386.c
index 83e0544228..9f0c5431ab 100644
--- a/src/mod/formats/mod_shout/decode_i386.c
+++ b/src/mod/formats/mod_shout/decode_i386.c
@@ -25,129 +25,124 @@
   else if( (sum) < -32768.0) { *(samples) = -0x8000; (clip)++; } \
   else { *(samples) = sum; }
 
-int synth_1to1_mono(struct mpstr *mp,real *bandPtr,unsigned char *samples,int *pnt)
+int synth_1to1_mono(struct mpstr *mp, real * bandPtr, unsigned char *samples, int *pnt)
 {
-  short samples_tmp[64];
-  short *tmp1 = samples_tmp;
-  int i,ret;
-  int pnt1 = 0;
+	short samples_tmp[64];
+	short *tmp1 = samples_tmp;
+	int i, ret;
+	int pnt1 = 0;
 
-  ret = synth_1to1(mp,bandPtr,0,(unsigned char *) samples_tmp,&pnt1);
-  samples += *pnt;
+	ret = synth_1to1(mp, bandPtr, 0, (unsigned char *) samples_tmp, &pnt1);
+	samples += *pnt;
 
-  for(i=0;i<32;i++) {
-    *( (short *) samples) = *tmp1;
-    samples += 2;
-    tmp1 += 2;
-  }
-  *pnt += 64;
+	for (i = 0; i < 32; i++) {
+		*((short *) samples) = *tmp1;
+		samples += 2;
+		tmp1 += 2;
+	}
+	*pnt += 64;
 
-  return ret;
+	return ret;
 }
 
 
-int synth_1to1(struct mpstr *mp, real *bandPtr,int channel,unsigned char *out,int *pnt)
+int synth_1to1(struct mpstr *mp, real * bandPtr, int channel, unsigned char *out, int *pnt)
 {
-  static const int step = 2;
-  int bo;
-  short *samples = (short *) (out + *pnt);
+	static const int step = 2;
+	int bo;
+	short *samples = (short *) (out + *pnt);
 
-  real *b0,(*buf)[0x110];
-  int clip = 0; 
-  int bo1;
+	real *b0, (*buf)[0x110];
+	int clip = 0;
+	int bo1;
 
-  bo = mp->synth_bo;
+	bo = mp->synth_bo;
 
-  if(!channel) {
-    bo--;
-    bo &= 0xf;
-    buf = mp->synth_buffs[0];
-  }
-  else {
-    samples++;
-    buf = mp->synth_buffs[1];
-  }
+	if (!channel) {
+		bo--;
+		bo &= 0xf;
+		buf = mp->synth_buffs[0];
+	} else {
+		samples++;
+		buf = mp->synth_buffs[1];
+	}
 
-  if(bo & 0x1) {
-    b0 = buf[0];
-    bo1 = bo;
-    dct64(buf[1]+((bo+1)&0xf),buf[0]+bo,bandPtr);
-  }
-  else {
-    b0 = buf[1];
-    bo1 = bo+1;
-    dct64(buf[0]+bo,buf[1]+bo+1,bandPtr);
-  }
+	if (bo & 0x1) {
+		b0 = buf[0];
+		bo1 = bo;
+		dct64(buf[1] + ((bo + 1) & 0xf), buf[0] + bo, bandPtr);
+	} else {
+		b0 = buf[1];
+		bo1 = bo + 1;
+		dct64(buf[0] + bo, buf[1] + bo + 1, bandPtr);
+	}
 
-  mp->synth_bo = bo;
-  
-  {
-    register int j;
-    real *window = decwin + 16 - bo1;
+	mp->synth_bo = bo;
 
-    for (j=16;j;j--,b0+=0x10,window+=0x20,samples+=step)
-    {
-      real sum;
-      sum  = window[0x0] * b0[0x0];
-      sum -= window[0x1] * b0[0x1];
-      sum += window[0x2] * b0[0x2];
-      sum -= window[0x3] * b0[0x3];
-      sum += window[0x4] * b0[0x4];
-      sum -= window[0x5] * b0[0x5];
-      sum += window[0x6] * b0[0x6];
-      sum -= window[0x7] * b0[0x7];
-      sum += window[0x8] * b0[0x8];
-      sum -= window[0x9] * b0[0x9];
-      sum += window[0xA] * b0[0xA];
-      sum -= window[0xB] * b0[0xB];
-      sum += window[0xC] * b0[0xC];
-      sum -= window[0xD] * b0[0xD];
-      sum += window[0xE] * b0[0xE];
-      sum -= window[0xF] * b0[0xF];
+	{
+		register int j;
+		real *window = decwin + 16 - bo1;
 
-      WRITE_SAMPLE(samples,sum,clip);
-    }
+		for (j = 16; j; j--, b0 += 0x10, window += 0x20, samples += step) {
+			real sum;
+			sum = window[0x0] * b0[0x0];
+			sum -= window[0x1] * b0[0x1];
+			sum += window[0x2] * b0[0x2];
+			sum -= window[0x3] * b0[0x3];
+			sum += window[0x4] * b0[0x4];
+			sum -= window[0x5] * b0[0x5];
+			sum += window[0x6] * b0[0x6];
+			sum -= window[0x7] * b0[0x7];
+			sum += window[0x8] * b0[0x8];
+			sum -= window[0x9] * b0[0x9];
+			sum += window[0xA] * b0[0xA];
+			sum -= window[0xB] * b0[0xB];
+			sum += window[0xC] * b0[0xC];
+			sum -= window[0xD] * b0[0xD];
+			sum += window[0xE] * b0[0xE];
+			sum -= window[0xF] * b0[0xF];
 
-    {
-      real sum;
-      sum  = window[0x0] * b0[0x0];
-      sum += window[0x2] * b0[0x2];
-      sum += window[0x4] * b0[0x4];
-      sum += window[0x6] * b0[0x6];
-      sum += window[0x8] * b0[0x8];
-      sum += window[0xA] * b0[0xA];
-      sum += window[0xC] * b0[0xC];
-      sum += window[0xE] * b0[0xE];
-      WRITE_SAMPLE(samples,sum,clip);
-      b0-=0x10,window-=0x20,samples+=step;
-    }
-    window += bo1<<1;
+			WRITE_SAMPLE(samples, sum, clip);
+		}
 
-    for (j=15;j;j--,b0-=0x10,window-=0x20,samples+=step)
-    {
-      real sum;
-      sum = -window[-0x1] * b0[0x0];
-      sum -= window[-0x2] * b0[0x1];
-      sum -= window[-0x3] * b0[0x2];
-      sum -= window[-0x4] * b0[0x3];
-      sum -= window[-0x5] * b0[0x4];
-      sum -= window[-0x6] * b0[0x5];
-      sum -= window[-0x7] * b0[0x6];
-      sum -= window[-0x8] * b0[0x7];
-      sum -= window[-0x9] * b0[0x8];
-      sum -= window[-0xA] * b0[0x9];
-      sum -= window[-0xB] * b0[0xA];
-      sum -= window[-0xC] * b0[0xB];
-      sum -= window[-0xD] * b0[0xC];
-      sum -= window[-0xE] * b0[0xD];
-      sum -= window[-0xF] * b0[0xE];
-      sum -= window[-0x0] * b0[0xF];
+		{
+			real sum;
+			sum = window[0x0] * b0[0x0];
+			sum += window[0x2] * b0[0x2];
+			sum += window[0x4] * b0[0x4];
+			sum += window[0x6] * b0[0x6];
+			sum += window[0x8] * b0[0x8];
+			sum += window[0xA] * b0[0xA];
+			sum += window[0xC] * b0[0xC];
+			sum += window[0xE] * b0[0xE];
+			WRITE_SAMPLE(samples, sum, clip);
+			b0 -= 0x10, window -= 0x20, samples += step;
+		}
+		window += bo1 << 1;
 
-      WRITE_SAMPLE(samples,sum,clip);
-    }
-  }
-  *pnt += 128;
+		for (j = 15; j; j--, b0 -= 0x10, window -= 0x20, samples += step) {
+			real sum;
+			sum = -window[-0x1] * b0[0x0];
+			sum -= window[-0x2] * b0[0x1];
+			sum -= window[-0x3] * b0[0x2];
+			sum -= window[-0x4] * b0[0x3];
+			sum -= window[-0x5] * b0[0x4];
+			sum -= window[-0x6] * b0[0x5];
+			sum -= window[-0x7] * b0[0x6];
+			sum -= window[-0x8] * b0[0x7];
+			sum -= window[-0x9] * b0[0x8];
+			sum -= window[-0xA] * b0[0x9];
+			sum -= window[-0xB] * b0[0xA];
+			sum -= window[-0xC] * b0[0xB];
+			sum -= window[-0xD] * b0[0xC];
+			sum -= window[-0xE] * b0[0xD];
+			sum -= window[-0xF] * b0[0xE];
+			sum -= window[-0x0] * b0[0xF];
 
-  return clip;
+			WRITE_SAMPLE(samples, sum, clip);
+		}
+	}
+	*pnt += 128;
+
+	return clip;
 }
-
diff --git a/src/mod/formats/mod_shout/decode_ntom.c b/src/mod/formats/mod_shout/decode_ntom.c
index a8ad097929..59c11d0b85 100644
--- a/src/mod/formats/mod_shout/decode_ntom.c
+++ b/src/mod/formats/mod_shout/decode_ntom.c
@@ -21,198 +21,191 @@
   else { *(samples) = sum; }
 
 #define NTOM_MUL (32768)
-static unsigned long ntom_val[2] = { NTOM_MUL>>1,NTOM_MUL>>1 };
+static unsigned long ntom_val[2] = { NTOM_MUL >> 1, NTOM_MUL >> 1 };
 static unsigned long ntom_step = NTOM_MUL;
 
 
-int synth_ntom_set_step(long m,long n)
+int synth_ntom_set_step(long m, long n)
 {
-	if(param.verbose > 1)
-		debug_printf("Init rate converter: %ld->%ld\n",m,n);
+	if (param.verbose > 1)
+		debug_printf("Init rate converter: %ld->%ld\n", m, n);
 
-	if(n >= 96000 || m >= 96000 || m == 0 || n == 0) {
-		debug_printf("NtoM converter: %d illegal rates\n",  __LINE__);
+	if (n >= 96000 || m >= 96000 || m == 0 || n == 0) {
+		debug_printf("NtoM converter: %d illegal rates\n", __LINE__);
 		return (1);
 	}
 
 	n *= NTOM_MUL;
 	ntom_step = n / m;
 
-	if(ntom_step > 8*NTOM_MUL) {
-		debug_printf("%d max. 1:8 conversion allowed!\n",  __LINE__);
+	if (ntom_step > 8 * NTOM_MUL) {
+		debug_printf("%d max. 1:8 conversion allowed!\n", __LINE__);
 		return (1);
 	}
 
-	ntom_val[0] = ntom_val[1] = NTOM_MUL>>1;
+	ntom_val[0] = ntom_val[1] = NTOM_MUL >> 1;
 
 	return (0);
-	
+
 }
 
 
-int synth_ntom_mono (struct mpstr *mp, real *bandPtr,unsigned char *samples,int *pnt)
+int synth_ntom_mono(struct mpstr *mp, real * bandPtr, unsigned char *samples, int *pnt)
 {
-  short samples_tmp[8*64];
-  short *tmp1 = samples_tmp;
-  int i,ret;
-  int pnt1 = 0;
+	short samples_tmp[8 * 64];
+	short *tmp1 = samples_tmp;
+	int i, ret;
+	int pnt1 = 0;
 
-  ret = synth_ntom(mp, bandPtr,0,(unsigned char *) samples_tmp,&pnt1);
-  samples += *pnt;
+	ret = synth_ntom(mp, bandPtr, 0, (unsigned char *) samples_tmp, &pnt1);
+	samples += *pnt;
 
-  for(i=0;i<(pnt1>>2);i++) {
-    *( (short *)samples) = *tmp1;
-    samples += 2;
-    tmp1 += 2;
-  }
-  *pnt += pnt1 >> 1;
+	for (i = 0; i < (pnt1 >> 2); i++) {
+		*((short *) samples) = *tmp1;
+		samples += 2;
+		tmp1 += 2;
+	}
+	*pnt += pnt1 >> 1;
 
-  return ret;
+	return ret;
 }
 
 
 
-int synth_ntom(struct mpstr *mp, real *bandPtr,int channel,unsigned char *out,int *pnt)
+int synth_ntom(struct mpstr *mp, real * bandPtr, int channel, unsigned char *out, int *pnt)
 {
-  static const int step = 2;
-  int bo;
-  short *samples = (short *) (out + *pnt);
+	static const int step = 2;
+	int bo;
+	short *samples = (short *) (out + *pnt);
 
-  real *b0,(*buf)[0x110];
-  int clip = 0; 
-  int bo1;
-  int ntom;
+	real *b0, (*buf)[0x110];
+	int clip = 0;
+	int bo1;
+	int ntom;
 
-  bo = mp->synth_bo;
-  
-  if(!channel) {
-    bo--;
-    bo &= 0xf;
-    buf = mp->synth_buffs[0];
-    ntom = ntom_val[1] = ntom_val[0];
-  }
-  else {
-    samples++;
-    out += 2; /* to compute the right *pnt value */
-    buf = mp->synth_buffs[1];
-    ntom = ntom_val[1];
-  }
+	bo = mp->synth_bo;
 
-  if(bo & 0x1) {
-    b0 = buf[0];
-    bo1 = bo;
-    dct64(buf[1]+((bo+1)&0xf),buf[0]+bo,bandPtr);
-  }
-  else {
-    b0 = buf[1];
-    bo1 = bo+1;
-    dct64(buf[0]+bo,buf[1]+bo+1,bandPtr);
-  }
+	if (!channel) {
+		bo--;
+		bo &= 0xf;
+		buf = mp->synth_buffs[0];
+		ntom = ntom_val[1] = ntom_val[0];
+	} else {
+		samples++;
+		out += 2;				/* to compute the right *pnt value */
+		buf = mp->synth_buffs[1];
+		ntom = ntom_val[1];
+	}
 
-  mp->synth_bo = bo;
-  
-  {
-    register int j;
-    real *window = (mp->decwin) + 16 - bo1;
- 
-    for (j=16;j;j--,window+=0x10)
-    {
-      real sum;
+	if (bo & 0x1) {
+		b0 = buf[0];
+		bo1 = bo;
+		dct64(buf[1] + ((bo + 1) & 0xf), buf[0] + bo, bandPtr);
+	} else {
+		b0 = buf[1];
+		bo1 = bo + 1;
+		dct64(buf[0] + bo, buf[1] + bo + 1, bandPtr);
+	}
 
-      ntom += ntom_step;
-      if(ntom < NTOM_MUL) {
-        window += 16;
-        b0 += 16;
-        continue;
-      }
+	mp->synth_bo = bo;
 
-      sum  = *window++ * *b0++;
-      sum -= *window++ * *b0++;
-      sum += *window++ * *b0++;
-      sum -= *window++ * *b0++;
-      sum += *window++ * *b0++;
-      sum -= *window++ * *b0++;
-      sum += *window++ * *b0++;
-      sum -= *window++ * *b0++;
-      sum += *window++ * *b0++;
-      sum -= *window++ * *b0++;
-      sum += *window++ * *b0++;
-      sum -= *window++ * *b0++;
-      sum += *window++ * *b0++;
-      sum -= *window++ * *b0++;
-      sum += *window++ * *b0++;
-      sum -= *window++ * *b0++;
+	{
+		register int j;
+		real *window = (mp->decwin) + 16 - bo1;
 
-      while(ntom >= NTOM_MUL) {
-        WRITE_SAMPLE(samples,sum,clip);
-        samples += step;
-        ntom -= NTOM_MUL;
-      }
-    }
+		for (j = 16; j; j--, window += 0x10) {
+			real sum;
 
-    ntom += ntom_step;
-    if(ntom >= NTOM_MUL)
-    {
-      real sum;
-      sum  = window[0x0] * b0[0x0];
-      sum += window[0x2] * b0[0x2];
-      sum += window[0x4] * b0[0x4];
-      sum += window[0x6] * b0[0x6];
-      sum += window[0x8] * b0[0x8];
-      sum += window[0xA] * b0[0xA];
-      sum += window[0xC] * b0[0xC];
-      sum += window[0xE] * b0[0xE];
+			ntom += ntom_step;
+			if (ntom < NTOM_MUL) {
+				window += 16;
+				b0 += 16;
+				continue;
+			}
 
-      while(ntom >= NTOM_MUL) {
-        WRITE_SAMPLE(samples,sum,clip);
-        samples += step;
-        ntom -= NTOM_MUL;
-      }
-    }
+			sum = *window++ * *b0++;
+			sum -= *window++ * *b0++;
+			sum += *window++ * *b0++;
+			sum -= *window++ * *b0++;
+			sum += *window++ * *b0++;
+			sum -= *window++ * *b0++;
+			sum += *window++ * *b0++;
+			sum -= *window++ * *b0++;
+			sum += *window++ * *b0++;
+			sum -= *window++ * *b0++;
+			sum += *window++ * *b0++;
+			sum -= *window++ * *b0++;
+			sum += *window++ * *b0++;
+			sum -= *window++ * *b0++;
+			sum += *window++ * *b0++;
+			sum -= *window++ * *b0++;
 
-    b0-=0x10,window-=0x20;
-    window += bo1<<1;
+			while (ntom >= NTOM_MUL) {
+				WRITE_SAMPLE(samples, sum, clip);
+				samples += step;
+				ntom -= NTOM_MUL;
+			}
+		}
 
-    for (j=15;j;j--,b0-=0x20,window-=0x10)
-    {
-      real sum;
+		ntom += ntom_step;
+		if (ntom >= NTOM_MUL) {
+			real sum;
+			sum = window[0x0] * b0[0x0];
+			sum += window[0x2] * b0[0x2];
+			sum += window[0x4] * b0[0x4];
+			sum += window[0x6] * b0[0x6];
+			sum += window[0x8] * b0[0x8];
+			sum += window[0xA] * b0[0xA];
+			sum += window[0xC] * b0[0xC];
+			sum += window[0xE] * b0[0xE];
 
-      ntom += ntom_step;
-      if(ntom < NTOM_MUL) {
-        window -= 16;
-        b0 += 16;
-        continue;
-      }
+			while (ntom >= NTOM_MUL) {
+				WRITE_SAMPLE(samples, sum, clip);
+				samples += step;
+				ntom -= NTOM_MUL;
+			}
+		}
 
-      sum = -*(--window) * *b0++;
-      sum -= *(--window) * *b0++;
-      sum -= *(--window) * *b0++;
-      sum -= *(--window) * *b0++;
-      sum -= *(--window) * *b0++;
-      sum -= *(--window) * *b0++;
-      sum -= *(--window) * *b0++;
-      sum -= *(--window) * *b0++;
-      sum -= *(--window) * *b0++;
-      sum -= *(--window) * *b0++;
-      sum -= *(--window) * *b0++;
-      sum -= *(--window) * *b0++;
-      sum -= *(--window) * *b0++;
-      sum -= *(--window) * *b0++;
-      sum -= *(--window) * *b0++;
-      sum -= *(--window) * *b0++;
+		b0 -= 0x10, window -= 0x20;
+		window += bo1 << 1;
 
-      while(ntom >= NTOM_MUL) {
-        WRITE_SAMPLE(samples,sum,clip);
-        samples += step;
-        ntom -= NTOM_MUL;
-      }
-    }
-  }
+		for (j = 15; j; j--, b0 -= 0x20, window -= 0x10) {
+			real sum;
 
-  ntom_val[channel] = ntom;
-  *pnt = ((unsigned char *) samples - out);
+			ntom += ntom_step;
+			if (ntom < NTOM_MUL) {
+				window -= 16;
+				b0 += 16;
+				continue;
+			}
 
-  return clip;
+			sum = -*(--window) * *b0++;
+			sum -= *(--window) * *b0++;
+			sum -= *(--window) * *b0++;
+			sum -= *(--window) * *b0++;
+			sum -= *(--window) * *b0++;
+			sum -= *(--window) * *b0++;
+			sum -= *(--window) * *b0++;
+			sum -= *(--window) * *b0++;
+			sum -= *(--window) * *b0++;
+			sum -= *(--window) * *b0++;
+			sum -= *(--window) * *b0++;
+			sum -= *(--window) * *b0++;
+			sum -= *(--window) * *b0++;
+			sum -= *(--window) * *b0++;
+			sum -= *(--window) * *b0++;
+			sum -= *(--window) * *b0++;
+
+			while (ntom >= NTOM_MUL) {
+				WRITE_SAMPLE(samples, sum, clip);
+				samples += step;
+				ntom -= NTOM_MUL;
+			}
+		}
+	}
+
+	ntom_val[channel] = ntom;
+	*pnt = ((unsigned char *) samples - out);
+
+	return clip;
 }
-
-
diff --git a/src/mod/formats/mod_shout/huffman.h b/src/mod/formats/mod_shout/huffman.h
index 7fec0d589e..d5e279dcf8 100644
--- a/src/mod/formats/mod_shout/huffman.h
+++ b/src/mod/formats/mod_shout/huffman.h
@@ -6,327 +6,304 @@
  * smaller tables are often the part of a bigger table
  */
 
-struct newhuff 
-{
-  unsigned int linbits;
-  short *table;
+struct newhuff {
+	unsigned int linbits;
+	short *table;
 };
 
-static short tab0[] = 
-{ 
-   0
+static short tab0[] = {
+	0
 };
 
-static short tab1[] =
-{
-  -5,  -3,  -1,  17,   1,  16,   0
+static short tab1[] = {
+	-5, -3, -1, 17, 1, 16, 0
 };
 
-static short tab2[] =
-{
- -15, -11,  -9,  -5,  -3,  -1,  34,   2,  18,  -1,  33,  32,  17,  -1,   1,
-  16,   0
+static short tab2[] = {
+	-15, -11, -9, -5, -3, -1, 34, 2, 18, -1, 33, 32, 17, -1, 1,
+	16, 0
 };
 
-static short tab3[] =
-{
- -13, -11,  -9,  -5,  -3,  -1,  34,   2,  18,  -1,  33,  32,  16,  17,  -1,
-   1,   0
+static short tab3[] = {
+	-13, -11, -9, -5, -3, -1, 34, 2, 18, -1, 33, 32, 16, 17, -1,
+	1, 0
 };
 
-static short tab5[] =
-{
- -29, -25, -23, -15,  -7,  -5,  -3,  -1,  51,  35,  50,  49,  -3,  -1,  19,
-   3,  -1,  48,  34,  -3,  -1,  18,  33,  -1,   2,  32,  17,  -1,   1,  16,
-   0
+static short tab5[] = {
+	-29, -25, -23, -15, -7, -5, -3, -1, 51, 35, 50, 49, -3, -1, 19,
+	3, -1, 48, 34, -3, -1, 18, 33, -1, 2, 32, 17, -1, 1, 16,
+	0
 };
 
-static short tab6[] =
-{
- -25, -19, -13,  -9,  -5,  -3,  -1,  51,   3,  35,  -1,  50,  48,  -1,  19,
-  49,  -3,  -1,  34,   2,  18,  -3,  -1,  33,  32,   1,  -1,  17,  -1,  16,
-   0
+static short tab6[] = {
+	-25, -19, -13, -9, -5, -3, -1, 51, 3, 35, -1, 50, 48, -1, 19,
+	49, -3, -1, 34, 2, 18, -3, -1, 33, 32, 1, -1, 17, -1, 16,
+	0
 };
 
-static short tab7[] =
-{
- -69, -65, -57, -39, -29, -17, -11,  -7,  -3,  -1,  85,  69,  -1,  84,  83,
-  -1,  53,  68,  -3,  -1,  37,  82,  21,  -5,  -1,  81,  -1,   5,  52,  -1,
-  80,  -1,  67,  51,  -5,  -3,  -1,  36,  66,  20,  -1,  65,  64, -11,  -7,
-  -3,  -1,   4,  35,  -1,  50,   3,  -1,  19,  49,  -3,  -1,  48,  34,  18,
-  -5,  -1,  33,  -1,   2,  32,  17,  -1,   1,  16,   0
+static short tab7[] = {
+	-69, -65, -57, -39, -29, -17, -11, -7, -3, -1, 85, 69, -1, 84, 83,
+	-1, 53, 68, -3, -1, 37, 82, 21, -5, -1, 81, -1, 5, 52, -1,
+	80, -1, 67, 51, -5, -3, -1, 36, 66, 20, -1, 65, 64, -11, -7,
+	-3, -1, 4, 35, -1, 50, 3, -1, 19, 49, -3, -1, 48, 34, 18,
+	-5, -1, 33, -1, 2, 32, 17, -1, 1, 16, 0
 };
 
-static short tab8[] =
-{
- -65, -63, -59, -45, -31, -19, -13,  -7,  -5,  -3,  -1,  85,  84,  69,  83,
-  -3,  -1,  53,  68,  37,  -3,  -1,  82,   5,  21,  -5,  -1,  81,  -1,  52,
-  67,  -3,  -1,  80,  51,  36,  -5,  -3,  -1,  66,  20,  65,  -3,  -1,   4,
-  64,  -1,  35,  50,  -9,  -7,  -3,  -1,  19,  49,  -1,   3,  48,  34,  -1,
-   2,  32,  -1,  18,  33,  17,  -3,  -1,   1,  16,   0
+static short tab8[] = {
+	-65, -63, -59, -45, -31, -19, -13, -7, -5, -3, -1, 85, 84, 69, 83,
+	-3, -1, 53, 68, 37, -3, -1, 82, 5, 21, -5, -1, 81, -1, 52,
+	67, -3, -1, 80, 51, 36, -5, -3, -1, 66, 20, 65, -3, -1, 4,
+	64, -1, 35, 50, -9, -7, -3, -1, 19, 49, -1, 3, 48, 34, -1,
+	2, 32, -1, 18, 33, 17, -3, -1, 1, 16, 0
 };
 
-static short tab9[] =
-{
- -63, -53, -41, -29, -19, -11,  -5,  -3,  -1,  85,  69,  53,  -1,  83,  -1,
-  84,   5,  -3,  -1,  68,  37,  -1,  82,  21,  -3,  -1,  81,  52,  -1,  67,
-  -1,  80,   4,  -7,  -3,  -1,  36,  66,  -1,  51,  64,  -1,  20,  65,  -5,
-  -3,  -1,  35,  50,  19,  -1,  49,  -1,   3,  48,  -5,  -3,  -1,  34,   2,
-  18,  -1,  33,  32,  -3,  -1,  17,   1,  -1,  16,   0
+static short tab9[] = {
+	-63, -53, -41, -29, -19, -11, -5, -3, -1, 85, 69, 53, -1, 83, -1,
+	84, 5, -3, -1, 68, 37, -1, 82, 21, -3, -1, 81, 52, -1, 67,
+	-1, 80, 4, -7, -3, -1, 36, 66, -1, 51, 64, -1, 20, 65, -5,
+	-3, -1, 35, 50, 19, -1, 49, -1, 3, 48, -5, -3, -1, 34, 2,
+	18, -1, 33, 32, -3, -1, 17, 1, -1, 16, 0
 };
 
-static short tab10[] =
-{
--125,-121,-111, -83, -55, -35, -21, -13,  -7,  -3,  -1, 119, 103,  -1, 118,
-  87,  -3,  -1, 117, 102,  71,  -3,  -1, 116,  86,  -1, 101,  55,  -9,  -3,
-  -1, 115,  70,  -3,  -1,  85,  84,  99,  -1,  39, 114, -11,  -5,  -3,  -1,
- 100,   7, 112,  -1,  98,  -1,  69,  53,  -5,  -1,   6,  -1,  83,  68,  23,
- -17,  -5,  -1, 113,  -1,  54,  38,  -5,  -3,  -1,  37,  82,  21,  -1,  81,
-  -1,  52,  67,  -3,  -1,  22,  97,  -1,  96,  -1,   5,  80, -19, -11,  -7,
-  -3,  -1,  36,  66,  -1,  51,   4,  -1,  20,  65,  -3,  -1,  64,  35,  -1,
-  50,   3,  -3,  -1,  19,  49,  -1,  48,  34,  -7,  -3,  -1,  18,  33,  -1,
-   2,  32,  17,  -1,   1,  16,   0
+static short tab10[] = {
+	-125, -121, -111, -83, -55, -35, -21, -13, -7, -3, -1, 119, 103, -1, 118,
+	87, -3, -1, 117, 102, 71, -3, -1, 116, 86, -1, 101, 55, -9, -3,
+	-1, 115, 70, -3, -1, 85, 84, 99, -1, 39, 114, -11, -5, -3, -1,
+	100, 7, 112, -1, 98, -1, 69, 53, -5, -1, 6, -1, 83, 68, 23,
+	-17, -5, -1, 113, -1, 54, 38, -5, -3, -1, 37, 82, 21, -1, 81,
+	-1, 52, 67, -3, -1, 22, 97, -1, 96, -1, 5, 80, -19, -11, -7,
+	-3, -1, 36, 66, -1, 51, 4, -1, 20, 65, -3, -1, 64, 35, -1,
+	50, 3, -3, -1, 19, 49, -1, 48, 34, -7, -3, -1, 18, 33, -1,
+	2, 32, 17, -1, 1, 16, 0
 };
 
-static short tab11[] =
-{
--121,-113, -89, -59, -43, -27, -17,  -7,  -3,  -1, 119, 103,  -1, 118, 117,
-  -3,  -1, 102,  71,  -1, 116,  -1,  87,  85,  -5,  -3,  -1,  86, 101,  55,
-  -1, 115,  70,  -9,  -7,  -3,  -1,  69,  84,  -1,  53,  83,  39,  -1, 114,
-  -1, 100,   7,  -5,  -1, 113,  -1,  23, 112,  -3,  -1,  54,  99,  -1,  96,
-  -1,  68,  37, -13,  -7,  -5,  -3,  -1,  82,   5,  21,  98,  -3,  -1,  38,
-   6,  22,  -5,  -1,  97,  -1,  81,  52,  -5,  -1,  80,  -1,  67,  51,  -1,
-  36,  66, -15, -11,  -7,  -3,  -1,  20,  65,  -1,   4,  64,  -1,  35,  50,
-  -1,  19,  49,  -5,  -3,  -1,   3,  48,  34,  33,  -5,  -1,  18,  -1,   2,
-  32,  17,  -3,  -1,   1,  16,   0
+static short tab11[] = {
+	-121, -113, -89, -59, -43, -27, -17, -7, -3, -1, 119, 103, -1, 118, 117,
+	-3, -1, 102, 71, -1, 116, -1, 87, 85, -5, -3, -1, 86, 101, 55,
+	-1, 115, 70, -9, -7, -3, -1, 69, 84, -1, 53, 83, 39, -1, 114,
+	-1, 100, 7, -5, -1, 113, -1, 23, 112, -3, -1, 54, 99, -1, 96,
+	-1, 68, 37, -13, -7, -5, -3, -1, 82, 5, 21, 98, -3, -1, 38,
+	6, 22, -5, -1, 97, -1, 81, 52, -5, -1, 80, -1, 67, 51, -1,
+	36, 66, -15, -11, -7, -3, -1, 20, 65, -1, 4, 64, -1, 35, 50,
+	-1, 19, 49, -5, -3, -1, 3, 48, 34, 33, -5, -1, 18, -1, 2,
+	32, 17, -3, -1, 1, 16, 0
 };
 
-static short tab12[] =
-{
--115, -99, -73, -45, -27, -17,  -9,  -5,  -3,  -1, 119, 103, 118,  -1,  87,
- 117,  -3,  -1, 102,  71,  -1, 116, 101,  -3,  -1,  86,  55,  -3,  -1, 115,
-  85,  39,  -7,  -3,  -1, 114,  70,  -1, 100,  23,  -5,  -1, 113,  -1,   7,
- 112,  -1,  54,  99, -13,  -9,  -3,  -1,  69,  84,  -1,  68,  -1,   6,   5,
-  -1,  38,  98,  -5,  -1,  97,  -1,  22,  96,  -3,  -1,  53,  83,  -1,  37,
-  82, -17,  -7,  -3,  -1,  21,  81,  -1,  52,  67,  -5,  -3,  -1,  80,   4,
-  36,  -1,  66,  20,  -3,  -1,  51,  65,  -1,  35,  50, -11,  -7,  -5,  -3,
-  -1,  64,   3,  48,  19,  -1,  49,  34,  -1,  18,  33,  -7,  -5,  -3,  -1,
-   2,  32,   0,  17,  -1,   1,  16
+static short tab12[] = {
+	-115, -99, -73, -45, -27, -17, -9, -5, -3, -1, 119, 103, 118, -1, 87,
+	117, -3, -1, 102, 71, -1, 116, 101, -3, -1, 86, 55, -3, -1, 115,
+	85, 39, -7, -3, -1, 114, 70, -1, 100, 23, -5, -1, 113, -1, 7,
+	112, -1, 54, 99, -13, -9, -3, -1, 69, 84, -1, 68, -1, 6, 5,
+	-1, 38, 98, -5, -1, 97, -1, 22, 96, -3, -1, 53, 83, -1, 37,
+	82, -17, -7, -3, -1, 21, 81, -1, 52, 67, -5, -3, -1, 80, 4,
+	36, -1, 66, 20, -3, -1, 51, 65, -1, 35, 50, -11, -7, -5, -3,
+	-1, 64, 3, 48, 19, -1, 49, 34, -1, 18, 33, -7, -5, -3, -1,
+	2, 32, 0, 17, -1, 1, 16
 };
 
-static short tab13[] =
-{
--509,-503,-475,-405,-333,-265,-205,-153,-115, -83, -53, -35, -21, -13,  -9,
-  -7,  -5,  -3,  -1, 254, 252, 253, 237, 255,  -1, 239, 223,  -3,  -1, 238,
- 207,  -1, 222, 191,  -9,  -3,  -1, 251, 206,  -1, 220,  -1, 175, 233,  -1,
- 236, 221,  -9,  -5,  -3,  -1, 250, 205, 190,  -1, 235, 159,  -3,  -1, 249,
- 234,  -1, 189, 219, -17,  -9,  -3,  -1, 143, 248,  -1, 204,  -1, 174, 158,
-  -5,  -1, 142,  -1, 127, 126, 247,  -5,  -1, 218,  -1, 173, 188,  -3,  -1,
- 203, 246, 111, -15,  -7,  -3,  -1, 232,  95,  -1, 157, 217,  -3,  -1, 245,
- 231,  -1, 172, 187,  -9,  -3,  -1,  79, 244,  -3,  -1, 202, 230, 243,  -1,
-  63,  -1, 141, 216, -21,  -9,  -3,  -1,  47, 242,  -3,  -1, 110, 156,  15,
-  -5,  -3,  -1, 201,  94, 171,  -3,  -1, 125, 215,  78, -11,  -5,  -3,  -1,
- 200, 214,  62,  -1, 185,  -1, 155, 170,  -1,  31, 241, -23, -13,  -5,  -1,
- 240,  -1, 186, 229,  -3,  -1, 228, 140,  -1, 109, 227,  -5,  -1, 226,  -1,
-  46,  14,  -1,  30, 225, -15,  -7,  -3,  -1, 224,  93,  -1, 213, 124,  -3,
-  -1, 199,  77,  -1, 139, 184,  -7,  -3,  -1, 212, 154,  -1, 169, 108,  -1,
- 198,  61, -37, -21,  -9,  -5,  -3,  -1, 211, 123,  45,  -1, 210,  29,  -5,
-  -1, 183,  -1,  92, 197,  -3,  -1, 153, 122, 195,  -7,  -5,  -3,  -1, 167,
- 151,  75, 209,  -3,  -1,  13, 208,  -1, 138, 168, -11,  -7,  -3,  -1,  76,
- 196,  -1, 107, 182,  -1,  60,  44,  -3,  -1, 194,  91,  -3,  -1, 181, 137,
-  28, -43, -23, -11,  -5,  -1, 193,  -1, 152,  12,  -1, 192,  -1, 180, 106,
-  -5,  -3,  -1, 166, 121,  59,  -1, 179,  -1, 136,  90, -11,  -5,  -1,  43,
-  -1, 165, 105,  -1, 164,  -1, 120, 135,  -5,  -1, 148,  -1, 119, 118, 178,
- -11,  -3,  -1,  27, 177,  -3,  -1,  11, 176,  -1, 150,  74,  -7,  -3,  -1,
-  58, 163,  -1,  89, 149,  -1,  42, 162, -47, -23,  -9,  -3,  -1,  26, 161,
-  -3,  -1,  10, 104, 160,  -5,  -3,  -1, 134,  73, 147,  -3,  -1,  57,  88,
-  -1, 133, 103,  -9,  -3,  -1,  41, 146,  -3,  -1,  87, 117,  56,  -5,  -1,
- 131,  -1, 102,  71,  -3,  -1, 116,  86,  -1, 101, 115, -11,  -3,  -1,  25,
- 145,  -3,  -1,   9, 144,  -1,  72, 132,  -7,  -5,  -1, 114,  -1,  70, 100,
-  40,  -1, 130,  24, -41, -27, -11,  -5,  -3,  -1,  55,  39,  23,  -1, 113,
-  -1,  85,   7,  -7,  -3,  -1, 112,  54,  -1,  99,  69,  -3,  -1,  84,  38,
-  -1,  98,  53,  -5,  -1, 129,  -1,   8, 128,  -3,  -1,  22,  97,  -1,   6,
-  96, -13,  -9,  -5,  -3,  -1,  83,  68,  37,  -1,  82,   5,  -1,  21,  81,
-  -7,  -3,  -1,  52,  67,  -1,  80,  36,  -3,  -1,  66,  51,  20, -19, -11,
-  -5,  -1,  65,  -1,   4,  64,  -3,  -1,  35,  50,  19,  -3,  -1,  49,   3,
-  -1,  48,  34,  -3,  -1,  18,  33,  -1,   2,  32,  -3,  -1,  17,   1,  16,
-   0
+static short tab13[] = {
+	-509, -503, -475, -405, -333, -265, -205, -153, -115, -83, -53, -35, -21, -13, -9,
+	-7, -5, -3, -1, 254, 252, 253, 237, 255, -1, 239, 223, -3, -1, 238,
+	207, -1, 222, 191, -9, -3, -1, 251, 206, -1, 220, -1, 175, 233, -1,
+	236, 221, -9, -5, -3, -1, 250, 205, 190, -1, 235, 159, -3, -1, 249,
+	234, -1, 189, 219, -17, -9, -3, -1, 143, 248, -1, 204, -1, 174, 158,
+	-5, -1, 142, -1, 127, 126, 247, -5, -1, 218, -1, 173, 188, -3, -1,
+	203, 246, 111, -15, -7, -3, -1, 232, 95, -1, 157, 217, -3, -1, 245,
+	231, -1, 172, 187, -9, -3, -1, 79, 244, -3, -1, 202, 230, 243, -1,
+	63, -1, 141, 216, -21, -9, -3, -1, 47, 242, -3, -1, 110, 156, 15,
+	-5, -3, -1, 201, 94, 171, -3, -1, 125, 215, 78, -11, -5, -3, -1,
+	200, 214, 62, -1, 185, -1, 155, 170, -1, 31, 241, -23, -13, -5, -1,
+	240, -1, 186, 229, -3, -1, 228, 140, -1, 109, 227, -5, -1, 226, -1,
+	46, 14, -1, 30, 225, -15, -7, -3, -1, 224, 93, -1, 213, 124, -3,
+	-1, 199, 77, -1, 139, 184, -7, -3, -1, 212, 154, -1, 169, 108, -1,
+	198, 61, -37, -21, -9, -5, -3, -1, 211, 123, 45, -1, 210, 29, -5,
+	-1, 183, -1, 92, 197, -3, -1, 153, 122, 195, -7, -5, -3, -1, 167,
+	151, 75, 209, -3, -1, 13, 208, -1, 138, 168, -11, -7, -3, -1, 76,
+	196, -1, 107, 182, -1, 60, 44, -3, -1, 194, 91, -3, -1, 181, 137,
+	28, -43, -23, -11, -5, -1, 193, -1, 152, 12, -1, 192, -1, 180, 106,
+	-5, -3, -1, 166, 121, 59, -1, 179, -1, 136, 90, -11, -5, -1, 43,
+	-1, 165, 105, -1, 164, -1, 120, 135, -5, -1, 148, -1, 119, 118, 178,
+	-11, -3, -1, 27, 177, -3, -1, 11, 176, -1, 150, 74, -7, -3, -1,
+	58, 163, -1, 89, 149, -1, 42, 162, -47, -23, -9, -3, -1, 26, 161,
+	-3, -1, 10, 104, 160, -5, -3, -1, 134, 73, 147, -3, -1, 57, 88,
+	-1, 133, 103, -9, -3, -1, 41, 146, -3, -1, 87, 117, 56, -5, -1,
+	131, -1, 102, 71, -3, -1, 116, 86, -1, 101, 115, -11, -3, -1, 25,
+	145, -3, -1, 9, 144, -1, 72, 132, -7, -5, -1, 114, -1, 70, 100,
+	40, -1, 130, 24, -41, -27, -11, -5, -3, -1, 55, 39, 23, -1, 113,
+	-1, 85, 7, -7, -3, -1, 112, 54, -1, 99, 69, -3, -1, 84, 38,
+	-1, 98, 53, -5, -1, 129, -1, 8, 128, -3, -1, 22, 97, -1, 6,
+	96, -13, -9, -5, -3, -1, 83, 68, 37, -1, 82, 5, -1, 21, 81,
+	-7, -3, -1, 52, 67, -1, 80, 36, -3, -1, 66, 51, 20, -19, -11,
+	-5, -1, 65, -1, 4, 64, -3, -1, 35, 50, 19, -3, -1, 49, 3,
+	-1, 48, 34, -3, -1, 18, 33, -1, 2, 32, -3, -1, 17, 1, 16,
+	0
 };
 
-static short tab15[] =
-{
--495,-445,-355,-263,-183,-115, -77, -43, -27, -13,  -7,  -3,  -1, 255, 239,
-  -1, 254, 223,  -1, 238,  -1, 253, 207,  -7,  -3,  -1, 252, 222,  -1, 237,
- 191,  -1, 251,  -1, 206, 236,  -7,  -3,  -1, 221, 175,  -1, 250, 190,  -3,
-  -1, 235, 205,  -1, 220, 159, -15,  -7,  -3,  -1, 249, 234,  -1, 189, 219,
-  -3,  -1, 143, 248,  -1, 204, 158,  -7,  -3,  -1, 233, 127,  -1, 247, 173,
-  -3,  -1, 218, 188,  -1, 111,  -1, 174,  15, -19, -11,  -3,  -1, 203, 246,
-  -3,  -1, 142, 232,  -1,  95, 157,  -3,  -1, 245, 126,  -1, 231, 172,  -9,
-  -3,  -1, 202, 187,  -3,  -1, 217, 141,  79,  -3,  -1, 244,  63,  -1, 243,
- 216, -33, -17,  -9,  -3,  -1, 230,  47,  -1, 242,  -1, 110, 240,  -3,  -1,
-  31, 241,  -1, 156, 201,  -7,  -3,  -1,  94, 171,  -1, 186, 229,  -3,  -1,
- 125, 215,  -1,  78, 228, -15,  -7,  -3,  -1, 140, 200,  -1,  62, 109,  -3,
-  -1, 214, 227,  -1, 155, 185,  -7,  -3,  -1,  46, 170,  -1, 226,  30,  -5,
-  -1, 225,  -1,  14, 224,  -1,  93, 213, -45, -25, -13,  -7,  -3,  -1, 124,
- 199,  -1,  77, 139,  -1, 212,  -1, 184, 154,  -7,  -3,  -1, 169, 108,  -1,
- 198,  61,  -1, 211, 210,  -9,  -5,  -3,  -1,  45,  13,  29,  -1, 123, 183,
-  -5,  -1, 209,  -1,  92, 208,  -1, 197, 138, -17,  -7,  -3,  -1, 168,  76,
-  -1, 196, 107,  -5,  -1, 182,  -1, 153,  12,  -1,  60, 195,  -9,  -3,  -1,
- 122, 167,  -1, 166,  -1, 192,  11,  -1, 194,  -1,  44,  91, -55, -29, -15,
-  -7,  -3,  -1, 181,  28,  -1, 137, 152,  -3,  -1, 193,  75,  -1, 180, 106,
-  -5,  -3,  -1,  59, 121, 179,  -3,  -1, 151, 136,  -1,  43,  90, -11,  -5,
-  -1, 178,  -1, 165,  27,  -1, 177,  -1, 176, 105,  -7,  -3,  -1, 150,  74,
-  -1, 164, 120,  -3,  -1, 135,  58, 163, -17,  -7,  -3,  -1,  89, 149,  -1,
-  42, 162,  -3,  -1,  26, 161,  -3,  -1,  10, 160, 104,  -7,  -3,  -1, 134,
-  73,  -1, 148,  57,  -5,  -1, 147,  -1, 119,   9,  -1,  88, 133, -53, -29,
- -13,  -7,  -3,  -1,  41, 103,  -1, 118, 146,  -1, 145,  -1,  25, 144,  -7,
-  -3,  -1,  72, 132,  -1,  87, 117,  -3,  -1,  56, 131,  -1, 102,  71,  -7,
-  -3,  -1,  40, 130,  -1,  24, 129,  -7,  -3,  -1, 116,   8,  -1, 128,  86,
-  -3,  -1, 101,  55,  -1, 115,  70, -17,  -7,  -3,  -1,  39, 114,  -1, 100,
-  23,  -3,  -1,  85, 113,  -3,  -1,   7, 112,  54,  -7,  -3,  -1,  99,  69,
-  -1,  84,  38,  -3,  -1,  98,  22,  -3,  -1,   6,  96,  53, -33, -19,  -9,
-  -5,  -1,  97,  -1,  83,  68,  -1,  37,  82,  -3,  -1,  21,  81,  -3,  -1,
-   5,  80,  52,  -7,  -3,  -1,  67,  36,  -1,  66,  51,  -1,  65,  -1,  20,
-   4,  -9,  -3,  -1,  35,  50,  -3,  -1,  64,   3,  19,  -3,  -1,  49,  48,
-  34,  -9,  -7,  -3,  -1,  18,  33,  -1,   2,  32,  17,  -3,  -1,   1,  16,
-   0
+static short tab15[] = {
+	-495, -445, -355, -263, -183, -115, -77, -43, -27, -13, -7, -3, -1, 255, 239,
+	-1, 254, 223, -1, 238, -1, 253, 207, -7, -3, -1, 252, 222, -1, 237,
+	191, -1, 251, -1, 206, 236, -7, -3, -1, 221, 175, -1, 250, 190, -3,
+	-1, 235, 205, -1, 220, 159, -15, -7, -3, -1, 249, 234, -1, 189, 219,
+	-3, -1, 143, 248, -1, 204, 158, -7, -3, -1, 233, 127, -1, 247, 173,
+	-3, -1, 218, 188, -1, 111, -1, 174, 15, -19, -11, -3, -1, 203, 246,
+	-3, -1, 142, 232, -1, 95, 157, -3, -1, 245, 126, -1, 231, 172, -9,
+	-3, -1, 202, 187, -3, -1, 217, 141, 79, -3, -1, 244, 63, -1, 243,
+	216, -33, -17, -9, -3, -1, 230, 47, -1, 242, -1, 110, 240, -3, -1,
+	31, 241, -1, 156, 201, -7, -3, -1, 94, 171, -1, 186, 229, -3, -1,
+	125, 215, -1, 78, 228, -15, -7, -3, -1, 140, 200, -1, 62, 109, -3,
+	-1, 214, 227, -1, 155, 185, -7, -3, -1, 46, 170, -1, 226, 30, -5,
+	-1, 225, -1, 14, 224, -1, 93, 213, -45, -25, -13, -7, -3, -1, 124,
+	199, -1, 77, 139, -1, 212, -1, 184, 154, -7, -3, -1, 169, 108, -1,
+	198, 61, -1, 211, 210, -9, -5, -3, -1, 45, 13, 29, -1, 123, 183,
+	-5, -1, 209, -1, 92, 208, -1, 197, 138, -17, -7, -3, -1, 168, 76,
+	-1, 196, 107, -5, -1, 182, -1, 153, 12, -1, 60, 195, -9, -3, -1,
+	122, 167, -1, 166, -1, 192, 11, -1, 194, -1, 44, 91, -55, -29, -15,
+	-7, -3, -1, 181, 28, -1, 137, 152, -3, -1, 193, 75, -1, 180, 106,
+	-5, -3, -1, 59, 121, 179, -3, -1, 151, 136, -1, 43, 90, -11, -5,
+	-1, 178, -1, 165, 27, -1, 177, -1, 176, 105, -7, -3, -1, 150, 74,
+	-1, 164, 120, -3, -1, 135, 58, 163, -17, -7, -3, -1, 89, 149, -1,
+	42, 162, -3, -1, 26, 161, -3, -1, 10, 160, 104, -7, -3, -1, 134,
+	73, -1, 148, 57, -5, -1, 147, -1, 119, 9, -1, 88, 133, -53, -29,
+	-13, -7, -3, -1, 41, 103, -1, 118, 146, -1, 145, -1, 25, 144, -7,
+	-3, -1, 72, 132, -1, 87, 117, -3, -1, 56, 131, -1, 102, 71, -7,
+	-3, -1, 40, 130, -1, 24, 129, -7, -3, -1, 116, 8, -1, 128, 86,
+	-3, -1, 101, 55, -1, 115, 70, -17, -7, -3, -1, 39, 114, -1, 100,
+	23, -3, -1, 85, 113, -3, -1, 7, 112, 54, -7, -3, -1, 99, 69,
+	-1, 84, 38, -3, -1, 98, 22, -3, -1, 6, 96, 53, -33, -19, -9,
+	-5, -1, 97, -1, 83, 68, -1, 37, 82, -3, -1, 21, 81, -3, -1,
+	5, 80, 52, -7, -3, -1, 67, 36, -1, 66, 51, -1, 65, -1, 20,
+	4, -9, -3, -1, 35, 50, -3, -1, 64, 3, 19, -3, -1, 49, 48,
+	34, -9, -7, -3, -1, 18, 33, -1, 2, 32, 17, -3, -1, 1, 16,
+	0
 };
 
-static short tab16[] =
-{
--509,-503,-461,-323,-103, -37, -27, -15,  -7,  -3,  -1, 239, 254,  -1, 223,
- 253,  -3,  -1, 207, 252,  -1, 191, 251,  -5,  -1, 175,  -1, 250, 159,  -3,
-  -1, 249, 248, 143,  -7,  -3,  -1, 127, 247,  -1, 111, 246, 255,  -9,  -5,
-  -3,  -1,  95, 245,  79,  -1, 244, 243, -53,  -1, 240,  -1,  63, -29, -19,
- -13,  -7,  -5,  -1, 206,  -1, 236, 221, 222,  -1, 233,  -1, 234, 217,  -1,
- 238,  -1, 237, 235,  -3,  -1, 190, 205,  -3,  -1, 220, 219, 174, -11,  -5,
-  -1, 204,  -1, 173, 218,  -3,  -1, 126, 172, 202,  -5,  -3,  -1, 201, 125,
-  94, 189, 242, -93,  -5,  -3,  -1,  47,  15,  31,  -1, 241, -49, -25, -13,
-  -5,  -1, 158,  -1, 188, 203,  -3,  -1, 142, 232,  -1, 157, 231,  -7,  -3,
-  -1, 187, 141,  -1, 216, 110,  -1, 230, 156, -13,  -7,  -3,  -1, 171, 186,
-  -1, 229, 215,  -1,  78,  -1, 228, 140,  -3,  -1, 200,  62,  -1, 109,  -1,
- 214, 155, -19, -11,  -5,  -3,  -1, 185, 170, 225,  -1, 212,  -1, 184, 169,
-  -5,  -1, 123,  -1, 183, 208, 227,  -7,  -3,  -1,  14, 224,  -1,  93, 213,
-  -3,  -1, 124, 199,  -1,  77, 139, -75, -45, -27, -13,  -7,  -3,  -1, 154,
- 108,  -1, 198,  61,  -3,  -1,  92, 197,  13,  -7,  -3,  -1, 138, 168,  -1,
- 153,  76,  -3,  -1, 182, 122,  60, -11,  -5,  -3,  -1,  91, 137,  28,  -1,
- 192,  -1, 152, 121,  -1, 226,  -1,  46,  30, -15,  -7,  -3,  -1, 211,  45,
-  -1, 210, 209,  -5,  -1,  59,  -1, 151, 136,  29,  -7,  -3,  -1, 196, 107,
-  -1, 195, 167,  -1,  44,  -1, 194, 181, -23, -13,  -7,  -3,  -1, 193,  12,
-  -1,  75, 180,  -3,  -1, 106, 166, 179,  -5,  -3,  -1,  90, 165,  43,  -1,
- 178,  27, -13,  -5,  -1, 177,  -1,  11, 176,  -3,  -1, 105, 150,  -1,  74,
- 164,  -5,  -3,  -1, 120, 135, 163,  -3,  -1,  58,  89,  42, -97, -57, -33,
- -19, -11,  -5,  -3,  -1, 149, 104, 161,  -3,  -1, 134, 119, 148,  -5,  -3,
-  -1,  73,  87, 103, 162,  -5,  -1,  26,  -1,  10, 160,  -3,  -1,  57, 147,
-  -1,  88, 133,  -9,  -3,  -1,  41, 146,  -3,  -1, 118,   9,  25,  -5,  -1,
- 145,  -1, 144,  72,  -3,  -1, 132, 117,  -1,  56, 131, -21, -11,  -5,  -3,
-  -1, 102,  40, 130,  -3,  -1,  71, 116,  24,  -3,  -1, 129, 128,  -3,  -1,
-   8,  86,  55,  -9,  -5,  -1, 115,  -1, 101,  70,  -1,  39, 114,  -5,  -3,
-  -1, 100,  85,   7,  23, -23, -13,  -5,  -1, 113,  -1, 112,  54,  -3,  -1,
-  99,  69,  -1,  84,  38,  -3,  -1,  98,  22,  -1,  97,  -1,   6,  96,  -9,
-  -5,  -1,  83,  -1,  53,  68,  -1,  37,  82,  -1,  81,  -1,  21,   5, -33,
- -23, -13,  -7,  -3,  -1,  52,  67,  -1,  80,  36,  -3,  -1,  66,  51,  20,
-  -5,  -1,  65,  -1,   4,  64,  -1,  35,  50,  -3,  -1,  19,  49,  -3,  -1,
-   3,  48,  34,  -3,  -1,  18,  33,  -1,   2,  32,  -3,  -1,  17,   1,  16,
-   0
+static short tab16[] = {
+	-509, -503, -461, -323, -103, -37, -27, -15, -7, -3, -1, 239, 254, -1, 223,
+	253, -3, -1, 207, 252, -1, 191, 251, -5, -1, 175, -1, 250, 159, -3,
+	-1, 249, 248, 143, -7, -3, -1, 127, 247, -1, 111, 246, 255, -9, -5,
+	-3, -1, 95, 245, 79, -1, 244, 243, -53, -1, 240, -1, 63, -29, -19,
+	-13, -7, -5, -1, 206, -1, 236, 221, 222, -1, 233, -1, 234, 217, -1,
+	238, -1, 237, 235, -3, -1, 190, 205, -3, -1, 220, 219, 174, -11, -5,
+	-1, 204, -1, 173, 218, -3, -1, 126, 172, 202, -5, -3, -1, 201, 125,
+	94, 189, 242, -93, -5, -3, -1, 47, 15, 31, -1, 241, -49, -25, -13,
+	-5, -1, 158, -1, 188, 203, -3, -1, 142, 232, -1, 157, 231, -7, -3,
+	-1, 187, 141, -1, 216, 110, -1, 230, 156, -13, -7, -3, -1, 171, 186,
+	-1, 229, 215, -1, 78, -1, 228, 140, -3, -1, 200, 62, -1, 109, -1,
+	214, 155, -19, -11, -5, -3, -1, 185, 170, 225, -1, 212, -1, 184, 169,
+	-5, -1, 123, -1, 183, 208, 227, -7, -3, -1, 14, 224, -1, 93, 213,
+	-3, -1, 124, 199, -1, 77, 139, -75, -45, -27, -13, -7, -3, -1, 154,
+	108, -1, 198, 61, -3, -1, 92, 197, 13, -7, -3, -1, 138, 168, -1,
+	153, 76, -3, -1, 182, 122, 60, -11, -5, -3, -1, 91, 137, 28, -1,
+	192, -1, 152, 121, -1, 226, -1, 46, 30, -15, -7, -3, -1, 211, 45,
+	-1, 210, 209, -5, -1, 59, -1, 151, 136, 29, -7, -3, -1, 196, 107,
+	-1, 195, 167, -1, 44, -1, 194, 181, -23, -13, -7, -3, -1, 193, 12,
+	-1, 75, 180, -3, -1, 106, 166, 179, -5, -3, -1, 90, 165, 43, -1,
+	178, 27, -13, -5, -1, 177, -1, 11, 176, -3, -1, 105, 150, -1, 74,
+	164, -5, -3, -1, 120, 135, 163, -3, -1, 58, 89, 42, -97, -57, -33,
+	-19, -11, -5, -3, -1, 149, 104, 161, -3, -1, 134, 119, 148, -5, -3,
+	-1, 73, 87, 103, 162, -5, -1, 26, -1, 10, 160, -3, -1, 57, 147,
+	-1, 88, 133, -9, -3, -1, 41, 146, -3, -1, 118, 9, 25, -5, -1,
+	145, -1, 144, 72, -3, -1, 132, 117, -1, 56, 131, -21, -11, -5, -3,
+	-1, 102, 40, 130, -3, -1, 71, 116, 24, -3, -1, 129, 128, -3, -1,
+	8, 86, 55, -9, -5, -1, 115, -1, 101, 70, -1, 39, 114, -5, -3,
+	-1, 100, 85, 7, 23, -23, -13, -5, -1, 113, -1, 112, 54, -3, -1,
+	99, 69, -1, 84, 38, -3, -1, 98, 22, -1, 97, -1, 6, 96, -9,
+	-5, -1, 83, -1, 53, 68, -1, 37, 82, -1, 81, -1, 21, 5, -33,
+	-23, -13, -7, -3, -1, 52, 67, -1, 80, 36, -3, -1, 66, 51, 20,
+	-5, -1, 65, -1, 4, 64, -1, 35, 50, -3, -1, 19, 49, -3, -1,
+	3, 48, 34, -3, -1, 18, 33, -1, 2, 32, -3, -1, 17, 1, 16,
+	0
 };
 
-static short tab24[] =
-{
--451,-117, -43, -25, -15,  -7,  -3,  -1, 239, 254,  -1, 223, 253,  -3,  -1,
- 207, 252,  -1, 191, 251,  -5,  -1, 250,  -1, 175, 159,  -1, 249, 248,  -9,
-  -5,  -3,  -1, 143, 127, 247,  -1, 111, 246,  -3,  -1,  95, 245,  -1,  79,
- 244, -71,  -7,  -3,  -1,  63, 243,  -1,  47, 242,  -5,  -1, 241,  -1,  31,
- 240, -25,  -9,  -1,  15,  -3,  -1, 238, 222,  -1, 237, 206,  -7,  -3,  -1,
- 236, 221,  -1, 190, 235,  -3,  -1, 205, 220,  -1, 174, 234, -15,  -7,  -3,
-  -1, 189, 219,  -1, 204, 158,  -3,  -1, 233, 173,  -1, 218, 188,  -7,  -3,
-  -1, 203, 142,  -1, 232, 157,  -3,  -1, 217, 126,  -1, 231, 172, 255,-235,
--143, -77, -45, -25, -15,  -7,  -3,  -1, 202, 187,  -1, 141, 216,  -5,  -3,
-  -1,  14, 224,  13, 230,  -5,  -3,  -1, 110, 156, 201,  -1,  94, 186,  -9,
-  -5,  -1, 229,  -1, 171, 125,  -1, 215, 228,  -3,  -1, 140, 200,  -3,  -1,
-  78,  46,  62, -15,  -7,  -3,  -1, 109, 214,  -1, 227, 155,  -3,  -1, 185,
- 170,  -1, 226,  30,  -7,  -3,  -1, 225,  93,  -1, 213, 124,  -3,  -1, 199,
-  77,  -1, 139, 184, -31, -15,  -7,  -3,  -1, 212, 154,  -1, 169, 108,  -3,
-  -1, 198,  61,  -1, 211,  45,  -7,  -3,  -1, 210,  29,  -1, 123, 183,  -3,
-  -1, 209,  92,  -1, 197, 138, -17,  -7,  -3,  -1, 168, 153,  -1,  76, 196,
-  -3,  -1, 107, 182,  -3,  -1, 208,  12,  60,  -7,  -3,  -1, 195, 122,  -1,
- 167,  44,  -3,  -1, 194,  91,  -1, 181,  28, -57, -35, -19,  -7,  -3,  -1,
- 137, 152,  -1, 193,  75,  -5,  -3,  -1, 192,  11,  59,  -3,  -1, 176,  10,
-  26,  -5,  -1, 180,  -1, 106, 166,  -3,  -1, 121, 151,  -3,  -1, 160,   9,
- 144,  -9,  -3,  -1, 179, 136,  -3,  -1,  43,  90, 178,  -7,  -3,  -1, 165,
-  27,  -1, 177, 105,  -1, 150, 164, -17,  -9,  -5,  -3,  -1,  74, 120, 135,
-  -1,  58, 163,  -3,  -1,  89, 149,  -1,  42, 162,  -7,  -3,  -1, 161, 104,
-  -1, 134, 119,  -3,  -1,  73, 148,  -1,  57, 147, -63, -31, -15,  -7,  -3,
-  -1,  88, 133,  -1,  41, 103,  -3,  -1, 118, 146,  -1,  25, 145,  -7,  -3,
-  -1,  72, 132,  -1,  87, 117,  -3,  -1,  56, 131,  -1, 102,  40, -17,  -7,
-  -3,  -1, 130,  24,  -1,  71, 116,  -5,  -1, 129,  -1,   8, 128,  -1,  86,
- 101,  -7,  -5,  -1,  23,  -1,   7, 112, 115,  -3,  -1,  55,  39, 114, -15,
-  -7,  -3,  -1,  70, 100,  -1,  85, 113,  -3,  -1,  54,  99,  -1,  69,  84,
-  -7,  -3,  -1,  38,  98,  -1,  22,  97,  -5,  -3,  -1,   6,  96,  53,  -1,
-  83,  68, -51, -37, -23, -15,  -9,  -3,  -1,  37,  82,  -1,  21,  -1,   5,
-  80,  -1,  81,  -1,  52,  67,  -3,  -1,  36,  66,  -1,  51,  20,  -9,  -5,
-  -1,  65,  -1,   4,  64,  -1,  35,  50,  -1,  19,  49,  -7,  -5,  -3,  -1,
-   3,  48,  34,  18,  -1,  33,  -1,   2,  32,  -3,  -1,  17,   1,  -1,  16,
-   0
+static short tab24[] = {
+	-451, -117, -43, -25, -15, -7, -3, -1, 239, 254, -1, 223, 253, -3, -1,
+	207, 252, -1, 191, 251, -5, -1, 250, -1, 175, 159, -1, 249, 248, -9,
+	-5, -3, -1, 143, 127, 247, -1, 111, 246, -3, -1, 95, 245, -1, 79,
+	244, -71, -7, -3, -1, 63, 243, -1, 47, 242, -5, -1, 241, -1, 31,
+	240, -25, -9, -1, 15, -3, -1, 238, 222, -1, 237, 206, -7, -3, -1,
+	236, 221, -1, 190, 235, -3, -1, 205, 220, -1, 174, 234, -15, -7, -3,
+	-1, 189, 219, -1, 204, 158, -3, -1, 233, 173, -1, 218, 188, -7, -3,
+	-1, 203, 142, -1, 232, 157, -3, -1, 217, 126, -1, 231, 172, 255, -235,
+	-143, -77, -45, -25, -15, -7, -3, -1, 202, 187, -1, 141, 216, -5, -3,
+	-1, 14, 224, 13, 230, -5, -3, -1, 110, 156, 201, -1, 94, 186, -9,
+	-5, -1, 229, -1, 171, 125, -1, 215, 228, -3, -1, 140, 200, -3, -1,
+	78, 46, 62, -15, -7, -3, -1, 109, 214, -1, 227, 155, -3, -1, 185,
+	170, -1, 226, 30, -7, -3, -1, 225, 93, -1, 213, 124, -3, -1, 199,
+	77, -1, 139, 184, -31, -15, -7, -3, -1, 212, 154, -1, 169, 108, -3,
+	-1, 198, 61, -1, 211, 45, -7, -3, -1, 210, 29, -1, 123, 183, -3,
+	-1, 209, 92, -1, 197, 138, -17, -7, -3, -1, 168, 153, -1, 76, 196,
+	-3, -1, 107, 182, -3, -1, 208, 12, 60, -7, -3, -1, 195, 122, -1,
+	167, 44, -3, -1, 194, 91, -1, 181, 28, -57, -35, -19, -7, -3, -1,
+	137, 152, -1, 193, 75, -5, -3, -1, 192, 11, 59, -3, -1, 176, 10,
+	26, -5, -1, 180, -1, 106, 166, -3, -1, 121, 151, -3, -1, 160, 9,
+	144, -9, -3, -1, 179, 136, -3, -1, 43, 90, 178, -7, -3, -1, 165,
+	27, -1, 177, 105, -1, 150, 164, -17, -9, -5, -3, -1, 74, 120, 135,
+	-1, 58, 163, -3, -1, 89, 149, -1, 42, 162, -7, -3, -1, 161, 104,
+	-1, 134, 119, -3, -1, 73, 148, -1, 57, 147, -63, -31, -15, -7, -3,
+	-1, 88, 133, -1, 41, 103, -3, -1, 118, 146, -1, 25, 145, -7, -3,
+	-1, 72, 132, -1, 87, 117, -3, -1, 56, 131, -1, 102, 40, -17, -7,
+	-3, -1, 130, 24, -1, 71, 116, -5, -1, 129, -1, 8, 128, -1, 86,
+	101, -7, -5, -1, 23, -1, 7, 112, 115, -3, -1, 55, 39, 114, -15,
+	-7, -3, -1, 70, 100, -1, 85, 113, -3, -1, 54, 99, -1, 69, 84,
+	-7, -3, -1, 38, 98, -1, 22, 97, -5, -3, -1, 6, 96, 53, -1,
+	83, 68, -51, -37, -23, -15, -9, -3, -1, 37, 82, -1, 21, -1, 5,
+	80, -1, 81, -1, 52, 67, -3, -1, 36, 66, -1, 51, 20, -9, -5,
+	-1, 65, -1, 4, 64, -1, 35, 50, -1, 19, 49, -7, -5, -3, -1,
+	3, 48, 34, 18, -1, 33, -1, 2, 32, -3, -1, 17, 1, -1, 16,
+	0
 };
 
-static short tab_c0[] =
-{
- -29, -21, -13,  -7,  -3,  -1,  11,  15,  -1,  13,  14,  -3,  -1,   7,   5,
-   9,  -3,  -1,   6,   3,  -1,  10,  12,  -3,  -1,   2,   1,  -1,   4,   8,
-   0
+static short tab_c0[] = {
+	-29, -21, -13, -7, -3, -1, 11, 15, -1, 13, 14, -3, -1, 7, 5,
+	9, -3, -1, 6, 3, -1, 10, 12, -3, -1, 2, 1, -1, 4, 8,
+	0
 };
 
-static short tab_c1[] =
-{
- -15,  -7,  -3,  -1,  15,  14,  -1,  13,  12,  -3,  -1,  11,  10,  -1,   9,
-   8,  -7,  -3,  -1,   7,   6,  -1,   5,   4,  -3,  -1,   3,   2,  -1,   1,
-   0
+static short tab_c1[] = {
+	-15, -7, -3, -1, 15, 14, -1, 13, 12, -3, -1, 11, 10, -1, 9,
+	8, -7, -3, -1, 7, 6, -1, 5, 4, -3, -1, 3, 2, -1, 1,
+	0
 };
 
 
 
-static struct newhuff ht[] = 
-{
- { /* 0 */ 0 , tab0  } ,
- { /* 2 */ 0 , tab1  } ,
- { /* 3 */ 0 , tab2  } ,
- { /* 3 */ 0 , tab3  } ,
- { /* 0 */ 0 , tab0  } ,
- { /* 4 */ 0 , tab5  } ,
- { /* 4 */ 0 , tab6  } ,
- { /* 6 */ 0 , tab7  } ,
- { /* 6 */ 0 , tab8  } ,
- { /* 6 */ 0 , tab9  } ,
- { /* 8 */ 0 , tab10 } ,
- { /* 8 */ 0 , tab11 } ,
- { /* 8 */ 0 , tab12 } ,
- { /* 16 */ 0 , tab13 } ,
- { /* 0  */ 0 , tab0  } ,
- { /* 16 */ 0 , tab15 } ,
+static struct newhuff ht[] = {
+	{ /* 0 */ 0, tab0},
+	{ /* 2 */ 0, tab1},
+	{ /* 3 */ 0, tab2},
+	{ /* 3 */ 0, tab3},
+	{ /* 0 */ 0, tab0},
+	{ /* 4 */ 0, tab5},
+	{ /* 4 */ 0, tab6},
+	{ /* 6 */ 0, tab7},
+	{ /* 6 */ 0, tab8},
+	{ /* 6 */ 0, tab9},
+	{ /* 8 */ 0, tab10},
+	{ /* 8 */ 0, tab11},
+	{ /* 8 */ 0, tab12},
+	{ /* 16 */ 0, tab13},
+	{ /* 0  */ 0, tab0},
+	{ /* 16 */ 0, tab15},
 
- { /* 16 */ 1 , tab16 } ,
- { /* 16 */ 2 , tab16 } ,
- { /* 16 */ 3 , tab16 } ,
- { /* 16 */ 4 , tab16 } ,
- { /* 16 */ 6 , tab16 } ,
- { /* 16 */ 8 , tab16 } ,
- { /* 16 */ 10, tab16 } ,
- { /* 16 */ 13, tab16 } ,
- { /* 16 */ 4 , tab24 } ,
- { /* 16 */ 5 , tab24 } ,
- { /* 16 */ 6 , tab24 } ,
- { /* 16 */ 7 , tab24 } ,
- { /* 16 */ 8 , tab24 } ,
- { /* 16 */ 9 , tab24 } ,
- { /* 16 */ 11, tab24 } ,
- { /* 16 */ 13, tab24 }
+	{ /* 16 */ 1, tab16},
+	{ /* 16 */ 2, tab16},
+	{ /* 16 */ 3, tab16},
+	{ /* 16 */ 4, tab16},
+	{ /* 16 */ 6, tab16},
+	{ /* 16 */ 8, tab16},
+	{ /* 16 */ 10, tab16},
+	{ /* 16 */ 13, tab16},
+	{ /* 16 */ 4, tab24},
+	{ /* 16 */ 5, tab24},
+	{ /* 16 */ 6, tab24},
+	{ /* 16 */ 7, tab24},
+	{ /* 16 */ 8, tab24},
+	{ /* 16 */ 9, tab24},
+	{ /* 16 */ 11, tab24},
+	{ /* 16 */ 13, tab24}
 };
 
-static struct newhuff htc[] = 
-{
- { /* 1 , 1 , */ 0 , tab_c0 } ,
- { /* 1 , 1 , */ 0 , tab_c1 }
+static struct newhuff htc[] = {
+	{ /* 1 , 1 , */ 0, tab_c0},
+	{ /* 1 , 1 , */ 0, tab_c1}
 };
-
-
diff --git a/src/mod/formats/mod_shout/interface.c b/src/mod/formats/mod_shout/interface.c
index 8a9ec3ddf5..f188189377 100644
--- a/src/mod/formats/mod_shout/interface.c
+++ b/src/mod/formats/mod_shout/interface.c
@@ -9,21 +9,21 @@ void InitMP3Constants(void)
 {
 	init_layer3_const();
 	make_decode_tables_const();
-	
+
 }
 
 
-BOOL InitMP3(struct mpstr *mp, long outscale, int samplerate) 
+BOOL InitMP3(struct mpstr *mp, long outscale, int samplerate)
 {
 	/* quiet 4096 med 8192 */
 
-	memset(mp,0,sizeof(struct mpstr));
+	memset(mp, 0, sizeof(struct mpstr));
 
 	mp->framesize = 0;
 	mp->fsizeold = -1;
 	mp->bsize = 0;
 	mp->head = mp->tail = NULL;
-	mp->fr.single = 3; /* force mono */
+	mp->fr.single = 3;			/* force mono */
 	mp->bsnum = 0;
 	mp->synth_bo = 1;
 	mp->outsamplerate = samplerate;
@@ -37,10 +37,10 @@ BOOL InitMP3(struct mpstr *mp, long outscale, int samplerate)
 
 void ExitMP3(struct mpstr *mp)
 {
-	struct buf *b,*bn;
-	
+	struct buf *b, *bn;
+
 	b = mp->tail;
-	while(b) {
+	while (b) {
 		free(b->pnt);
 		bn = b->next;
 		free(b);
@@ -48,31 +48,30 @@ void ExitMP3(struct mpstr *mp)
 	}
 }
 
-static struct buf *addbuf(struct mpstr *mp,char *buf,int size)
+static struct buf *addbuf(struct mpstr *mp, char *buf, int size)
 {
 	struct buf *nbuf;
 
-	nbuf = malloc( sizeof(struct buf) );
-	if(!nbuf) {
-		debug_printf("%d Out of memory!\n",  __LINE__);
+	nbuf = malloc(sizeof(struct buf));
+	if (!nbuf) {
+		debug_printf("%d Out of memory!\n", __LINE__);
 		return NULL;
 	}
 	nbuf->pnt = malloc(size);
-	if(!nbuf->pnt) {
+	if (!nbuf->pnt) {
 		free(nbuf);
 		return NULL;
 	}
 	nbuf->size = size;
-	memcpy(nbuf->pnt,buf,size);
+	memcpy(nbuf->pnt, buf, size);
 	nbuf->next = NULL;
 	nbuf->prev = mp->head;
 	nbuf->pos = 0;
 
-	if(!mp->tail) {
+	if (!mp->tail) {
 		mp->tail = nbuf;
-	}
-	else {
-	  mp->head->next = nbuf;
+	} else {
+		mp->head->next = nbuf;
 	}
 
 	mp->head = nbuf;
@@ -83,50 +82,51 @@ static struct buf *addbuf(struct mpstr *mp,char *buf,int size)
 
 static void remove_buf(struct mpstr *mp)
 {
-  struct buf *buf = mp->tail;
-  
-  mp->tail = buf->next;
-  if(mp->tail)
-    mp->tail->prev = NULL;
-  else {
-    mp->tail = mp->head = NULL;
-  }
-  
-  free(buf->pnt);
-  free(buf);
+	struct buf *buf = mp->tail;
+
+	mp->tail = buf->next;
+	if (mp->tail)
+		mp->tail->prev = NULL;
+	else {
+		mp->tail = mp->head = NULL;
+	}
+
+	free(buf->pnt);
+	free(buf);
 
 }
 
 static int read_buf_byte(int *error, struct mpstr *mp)
 {
-	unsigned int b;int pos;
+	unsigned int b;
+	int pos;
 
 	pos = mp->tail->pos;
-	while(pos >= mp->tail->size) {
+	while (pos >= mp->tail->size) {
 		remove_buf(mp);
 		pos = mp->tail->pos;
-		if(!mp->tail) {
-			/* We may pick up this error a few times*/
+		if (!mp->tail) {
+			/* We may pick up this error a few times */
 			/* But things have gone pear shaped */
-			debug_printf("%d Fatal Buffer error!\n",  __LINE__);
+			debug_printf("%d Fatal Buffer error!\n", __LINE__);
 			*error = 1;
-			return (0);		
+			return (0);
 		}
 	}
 
 	b = mp->tail->pnt[pos];
 	mp->bsize--;
 	mp->tail->pos++;
-	
+
 
 	return b;
 }
 
-static int  read_head(struct mpstr *mp)
+static int read_head(struct mpstr *mp)
 {
 	unsigned long head;
-	int error=0;
-	
+	int error = 0;
+
 
 	head = read_buf_byte(&error, mp);
 	head <<= 8;
@@ -138,130 +138,127 @@ static int  read_head(struct mpstr *mp)
 
 	mp->header = head;
 
-	if(error){
+	if (error) {
 		return (1);
-	}else
+	} else
 		return (0);
-		
+
 }
 
 static int head_check(unsigned long head)
 {
-    if( (head & 0xffe00000) != 0xffe00000)
-	return FALSE;
-    if(!((head>>17)&3))
-	return FALSE;
-    if( ((head>>12)&0xf) == 0xf || ((head>>12)&0xf) == 0)
-	return FALSE;
-    if( ((head>>10)&0x3) == 0x3 )
-	return FALSE;
-    if ((head & 0xffff0000) == 0xfffe0000)
-      return FALSE;
+	if ((head & 0xffe00000) != 0xffe00000)
+		return FALSE;
+	if (!((head >> 17) & 3))
+		return FALSE;
+	if (((head >> 12) & 0xf) == 0xf || ((head >> 12) & 0xf) == 0)
+		return FALSE;
+	if (((head >> 10) & 0x3) == 0x3)
+		return FALSE;
+	if ((head & 0xffff0000) == 0xfffe0000)
+		return FALSE;
 
-    return TRUE;
+	return TRUE;
 }
 
 static int head_shift(struct mpstr *mp)
 {
 	unsigned long head;
 	int error = 0;
-	
+
 	head = mp->header;
-	
+
 	head <<= 8;
 	head |= read_buf_byte(&error, mp);
-	
+
 	mp->header = head;
 
-	if (error){
+	if (error) {
 		return (1);
-	}else
+	} else
 		return (0);
-	
+
 }
 
 
-int decodeMP3(struct mpstr *mp,char *in,int isize,char *out,
-		int osize,int *done)
+int decodeMP3(struct mpstr *mp, char *in, int isize, char *out, int osize, int *done)
 {
 	int len;
-	long n,m;
+	long n, m;
 	int down_sample_sblimit;
 
-	if(osize < 4608) {
-		debug_printf("%d To less out space\n",  __LINE__);
+	if (osize < 4608) {
+		debug_printf("%d To less out space\n", __LINE__);
 		return MP3_TOOSMALL;
 	}
 
-	if(in) {
-		if(addbuf(mp,in,isize) == NULL) {
+	if (in) {
+		if (addbuf(mp, in, isize) == NULL) {
 			return MP3_ERR;
 		}
 	}
 
 	/* First decode header */
-	if(mp->framesize == 0) {
-		if(mp->bsize < 4) {
+	if (mp->framesize == 0) {
+		if (mp->bsize < 4) {
 			return MP3_NEED_MORE;
 		}
 		if (read_head(mp))
 			return MP3_ERR;
-		
-		if(!head_check(mp->header) ) {
+
+		if (!head_check(mp->header)) {
 			int i;
 
-			debug_printf("Junk at the beginning of frame %08lx\n",mp->header);
-			
+			debug_printf("Junk at the beginning of frame %08lx\n", mp->header);
+
 			/* step in byte steps through next 64K */
-			for(i=0;i<65536;i++) {
-				if(!mp->bsize)
+			for (i = 0; i < 65536; i++) {
+				if (!mp->bsize)
 					return MP3_NEED_MORE;
-				
-				if(head_shift(mp))
+
+				if (head_shift(mp))
 					return MP3_ERR;
-				
-				if(head_check(mp->header))
+
+				if (head_check(mp->header))
 					break;
 			}
-			if(i == 65536) {
-				debug_printf("%d Giving up searching valid MPEG header\n",  __LINE__);
+			if (i == 65536) {
+				debug_printf("%d Giving up searching valid MPEG header\n", __LINE__);
 				return MP3_ERR;
 			}
 		}
 
-		decode_header(&mp->fr,mp->header);
+		decode_header(&mp->fr, mp->header);
 		mp->framesize = mp->fr.framesize;
 
-		if (!mp->initmp3){
+		if (!mp->initmp3) {
 			mp->initmp3 = 1;
-			
+
 			n = freqs[mp->fr.sampling_frequency];
 			if (mp->outsamplerate) {
 				m = mp->outsamplerate;
+			} else {
+				m = n;
 			}
-			else {
-				m =n;
-			}
-		
-			if (synth_ntom_set_step(n,m))
+
+			if (synth_ntom_set_step(n, m))
 				return MP3_ERR;
-			
-			
-			if(n>m) {
+
+
+			if (n > m) {
 				down_sample_sblimit = SBLIMIT * m;
 				down_sample_sblimit /= n;
-			}
-			else {
+			} else {
 				down_sample_sblimit = SBLIMIT;
 			}
-			
+
 			init_layer3_sample_limits(mp, down_sample_sblimit);
-	
+
 		}
 	}
-	
 
-	if(mp->fr.framesize > mp->bsize)
+
+	if (mp->fr.framesize > mp->bsize)
 		return MP3_NEED_MORE;
 
 	(mp->worksample).wordpointer = mp->bsspace[mp->bsnum] + 512;
@@ -269,29 +266,28 @@ int decodeMP3(struct mpstr *mp,char *in,int isize,char *out,
 	(mp->worksample).bitindex = 0;
 
 	len = 0;
-	while(len < mp->framesize) {
+	while (len < mp->framesize) {
 		int nlen;
 		int blen = mp->tail->size - mp->tail->pos;
-		if( (mp->framesize - len) <= blen) {
-                  nlen = mp->framesize-len;
+		if ((mp->framesize - len) <= blen) {
+			nlen = mp->framesize - len;
+		} else {
+			nlen = blen;
 		}
-		else {
-                  nlen = blen;
-                }
-		memcpy((mp->worksample).wordpointer+len,mp->tail->pnt+mp->tail->pos,nlen);
-                len += nlen;
-                mp->tail->pos += nlen;
+		memcpy((mp->worksample).wordpointer + len, mp->tail->pnt + mp->tail->pos, nlen);
+		len += nlen;
+		mp->tail->pos += nlen;
 		mp->bsize -= nlen;
-                if(mp->tail->pos == mp->tail->size) {
-                   remove_buf(mp);
-                }
+		if (mp->tail->pos == mp->tail->size) {
+			remove_buf(mp);
+		}
 	}
 
 	*done = 0;
-	if(mp->fr.error_protection)
-           getbits(mp, 16);
-	
-	if (do_layer3(mp,(unsigned char *) out,done))
+	if (mp->fr.error_protection)
+		getbits(mp, 16);
+
+	if (do_layer3(mp, (unsigned char *) out, done))
 		return MP3_ERR;
 
 	mp->fsizeold = mp->framesize;
@@ -302,19 +298,15 @@ int decodeMP3(struct mpstr *mp,char *in,int isize,char *out,
 
 int set_pointer(struct mpstr *mp, long backstep)
 {
-  unsigned char *bsbufold;
-  if(mp->fsizeold < 0 && backstep > 0) {
-    debug_printf("Can't step back %ld!\n",backstep);
-    return MP3_ERR;
-  }
-  bsbufold = mp->bsspace[mp->bsnum] + 512;
-  (mp->worksample).wordpointer -= backstep;
-  if (backstep)
-    memcpy((mp->worksample).wordpointer,bsbufold+mp->fsizeold-backstep,backstep);
-  (mp->worksample).bitindex = 0;
-  return MP3_OK;
+	unsigned char *bsbufold;
+	if (mp->fsizeold < 0 && backstep > 0) {
+		debug_printf("Can't step back %ld!\n", backstep);
+		return MP3_ERR;
+	}
+	bsbufold = mp->bsspace[mp->bsnum] + 512;
+	(mp->worksample).wordpointer -= backstep;
+	if (backstep)
+		memcpy((mp->worksample).wordpointer, bsbufold + mp->fsizeold - backstep, backstep);
+	(mp->worksample).bitindex = 0;
+	return MP3_OK;
 }
-
-
-
-
diff --git a/src/mod/formats/mod_shout/layer3.c b/src/mod/formats/mod_shout/layer3.c
index 33f58ef1f3..14153a8f64 100644
--- a/src/mod/formats/mod_shout/layer3.c
+++ b/src/mod/formats/mod_shout/layer3.c
@@ -3,7 +3,7 @@
  * --------------------------
  * copyright (c) 1995,1996,1997 by Michael Hipp.
  * All rights reserved. See also 'README'
- */ 
+ */
 
 
 #include 
@@ -15,70 +15,70 @@
 
 /* These should all be constants setup once using init_layer3_const */
 static real ispow[8207];
-static real aa_ca[8],aa_cs[8];
+static real aa_ca[8], aa_cs[8];
 static real COS1[12][6];
 static real win[4][36];
 static real win1[4][36];
-static real gainpow2[256+118+4];
+static real gainpow2[256 + 118 + 4];
 static real COS9[9];
-static real COS6_1,COS6_2;
+static real COS6_1, COS6_2;
 static real tfcos36[9];
 static real tfcos12[3];
 
 struct bandInfoStruct {
-  short longIdx[23];
-  short longDiff[22];
-  short shortIdx[14];
-  short shortDiff[13];
+	short longIdx[23];
+	short longDiff[22];
+	short shortIdx[14];
+	short shortDiff[13];
 };
 
 
-struct bandInfoStruct bandInfo[9] = { 
+struct bandInfoStruct bandInfo[9] = {
 
 /* MPEG 1.0 */
- { {0,4,8,12,16,20,24,30,36,44,52,62,74, 90,110,134,162,196,238,288,342,418,576},
-   {4,4,4,4,4,4,6,6,8, 8,10,12,16,20,24,28,34,42,50,54, 76,158},
-   {0,4*3,8*3,12*3,16*3,22*3,30*3,40*3,52*3,66*3, 84*3,106*3,136*3,192*3},
-   {4,4,4,4,6,8,10,12,14,18,22,30,56} } ,
+	{{0, 4, 8, 12, 16, 20, 24, 30, 36, 44, 52, 62, 74, 90, 110, 134, 162, 196, 238, 288, 342, 418, 576},
+	 {4, 4, 4, 4, 4, 4, 6, 6, 8, 8, 10, 12, 16, 20, 24, 28, 34, 42, 50, 54, 76, 158},
+	 {0, 4 * 3, 8 * 3, 12 * 3, 16 * 3, 22 * 3, 30 * 3, 40 * 3, 52 * 3, 66 * 3, 84 * 3, 106 * 3, 136 * 3, 192 * 3},
+	 {4, 4, 4, 4, 6, 8, 10, 12, 14, 18, 22, 30, 56}},
 
- { {0,4,8,12,16,20,24,30,36,42,50,60,72, 88,106,128,156,190,230,276,330,384,576},
-   {4,4,4,4,4,4,6,6,6, 8,10,12,16,18,22,28,34,40,46,54, 54,192},
-   {0,4*3,8*3,12*3,16*3,22*3,28*3,38*3,50*3,64*3, 80*3,100*3,126*3,192*3},
-   {4,4,4,4,6,6,10,12,14,16,20,26,66} } ,
+	{{0, 4, 8, 12, 16, 20, 24, 30, 36, 42, 50, 60, 72, 88, 106, 128, 156, 190, 230, 276, 330, 384, 576},
+	 {4, 4, 4, 4, 4, 4, 6, 6, 6, 8, 10, 12, 16, 18, 22, 28, 34, 40, 46, 54, 54, 192},
+	 {0, 4 * 3, 8 * 3, 12 * 3, 16 * 3, 22 * 3, 28 * 3, 38 * 3, 50 * 3, 64 * 3, 80 * 3, 100 * 3, 126 * 3, 192 * 3},
+	 {4, 4, 4, 4, 6, 6, 10, 12, 14, 16, 20, 26, 66}},
 
- { {0,4,8,12,16,20,24,30,36,44,54,66,82,102,126,156,194,240,296,364,448,550,576} ,
-   {4,4,4,4,4,4,6,6,8,10,12,16,20,24,30,38,46,56,68,84,102, 26} ,
-   {0,4*3,8*3,12*3,16*3,22*3,30*3,42*3,58*3,78*3,104*3,138*3,180*3,192*3} ,
-   {4,4,4,4,6,8,12,16,20,26,34,42,12} }  ,
+	{{0, 4, 8, 12, 16, 20, 24, 30, 36, 44, 54, 66, 82, 102, 126, 156, 194, 240, 296, 364, 448, 550, 576},
+	 {4, 4, 4, 4, 4, 4, 6, 6, 8, 10, 12, 16, 20, 24, 30, 38, 46, 56, 68, 84, 102, 26},
+	 {0, 4 * 3, 8 * 3, 12 * 3, 16 * 3, 22 * 3, 30 * 3, 42 * 3, 58 * 3, 78 * 3, 104 * 3, 138 * 3, 180 * 3, 192 * 3},
+	 {4, 4, 4, 4, 6, 8, 12, 16, 20, 26, 34, 42, 12}},
 
 /* MPEG 2.0 */
- { {0,6,12,18,24,30,36,44,54,66,80,96,116,140,168,200,238,284,336,396,464,522,576},
-   {6,6,6,6,6,6,8,10,12,14,16,20,24,28,32,38,46,52,60,68,58,54 } ,
-   {0,4*3,8*3,12*3,18*3,24*3,32*3,42*3,56*3,74*3,100*3,132*3,174*3,192*3} ,
-   {4,4,4,6,6,8,10,14,18,26,32,42,18 } } ,
+	{{0, 6, 12, 18, 24, 30, 36, 44, 54, 66, 80, 96, 116, 140, 168, 200, 238, 284, 336, 396, 464, 522, 576},
+	 {6, 6, 6, 6, 6, 6, 8, 10, 12, 14, 16, 20, 24, 28, 32, 38, 46, 52, 60, 68, 58, 54},
+	 {0, 4 * 3, 8 * 3, 12 * 3, 18 * 3, 24 * 3, 32 * 3, 42 * 3, 56 * 3, 74 * 3, 100 * 3, 132 * 3, 174 * 3, 192 * 3},
+	 {4, 4, 4, 6, 6, 8, 10, 14, 18, 26, 32, 42, 18}},
 
- { {0,6,12,18,24,30,36,44,54,66,80,96,114,136,162,194,232,278,330,394,464,540,576},
-   {6,6,6,6,6,6,8,10,12,14,16,18,22,26,32,38,46,52,64,70,76,36 } ,
-   {0,4*3,8*3,12*3,18*3,26*3,36*3,48*3,62*3,80*3,104*3,136*3,180*3,192*3} ,
-   {4,4,4,6,8,10,12,14,18,24,32,44,12 } } ,
+	{{0, 6, 12, 18, 24, 30, 36, 44, 54, 66, 80, 96, 114, 136, 162, 194, 232, 278, 330, 394, 464, 540, 576},
+	 {6, 6, 6, 6, 6, 6, 8, 10, 12, 14, 16, 18, 22, 26, 32, 38, 46, 52, 64, 70, 76, 36},
+	 {0, 4 * 3, 8 * 3, 12 * 3, 18 * 3, 26 * 3, 36 * 3, 48 * 3, 62 * 3, 80 * 3, 104 * 3, 136 * 3, 180 * 3, 192 * 3},
+	 {4, 4, 4, 6, 8, 10, 12, 14, 18, 24, 32, 44, 12}},
 
- { {0,6,12,18,24,30,36,44,54,66,80,96,116,140,168,200,238,284,336,396,464,522,576},
-   {6,6,6,6,6,6,8,10,12,14,16,20,24,28,32,38,46,52,60,68,58,54 },
-   {0,4*3,8*3,12*3,18*3,26*3,36*3,48*3,62*3,80*3,104*3,134*3,174*3,192*3},
-   {4,4,4,6,8,10,12,14,18,24,30,40,18 } } ,
+	{{0, 6, 12, 18, 24, 30, 36, 44, 54, 66, 80, 96, 116, 140, 168, 200, 238, 284, 336, 396, 464, 522, 576},
+	 {6, 6, 6, 6, 6, 6, 8, 10, 12, 14, 16, 20, 24, 28, 32, 38, 46, 52, 60, 68, 58, 54},
+	 {0, 4 * 3, 8 * 3, 12 * 3, 18 * 3, 26 * 3, 36 * 3, 48 * 3, 62 * 3, 80 * 3, 104 * 3, 134 * 3, 174 * 3, 192 * 3},
+	 {4, 4, 4, 6, 8, 10, 12, 14, 18, 24, 30, 40, 18}},
 /* MPEG 2.5 */
- { {0,6,12,18,24,30,36,44,54,66,80,96,116,140,168,200,238,284,336,396,464,522,576} ,
-   {6,6,6,6,6,6,8,10,12,14,16,20,24,28,32,38,46,52,60,68,58,54},
-   {0,12,24,36,54,78,108,144,186,240,312,402,522,576},
-   {4,4,4,6,8,10,12,14,18,24,30,40,18} },
- { {0,6,12,18,24,30,36,44,54,66,80,96,116,140,168,200,238,284,336,396,464,522,576} ,
-   {6,6,6,6,6,6,8,10,12,14,16,20,24,28,32,38,46,52,60,68,58,54},
-   {0,12,24,36,54,78,108,144,186,240,312,402,522,576},
-   {4,4,4,6,8,10,12,14,18,24,30,40,18} },
- { {0,12,24,36,48,60,72,88,108,132,160,192,232,280,336,400,476,566,568,570,572,574,576},
-   {12,12,12,12,12,12,16,20,24,28,32,40,48,56,64,76,90,2,2,2,2,2},
-   {0, 24, 48, 72,108,156,216,288,372,480,486,492,498,576},
-   {8,8,8,12,16,20,24,28,36,2,2,2,26} } ,
+	{{0, 6, 12, 18, 24, 30, 36, 44, 54, 66, 80, 96, 116, 140, 168, 200, 238, 284, 336, 396, 464, 522, 576},
+	 {6, 6, 6, 6, 6, 6, 8, 10, 12, 14, 16, 20, 24, 28, 32, 38, 46, 52, 60, 68, 58, 54},
+	 {0, 12, 24, 36, 54, 78, 108, 144, 186, 240, 312, 402, 522, 576},
+	 {4, 4, 4, 6, 8, 10, 12, 14, 18, 24, 30, 40, 18}},
+	{{0, 6, 12, 18, 24, 30, 36, 44, 54, 66, 80, 96, 116, 140, 168, 200, 238, 284, 336, 396, 464, 522, 576},
+	 {6, 6, 6, 6, 6, 6, 8, 10, 12, 14, 16, 20, 24, 28, 32, 38, 46, 52, 60, 68, 58, 54},
+	 {0, 12, 24, 36, 54, 78, 108, 144, 186, 240, 312, 402, 522, 576},
+	 {4, 4, 4, 6, 8, 10, 12, 14, 18, 24, 30, 40, 18}},
+	{{0, 12, 24, 36, 48, 60, 72, 88, 108, 132, 160, 192, 232, 280, 336, 400, 476, 566, 568, 570, 572, 574, 576},
+	 {12, 12, 12, 12, 12, 12, 16, 20, 24, 28, 32, 40, 48, 56, 64, 76, 90, 2, 2, 2, 2, 2},
+	 {0, 24, 48, 72, 108, 156, 216, 288, 372, 480, 486, 492, 498, 576},
+	 {8, 8, 8, 12, 16, 20, 24, 28, 36, 2, 2, 2, 26}},
 };
 
 static int mapbuf0[9][152];
@@ -87,206 +87,203 @@ static int mapbuf2[9][44];
 static int *map[9][3];
 static int *mapend[9][3];
 
-static unsigned int n_slen2[512]; /* MPEG 2.0 slen for 'normal' mode */
-static unsigned int i_slen2[256]; /* MPEG 2.0 slen for intensity stereo */
+static unsigned int n_slen2[512];	/* MPEG 2.0 slen for 'normal' mode */
+static unsigned int i_slen2[256];	/* MPEG 2.0 slen for intensity stereo */
 
-static real tan1_1[16],tan2_1[16],tan1_2[16],tan2_2[16];
-static real pow1_1[2][16],pow2_1[2][16],pow1_2[2][16],pow2_2[2][16];
+static real tan1_1[16], tan2_1[16], tan1_2[16], tan2_2[16];
+static real pow1_1[2][16], pow2_1[2][16], pow1_2[2][16], pow2_2[2][16];
 
 /* 
  * init constant tables for layer-3 
  */
 void init_layer3_const(void)
 {
-  int i,j,k,l;
+	int i, j, k, l;
 
-  for(i=-256;i<118+4;i++)
-    gainpow2[i+256] = pow((double)2.0,-0.25 * (double) (i+210) );
+	for (i = -256; i < 118 + 4; i++)
+		gainpow2[i + 256] = pow((double) 2.0, -0.25 * (double) (i + 210));
 
-  for(i=0;i<8207;i++)
-    ispow[i] = pow((double)i,(double)4.0/3.0);
+	for (i = 0; i < 8207; i++)
+		ispow[i] = pow((double) i, (double) 4.0 / 3.0);
 
-  for (i=0;i<8;i++)
-  {
-    static double Ci[8]={-0.6,-0.535,-0.33,-0.185,-0.095,-0.041,-0.0142,-0.0037};
-    double sq=sqrt(1.0+Ci[i]*Ci[i]);
-    aa_cs[i] = 1.0/sq;
-    aa_ca[i] = Ci[i]/sq;
-  }
+	for (i = 0; i < 8; i++) {
+		static double Ci[8] = { -0.6, -0.535, -0.33, -0.185, -0.095, -0.041, -0.0142, -0.0037 };
+		double sq = sqrt(1.0 + Ci[i] * Ci[i]);
+		aa_cs[i] = 1.0 / sq;
+		aa_ca[i] = Ci[i] / sq;
+	}
 
-  for(i=0;i<18;i++)
-  {
-    win[0][i]    = win[1][i]    = 0.5 * sin( M_PI / 72.0 * (double) (2*(i+0) +1) ) / cos ( M_PI * (double) (2*(i+0) +19) / 72.0 );
-    win[0][i+18] = win[3][i+18] = 0.5 * sin( M_PI / 72.0 * (double) (2*(i+18)+1) ) / cos ( M_PI * (double) (2*(i+18)+19) / 72.0 );
-  }
-  for(i=0;i<6;i++)
-  {
-    win[1][i+18] = 0.5 / cos ( M_PI * (double) (2*(i+18)+19) / 72.0 );
-    win[3][i+12] = 0.5 / cos ( M_PI * (double) (2*(i+12)+19) / 72.0 );
-    win[1][i+24] = 0.5 * sin( M_PI / 24.0 * (double) (2*i+13) ) / cos ( M_PI * (double) (2*(i+24)+19) / 72.0 );
-    win[1][i+30] = win[3][i] = 0.0;
-    win[3][i+6 ] = 0.5 * sin( M_PI / 24.0 * (double) (2*i+1) )  / cos ( M_PI * (double) (2*(i+6 )+19) / 72.0 );
-  }
+	for (i = 0; i < 18; i++) {
+		win[0][i] = win[1][i] =
+			0.5 * sin(M_PI / 72.0 * (double) (2 * (i + 0) + 1)) / cos(M_PI * (double) (2 * (i + 0) + 19) / 72.0);
+		win[0][i + 18] = win[3][i + 18] =
+			0.5 * sin(M_PI / 72.0 * (double) (2 * (i + 18) + 1)) / cos(M_PI * (double) (2 * (i + 18) + 19) / 72.0);
+	}
+	for (i = 0; i < 6; i++) {
+		win[1][i + 18] = 0.5 / cos(M_PI * (double) (2 * (i + 18) + 19) / 72.0);
+		win[3][i + 12] = 0.5 / cos(M_PI * (double) (2 * (i + 12) + 19) / 72.0);
+		win[1][i + 24] =
+			0.5 * sin(M_PI / 24.0 * (double) (2 * i + 13)) / cos(M_PI * (double) (2 * (i + 24) + 19) / 72.0);
+		win[1][i + 30] = win[3][i] = 0.0;
+		win[3][i + 6] = 0.5 * sin(M_PI / 24.0 * (double) (2 * i + 1)) / cos(M_PI * (double) (2 * (i + 6) + 19) / 72.0);
+	}
 
-  for(i=0;i<9;i++)
-    COS9[i] = cos( M_PI / 18.0 * (double) i);
+	for (i = 0; i < 9; i++)
+		COS9[i] = cos(M_PI / 18.0 * (double) i);
 
-  for(i=0;i<9;i++)
-    tfcos36[i] = 0.5 / cos ( M_PI * (double) (i*2+1) / 36.0 );
-  for(i=0;i<3;i++)
-    tfcos12[i] = 0.5 / cos ( M_PI * (double) (i*2+1) / 12.0 );
+	for (i = 0; i < 9; i++)
+		tfcos36[i] = 0.5 / cos(M_PI * (double) (i * 2 + 1) / 36.0);
+	for (i = 0; i < 3; i++)
+		tfcos12[i] = 0.5 / cos(M_PI * (double) (i * 2 + 1) / 12.0);
 
-  COS6_1 = cos( M_PI / 6.0 * (double) 1);
-  COS6_2 = cos( M_PI / 6.0 * (double) 2);
+	COS6_1 = cos(M_PI / 6.0 * (double) 1);
+	COS6_2 = cos(M_PI / 6.0 * (double) 2);
 
-  for(i=0;i<12;i++)
-  {
-    win[2][i]  = 0.5 * sin( M_PI / 24.0 * (double) (2*i+1) ) / cos ( M_PI * (double) (2*i+7) / 24.0 );
-    for(j=0;j<6;j++)
-      COS1[i][j] = cos( M_PI / 24.0 * (double) ((2*i+7)*(2*j+1)) );
-  }
+	for (i = 0; i < 12; i++) {
+		win[2][i] = 0.5 * sin(M_PI / 24.0 * (double) (2 * i + 1)) / cos(M_PI * (double) (2 * i + 7) / 24.0);
+		for (j = 0; j < 6; j++)
+			COS1[i][j] = cos(M_PI / 24.0 * (double) ((2 * i + 7) * (2 * j + 1)));
+	}
 
-  for(j=0;j<4;j++) {
-    static int len[4] = { 36,36,12,36 };
-    for(i=0;i 0) {
-        if( i & 1 )
-          p1 = pow(base,(i+1.0)*0.5);
-        else
-          p2 = pow(base,i*0.5);
-      }
-      pow1_1[j][i] = p1;
-      pow2_1[j][i] = p2;
-      pow1_2[j][i] = M_SQRT2 * p1;
-      pow2_2[j][i] = M_SQRT2 * p2;
-    }
-  }
+		for (j = 0; j < 2; j++) {
+			double base = pow(2.0, -0.25 * (j + 1.0));
+			double p1 = 1.0, p2 = 1.0;
+			if (i > 0) {
+				if (i & 1)
+					p1 = pow(base, (i + 1.0) * 0.5);
+				else
+					p2 = pow(base, i * 0.5);
+			}
+			pow1_1[j][i] = p1;
+			pow2_1[j][i] = p2;
+			pow1_2[j][i] = M_SQRT2 * p1;
+			pow2_2[j][i] = M_SQRT2 * p2;
+		}
+	}
 
-  for(j=0;j<9;j++)
-  {
-   struct bandInfoStruct *bi = &bandInfo[j];
-   int *mp;
-   int cb,lwin;
-   short *bdf;
+	for (j = 0; j < 9; j++) {
+		struct bandInfoStruct *bi = &bandInfo[j];
+		int *mp;
+		int cb, lwin;
+		short *bdf;
 
-   mp = map[j][0] = mapbuf0[j];
-   bdf = bi->longDiff;
-   for(i=0,cb = 0; cb < 8 ; cb++,i+=*bdf++) {
-     *mp++ = (*bdf) >> 1;
-     *mp++ = i;
-     *mp++ = 3;
-     *mp++ = cb;
-   }
-   bdf = bi->shortDiff+3;
-   for(cb=3;cb<13;cb++) {
-     int l = (*bdf++) >> 1;
-     for(lwin=0;lwin<3;lwin++) {
-       *mp++ = l;
-       *mp++ = i + lwin;
-       *mp++ = lwin;
-       *mp++ = cb;
-     }
-     i += 6*l;
-   }
-   mapend[j][0] = mp;
+		mp = map[j][0] = mapbuf0[j];
+		bdf = bi->longDiff;
+		for (i = 0, cb = 0; cb < 8; cb++, i += *bdf++) {
+			*mp++ = (*bdf) >> 1;
+			*mp++ = i;
+			*mp++ = 3;
+			*mp++ = cb;
+		}
+		bdf = bi->shortDiff + 3;
+		for (cb = 3; cb < 13; cb++) {
+			int l = (*bdf++) >> 1;
+			for (lwin = 0; lwin < 3; lwin++) {
+				*mp++ = l;
+				*mp++ = i + lwin;
+				*mp++ = lwin;
+				*mp++ = cb;
+			}
+			i += 6 * l;
+		}
+		mapend[j][0] = mp;
 
-   mp = map[j][1] = mapbuf1[j];
-   bdf = bi->shortDiff+0;
-   for(i=0,cb=0;cb<13;cb++) {
-     int l = (*bdf++) >> 1;
-     for(lwin=0;lwin<3;lwin++) {
-       *mp++ = l;
-       *mp++ = i + lwin;
-       *mp++ = lwin;
-       *mp++ = cb;
-     }
-     i += 6*l;
-   }
-   mapend[j][1] = mp;
+		mp = map[j][1] = mapbuf1[j];
+		bdf = bi->shortDiff + 0;
+		for (i = 0, cb = 0; cb < 13; cb++) {
+			int l = (*bdf++) >> 1;
+			for (lwin = 0; lwin < 3; lwin++) {
+				*mp++ = l;
+				*mp++ = i + lwin;
+				*mp++ = lwin;
+				*mp++ = cb;
+			}
+			i += 6 * l;
+		}
+		mapend[j][1] = mp;
 
-   mp = map[j][2] = mapbuf2[j];
-   bdf = bi->longDiff;
-   for(cb = 0; cb < 22 ; cb++) {
-     *mp++ = (*bdf++) >> 1;
-     *mp++ = cb;
-   }
-   mapend[j][2] = mp;
+		mp = map[j][2] = mapbuf2[j];
+		bdf = bi->longDiff;
+		for (cb = 0; cb < 22; cb++) {
+			*mp++ = (*bdf++) >> 1;
+			*mp++ = cb;
+		}
+		mapend[j][2] = mp;
 
-  }
+	}
 
-  for(i=0;i<5;i++) {
-    for(j=0;j<6;j++) {
-      for(k=0;k<6;k++) {
-        int n = k + j * 6 + i * 36;
-        i_slen2[n] = i|(j<<3)|(k<<6)|(3<<12);
-      }
-    }
-  }
-  for(i=0;i<4;i++) {
-    for(j=0;j<4;j++) {
-      for(k=0;k<4;k++) {
-        int n = k + j * 4 + i * 16;
-        i_slen2[n+180] = i|(j<<3)|(k<<6)|(4<<12);
-      }
-    }
-  }
-  for(i=0;i<4;i++) {
-    for(j=0;j<3;j++) {
-      int n = j + i * 3;
-      i_slen2[n+244] = i|(j<<3) | (5<<12);
-      n_slen2[n+500] = i|(j<<3) | (2<<12) | (1<<15);
-    }
-  }
+	for (i = 0; i < 5; i++) {
+		for (j = 0; j < 6; j++) {
+			for (k = 0; k < 6; k++) {
+				int n = k + j * 6 + i * 36;
+				i_slen2[n] = i | (j << 3) | (k << 6) | (3 << 12);
+			}
+		}
+	}
+	for (i = 0; i < 4; i++) {
+		for (j = 0; j < 4; j++) {
+			for (k = 0; k < 4; k++) {
+				int n = k + j * 4 + i * 16;
+				i_slen2[n + 180] = i | (j << 3) | (k << 6) | (4 << 12);
+			}
+		}
+	}
+	for (i = 0; i < 4; i++) {
+		for (j = 0; j < 3; j++) {
+			int n = j + i * 3;
+			i_slen2[n + 244] = i | (j << 3) | (5 << 12);
+			n_slen2[n + 500] = i | (j << 3) | (2 << 12) | (1 << 15);
+		}
+	}
 
-  for(i=0;i<5;i++) {
-    for(j=0;j<5;j++) {
-      for(k=0;k<4;k++) {
-        for(l=0;l<4;l++) {
-          int n = l + k * 4 + j * 16 + i * 80;
-          n_slen2[n] = i|(j<<3)|(k<<6)|(l<<9)|(0<<12);
-        }
-      }
-    }
-  }
-  for(i=0;i<5;i++) {
-    for(j=0;j<5;j++) {
-      for(k=0;k<4;k++) {
-        int n = k + j * 4 + i * 20;
-        n_slen2[n+400] = i|(j<<3)|(k<<6)|(1<<12);
-      }
-    }
-  }
+	for (i = 0; i < 5; i++) {
+		for (j = 0; j < 5; j++) {
+			for (k = 0; k < 4; k++) {
+				for (l = 0; l < 4; l++) {
+					int n = l + k * 4 + j * 16 + i * 80;
+					n_slen2[n] = i | (j << 3) | (k << 6) | (l << 9) | (0 << 12);
+				}
+			}
+		}
+	}
+	for (i = 0; i < 5; i++) {
+		for (j = 0; j < 5; j++) {
+			for (k = 0; k < 4; k++) {
+				int n = k + j * 4 + i * 20;
+				n_slen2[n + 400] = i | (j << 3) | (k << 6) | (1 << 12);
+			}
+		}
+	}
 }
 
 /* MP3 file specific rates */
 void init_layer3_sample_limits(struct mpstr *mp, int down_sample_sblimit)
 {
-	int i,j;	
-	for(j=0;j<9;j++) {
-		for(i=0;i<23;i++) {
+	int i, j;
+	for (j = 0; j < 9; j++) {
+		for (i = 0; i < 23; i++) {
 			(mp->longLimit)[j][i] = (bandInfo[j].longIdx[i] - 1 + 8) / 18 + 1;
-			if((mp->longLimit)[j][i] > (down_sample_sblimit) )
+			if ((mp->longLimit)[j][i] > (down_sample_sblimit))
 				(mp->longLimit)[j][i] = down_sample_sblimit;
 		}
-		for(i=0;i<14;i++) {
+		for (i = 0; i < 14; i++) {
 			(mp->shortLimit)[j][i] = (bandInfo[j].shortIdx[i] - 1) / 18 + 1;
-			if((mp->shortLimit)[j][i] > (down_sample_sblimit) )
+			if ((mp->shortLimit)[j][i] > (down_sample_sblimit))
 				(mp->shortLimit)[j][i] = down_sample_sblimit;
 		}
 	}
@@ -297,1272 +294,1221 @@ void init_layer3_sample_limits(struct mpstr *mp, int down_sample_sblimit)
 /*
  * read additional side information
  */
-#ifdef MPEG1 
-static int III_get_side_info_1(struct mpstr *mp, struct III_sideinfo *si,int stereo,
- int ms_stereo,long sfreq,int single)
+#ifdef MPEG1
+static int III_get_side_info_1(struct mpstr *mp, struct III_sideinfo *si, int stereo,
+							   int ms_stereo, long sfreq, int single)
 {
-   int ch, gr;
-   int powdiff = (single == 3) ? 4 : 0;
+	int ch, gr;
+	int powdiff = (single == 3) ? 4 : 0;
 
-   si->main_data_begin = getbits(mp, 9);
-   if (stereo == 1)
-     si->private_bits = getbits_fast(mp, 5);
-   else 
-     si->private_bits = getbits_fast(mp, 3);
+	si->main_data_begin = getbits(mp, 9);
+	if (stereo == 1)
+		si->private_bits = getbits_fast(mp, 5);
+	else
+		si->private_bits = getbits_fast(mp, 3);
 
-   for (ch=0; chch[ch].gr[0].scfsi = -1;
-       si->ch[ch].gr[1].scfsi = getbits_fast(mp, 4);
-   }
+	for (ch = 0; ch < stereo; ch++) {
+		si->ch[ch].gr[0].scfsi = -1;
+		si->ch[ch].gr[1].scfsi = getbits_fast(mp, 4);
+	}
 
-   for (gr=0; gr<2; gr++) 
-   {
-     for (ch=0; chch[ch].gr[gr]);
+	for (gr = 0; gr < 2; gr++) {
+		for (ch = 0; ch < stereo; ch++) {
+			register struct gr_info_s *gr_info = &(si->ch[ch].gr[gr]);
 
-       gr_info->part2_3_length = getbits(mp, 12);
-       gr_info->big_values = getbits_fast(mp, 9);
-       if(gr_info->big_values > 288) {
-		   debug_printf("%d big_values too large!\n", __LINE__);
-          gr_info->big_values = 288;
-       }
-       gr_info->pow2gain = gainpow2+256 - getbits_fast(mp, 8) + powdiff;
-       if(ms_stereo)
-         gr_info->pow2gain += 2;
-       gr_info->scalefac_compress = getbits_fast(mp, 4);
+			gr_info->part2_3_length = getbits(mp, 12);
+			gr_info->big_values = getbits_fast(mp, 9);
+			if (gr_info->big_values > 288) {
+				debug_printf("%d big_values too large!\n", __LINE__);
+				gr_info->big_values = 288;
+			}
+			gr_info->pow2gain = gainpow2 + 256 - getbits_fast(mp, 8) + powdiff;
+			if (ms_stereo)
+				gr_info->pow2gain += 2;
+			gr_info->scalefac_compress = getbits_fast(mp, 4);
 /* window-switching flag == 1 for block_Type != 0 .. and block-type == 0 -> win-sw-flag = 0 */
-       if(get1bit(mp)) 
-       {
-         int i;
-         gr_info->block_type = getbits_fast(mp, 2);
-         gr_info->mixed_block_flag = get1bit(mp);
-         gr_info->table_select[0] = getbits_fast(mp, 5);
-         gr_info->table_select[1] = getbits_fast(mp, 5);
-         /*
-          * table_select[2] not needed, because there is no region2,
-          * but to satisfy some verifications tools we set it either.
-          */
-         gr_info->table_select[2] = 0;
-         for(i=0;i<3;i++)
-           gr_info->full_gain[i] = gr_info->pow2gain + (getbits_fast(mp, 3)<<3);
+			if (get1bit(mp)) {
+				int i;
+				gr_info->block_type = getbits_fast(mp, 2);
+				gr_info->mixed_block_flag = get1bit(mp);
+				gr_info->table_select[0] = getbits_fast(mp, 5);
+				gr_info->table_select[1] = getbits_fast(mp, 5);
+				/*
+				 * table_select[2] not needed, because there is no region2,
+				 * but to satisfy some verifications tools we set it either.
+				 */
+				gr_info->table_select[2] = 0;
+				for (i = 0; i < 3; i++)
+					gr_info->full_gain[i] = gr_info->pow2gain + (getbits_fast(mp, 3) << 3);
+
+				if (gr_info->block_type == 0) {
+					debug_printf("%d Blocktype == 0 and window-switching == 1 not allowed.\n", __LINE__);
+					return (1);
+				}
+				/* region_count/start parameters are implicit in this case. */
+				gr_info->region1start = 36 >> 1;
+				gr_info->region2start = 576 >> 1;
+			} else {
+				int i, r0c, r1c;
+				for (i = 0; i < 3; i++)
+					gr_info->table_select[i] = getbits_fast(mp, 5);
+				r0c = getbits_fast(mp, 4);
+				r1c = getbits_fast(mp, 3);
+				gr_info->region1start = bandInfo[sfreq].longIdx[r0c + 1] >> 1;
+				gr_info->region2start = bandInfo[sfreq].longIdx[r0c + 1 + r1c + 1] >> 1;
+				gr_info->block_type = 0;
+				gr_info->mixed_block_flag = 0;
+			}
+			gr_info->preflag = get1bit(mp);
+			gr_info->scalefac_scale = get1bit(mp);
+			gr_info->count1table_select = get1bit(mp);
+		}
+	}
+	return (0);
 
-         if(gr_info->block_type == 0) {
-			 debug_printf("%d Blocktype == 0 and window-switching == 1 not allowed.\n",  __LINE__);
-           return (1);
-         }
-         /* region_count/start parameters are implicit in this case. */       
-         gr_info->region1start = 36>>1;
-         gr_info->region2start = 576>>1;
-       }
-       else 
-       {
-         int i,r0c,r1c;
-         for (i=0; i<3; i++)
-           gr_info->table_select[i] = getbits_fast(mp, 5);
-         r0c = getbits_fast(mp, 4);
-         r1c = getbits_fast(mp, 3);
-         gr_info->region1start = bandInfo[sfreq].longIdx[r0c+1] >> 1 ;
-         gr_info->region2start = bandInfo[sfreq].longIdx[r0c+1+r1c+1] >> 1;
-         gr_info->block_type = 0;
-         gr_info->mixed_block_flag = 0;
-       }
-       gr_info->preflag = get1bit(mp);
-       gr_info->scalefac_scale = get1bit(mp);
-       gr_info->count1table_select = get1bit(mp);
-     }
-   }
-   return (0);
-   
 }
 #endif
 
 /*
  * Side Info for MPEG 2.0 / LSF
  */
-static int III_get_side_info_2(struct mpstr *mp, struct III_sideinfo *si,int stereo,
- int ms_stereo,long sfreq,int single)
+static int III_get_side_info_2(struct mpstr *mp, struct III_sideinfo *si, int stereo,
+							   int ms_stereo, long sfreq, int single)
 {
-   int ch;
-   int powdiff = (single == 3) ? 4 : 0;
+	int ch;
+	int powdiff = (single == 3) ? 4 : 0;
 
-   si->main_data_begin = getbits(mp, 8);
-   if (stereo == 1)
-     si->private_bits = get1bit(mp);
-   else 
-     si->private_bits = getbits_fast(mp, 2);
+	si->main_data_begin = getbits(mp, 8);
+	if (stereo == 1)
+		si->private_bits = get1bit(mp);
+	else
+		si->private_bits = getbits_fast(mp, 2);
 
-   for (ch=0; chch[ch].gr[0]);
+	for (ch = 0; ch < stereo; ch++) {
+		register struct gr_info_s *gr_info = &(si->ch[ch].gr[0]);
 
-       gr_info->part2_3_length = getbits(mp, 12);
-       gr_info->big_values = getbits_fast(mp, 9);
-       if(gr_info->big_values > 288) {
-		   debug_printf("%d big_values too large!\n",  __LINE__);
-         gr_info->big_values = 288;
-       }
-       gr_info->pow2gain = gainpow2+256 - getbits_fast(mp, 8) + powdiff;
-       if(ms_stereo)
-         gr_info->pow2gain += 2;
-       gr_info->scalefac_compress = getbits(mp, 9);
+		gr_info->part2_3_length = getbits(mp, 12);
+		gr_info->big_values = getbits_fast(mp, 9);
+		if (gr_info->big_values > 288) {
+			debug_printf("%d big_values too large!\n", __LINE__);
+			gr_info->big_values = 288;
+		}
+		gr_info->pow2gain = gainpow2 + 256 - getbits_fast(mp, 8) + powdiff;
+		if (ms_stereo)
+			gr_info->pow2gain += 2;
+		gr_info->scalefac_compress = getbits(mp, 9);
 /* window-switching flag == 1 for block_Type != 0 .. and block-type == 0 -> win-sw-flag = 0 */
-       if(get1bit(mp)) 
-       {
-         int i;
-         gr_info->block_type = getbits_fast(mp, 2);
-         gr_info->mixed_block_flag = get1bit(mp);
-         gr_info->table_select[0] = getbits_fast(mp, 5);
-         gr_info->table_select[1] = getbits_fast(mp, 5);
-         /*
-          * table_select[2] not needed, because there is no region2,
-          * but to satisfy some verifications tools we set it either.
-          */
-         gr_info->table_select[2] = 0;
-         for(i=0;i<3;i++)
-           gr_info->full_gain[i] = gr_info->pow2gain + (getbits_fast(mp, 3)<<3);
+		if (get1bit(mp)) {
+			int i;
+			gr_info->block_type = getbits_fast(mp, 2);
+			gr_info->mixed_block_flag = get1bit(mp);
+			gr_info->table_select[0] = getbits_fast(mp, 5);
+			gr_info->table_select[1] = getbits_fast(mp, 5);
+			/*
+			 * table_select[2] not needed, because there is no region2,
+			 * but to satisfy some verifications tools we set it either.
+			 */
+			gr_info->table_select[2] = 0;
+			for (i = 0; i < 3; i++)
+				gr_info->full_gain[i] = gr_info->pow2gain + (getbits_fast(mp, 3) << 3);
 
-         if(gr_info->block_type == 0) {
-			 debug_printf("%d Blocktype == 0 and window-switching == 1 not allowed.\n",  __LINE__);
-           return (1);
-         }
-         /* region_count/start parameters are implicit in this case. */       
+			if (gr_info->block_type == 0) {
+				debug_printf("%d Blocktype == 0 and window-switching == 1 not allowed.\n", __LINE__);
+				return (1);
+			}
+			/* region_count/start parameters are implicit in this case. */
 /* check this again! */
-         if(gr_info->block_type == 2)
-           gr_info->region1start = 36>>1;
-         else if(sfreq == 8)
+			if (gr_info->block_type == 2)
+				gr_info->region1start = 36 >> 1;
+			else if (sfreq == 8)
 /* check this for 2.5 and sfreq=8 */
-           gr_info->region1start = 108>>1;
-         else
-           gr_info->region1start = 54>>1;
-         gr_info->region2start = 576>>1;
-       }
-       else 
-       {
-         int i,r0c,r1c;
-         for (i=0; i<3; i++)
-           gr_info->table_select[i] = getbits_fast(mp, 5);
-         r0c = getbits_fast(mp, 4);
-         r1c = getbits_fast(mp, 3);
-         gr_info->region1start = bandInfo[sfreq].longIdx[r0c+1] >> 1 ;
-         gr_info->region2start = bandInfo[sfreq].longIdx[r0c+1+r1c+1] >> 1;
-         gr_info->block_type = 0;
-         gr_info->mixed_block_flag = 0;
-       }
-       gr_info->scalefac_scale = get1bit(mp);
-       gr_info->count1table_select = get1bit(mp);
-   }
-   return (0);
+				gr_info->region1start = 108 >> 1;
+			else
+				gr_info->region1start = 54 >> 1;
+			gr_info->region2start = 576 >> 1;
+		} else {
+			int i, r0c, r1c;
+			for (i = 0; i < 3; i++)
+				gr_info->table_select[i] = getbits_fast(mp, 5);
+			r0c = getbits_fast(mp, 4);
+			r1c = getbits_fast(mp, 3);
+			gr_info->region1start = bandInfo[sfreq].longIdx[r0c + 1] >> 1;
+			gr_info->region2start = bandInfo[sfreq].longIdx[r0c + 1 + r1c + 1] >> 1;
+			gr_info->block_type = 0;
+			gr_info->mixed_block_flag = 0;
+		}
+		gr_info->scalefac_scale = get1bit(mp);
+		gr_info->count1table_select = get1bit(mp);
+	}
+	return (0);
 }
 
 /*
  * read scalefactors
  */
 #ifdef MPEG1
-static int III_get_scale_factors_1(struct mpstr *mp, int *scf,struct gr_info_s *gr_info)
+static int III_get_scale_factors_1(struct mpstr *mp, int *scf, struct gr_info_s *gr_info)
 {
-   static unsigned char slen[2][16] = {
-     {0, 0, 0, 0, 3, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4},
-     {0, 1, 2, 3, 0, 1, 2, 3, 1, 2, 3, 1, 2, 3, 2, 3}
-   };
-   int numbits;
-   int num0 = slen[0][gr_info->scalefac_compress];
-   int num1 = slen[1][gr_info->scalefac_compress];
+	static unsigned char slen[2][16] = {
+		{0, 0, 0, 0, 3, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4},
+		{0, 1, 2, 3, 0, 1, 2, 3, 1, 2, 3, 1, 2, 3, 2, 3}
+	};
+	int numbits;
+	int num0 = slen[0][gr_info->scalefac_compress];
+	int num1 = slen[1][gr_info->scalefac_compress];
 
-    if (gr_info->block_type == 2) 
-    {
-      int i=18;
-      numbits = (num0 + num1) * 18;
+	if (gr_info->block_type == 2) {
+		int i = 18;
+		numbits = (num0 + num1) * 18;
 
-      if (gr_info->mixed_block_flag) {
-         for (i=8;i;i--)
-           *scf++ = getbits_fast(mp, num0);
-         i = 9;
-         numbits -= num0; /* num0 * 17 + num1 * 18 */
-      }
+		if (gr_info->mixed_block_flag) {
+			for (i = 8; i; i--)
+				*scf++ = getbits_fast(mp, num0);
+			i = 9;
+			numbits -= num0;	/* num0 * 17 + num1 * 18 */
+		}
 
-      for (;i;i--)
-        *scf++ = getbits_fast(mp, num0);
-      for (i = 18; i; i--)
-        *scf++ = getbits_fast(mp, num1);
-      *scf++ = 0; *scf++ = 0; *scf++ = 0; /* short[13][0..2] = 0 */
-    }
-    else 
-    {
-      int i;
-      int scfsi = gr_info->scfsi;
+		for (; i; i--)
+			*scf++ = getbits_fast(mp, num0);
+		for (i = 18; i; i--)
+			*scf++ = getbits_fast(mp, num1);
+		*scf++ = 0;
+		*scf++ = 0;
+		*scf++ = 0;				/* short[13][0..2] = 0 */
+	} else {
+		int i;
+		int scfsi = gr_info->scfsi;
 
-      if(scfsi < 0) { /* scfsi < 0 => granule == 0 */
-         for(i=11;i;i--)
-           *scf++ = getbits_fast(mp, num0);
-         for(i=10;i;i--)
-           *scf++ = getbits_fast(mp, num1);
-         numbits = (num0 + num1) * 10 + num0;
-      }
-      else {
-        numbits = 0;
-        if(!(scfsi & 0x8)) {
-          for (i=6;i;i--)
-            *scf++ = getbits_fast(mp, num0);
-          numbits += num0 * 6;
-        }
-        else {
-          *scf++ = 0; *scf++ = 0; *scf++ = 0;  /* set to ZERO necessary? */
-          *scf++ = 0; *scf++ = 0; *scf++ = 0;
-        }
+		if (scfsi < 0) {		/* scfsi < 0 => granule == 0 */
+			for (i = 11; i; i--)
+				*scf++ = getbits_fast(mp, num0);
+			for (i = 10; i; i--)
+				*scf++ = getbits_fast(mp, num1);
+			numbits = (num0 + num1) * 10 + num0;
+		} else {
+			numbits = 0;
+			if (!(scfsi & 0x8)) {
+				for (i = 6; i; i--)
+					*scf++ = getbits_fast(mp, num0);
+				numbits += num0 * 6;
+			} else {
+				*scf++ = 0;
+				*scf++ = 0;
+				*scf++ = 0;		/* set to ZERO necessary? */
+				*scf++ = 0;
+				*scf++ = 0;
+				*scf++ = 0;
+			}
 
-        if(!(scfsi & 0x4)) {
-          for (i=5;i;i--)
-            *scf++ = getbits_fast(mp, num0);
-          numbits += num0 * 5;
-        }
-        else {
-          *scf++ = 0; *scf++ = 0; *scf++ = 0;  /* set to ZERO necessary? */
-          *scf++ = 0; *scf++ = 0;
-        }
+			if (!(scfsi & 0x4)) {
+				for (i = 5; i; i--)
+					*scf++ = getbits_fast(mp, num0);
+				numbits += num0 * 5;
+			} else {
+				*scf++ = 0;
+				*scf++ = 0;
+				*scf++ = 0;		/* set to ZERO necessary? */
+				*scf++ = 0;
+				*scf++ = 0;
+			}
 
-        if(!(scfsi & 0x2)) {
-          for(i=5;i;i--)
-            *scf++ = getbits_fast(mp, num1);
-          numbits += num1 * 5;
-        }
-        else {
-          *scf++ = 0; *scf++ = 0; *scf++ = 0;  /* set to ZERO necessary? */
-          *scf++ = 0; *scf++ = 0;
-        }
+			if (!(scfsi & 0x2)) {
+				for (i = 5; i; i--)
+					*scf++ = getbits_fast(mp, num1);
+				numbits += num1 * 5;
+			} else {
+				*scf++ = 0;
+				*scf++ = 0;
+				*scf++ = 0;		/* set to ZERO necessary? */
+				*scf++ = 0;
+				*scf++ = 0;
+			}
 
-        if(!(scfsi & 0x1)) {
-          for (i=5;i;i--)
-            *scf++ = getbits_fast(mp, num1);
-          numbits += num1 * 5;
-        }
-        else {
-          *scf++ = 0; *scf++ = 0; *scf++ = 0;  /* set to ZERO necessary? */
-          *scf++ = 0; *scf++ = 0;
-        }
-      }
+			if (!(scfsi & 0x1)) {
+				for (i = 5; i; i--)
+					*scf++ = getbits_fast(mp, num1);
+				numbits += num1 * 5;
+			} else {
+				*scf++ = 0;
+				*scf++ = 0;
+				*scf++ = 0;		/* set to ZERO necessary? */
+				*scf++ = 0;
+				*scf++ = 0;
+			}
+		}
 
-      *scf++ = 0;  /* no l[21] in original sources */
-    }
-    return numbits;
+		*scf++ = 0;				/* no l[21] in original sources */
+	}
+	return numbits;
 }
 #endif
 
-static int III_get_scale_factors_2(struct mpstr *mp, int *scf,struct gr_info_s *gr_info,int i_stereo)
+static int III_get_scale_factors_2(struct mpstr *mp, int *scf, struct gr_info_s *gr_info, int i_stereo)
 {
-  unsigned char *pnt;
-  int i,j;
-  unsigned int slen;
-  int n = 0;
-  int numbits = 0;
+	unsigned char *pnt;
+	int i, j;
+	unsigned int slen;
+	int n = 0;
+	int numbits = 0;
 
-  static unsigned char stab[3][6][4] = {
-   { { 6, 5, 5,5 } , { 6, 5, 7,3 } , { 11,10,0,0} ,
-     { 7, 7, 7,0 } , { 6, 6, 6,3 } , {  8, 8,5,0} } ,
-   { { 9, 9, 9,9 } , { 9, 9,12,6 } , { 18,18,0,0} ,
-     {12,12,12,0 } , {12, 9, 9,6 } , { 15,12,9,0} } ,
-   { { 6, 9, 9,9 } , { 6, 9,12,6 } , { 15,18,0,0} ,
-     { 6,15,12,0 } , { 6,12, 9,6 } , {  6,18,9,0} } }; 
+	static unsigned char stab[3][6][4] = {
+		{{6, 5, 5, 5}, {6, 5, 7, 3}, {11, 10, 0, 0},
+		 {7, 7, 7, 0}, {6, 6, 6, 3}, {8, 8, 5, 0}},
+		{{9, 9, 9, 9}, {9, 9, 12, 6}, {18, 18, 0, 0},
+		 {12, 12, 12, 0}, {12, 9, 9, 6}, {15, 12, 9, 0}},
+		{{6, 9, 9, 9}, {6, 9, 12, 6}, {15, 18, 0, 0},
+		 {6, 15, 12, 0}, {6, 12, 9, 6}, {6, 18, 9, 0}}
+	};
 
-  if(i_stereo) /* i_stereo AND second channel -> do_layer3() checks this */
-    slen = i_slen2[gr_info->scalefac_compress>>1];
-  else
-    slen = n_slen2[gr_info->scalefac_compress];
+	if (i_stereo)				/* i_stereo AND second channel -> do_layer3() checks this */
+		slen = i_slen2[gr_info->scalefac_compress >> 1];
+	else
+		slen = n_slen2[gr_info->scalefac_compress];
 
-  gr_info->preflag = (slen>>15) & 0x1;
+	gr_info->preflag = (slen >> 15) & 0x1;
 
-  n = 0;  
-  if( gr_info->block_type == 2 ) {
-    n++;
-    if(gr_info->mixed_block_flag)
-      n++;
-  }
+	n = 0;
+	if (gr_info->block_type == 2) {
+		n++;
+		if (gr_info->mixed_block_flag)
+			n++;
+	}
 
-  pnt = stab[n][(slen>>12)&0x7];
+	pnt = stab[n][(slen >> 12) & 0x7];
 
-  for(i=0;i<4;i++) {
-    int num = slen & 0x7;
-    slen >>= 3;
-    if(num) {
-      for(j=0;j<(int)(pnt[i]);j++)
-        *scf++ = getbits_fast(mp, num);
-      numbits += pnt[i] * num;
-    }
-    else {
-      for(j=0;j<(int)(pnt[i]);j++)
-        *scf++ = 0;
-    }
-  }
-  
-  n = (n << 1) + 1;
-  for(i=0;i>= 3;
+		if (num) {
+			for (j = 0; j < (int) (pnt[i]); j++)
+				*scf++ = getbits_fast(mp, num);
+			numbits += pnt[i] * num;
+		} else {
+			for (j = 0; j < (int) (pnt[i]); j++)
+				*scf++ = 0;
+		}
+	}
 
-  return numbits;
+	n = (n << 1) + 1;
+	for (i = 0; i < n; i++)
+		*scf++ = 0;
+
+	return numbits;
 }
 
-static int pretab1[22] = {0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,2,2,3,3,3,2,0};
-static int pretab2[22] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
+static int pretab1[22] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 3, 3, 3, 2, 0 };
+static int pretab2[22] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
 
 /*
  * don't forget to apply the same changes to III_dequantize_sample_ms() !!! 
  */
-static int III_dequantize_sample(struct mpstr *mp, real xr[SBLIMIT][SSLIMIT],int *scf,
-   struct gr_info_s *gr_info,int sfreq,int part2bits)
+static int III_dequantize_sample(struct mpstr *mp, real xr[SBLIMIT][SSLIMIT], int *scf,
+								 struct gr_info_s *gr_info, int sfreq, int part2bits)
 {
-  int shift = 1 + gr_info->scalefac_scale;
-  real *xrpnt = (real *) xr;
-  int l[3],l3;
-  int part2remain = gr_info->part2_3_length - part2bits;
-  int *me;
+	int shift = 1 + gr_info->scalefac_scale;
+	real *xrpnt = (real *) xr;
+	int l[3], l3;
+	int part2remain = gr_info->part2_3_length - part2bits;
+	int *me;
 
-  {
-    int bv       = gr_info->big_values;
-    int region1  = gr_info->region1start;
-    int region2  = gr_info->region2start;
+	{
+		int bv = gr_info->big_values;
+		int region1 = gr_info->region1start;
+		int region2 = gr_info->region2start;
 
-    l3 = ((576>>1)-bv)>>1;   
+		l3 = ((576 >> 1) - bv) >> 1;
 /*
  * we may lose the 'odd' bit here !! 
  * check this later again 
  */
-    if(bv <= region1) {
-      l[0] = bv; l[1] = 0; l[2] = 0;
-    }
-    else {
-      l[0] = region1;
-      if(bv <= region2) {
-        l[1] = bv - l[0];  l[2] = 0;
-      }
-      else {
-        l[1] = region2 - l[0]; l[2] = bv - region2;
-      }
-    }
-  }
- 
-  if(gr_info->block_type == 2) {
-    /*
-     * decoding with short or mixed mode BandIndex table 
-     */
-    int i,max[4];
-    int step=0,lwin=0,cb=0;
-    register real v = 0.0;
-    register int *m,mc;
+		if (bv <= region1) {
+			l[0] = bv;
+			l[1] = 0;
+			l[2] = 0;
+		} else {
+			l[0] = region1;
+			if (bv <= region2) {
+				l[1] = bv - l[0];
+				l[2] = 0;
+			} else {
+				l[1] = region2 - l[0];
+				l[2] = bv - region2;
+			}
+		}
+	}
 
-    if(gr_info->mixed_block_flag) {
-      max[3] = -1;
-      max[0] = max[1] = max[2] = 2;
-      m = map[sfreq][0];
-      me = mapend[sfreq][0];
-    }
-    else {
-      max[0] = max[1] = max[2] = max[3] = -1;
-      /* max[3] not really needed in this case */
-      m = map[sfreq][1];
-      me = mapend[sfreq][1];
-    }
+	if (gr_info->block_type == 2) {
+		/*
+		 * decoding with short or mixed mode BandIndex table 
+		 */
+		int i, max[4];
+		int step = 0, lwin = 0, cb = 0;
+		register real v = 0.0;
+		register int *m, mc;
 
-    mc = 0;
-    for(i=0;i<2;i++) {
-      int lp = l[i];
-      struct newhuff *h = ht+gr_info->table_select[i];
-      for(;lp;lp--,mc--) {
-        register int x,y;
-        if( (!mc) ) {
-          mc = *m++;
-          xrpnt = ((real *) xr) + (*m++);
-          lwin = *m++;
-          cb = *m++;
-          if(lwin == 3) {
-            v = gr_info->pow2gain[(*scf++) << shift];
-            step = 1;
-          }
-          else {
-            v = gr_info->full_gain[lwin][(*scf++) << shift];
-            step = 3;
-          }
-        }
-        {
-          register short *val = h->table;
-          while((y=*val++)<0) {
-            if (get1bit(mp))
-              val -= y;
-            part2remain--;
-          }
-          x = y >> 4;
-          y &= 0xf;
-        }
-        if(x == 15) {
-          max[lwin] = cb;
-          part2remain -= h->linbits+1;
-          x += getbits(mp, h->linbits);
-          if(get1bit(mp))
-            *xrpnt = -ispow[x] * v;
-          else
-            *xrpnt =  ispow[x] * v;
-        }
-        else if(x) {
-          max[lwin] = cb;
-          if(get1bit(mp))
-            *xrpnt = -ispow[x] * v;
-          else
-            *xrpnt =  ispow[x] * v;
-          part2remain--;
-        }
-        else
-          *xrpnt = 0.0;
-        xrpnt += step;
-        if(y == 15) {
-          max[lwin] = cb;
-          part2remain -= h->linbits+1;
-          y += getbits(mp, h->linbits);
-          if(get1bit(mp))
-            *xrpnt = -ispow[y] * v;
-          else
-            *xrpnt =  ispow[y] * v;
-        }
-        else if(y) {
-          max[lwin] = cb;
-          if(get1bit(mp))
-            *xrpnt = -ispow[y] * v;
-          else
-            *xrpnt =  ispow[y] * v;
-          part2remain--;
-        }
-        else
-          *xrpnt = 0.0;
-        xrpnt += step;
-      }
-    }
-    for(;l3 && (part2remain > 0);l3--) {
-      struct newhuff *h = htc+gr_info->count1table_select;
-      register short *val = h->table,a;
+		if (gr_info->mixed_block_flag) {
+			max[3] = -1;
+			max[0] = max[1] = max[2] = 2;
+			m = map[sfreq][0];
+			me = mapend[sfreq][0];
+		} else {
+			max[0] = max[1] = max[2] = max[3] = -1;
+			/* max[3] not really needed in this case */
+			m = map[sfreq][1];
+			me = mapend[sfreq][1];
+		}
 
-      while((a=*val++)<0) {
-        part2remain--;
-        if(part2remain < 0) {
-          part2remain++;
-          a = 0;
-          break;
-        }
-        if (get1bit(mp))
-          val -= a;
-      }
+		mc = 0;
+		for (i = 0; i < 2; i++) {
+			int lp = l[i];
+			struct newhuff *h = ht + gr_info->table_select[i];
+			for (; lp; lp--, mc--) {
+				register int x, y;
+				if ((!mc)) {
+					mc = *m++;
+					xrpnt = ((real *) xr) + (*m++);
+					lwin = *m++;
+					cb = *m++;
+					if (lwin == 3) {
+						v = gr_info->pow2gain[(*scf++) << shift];
+						step = 1;
+					} else {
+						v = gr_info->full_gain[lwin][(*scf++) << shift];
+						step = 3;
+					}
+				}
+				{
+					register short *val = h->table;
+					while ((y = *val++) < 0) {
+						if (get1bit(mp))
+							val -= y;
+						part2remain--;
+					}
+					x = y >> 4;
+					y &= 0xf;
+				}
+				if (x == 15) {
+					max[lwin] = cb;
+					part2remain -= h->linbits + 1;
+					x += getbits(mp, h->linbits);
+					if (get1bit(mp))
+						*xrpnt = -ispow[x] * v;
+					else
+						*xrpnt = ispow[x] * v;
+				} else if (x) {
+					max[lwin] = cb;
+					if (get1bit(mp))
+						*xrpnt = -ispow[x] * v;
+					else
+						*xrpnt = ispow[x] * v;
+					part2remain--;
+				} else
+					*xrpnt = 0.0;
+				xrpnt += step;
+				if (y == 15) {
+					max[lwin] = cb;
+					part2remain -= h->linbits + 1;
+					y += getbits(mp, h->linbits);
+					if (get1bit(mp))
+						*xrpnt = -ispow[y] * v;
+					else
+						*xrpnt = ispow[y] * v;
+				} else if (y) {
+					max[lwin] = cb;
+					if (get1bit(mp))
+						*xrpnt = -ispow[y] * v;
+					else
+						*xrpnt = ispow[y] * v;
+					part2remain--;
+				} else
+					*xrpnt = 0.0;
+				xrpnt += step;
+			}
+		}
+		for (; l3 && (part2remain > 0); l3--) {
+			struct newhuff *h = htc + gr_info->count1table_select;
+			register short *val = h->table, a;
 
-      for(i=0;i<4;i++) {
-        if(!(i & 1)) {
-          if(!mc) {
-            mc = *m++;
-            xrpnt = ((real *) xr) + (*m++);
-            lwin = *m++;
-            cb = *m++;
-            if(lwin == 3) {
-              v = gr_info->pow2gain[(*scf++) << shift];
-              step = 1;
-            }
-            else {
-              v = gr_info->full_gain[lwin][(*scf++) << shift];
-              step = 3;
-            }
-          }
-          mc--;
-        }
-        if( (a & (0x8>>i)) ) {
-          max[lwin] = cb;
-          part2remain--;
-          if(part2remain < 0) {
-            part2remain++;
-            break;
-          }
-          if(get1bit(mp)) 
-            *xrpnt = -v;
-          else
-            *xrpnt = v;
-        }
-        else
-          *xrpnt = 0.0;
-        xrpnt += step;
-      }
-    }
- 
-    while( m < me ) {
-      if(!mc) {
-        mc = *m++;
-        xrpnt = ((real *) xr) + *m++;
-        if( (*m++) == 3)
-          step = 1;
-        else
-          step = 3;
-        m++; /* cb */
-      }
-      mc--;
-      *xrpnt = 0.0;
-      xrpnt += step;
-      *xrpnt = 0.0;
-      xrpnt += step;
+			while ((a = *val++) < 0) {
+				part2remain--;
+				if (part2remain < 0) {
+					part2remain++;
+					a = 0;
+					break;
+				}
+				if (get1bit(mp))
+					val -= a;
+			}
+
+			for (i = 0; i < 4; i++) {
+				if (!(i & 1)) {
+					if (!mc) {
+						mc = *m++;
+						xrpnt = ((real *) xr) + (*m++);
+						lwin = *m++;
+						cb = *m++;
+						if (lwin == 3) {
+							v = gr_info->pow2gain[(*scf++) << shift];
+							step = 1;
+						} else {
+							v = gr_info->full_gain[lwin][(*scf++) << shift];
+							step = 3;
+						}
+					}
+					mc--;
+				}
+				if ((a & (0x8 >> i))) {
+					max[lwin] = cb;
+					part2remain--;
+					if (part2remain < 0) {
+						part2remain++;
+						break;
+					}
+					if (get1bit(mp))
+						*xrpnt = -v;
+					else
+						*xrpnt = v;
+				} else
+					*xrpnt = 0.0;
+				xrpnt += step;
+			}
+		}
+
+		while (m < me) {
+			if (!mc) {
+				mc = *m++;
+				xrpnt = ((real *) xr) + *m++;
+				if ((*m++) == 3)
+					step = 1;
+				else
+					step = 3;
+				m++;			/* cb */
+			}
+			mc--;
+			*xrpnt = 0.0;
+			xrpnt += step;
+			*xrpnt = 0.0;
+			xrpnt += step;
 /* we could add a little opt. here:
  * if we finished a band for window 3 or a long band
  * further bands could copied in a simple loop without a
  * special 'map' decoding
  */
-    }
+		}
 
-    gr_info->maxband[0] = max[0]+1;
-    gr_info->maxband[1] = max[1]+1;
-    gr_info->maxband[2] = max[2]+1;
-    gr_info->maxbandl = max[3]+1;
+		gr_info->maxband[0] = max[0] + 1;
+		gr_info->maxband[1] = max[1] + 1;
+		gr_info->maxband[2] = max[2] + 1;
+		gr_info->maxbandl = max[3] + 1;
 
-    {
-      int rmax = max[0] > max[1] ? max[0] : max[1];
-      rmax = (rmax > max[2] ? rmax : max[2]) + 1;
-      gr_info->maxb = rmax ? (mp->shortLimit)[sfreq][rmax] : (mp->longLimit)[sfreq][max[3]+1];
-    }
+		{
+			int rmax = max[0] > max[1] ? max[0] : max[1];
+			rmax = (rmax > max[2] ? rmax : max[2]) + 1;
+			gr_info->maxb = rmax ? (mp->shortLimit)[sfreq][rmax] : (mp->longLimit)[sfreq][max[3] + 1];
+		}
 
-  }
-  else {
-	/*
-     * decoding with 'long' BandIndex table (block_type != 2)
-     */
-    int *pretab = gr_info->preflag ? pretab1 : pretab2;
-    int i,max = -1;
-    int cb = 0;
-    register int *m = map[sfreq][2];
-    register real v = 0.0;
-    register int mc = 0;
+	} else {
+		/*
+		 * decoding with 'long' BandIndex table (block_type != 2)
+		 */
+		int *pretab = gr_info->preflag ? pretab1 : pretab2;
+		int i, max = -1;
+		int cb = 0;
+		register int *m = map[sfreq][2];
+		register real v = 0.0;
+		register int mc = 0;
 #if 0
-    me = mapend[sfreq][2];
+		me = mapend[sfreq][2];
 #endif
 
-	/*
-     * long hash table values
-     */
-    for(i=0;i<3;i++) {
-      int lp = l[i];
-      struct newhuff *h = ht+gr_info->table_select[i];
+		/*
+		 * long hash table values
+		 */
+		for (i = 0; i < 3; i++) {
+			int lp = l[i];
+			struct newhuff *h = ht + gr_info->table_select[i];
 
-      for(;lp;lp--,mc--) {
-        int x,y;
+			for (; lp; lp--, mc--) {
+				int x, y;
 
-        if(!mc) {
-          mc = *m++;
-          v = gr_info->pow2gain[((*scf++) + (*pretab++)) << shift];
-          cb = *m++;
-        }
-        {
-          register short *val = h->table;
-          while((y=*val++)<0) {
-            if (get1bit(mp))
-              val -= y;
-            part2remain--;
-          }
-          x = y >> 4;
-          y &= 0xf;
-        }
-        if (x == 15) {
-          max = cb;
-          part2remain -= h->linbits+1;
-          x += getbits(mp, h->linbits);
-          if(get1bit(mp))
-            *xrpnt++ = -ispow[x] * v;
-          else
-            *xrpnt++ =  ispow[x] * v;
-        }
-        else if(x) {
-          max = cb;
-          if(get1bit(mp))
-            *xrpnt++ = -ispow[x] * v;
-          else
-            *xrpnt++ =  ispow[x] * v;
-          part2remain--;
-        }
-        else
-          *xrpnt++ = 0.0;
+				if (!mc) {
+					mc = *m++;
+					v = gr_info->pow2gain[((*scf++) + (*pretab++)) << shift];
+					cb = *m++;
+				}
+				{
+					register short *val = h->table;
+					while ((y = *val++) < 0) {
+						if (get1bit(mp))
+							val -= y;
+						part2remain--;
+					}
+					x = y >> 4;
+					y &= 0xf;
+				}
+				if (x == 15) {
+					max = cb;
+					part2remain -= h->linbits + 1;
+					x += getbits(mp, h->linbits);
+					if (get1bit(mp))
+						*xrpnt++ = -ispow[x] * v;
+					else
+						*xrpnt++ = ispow[x] * v;
+				} else if (x) {
+					max = cb;
+					if (get1bit(mp))
+						*xrpnt++ = -ispow[x] * v;
+					else
+						*xrpnt++ = ispow[x] * v;
+					part2remain--;
+				} else
+					*xrpnt++ = 0.0;
 
-        if (y == 15) {
-          max = cb;
-          part2remain -= h->linbits+1;
-          y += getbits(mp, h->linbits);
-          if(get1bit(mp))
-            *xrpnt++ = -ispow[y] * v;
-          else
-            *xrpnt++ =  ispow[y] * v;
-        }
-        else if(y) {
-          max = cb;
-          if(get1bit(mp))
-            *xrpnt++ = -ispow[y] * v;
-          else
-            *xrpnt++ =  ispow[y] * v;
-          part2remain--;
-        }
-        else
-          *xrpnt++ = 0.0;
-      }
-    }
+				if (y == 15) {
+					max = cb;
+					part2remain -= h->linbits + 1;
+					y += getbits(mp, h->linbits);
+					if (get1bit(mp))
+						*xrpnt++ = -ispow[y] * v;
+					else
+						*xrpnt++ = ispow[y] * v;
+				} else if (y) {
+					max = cb;
+					if (get1bit(mp))
+						*xrpnt++ = -ispow[y] * v;
+					else
+						*xrpnt++ = ispow[y] * v;
+					part2remain--;
+				} else
+					*xrpnt++ = 0.0;
+			}
+		}
 
-	/*
-     * short (count1table) values
-     */
-    for(;l3 && (part2remain > 0);l3--) {
-      struct newhuff *h = htc+gr_info->count1table_select;
-      register short *val = h->table,a;
+		/*
+		 * short (count1table) values
+		 */
+		for (; l3 && (part2remain > 0); l3--) {
+			struct newhuff *h = htc + gr_info->count1table_select;
+			register short *val = h->table, a;
 
-      while((a=*val++)<0) {
-        part2remain--;
-        if(part2remain < 0) {
-          part2remain++;
-          a = 0;
-          break;
-        }
-        if (get1bit(mp))
-          val -= a;
-      }
+			while ((a = *val++) < 0) {
+				part2remain--;
+				if (part2remain < 0) {
+					part2remain++;
+					a = 0;
+					break;
+				}
+				if (get1bit(mp))
+					val -= a;
+			}
 
-      for(i=0;i<4;i++) {
-        if(!(i & 1)) {
-          if(!mc) {
-            mc = *m++;
-            cb = *m++;
-            v = gr_info->pow2gain[((*scf++) + (*pretab++)) << shift];
-          }
-          mc--;
-        }
-        if ( (a & (0x8>>i)) ) {
-          max = cb;
-          part2remain--;
-          if(part2remain < 0) {
-            part2remain++;
-            break;
-          }
-          if(get1bit(mp))
-            *xrpnt++ = -v;
-          else
-            *xrpnt++ = v;
-        }
-        else
-          *xrpnt++ = 0.0;
-      }
-    }
+			for (i = 0; i < 4; i++) {
+				if (!(i & 1)) {
+					if (!mc) {
+						mc = *m++;
+						cb = *m++;
+						v = gr_info->pow2gain[((*scf++) + (*pretab++)) << shift];
+					}
+					mc--;
+				}
+				if ((a & (0x8 >> i))) {
+					max = cb;
+					part2remain--;
+					if (part2remain < 0) {
+						part2remain++;
+						break;
+					}
+					if (get1bit(mp))
+						*xrpnt++ = -v;
+					else
+						*xrpnt++ = v;
+				} else
+					*xrpnt++ = 0.0;
+			}
+		}
 
-	/* 
-     * zero part
-     */
-    for(i=(&xr[SBLIMIT][0]-xrpnt)>>1;i;i--) {
-      *xrpnt++ = 0.0;
-      *xrpnt++ = 0.0;
-    }
+		/* 
+		 * zero part
+		 */
+		for (i = (&xr[SBLIMIT][0] - xrpnt) >> 1; i; i--) {
+			*xrpnt++ = 0.0;
+			*xrpnt++ = 0.0;
+		}
 
-    gr_info->maxbandl = max+1;
-    gr_info->maxb = (mp->longLimit)[sfreq][gr_info->maxbandl];
-  }
+		gr_info->maxbandl = max + 1;
+		gr_info->maxb = (mp->longLimit)[sfreq][gr_info->maxbandl];
+	}
 
-  while( part2remain > 16 ) {
-    getbits(mp, 16); /* Dismiss stuffing Bits */
-    part2remain -= 16;
-  }
-  if(part2remain > 0)
-    getbits(mp, part2remain);
-  else if(part2remain < 0) {
-	  debug_printf("mpg123: %d Can't rewind stream by %d bits!\n",-part2remain,  __LINE__);
-    return 1; /* -> error */
-  }
-  return 0;
+	while (part2remain > 16) {
+		getbits(mp, 16);		/* Dismiss stuffing Bits */
+		part2remain -= 16;
+	}
+	if (part2remain > 0)
+		getbits(mp, part2remain);
+	else if (part2remain < 0) {
+		debug_printf("mpg123: %d Can't rewind stream by %d bits!\n", -part2remain, __LINE__);
+		return 1;				/* -> error */
+	}
+	return 0;
 }
 
 #if 0
-static int III_dequantize_sample_ms(real xr[2][SBLIMIT][SSLIMIT],int *scf,
-   struct gr_info_s *gr_info,int sfreq,int part2bits)
+static int III_dequantize_sample_ms(real xr[2][SBLIMIT][SSLIMIT], int *scf,
+									struct gr_info_s *gr_info, int sfreq, int part2bits)
 {
-  int shift = 1 + gr_info->scalefac_scale;
-  real *xrpnt = (real *) xr[1];
-  real *xr0pnt = (real *) xr[0];
-  int l[3],l3;
-  int part2remain = gr_info->part2_3_length - part2bits;
-  int *me;
+	int shift = 1 + gr_info->scalefac_scale;
+	real *xrpnt = (real *) xr[1];
+	real *xr0pnt = (real *) xr[0];
+	int l[3], l3;
+	int part2remain = gr_info->part2_3_length - part2bits;
+	int *me;
 
-  {
-    int bv       = gr_info->big_values;
-    int region1  = gr_info->region1start;
-    int region2  = gr_info->region2start;
+	{
+		int bv = gr_info->big_values;
+		int region1 = gr_info->region1start;
+		int region2 = gr_info->region2start;
 
-    l3 = ((576>>1)-bv)>>1;   
+		l3 = ((576 >> 1) - bv) >> 1;
 /*
  * we may lose the 'odd' bit here !! 
  * check this later gain 
  */
-    if(bv <= region1) {
-      l[0] = bv; l[1] = 0; l[2] = 0;
-    }
-    else {
-      l[0] = region1;
-      if(bv <= region2) {
-        l[1] = bv - l[0];  l[2] = 0;
-      }
-      else {
-        l[1] = region2 - l[0]; l[2] = bv - region2;
-      }
-    }
-  }
- 
-  if(gr_info->block_type == 2) {
-    int i,max[4];
-    int step=0,lwin=0,cb=0;
-    register real v = 0.0;
-    register int *m,mc = 0;
+		if (bv <= region1) {
+			l[0] = bv;
+			l[1] = 0;
+			l[2] = 0;
+		} else {
+			l[0] = region1;
+			if (bv <= region2) {
+				l[1] = bv - l[0];
+				l[2] = 0;
+			} else {
+				l[1] = region2 - l[0];
+				l[2] = bv - region2;
+			}
+		}
+	}
 
-    if(gr_info->mixed_block_flag) {
-      max[3] = -1;
-      max[0] = max[1] = max[2] = 2;
-      m = map[sfreq][0];
-      me = mapend[sfreq][0];
-    }
-    else {
-      max[0] = max[1] = max[2] = max[3] = -1;
-      /* max[3] not really needed in this case */
-      m = map[sfreq][1];
-      me = mapend[sfreq][1];
-    }
+	if (gr_info->block_type == 2) {
+		int i, max[4];
+		int step = 0, lwin = 0, cb = 0;
+		register real v = 0.0;
+		register int *m, mc = 0;
 
-    for(i=0;i<2;i++) {
-      int lp = l[i];
-      struct newhuff *h = ht+gr_info->table_select[i];
-      for(;lp;lp--,mc--) {
-        int x,y;
+		if (gr_info->mixed_block_flag) {
+			max[3] = -1;
+			max[0] = max[1] = max[2] = 2;
+			m = map[sfreq][0];
+			me = mapend[sfreq][0];
+		} else {
+			max[0] = max[1] = max[2] = max[3] = -1;
+			/* max[3] not really needed in this case */
+			m = map[sfreq][1];
+			me = mapend[sfreq][1];
+		}
 
-        if(!mc) {
-          mc = *m++;
-          xrpnt = ((real *) xr[1]) + *m;
-          xr0pnt = ((real *) xr[0]) + *m++;
-          lwin = *m++;
-          cb = *m++;
-          if(lwin == 3) {
-            v = gr_info->pow2gain[(*scf++) << shift];
-            step = 1;
-          }
-          else {
-            v = gr_info->full_gain[lwin][(*scf++) << shift];
-            step = 3;
-          }
-        }
-        {
-          register short *val = h->table;
-          while((y=*val++)<0) {
-            if (get1bit(mp))
-              val -= y;
-            part2remain--;
-          }
-          x = y >> 4;
-          y &= 0xf;
-        }
-        if(x == 15) {
-          max[lwin] = cb;
-          part2remain -= h->linbits+1;
-          x += getbits(mp, h->linbits);
-          if(get1bit(mp)) {
-            real a = ispow[x] * v;
-            *xrpnt = *xr0pnt + a;
-            *xr0pnt -= a;
-          }
-          else {
-            real a = ispow[x] * v;
-            *xrpnt = *xr0pnt - a;
-            *xr0pnt += a;
-          }
-        }
-        else if(x) {
-          max[lwin] = cb;
-          if(get1bit(mp)) {
-            real a = ispow[x] * v;
-            *xrpnt = *xr0pnt + a;
-            *xr0pnt -= a;
-          }
-          else {
-            real a = ispow[x] * v;
-            *xrpnt = *xr0pnt - a;
-            *xr0pnt += a;
-          }
-          part2remain--;
-        }
-        else
-          *xrpnt = *xr0pnt;
-        xrpnt += step;
-        xr0pnt += step;
+		for (i = 0; i < 2; i++) {
+			int lp = l[i];
+			struct newhuff *h = ht + gr_info->table_select[i];
+			for (; lp; lp--, mc--) {
+				int x, y;
 
-        if(y == 15) {
-          max[lwin] = cb;
-          part2remain -= h->linbits+1;
-          y += getbits(mp, h->linbits);
-          if(get1bit(mp)) {
-            real a = ispow[y] * v;
-            *xrpnt = *xr0pnt + a;
-            *xr0pnt -= a;
-          }
-          else {
-            real a = ispow[y] * v;
-            *xrpnt = *xr0pnt - a;
-            *xr0pnt += a;
-          }
-        }
-        else if(y) {
-          max[lwin] = cb;
-          if(get1bit(mp)) {
-            real a = ispow[y] * v;
-            *xrpnt = *xr0pnt + a;
-            *xr0pnt -= a;
-          }
-          else {
-            real a = ispow[y] * v;
-            *xrpnt = *xr0pnt - a;
-            *xr0pnt += a;
-          }
-          part2remain--;
-        }
-        else
-          *xrpnt = *xr0pnt;
-        xrpnt += step;
-        xr0pnt += step;
-      }
-    }
+				if (!mc) {
+					mc = *m++;
+					xrpnt = ((real *) xr[1]) + *m;
+					xr0pnt = ((real *) xr[0]) + *m++;
+					lwin = *m++;
+					cb = *m++;
+					if (lwin == 3) {
+						v = gr_info->pow2gain[(*scf++) << shift];
+						step = 1;
+					} else {
+						v = gr_info->full_gain[lwin][(*scf++) << shift];
+						step = 3;
+					}
+				}
+				{
+					register short *val = h->table;
+					while ((y = *val++) < 0) {
+						if (get1bit(mp))
+							val -= y;
+						part2remain--;
+					}
+					x = y >> 4;
+					y &= 0xf;
+				}
+				if (x == 15) {
+					max[lwin] = cb;
+					part2remain -= h->linbits + 1;
+					x += getbits(mp, h->linbits);
+					if (get1bit(mp)) {
+						real a = ispow[x] * v;
+						*xrpnt = *xr0pnt + a;
+						*xr0pnt -= a;
+					} else {
+						real a = ispow[x] * v;
+						*xrpnt = *xr0pnt - a;
+						*xr0pnt += a;
+					}
+				} else if (x) {
+					max[lwin] = cb;
+					if (get1bit(mp)) {
+						real a = ispow[x] * v;
+						*xrpnt = *xr0pnt + a;
+						*xr0pnt -= a;
+					} else {
+						real a = ispow[x] * v;
+						*xrpnt = *xr0pnt - a;
+						*xr0pnt += a;
+					}
+					part2remain--;
+				} else
+					*xrpnt = *xr0pnt;
+				xrpnt += step;
+				xr0pnt += step;
 
-    for(;l3 && (part2remain > 0);l3--) {
-      struct newhuff *h = htc+gr_info->count1table_select;
-      register short *val = h->table,a;
+				if (y == 15) {
+					max[lwin] = cb;
+					part2remain -= h->linbits + 1;
+					y += getbits(mp, h->linbits);
+					if (get1bit(mp)) {
+						real a = ispow[y] * v;
+						*xrpnt = *xr0pnt + a;
+						*xr0pnt -= a;
+					} else {
+						real a = ispow[y] * v;
+						*xrpnt = *xr0pnt - a;
+						*xr0pnt += a;
+					}
+				} else if (y) {
+					max[lwin] = cb;
+					if (get1bit(mp)) {
+						real a = ispow[y] * v;
+						*xrpnt = *xr0pnt + a;
+						*xr0pnt -= a;
+					} else {
+						real a = ispow[y] * v;
+						*xrpnt = *xr0pnt - a;
+						*xr0pnt += a;
+					}
+					part2remain--;
+				} else
+					*xrpnt = *xr0pnt;
+				xrpnt += step;
+				xr0pnt += step;
+			}
+		}
 
-      while((a=*val++)<0) {
-        part2remain--;
-        if(part2remain < 0) {
-          part2remain++;
-          a = 0;
-          break;
-        }
-        if (get1bit(mp))
-          val -= a;
-      }
+		for (; l3 && (part2remain > 0); l3--) {
+			struct newhuff *h = htc + gr_info->count1table_select;
+			register short *val = h->table, a;
 
-      for(i=0;i<4;i++) {
-        if(!(i & 1)) {
-          if(!mc) {
-            mc = *m++;
-            xrpnt = ((real *) xr[1]) + *m;
-            xr0pnt = ((real *) xr[0]) + *m++;
-            lwin = *m++;
-            cb = *m++;
-            if(lwin == 3) {
-              v = gr_info->pow2gain[(*scf++) << shift];
-              step = 1;
-            }
-            else {
-              v = gr_info->full_gain[lwin][(*scf++) << shift];
-              step = 3;
-            }
-          }
-          mc--;
-        }
-        if( (a & (0x8>>i)) ) {
-          max[lwin] = cb;
-          part2remain--;
-          if(part2remain < 0) {
-            part2remain++;
-            break;
-          }
-          if(get1bit(mp)) {
-            *xrpnt = *xr0pnt + v;
-            *xr0pnt -= v;
-          }
-          else {
-            *xrpnt = *xr0pnt - v;
-            *xr0pnt += v;
-          }
-        }
-        else
-          *xrpnt = *xr0pnt;
-        xrpnt += step;
-        xr0pnt += step;
-      }
-    }
- 
-    while( m < me ) {
-      if(!mc) {
-        mc = *m++;
-        xrpnt = ((real *) xr[1]) + *m;
-        xr0pnt = ((real *) xr[0]) + *m++;
-        if(*m++ == 3)
-          step = 1;
-        else
-          step = 3;
-        m++; /* cb */
-      }
-      mc--;
-      *xrpnt = *xr0pnt;
-      xrpnt += step;
-      xr0pnt += step;
-      *xrpnt = *xr0pnt;
-      xrpnt += step;
-      xr0pnt += step;
+			while ((a = *val++) < 0) {
+				part2remain--;
+				if (part2remain < 0) {
+					part2remain++;
+					a = 0;
+					break;
+				}
+				if (get1bit(mp))
+					val -= a;
+			}
+
+			for (i = 0; i < 4; i++) {
+				if (!(i & 1)) {
+					if (!mc) {
+						mc = *m++;
+						xrpnt = ((real *) xr[1]) + *m;
+						xr0pnt = ((real *) xr[0]) + *m++;
+						lwin = *m++;
+						cb = *m++;
+						if (lwin == 3) {
+							v = gr_info->pow2gain[(*scf++) << shift];
+							step = 1;
+						} else {
+							v = gr_info->full_gain[lwin][(*scf++) << shift];
+							step = 3;
+						}
+					}
+					mc--;
+				}
+				if ((a & (0x8 >> i))) {
+					max[lwin] = cb;
+					part2remain--;
+					if (part2remain < 0) {
+						part2remain++;
+						break;
+					}
+					if (get1bit(mp)) {
+						*xrpnt = *xr0pnt + v;
+						*xr0pnt -= v;
+					} else {
+						*xrpnt = *xr0pnt - v;
+						*xr0pnt += v;
+					}
+				} else
+					*xrpnt = *xr0pnt;
+				xrpnt += step;
+				xr0pnt += step;
+			}
+		}
+
+		while (m < me) {
+			if (!mc) {
+				mc = *m++;
+				xrpnt = ((real *) xr[1]) + *m;
+				xr0pnt = ((real *) xr[0]) + *m++;
+				if (*m++ == 3)
+					step = 1;
+				else
+					step = 3;
+				m++;			/* cb */
+			}
+			mc--;
+			*xrpnt = *xr0pnt;
+			xrpnt += step;
+			xr0pnt += step;
+			*xrpnt = *xr0pnt;
+			xrpnt += step;
+			xr0pnt += step;
 /* we could add a little opt. here:
  * if we finished a band for window 3 or a long band
  * further bands could copied in a simple loop without a
  * special 'map' decoding
  */
-    }
+		}
 
-    gr_info->maxband[0] = max[0]+1;
-    gr_info->maxband[1] = max[1]+1;
-    gr_info->maxband[2] = max[2]+1;
-    gr_info->maxbandl = max[3]+1;
+		gr_info->maxband[0] = max[0] + 1;
+		gr_info->maxband[1] = max[1] + 1;
+		gr_info->maxband[2] = max[2] + 1;
+		gr_info->maxbandl = max[3] + 1;
 
-    {
-      int rmax = max[0] > max[1] ? max[0] : max[1];
-      rmax = (rmax > max[2] ? rmax : max[2]) + 1;
-      gr_info->maxb = rmax ? (mp->shortLimit)[sfreq][rmax] : (mp->longLimit)[sfreq][max[3]+1];
-    }
-  }
-  else {
-    int *pretab = gr_info->preflag ? pretab1 : pretab2;
-    int i,max = -1;
-    int cb = 0;
-    register int mc=0,*m = map[sfreq][2];
-    register real v = 0.0;
+		{
+			int rmax = max[0] > max[1] ? max[0] : max[1];
+			rmax = (rmax > max[2] ? rmax : max[2]) + 1;
+			gr_info->maxb = rmax ? (mp->shortLimit)[sfreq][rmax] : (mp->longLimit)[sfreq][max[3] + 1];
+		}
+	} else {
+		int *pretab = gr_info->preflag ? pretab1 : pretab2;
+		int i, max = -1;
+		int cb = 0;
+		register int mc = 0, *m = map[sfreq][2];
+		register real v = 0.0;
 #if 0
-    me = mapend[sfreq][2];
+		me = mapend[sfreq][2];
 #endif
 
-    for(i=0;i<3;i++) {
-      int lp = l[i];
-      struct newhuff *h = ht+gr_info->table_select[i];
+		for (i = 0; i < 3; i++) {
+			int lp = l[i];
+			struct newhuff *h = ht + gr_info->table_select[i];
 
-      for(;lp;lp--,mc--) {
-        int x,y;
-        if(!mc) {
-          mc = *m++;
-          cb = *m++;
-          v = gr_info->pow2gain[((*scf++) + (*pretab++)) << shift];
-        }
-        {
-          register short *val = h->table;
-          while((y=*val++)<0) {
-            if (get1bit(mp))
-              val -= y;
-            part2remain--;
-          }
-          x = y >> 4;
-          y &= 0xf;
-        }
-        if (x == 15) {
-          max = cb;
-          part2remain -= h->linbits+1;
-          x += getbits(mp, h->linbits);
-          if(get1bit(mp)) {
-            real a = ispow[x] * v;
-            *xrpnt++ = *xr0pnt + a;
-            *xr0pnt++ -= a;
-          }
-          else {
-            real a = ispow[x] * v;
-            *xrpnt++ = *xr0pnt - a;
-            *xr0pnt++ += a;
-          }
-        }
-        else if(x) {
-          max = cb;
-          if(get1bit(mp)) {
-            real a = ispow[x] * v;
-            *xrpnt++ = *xr0pnt + a;
-            *xr0pnt++ -= a;
-          }
-          else {
-            real a = ispow[x] * v;
-            *xrpnt++ = *xr0pnt - a;
-            *xr0pnt++ += a;
-          }
-          part2remain--;
-        }
-        else
-          *xrpnt++ = *xr0pnt++;
+			for (; lp; lp--, mc--) {
+				int x, y;
+				if (!mc) {
+					mc = *m++;
+					cb = *m++;
+					v = gr_info->pow2gain[((*scf++) + (*pretab++)) << shift];
+				}
+				{
+					register short *val = h->table;
+					while ((y = *val++) < 0) {
+						if (get1bit(mp))
+							val -= y;
+						part2remain--;
+					}
+					x = y >> 4;
+					y &= 0xf;
+				}
+				if (x == 15) {
+					max = cb;
+					part2remain -= h->linbits + 1;
+					x += getbits(mp, h->linbits);
+					if (get1bit(mp)) {
+						real a = ispow[x] * v;
+						*xrpnt++ = *xr0pnt + a;
+						*xr0pnt++ -= a;
+					} else {
+						real a = ispow[x] * v;
+						*xrpnt++ = *xr0pnt - a;
+						*xr0pnt++ += a;
+					}
+				} else if (x) {
+					max = cb;
+					if (get1bit(mp)) {
+						real a = ispow[x] * v;
+						*xrpnt++ = *xr0pnt + a;
+						*xr0pnt++ -= a;
+					} else {
+						real a = ispow[x] * v;
+						*xrpnt++ = *xr0pnt - a;
+						*xr0pnt++ += a;
+					}
+					part2remain--;
+				} else
+					*xrpnt++ = *xr0pnt++;
 
-        if (y == 15) {
-          max = cb;
-          part2remain -= h->linbits+1;
-          y += getbits(mp, h->linbits);
-          if(get1bit(mp)) {
-            real a = ispow[y] * v;
-            *xrpnt++ = *xr0pnt + a;
-            *xr0pnt++ -= a;
-          }
-          else {
-            real a = ispow[y] * v;
-            *xrpnt++ = *xr0pnt - a;
-            *xr0pnt++ += a;
-          }
-        }
-        else if(y) {
-          max = cb;
-          if(get1bit(mp)) {
-            real a = ispow[y] * v;
-            *xrpnt++ = *xr0pnt + a;
-            *xr0pnt++ -= a;
-          }
-          else {
-            real a = ispow[y] * v;
-            *xrpnt++ = *xr0pnt - a;
-            *xr0pnt++ += a;
-          }
-          part2remain--;
-        }
-        else
-          *xrpnt++ = *xr0pnt++;
-      }
-    }
+				if (y == 15) {
+					max = cb;
+					part2remain -= h->linbits + 1;
+					y += getbits(mp, h->linbits);
+					if (get1bit(mp)) {
+						real a = ispow[y] * v;
+						*xrpnt++ = *xr0pnt + a;
+						*xr0pnt++ -= a;
+					} else {
+						real a = ispow[y] * v;
+						*xrpnt++ = *xr0pnt - a;
+						*xr0pnt++ += a;
+					}
+				} else if (y) {
+					max = cb;
+					if (get1bit(mp)) {
+						real a = ispow[y] * v;
+						*xrpnt++ = *xr0pnt + a;
+						*xr0pnt++ -= a;
+					} else {
+						real a = ispow[y] * v;
+						*xrpnt++ = *xr0pnt - a;
+						*xr0pnt++ += a;
+					}
+					part2remain--;
+				} else
+					*xrpnt++ = *xr0pnt++;
+			}
+		}
 
-    for(;l3 && (part2remain > 0);l3--) {
-      struct newhuff *h = htc+gr_info->count1table_select;
-      register short *val = h->table,a;
+		for (; l3 && (part2remain > 0); l3--) {
+			struct newhuff *h = htc + gr_info->count1table_select;
+			register short *val = h->table, a;
 
-      while((a=*val++)<0) {
-        part2remain--;
-        if(part2remain < 0) {
-          part2remain++;
-          a = 0;
-          break;
-        }
-        if (get1bit(mp))
-          val -= a;
-      }
+			while ((a = *val++) < 0) {
+				part2remain--;
+				if (part2remain < 0) {
+					part2remain++;
+					a = 0;
+					break;
+				}
+				if (get1bit(mp))
+					val -= a;
+			}
 
-      for(i=0;i<4;i++) {
-        if(!(i & 1)) {
-          if(!mc) {
-            mc = *m++;
-            cb = *m++;
-            v = gr_info->pow2gain[((*scf++) + (*pretab++)) << shift];
-          }
-          mc--;
-        }
-        if ( (a & (0x8>>i)) ) {
-          max = cb;
-          part2remain--;
-          if(part2remain <= 0) {
-            part2remain++;
-            break;
-          }
-          if(get1bit(mp)) {
-            *xrpnt++ = *xr0pnt + v;
-            *xr0pnt++ -= v;
-          }
-          else {
-            *xrpnt++ = *xr0pnt - v;
-            *xr0pnt++ += v;
-          }
-        }
-        else
-          *xrpnt++ = *xr0pnt++;
-      }
-    }
-    for(i=(&xr[1][SBLIMIT][0]-xrpnt)>>1;i;i--) {
-      *xrpnt++ = *xr0pnt++;
-      *xrpnt++ = *xr0pnt++;
-    }
+			for (i = 0; i < 4; i++) {
+				if (!(i & 1)) {
+					if (!mc) {
+						mc = *m++;
+						cb = *m++;
+						v = gr_info->pow2gain[((*scf++) + (*pretab++)) << shift];
+					}
+					mc--;
+				}
+				if ((a & (0x8 >> i))) {
+					max = cb;
+					part2remain--;
+					if (part2remain <= 0) {
+						part2remain++;
+						break;
+					}
+					if (get1bit(mp)) {
+						*xrpnt++ = *xr0pnt + v;
+						*xr0pnt++ -= v;
+					} else {
+						*xrpnt++ = *xr0pnt - v;
+						*xr0pnt++ += v;
+					}
+				} else
+					*xrpnt++ = *xr0pnt++;
+			}
+		}
+		for (i = (&xr[1][SBLIMIT][0] - xrpnt) >> 1; i; i--) {
+			*xrpnt++ = *xr0pnt++;
+			*xrpnt++ = *xr0pnt++;
+		}
 
-    gr_info->maxbandl = max+1;
-    gr_info->maxb = longLimit[sfreq][gr_info->maxbandl];
-  }
+		gr_info->maxbandl = max + 1;
+		gr_info->maxb = longLimit[sfreq][gr_info->maxbandl];
+	}
 
-  while ( part2remain > 16 ) {
-    getbits(mp, 16); /* Dismiss stuffing Bits */
-    part2remain -= 16;
-  }
-  if(part2remain > 0 )
-    getbits(mp, part2remain);
-  else if(part2remain < 0) {
-	  debug_printf("mpg123_ms: %d: Can't rewind stream by %d bits!\n",-part2remain,  __LINE__);
-    return 1; /* -> error */
-  }
-  return 0;
+	while (part2remain > 16) {
+		getbits(mp, 16);		/* Dismiss stuffing Bits */
+		part2remain -= 16;
+	}
+	if (part2remain > 0)
+		getbits(mp, part2remain);
+	else if (part2remain < 0) {
+		debug_printf("mpg123_ms: %d: Can't rewind stream by %d bits!\n", -part2remain, __LINE__);
+		return 1;				/* -> error */
+	}
+	return 0;
 }
 #endif
 
 /* 
  * III_stereo: calculate real channel values for Joint-I-Stereo-mode
  */
-static void III_i_stereo(real xr_buf[2][SBLIMIT][SSLIMIT],int *scalefac,
-   struct gr_info_s *gr_info,int sfreq,int ms_stereo,int lsf)
+static void III_i_stereo(real xr_buf[2][SBLIMIT][SSLIMIT], int *scalefac,
+						 struct gr_info_s *gr_info, int sfreq, int ms_stereo, int lsf)
 {
-      real (*xr)[SBLIMIT*SSLIMIT] = (real (*)[SBLIMIT*SSLIMIT] ) xr_buf;
-      struct bandInfoStruct *bi = &bandInfo[sfreq];
-      real *tab1,*tab2;
+	real(*xr)[SBLIMIT * SSLIMIT] = (real(*)[SBLIMIT * SSLIMIT]) xr_buf;
+	struct bandInfoStruct *bi = &bandInfo[sfreq];
+	real *tab1, *tab2;
 
-      if(lsf) {
-        int p = gr_info->scalefac_compress & 0x1;
-	    if(ms_stereo) {
-          tab1 = pow1_2[p]; tab2 = pow2_2[p];
-        }
-        else {
-          tab1 = pow1_1[p]; tab2 = pow2_1[p];
-        }
-      }
-      else {
-        if(ms_stereo) {
-          tab1 = tan1_2; tab2 = tan2_2;
-        }
-        else {
-          tab1 = tan1_1; tab2 = tan2_1;
-        }
-      }
+	if (lsf) {
+		int p = gr_info->scalefac_compress & 0x1;
+		if (ms_stereo) {
+			tab1 = pow1_2[p];
+			tab2 = pow2_2[p];
+		} else {
+			tab1 = pow1_1[p];
+			tab2 = pow2_1[p];
+		}
+	} else {
+		if (ms_stereo) {
+			tab1 = tan1_2;
+			tab2 = tan2_2;
+		} else {
+			tab1 = tan1_1;
+			tab2 = tan2_1;
+		}
+	}
 
-      if (gr_info->block_type == 2)
-      {
-         int lwin,do_l = 0;
-         if( gr_info->mixed_block_flag )
-           do_l = 1;
+	if (gr_info->block_type == 2) {
+		int lwin, do_l = 0;
+		if (gr_info->mixed_block_flag)
+			do_l = 1;
 
-         for (lwin=0;lwin<3;lwin++) /* process each window */
-         {
-             /* get first band with zero values */
-           int is_p,sb,idx,sfb = gr_info->maxband[lwin];  /* sfb is minimal 3 for mixed mode */
-           if(sfb > 3)
-             do_l = 0;
+		for (lwin = 0; lwin < 3; lwin++) {	/* process each window */
+			/* get first band with zero values */
+			int is_p, sb, idx, sfb = gr_info->maxband[lwin];	/* sfb is minimal 3 for mixed mode */
+			if (sfb > 3)
+				do_l = 0;
 
-           for(;sfb<12;sfb++)
-           {
-             is_p = scalefac[sfb*3+lwin-gr_info->mixed_block_flag]; /* scale: 0-15 */ 
-             if(is_p != 7) {
-               real t1,t2;
-               sb = bi->shortDiff[sfb];
-               idx = bi->shortIdx[sfb] + lwin;
-               t1 = tab1[is_p]; t2 = tab2[is_p];
-               for (; sb > 0; sb--,idx+=3)
-               {
-                 real v = xr[0][idx];
-                 xr[0][idx] = v * t1;
-                 xr[1][idx] = v * t2;
-               }
-             }
-           }
+			for (; sfb < 12; sfb++) {
+				is_p = scalefac[sfb * 3 + lwin - gr_info->mixed_block_flag];	/* scale: 0-15 */
+				if (is_p != 7) {
+					real t1, t2;
+					sb = bi->shortDiff[sfb];
+					idx = bi->shortIdx[sfb] + lwin;
+					t1 = tab1[is_p];
+					t2 = tab2[is_p];
+					for (; sb > 0; sb--, idx += 3) {
+						real v = xr[0][idx];
+						xr[0][idx] = v * t1;
+						xr[1][idx] = v * t2;
+					}
+				}
+			}
 
 #if 1
 /* in the original: copy 10 to 11 , here: copy 11 to 12 
 maybe still wrong??? (copy 12 to 13?) */
-           is_p = scalefac[11*3+lwin-gr_info->mixed_block_flag]; /* scale: 0-15 */
-           sb = bi->shortDiff[12];
-           idx = bi->shortIdx[12] + lwin;
+			is_p = scalefac[11 * 3 + lwin - gr_info->mixed_block_flag];	/* scale: 0-15 */
+			sb = bi->shortDiff[12];
+			idx = bi->shortIdx[12] + lwin;
 #else
-           is_p = scalefac[10*3+lwin-gr_info->mixed_block_flag]; /* scale: 0-15 */
-           sb = bi->shortDiff[11];
-           idx = bi->shortIdx[11] + lwin;
+			is_p = scalefac[10 * 3 + lwin - gr_info->mixed_block_flag];	/* scale: 0-15 */
+			sb = bi->shortDiff[11];
+			idx = bi->shortIdx[11] + lwin;
 #endif
-           if(is_p != 7)
-           {
-             real t1,t2;
-             t1 = tab1[is_p]; t2 = tab2[is_p];
-             for ( ; sb > 0; sb--,idx+=3 )
-             {  
-               real v = xr[0][idx];
-               xr[0][idx] = v * t1;
-               xr[1][idx] = v * t2;
-             }
-           }
-         } /* end for(lwin; .. ; . ) */
+			if (is_p != 7) {
+				real t1, t2;
+				t1 = tab1[is_p];
+				t2 = tab2[is_p];
+				for (; sb > 0; sb--, idx += 3) {
+					real v = xr[0][idx];
+					xr[0][idx] = v * t1;
+					xr[1][idx] = v * t2;
+				}
+			}
+		}						/* end for(lwin; .. ; . ) */
 
-         if (do_l)
-         {
+		if (do_l) {
 /* also check l-part, if ALL bands in the three windows are 'empty'
  * and mode = mixed_mode 
  */
-           int sfb = gr_info->maxbandl;
-           int idx = bi->longIdx[sfb];
+			int sfb = gr_info->maxbandl;
+			int idx = bi->longIdx[sfb];
 
-           for ( ; sfb<8; sfb++ )
-           {
-             int sb = bi->longDiff[sfb];
-             int is_p = scalefac[sfb]; /* scale: 0-15 */
-             if(is_p != 7) {
-               real t1,t2;
-               t1 = tab1[is_p]; t2 = tab2[is_p];
-               for ( ; sb > 0; sb--,idx++)
-               {
-                 real v = xr[0][idx];
-                 xr[0][idx] = v * t1;
-                 xr[1][idx] = v * t2;
-               }
-             }
-             else 
-               idx += sb;
-           }
-         }     
-      } 
-      else /* ((gr_info->block_type != 2)) */
-      {
-        int sfb = gr_info->maxbandl;
-        int is_p,idx = bi->longIdx[sfb];
-        for ( ; sfb<21; sfb++)
-        {
-          int sb = bi->longDiff[sfb];
-          is_p = scalefac[sfb]; /* scale: 0-15 */
-          if(is_p != 7) {
-            real t1,t2;
-            t1 = tab1[is_p]; t2 = tab2[is_p];
-            for ( ; sb > 0; sb--,idx++)
-            {
-               real v = xr[0][idx];
-               xr[0][idx] = v * t1;
-               xr[1][idx] = v * t2;
-            }
-          }
-          else
-            idx += sb;
-        }
+			for (; sfb < 8; sfb++) {
+				int sb = bi->longDiff[sfb];
+				int is_p = scalefac[sfb];	/* scale: 0-15 */
+				if (is_p != 7) {
+					real t1, t2;
+					t1 = tab1[is_p];
+					t2 = tab2[is_p];
+					for (; sb > 0; sb--, idx++) {
+						real v = xr[0][idx];
+						xr[0][idx] = v * t1;
+						xr[1][idx] = v * t2;
+					}
+				} else
+					idx += sb;
+			}
+		}
+	} else {					/* ((gr_info->block_type != 2)) */
 
-        is_p = scalefac[20]; /* copy l-band 20 to l-band 21 */
-        if(is_p != 7)
-        {
-          int sb;
-          real t1 = tab1[is_p],t2 = tab2[is_p]; 
+		int sfb = gr_info->maxbandl;
+		int is_p, idx = bi->longIdx[sfb];
+		for (; sfb < 21; sfb++) {
+			int sb = bi->longDiff[sfb];
+			is_p = scalefac[sfb];	/* scale: 0-15 */
+			if (is_p != 7) {
+				real t1, t2;
+				t1 = tab1[is_p];
+				t2 = tab2[is_p];
+				for (; sb > 0; sb--, idx++) {
+					real v = xr[0][idx];
+					xr[0][idx] = v * t1;
+					xr[1][idx] = v * t2;
+				}
+			} else
+				idx += sb;
+		}
 
-          for ( sb = bi->longDiff[21]; sb > 0; sb--,idx++ )
-          {
-            real v = xr[0][idx];
-            xr[0][idx] = v * t1;
-            xr[1][idx] = v * t2;
-          }
-        }
-      } /* ... */
+		is_p = scalefac[20];	/* copy l-band 20 to l-band 21 */
+		if (is_p != 7) {
+			int sb;
+			real t1 = tab1[is_p], t2 = tab2[is_p];
+
+			for (sb = bi->longDiff[21]; sb > 0; sb--, idx++) {
+				real v = xr[0][idx];
+				xr[0][idx] = v * t1;
+				xr[1][idx] = v * t2;
+			}
+		}
+	}							/* ... */
 }
 
-static void III_antialias(real xr[SBLIMIT][SSLIMIT],struct gr_info_s *gr_info)
+static void III_antialias(real xr[SBLIMIT][SSLIMIT], struct gr_info_s *gr_info)
 {
-   int sblim;
+	int sblim;
 
-   if(gr_info->block_type == 2)
-   {
-      if(!gr_info->mixed_block_flag) 
-        return;
-      sblim = 1; 
-   }
-   else {
-     sblim = gr_info->maxb-1;
-   }
+	if (gr_info->block_type == 2) {
+		if (!gr_info->mixed_block_flag)
+			return;
+		sblim = 1;
+	} else {
+		sblim = gr_info->maxb - 1;
+	}
 
-   /* 31 alias-reduction operations between each pair of sub-bands */
-   /* with 8 butterflies between each pair                         */
+	/* 31 alias-reduction operations between each pair of sub-bands */
+	/* with 8 butterflies between each pair                         */
 
-   {
-     int sb;
-     real *xr1=(real *) xr[1];
+	{
+		int sb;
+		real *xr1 = (real *) xr[1];
 
-     for(sb=sblim;sb;sb--,xr1+=10)
-     {
-       int ss;
-       real *cs=aa_cs,*ca=aa_ca;
-       real *xr2 = xr1;
+		for (sb = sblim; sb; sb--, xr1 += 10) {
+			int ss;
+			real *cs = aa_cs, *ca = aa_ca;
+			real *xr2 = xr1;
 
-       for(ss=7;ss>=0;ss--)
-       {       /* upper and lower butterfly inputs */
-         register real bu = *--xr2,bd = *xr1;
-         *xr2   = (bu * (*cs)   ) - (bd * (*ca)   );
-         *xr1++ = (bd * (*cs++) ) + (bu * (*ca++) );
-       }
-     }
-  }
+			for (ss = 7; ss >= 0; ss--) {	/* upper and lower butterfly inputs */
+				register real bu = *--xr2, bd = *xr1;
+				*xr2 = (bu * (*cs)) - (bd * (*ca));
+				*xr1++ = (bd * (*cs++)) + (bu * (*ca++));
+			}
+		}
+	}
 }
 
 /*
@@ -1575,23 +1521,40 @@ static void III_antialias(real xr[SBLIMIT][SSLIMIT],struct gr_info_s *gr_info)
      Pages 175-199
 */
 
-static void dct36(real *inbuf,real *o1,real *o2,real *wintab,real *tsbuf)
+static void dct36(real * inbuf, real * o1, real * o2, real * wintab, real * tsbuf)
 {
-  {
-    register real *in = inbuf;
+	{
+		register real *in = inbuf;
 
-    in[17]+=in[16]; in[16]+=in[15]; in[15]+=in[14];
-    in[14]+=in[13]; in[13]+=in[12]; in[12]+=in[11];
-    in[11]+=in[10]; in[10]+=in[9];  in[9] +=in[8];
-    in[8] +=in[7];  in[7] +=in[6];  in[6] +=in[5];
-    in[5] +=in[4];  in[4] +=in[3];  in[3] +=in[2];
-    in[2] +=in[1];  in[1] +=in[0];
+		in[17] += in[16];
+		in[16] += in[15];
+		in[15] += in[14];
+		in[14] += in[13];
+		in[13] += in[12];
+		in[12] += in[11];
+		in[11] += in[10];
+		in[10] += in[9];
+		in[9] += in[8];
+		in[8] += in[7];
+		in[7] += in[6];
+		in[6] += in[5];
+		in[5] += in[4];
+		in[4] += in[3];
+		in[3] += in[2];
+		in[2] += in[1];
+		in[1] += in[0];
 
-    in[17]+=in[15]; in[15]+=in[13]; in[13]+=in[11]; in[11]+=in[9];
-    in[9] +=in[7];  in[7] +=in[5];  in[5] +=in[3];  in[3] +=in[1];
+		in[17] += in[15];
+		in[15] += in[13];
+		in[13] += in[11];
+		in[11] += in[9];
+		in[9] += in[7];
+		in[7] += in[5];
+		in[5] += in[3];
+		in[3] += in[1];
 
 
-  {
+		{
 
 #define MACRO0(v) { \
     real tmp; \
@@ -1599,7 +1562,7 @@ static void dct36(real *inbuf,real *o1,real *o2,real *wintab,real *tsbuf)
     out2[8-(v)] = tmp * w[26-(v)];  } \
     sum0 -= sum1; \
     ts[SBLIMIT*(8-(v))] = out1[8-(v)] + sum0 * w[8-(v)]; \
-    ts[SBLIMIT*(9+(v))] = out1[9+(v)] + sum0 * w[9+(v)]; 
+    ts[SBLIMIT*(9+(v))] = out1[9+(v)] + sum0 * w[9+(v)];
 #define MACRO1(v) { \
 	real sum0,sum1; \
     sum0 = tmp1a + tmp2a; \
@@ -1611,78 +1574,78 @@ static void dct36(real *inbuf,real *o1,real *o2,real *wintab,real *tsbuf)
     sum1 = (tmp2b - tmp1b) * tfcos36[(v)]; \
 	MACRO0(v); }
 
-    register const real *c = COS9;
-    register real *out2 = o2;
-	register real *w = wintab;
-	register real *out1 = o1;
-	register real *ts = tsbuf;
+			register const real *c = COS9;
+			register real *out2 = o2;
+			register real *w = wintab;
+			register real *out1 = o1;
+			register real *ts = tsbuf;
 
-    real ta33,ta66,tb33,tb66;
+			real ta33, ta66, tb33, tb66;
 
-    ta33 = in[2*3+0] * c[3];
-    ta66 = in[2*6+0] * c[6];
-    tb33 = in[2*3+1] * c[3];
-    tb66 = in[2*6+1] * c[6];
+			ta33 = in[2 * 3 + 0] * c[3];
+			ta66 = in[2 * 6 + 0] * c[6];
+			tb33 = in[2 * 3 + 1] * c[3];
+			tb66 = in[2 * 6 + 1] * c[6];
 
-    { 
-      real tmp1a,tmp2a,tmp1b,tmp2b;
-      tmp1a =             in[2*1+0] * c[1] + ta33 + in[2*5+0] * c[5] + in[2*7+0] * c[7];
-      tmp1b =             in[2*1+1] * c[1] + tb33 + in[2*5+1] * c[5] + in[2*7+1] * c[7];
-      tmp2a = in[2*0+0] + in[2*2+0] * c[2] + in[2*4+0] * c[4] + ta66 + in[2*8+0] * c[8];
-      tmp2b = in[2*0+1] + in[2*2+1] * c[2] + in[2*4+1] * c[4] + tb66 + in[2*8+1] * c[8];
+			{
+				real tmp1a, tmp2a, tmp1b, tmp2b;
+				tmp1a = in[2 * 1 + 0] * c[1] + ta33 + in[2 * 5 + 0] * c[5] + in[2 * 7 + 0] * c[7];
+				tmp1b = in[2 * 1 + 1] * c[1] + tb33 + in[2 * 5 + 1] * c[5] + in[2 * 7 + 1] * c[7];
+				tmp2a = in[2 * 0 + 0] + in[2 * 2 + 0] * c[2] + in[2 * 4 + 0] * c[4] + ta66 + in[2 * 8 + 0] * c[8];
+				tmp2b = in[2 * 0 + 1] + in[2 * 2 + 1] * c[2] + in[2 * 4 + 1] * c[4] + tb66 + in[2 * 8 + 1] * c[8];
 
-      MACRO1(0);
-      MACRO2(8);
-    }
+				MACRO1(0);
+				MACRO2(8);
+			}
 
-    {
-      real tmp1a,tmp2a,tmp1b,tmp2b;
-      tmp1a = ( in[2*1+0] - in[2*5+0] - in[2*7+0] ) * c[3];
-      tmp1b = ( in[2*1+1] - in[2*5+1] - in[2*7+1] ) * c[3];
-      tmp2a = ( in[2*2+0] - in[2*4+0] - in[2*8+0] ) * c[6] - in[2*6+0] + in[2*0+0];
-      tmp2b = ( in[2*2+1] - in[2*4+1] - in[2*8+1] ) * c[6] - in[2*6+1] + in[2*0+1];
+			{
+				real tmp1a, tmp2a, tmp1b, tmp2b;
+				tmp1a = (in[2 * 1 + 0] - in[2 * 5 + 0] - in[2 * 7 + 0]) * c[3];
+				tmp1b = (in[2 * 1 + 1] - in[2 * 5 + 1] - in[2 * 7 + 1]) * c[3];
+				tmp2a = (in[2 * 2 + 0] - in[2 * 4 + 0] - in[2 * 8 + 0]) * c[6] - in[2 * 6 + 0] + in[2 * 0 + 0];
+				tmp2b = (in[2 * 2 + 1] - in[2 * 4 + 1] - in[2 * 8 + 1]) * c[6] - in[2 * 6 + 1] + in[2 * 0 + 1];
 
-      MACRO1(1);
-      MACRO2(7);
-    }
+				MACRO1(1);
+				MACRO2(7);
+			}
 
-    {
-      real tmp1a,tmp2a,tmp1b,tmp2b;
-      tmp1a =             in[2*1+0] * c[5] - ta33 - in[2*5+0] * c[7] + in[2*7+0] * c[1];
-      tmp1b =             in[2*1+1] * c[5] - tb33 - in[2*5+1] * c[7] + in[2*7+1] * c[1];
-      tmp2a = in[2*0+0] - in[2*2+0] * c[8] - in[2*4+0] * c[2] + ta66 + in[2*8+0] * c[4];
-      tmp2b = in[2*0+1] - in[2*2+1] * c[8] - in[2*4+1] * c[2] + tb66 + in[2*8+1] * c[4];
+			{
+				real tmp1a, tmp2a, tmp1b, tmp2b;
+				tmp1a = in[2 * 1 + 0] * c[5] - ta33 - in[2 * 5 + 0] * c[7] + in[2 * 7 + 0] * c[1];
+				tmp1b = in[2 * 1 + 1] * c[5] - tb33 - in[2 * 5 + 1] * c[7] + in[2 * 7 + 1] * c[1];
+				tmp2a = in[2 * 0 + 0] - in[2 * 2 + 0] * c[8] - in[2 * 4 + 0] * c[2] + ta66 + in[2 * 8 + 0] * c[4];
+				tmp2b = in[2 * 0 + 1] - in[2 * 2 + 1] * c[8] - in[2 * 4 + 1] * c[2] + tb66 + in[2 * 8 + 1] * c[4];
 
-      MACRO1(2);
-      MACRO2(6);
-    }
+				MACRO1(2);
+				MACRO2(6);
+			}
 
-    {
-      real tmp1a,tmp2a,tmp1b,tmp2b;
-      tmp1a =             in[2*1+0] * c[7] - ta33 + in[2*5+0] * c[1] - in[2*7+0] * c[5];
-      tmp1b =             in[2*1+1] * c[7] - tb33 + in[2*5+1] * c[1] - in[2*7+1] * c[5];
-      tmp2a = in[2*0+0] - in[2*2+0] * c[4] + in[2*4+0] * c[8] + ta66 - in[2*8+0] * c[2];
-      tmp2b = in[2*0+1] - in[2*2+1] * c[4] + in[2*4+1] * c[8] + tb66 - in[2*8+1] * c[2];
+			{
+				real tmp1a, tmp2a, tmp1b, tmp2b;
+				tmp1a = in[2 * 1 + 0] * c[7] - ta33 + in[2 * 5 + 0] * c[1] - in[2 * 7 + 0] * c[5];
+				tmp1b = in[2 * 1 + 1] * c[7] - tb33 + in[2 * 5 + 1] * c[1] - in[2 * 7 + 1] * c[5];
+				tmp2a = in[2 * 0 + 0] - in[2 * 2 + 0] * c[4] + in[2 * 4 + 0] * c[8] + ta66 - in[2 * 8 + 0] * c[2];
+				tmp2b = in[2 * 0 + 1] - in[2 * 2 + 1] * c[4] + in[2 * 4 + 1] * c[8] + tb66 - in[2 * 8 + 1] * c[2];
 
-      MACRO1(3);
-      MACRO2(5);
-    }
+				MACRO1(3);
+				MACRO2(5);
+			}
+
+			{
+				real sum0, sum1;
+				sum0 = in[2 * 0 + 0] - in[2 * 2 + 0] + in[2 * 4 + 0] - in[2 * 6 + 0] + in[2 * 8 + 0];
+				sum1 = (in[2 * 0 + 1] - in[2 * 2 + 1] + in[2 * 4 + 1] - in[2 * 6 + 1] + in[2 * 8 + 1]) * tfcos36[4];
+				MACRO0(4);
+			}
+		}
 
-	{
-		real sum0,sum1;
-    	sum0 =  in[2*0+0] - in[2*2+0] + in[2*4+0] - in[2*6+0] + in[2*8+0];
-    	sum1 = (in[2*0+1] - in[2*2+1] + in[2*4+1] - in[2*6+1] + in[2*8+1] ) * tfcos36[4];
-		MACRO0(4);
 	}
-  }
-
-  }
 }
 
 /*
  * new DCT12
  */
-static void dct12(real *in,real *rawout1,real *rawout2,register real *wi,register real *ts)
+static void dct12(real * in, real * rawout1, real * rawout2, register real * wi, register real * ts)
 {
 #define DCT12_PART1 \
              in5 = in[5*3];  \
@@ -1715,314 +1678,300 @@ static void dct12(real *in,real *rawout1,real *rawout2,register real *wi,registe
      in0 -= in1;
 
 
-   {
-     real in0,in1,in2,in3,in4,in5;
-     register real *out1 = rawout1;
-     ts[SBLIMIT*0] = out1[0]; ts[SBLIMIT*1] = out1[1]; ts[SBLIMIT*2] = out1[2];
-     ts[SBLIMIT*3] = out1[3]; ts[SBLIMIT*4] = out1[4]; ts[SBLIMIT*5] = out1[5];
- 
-     DCT12_PART1
+	{
+		real in0, in1, in2, in3, in4, in5;
+		register real *out1 = rawout1;
+		ts[SBLIMIT * 0] = out1[0];
+		ts[SBLIMIT * 1] = out1[1];
+		ts[SBLIMIT * 2] = out1[2];
+		ts[SBLIMIT * 3] = out1[3];
+		ts[SBLIMIT * 4] = out1[4];
+		ts[SBLIMIT * 5] = out1[5];
 
-     {
-       real tmp0,tmp1 = (in0 - in4);
-       {
-         real tmp2 = (in1 - in5) * tfcos12[1];
-         tmp0 = tmp1 + tmp2;
-         tmp1 -= tmp2;
-       }
-       ts[(17-1)*SBLIMIT] = out1[17-1] + tmp0 * wi[11-1];
-       ts[(12+1)*SBLIMIT] = out1[12+1] + tmp0 * wi[6+1];
-       ts[(6 +1)*SBLIMIT] = out1[6 +1] + tmp1 * wi[1];
-       ts[(11-1)*SBLIMIT] = out1[11-1] + tmp1 * wi[5-1];
-     }
+		DCT12_PART1 {
+			real tmp0, tmp1 = (in0 - in4);
+			{
+				real tmp2 = (in1 - in5) * tfcos12[1];
+				tmp0 = tmp1 + tmp2;
+				tmp1 -= tmp2;
+			}
+			ts[(17 - 1) * SBLIMIT] = out1[17 - 1] + tmp0 * wi[11 - 1];
+			ts[(12 + 1) * SBLIMIT] = out1[12 + 1] + tmp0 * wi[6 + 1];
+			ts[(6 + 1) * SBLIMIT] = out1[6 + 1] + tmp1 * wi[1];
+			ts[(11 - 1) * SBLIMIT] = out1[11 - 1] + tmp1 * wi[5 - 1];
+		}
 
-     DCT12_PART2
+		DCT12_PART2 ts[(17 - 0) * SBLIMIT] = out1[17 - 0] + in2 * wi[11 - 0];
+		ts[(12 + 0) * SBLIMIT] = out1[12 + 0] + in2 * wi[6 + 0];
+		ts[(12 + 2) * SBLIMIT] = out1[12 + 2] + in3 * wi[6 + 2];
+		ts[(17 - 2) * SBLIMIT] = out1[17 - 2] + in3 * wi[11 - 2];
 
-     ts[(17-0)*SBLIMIT] = out1[17-0] + in2 * wi[11-0];
-     ts[(12+0)*SBLIMIT] = out1[12+0] + in2 * wi[6+0];
-     ts[(12+2)*SBLIMIT] = out1[12+2] + in3 * wi[6+2];
-     ts[(17-2)*SBLIMIT] = out1[17-2] + in3 * wi[11-2];
+		ts[(6 + 0) * SBLIMIT] = out1[6 + 0] + in0 * wi[0];
+		ts[(11 - 0) * SBLIMIT] = out1[11 - 0] + in0 * wi[5 - 0];
+		ts[(6 + 2) * SBLIMIT] = out1[6 + 2] + in4 * wi[2];
+		ts[(11 - 2) * SBLIMIT] = out1[11 - 2] + in4 * wi[5 - 2];
+	}
 
-     ts[(6+0)*SBLIMIT]  = out1[6+0] + in0 * wi[0];
-     ts[(11-0)*SBLIMIT] = out1[11-0] + in0 * wi[5-0];
-     ts[(6+2)*SBLIMIT]  = out1[6+2] + in4 * wi[2];
-     ts[(11-2)*SBLIMIT] = out1[11-2] + in4 * wi[5-2];
-  }
+	in++;
 
-  in++;
+	{
+		real in0, in1, in2, in3, in4, in5;
+		register real *out2 = rawout2;
 
-  {
-     real in0,in1,in2,in3,in4,in5;
-     register real *out2 = rawout2;
- 
-     DCT12_PART1
+		DCT12_PART1 {
+			real tmp0, tmp1 = (in0 - in4);
+			{
+				real tmp2 = (in1 - in5) * tfcos12[1];
+				tmp0 = tmp1 + tmp2;
+				tmp1 -= tmp2;
+			}
+			out2[5 - 1] = tmp0 * wi[11 - 1];
+			out2[0 + 1] = tmp0 * wi[6 + 1];
+			ts[(12 + 1) * SBLIMIT] += tmp1 * wi[1];
+			ts[(17 - 1) * SBLIMIT] += tmp1 * wi[5 - 1];
+		}
 
-     {
-       real tmp0,tmp1 = (in0 - in4);
-       {
-         real tmp2 = (in1 - in5) * tfcos12[1];
-         tmp0 = tmp1 + tmp2;
-         tmp1 -= tmp2;
-       }
-       out2[5-1] = tmp0 * wi[11-1];
-       out2[0+1] = tmp0 * wi[6+1];
-       ts[(12+1)*SBLIMIT] += tmp1 * wi[1];
-       ts[(17-1)*SBLIMIT] += tmp1 * wi[5-1];
-     }
+		DCT12_PART2 out2[5 - 0] = in2 * wi[11 - 0];
+		out2[0 + 0] = in2 * wi[6 + 0];
+		out2[0 + 2] = in3 * wi[6 + 2];
+		out2[5 - 2] = in3 * wi[11 - 2];
 
-     DCT12_PART2
+		ts[(12 + 0) * SBLIMIT] += in0 * wi[0];
+		ts[(17 - 0) * SBLIMIT] += in0 * wi[5 - 0];
+		ts[(12 + 2) * SBLIMIT] += in4 * wi[2];
+		ts[(17 - 2) * SBLIMIT] += in4 * wi[5 - 2];
+	}
 
-     out2[5-0] = in2 * wi[11-0];
-     out2[0+0] = in2 * wi[6+0];
-     out2[0+2] = in3 * wi[6+2];
-     out2[5-2] = in3 * wi[11-2];
+	in++;
 
-     ts[(12+0)*SBLIMIT] += in0 * wi[0];
-     ts[(17-0)*SBLIMIT] += in0 * wi[5-0];
-     ts[(12+2)*SBLIMIT] += in4 * wi[2];
-     ts[(17-2)*SBLIMIT] += in4 * wi[5-2];
-  }
+	{
+		real in0, in1, in2, in3, in4, in5;
+		register real *out2 = rawout2;
+		out2[12] = out2[13] = out2[14] = out2[15] = out2[16] = out2[17] = 0.0;
 
-  in++; 
+		DCT12_PART1 {
+			real tmp0, tmp1 = (in0 - in4);
+			{
+				real tmp2 = (in1 - in5) * tfcos12[1];
+				tmp0 = tmp1 + tmp2;
+				tmp1 -= tmp2;
+			}
+			out2[11 - 1] = tmp0 * wi[11 - 1];
+			out2[6 + 1] = tmp0 * wi[6 + 1];
+			out2[0 + 1] += tmp1 * wi[1];
+			out2[5 - 1] += tmp1 * wi[5 - 1];
+		}
 
-  {
-     real in0,in1,in2,in3,in4,in5;
-     register real *out2 = rawout2;
-     out2[12]=out2[13]=out2[14]=out2[15]=out2[16]=out2[17]=0.0;
+		DCT12_PART2 out2[11 - 0] = in2 * wi[11 - 0];
+		out2[6 + 0] = in2 * wi[6 + 0];
+		out2[6 + 2] = in3 * wi[6 + 2];
+		out2[11 - 2] = in3 * wi[11 - 2];
 
-     DCT12_PART1
-
-     {
-       real tmp0,tmp1 = (in0 - in4);
-       {
-         real tmp2 = (in1 - in5) * tfcos12[1];
-         tmp0 = tmp1 + tmp2;
-         tmp1 -= tmp2;
-       }
-       out2[11-1] = tmp0 * wi[11-1];
-       out2[6 +1] = tmp0 * wi[6+1];
-       out2[0+1] += tmp1 * wi[1];
-       out2[5-1] += tmp1 * wi[5-1];
-     }
-
-     DCT12_PART2
-
-     out2[11-0] = in2 * wi[11-0];
-     out2[6 +0] = in2 * wi[6+0];
-     out2[6 +2] = in3 * wi[6+2];
-     out2[11-2] = in3 * wi[11-2];
-
-     out2[0+0] += in0 * wi[0];
-     out2[5-0] += in0 * wi[5-0];
-     out2[0+2] += in4 * wi[2];
-     out2[5-2] += in4 * wi[5-2];
-  }
+		out2[0 + 0] += in0 * wi[0];
+		out2[5 - 0] += in0 * wi[5 - 0];
+		out2[0 + 2] += in4 * wi[2];
+		out2[5 - 2] += in4 * wi[5 - 2];
+	}
 }
 
 /*
  * III_hybrid
  */
-static void III_hybrid(struct mpstr *mp, real fsIn[SBLIMIT][SSLIMIT],real tsOut[SSLIMIT][SBLIMIT],
-   int ch,struct gr_info_s *gr_info)
+static void III_hybrid(struct mpstr *mp, real fsIn[SBLIMIT][SSLIMIT], real tsOut[SSLIMIT][SBLIMIT],
+					   int ch, struct gr_info_s *gr_info)
 {
-   real *tspnt = (real *) tsOut;
-   real (*block)[2][SBLIMIT*SSLIMIT] = mp->hybrid_block;
-   int *blc = mp->hybrid_blc;
-   real *rawout1,*rawout2;
-   int bt;
-   int sb = 0;
+	real *tspnt = (real *) tsOut;
+	real(*block)[2][SBLIMIT * SSLIMIT] = mp->hybrid_block;
+	int *blc = mp->hybrid_blc;
+	real *rawout1, *rawout2;
+	int bt;
+	int sb = 0;
 
-   {
-     int b = blc[ch];
-     rawout1=block[b][ch];
-     b=-b+1;
-     rawout2=block[b][ch];
-     blc[ch] = b;
-   }
+	{
+		int b = blc[ch];
+		rawout1 = block[b][ch];
+		b = -b + 1;
+		rawout2 = block[b][ch];
+		blc[ch] = b;
+	}
 
-  
-   if(gr_info->mixed_block_flag) {
-     sb = 2;
-     dct36(fsIn[0],rawout1,rawout2,win[0],tspnt);
-     dct36(fsIn[1],rawout1+18,rawout2+18,win1[0],tspnt+1);
-     rawout1 += 36; rawout2 += 36; tspnt += 2;
-   }
- 
-   bt = gr_info->block_type;
-   if(bt == 2) {
-     for (; sbmaxb; sb+=2,tspnt+=2,rawout1+=36,rawout2+=36) {
-       dct12(fsIn[sb],rawout1,rawout2,win[2],tspnt);
-       dct12(fsIn[sb+1],rawout1+18,rawout2+18,win1[2],tspnt+1);
-     }
-   }
-   else {
-     for (; sbmaxb; sb+=2,tspnt+=2,rawout1+=36,rawout2+=36) {
-       dct36(fsIn[sb],rawout1,rawout2,win[bt],tspnt);
-       dct36(fsIn[sb+1],rawout1+18,rawout2+18,win1[bt],tspnt+1);
-     }
-   }
 
-   for(;sbmixed_block_flag) {
+		sb = 2;
+		dct36(fsIn[0], rawout1, rawout2, win[0], tspnt);
+		dct36(fsIn[1], rawout1 + 18, rawout2 + 18, win1[0], tspnt + 1);
+		rawout1 += 36;
+		rawout2 += 36;
+		tspnt += 2;
+	}
+
+	bt = gr_info->block_type;
+	if (bt == 2) {
+		for (; sb < gr_info->maxb; sb += 2, tspnt += 2, rawout1 += 36, rawout2 += 36) {
+			dct12(fsIn[sb], rawout1, rawout2, win[2], tspnt);
+			dct12(fsIn[sb + 1], rawout1 + 18, rawout2 + 18, win1[2], tspnt + 1);
+		}
+	} else {
+		for (; sb < gr_info->maxb; sb += 2, tspnt += 2, rawout1 += 36, rawout2 += 36) {
+			dct36(fsIn[sb], rawout1, rawout2, win[bt], tspnt);
+			dct36(fsIn[sb + 1], rawout1 + 18, rawout2 + 18, win1[bt], tspnt + 1);
+		}
+	}
+
+	for (; sb < SBLIMIT; sb++, tspnt++) {
+		int i;
+		for (i = 0; i < SSLIMIT; i++) {
+			tspnt[i * SBLIMIT] = *rawout1++;
+			*rawout2++ = 0.0;
+		}
+	}
 }
 
 /*
  * main layer3 handler
  */
-int do_layer3(struct mpstr *mp,unsigned char *pcm_sample,int *pcm_point)
+int do_layer3(struct mpstr *mp, unsigned char *pcm_sample, int *pcm_point)
 {
 
-  int gr, ch, ss,clip=0;
-  int scalefacs[39]; /* max 39 for short[13][3] mode, mixed: 38, long: 22 */
-  struct III_sideinfo sideinfo;
-  struct frame *fr;
-  int stereo, single, sfreq;
-  int ms_stereo,i_stereo;
-  int stereo1,granules;
+	int gr, ch, ss, clip = 0;
+	int scalefacs[39];			/* max 39 for short[13][3] mode, mixed: 38, long: 22 */
+	struct III_sideinfo sideinfo;
+	struct frame *fr;
+	int stereo, single, sfreq;
+	int ms_stereo, i_stereo;
+	int stereo1, granules;
 
-  fr = &(mp->fr);
-  stereo = fr->stereo;
-  single = fr->single;
-  sfreq = fr->sampling_frequency;
+	fr = &(mp->fr);
+	stereo = fr->stereo;
+	single = fr->single;
+	sfreq = fr->sampling_frequency;
 
-  
-  
-  if(stereo == 1) { /* stream is mono */
-    stereo1 = 1;
-    single = 0;
-  }
-  else if(single >= 0) /* stream is stereo, but force to mono */
-    stereo1 = 1;
-  else
-    stereo1 = 2;
 
-  if(fr->mode == MPG_MD_JOINT_STEREO) {
-    ms_stereo = fr->mode_ext & 0x2;
-    i_stereo  = fr->mode_ext & 0x1;
-  }
-  else
-    ms_stereo = i_stereo = 0;
 
-  if(fr->lsf) {
-    granules = 1;
-    if (III_get_side_info_2(mp, &sideinfo,stereo,ms_stereo,sfreq,single))
-	    return (MP3_ERR);
-  }
-  else {
-    granules = 2;
+	if (stereo == 1) {			/* stream is mono */
+		stereo1 = 1;
+		single = 0;
+	} else if (single >= 0)		/* stream is stereo, but force to mono */
+		stereo1 = 1;
+	else
+		stereo1 = 2;
+
+	if (fr->mode == MPG_MD_JOINT_STEREO) {
+		ms_stereo = fr->mode_ext & 0x2;
+		i_stereo = fr->mode_ext & 0x1;
+	} else
+		ms_stereo = i_stereo = 0;
+
+	if (fr->lsf) {
+		granules = 1;
+		if (III_get_side_info_2(mp, &sideinfo, stereo, ms_stereo, sfreq, single))
+			return (MP3_ERR);
+	} else {
+		granules = 2;
 #ifdef MPEG1
-   if ( III_get_side_info_1(mp, &sideinfo,stereo,ms_stereo,sfreq,single))
-	   return (MP3_ERR);
-   
+		if (III_get_side_info_1(mp, &sideinfo, stereo, ms_stereo, sfreq, single))
+			return (MP3_ERR);
+
 #else
-   debug_printf("%d Not supported\n",  __LINE__);
+		debug_printf("%d Not supported\n", __LINE__);
 #endif
-  }
+	}
 
-  if(set_pointer(mp, sideinfo.main_data_begin) == MP3_ERR)
-    return 0;
+	if (set_pointer(mp, sideinfo.main_data_begin) == MP3_ERR)
+		return 0;
 
-  for (gr=0;grlsf)
-        part2bits = III_get_scale_factors_2(mp, scalefacs,gr_info,0);
-      else {
+		{
+			struct gr_info_s *gr_info = &(sideinfo.ch[0].gr[gr]);
+			long part2bits;
+			if (fr->lsf)
+				part2bits = III_get_scale_factors_2(mp, scalefacs, gr_info, 0);
+			else {
 #ifdef MPEG1
-        part2bits = III_get_scale_factors_1(mp, scalefacs,gr_info);
+				part2bits = III_get_scale_factors_1(mp, scalefacs, gr_info);
 #else
-		debug_printf("%d Not supported\n",  __LINE__);
+				debug_printf("%d Not supported\n", __LINE__);
 #endif
-      }
-      if(III_dequantize_sample(mp, hybridIn[0], scalefacs,gr_info,sfreq,part2bits))
-        return (MP3_ERR);
-    }
-    if(stereo == 2) {
-      struct gr_info_s *gr_info = &(sideinfo.ch[1].gr[gr]);
-      long part2bits;
-      if(fr->lsf) 
-        part2bits = III_get_scale_factors_2(mp, scalefacs,gr_info,i_stereo);
-      else {
+			}
+			if (III_dequantize_sample(mp, hybridIn[0], scalefacs, gr_info, sfreq, part2bits))
+				return (MP3_ERR);
+		}
+		if (stereo == 2) {
+			struct gr_info_s *gr_info = &(sideinfo.ch[1].gr[gr]);
+			long part2bits;
+			if (fr->lsf)
+				part2bits = III_get_scale_factors_2(mp, scalefacs, gr_info, i_stereo);
+			else {
 #ifdef MPEG1
-        part2bits = III_get_scale_factors_1(mp, scalefacs,gr_info);
+				part2bits = III_get_scale_factors_1(mp, scalefacs, gr_info);
 #else
-		debug_printf("%d Not supported\n",  __LINE__);
+				debug_printf("%d Not supported\n", __LINE__);
 #endif
-      }
+			}
 
-      if(III_dequantize_sample(mp, hybridIn[1],scalefacs,gr_info,sfreq,part2bits))
-          return (MP3_ERR);
+			if (III_dequantize_sample(mp, hybridIn[1], scalefacs, gr_info, sfreq, part2bits))
+				return (MP3_ERR);
 
-      if(ms_stereo) {
-        int i;
-        for(i=0;ilsf);
+			if (i_stereo)
+				III_i_stereo(hybridIn, scalefacs, gr_info, sfreq, ms_stereo, fr->lsf);
 
-      if(ms_stereo || i_stereo || (single == 3) ) {
-        if(gr_info->maxb > sideinfo.ch[0].gr[gr].maxb) 
-          sideinfo.ch[0].gr[gr].maxb = gr_info->maxb;
-        else
-          gr_info->maxb = sideinfo.ch[0].gr[gr].maxb;
-      }
+			if (ms_stereo || i_stereo || (single == 3)) {
+				if (gr_info->maxb > sideinfo.ch[0].gr[gr].maxb)
+					sideinfo.ch[0].gr[gr].maxb = gr_info->maxb;
+				else
+					gr_info->maxb = sideinfo.ch[0].gr[gr].maxb;
+			}
 
-      switch(single) {
-        case 3:
-          {
-            register int i;
-            register real *in0 = (real *) hybridIn[0],*in1 = (real *) hybridIn[1];
-            for(i=0;imaxb;i++,in0++)
-              *in0 = (*in0 + *in1++); /* *0.5 done by pow-scale */ 
-          }
-          break;
-        case 1:
-          {
-            register int i;
-            register real *in0 = (real *) hybridIn[0],*in1 = (real *) hybridIn[1];
-            for(i=0;imaxb;i++)
-              *in0++ = *in1++;
-          }
-          break;
-      }
-    }
+			switch (single) {
+			case 3:
+				{
+					register int i;
+					register real *in0 = (real *) hybridIn[0], *in1 = (real *) hybridIn[1];
+					for (i = 0; i < SSLIMIT * gr_info->maxb; i++, in0++)
+						*in0 = (*in0 + *in1++);	/* *0.5 done by pow-scale */
+				}
+				break;
+			case 1:
+				{
+					register int i;
+					register real *in0 = (real *) hybridIn[0], *in1 = (real *) hybridIn[1];
+					for (i = 0; i < SSLIMIT * gr_info->maxb; i++)
+						*in0++ = *in1++;
+				}
+				break;
+			}
+		}
 
-    for(ch=0;ch= 0) {
-        clip += synth_ntom_mono(mp,hybridOut[0][ss],pcm_sample,pcm_point);
-      }
-      else {
-        int p1 = *pcm_point;
-        clip += synth_ntom(mp,hybridOut[0][ss],0,pcm_sample,&p1);
-        clip += synth_ntom(mp,hybridOut[1][ss],1,pcm_sample,pcm_point);
-      }
-    }
-  }
-  
-  return 0;
+		for (ss = 0; ss < SSLIMIT; ss++) {
+			if (single >= 0) {
+				clip += synth_ntom_mono(mp, hybridOut[0][ss], pcm_sample, pcm_point);
+			} else {
+				int p1 = *pcm_point;
+				clip += synth_ntom(mp, hybridOut[0][ss], 0, pcm_sample, &p1);
+				clip += synth_ntom(mp, hybridOut[1][ss], 1, pcm_sample, pcm_point);
+			}
+		}
+	}
+
+	return 0;
 }
-
-
diff --git a/src/mod/formats/mod_shout/mod_shout.c b/src/mod/formats/mod_shout/mod_shout.c
index ba73e0a0a5..0141e5a6fe 100644
--- a/src/mod/formats/mod_shout/mod_shout.c
+++ b/src/mod/formats/mod_shout/mod_shout.c
@@ -46,84 +46,84 @@ static const char modname[] = "mod_shout";
 
 
 
-static char *supported_formats[SWITCH_MAX_CODECS] = {0};
+static char *supported_formats[SWITCH_MAX_CODECS] = { 0 };
 
 struct shout_context {
 	shout_t *shout;
-    lame_global_flags *gfp;
-    char *stream_url;
+	lame_global_flags *gfp;
+	char *stream_url;
 	switch_mutex_t *audio_mutex;
 	switch_buffer_t *audio_buffer;
-    switch_memory_pool_t *memory_pool;
-    char decode_buf[MP3_DCACHE];
-    struct mpstr mp;
-    int err;
-    int mp3err;
-    int dlen;
-    switch_file_t *fd;
-    FILE *fp;
-    int samplerate;
-    uint8_t thread_running;
-    uint8_t shout_init;
+	switch_memory_pool_t *memory_pool;
+	char decode_buf[MP3_DCACHE];
+	struct mpstr mp;
+	int err;
+	int mp3err;
+	int dlen;
+	switch_file_t *fd;
+	FILE *fp;
+	int samplerate;
+	uint8_t thread_running;
+	uint8_t shout_init;
 };
 
 typedef struct shout_context shout_context_t;
 
 
-static size_t decode_fd(shout_context_t *context, void *data, size_t bytes);
+static size_t decode_fd(shout_context_t * context, void *data, size_t bytes);
 
-static inline void free_context(shout_context_t *context)
+static inline void free_context(shout_context_t * context)
 {
-    if (context) {
-        context->err++;
+	if (context) {
+		context->err++;
 
-        if (context->fd) {
-            switch_file_close(context->fd);
-            context->fd = NULL;
-        }
+		if (context->fd) {
+			switch_file_close(context->fd);
+			context->fd = NULL;
+		}
 
-        if (context->fp) {
-            unsigned char mp3buffer[1024];
-            int len;
+		if (context->fp) {
+			unsigned char mp3buffer[1024];
+			int len;
 
-            while ((len = lame_encode_flush(context->gfp, mp3buffer, sizeof(mp3buffer))) > 0) {
-                fwrite(mp3buffer, 1, len, context->fp);
-            }
-            
-            lame_mp3_tags_fid(context->gfp, context->fp);
-            fclose(context->fp);
-            context->fp = NULL;
-        }
+			while ((len = lame_encode_flush(context->gfp, mp3buffer, sizeof(mp3buffer))) > 0) {
+				fwrite(mp3buffer, 1, len, context->fp);
+			}
 
-        if (context->audio_buffer) {
-            switch_mutex_lock(context->audio_mutex);
-            switch_buffer_destroy(&context->audio_buffer);
-            switch_mutex_unlock(context->audio_mutex);
-        }
+			lame_mp3_tags_fid(context->gfp, context->fp);
+			fclose(context->fp);
+			context->fp = NULL;
+		}
 
-        if (context->shout) {
-            shout_close(context->shout);
-            context->shout = NULL;
-        }
+		if (context->audio_buffer) {
+			switch_mutex_lock(context->audio_mutex);
+			switch_buffer_destroy(&context->audio_buffer);
+			switch_mutex_unlock(context->audio_mutex);
+		}
 
-        if (context->gfp) {
-            lame_close(context->gfp);
-            context->gfp = NULL;
-        }
+		if (context->shout) {
+			shout_close(context->shout);
+			context->shout = NULL;
+		}
 
-        if (context->stream_url) {
-            int sanity = 0;
-        
-            while(context->thread_running) {
-                switch_yield(500000);
-                if (++sanity > 10) {
-                    break;
-                }
-            }
+		if (context->gfp) {
+			lame_close(context->gfp);
+			context->gfp = NULL;
+		}
 
-            ExitMP3(&context->mp);
-        }
-    }
+		if (context->stream_url) {
+			int sanity = 0;
+
+			while (context->thread_running) {
+				switch_yield(500000);
+				if (++sanity > 10) {
+					break;
+				}
+			}
+
+			ExitMP3(&context->mp);
+		}
+	}
 }
 
 
@@ -142,13 +142,13 @@ static void log_error(char const *fmt, va_list ap)
 		data = (char *) malloc(2048);
 		if (data) {
 			vsnprintf(data, 2048, fmt, ap);
-		} else { 
+		} else {
 			return;
 		}
 #endif
 	}
 	if (data) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, (char*) "%s", data);
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, (char *) "%s", data);
 		free(data);
 	}
 }
@@ -168,13 +168,13 @@ static void log_debug(char const *fmt, va_list ap)
 		data = (char *) malloc(2048);
 		if (data) {
 			vsnprintf(data, 2048, fmt, ap);
-		} else { 
+		} else {
 			return;
 		}
 #endif
 	}
 	if (data) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, (char*) "%s", data);
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, (char *) "%s", data);
 		free(data);
 	}
 }
@@ -194,120 +194,120 @@ static void log_msg(char const *fmt, va_list ap)
 		data = (char *) malloc(2048);
 		if (data) {
 			vsnprintf(data, 2048, fmt, ap);
-		} else { 
+		} else {
 			return;
 		}
 #endif
 	}
 	if (data) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, (char*) "%s", data);
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, (char *) "%s", data);
 		free(data);
 	}
 }
 
-static size_t decode_fd(shout_context_t *context, void *data, size_t bytes)
+static size_t decode_fd(shout_context_t * context, void *data, size_t bytes)
 {
-    int decode_status = 0;
-    int dlen = 0;
-    int x = 0;
-    char *in;
-    int inlen;
-    char *out;
-    int outlen;
-    int usedlen;
-    char inbuf[MP3_SCACHE];
-    int done = 0;
-    
-    size_t lp;
-    size_t rb = 0;
+	int decode_status = 0;
+	int dlen = 0;
+	int x = 0;
+	char *in;
+	int inlen;
+	char *out;
+	int outlen;
+	int usedlen;
+	char inbuf[MP3_SCACHE];
+	int done = 0;
 
-    while (switch_buffer_inuse(context->audio_buffer) < bytes) {
-        lp = sizeof(inbuf);
-        if ((switch_file_read(context->fd, inbuf, &lp) != SWITCH_STATUS_SUCCESS) || lp == 0) {
-            goto error;
-        }
+	size_t lp;
+	size_t rb = 0;
 
-        inlen = (int) lp;
-        in = inbuf;
-        
-        out = context->decode_buf;
-        outlen = (int) sizeof(context->decode_buf);
-        usedlen = 0;
-        x =  0;
+	while (switch_buffer_inuse(context->audio_buffer) < bytes) {
+		lp = sizeof(inbuf);
+		if ((switch_file_read(context->fd, inbuf, &lp) != SWITCH_STATUS_SUCCESS) || lp == 0) {
+			goto error;
+		}
 
-        if (inlen < bytes) {
-            done = 1;
-        }
+		inlen = (int) lp;
+		in = inbuf;
 
-        do {
-            decode_status = decodeMP3(&context->mp, in, inlen, out, outlen, &dlen);
+		out = context->decode_buf;
+		outlen = (int) sizeof(context->decode_buf);
+		usedlen = 0;
+		x = 0;
 
-            if (context->err) {
-                goto error;
-            }
+		if (inlen < bytes) {
+			done = 1;
+		}
 
-            if (!x) {
-                in = NULL;
-                inlen = 0;
-                x++;
-            }
-            
-            if (decode_status == MP3_TOOSMALL) {
-                if (context->audio_buffer) {
-                    switch_buffer_write(context->audio_buffer, context->decode_buf, usedlen);
-                } else {
-                    goto error;
-                }
-                
-                out = context->decode_buf;
-                outlen = sizeof(context->decode_buf);
-                usedlen = 0;
-                continue;
-                
-            }
+		do {
+			decode_status = decodeMP3(&context->mp, in, inlen, out, outlen, &dlen);
 
-            if (decode_status == MP3_ERR) {
-                if (++context->mp3err >= 20) {
-                    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Decoder Error!\n");
-                }
-                dlen = 0;
-                continue;
-            }
-            
-            context->mp3err = 0;
-            
-            usedlen += dlen;        
-            out += dlen;
-            outlen -= dlen;
-            dlen = 0;
-            
+			if (context->err) {
+				goto error;
+			}
 
-        } while (decode_status != MP3_NEED_MORE);
-        
+			if (!x) {
+				in = NULL;
+				inlen = 0;
+				x++;
+			}
 
-        if (context->audio_buffer) {
-            switch_buffer_write(context->audio_buffer, context->decode_buf, usedlen);
-        } else {
-            goto error;
-        }
+			if (decode_status == MP3_TOOSMALL) {
+				if (context->audio_buffer) {
+					switch_buffer_write(context->audio_buffer, context->decode_buf, usedlen);
+				} else {
+					goto error;
+				}
 
-        if (done) {
-            break;
-        }
-    }
+				out = context->decode_buf;
+				outlen = sizeof(context->decode_buf);
+				usedlen = 0;
+				continue;
 
-    if (done || switch_buffer_inuse(context->audio_buffer) >= bytes) {
-        rb = switch_buffer_read(context->audio_buffer, data, bytes);
-        return rb;
-    }
+			}
 
-    return 0;
-    
- error:
-    switch_mutex_lock(context->audio_mutex);
-    context->err++;
-    switch_mutex_unlock(context->audio_mutex);
-    return 0;
+			if (decode_status == MP3_ERR) {
+				if (++context->mp3err >= 20) {
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Decoder Error!\n");
+				}
+				dlen = 0;
+				continue;
+			}
+
+			context->mp3err = 0;
+
+			usedlen += dlen;
+			out += dlen;
+			outlen -= dlen;
+			dlen = 0;
+
+
+		} while (decode_status != MP3_NEED_MORE);
+
+
+		if (context->audio_buffer) {
+			switch_buffer_write(context->audio_buffer, context->decode_buf, usedlen);
+		} else {
+			goto error;
+		}
+
+		if (done) {
+			break;
+		}
+	}
+
+	if (done || switch_buffer_inuse(context->audio_buffer) >= bytes) {
+		rb = switch_buffer_read(context->audio_buffer, data, bytes);
+		return rb;
+	}
+
+	return 0;
+
+  error:
+	switch_mutex_lock(context->audio_mutex);
+	context->err++;
+	switch_mutex_unlock(context->audio_mutex);
+	return 0;
 
 }
 
@@ -315,107 +315,107 @@ static size_t decode_fd(shout_context_t *context, void *data, size_t bytes)
 
 static size_t stream_callback(void *ptr, size_t size, size_t nmemb, void *data)
 {
-	register unsigned int realsize = (unsigned int)(size * nmemb);
+	register unsigned int realsize = (unsigned int) (size * nmemb);
 	shout_context_t *context = data;
-    int decode_status = 0;
-    int dlen = 0;
-    int x = 0;
-    char *in;
-    int inlen;
-    char *out;
-    int outlen;
-    int usedlen;
-    uint32_t used, buf_size = 1024 * 64;
-    
-    in = ptr;
-    inlen = realsize;
-    out = context->decode_buf;
-    outlen = sizeof(context->decode_buf);
-    usedlen = 0;
+	int decode_status = 0;
+	int dlen = 0;
+	int x = 0;
+	char *in;
+	int inlen;
+	char *out;
+	int outlen;
+	int usedlen;
+	uint32_t used, buf_size = 1024 * 64;
 
-    error_check();
-    
-    /* make sure we aren't over zealous by slowing down the stream when the buffer is too full */
-    for(;;) { 
-        error_check();
+	in = ptr;
+	inlen = realsize;
+	out = context->decode_buf;
+	outlen = sizeof(context->decode_buf);
+	usedlen = 0;
 
-        switch_mutex_lock(context->audio_mutex);
-        if (!context->audio_buffer) {
-            context->err++;
-            break;
-        }
+	error_check();
 
-        used = switch_buffer_inuse(context->audio_buffer);
-        switch_mutex_unlock(context->audio_mutex);
+	/* make sure we aren't over zealous by slowing down the stream when the buffer is too full */
+	for (;;) {
+		error_check();
 
-        if (used < buf_size) {
-            break;
-        }
+		switch_mutex_lock(context->audio_mutex);
+		if (!context->audio_buffer) {
+			context->err++;
+			break;
+		}
 
-        switch_yield(1000000);
-    }
+		used = switch_buffer_inuse(context->audio_buffer);
+		switch_mutex_unlock(context->audio_mutex);
 
-    error_check();
+		if (used < buf_size) {
+			break;
+		}
 
-    do {
-        decode_status = decodeMP3(&context->mp, in, inlen, out, outlen, &dlen);
+		switch_yield(1000000);
+	}
 
-        error_check();
+	error_check();
 
-        if (!x) {
-            in = NULL;
-            inlen = 0;
-            x++;
-        }
-        
-        if (decode_status == MP3_TOOSMALL) {
-            switch_mutex_lock(context->audio_mutex);
-            if (context->audio_buffer) {
-                switch_buffer_write(context->audio_buffer, context->decode_buf, usedlen);
-            } else {
-                goto error;
-            }
-            out = context->decode_buf;
-            outlen = sizeof(context->decode_buf);
-            usedlen = 0;
-            switch_mutex_unlock(context->audio_mutex);
-            
-        } else if (decode_status == MP3_ERR) {
+	do {
+		decode_status = decodeMP3(&context->mp, in, inlen, out, outlen, &dlen);
 
-            if (++context->mp3err >= 20) {
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Decoder Error!\n");
-                goto error;
-            }
+		error_check();
 
-            ExitMP3(&context->mp);
-            InitMP3(&context->mp, OUTSCALE, context->samplerate);
-            
-            return realsize;
-        }
+		if (!x) {
+			in = NULL;
+			inlen = 0;
+			x++;
+		}
 
-        context->mp3err = 0;    
-        usedlen += dlen;        
-        out += dlen;
-        outlen -= dlen;
-        dlen = 0;
-    } while (decode_status != MP3_NEED_MORE);
+		if (decode_status == MP3_TOOSMALL) {
+			switch_mutex_lock(context->audio_mutex);
+			if (context->audio_buffer) {
+				switch_buffer_write(context->audio_buffer, context->decode_buf, usedlen);
+			} else {
+				goto error;
+			}
+			out = context->decode_buf;
+			outlen = sizeof(context->decode_buf);
+			usedlen = 0;
+			switch_mutex_unlock(context->audio_mutex);
+
+		} else if (decode_status == MP3_ERR) {
+
+			if (++context->mp3err >= 20) {
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Decoder Error!\n");
+				goto error;
+			}
+
+			ExitMP3(&context->mp);
+			InitMP3(&context->mp, OUTSCALE, context->samplerate);
+
+			return realsize;
+		}
+
+		context->mp3err = 0;
+		usedlen += dlen;
+		out += dlen;
+		outlen -= dlen;
+		dlen = 0;
+	} while (decode_status != MP3_NEED_MORE);
 
 
-    switch_mutex_lock(context->audio_mutex);
-    if (context->audio_buffer) {
-        switch_buffer_write(context->audio_buffer, context->decode_buf, usedlen);
-    } else {
-        goto error;
-    }
-    switch_mutex_unlock(context->audio_mutex);
+	switch_mutex_lock(context->audio_mutex);
+	if (context->audio_buffer) {
+		switch_buffer_write(context->audio_buffer, context->decode_buf, usedlen);
+	} else {
+		goto error;
+	}
+	switch_mutex_unlock(context->audio_mutex);
 
 	return realsize;
-    
- error:
-    switch_mutex_lock(context->audio_mutex);
-    context->err++;
-    switch_mutex_unlock(context->audio_mutex);
-    return 0;
+
+  error:
+	switch_mutex_lock(context->audio_mutex);
+	context->err++;
+	switch_mutex_unlock(context->audio_mutex);
+	return 0;
 
 }
 
@@ -424,34 +424,34 @@ static size_t stream_callback(void *ptr, size_t size, size_t nmemb, void *data)
 #define MY_BLOCK_SIZE MY_BUF_LEN
 static void *SWITCH_THREAD_FUNC read_stream_thread(switch_thread_t *thread, void *obj)
 {
-    CURL *curl_handle = NULL;
-    shout_context_t *context = (shout_context_t *) obj;
+	CURL *curl_handle = NULL;
+	shout_context_t *context = (shout_context_t *) obj;
 
 	curl_handle = curl_easy_init();
-    curl_easy_setopt(curl_handle, CURLOPT_URL, context->stream_url);
-    curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, stream_callback);
-    curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *)context);
-    curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, "FreeSWITCH(mod_shout)/1.0");
-    curl_easy_perform(curl_handle);
-    curl_easy_cleanup(curl_handle);
-    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Thread Done\n");
-    switch_mutex_lock(context->audio_mutex);
-    context->err++;
-    switch_mutex_unlock(context->audio_mutex);
-    context->thread_running = 0;
-    return NULL;
+	curl_easy_setopt(curl_handle, CURLOPT_URL, context->stream_url);
+	curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, stream_callback);
+	curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *) context);
+	curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, "FreeSWITCH(mod_shout)/1.0");
+	curl_easy_perform(curl_handle);
+	curl_easy_cleanup(curl_handle);
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Thread Done\n");
+	switch_mutex_lock(context->audio_mutex);
+	context->err++;
+	switch_mutex_unlock(context->audio_mutex);
+	context->thread_running = 0;
+	return NULL;
 }
 
-static void launch_read_stream_thread(shout_context_t *context)
+static void launch_read_stream_thread(shout_context_t * context)
 {
 	switch_thread_t *thread;
 	switch_threadattr_t *thd_attr = NULL;
 
 	if (context->err) {
-        return;
-    }
-    
-    context->thread_running = 1;
+		return;
+	}
+
+	context->thread_running = 1;
 	switch_threadattr_create(&thd_attr, context->memory_pool);
 	switch_threadattr_detach_set(thd_attr, 1);
 	switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
@@ -460,66 +460,69 @@ static void launch_read_stream_thread(shout_context_t *context)
 
 static void *SWITCH_THREAD_FUNC write_stream_thread(switch_thread_t *thread, void *obj)
 {
-    shout_context_t *context = (shout_context_t *) obj;
+	shout_context_t *context = (shout_context_t *) obj;
 
-    while(!context->err && context->thread_running) {
-        unsigned char mp3buf[8192] = "";
-        unsigned char audio[8192] = "";
-        switch_size_t audio_read = 0;
-        int rlen;
-        long ret = 0;
+	while (!context->err && context->thread_running) {
+		unsigned char mp3buf[8192] = "";
+		unsigned char audio[8192] = "";
+		switch_size_t audio_read = 0;
+		int rlen;
+		long ret = 0;
 
-        switch_mutex_lock(context->audio_mutex);
-        if (context->audio_buffer) {
-            audio_read = switch_buffer_read(context->audio_buffer, audio, sizeof(audio));
-        } else {
-            context->err++;
-        }
-        switch_mutex_unlock(context->audio_mutex);
+		switch_mutex_lock(context->audio_mutex);
+		if (context->audio_buffer) {
+			audio_read = switch_buffer_read(context->audio_buffer, audio, sizeof(audio));
+		} else {
+			context->err++;
+		}
+		switch_mutex_unlock(context->audio_mutex);
 
-        error_check();
+		error_check();
 
-        if (!audio_read) {
-            audio_read = sizeof(audio);
-            memset(audio, 255, sizeof(audio));
-        }
-        
-        if ((rlen = lame_encode_buffer(context->gfp, (void *) audio, NULL, audio_read / sizeof(int16_t), mp3buf, sizeof(mp3buf))) < 0) {
-            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "MP3 encode error %d!\n", rlen);
-            goto error;
-        }
+		if (!audio_read) {
+			audio_read = sizeof(audio);
+			memset(audio, 255, sizeof(audio));
+		}
 
-        if (rlen) {
-            ret = shout_send(context->shout, mp3buf, rlen);
-            if (ret != SHOUTERR_SUCCESS) {
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Send error: %s\n", shout_get_error(context->shout));
-                goto error;
-            }
-        } else {
-            memset(mp3buf, 0, 128);
-            ret = shout_send(context->shout, mp3buf, 128);
-        }
-        
-        shout_sync(context->shout);
-        switch_yield(100000);
-    }
+		if ((rlen =
+			 lame_encode_buffer(context->gfp, (void *) audio, NULL, audio_read / sizeof(int16_t), mp3buf,
+								sizeof(mp3buf))) < 0) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "MP3 encode error %d!\n", rlen);
+			goto error;
+		}
 
-    error:
-    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Thread Done\n");
-    context->thread_running = 0;
-    return NULL;
+		if (rlen) {
+			ret = shout_send(context->shout, mp3buf, rlen);
+			if (ret != SHOUTERR_SUCCESS) {
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Send error: %s\n",
+								  shout_get_error(context->shout));
+				goto error;
+			}
+		} else {
+			memset(mp3buf, 0, 128);
+			ret = shout_send(context->shout, mp3buf, 128);
+		}
+
+		shout_sync(context->shout);
+		switch_yield(100000);
+	}
+
+  error:
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Thread Done\n");
+	context->thread_running = 0;
+	return NULL;
 }
 
-static void launch_write_stream_thread(shout_context_t *context)
+static void launch_write_stream_thread(shout_context_t * context)
 {
 	switch_thread_t *thread;
 	switch_threadattr_t *thd_attr = NULL;
 
 	if (context->err) {
-        return;
-    }
-    
-    context->thread_running = 1;
+		return;
+	}
+
+	context->thread_running = 1;
 	switch_threadattr_create(&thd_attr, context->memory_pool);
 	switch_threadattr_detach_set(thd_attr, 1);
 	switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
@@ -529,178 +532,190 @@ static void launch_write_stream_thread(shout_context_t *context)
 static switch_status_t shout_file_open(switch_file_handle_t *handle, char *path)
 {
 	shout_context_t *context;
-    char *host, *file;
-    char *username, *password, *port;
-    char *err = NULL;
-    int portno = 0;
+	char *host, *file;
+	char *username, *password, *port;
+	char *err = NULL;
+	int portno = 0;
 
 	if ((context = switch_core_alloc(handle->memory_pool, sizeof(*context))) == 0) {
 		return SWITCH_STATUS_MEMERR;
 	}
 
-    if (!handle->samplerate) {
-        handle->samplerate = 8000;
-    }
+	if (!handle->samplerate) {
+		handle->samplerate = 8000;
+	}
 
-    context->memory_pool = handle->memory_pool;
-    context->samplerate = handle->samplerate;
-    
-    if (switch_test_flag(handle, SWITCH_FILE_FLAG_READ)) {
-        if (switch_buffer_create_dynamic(&context->audio_buffer, MY_BLOCK_SIZE, MY_BUF_LEN, 0) != SWITCH_STATUS_SUCCESS) {
-            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Memory Error!\n");
-            goto error;
-        }
-        
-        switch_mutex_init(&context->audio_mutex, SWITCH_MUTEX_NESTED, context->memory_pool);
-        InitMP3(&context->mp, OUTSCALE, context->samplerate);
-        if (handle->handler) {
-            context->stream_url = switch_core_sprintf(context->memory_pool, "http://%s", path);
-            launch_read_stream_thread(context);
-        } else {
-            if (switch_file_open(&context->fd, path, SWITCH_FOPEN_READ, 
-                                 SWITCH_FPROT_UREAD|SWITCH_FPROT_UWRITE, handle->memory_pool) != SWITCH_STATUS_SUCCESS) {
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error opening %s\n", path);
-                goto error;
-            }
-        }
-    } else if (switch_test_flag(handle, SWITCH_FILE_FLAG_WRITE)) {
-        if (!(context->gfp = lame_init())) {
-            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not allocate lame\n");
-            goto error;
-        }
+	context->memory_pool = handle->memory_pool;
+	context->samplerate = handle->samplerate;
 
-        lame_set_num_channels(context->gfp, handle->channels);
-        lame_set_in_samplerate(context->gfp, handle->samplerate);
-        lame_set_brate(context->gfp, 64);
-        lame_set_mode(context->gfp, 3);
-        lame_set_quality(context->gfp, 2);   /* 2=high  5 = medium  7=low */
-        
-        lame_set_errorf(context->gfp, log_error);
-        lame_set_debugf(context->gfp, log_debug);
-        lame_set_msgf(context->gfp, log_msg);
-        
-        lame_init_params(context->gfp);
-        lame_print_config(context->gfp);
-        
-        if (handle->handler) {
-            if (switch_buffer_create_dynamic(&context->audio_buffer, MY_BLOCK_SIZE, MY_BUF_LEN, 0) != SWITCH_STATUS_SUCCESS) {
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Memory Error!\n");
-                goto error;
-            }
-            switch_mutex_init(&context->audio_mutex, SWITCH_MUTEX_NESTED, context->memory_pool);
-            lame_set_bWriteVbrTag(context->gfp, 0);
-            lame_mp3_tags_fid(context->gfp, NULL);
-            
-            username = switch_core_strdup(handle->memory_pool, path);
-            if (!(password = strchr(username, ':'))) {
-                err = "invalid url";
-                goto error;
-            }
-            *password++ = '\0';
-        
-            if (!(host = strchr(password, '@'))) {
-                err = "invalid url";
-                goto error;
-            }
-            *host++ = '\0';
-    
-            if ((file = strchr(host, '/'))) {
-                *file++ = '\0';
-            } else {
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid URL: %s\n", path);
-                goto error;
-            }
-            
-            if ((port = strchr(host, ':'))) {
-                *port++ = '\0';
-                if (port) {
-                    portno = atoi(port);
-                }
-            }
+	if (switch_test_flag(handle, SWITCH_FILE_FLAG_READ)) {
+		if (switch_buffer_create_dynamic(&context->audio_buffer, MY_BLOCK_SIZE, MY_BUF_LEN, 0) != SWITCH_STATUS_SUCCESS) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Memory Error!\n");
+			goto error;
+		}
 
-            if (!portno) {
-                portno = 8000;
-            }
+		switch_mutex_init(&context->audio_mutex, SWITCH_MUTEX_NESTED, context->memory_pool);
+		InitMP3(&context->mp, OUTSCALE, context->samplerate);
+		if (handle->handler) {
+			context->stream_url = switch_core_sprintf(context->memory_pool, "http://%s", path);
+			launch_read_stream_thread(context);
+		} else {
+			if (switch_file_open(&context->fd, path, SWITCH_FOPEN_READ,
+								 SWITCH_FPROT_UREAD | SWITCH_FPROT_UWRITE,
+								 handle->memory_pool) != SWITCH_STATUS_SUCCESS) {
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error opening %s\n", path);
+				goto error;
+			}
+		}
+	} else if (switch_test_flag(handle, SWITCH_FILE_FLAG_WRITE)) {
+		if (!(context->gfp = lame_init())) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not allocate lame\n");
+			goto error;
+		}
 
-            if (!(context->shout = shout_new())) {
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not allocate shout_t\n");
-                goto error;
-            }
-            
-            if (shout_set_host(context->shout, host) != SHOUTERR_SUCCESS) {
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting hostname: %s\n", shout_get_error(context->shout));
-                goto error;
-            }
+		lame_set_num_channels(context->gfp, handle->channels);
+		lame_set_in_samplerate(context->gfp, handle->samplerate);
+		lame_set_brate(context->gfp, 64);
+		lame_set_mode(context->gfp, 3);
+		lame_set_quality(context->gfp, 2);	/* 2=high  5 = medium  7=low */
 
-            if (shout_set_protocol(context->shout, SHOUT_PROTOCOL_HTTP) != SHOUTERR_SUCCESS) {
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting protocol: %s\n", shout_get_error(context->shout));
-                goto error;
-            }
-    
-            if (shout_set_port(context->shout, portno) != SHOUTERR_SUCCESS) {
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting port: %s\n", shout_get_error(context->shout));
-                goto error;
-            }
+		lame_set_errorf(context->gfp, log_error);
+		lame_set_debugf(context->gfp, log_debug);
+		lame_set_msgf(context->gfp, log_msg);
 
-            if (shout_set_password(context->shout, password) != SHOUTERR_SUCCESS) {
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting password: %s\n", shout_get_error(context->shout));
-                goto error;
-            }
+		lame_init_params(context->gfp);
+		lame_print_config(context->gfp);
 
-            if (shout_set_mount(context->shout, file) != SHOUTERR_SUCCESS) {
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting mount: %s\n", shout_get_error(context->shout));
-                goto error;
-            }
+		if (handle->handler) {
+			if (switch_buffer_create_dynamic(&context->audio_buffer, MY_BLOCK_SIZE, MY_BUF_LEN, 0) !=
+				SWITCH_STATUS_SUCCESS) {
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Memory Error!\n");
+				goto error;
+			}
+			switch_mutex_init(&context->audio_mutex, SWITCH_MUTEX_NESTED, context->memory_pool);
+			lame_set_bWriteVbrTag(context->gfp, 0);
+			lame_mp3_tags_fid(context->gfp, NULL);
 
-            if (shout_set_user(context->shout, username) != SHOUTERR_SUCCESS) {
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting user: %s\n", shout_get_error(context->shout));
-                goto error;
-            }
+			username = switch_core_strdup(handle->memory_pool, path);
+			if (!(password = strchr(username, ':'))) {
+				err = "invalid url";
+				goto error;
+			}
+			*password++ = '\0';
 
-            if (shout_set_url(context->shout, "http://www.freeswitch.org") != SHOUTERR_SUCCESS) {
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting name: %s\n", shout_get_error(context->shout));
-                goto error;
-            }
+			if (!(host = strchr(password, '@'))) {
+				err = "invalid url";
+				goto error;
+			}
+			*host++ = '\0';
 
-            if (shout_set_description(context->shout, "FreeSWITCH mod_shout Broadcasting Module") != SHOUTERR_SUCCESS) {
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting name: %s\n", shout_get_error(context->shout));
-                goto error;
-            }
+			if ((file = strchr(host, '/'))) {
+				*file++ = '\0';
+			} else {
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid URL: %s\n", path);
+				goto error;
+			}
 
-            if (shout_set_audio_info(context->shout, "bitrate", "64000") != SHOUTERR_SUCCESS) {
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting user: %s\n", shout_get_error(context->shout));
-                goto error;
-            }
+			if ((port = strchr(host, ':'))) {
+				*port++ = '\0';
+				if (port) {
+					portno = atoi(port);
+				}
+			}
 
-            if (shout_set_format(context->shout, SHOUT_FORMAT_MP3) != SHOUTERR_SUCCESS) {
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting user: %s\n", shout_get_error(context->shout));
-                goto error;
-            }
+			if (!portno) {
+				portno = 8000;
+			}
 
-        } else {
-            handle->seekable = 1;
-            /* lame being lame and all has FILE * coded into it's API for some functions so we gotta use it */
-            if (!(context->fp = fopen(path, "wb+"))) {
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error opening %s\n", path);
-                return SWITCH_STATUS_GENERR;
-            }
-        }
-    }
+			if (!(context->shout = shout_new())) {
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not allocate shout_t\n");
+				goto error;
+			}
 
-    handle->samples = 0;
-    handle->format = 0;
-    handle->sections = 0;
-    handle->speed = 0;
+			if (shout_set_host(context->shout, host) != SHOUTERR_SUCCESS) {
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting hostname: %s\n",
+								  shout_get_error(context->shout));
+				goto error;
+			}
+
+			if (shout_set_protocol(context->shout, SHOUT_PROTOCOL_HTTP) != SHOUTERR_SUCCESS) {
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting protocol: %s\n",
+								  shout_get_error(context->shout));
+				goto error;
+			}
+
+			if (shout_set_port(context->shout, portno) != SHOUTERR_SUCCESS) {
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting port: %s\n",
+								  shout_get_error(context->shout));
+				goto error;
+			}
+
+			if (shout_set_password(context->shout, password) != SHOUTERR_SUCCESS) {
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting password: %s\n",
+								  shout_get_error(context->shout));
+				goto error;
+			}
+
+			if (shout_set_mount(context->shout, file) != SHOUTERR_SUCCESS) {
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting mount: %s\n",
+								  shout_get_error(context->shout));
+				goto error;
+			}
+
+			if (shout_set_user(context->shout, username) != SHOUTERR_SUCCESS) {
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting user: %s\n",
+								  shout_get_error(context->shout));
+				goto error;
+			}
+
+			if (shout_set_url(context->shout, "http://www.freeswitch.org") != SHOUTERR_SUCCESS) {
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting name: %s\n",
+								  shout_get_error(context->shout));
+				goto error;
+			}
+
+			if (shout_set_description(context->shout, "FreeSWITCH mod_shout Broadcasting Module") != SHOUTERR_SUCCESS) {
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting name: %s\n",
+								  shout_get_error(context->shout));
+				goto error;
+			}
+
+			if (shout_set_audio_info(context->shout, "bitrate", "64000") != SHOUTERR_SUCCESS) {
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting user: %s\n",
+								  shout_get_error(context->shout));
+				goto error;
+			}
+
+			if (shout_set_format(context->shout, SHOUT_FORMAT_MP3) != SHOUTERR_SUCCESS) {
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting user: %s\n",
+								  shout_get_error(context->shout));
+				goto error;
+			}
+
+		} else {
+			handle->seekable = 1;
+			/* lame being lame and all has FILE * coded into it's API for some functions so we gotta use it */
+			if (!(context->fp = fopen(path, "wb+"))) {
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error opening %s\n", path);
+				return SWITCH_STATUS_GENERR;
+			}
+		}
+	}
+
+	handle->samples = 0;
+	handle->format = 0;
+	handle->sections = 0;
+	handle->speed = 0;
 	handle->private_info = context;
-    
+
 	return SWITCH_STATUS_SUCCESS;
-    
- error:
-    if (err) {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error: %s\n", err);
-    }
-    free_context(context);
-    return SWITCH_STATUS_GENERR;
+
+  error:
+	if (err) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error: %s\n", err);
+	}
+	free_context(context);
+	return SWITCH_STATUS_GENERR;
 
 }
 
@@ -708,66 +723,67 @@ static switch_status_t shout_file_close(switch_file_handle_t *handle)
 {
 	shout_context_t *context = handle->private_info;
 
-    free_context(context);
+	free_context(context);
 
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status_t shout_file_seek(switch_file_handle_t *handle, unsigned int *cur_sample, int64_t samples, int whence)
+static switch_status_t shout_file_seek(switch_file_handle_t *handle, unsigned int *cur_sample, int64_t samples,
+									   int whence)
 {
 	shout_context_t *context = handle->private_info;
 
-    if (handle->handler) {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot seek on a stream.\n");
-        return SWITCH_STATUS_FALSE;
-    } else {
-        switch_mutex_lock(context->audio_mutex);
-        if (context->audio_buffer) {
-            if (context->fd) {
-                switch_file_seek(context->fd, whence, &samples);
-            } else if (context->fp) {
-                *cur_sample = fseek(context->fp, *cur_sample, whence);
-            }
-            switch_buffer_zero(context->audio_buffer);
-        } else {
-            context->err++;
-        }
-        switch_mutex_unlock(context->audio_mutex);
-        return SWITCH_STATUS_SUCCESS;
-    }
+	if (handle->handler) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot seek on a stream.\n");
+		return SWITCH_STATUS_FALSE;
+	} else {
+		switch_mutex_lock(context->audio_mutex);
+		if (context->audio_buffer) {
+			if (context->fd) {
+				switch_file_seek(context->fd, whence, &samples);
+			} else if (context->fp) {
+				*cur_sample = fseek(context->fp, *cur_sample, whence);
+			}
+			switch_buffer_zero(context->audio_buffer);
+		} else {
+			context->err++;
+		}
+		switch_mutex_unlock(context->audio_mutex);
+		return SWITCH_STATUS_SUCCESS;
+	}
 }
 
 static switch_status_t shout_file_read(switch_file_handle_t *handle, void *data, size_t *len)
 {
 	shout_context_t *context = handle->private_info;
-    size_t rb = 0, bytes = *len * sizeof(int16_t);
+	size_t rb = 0, bytes = *len * sizeof(int16_t);
 
-    *len = 0;
+	*len = 0;
 
-    if (context->fd) {
-        rb = decode_fd(context, data, bytes);
-    } else {
-        switch_mutex_lock(context->audio_mutex);
-        if (context->audio_buffer) {
-            rb = switch_buffer_read(context->audio_buffer, data, bytes);
-        } else {
-            switch_mutex_lock(context->audio_mutex);
-            context->err++;
-            switch_mutex_unlock(context->audio_mutex);
-        }
-        switch_mutex_unlock(context->audio_mutex);
-    }
+	if (context->fd) {
+		rb = decode_fd(context, data, bytes);
+	} else {
+		switch_mutex_lock(context->audio_mutex);
+		if (context->audio_buffer) {
+			rb = switch_buffer_read(context->audio_buffer, data, bytes);
+		} else {
+			switch_mutex_lock(context->audio_mutex);
+			context->err++;
+			switch_mutex_unlock(context->audio_mutex);
+		}
+		switch_mutex_unlock(context->audio_mutex);
+	}
 
-    if (context->err) {
-        return SWITCH_STATUS_FALSE;
-    }
+	if (context->err) {
+		return SWITCH_STATUS_FALSE;
+	}
 
-    if (rb) {
-        *len = rb / sizeof(int16_t);
-    } else {
-        memset(data, 255, bytes);
-        *len = bytes / sizeof(int16_t);
-    }
+	if (rb) {
+		*len = rb / sizeof(int16_t);
+	} else {
+		memset(data, 255, bytes);
+		*len = bytes / sizeof(int16_t);
+	}
 
 	return SWITCH_STATUS_SUCCESS;
 }
@@ -775,75 +791,79 @@ static switch_status_t shout_file_read(switch_file_handle_t *handle, void *data,
 static switch_status_t shout_file_write(switch_file_handle_t *handle, void *data, size_t *len)
 {
 	shout_context_t *context = handle->private_info;
-    unsigned char mp3buf[2048] = "";
-    int rlen;
-    int16_t *audio = data;
-    int nsamples = *len;
-    
+	unsigned char mp3buf[2048] = "";
+	int rlen;
+	int16_t *audio = data;
+	int nsamples = *len;
 
-    if (context->shout && !context->shout_init) {
-        context->shout_init++;
-        if (shout_open(context->shout) != SHOUTERR_SUCCESS) {
-            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error opening stream: %s\n", shout_get_error(context->shout));
-            context->err++;
-            return SWITCH_STATUS_FALSE;
-        }
-        launch_write_stream_thread(context);
-    }
 
-    if (handle->handler) {
-        switch_mutex_lock(context->audio_mutex);
-        if (context->audio_buffer) {
-            if (!switch_buffer_write(context->audio_buffer, data, nsamples * sizeof(int16_t))) {
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Buffer error\n");
-                context->err++;
-            }
-        } else {
-            context->err++;
-        }
-        switch_mutex_unlock(context->audio_mutex);
-        if (context->err) {
-            return SWITCH_STATUS_FALSE;
-        }
-    } else {
-        if ((rlen = lame_encode_buffer(context->gfp, audio, NULL, nsamples, mp3buf, sizeof(mp3buf))) < 0) {
-            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "MP3 encode error %d!\n", rlen);
-            return SWITCH_STATUS_FALSE;
-        }
-        if (rlen) {
-            if (fwrite(mp3buf, 1, rlen, context->fp) < 0) {
-                return SWITCH_STATUS_FALSE;
-            }
-        }
-    }
+	if (context->shout && !context->shout_init) {
+		context->shout_init++;
+		if (shout_open(context->shout) != SHOUTERR_SUCCESS) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error opening stream: %s\n",
+							  shout_get_error(context->shout));
+			context->err++;
+			return SWITCH_STATUS_FALSE;
+		}
+		launch_write_stream_thread(context);
+	}
 
-    return SWITCH_STATUS_SUCCESS;
+	if (handle->handler) {
+		switch_mutex_lock(context->audio_mutex);
+		if (context->audio_buffer) {
+			if (!switch_buffer_write(context->audio_buffer, data, nsamples * sizeof(int16_t))) {
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Buffer error\n");
+				context->err++;
+			}
+		} else {
+			context->err++;
+		}
+		switch_mutex_unlock(context->audio_mutex);
+		if (context->err) {
+			return SWITCH_STATUS_FALSE;
+		}
+	} else {
+		if ((rlen = lame_encode_buffer(context->gfp, audio, NULL, nsamples, mp3buf, sizeof(mp3buf))) < 0) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "MP3 encode error %d!\n", rlen);
+			return SWITCH_STATUS_FALSE;
+		}
+		if (rlen) {
+			if (fwrite(mp3buf, 1, rlen, context->fp) < 0) {
+				return SWITCH_STATUS_FALSE;
+			}
+		}
+	}
+
+	return SWITCH_STATUS_SUCCESS;
 }
 
 static switch_status_t shout_file_set_string(switch_file_handle_t *handle, switch_audio_col_t col, const char *string)
 {
 	shout_context_t *context = handle->private_info;
 
-    switch(col) {
-    case SWITCH_AUDIO_COL_STR_TITLE:
-        if (shout_set_name(context->shout, string) != SHOUTERR_SUCCESS) {
-            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting name: %s\n", shout_get_error(context->shout));
-        }
-        break;
-    case SWITCH_AUDIO_COL_STR_COMMENT:
-        if (shout_set_url(context->shout, string) != SHOUTERR_SUCCESS) {
-            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting name: %s\n", shout_get_error(context->shout));
-        }
-        break;
-    case SWITCH_AUDIO_COL_STR_ARTIST:
-        if (shout_set_description(context->shout, string) != SHOUTERR_SUCCESS) {
-            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting name: %s\n", shout_get_error(context->shout));
-        }
-        break;
-    default:
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Value Ignored\n");
-        break;
-    }
+	switch (col) {
+	case SWITCH_AUDIO_COL_STR_TITLE:
+		if (shout_set_name(context->shout, string) != SHOUTERR_SUCCESS) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting name: %s\n",
+							  shout_get_error(context->shout));
+		}
+		break;
+	case SWITCH_AUDIO_COL_STR_COMMENT:
+		if (shout_set_url(context->shout, string) != SHOUTERR_SUCCESS) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting name: %s\n",
+							  shout_get_error(context->shout));
+		}
+		break;
+	case SWITCH_AUDIO_COL_STR_ARTIST:
+		if (shout_set_description(context->shout, string) != SHOUTERR_SUCCESS) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting name: %s\n",
+							  shout_get_error(context->shout));
+		}
+		break;
+	default:
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Value Ignored\n");
+		break;
+	}
 	return SWITCH_STATUS_FALSE;
 }
 
@@ -878,19 +898,20 @@ static switch_loadable_module_interface_t shout_module_interface = {
 	/*.directory_interface */ NULL
 };
 
-SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
+													   char *filename)
 {
-    supported_formats[0] = "shout";
-    supported_formats[1] = "mp3";
+	supported_formats[0] = "shout";
+	supported_formats[1] = "mp3";
 	shout_file_interface.extens = supported_formats;
 
-    curl_global_init(CURL_GLOBAL_ALL);
+	curl_global_init(CURL_GLOBAL_ALL);
 
 	/* connect my internal structure to the blank pointer passed to me */
 	*module_interface = &shout_module_interface;
 
 	shout_init();
-    InitMP3Constants();
+	InitMP3Constants();
 
 	/* indicate that the module should continue to be loaded */
 	return SWITCH_STATUS_SUCCESS;
diff --git a/src/mod/formats/mod_shout/mpg123.h b/src/mod/formats/mod_shout/mpg123.h
index e607cc2777..4a0a8ef935 100644
--- a/src/mod/formats/mod_shout/mpg123.h
+++ b/src/mod/formats/mod_shout/mpg123.h
@@ -58,69 +58,67 @@
 #define AUSHIFT (3)
 
 struct frame {
-    int stereo;
-    int jsbound;
-    int single;
-    int lsf;
-    int mpeg25;
-    int header_change;
-    int lay;
-    int error_protection;
-    int bitrate_index;
-    int sampling_frequency;
-    int padding;
-    int extension;
-    int mode;
-    int mode_ext;
-    int copyright;
-    int original;
-    int emphasis;
-    int framesize; /* computed framesize */
+	int stereo;
+	int jsbound;
+	int single;
+	int lsf;
+	int mpeg25;
+	int header_change;
+	int lay;
+	int error_protection;
+	int bitrate_index;
+	int sampling_frequency;
+	int padding;
+	int extension;
+	int mode;
+	int mode_ext;
+	int copyright;
+	int original;
+	int emphasis;
+	int framesize;				/* computed framesize */
 };
 
 struct parameter {
-	int quiet;	/* shut up! */
-	int tryresync;  /* resync stream after error */
-	int verbose;    /* verbose level */
+	int quiet;					/* shut up! */
+	int tryresync;				/* resync stream after error */
+	int verbose;				/* verbose level */
 	int checkrange;
 };
 
-extern int decode_header(struct frame *fr,unsigned long newhead);
+extern int decode_header(struct frame *fr, unsigned long newhead);
 
 
 
 struct gr_info_s {
-      int scfsi;
-      unsigned part2_3_length;
-      unsigned big_values;
-      unsigned scalefac_compress;
-      unsigned block_type;
-      unsigned mixed_block_flag;
-      unsigned table_select[3];
-      unsigned subblock_gain[3];
-      unsigned maxband[3];
-      unsigned maxbandl;
-      unsigned maxb;
-      unsigned region1start;
-      unsigned region2start;
-      unsigned preflag;
-      unsigned scalefac_scale;
-      unsigned count1table_select;
-      real *full_gain[3];
-      real *pow2gain;
+	int scfsi;
+	unsigned part2_3_length;
+	unsigned big_values;
+	unsigned scalefac_compress;
+	unsigned block_type;
+	unsigned mixed_block_flag;
+	unsigned table_select[3];
+	unsigned subblock_gain[3];
+	unsigned maxband[3];
+	unsigned maxbandl;
+	unsigned maxb;
+	unsigned region1start;
+	unsigned region2start;
+	unsigned preflag;
+	unsigned scalefac_scale;
+	unsigned count1table_select;
+	real *full_gain[3];
+	real *pow2gain;
 };
 
-struct III_sideinfo
-{
-  unsigned main_data_begin;
-  unsigned private_bits;
-  struct {
-    struct gr_info_s gr[2];
-  } ch[2];
+struct III_sideinfo {
+	unsigned main_data_begin;
+	unsigned private_bits;
+	struct {
+		struct gr_info_s gr[2];
+	} ch[2];
 };
 
-struct pcm_workingsample
-{
+struct pcm_workingsample {
 	int bitindex;
 	unsigned char *wordpointer;
 };
@@ -129,4 +127,3 @@ struct pcm_workingsample
 extern long freqs[9];
 extern struct parameter param;
 extern real *pnts[5];
-
diff --git a/src/mod/formats/mod_shout/mpglib.h b/src/mod/formats/mod_shout/mpglib.h
index 031d33e245..3ad9283eb6 100644
--- a/src/mod/formats/mod_shout/mpglib.h
+++ b/src/mod/formats/mod_shout/mpglib.h
@@ -5,11 +5,11 @@
 #endif
 
 struct buf {
-        unsigned char *pnt;
+	unsigned char *pnt;
 	long size;
 	long pos;
-        struct buf *next;
-        struct buf *prev;
+	struct buf *next;
+	struct buf *prev;
 };
 
 struct framebuf {
@@ -20,27 +20,27 @@ struct framebuf {
 };
 
 struct mpstr {
-	struct buf *head,*tail;
+	struct buf *head, *tail;
 	int bsize;
 	int framesize;
-        int fsizeold;
+	int fsizeold;
 	struct frame fr;
-        unsigned char bsspace[2][MAXFRAMESIZE+512]; /* MAXFRAMESIZE */
-	real hybrid_block[2][2][SBLIMIT*SSLIMIT];
+	unsigned char bsspace[2][MAXFRAMESIZE + 512];	/* MAXFRAMESIZE */
+	real hybrid_block[2][2][SBLIMIT * SSLIMIT];
 	int hybrid_blc[2];
 	unsigned long header;
 	int bsnum;
 	real synth_buffs[2][2][0x110];
-        int  synth_bo;
-	long outscale; /* volume control default value 32768 */
-	long outsamplerate; /* raw output rate default same as mp3 sample rate*/
-	struct pcm_workingsample worksample; /* keep the state of the working sample for threads */
-	int initmp3; /* flag for first initialisation */
-	int longLimit[9][23]; /*sample limits re setting volume */
+	int synth_bo;
+	long outscale;				/* volume control default value 32768 */
+	long outsamplerate;			/* raw output rate default same as mp3 sample rate */
+	struct pcm_workingsample worksample;	/* keep the state of the working sample for threads */
+	int initmp3;				/* flag for first initialisation */
+	int longLimit[9][23];		/*sample limits re setting volume */
 	int shortLimit[9][14];
-	real decwin[512+32]; /* scale table */
-	
-	};
+	real decwin[512 + 32];		/* scale table */
+
+};
 
 #define BOOL int
 
@@ -51,30 +51,28 @@ struct mpstr {
 
 void InitMP3Constants(void);
 BOOL InitMP3(struct mpstr *mp, long outscale, int samplerate);
-int decodeMP3(struct mpstr *mp,char *inmemory,int inmemsize,
-     char *outmemory,int outmemsize,int *done);
+int decodeMP3(struct mpstr *mp, char *inmemory, int inmemsize, char *outmemory, int outmemsize, int *done);
 void ExitMP3(struct mpstr *mp);
 
-extern int synth_ntom_set_step(long,long);
-extern int synth_ntom(struct mpstr *mp, real *bandPtr,int channel,unsigned char *out,int *pnt);
-extern int synth_ntom_mono (struct mpstr *mp, real *bandPtr,unsigned char *samples,int *pnt);
-extern int synth_ntom_8bit (real *,int,unsigned char *,int *);
-extern int synth_ntom_mono2stereo (real *,unsigned char *,int *);
-extern int synth_ntom_8bit_mono (real *,unsigned char *,int *);
-extern int synth_ntom_8bit_mono2stereo (real *,unsigned char *,int *);
+extern int synth_ntom_set_step(long, long);
+extern int synth_ntom(struct mpstr *mp, real * bandPtr, int channel, unsigned char *out, int *pnt);
+extern int synth_ntom_mono(struct mpstr *mp, real * bandPtr, unsigned char *samples, int *pnt);
+extern int synth_ntom_8bit(real *, int, unsigned char *, int *);
+extern int synth_ntom_mono2stereo(real *, unsigned char *, int *);
+extern int synth_ntom_8bit_mono(real *, unsigned char *, int *);
+extern int synth_ntom_8bit_mono2stereo(real *, unsigned char *, int *);
 
 extern void init_layer3_sample_limits(struct mpstr *mp, int down_sample_sblimit);
 extern void init_layer3_const(void);
-extern int do_layer3(struct mpstr *mp,unsigned char *,int *);
+extern int do_layer3(struct mpstr *mp, unsigned char *, int *);
 
 extern void make_decode_tables_scale(struct mpstr *mp, long scaleval);
 extern void make_decode_tables_const(void);
 extern void make_conv16to8_table(int);
 
-extern void dct64(real *,real *,real *);
+extern void dct64(real *, real *, real *);
 
-extern unsigned int   get1bit(struct mpstr *mp);
-extern unsigned int   getbits(struct mpstr *mp, int);
-extern unsigned int   getbits_fast(struct mpstr *mp, int);
+extern unsigned int get1bit(struct mpstr *mp);
+extern unsigned int getbits(struct mpstr *mp, int);
+extern unsigned int getbits_fast(struct mpstr *mp, int);
 extern int set_pointer(struct mpstr *mp, long backstep);
-
diff --git a/src/mod/formats/mod_shout/tabinit.c b/src/mod/formats/mod_shout/tabinit.c
index d3e49f500a..381d9a20ad 100644
--- a/src/mod/formats/mod_shout/tabinit.c
+++ b/src/mod/formats/mod_shout/tabinit.c
@@ -4,47 +4,48 @@
 #include "mpg123.h"
 #include "mpglib.h"
 
-static real cos64[16],cos32[8],cos16[4],cos8[2],cos4[1];
-real *pnts[] = { cos64,cos32,cos16,cos8,cos4 };
+static real cos64[16], cos32[8], cos16[4], cos8[2], cos4[1];
+real *pnts[] = { cos64, cos32, cos16, cos8, cos4 };
 
 static long intwinbase[] = {
-     0,    -1,    -1,    -1,    -1,    -1,    -1,    -2,    -2,    -2,
-    -2,    -3,    -3,    -4,    -4,    -5,    -5,    -6,    -7,    -7,
-    -8,    -9,   -10,   -11,   -13,   -14,   -16,   -17,   -19,   -21,
-   -24,   -26,   -29,   -31,   -35,   -38,   -41,   -45,   -49,   -53,
-   -58,   -63,   -68,   -73,   -79,   -85,   -91,   -97,  -104,  -111,
-  -117,  -125,  -132,  -139,  -147,  -154,  -161,  -169,  -176,  -183,
-  -190,  -196,  -202,  -208,  -213,  -218,  -222,  -225,  -227,  -228,
-  -228,  -227,  -224,  -221,  -215,  -208,  -200,  -189,  -177,  -163,
-  -146,  -127,  -106,   -83,   -57,   -29,     2,    36,    72,   111,
-   153,   197,   244,   294,   347,   401,   459,   519,   581,   645,
-   711,   779,   848,   919,   991,  1064,  1137,  1210,  1283,  1356,
-  1428,  1498,  1567,  1634,  1698,  1759,  1817,  1870,  1919,  1962,
-  2001,  2032,  2057,  2075,  2085,  2087,  2080,  2063,  2037,  2000,
-  1952,  1893,  1822,  1739,  1644,  1535,  1414,  1280,  1131,   970,
-   794,   605,   402,   185,   -45,  -288,  -545,  -814, -1095, -1388,
- -1692, -2006, -2330, -2663, -3004, -3351, -3705, -4063, -4425, -4788,
- -5153, -5517, -5879, -6237, -6589, -6935, -7271, -7597, -7910, -8209,
- -8491, -8755, -8998, -9219, -9416, -9585, -9727, -9838, -9916, -9959,
- -9966, -9935, -9863, -9750, -9592, -9389, -9139, -8840, -8492, -8092,
- -7640, -7134, -6574, -5959, -5288, -4561, -3776, -2935, -2037, -1082,
-   -70,   998,  2122,  3300,  4533,  5818,  7154,  8540,  9975, 11455,
- 12980, 14548, 16155, 17799, 19478, 21189, 22929, 24694, 26482, 28289,
- 30112, 31947, 33791, 35640, 37489, 39336, 41176, 43006, 44821, 46617,
- 48390, 50137, 51853, 53534, 55178, 56778, 58333, 59838, 61289, 62684,
- 64019, 65290, 66494, 67629, 68692, 69679, 70590, 71420, 72169, 72835,
- 73415, 73908, 74313, 74630, 74856, 74992, 75038 };
+	0, -1, -1, -1, -1, -1, -1, -2, -2, -2,
+	-2, -3, -3, -4, -4, -5, -5, -6, -7, -7,
+	-8, -9, -10, -11, -13, -14, -16, -17, -19, -21,
+	-24, -26, -29, -31, -35, -38, -41, -45, -49, -53,
+	-58, -63, -68, -73, -79, -85, -91, -97, -104, -111,
+	-117, -125, -132, -139, -147, -154, -161, -169, -176, -183,
+	-190, -196, -202, -208, -213, -218, -222, -225, -227, -228,
+	-228, -227, -224, -221, -215, -208, -200, -189, -177, -163,
+	-146, -127, -106, -83, -57, -29, 2, 36, 72, 111,
+	153, 197, 244, 294, 347, 401, 459, 519, 581, 645,
+	711, 779, 848, 919, 991, 1064, 1137, 1210, 1283, 1356,
+	1428, 1498, 1567, 1634, 1698, 1759, 1817, 1870, 1919, 1962,
+	2001, 2032, 2057, 2075, 2085, 2087, 2080, 2063, 2037, 2000,
+	1952, 1893, 1822, 1739, 1644, 1535, 1414, 1280, 1131, 970,
+	794, 605, 402, 185, -45, -288, -545, -814, -1095, -1388,
+	-1692, -2006, -2330, -2663, -3004, -3351, -3705, -4063, -4425, -4788,
+	-5153, -5517, -5879, -6237, -6589, -6935, -7271, -7597, -7910, -8209,
+	-8491, -8755, -8998, -9219, -9416, -9585, -9727, -9838, -9916, -9959,
+	-9966, -9935, -9863, -9750, -9592, -9389, -9139, -8840, -8492, -8092,
+	-7640, -7134, -6574, -5959, -5288, -4561, -3776, -2935, -2037, -1082,
+	-70, 998, 2122, 3300, 4533, 5818, 7154, 8540, 9975, 11455,
+	12980, 14548, 16155, 17799, 19478, 21189, 22929, 24694, 26482, 28289,
+	30112, 31947, 33791, 35640, 37489, 39336, 41176, 43006, 44821, 46617,
+	48390, 50137, 51853, 53534, 55178, 56778, 58333, 59838, 61289, 62684,
+	64019, 65290, 66494, 67629, 68692, 69679, 70590, 71420, 72169, 72835,
+	73415, 73908, 74313, 74630, 74856, 74992, 75038
+};
 
 void make_decode_tables_const(void)
 {
-	int i,k,kr,divv;
+	int i, k, kr, divv;
 	real *costab;
-		
-	for(i=0;i<5;i++)
-	{
-		kr=0x10>>i; divv=0x40>>i;
+
+	for (i = 0; i < 5; i++) {
+		kr = 0x10 >> i;
+		divv = 0x40 >> i;
 		costab = pnts[i];
-		for(k=0;kdecwin;
-  scaleval = -scaleval;
-  for(i=0,j=0;i<256;i++,j++,table+=32)
-  {
-    if(table < (mp->decwin)+512+16)
-      table[16] = table[0] = (double) intwinbase[j] / 65536.0 * (double) scaleval;
-    if(i % 32 == 31)
-      table -= 1023;
-    if(i % 64 == 63)
-      scaleval = - scaleval;
-  }
+	int i, j;
+	real *table;
 
-  for( /* i=256 */ ;i<512;i++,j--,table+=32)
-  {
-    if(table < (mp->decwin)+512+16)
-      table[16] = table[0] = (double) intwinbase[j] / 65536.0 * (double) scaleval;
-    if(i % 32 == 31)
-      table -= 1023;
-    if(i % 64 == 63)
-      scaleval = - scaleval;
-  }
+	table = mp->decwin;
+	scaleval = -scaleval;
+	for (i = 0, j = 0; i < 256; i++, j++, table += 32) {
+		if (table < (mp->decwin) + 512 + 16)
+			table[16] = table[0] = (double) intwinbase[j] / 65536.0 * (double) scaleval;
+		if (i % 32 == 31)
+			table -= 1023;
+		if (i % 64 == 63)
+			scaleval = -scaleval;
+	}
+
+	for ( /* i=256 */ ; i < 512; i++, j--, table += 32) {
+		if (table < (mp->decwin) + 512 + 16)
+			table[16] = table[0] = (double) intwinbase[j] / 65536.0 * (double) scaleval;
+		if (i % 32 == 31)
+			table -= 1023;
+		if (i % 64 == 63)
+			scaleval = -scaleval;
+	}
 }
-
-
diff --git a/src/mod/formats/mod_sndfile/mod_sndfile.c b/src/mod/formats/mod_sndfile/mod_sndfile.c
index e6c33c3930..84dbc07442 100644
--- a/src/mod/formats/mod_sndfile/mod_sndfile.c
+++ b/src/mod/formats/mod_sndfile/mod_sndfile.c
@@ -87,8 +87,8 @@ static switch_status_t sndfile_file_open(switch_file_handle_t *handle, char *pat
 	map = switch_core_hash_find(globals.format_hash, ext);
 
 	if (mode & SFM_WRITE) {
-		sf_count_t  frames = 0 ;
-		
+		sf_count_t frames = 0;
+
 		context->sfinfo.channels = handle->channels;
 		context->sfinfo.samplerate = handle->samplerate;
 		if (handle->samplerate == 8000 || handle->samplerate == 16000) {
@@ -99,9 +99,9 @@ static switch_status_t sndfile_file_open(switch_file_handle_t *handle, char *pat
 			context->sfinfo.format |= SF_FORMAT_PCM_32;
 		}
 
-        sf_command (context->handle, SFC_FILE_TRUNCATE, &frames, sizeof (frames));
-	} 
-	
+		sf_command(context->handle, SFC_FILE_TRUNCATE, &frames, sizeof(frames));
+	}
+
 	if (map) {
 		context->sfinfo.format |= map->format;
 	}
@@ -134,23 +134,25 @@ static switch_status_t sndfile_file_open(switch_file_handle_t *handle, char *pat
 		context->sfinfo.format = SF_FORMAT_RAW | SF_FORMAT_ALAW;
 		context->sfinfo.channels = 1;
 		context->sfinfo.samplerate = 8000;
-	} 
-	
-	if ((mode & SFM_WRITE) && sf_format_check (&context->sfinfo) == 0) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error : file format is invalid (0x%08X).\n", context->sfinfo.format);
+	}
+
+	if ((mode & SFM_WRITE) && sf_format_check(&context->sfinfo) == 0) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error : file format is invalid (0x%08X).\n",
+						  context->sfinfo.format);
 		return SWITCH_STATUS_GENERR;
 	};
-	
+
 	if ((context->handle = sf_open(path, mode, &context->sfinfo)) == 0) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening File [%s] [%s]\n", path,
-							  sf_strerror(context->handle));
+						  sf_strerror(context->handle));
 		return SWITCH_STATUS_GENERR;
 	}
 
-	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Opening File [%s] %dhz\n", path, context->sfinfo.samplerate);
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Opening File [%s] %dhz\n", path,
+					  context->sfinfo.samplerate);
 	handle->samples = (unsigned int) context->sfinfo.frames;
 	handle->samplerate = context->sfinfo.samplerate;
-	handle->channels = (uint8_t)context->sfinfo.channels;
+	handle->channels = (uint8_t) context->sfinfo.channels;
 	handle->format = context->sfinfo.format;
 	handle->sections = context->sfinfo.sections;
 	handle->seekable = context->sfinfo.seekable;
@@ -169,7 +171,8 @@ static switch_status_t sndfile_file_close(switch_file_handle_t *handle)
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status_t sndfile_file_seek(switch_file_handle_t *handle, unsigned int *cur_sample, int64_t samples, int whence)
+static switch_status_t sndfile_file_seek(switch_file_handle_t *handle, unsigned int *cur_sample, int64_t samples,
+										 int whence)
 {
 	sndfile_context *context = handle->private_info;
 
@@ -233,15 +236,16 @@ static switch_status_t sndfile_file_set_string(switch_file_handle_t *handle, swi
 {
 	sndfile_context *context = handle->private_info;
 
-	return sf_set_string(context->handle, (int)col, string) ? SWITCH_STATUS_FALSE : SWITCH_STATUS_SUCCESS;
+	return sf_set_string(context->handle, (int) col, string) ? SWITCH_STATUS_FALSE : SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status_t sndfile_file_get_string(switch_file_handle_t *handle, switch_audio_col_t col, const char **string)
+static switch_status_t sndfile_file_get_string(switch_file_handle_t *handle, switch_audio_col_t col,
+											   const char **string)
 {
 	sndfile_context *context = handle->private_info;
 	const char *s;
 
-	if ((s = sf_get_string(context->handle, (int)col))) {
+	if ((s = sf_get_string(context->handle, (int) col))) {
 		*string = s;
 		return SWITCH_STATUS_SUCCESS;
 	}
@@ -287,17 +291,18 @@ static switch_status_t setup_formats(void)
 	char *extras[] = { "r8", "r16", "r24", "r32", "gsm", "ul", "al", NULL };
 	int exlen = (sizeof(extras) / sizeof(extras[0]));
 	buffer[0] = 0;
-	
+
 	sf_command(NULL, SFC_GET_LIB_VERSION, buffer, sizeof(buffer));
 	if (strlen(buffer) < 1) {
-		switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR, "Line %d: could not retrieve lib version.\n", __LINE__);
+		switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR, "Line %d: could not retrieve lib version.\n",
+						  __LINE__);
 		return SWITCH_STATUS_FALSE;
 	}
 
 
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "\nLibSndFile Version : %s Supported Formats\n", buffer);
 	switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO,
-						  "================================================================================\n");
+					  "================================================================================\n");
 	sf_command(NULL, SFC_GET_FORMAT_MAJOR_COUNT, &major_count, sizeof(int));
 	sf_command(NULL, SFC_GET_FORMAT_SUBTYPE_COUNT, &subtype_count, sizeof(int));
 
@@ -310,7 +315,8 @@ static switch_status_t setup_formats(void)
 		skip = 0;
 		info.format = m;
 		sf_command(NULL, SFC_GET_FORMAT_MAJOR, &info, sizeof(info));
-		switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, "%s  (extension \"%s\")\n", info.name, info.extension);
+		switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, "%s  (extension \"%s\")\n", info.name,
+						  info.extension);
 		for (x = 0; x < len; x++) {
 			if (supported_formats[x] == info.extension) {
 				skip++;
@@ -327,11 +333,11 @@ static switch_status_t setup_formats(void)
 			map->ext = switch_core_permanent_strdup(info.extension);
 			map->uext = switch_core_permanent_strdup(info.extension);
 			map->format = info.format;
-			for(p = map->ext; *p; p++) {
-				*p = (char)tolower(*p);
+			for (p = map->ext; *p; p++) {
+				*p = (char) tolower(*p);
 			}
-			for(p = map->uext; *p; p++) {
-				*p = (char)toupper(*p);
+			for (p = map->uext; *p; p++) {
+				*p = (char) toupper(*p);
 			}
 			switch_core_hash_insert(globals.format_hash, map->ext, map);
 			switch_core_hash_insert(globals.format_hash, map->uext, map);
@@ -339,16 +345,16 @@ static switch_status_t setup_formats(void)
 		}
 		format = info.format;
 
-		for (s = 0; s < subtype_count; s++) {			
+		for (s = 0; s < subtype_count; s++) {
 			info.format = s;
 			sf_command(NULL, SFC_GET_FORMAT_SUBTYPE, &info, sizeof(info));
 			format = (format & SF_FORMAT_TYPEMASK) | info.format;
 			sfinfo.format = format;
 			/*
-			if (sf_format_check(&sfinfo)) {
-				switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG, "   %s\n", info.name);
-			}
-			*/
+			   if (sf_format_check(&sfinfo)) {
+			   switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG, "   %s\n", info.name);
+			   }
+			 */
 		}
 
 	}
@@ -359,12 +365,13 @@ static switch_status_t setup_formats(void)
 
 
 	switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_NOTICE,
-						  "================================================================================\n");
-	
+					  "================================================================================\n");
+
 	return SWITCH_STATUS_SUCCESS;
 }
 
-SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
+													   char *filename)
 {
 
 	if (switch_core_new_memory_pool(&module_pool) != SWITCH_STATUS_SUCCESS) {
@@ -373,7 +380,7 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_mod
 	}
 
 	switch_core_hash_init(&globals.format_hash, module_pool);
-	
+
 	if (setup_formats() != SWITCH_STATUS_SUCCESS) {
 		return SWITCH_STATUS_FALSE;
 	}
diff --git a/src/mod/languages/mod_mono/mod_mono.c b/src/mod/languages/mod_mono/mod_mono.c
index f57e87ef74..79991034cc 100755
--- a/src/mod/languages/mod_mono/mod_mono.c
+++ b/src/mod/languages/mod_mono/mod_mono.c
@@ -39,16 +39,17 @@
 //#include 
 #include 
 
-#define SWITCH_MONO_MODULES  "mono/" 
+#define SWITCH_MONO_MODULES  "mono/"
 #define SWITCH_MONO_LIBDIR   "lib/"
 #define SWITCH_MONO_ASSEMBLY "FreeSwitch.dll"
 
 /* Module functions */
 switch_status_t mod_mono_load_modules(const char *module_dir);
-MonoClass* mod_mono_find_assembly_class(MonoImage *image);
+MonoClass *mod_mono_find_assembly_class(MonoImage * image);
 
 /* Managed functions */
-void mod_mono_switch_console_printf(switch_text_channel_t channel, char *file, const char *func, int line, char *fmt, char *msg);
+void mod_mono_switch_console_printf(switch_text_channel_t channel, char *file, const char *func, int line, char *fmt,
+									char *msg);
 
 static const char modname[] = "mod_mono";
 static switch_memory_pool_t *mono_pool = NULL;
@@ -61,7 +62,7 @@ static struct {
 typedef struct {
 	MonoAssembly *assembly;
 	MonoClass *class;
-	MonoObject *object;	
+	MonoObject *object;
 } mono_plugin;
 
 static switch_loadable_module_interface_t mono_module_interface = {
@@ -74,7 +75,8 @@ static switch_loadable_module_interface_t mono_module_interface = {
  * This function will initialise the memory pool and plugin hash for this module,
  * it will then initialise a new mono domain.
  */
-SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **interface, char *filename)
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **interface,
+													   char *filename)
 {
 	*interface = &mono_module_interface;
 
@@ -83,23 +85,24 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_mod
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not allocate memory pool\n");
 		return SWITCH_STATUS_FALSE;
 	}
-	
+
 	/* Initialise plugin hash */
 	if (switch_core_hash_init(&globals.plugins, mono_pool) != SWITCH_STATUS_SUCCESS) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not initialise plugins hash\n");
 		return SWITCH_STATUS_FALSE;
-	}		
-	
+	}
+
 	/* Construct the path to the FreeSwitch assembly, then check to make sure it exists */
-	switch_size_t assembly_dir_len  = strlen(SWITCH_GLOBAL_dirs.base_dir) + strlen(SWITCH_MONO_LIBDIR) + 2; /* Account for / and \0 */
+	switch_size_t assembly_dir_len = strlen(SWITCH_GLOBAL_dirs.base_dir) + strlen(SWITCH_MONO_LIBDIR) + 2;	/* Account for / and \0 */
 	switch_size_t assembly_file_len = assembly_dir_len + strlen(SWITCH_MONO_ASSEMBLY);
-	char *assembly_dir  = (char *) switch_core_alloc(mono_pool, assembly_dir_len);
+	char *assembly_dir = (char *) switch_core_alloc(mono_pool, assembly_dir_len);
 	char *assembly_file = (char *) switch_core_alloc(mono_pool, assembly_file_len);
 
 	apr_finfo_t *assembly_finfo = (apr_finfo_t *) switch_core_alloc(mono_pool, sizeof(*assembly_finfo));
 
 	snprintf(assembly_dir, assembly_dir_len, "%s/%s", SWITCH_GLOBAL_dirs.base_dir, SWITCH_MONO_LIBDIR);
-	snprintf(assembly_file, assembly_file_len, "%s/%s%s", SWITCH_GLOBAL_dirs.base_dir, SWITCH_MONO_LIBDIR, SWITCH_MONO_ASSEMBLY);
+	snprintf(assembly_file, assembly_file_len, "%s/%s%s", SWITCH_GLOBAL_dirs.base_dir, SWITCH_MONO_LIBDIR,
+			 SWITCH_MONO_ASSEMBLY);
 
 	if (apr_stat(assembly_finfo, assembly_file, 0, mono_pool) != SWITCH_STATUS_SUCCESS) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Could not find FreeSwitch.NET assembly\n");
@@ -108,22 +111,21 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_mod
 
 	/* Mono wants to know where it will be able to find the FreeSwitch assembly if it's not in the GAC */
 	if (getenv("MONO_PATH") != NULL) {
-		switch_size_t mono_path_len = strlen(getenv("MONO_PATH")) + strlen(assembly_dir) + 2; /* Account for : and \0 */ 
+		switch_size_t mono_path_len = strlen(getenv("MONO_PATH")) + strlen(assembly_dir) + 2;	/* Account for : and \0 */
 		char *mono_path = (char *) switch_core_alloc(mono_pool, mono_path_len);
-	
+
 		snprintf(mono_path, mono_path_len, "%s:%s", getenv("MONO_PATH"), assembly_dir);
 
 		setenv("MONO_PATH", mono_path, 1);
-	}
-	else
+	} else
 		setenv("MONO_PATH", assembly_dir, 1);
 
 	/* Now find where our managed modules are */
-	switch_size_t module_dir_len = strlen(SWITCH_GLOBAL_dirs.mod_dir) + strlen(SWITCH_MONO_MODULES) + 2; /* Account for / and \0 */
+	switch_size_t module_dir_len = strlen(SWITCH_GLOBAL_dirs.mod_dir) + strlen(SWITCH_MONO_MODULES) + 2;	/* Account for / and \0 */
 	char *module_dir = (char *) switch_core_alloc(mono_pool, module_dir_len);
 
 	snprintf(module_dir, module_dir_len, "%s/%s", SWITCH_GLOBAL_dirs.mod_dir, SWITCH_MONO_MODULES);
-	
+
 	/* Initialise the mono domain */
 	if (!(globals.domain = mono_jit_init("freeswitch"))) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error initialising mono runtime\n");
@@ -139,7 +141,7 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_mod
 		return SWITCH_STATUS_FALSE;
 	}
 
-	/* Finally, go through and initialise each plugin before returning SUCCESS */ 
+	/* Finally, go through and initialise each plugin before returning SUCCESS */
 	switch_hash_index_t *p = NULL;
 
 	for (p = switch_hash_first(mono_pool, globals.plugins); p; p = switch_hash_next(p)) {
@@ -150,10 +152,10 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_mod
 
 		switch_hash_this(p, &key, key_length, &value);
 		plugin = (mono_plugin *) value;
-		
+
 		mono_runtime_object_init(plugin->object);
 	}
-	
+
 	return SWITCH_STATUS_SUCCESS;
 }
 
@@ -175,16 +177,16 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_shutdown(void)
 /*
  * This function will load the managed modules
  *
- */ 
+ */
 switch_status_t mod_mono_load_modules(const char *module_dir)
 {
 	apr_finfo_t *module_finfo = (apr_finfo_t *) switch_core_alloc(mono_pool, sizeof(*module_finfo));
-	
+
 	if (apr_stat(module_finfo, module_dir, 0, mono_pool) != SWITCH_STATUS_SUCCESS) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not access module dir!.\n");
 		return SWITCH_STATUS_FALSE;
 	}
-	
+
 	apr_dir_t *module_dir_handle;
 	char *file;
 	size_t len;
@@ -196,22 +198,21 @@ switch_status_t mod_mono_load_modules(const char *module_dir)
 	MonoAssembly *assembly;
 	MonoImage *image;
 	gpointer iter;
-	iter=NULL;
-	mono_plugin *plugin=NULL;
+	iter = NULL;
+	mono_plugin *plugin = NULL;
 
 	if (apr_dir_open(&module_dir_handle, module_dir, mono_pool) != SWITCH_STATUS_SUCCESS)
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Could not open directory: %s\n", module_dir);
 
 	/* Read the modules directory */
-	while (apr_dir_read(&finfo, finfo_flags, module_dir_handle) == SWITCH_STATUS_SUCCESS)
-	{
+	while (apr_dir_read(&finfo, finfo_flags, module_dir_handle) == SWITCH_STATUS_SUCCESS) {
 		assembly = (MonoAssembly *) switch_core_alloc(mono_pool, sizeof(assembly));
 		image = (MonoImage *) switch_core_alloc(mono_pool, sizeof(image));
 		const char *fname = finfo.fname;
 
 		if (finfo.filetype != APR_REG)
 			continue;
-                        
+
 		if (!fname)
 			fname = finfo.name;
 
@@ -222,7 +223,7 @@ switch_status_t mod_mono_load_modules(const char *module_dir)
 			continue;
 
 		len = strlen(module_dir) + strlen(fname) + 2;
-		file = (char *)switch_core_alloc(mono_pool, len);
+		file = (char *) switch_core_alloc(mono_pool, len);
 		snprintf(file, len, "%s%s", module_dir, fname);
 
 		/* Attempt to open the assembly */
@@ -233,53 +234,54 @@ switch_status_t mod_mono_load_modules(const char *module_dir)
 			continue;
 		}
 
-		/* Get the image from assembly */	
+		/* Get the image from assembly */
 		image = mono_assembly_get_image(assembly);
-	
-		plugin = (mono_plugin *)switch_core_alloc(mono_pool, sizeof(*plugin));
+
+		plugin = (mono_plugin *) switch_core_alloc(mono_pool, sizeof(*plugin));
 
 		plugin->assembly = assembly;
-		plugin->class    = mod_mono_find_assembly_class(mono_assembly_get_image(plugin->assembly));
+		plugin->class = mod_mono_find_assembly_class(mono_assembly_get_image(plugin->assembly));
 
 		if (!plugin->class)
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "No plugin class\n");
 
 		plugin->object = mono_object_new(globals.domain, plugin->class);
 
-		switch_core_hash_insert(globals.plugins, (char *) mono_image_get_name(mono_assembly_get_image(assembly)), plugin);
+		switch_core_hash_insert(globals.plugins, (char *) mono_image_get_name(mono_assembly_get_image(assembly)),
+								plugin);
 
 		plugin = NULL;
-	}	
+	}
 	return SWITCH_STATUS_SUCCESS;
 }
 
 /*
  *
- */ 
-MonoClass* mod_mono_find_assembly_class(MonoImage *image)
+ */
+MonoClass *mod_mono_find_assembly_class(MonoImage * image)
 {
 	MonoClass *class, *parent_class = NULL;
 	int i, total;
 
 	total = mono_image_get_table_rows(image, MONO_TABLE_TYPEDEF);
-	
-	for (i = 1; i <= total; ++i)
-	{
+
+	for (i = 1; i <= total; ++i) {
 		class = mono_class_get(image, MONO_TOKEN_TYPE_DEF | i);
 		parent_class = mono_class_get_parent(class);
-		
-		if (parent_class) 
+
+		if (parent_class)
 			if (!strcmp("Module", mono_class_get_name(parent_class)))
 				return class;
 	}
-						
+
 	return NULL;
 }
 
 /*
  *
  */
-void mono_switch_console_printf(switch_text_channel_t channel, char *file, const char *func, int line, char *fmt, char *msg)
+void mono_switch_console_printf(switch_text_channel_t channel, char *file, const char *func, int line, char *fmt,
+								char *msg)
 {
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, msg);
 }
diff --git a/src/mod/languages/mod_perl/mod_perl.c b/src/mod/languages/mod_perl/mod_perl.c
index db39f61516..cde3560d2a 100644
--- a/src/mod/languages/mod_perl/mod_perl.c
+++ b/src/mod/languages/mod_perl/mod_perl.c
@@ -50,7 +50,7 @@ static struct {
 } globals;
 
 
-static void destroy_perl(PerlInterpreter **to_destroy)
+static void destroy_perl(PerlInterpreter ** to_destroy)
 {
 	perl_destruct(*to_destroy);
 	perl_free(*to_destroy);
@@ -59,7 +59,7 @@ static void destroy_perl(PerlInterpreter **to_destroy)
 
 static PerlInterpreter *clone_perl(void)
 {
-	return perl_clone(globals.my_perl, CLONEf_COPY_STACKS|CLONEf_KEEP_PTR_TABLE);
+	return perl_clone(globals.my_perl, CLONEf_COPY_STACKS | CLONEf_KEEP_PTR_TABLE);
 }
 
 
@@ -69,9 +69,7 @@ static void perl_function(switch_core_session_t *session, char *data)
 	char code[1024];
 	PerlInterpreter *my_perl = clone_perl();
 	sprintf(code, "package fs_perl;\n"
-			"$SWITCH_ENV{UUID} = \"%s\";\n"
-			"chdir(\"%s/perl\");\n",
-			uuid, SWITCH_GLOBAL_dirs.base_dir);
+			"$SWITCH_ENV{UUID} = \"%s\";\n" "chdir(\"%s/perl\");\n", uuid, SWITCH_GLOBAL_dirs.base_dir);
 
 	Perl_eval_pv(my_perl, code, TRUE);
 
@@ -84,8 +82,9 @@ static const switch_application_interface_t perl_application_interface = {
 	/*.interface_name */ "perl",
 	/*.application_function */ perl_function,
 	NULL, NULL, NULL,
-	/* flags */ SAF_NONE, /* should we support no media mode here?  If so, we need to detect the mode, and either disable the media functions or indicate media if/when we need */
-	/*.next*/ NULL
+	/* flags */ SAF_NONE,
+	/* should we support no media mode here?  If so, we need to detect the mode, and either disable the media functions or indicate media if/when we need */
+	/*.next */ NULL
 };
 
 static switch_loadable_module_interface_t perl_module_interface = {
@@ -102,7 +101,7 @@ static switch_loadable_module_interface_t perl_module_interface = {
 };
 
 
-SWITCH_MOD_DECLARE(switch_status_t) switch_module_shutdown(void) 
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_shutdown(void)
 {
 	if (globals.my_perl) {
 		perl_destruct(globals.my_perl);
@@ -113,12 +112,13 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_shutdown(void)
 	return SWITCH_STATUS_SUCCESS;
 }
 
-SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
+													   char *filename)
 {
 
 	PerlInterpreter *my_perl;
 	char code[1024];
-	
+
 	if (!(my_perl = perl_alloc())) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not allocate perl intrepreter\n");
 		return SWITCH_STATUS_MEMERR;
@@ -131,7 +131,7 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_mod
 	perl_run(my_perl);
 	globals.my_perl = my_perl;
 	sprintf(code, "use lib '%s/perl';use fs_perl;use freeswitch\n", SWITCH_GLOBAL_dirs.base_dir);
-    Perl_eval_pv(my_perl, code, TRUE);
+	Perl_eval_pv(my_perl, code, TRUE);
 
 
 	/* connect my internal structure to the blank pointer passed to me */
diff --git a/src/mod/languages/mod_perl/perlxsi.c b/src/mod/languages/mod_perl/perlxsi.c
index c5978dab89..51aea72065 100644
--- a/src/mod/languages/mod_perl/perlxsi.c
+++ b/src/mod/languages/mod_perl/perlxsi.c
@@ -4,12 +4,11 @@
 #include 
 #include 
 
-EXTERN_C void xs_init (pTHX);
+EXTERN_C void xs_init(pTHX);
 
-EXTERN_C void boot_DynaLoader (pTHX_ CV* cv);
+EXTERN_C void boot_DynaLoader(pTHX_ CV * cv);
 
-EXTERN_C void
-xs_init(pTHX)
+EXTERN_C void xs_init(pTHX)
 {
 	char *file = __FILE__;
 	dXSUB_SYS;
diff --git a/src/mod/languages/mod_perl/switch_swig_wrap.c b/src/mod/languages/mod_perl/switch_swig_wrap.c
index a088af3569..d06d97f523 100644
--- a/src/mod/languages/mod_perl/switch_swig_wrap.c
+++ b/src/mod/languages/mod_perl/switch_swig_wrap.c
@@ -24,8 +24,8 @@
 #define SWIG_TypeName        SWIG_Perl_TypeName
 #define SWIG_TypeQuery       SWIG_Perl_TypeQuery
 #define SWIG_TypeClientData  SWIG_Perl_TypeClientData
-#define SWIG_PackData        SWIG_Perl_PackData 
-#define SWIG_UnpackData      SWIG_Perl_UnpackData 
+#define SWIG_PackData        SWIG_Perl_PackData
+#define SWIG_UnpackData      SWIG_Perl_UnpackData
 
 
 /***********************************************************************
@@ -78,194 +78,205 @@
 extern "C" {
 #endif
 
-typedef void *(*swig_converter_func)(void *);
-typedef struct swig_type_info *(*swig_dycast_func)(void **);
+	typedef void *(*swig_converter_func) (void *);
+	typedef struct swig_type_info *(*swig_dycast_func) (void **);
 
-typedef struct swig_type_info {
-  const char             *name;
-  swig_converter_func     converter;
-  const char             *str;
-  void                   *clientdata;
-  swig_dycast_func        dcast;
-  struct swig_type_info  *next;
-  struct swig_type_info  *prev;
-} swig_type_info;
+	typedef struct swig_type_info {
+		const char *name;
+		swig_converter_func converter;
+		const char *str;
+		void *clientdata;
+		swig_dycast_func dcast;
+		struct swig_type_info *next;
+		struct swig_type_info *prev;
+	} swig_type_info;
 
 #ifdef SWIG_NOINCLUDE
 
-SWIGIMPORT(swig_type_info *) SWIG_TypeRegister(swig_type_info *);
-SWIGIMPORT(swig_type_info *) SWIG_TypeCheck(char *c, swig_type_info *);
-SWIGIMPORT(void *)           SWIG_TypeCast(swig_type_info *, void *);
-SWIGIMPORT(swig_type_info *) SWIG_TypeDynamicCast(swig_type_info *, void **);
-SWIGIMPORT(const char *)     SWIG_TypeName(const swig_type_info *);
-SWIGIMPORT(swig_type_info *) SWIG_TypeQuery(const char *);
-SWIGIMPORT(void)             SWIG_TypeClientData(swig_type_info *, void *);
-SWIGIMPORT(char *)           SWIG_PackData(char *, void *, int);
-SWIGIMPORT(char *)           SWIG_UnpackData(char *, void *, int);
+	               SWIGIMPORT(swig_type_info *) SWIG_TypeRegister(swig_type_info *);
+	               SWIGIMPORT(swig_type_info *) SWIG_TypeCheck(char *c, swig_type_info *);
+	     SWIGIMPORT(void *) SWIG_TypeCast(swig_type_info *, void *);
+	     SWIGIMPORT(swig_type_info *) SWIG_TypeDynamicCast(swig_type_info *, void **);
+	     SWIGIMPORT(const char *) SWIG_TypeName(const swig_type_info *);
+	      SWIGIMPORT(swig_type_info *) SWIG_TypeQuery(const char *);
+	     SWIGIMPORT(void) SWIG_TypeClientData(swig_type_info *, void *);
+	     SWIGIMPORT(char *) SWIG_PackData(char *, void *, int);
+	    SWIGIMPORT(char *) SWIG_UnpackData(char *, void *, int);
 
 #else
 
-static swig_type_info *swig_type_list = 0;
+	static swig_type_info *swig_type_list = 0;
 
 /* Register a type mapping with the type-checking */
-SWIGRUNTIME(swig_type_info *)
-SWIG_TypeRegister(swig_type_info *ti) {
-  swig_type_info *tc, *head, *ret, *next;
-  /* Check to see if this type has already been registered */
-  tc = swig_type_list;
-  while (tc) {
-    if (strcmp(tc->name, ti->name) == 0) {
-      /* Already exists in the table.  Just add additional types to the list */
-      if (tc->clientdata) ti->clientdata = tc->clientdata;
-      head = tc;
-      next = tc->next;
-      goto l1;
-    }
-    tc = tc->prev;
-  }
-  head = ti;
-  next = 0;
+	               SWIGRUNTIME(swig_type_info *)
+	               SWIG_TypeRegister(swig_type_info * ti) {
+		swig_type_info *tc, *head, *ret, *next;
+		/* Check to see if this type has already been registered */
+		               tc = swig_type_list;
+		while          (tc) {
+			if (strcmp(tc->name, ti->name) == 0) {
+				/* Already exists in the table.  Just add additional types to the list */
+				if (tc->clientdata)
+					ti->clientdata = tc->clientdata;
+				head = tc;
+				next = tc->next;
+				goto l1;
+			}
+			tc = tc->prev;
+		}
+		head = ti;
+		next = 0;
 
-  /* Place in list */
-  ti->prev = swig_type_list;
-  swig_type_list = ti;
+		/* Place in list */
+		ti->prev = swig_type_list;
+		swig_type_list = ti;
 
-  /* Build linked lists */
-  l1:
-  ret = head;
-  tc = ti + 1;
-  /* Patch up the rest of the links */
-  while (tc->name) {
-    head->next = tc;
-    tc->prev = head;
-    head = tc;
-    tc++;
-  }
-  if (next) next->prev = head;
-  head->next = next;
-  return ret;
-}
+		/* Build linked lists */
+	  l1:
+		ret = head;
+		tc = ti + 1;
+		/* Patch up the rest of the links */
+		while (tc->name) {
+			head->next = tc;
+			tc->prev = head;
+			head = tc;
+			tc++;
+		}
+		if (next)
+			next->prev = head;
+		head->next = next;
+		return ret;
+	}
 
 /* Check the typename */
-SWIGRUNTIME(swig_type_info *) 
-SWIG_TypeCheck(char *c, swig_type_info *ty) {
-  swig_type_info *s;
-  if (!ty) return 0;        /* Void pointer */
-  s = ty->next;             /* First element always just a name */
-  do {
-    if (strcmp(s->name,c) == 0) {
-      if (s == ty->next) return s;
-      /* Move s to the top of the linked list */
-      s->prev->next = s->next;
-      if (s->next) {
-        s->next->prev = s->prev;
-      }
-      /* Insert s as second element in the list */
-      s->next = ty->next;
-      if (ty->next) ty->next->prev = s;
-      ty->next = s;
-      s->prev = ty;
-      return s;
-    }
-    s = s->next;
-  } while (s && (s != ty->next));
-  return 0;
-}
+	SWIGRUNTIME(swig_type_info *)
+		SWIG_TypeCheck(char *c, swig_type_info * ty) {
+		swig_type_info *s;
+		if (!ty)
+			return 0;			/* Void pointer */
+		s = ty->next;			/* First element always just a name */
+		do {
+			if (strcmp(s->name, c) == 0) {
+				if (s == ty->next)
+					return s;
+				/* Move s to the top of the linked list */
+				s->prev->next = s->next;
+				if (s->next) {
+					s->next->prev = s->prev;
+				}
+				/* Insert s as second element in the list */
+				s->next = ty->next;
+				if (ty->next)
+					ty->next->prev = s;
+				ty->next = s;
+				s->prev = ty;
+				return s;
+			}
+			s = s->next;
+		} while (s && (s != ty->next));
+		return 0;
+	}
 
 /* Cast a pointer up an inheritance hierarchy */
-SWIGRUNTIME(void *) 
-SWIG_TypeCast(swig_type_info *ty, void *ptr) {
-  if ((!ty) || (!ty->converter)) return ptr;
-  return (*ty->converter)(ptr);
-}
+	SWIGRUNTIME(void *)
+		SWIG_TypeCast(swig_type_info * ty, void *ptr) {
+		if ((!ty) || (!ty->converter))
+			return ptr;
+		return (*ty->converter) (ptr);
+	}
 
 /* Dynamic pointer casting. Down an inheritance hierarchy */
-SWIGRUNTIME(swig_type_info *) 
-SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) {
-  swig_type_info *lastty = ty;
-  if (!ty || !ty->dcast) return ty;
-  while (ty && (ty->dcast)) {
-    ty = (*ty->dcast)(ptr);
-    if (ty) lastty = ty;
-  }
-  return lastty;
-}
+	SWIGRUNTIME(swig_type_info *)
+		SWIG_TypeDynamicCast(swig_type_info * ty, void **ptr) {
+		swig_type_info *lastty = ty;
+		if (!ty || !ty->dcast)
+			return ty;
+		while (ty && (ty->dcast)) {
+			ty = (*ty->dcast) (ptr);
+			if (ty)
+				lastty = ty;
+		}
+		return lastty;
+	}
 
 /* Return the name associated with this type */
-SWIGRUNTIME(const char *)
-SWIG_TypeName(const swig_type_info *ty) {
-  return ty->name;
-}
+	SWIGRUNTIME(const char *)
+		SWIG_TypeName(const swig_type_info * ty) {
+		return ty->name;
+	}
 
 /* Search for a swig_type_info structure */
-SWIGRUNTIME(swig_type_info *)
-SWIG_TypeQuery(const char *name) {
-  swig_type_info *ty = swig_type_list;
-  while (ty) {
-    if (ty->str && (strcmp(name,ty->str) == 0)) return ty;
-    if (ty->name && (strcmp(name,ty->name) == 0)) return ty;
-    ty = ty->prev;
-  }
-  return 0;
-}
+	SWIGRUNTIME(swig_type_info *)
+		SWIG_TypeQuery(const char *name) {
+		swig_type_info *ty = swig_type_list;
+		while (ty) {
+			if (ty->str && (strcmp(name, ty->str) == 0))
+				return ty;
+			if (ty->name && (strcmp(name, ty->name) == 0))
+				return ty;
+			ty = ty->prev;
+		}
+		return 0;
+	}
 
 /* Set the clientdata field for a type */
-SWIGRUNTIME(void)
-SWIG_TypeClientData(swig_type_info *ti, void *clientdata) {
-  swig_type_info *tc, *equiv;
-  if (ti->clientdata == clientdata) return;
-  ti->clientdata = clientdata;
-  equiv = ti->next;
-  while (equiv) {
-    if (!equiv->converter) {
-      tc = swig_type_list;
-      while (tc) {
-        if ((strcmp(tc->name, equiv->name) == 0))
-          SWIG_TypeClientData(tc,clientdata);
-        tc = tc->prev;
-      }
-    }
-    equiv = equiv->next;
-  }
-}
+	SWIGRUNTIME(void)
+		SWIG_TypeClientData(swig_type_info * ti, void *clientdata) {
+		swig_type_info *tc, *equiv;
+		if (ti->clientdata == clientdata)
+			return;
+		ti->clientdata = clientdata;
+		equiv = ti->next;
+		while (equiv) {
+			if (!equiv->converter) {
+				tc = swig_type_list;
+				while (tc) {
+					if ((strcmp(tc->name, equiv->name) == 0))
+						SWIG_TypeClientData(tc, clientdata);
+					tc = tc->prev;
+				}
+			}
+			equiv = equiv->next;
+		}
+	}
 
 /* Pack binary data into a string */
-SWIGRUNTIME(char *)
-SWIG_PackData(char *c, void *ptr, int sz) {
-  static char hex[17] = "0123456789abcdef";
-  int i;
-  unsigned char *u = (unsigned char *) ptr;
-  register unsigned char uu;
-  for (i = 0; i < sz; i++,u++) {
-    uu = *u;
-    *(c++) = hex[(uu & 0xf0) >> 4];
-    *(c++) = hex[uu & 0xf];
-  }
-  return c;
-}
+	SWIGRUNTIME(char *)
+	     SWIG_PackData(char *c, void *ptr, int sz) {
+		static char hex[17] = "0123456789abcdef";
+		int i;
+		unsigned char *u = (unsigned char *) ptr;
+		register unsigned char uu;
+		for (i = 0; i < sz; i++, u++) {
+			uu = *u;
+			*(c++) = hex[(uu & 0xf0) >> 4];
+			*(c++) = hex[uu & 0xf];
+		}
+		return c;
+	}
 
 /* Unpack binary data from a string */
-SWIGRUNTIME(char *)
-SWIG_UnpackData(char *c, void *ptr, int sz) {
-  register unsigned char uu = 0;
-  register int d;
-  unsigned char *u = (unsigned char *) ptr;
-  int i;
-  for (i = 0; i < sz; i++, u++) {
-    d = *(c++);
-    if ((d >= '0') && (d <= '9'))
-      uu = ((d - '0') << 4);
-    else if ((d >= 'a') && (d <= 'f'))
-      uu = ((d - ('a'-10)) << 4);
-    d = *(c++);
-    if ((d >= '0') && (d <= '9'))
-      uu |= (d - '0');
-    else if ((d >= 'a') && (d <= 'f'))
-      uu |= (d - ('a'-10));
-    *u = uu;
-  }
-  return c;
-}
+	SWIGRUNTIME(char *)
+		SWIG_UnpackData(char *c, void *ptr, int sz) {
+		register unsigned char uu = 0;
+		register int d;
+		unsigned char *u = (unsigned char *) ptr;
+		int i;
+		for (i = 0; i < sz; i++, u++) {
+			d = *(c++);
+			if ((d >= '0') && (d <= '9'))
+				uu = ((d - '0') << 4);
+			else if ((d >= 'a') && (d <= 'f'))
+				uu = ((d - ('a' - 10)) << 4);
+			d = *(c++);
+			if ((d >= '0') && (d <= '9'))
+				uu |= (d - '0');
+			else if ((d >= 'a') && (d <= 'f'))
+				uu |= (d - ('a' - 10));
+			*u = uu;
+		}
+		return c;
+	}
 
 #endif
 
@@ -304,37 +315,30 @@ extern "C" {
 #ifdef __cplusplus
 }
 #endif
-
 /* Macro to call an XS function */
-
-#ifdef PERL_OBJECT 
-#  define SWIG_CALLXS(_name) _name(cv,pPerl) 
-#else 
-#  ifndef MULTIPLICITY 
-#    define SWIG_CALLXS(_name) _name(cv) 
-#  else 
-#    define SWIG_CALLXS(_name) _name(PERL_GET_THX, cv) 
-#  endif 
-#endif 
-
+#ifdef PERL_OBJECT
+#  define SWIG_CALLXS(_name) _name(cv,pPerl)
+#else
+#  ifndef MULTIPLICITY
+#    define SWIG_CALLXS(_name) _name(cv)
+#  else
+#    define SWIG_CALLXS(_name) _name(PERL_GET_THX, cv)
+#  endif
+#endif
 /* Contract support */
-
 #define SWIG_contract_assert(expr,msg) if (!(expr)) { SWIG_croak(msg); } else
-
 /* Note: SwigMagicFuncHack is a typedef used to get the C++ compiler to just shut up already */
-
 #ifdef PERL_OBJECT
 #define MAGIC_PPERL  CPerlObj *pPerl = (CPerlObj *) this;
-typedef int (CPerlObj::*SwigMagicFunc)(SV *, MAGIC *);
+typedef int (CPerlObj::*SwigMagicFunc) (SV *, MAGIC *);
 
 #ifdef __cplusplus
 extern "C" {
 #endif
-typedef int (CPerlObj::*SwigMagicFuncHack)(SV *, MAGIC *);
+	typedef int (CPerlObj::*SwigMagicFuncHack) (SV *, MAGIC *);
 #ifdef __cplusplus
 }
 #endif
-
 #define SWIG_MAGIC(a,b) (SV *a, MAGIC *b)
 #define SWIGCLASS_STATIC
 #else
@@ -342,37 +346,31 @@ typedef int (CPerlObj::*SwigMagicFuncHack)(SV *, MAGIC *);
 #define SWIGCLASS_STATIC static
 #ifndef MULTIPLICITY
 #define SWIG_MAGIC(a,b) (SV *a, MAGIC *b)
-typedef int (*SwigMagicFunc)(SV *, MAGIC *);
+typedef int (*SwigMagicFunc) (SV *, MAGIC *);
 
 #ifdef __cplusplus
 extern "C" {
 #endif
-typedef int (*SwigMagicFuncHack)(SV *, MAGIC *);
+	typedef int (*SwigMagicFuncHack) (SV *, MAGIC *);
 #ifdef __cplusplus
 }
 #endif
-
-
 #else
 #define SWIG_MAGIC(a,b) (struct interpreter *interp, SV *a, MAGIC *b)
-typedef int (*SwigMagicFunc)(struct interpreter *, SV *, MAGIC *);
+typedef int (*SwigMagicFunc) (struct interpreter *, SV *, MAGIC *);
 #ifdef __cplusplus
 extern "C" {
 #endif
-typedef int (*SwigMagicFuncHack)(struct interpreter *, SV *, MAGIC *);
+	typedef int (*SwigMagicFuncHack) (struct interpreter *, SV *, MAGIC *);
 #ifdef __cplusplus
 }
 #endif
-
 #endif
 #endif
-
 #if defined(WIN32) && defined(PERL_OBJECT) && !defined(PerlIO_exportFILE)
 #define PerlIO_exportFILE(fh,fl) (FILE*)(fh)
 #endif
-
 /* Modifications for newer Perl 5.005 releases */
-
 #if !defined(PERL_REVISION) || ((PERL_REVISION >= 5) && ((PERL_VERSION < 5) || ((PERL_VERSION == 5) && (PERL_SUBVERSION < 50))))
 #  ifndef PL_sv_yes
 #    define PL_sv_yes sv_yes
@@ -384,9 +382,7 @@ typedef int (*SwigMagicFuncHack)(struct interpreter *, SV *, MAGIC *);
 #    define PL_na na
 #  endif
 #endif
-
 #include 
-
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -447,187 +443,195 @@ extern "C" {
 
 #ifdef SWIG_NOINCLUDE
 
-SWIGIMPORT(int)               SWIG_Perl_ConvertPtr(SWIG_MAYBE_PERL_OBJECT SV *, void **, swig_type_info *, int flags);
-SWIGIMPORT(void)              SWIG_Perl_MakePtr(SWIG_MAYBE_PERL_OBJECT SV *, void *, swig_type_info *, int flags);
-SWIGIMPORT(SV *)              SWIG_Perl_NewPointerObj(SWIG_MAYBE_PERL_OBJECT void *, swig_type_info *, int flags);
-SWIGIMPORT(void)              SWIG_Perl_MakePackedObj(SWIG_MAYBE_PERL_OBJECT SV *, void *, int, swig_type_info *);
-SWIGIMPORT(int)               SWIG_Perl_ConvertPacked(SWIG_MAYBE_PERL_OBJECT SV *, void *, int, swig_type_info *, int flags);
-SWIGIMPORT(swig_type_info *)  SWIG_Perl_TypeCheckRV(SWIG_MAYBE_PERL_OBJECT SV *rv, swig_type_info *ty);
-SWIGIMPORT(SV *)              SWIG_Perl_SetError(SWIG_MAYBE_PERL_OBJECT char *);
+	SWIGIMPORT(int) SWIG_Perl_ConvertPtr(SWIG_MAYBE_PERL_OBJECT SV *, void **, swig_type_info *, int flags);
+	    SWIGIMPORT(void) SWIG_Perl_MakePtr(SWIG_MAYBE_PERL_OBJECT SV *, void *, swig_type_info *, int flags);
+	    SWIGIMPORT(SV *) SWIG_Perl_NewPointerObj(SWIG_MAYBE_PERL_OBJECT void *, swig_type_info *, int flags);
+	    SWIGIMPORT(void) SWIG_Perl_MakePackedObj(SWIG_MAYBE_PERL_OBJECT SV *, void *, int, swig_type_info *);
+	    SWIGIMPORT(int) SWIG_Perl_ConvertPacked(SWIG_MAYBE_PERL_OBJECT SV *, void *, int, swig_type_info *, int flags);
+	    SWIGIMPORT(swig_type_info *) SWIG_Perl_TypeCheckRV(SWIG_MAYBE_PERL_OBJECT SV * rv, swig_type_info * ty);
+	    SWIGIMPORT(SV *) SWIG_Perl_SetError(SWIG_MAYBE_PERL_OBJECT char *);
 
 #else
 
-SWIGRUNTIME(swig_type_info *)
-SWIG_Perl_TypeCheckRV(SWIG_MAYBE_PERL_OBJECT SV *rv, swig_type_info *ty) {
-  swig_type_info *s;
-  if (!ty) return 0;        /* Void pointer */
-  s = ty->next;             /* First element always just a name */
-  do {
-    if (sv_derived_from(rv, (char *) s->name)) {
-      if (s == ty->next) return s;
-      /* Move s to the top of the linked list */
-      s->prev->next = s->next;
-      if (s->next) {
-        s->next->prev = s->prev;
-      }
-      /* Insert s as second element in the list */
-      s->next = ty->next;
-      if (ty->next) ty->next->prev = s;
-      ty->next = s;
-      s->prev = ty;
-      return s;
-    }
-    s = s->next;
-  } while (s && (s != ty->next));
-  return 0;
-}
+	     SWIGRUNTIME(swig_type_info *)
+	     SWIG_Perl_TypeCheckRV(SWIG_MAYBE_PERL_OBJECT SV * rv, swig_type_info * ty) {
+		swig_type_info *s;
+		if             (!ty)
+			               return 0;	/* Void pointer */
+		               s = ty->next;	/* First element always just a name */
+		do {
+			if (sv_derived_from(rv, (char *) s->name)) {
+				if (s == ty->next)
+					return s;
+				/* Move s to the top of the linked list */
+				s->prev->next = s->next;
+				if (s->next) {
+					s->next->prev = s->prev;
+				}
+				/* Insert s as second element in the list */
+				s->    next = ty->next;
+				if (ty->next)
+					ty->next->prev = s;
+				ty->next = s;
+				s->prev = ty;
+				return s;
+			}
+			s = s->next;
+		} while (s && (s != ty->next));
+		return 0;
+	}
 
 /* Function for getting a pointer value */
 
-SWIGRUNTIME(int) 
-SWIG_Perl_ConvertPtr(SWIG_MAYBE_PERL_OBJECT SV *sv, void **ptr, swig_type_info *_t, int flags) {
-  swig_type_info *tc;
-  void *voidptr = (void *)0;
+	SWIGRUNTIME(int)
+		SWIG_Perl_ConvertPtr(SWIG_MAYBE_PERL_OBJECT SV * sv, void **ptr, swig_type_info * _t, int flags) {
+		swig_type_info *tc;
+		void *voidptr = (void *) 0;
 
-  /* If magical, apply more magic */
-  if (SvGMAGICAL(sv))
-    mg_get(sv);
+		/* If magical, apply more magic */
+		if (SvGMAGICAL(sv))
+			mg_get(sv);
 
-  /* Check to see if this is an object */
-  if (sv_isobject(sv)) {
-    SV *tsv = (SV*) SvRV(sv);
-    IV tmp = 0;
-    if ((SvTYPE(tsv) == SVt_PVHV)) {
-      MAGIC *mg;
-      if (SvMAGICAL(tsv)) {
-        mg = mg_find(tsv,'P');
-        if (mg) {
-          SV *rsv = mg->mg_obj;
-          if (sv_isobject(rsv)) {
-            tmp = SvIV((SV*)SvRV(rsv));
-          }
-        }
-      } else {
-        return -1;
-      }
-    } else {
-      tmp = SvIV((SV*)SvRV(sv));
-    }
-    voidptr = (void *)tmp;
-    if (!_t) {
-      *(ptr) = voidptr;
-      return 0;
-    }
-  } else if (! SvOK(sv)) {            /* Check for undef */
-    *(ptr) = (void *) 0;
-    return 0;
-  } else if (SvTYPE(sv) == SVt_RV) {  /* Check for NULL pointer */
-    *(ptr) = (void *) 0;
-    if (!SvROK(sv))
-      return 0;
-    else
-      return -1;
-  } else {                            /* Don't know what it is */
-    *(ptr) = (void *) 0;
-    return -1;
-  }
-  if (_t) {
-    /* Now see if the types match */
-    tc = SWIG_TypeCheckRV(sv,_t);
-    if (!tc) {
-      *ptr = voidptr;
-      return -1;
-    }
-    *ptr = SWIG_TypeCast(tc,voidptr);
-    return 0;
-  }
-  *ptr = voidptr;
-  return 0;
-}
+		/* Check to see if this is an object */
+		if (sv_isobject(sv)) {
+			SV *tsv = (SV *) SvRV(sv);
+			IV tmp = 0;
+			if ((SvTYPE(tsv) == SVt_PVHV)) {
+				MAGIC *mg;
+				if (SvMAGICAL(tsv)) {
+					mg = mg_find(tsv, 'P');
+					if (mg) {
+						SV *rsv = mg->mg_obj;
+						if (sv_isobject(rsv)) {
+							tmp = SvIV((SV *) SvRV(rsv));
+						}
+					}
+				} else {
+					return -1;
+				}
+			} else {
+				tmp = SvIV((SV *) SvRV(sv));
+			}
+			voidptr = (void *) tmp;
+			if (!_t) {
+				*(ptr) = voidptr;
+				return 0;
+			}
+		} else if (!SvOK(sv)) {	/* Check for undef */
+			*(ptr) = (void *) 0;
+			return 0;
+		} else if (SvTYPE(sv) == SVt_RV) {	/* Check for NULL pointer */
+			*(ptr) = (void *) 0;
+			if (!SvROK(sv))
+				return 0;
+			else
+				return -1;
+		} else {				/* Don't know what it is */
+			*(ptr) = (void *) 0;
+			return -1;
+		}
+		if (_t) {
+			/* Now see if the types match */
+			tc = SWIG_TypeCheckRV(sv, _t);
+			if (!tc) {
+				*ptr = voidptr;
+				return -1;
+			}
+			*ptr = SWIG_TypeCast(tc, voidptr);
+			return 0;
+		}
+		*ptr = voidptr;
+		return 0;
+	}
 
-SWIGRUNTIME(void)
-SWIG_Perl_MakePtr(SWIG_MAYBE_PERL_OBJECT SV *sv, void *ptr, swig_type_info *t, int flags) {
-  if (ptr && (flags & SWIG_SHADOW)) {
-    SV *self;
-    SV *obj=newSV(0);
-    HV *hash=newHV();
-    HV *stash;
-    sv_setref_pv(obj, (char *) t->name, ptr);
-    stash=SvSTASH(SvRV(obj));
-    if (flags & SWIG_OWNER) {
-      HV *hv;
-      GV *gv=*(GV**)hv_fetch(stash, "OWNER", 5, TRUE);
-      if (!isGV(gv))
-        gv_init(gv, stash, "OWNER", 5, FALSE);
-      hv=GvHVn(gv);
-      hv_store_ent(hv, obj, newSViv(1), 0);
-    }
-    sv_magic((SV *)hash, (SV *)obj, 'P', Nullch, 0);
-    SvREFCNT_dec(obj);
-    self=newRV_noinc((SV *)hash);
-    sv_setsv(sv, self);
-    SvREFCNT_dec((SV *)self);
-    sv_bless(sv, stash);
-  }
-  else {
-    sv_setref_pv(sv, (char *) t->name, ptr);
-  }
-}
+	SWIGRUNTIME(void)
+		SWIG_Perl_MakePtr(SWIG_MAYBE_PERL_OBJECT SV * sv, void *ptr, swig_type_info * t, int flags) {
+		if (ptr && (flags & SWIG_SHADOW)) {
+			SV *self;
+			SV *obj = newSV(0);
+			HV *hash = newHV();
+			HV *stash;
+			sv_setref_pv(obj, (char *) t->name, ptr);
+			stash = SvSTASH(SvRV(obj));
+			if (flags & SWIG_OWNER) {
+				HV *hv;
+				GV *gv = *(GV **) hv_fetch(stash, "OWNER", 5, TRUE);
+				if (!isGV(gv))
+					gv_init(gv, stash, "OWNER", 5, FALSE);
+				hv = GvHVn(gv);
+				hv_store_ent(hv, obj, newSViv(1), 0);
+			}
+			sv_magic((SV *) hash, (SV *) obj, 'P', Nullch, 0);
+			SvREFCNT_dec(obj);
+			self = newRV_noinc((SV *) hash);
+			sv_setsv(sv, self);
+			SvREFCNT_dec((SV *) self);
+			sv_bless(sv, stash);
+		} else {
+			sv_setref_pv(sv, (char *) t->name, ptr);
+		}
+	}
 
-SWIGRUNTIME(SV *)
-SWIG_Perl_NewPointerObj(SWIG_MAYBE_PERL_OBJECT void *ptr, swig_type_info *t, int flags) {
-  SV *result = sv_newmortal();
-  SWIG_MakePtr(result, ptr, t, flags);
-  return result;
-}
+	SWIGRUNTIME(SV *)
+		SWIG_Perl_NewPointerObj(SWIG_MAYBE_PERL_OBJECT void *ptr, swig_type_info * t, int flags) {
+		SV *result = sv_newmortal();
+		SWIG_MakePtr(result, ptr, t, flags);
+		return result;
+	}
 
-SWIGRUNTIME(void)
-  SWIG_Perl_MakePackedObj(SWIG_MAYBE_PERL_OBJECT SV *sv, void *ptr, int sz, swig_type_info *type) {
-  char result[1024];
-  char *r = result;
-  if ((2*sz + 1 + strlen(type->name)) > 1000) return;
-  *(r++) = '_';
-  r = SWIG_PackData(r,ptr,sz);
-  strcpy(r,type->name);
-  sv_setpv(sv, result);
-}
+	SWIGRUNTIME(void)
+		SWIG_Perl_MakePackedObj(SWIG_MAYBE_PERL_OBJECT SV * sv, void *ptr, int sz, swig_type_info * type) {
+		char result[1024];
+		char *r = result;
+		if ((2 * sz + 1 + strlen(type->name)) > 1000)
+			return;
+		*(r++) = '_';
+		r = SWIG_PackData(r, ptr, sz);
+		strcpy(r, type->name);
+		sv_setpv(sv, result);
+	}
 
 /* Convert a packed value value */
-SWIGRUNTIME(int)
-SWIG_Perl_ConvertPacked(SWIG_MAYBE_PERL_OBJECT SV *obj, void *ptr, int sz, swig_type_info *ty, int flags) {
-  swig_type_info *tc;
-  char  *c = 0;
+	SWIGRUNTIME(int)
+		SWIG_Perl_ConvertPacked(SWIG_MAYBE_PERL_OBJECT SV * obj, void *ptr, int sz, swig_type_info * ty, int flags) {
+		swig_type_info *tc;
+		char *c = 0;
 
-  if ((!obj) || (!SvOK(obj))) return -1;
-  c = SvPV(obj, PL_na);
-  /* Pointer values must start with leading underscore */
-  if (*c != '_') return -1;
-  c++;
-  c = SWIG_UnpackData(c,ptr,sz);
-  if (ty) {
-    tc = SWIG_TypeCheck(c,ty);
-    if (!tc) return -1;
-  }
-  return 0;
-}
+		if ((!obj) || (!SvOK(obj)))
+			return -1;
+		c = SvPV(obj, PL_na);
+		/* Pointer values must start with leading underscore */
+		if (*c != '_')
+			return -1;
+		c++;
+		c = SWIG_UnpackData(c, ptr, sz);
+		if (ty) {
+			tc = SWIG_TypeCheck(c, ty);
+			if (!tc)
+				return -1;
+		}
+		return 0;
+	}
 
-SWIGRUNTIME(void)
-SWIG_Perl_SetError(SWIG_MAYBE_PERL_OBJECT const char *error) {
-  if (error) sv_setpv(perl_get_sv("@", TRUE), error);
-}
+	SWIGRUNTIME(void)
+		SWIG_Perl_SetError(SWIG_MAYBE_PERL_OBJECT const char *error) {
+		if (error)
+			sv_setpv(perl_get_sv("@", TRUE), error);
+	}
 
-SWIGRUNTIME(void)
-SWIG_Perl_SetErrorSV(SWIG_MAYBE_PERL_OBJECT SV *error) {
-  if (error) sv_setsv(perl_get_sv("@", TRUE), error);
-}
+	SWIGRUNTIME(void)
+	     SWIG_Perl_SetErrorSV(SWIG_MAYBE_PERL_OBJECT SV * error) {
+		if (error)
+			sv_setsv(perl_get_sv("@", TRUE), error);
+	}
 
-SWIGRUNTIME(void)
-SWIG_Perl_SetErrorf(const char *fmt, ...) {
-  va_list args;
-  va_start(args, fmt);
-  sv_vsetpvfn(perl_get_sv("@", TRUE), fmt, strlen(fmt), &args, Null(SV**), 0, Null(bool*));
-  va_end(args);
-}
+	SWIGRUNTIME(void)
+	     SWIG_Perl_SetErrorf(const char *fmt, ...) {
+		va_list args;
+		va_start(args, fmt);
+		sv_vsetpvfn(perl_get_sv("@", TRUE), fmt, strlen(fmt), &args, Null(SV **), 0, Null(bool *));
+		va_end(args);
+	}
 
 #endif
 
@@ -639,14 +643,14 @@ SWIG_Perl_SetErrorf(const char *fmt, ...) {
 /* #define SWIG_croakf(x...) { SWIG_SetErrorf(x); goto fail; } */
 
 
-typedef XS(SwigPerlWrapper);
-typedef SwigPerlWrapper *SwigPerlWrapperPtr;
+	typedef XS(SwigPerlWrapper);
+	typedef SwigPerlWrapper *SwigPerlWrapperPtr;
 
 /* Structure for command table */
-typedef struct {
-  const char         *name;
-  SwigPerlWrapperPtr  wrapper;
-} swig_command_info;
+	typedef struct {
+		const char *name;
+		SwigPerlWrapperPtr wrapper;
+	} swig_command_info;
 
 /* Information for constant table */
 
@@ -657,14 +661,14 @@ typedef struct {
 #define SWIG_BINARY  5
 
 /* Constant information structure */
-typedef struct swig_constant_info {
-    int              type;
-    const char      *name;
-    long             lvalue;
-    double           dvalue;
-    void            *pvalue;
-    swig_type_info **ptype;
-} swig_constant_info;
+	typedef struct swig_constant_info {
+		int type;
+		const char *name;
+		long lvalue;
+		double dvalue;
+		void *pvalue;
+		swig_type_info **ptype;
+	} swig_constant_info;
 
 #ifdef __cplusplus
 }
@@ -672,33 +676,38 @@ typedef struct swig_constant_info {
 
 /* Structure for variable table */
 typedef struct {
-  const char   *name;
-  SwigMagicFunc   set;
-  SwigMagicFunc   get;
-  swig_type_info  **type;
+	const char *name;
+	SwigMagicFunc set;
+	SwigMagicFunc get;
+	swig_type_info **type;
 } swig_variable_info;
 
 /* Magic variable code */
 #ifndef PERL_OBJECT
 #define swig_create_magic(s,a,b,c) _swig_create_magic(s,a,b,c)
-  #ifndef MULTIPLICITY
-     static void _swig_create_magic(SV *sv, char *name, int (*set)(SV *, MAGIC *), int (*get)(SV *,MAGIC *)) {
-  #else
-     static void _swig_create_magic(SV *sv, char *name, int (*set)(struct interpreter*, SV *, MAGIC *), int (*get)(struct interpreter*, SV *,MAGIC *)) {
-  #endif
+#ifndef MULTIPLICITY
+static void _swig_create_magic(SV * sv, char *name, int (*set) (SV *, MAGIC *), int (*get) (SV *, MAGIC *))
+{
+#else
+static void _swig_create_magic(SV * sv, char *name, int (*set) (struct interpreter *, SV *, MAGIC *),
+							   int (*get) (struct interpreter *, SV *, MAGIC *))
+{
+#endif
 #else
 #  define swig_create_magic(s,a,b,c) _swig_create_magic(pPerl,s,a,b,c)
-static void _swig_create_magic(CPerlObj *pPerl, SV *sv, const char *name, int (CPerlObj::*set)(SV *, MAGIC *), int (CPerlObj::*get)(SV *, MAGIC *)) {
+static void _swig_create_magic(CPerlObj * pPerl, SV * sv, const char *name, int (CPerlObj::*set) (SV *, MAGIC *),
+							   int (CPerlObj::*get) (SV *, MAGIC *))
+{
 #endif
-  MAGIC *mg;
-  sv_magic(sv,sv,'U',(char *) name,strlen(name));
-  mg = mg_find(sv,'U');
-  mg->mg_virtual = (MGVTBL *) malloc(sizeof(MGVTBL));
-  mg->mg_virtual->svt_get = (SwigMagicFuncHack) get;
-  mg->mg_virtual->svt_set = (SwigMagicFuncHack) set;
-  mg->mg_virtual->svt_len = 0;
-  mg->mg_virtual->svt_clear = 0;
-  mg->mg_virtual->svt_free = 0;
+	MAGIC *mg;
+	sv_magic(sv, sv, 'U', (char *) name, strlen(name));
+	mg = mg_find(sv, 'U');
+	mg->mg_virtual = (MGVTBL *) malloc(sizeof(MGVTBL));
+	mg->mg_virtual->svt_get = (SwigMagicFuncHack) get;
+	mg->mg_virtual->svt_set = (SwigMagicFuncHack) set;
+	mg->mg_virtual->svt_len = 0;
+	mg->mg_virtual->svt_clear = 0;
+	mg->mg_virtual->svt_free = 0;
 }
 
 
@@ -707,69 +716,69 @@ static void _swig_create_magic(CPerlObj *pPerl, SV *sv, const char *name, int (C
 
 
 #ifdef do_open
-  #undef do_open
+#undef do_open
 #endif
 #ifdef do_close
-  #undef do_close
+#undef do_close
 #endif
 #ifdef scalar
-  #undef scalar
+#undef scalar
 #endif
 #ifdef list
-  #undef list
+#undef list
 #endif
 #ifdef apply
-  #undef apply
+#undef apply
 #endif
 #ifdef convert
-  #undef convert
+#undef convert
 #endif
 #ifdef Error
-  #undef Error
+#undef Error
 #endif
 #ifdef form
-  #undef form
+#undef form
 #endif
 #ifdef vform
-  #undef vform
+#undef vform
 #endif
 #ifdef LABEL
-  #undef LABEL
+#undef LABEL
 #endif
 #ifdef METHOD
-  #undef METHOD
+#undef METHOD
 #endif
 #ifdef Move
-  #undef Move
+#undef Move
 #endif
 #ifdef yylex
-  #undef yylex
+#undef yylex
 #endif
 #ifdef yyparse
-  #undef yyparse
+#undef yyparse
 #endif
 #ifdef yyerror
-  #undef yyerror
+#undef yyerror
 #endif
 #ifdef invert
-  #undef invert
+#undef invert
 #endif
 #ifdef ref
-  #undef ref
+#undef ref
 #endif
 #ifdef ENTER
-  #undef ENTER
+#undef ENTER
 #endif
 
 
 /* -------- TYPES TABLE (BEGIN) -------- */
 
-#define  SWIGTYPE_p_switch_channel_t swig_types[0] 
-#define  SWIGTYPE_p_switch_file_handle_t swig_types[1] 
-#define  SWIGTYPE_p_switch_core_session_t swig_types[2] 
-#define  SWIGTYPE_p_p_switch_core_session_t swig_types[3] 
-#define  SWIGTYPE_p_uint32_t swig_types[4] 
-#define  SWIGTYPE_p_switch_input_callback_function_t swig_types[5] 
+#define  SWIGTYPE_p_switch_channel_t swig_types[0]
+#define  SWIGTYPE_p_switch_file_handle_t swig_types[1]
+#define  SWIGTYPE_p_switch_core_session_t swig_types[2]
+#define  SWIGTYPE_p_p_switch_core_session_t swig_types[3]
+#define  SWIGTYPE_p_uint32_t swig_types[4]
+#define  SWIGTYPE_p_switch_input_callback_function_t swig_types[5]
 static swig_type_info *swig_types[7];
 
 /* -------- TYPES TABLE (END) -------- */
@@ -784,55 +793,59 @@ extern "C"
 #endif
 #ifndef PERL_OBJECT
 #ifndef MULTIPLICITY
-SWIGEXPORT(void) SWIG_init (CV* cv);
+SWIGEXPORT(void) SWIG_init(CV * cv);
 #else
-SWIGEXPORT(void) SWIG_init (pTHXo_ CV* cv);
+SWIGEXPORT(void) SWIG_init(pTHXo_ CV * cv);
 #endif
 #else
-SWIGEXPORT(void) SWIG_init (CV *cv, CPerlObj *);
+SWIGEXPORT(void) SWIG_init(CV * cv, CPerlObj *);
 #endif
 
-extern void fs_core_set_globals(void);
-extern int fs_core_init(char *);
-extern int fs_core_destroy(void);
-extern int fs_loadable_module_init(void);
-extern int fs_loadable_module_shutdown(void);
-extern int fs_console_loop(void);
-extern void fs_consol_log(char *,char *);
-extern void fs_consol_clean(char *);
-extern switch_core_session_t *fs_core_session_locate(char *);
-extern void fs_channel_answer(switch_core_session_t *);
-extern void fs_channel_pre_answer(switch_core_session_t *);
-extern void fs_channel_hangup(switch_core_session_t *,char *);
-extern void fs_channel_set_variable(switch_core_session_t *,char *,char *);
-extern void fs_channel_get_variable(switch_core_session_t *,char *);
-extern void fs_channel_set_state(switch_core_session_t *,char *);
-extern int fs_ivr_play_file(switch_core_session_t *,char *);
-extern int fs_switch_ivr_record_file(switch_core_session_t *,switch_file_handle_t *,char *,switch_input_callback_function_t,void *,unsigned int,unsigned int);
-extern int fs_switch_ivr_sleep(switch_core_session_t *,uint32_t);
-extern int fs_ivr_play_file2(switch_core_session_t *,char *);
-extern int fs_switch_ivr_collect_digits_callback(switch_core_session_t *,switch_input_callback_function_t,void *,unsigned int,unsigned int);
-extern int fs_switch_ivr_collect_digits_count(switch_core_session_t *,char *,unsigned int,unsigned int,char const *,char *,unsigned int);
-extern int fs_switch_ivr_originate(switch_core_session_t *,switch_core_session_t **,char *,uint32_t);
-extern int fs_switch_ivr_session_transfer(switch_core_session_t *,char *,char *,char *);
-extern int fs_switch_ivr_speak_text(switch_core_session_t *,char *,char *,uint32_t,char *);
-extern char *fs_switch_channel_get_variable(switch_channel_t *,char *);
-extern int fs_switch_channel_set_variable(switch_channel_t *,char *,char *);
+	 extern void fs_core_set_globals(void);
+	 extern int fs_core_init(char *);
+	 extern int fs_core_destroy(void);
+	 extern int fs_loadable_module_init(void);
+	 extern int fs_loadable_module_shutdown(void);
+	 extern int fs_console_loop(void);
+	 extern void fs_consol_log(char *, char *);
+	 extern void fs_consol_clean(char *);
+	 extern switch_core_session_t *fs_core_session_locate(char *);
+	 extern void fs_channel_answer(switch_core_session_t *);
+	 extern void fs_channel_pre_answer(switch_core_session_t *);
+	 extern void fs_channel_hangup(switch_core_session_t *, char *);
+	 extern void fs_channel_set_variable(switch_core_session_t *, char *, char *);
+	 extern void fs_channel_get_variable(switch_core_session_t *, char *);
+	 extern void fs_channel_set_state(switch_core_session_t *, char *);
+	 extern int fs_ivr_play_file(switch_core_session_t *, char *);
+	 extern int fs_switch_ivr_record_file(switch_core_session_t *, switch_file_handle_t *, char *,
+										  switch_input_callback_function_t, void *, unsigned int, unsigned int);
+	 extern int fs_switch_ivr_sleep(switch_core_session_t *, uint32_t);
+	 extern int fs_ivr_play_file2(switch_core_session_t *, char *);
+	 extern int fs_switch_ivr_collect_digits_callback(switch_core_session_t *, switch_input_callback_function_t, void *,
+													  unsigned int, unsigned int);
+	 extern int fs_switch_ivr_collect_digits_count(switch_core_session_t *, char *, unsigned int, unsigned int,
+												   char const *, char *, unsigned int);
+	 extern int fs_switch_ivr_originate(switch_core_session_t *, switch_core_session_t **, char *, uint32_t);
+	 extern int fs_switch_ivr_session_transfer(switch_core_session_t *, char *, char *, char *);
+	 extern int fs_switch_ivr_speak_text(switch_core_session_t *, char *, char *, uint32_t, char *);
+	 extern char *fs_switch_channel_get_variable(switch_channel_t *, char *);
+	 extern int fs_switch_channel_set_variable(switch_channel_t *, char *, char *);
 
 #include "switch.h"
 
 #ifdef PERL_OBJECT
 #define MAGIC_CLASS _wrap_fs_perl_var::
-class _wrap_fs_perl_var : public CPerlObj {
-public:
+	 class _wrap_fs_perl_var:public CPerlObj {
+	   public:
 #else
 #define MAGIC_CLASS
 #endif
-SWIGCLASS_STATIC int swig_magic_readonly(pTHX_ SV *sv, MAGIC *mg) {
-    MAGIC_PPERL
-    sv = sv; mg = mg;
-    croak("Value is read-only.");
-    return 0;
+	 SWIGCLASS_STATIC int swig_magic_readonly(pTHX_ SV * sv, MAGIC * mg)
+{
+	MAGIC_PPERL sv = sv;
+	mg = mg;
+	croak("Value is read-only.");
+	return 0;
 }
 
 
@@ -843,917 +856,990 @@ SWIGCLASS_STATIC int swig_magic_readonly(pTHX_ SV *sv, MAGIC *mg) {
 #ifdef __cplusplus
 extern "C" {
 #endif
-XS(_wrap_fs_core_set_globals) {
-    {
-        int argvi = 0;
-        dXSARGS;
-        
-        if ((items < 0) || (items > 0)) {
-            SWIG_croak("Usage: fs_core_set_globals();");
-        }
-        fs_core_set_globals();
-        
-        
-        XSRETURN(argvi);
-        fail:
-        ;
-    }
-    croak(Nullch);
-}
+	XS(_wrap_fs_core_set_globals) {
+		{
+			int argvi = 0;
+			    dXSARGS;
+
+			if  ((items < 0) || (items > 0)) {
+				SWIG_croak("Usage: fs_core_set_globals();");
+			}
+			fs_core_set_globals();
 
 
-XS(_wrap_fs_core_init) {
-    {
-        char *arg1 ;
-        int result;
-        int argvi = 0;
-        dXSARGS;
-        
-        if ((items < 1) || (items > 1)) {
-            SWIG_croak("Usage: fs_core_init(path);");
-        }
-        if (!SvOK((SV*) ST(0))) arg1 = 0;
-        else arg1 = (char *) SvPV(ST(0), PL_na);
-        result = (int)fs_core_init(arg1);
-        
-        ST(argvi) = sv_newmortal();
-        sv_setiv(ST(argvi++), (IV) result);
-        XSRETURN(argvi);
-        fail:
-        ;
-    }
-    croak(Nullch);
-}
+			XSRETURN(argvi);
+		  fail:
+			;
+		}
+		croak(Nullch);
+	}
 
 
-XS(_wrap_fs_core_destroy) {
-    {
-        int result;
-        int argvi = 0;
-        dXSARGS;
-        
-        if ((items < 0) || (items > 0)) {
-            SWIG_croak("Usage: fs_core_destroy();");
-        }
-        result = (int)fs_core_destroy();
-        
-        ST(argvi) = sv_newmortal();
-        sv_setiv(ST(argvi++), (IV) result);
-        XSRETURN(argvi);
-        fail:
-        ;
-    }
-    croak(Nullch);
-}
+	XS(_wrap_fs_core_init) {
+		{
+			char *arg1;
+			int result;
+			int argvi = 0;
+			dXSARGS;
+
+			if ((items < 1) || (items > 1)) {
+				SWIG_croak("Usage: fs_core_init(path);");
+			}
+			if (!SvOK((SV *) ST(0)))
+				arg1 = 0;
+			else
+				arg1 = (char *) SvPV(ST(0), PL_na);
+			result = (int) fs_core_init(arg1);
+
+			ST(argvi) = sv_newmortal();
+			sv_setiv(ST(argvi++), (IV) result);
+			XSRETURN(argvi);
+		  fail:
+			;
+		}
+		croak(Nullch);
+	}
 
 
-XS(_wrap_fs_loadable_module_init) {
-    {
-        int result;
-        int argvi = 0;
-        dXSARGS;
-        
-        if ((items < 0) || (items > 0)) {
-            SWIG_croak("Usage: fs_loadable_module_init();");
-        }
-        result = (int)fs_loadable_module_init();
-        
-        ST(argvi) = sv_newmortal();
-        sv_setiv(ST(argvi++), (IV) result);
-        XSRETURN(argvi);
-        fail:
-        ;
-    }
-    croak(Nullch);
-}
+	XS(_wrap_fs_core_destroy) {
+		{
+			int result;
+			int argvi = 0;
+			dXSARGS;
+
+			if ((items < 0) || (items > 0)) {
+				SWIG_croak("Usage: fs_core_destroy();");
+			}
+			result = (int) fs_core_destroy();
+
+			ST(argvi) = sv_newmortal();
+			sv_setiv(ST(argvi++), (IV) result);
+			XSRETURN(argvi);
+		  fail:
+			;
+		}
+		croak(Nullch);
+	}
 
 
-XS(_wrap_fs_loadable_module_shutdown) {
-    {
-        int result;
-        int argvi = 0;
-        dXSARGS;
-        
-        if ((items < 0) || (items > 0)) {
-            SWIG_croak("Usage: fs_loadable_module_shutdown();");
-        }
-        result = (int)fs_loadable_module_shutdown();
-        
-        ST(argvi) = sv_newmortal();
-        sv_setiv(ST(argvi++), (IV) result);
-        XSRETURN(argvi);
-        fail:
-        ;
-    }
-    croak(Nullch);
-}
+	XS(_wrap_fs_loadable_module_init) {
+		{
+			int result;
+			int argvi = 0;
+			dXSARGS;
+
+			if ((items < 0) || (items > 0)) {
+				SWIG_croak("Usage: fs_loadable_module_init();");
+			}
+			result = (int) fs_loadable_module_init();
+
+			ST(argvi) = sv_newmortal();
+			sv_setiv(ST(argvi++), (IV) result);
+			XSRETURN(argvi);
+		  fail:
+			;
+		}
+		croak(Nullch);
+	}
 
 
-XS(_wrap_fs_console_loop) {
-    {
-        int result;
-        int argvi = 0;
-        dXSARGS;
-        
-        if ((items < 0) || (items > 0)) {
-            SWIG_croak("Usage: fs_console_loop();");
-        }
-        result = (int)fs_console_loop();
-        
-        ST(argvi) = sv_newmortal();
-        sv_setiv(ST(argvi++), (IV) result);
-        XSRETURN(argvi);
-        fail:
-        ;
-    }
-    croak(Nullch);
-}
+	XS(_wrap_fs_loadable_module_shutdown) {
+		{
+			int result;
+			int argvi = 0;
+			dXSARGS;
+
+			if ((items < 0) || (items > 0)) {
+				SWIG_croak("Usage: fs_loadable_module_shutdown();");
+			}
+			result = (int) fs_loadable_module_shutdown();
+
+			ST(argvi) = sv_newmortal();
+			sv_setiv(ST(argvi++), (IV) result);
+			XSRETURN(argvi);
+		  fail:
+			;
+		}
+		croak(Nullch);
+	}
 
 
-XS(_wrap_fs_consol_log) {
-    {
-        char *arg1 ;
-        char *arg2 ;
-        int argvi = 0;
-        dXSARGS;
-        
-        if ((items < 2) || (items > 2)) {
-            SWIG_croak("Usage: fs_consol_log(level_str,msg);");
-        }
-        if (!SvOK((SV*) ST(0))) arg1 = 0;
-        else arg1 = (char *) SvPV(ST(0), PL_na);
-        if (!SvOK((SV*) ST(1))) arg2 = 0;
-        else arg2 = (char *) SvPV(ST(1), PL_na);
-        fs_consol_log(arg1,arg2);
-        
-        
-        XSRETURN(argvi);
-        fail:
-        ;
-    }
-    croak(Nullch);
-}
+	XS(_wrap_fs_console_loop) {
+		{
+			int result;
+			int argvi = 0;
+			dXSARGS;
+
+			if ((items < 0) || (items > 0)) {
+				SWIG_croak("Usage: fs_console_loop();");
+			}
+			result = (int) fs_console_loop();
+
+			ST(argvi) = sv_newmortal();
+			sv_setiv(ST(argvi++), (IV) result);
+			XSRETURN(argvi);
+		  fail:
+			;
+		}
+		croak(Nullch);
+	}
 
 
-XS(_wrap_fs_consol_clean) {
-    {
-        char *arg1 ;
-        int argvi = 0;
-        dXSARGS;
-        
-        if ((items < 1) || (items > 1)) {
-            SWIG_croak("Usage: fs_consol_clean(msg);");
-        }
-        if (!SvOK((SV*) ST(0))) arg1 = 0;
-        else arg1 = (char *) SvPV(ST(0), PL_na);
-        fs_consol_clean(arg1);
-        
-        
-        XSRETURN(argvi);
-        fail:
-        ;
-    }
-    croak(Nullch);
-}
+	XS(_wrap_fs_consol_log) {
+		{
+			char *arg1;
+			char *arg2;
+			int argvi = 0;
+			dXSARGS;
+
+			if ((items < 2) || (items > 2)) {
+				SWIG_croak("Usage: fs_consol_log(level_str,msg);");
+			}
+			if (!SvOK((SV *) ST(0)))
+				arg1 = 0;
+			else
+				arg1 = (char *) SvPV(ST(0), PL_na);
+			if (!SvOK((SV *) ST(1)))
+				arg2 = 0;
+			else
+				arg2 = (char *) SvPV(ST(1), PL_na);
+			fs_consol_log(arg1, arg2);
 
 
-XS(_wrap_fs_core_session_locate) {
-    {
-        char *arg1 ;
-        switch_core_session_t *result;
-        int argvi = 0;
-        dXSARGS;
-        
-        if ((items < 1) || (items > 1)) {
-            SWIG_croak("Usage: fs_core_session_locate(uuid);");
-        }
-        if (!SvOK((SV*) ST(0))) arg1 = 0;
-        else arg1 = (char *) SvPV(ST(0), PL_na);
-        result = (switch_core_session_t *)fs_core_session_locate(arg1);
-        
-        ST(argvi) = sv_newmortal();
-        SWIG_MakePtr(ST(argvi++), (void *) result, SWIGTYPE_p_switch_core_session_t, 0|0);
-        XSRETURN(argvi);
-        fail:
-        ;
-    }
-    croak(Nullch);
-}
+			XSRETURN(argvi);
+		  fail:
+			;
+		}
+		croak(Nullch);
+	}
 
 
-XS(_wrap_fs_channel_answer) {
-    {
-        switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
-        int argvi = 0;
-        dXSARGS;
-        
-        if ((items < 1) || (items > 1)) {
-            SWIG_croak("Usage: fs_channel_answer(session);");
-        }
-        {
-            if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session_t,0) < 0) {
-                SWIG_croak("Type error in argument 1 of fs_channel_answer. Expected _p_switch_core_session_t");
-            }
-        }
-        fs_channel_answer(arg1);
-        
-        
-        XSRETURN(argvi);
-        fail:
-        ;
-    }
-    croak(Nullch);
-}
+	XS(_wrap_fs_consol_clean) {
+		{
+			char *arg1;
+			int argvi = 0;
+			dXSARGS;
+
+			if ((items < 1) || (items > 1)) {
+				SWIG_croak("Usage: fs_consol_clean(msg);");
+			}
+			if (!SvOK((SV *) ST(0)))
+				arg1 = 0;
+			else
+				arg1 = (char *) SvPV(ST(0), PL_na);
+			fs_consol_clean(arg1);
 
 
-XS(_wrap_fs_channel_pre_answer) {
-    {
-        switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
-        int argvi = 0;
-        dXSARGS;
-        
-        if ((items < 1) || (items > 1)) {
-            SWIG_croak("Usage: fs_channel_pre_answer(session);");
-        }
-        {
-            if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session_t,0) < 0) {
-                SWIG_croak("Type error in argument 1 of fs_channel_pre_answer. Expected _p_switch_core_session_t");
-            }
-        }
-        fs_channel_pre_answer(arg1);
-        
-        
-        XSRETURN(argvi);
-        fail:
-        ;
-    }
-    croak(Nullch);
-}
+			XSRETURN(argvi);
+		  fail:
+			;
+		}
+		croak(Nullch);
+	}
 
 
-XS(_wrap_fs_channel_hangup) {
-    {
-        switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
-        char *arg2 ;
-        int argvi = 0;
-        dXSARGS;
-        
-        if ((items < 2) || (items > 2)) {
-            SWIG_croak("Usage: fs_channel_hangup(session,cause);");
-        }
-        {
-            if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session_t,0) < 0) {
-                SWIG_croak("Type error in argument 1 of fs_channel_hangup. Expected _p_switch_core_session_t");
-            }
-        }
-        if (!SvOK((SV*) ST(1))) arg2 = 0;
-        else arg2 = (char *) SvPV(ST(1), PL_na);
-        fs_channel_hangup(arg1,arg2);
-        
-        
-        XSRETURN(argvi);
-        fail:
-        ;
-    }
-    croak(Nullch);
-}
+	XS(_wrap_fs_core_session_locate) {
+		{
+			char *arg1;
+			switch_core_session_t *result;
+			int argvi = 0;
+			dXSARGS;
+
+			if ((items < 1) || (items > 1)) {
+				SWIG_croak("Usage: fs_core_session_locate(uuid);");
+			}
+			if (!SvOK((SV *) ST(0)))
+				arg1 = 0;
+			else
+				arg1 = (char *) SvPV(ST(0), PL_na);
+			result = (switch_core_session_t *) fs_core_session_locate(arg1);
+
+			ST(argvi) = sv_newmortal();
+			SWIG_MakePtr(ST(argvi++), (void *) result, SWIGTYPE_p_switch_core_session_t, 0 | 0);
+			XSRETURN(argvi);
+		  fail:
+			;
+		}
+		croak(Nullch);
+	}
 
 
-XS(_wrap_fs_channel_set_variable) {
-    {
-        switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
-        char *arg2 ;
-        char *arg3 ;
-        int argvi = 0;
-        dXSARGS;
-        
-        if ((items < 3) || (items > 3)) {
-            SWIG_croak("Usage: fs_channel_set_variable(session,var,val);");
-        }
-        {
-            if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session_t,0) < 0) {
-                SWIG_croak("Type error in argument 1 of fs_channel_set_variable. Expected _p_switch_core_session_t");
-            }
-        }
-        if (!SvOK((SV*) ST(1))) arg2 = 0;
-        else arg2 = (char *) SvPV(ST(1), PL_na);
-        if (!SvOK((SV*) ST(2))) arg3 = 0;
-        else arg3 = (char *) SvPV(ST(2), PL_na);
-        fs_channel_set_variable(arg1,arg2,arg3);
-        
-        
-        XSRETURN(argvi);
-        fail:
-        ;
-    }
-    croak(Nullch);
-}
+	XS(_wrap_fs_channel_answer) {
+		{
+			switch_core_session_t *arg1 = (switch_core_session_t *) 0;
+			int argvi = 0;
+			dXSARGS;
+
+			if ((items < 1) || (items > 1)) {
+				SWIG_croak("Usage: fs_channel_answer(session);");
+			}
+			{
+				if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session_t, 0) < 0) {
+					SWIG_croak("Type error in argument 1 of fs_channel_answer. Expected _p_switch_core_session_t");
+				}
+			}
+			fs_channel_answer(arg1);
 
 
-XS(_wrap_fs_channel_get_variable) {
-    {
-        switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
-        char *arg2 ;
-        int argvi = 0;
-        dXSARGS;
-        
-        if ((items < 2) || (items > 2)) {
-            SWIG_croak("Usage: fs_channel_get_variable(session,var);");
-        }
-        {
-            if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session_t,0) < 0) {
-                SWIG_croak("Type error in argument 1 of fs_channel_get_variable. Expected _p_switch_core_session_t");
-            }
-        }
-        if (!SvOK((SV*) ST(1))) arg2 = 0;
-        else arg2 = (char *) SvPV(ST(1), PL_na);
-        fs_channel_get_variable(arg1,arg2);
-        
-        
-        XSRETURN(argvi);
-        fail:
-        ;
-    }
-    croak(Nullch);
-}
+			XSRETURN(argvi);
+		  fail:
+			;
+		}
+		croak(Nullch);
+	}
 
 
-XS(_wrap_fs_channel_set_state) {
-    {
-        switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
-        char *arg2 ;
-        int argvi = 0;
-        dXSARGS;
-        
-        if ((items < 2) || (items > 2)) {
-            SWIG_croak("Usage: fs_channel_set_state(session,state);");
-        }
-        {
-            if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session_t,0) < 0) {
-                SWIG_croak("Type error in argument 1 of fs_channel_set_state. Expected _p_switch_core_session_t");
-            }
-        }
-        if (!SvOK((SV*) ST(1))) arg2 = 0;
-        else arg2 = (char *) SvPV(ST(1), PL_na);
-        fs_channel_set_state(arg1,arg2);
-        
-        
-        XSRETURN(argvi);
-        fail:
-        ;
-    }
-    croak(Nullch);
-}
+	XS(_wrap_fs_channel_pre_answer) {
+		{
+			switch_core_session_t *arg1 = (switch_core_session_t *) 0;
+			int argvi = 0;
+			dXSARGS;
+
+			if ((items < 1) || (items > 1)) {
+				SWIG_croak("Usage: fs_channel_pre_answer(session);");
+			}
+			{
+				if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session_t, 0) < 0) {
+					SWIG_croak("Type error in argument 1 of fs_channel_pre_answer. Expected _p_switch_core_session_t");
+				}
+			}
+			fs_channel_pre_answer(arg1);
 
 
-XS(_wrap_fs_ivr_play_file) {
-    {
-        switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
-        char *arg2 ;
-        int result;
-        int argvi = 0;
-        dXSARGS;
-        
-        if ((items < 2) || (items > 2)) {
-            SWIG_croak("Usage: fs_ivr_play_file(session,file);");
-        }
-        {
-            if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session_t,0) < 0) {
-                SWIG_croak("Type error in argument 1 of fs_ivr_play_file. Expected _p_switch_core_session_t");
-            }
-        }
-        if (!SvOK((SV*) ST(1))) arg2 = 0;
-        else arg2 = (char *) SvPV(ST(1), PL_na);
-        result = (int)fs_ivr_play_file(arg1,arg2);
-        
-        ST(argvi) = sv_newmortal();
-        sv_setiv(ST(argvi++), (IV) result);
-        XSRETURN(argvi);
-        fail:
-        ;
-    }
-    croak(Nullch);
-}
+			XSRETURN(argvi);
+		  fail:
+			;
+		}
+		croak(Nullch);
+	}
 
 
-XS(_wrap_fs_switch_ivr_record_file) {
-    {
-        switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
-        switch_file_handle_t *arg2 = (switch_file_handle_t *) 0 ;
-        char *arg3 ;
-        switch_input_callback_function_t arg4 ;
-        void *arg5 = (void *) 0 ;
-        unsigned int arg6 ;
-        unsigned int arg7 ;
-        int result;
-        int argvi = 0;
-        dXSARGS;
-        
-        if ((items < 7) || (items > 7)) {
-            SWIG_croak("Usage: fs_switch_ivr_record_file(session,fh,file,dtmf_callback,buf,buflen,limit);");
-        }
-        {
-            if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session_t,0) < 0) {
-                SWIG_croak("Type error in argument 1 of fs_switch_ivr_record_file. Expected _p_switch_core_session_t");
-            }
-        }
-        {
-            if (SWIG_ConvertPtr(ST(1), (void **) &arg2, SWIGTYPE_p_switch_file_handle_t,0) < 0) {
-                SWIG_croak("Type error in argument 2 of fs_switch_ivr_record_file. Expected _p_switch_file_handle_t");
-            }
-        }
-        if (!SvOK((SV*) ST(2))) arg3 = 0;
-        else arg3 = (char *) SvPV(ST(2), PL_na);
-        {
-            switch_input_callback_function_t * argp;
-            if (SWIG_ConvertPtr(ST(3),(void **) &argp, SWIGTYPE_p_switch_input_callback_function_t,0) < 0) {
-                SWIG_croak("Type error in argument 4 of fs_switch_ivr_record_file. Expected _p_switch_input_callback_function_t");
-            }
-            arg4 = *argp;
-        }
-        {
-            if (SWIG_ConvertPtr(ST(4), (void **) &arg5, 0,0) < 0) {
-                SWIG_croak("Type error in argument 5 of fs_switch_ivr_record_file. Expected _p_void");
-            }
-        }
-        arg6 = (unsigned int) SvUV(ST(5));
-        arg7 = (unsigned int) SvUV(ST(6));
-        result = (int)fs_switch_ivr_record_file(arg1,arg2,arg3,arg4,arg5,arg6,arg7);
-        
-        ST(argvi) = sv_newmortal();
-        sv_setiv(ST(argvi++), (IV) result);
-        XSRETURN(argvi);
-        fail:
-        ;
-    }
-    croak(Nullch);
-}
+	XS(_wrap_fs_channel_hangup) {
+		{
+			switch_core_session_t *arg1 = (switch_core_session_t *) 0;
+			char *arg2;
+			int argvi = 0;
+			dXSARGS;
+
+			if ((items < 2) || (items > 2)) {
+				SWIG_croak("Usage: fs_channel_hangup(session,cause);");
+			}
+			{
+				if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session_t, 0) < 0) {
+					SWIG_croak("Type error in argument 1 of fs_channel_hangup. Expected _p_switch_core_session_t");
+				}
+			}
+			if (!SvOK((SV *) ST(1)))
+				arg2 = 0;
+			else
+				arg2 = (char *) SvPV(ST(1), PL_na);
+			fs_channel_hangup(arg1, arg2);
 
 
-XS(_wrap_fs_switch_ivr_sleep) {
-    {
-        switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
-        uint32_t arg2 ;
-        int result;
-        int argvi = 0;
-        dXSARGS;
-        
-        if ((items < 2) || (items > 2)) {
-            SWIG_croak("Usage: fs_switch_ivr_sleep(session,ms);");
-        }
-        {
-            if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session_t,0) < 0) {
-                SWIG_croak("Type error in argument 1 of fs_switch_ivr_sleep. Expected _p_switch_core_session_t");
-            }
-        }
-        {
-            uint32_t * argp;
-            if (SWIG_ConvertPtr(ST(1),(void **) &argp, SWIGTYPE_p_uint32_t,0) < 0) {
-                SWIG_croak("Type error in argument 2 of fs_switch_ivr_sleep. Expected _p_uint32_t");
-            }
-            arg2 = *argp;
-        }
-        result = (int)fs_switch_ivr_sleep(arg1,arg2);
-        
-        ST(argvi) = sv_newmortal();
-        sv_setiv(ST(argvi++), (IV) result);
-        XSRETURN(argvi);
-        fail:
-        ;
-    }
-    croak(Nullch);
-}
+			XSRETURN(argvi);
+		  fail:
+			;
+		}
+		croak(Nullch);
+	}
 
 
-XS(_wrap_fs_ivr_play_file2) {
-    {
-        switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
-        char *arg2 ;
-        int result;
-        int argvi = 0;
-        dXSARGS;
-        
-        if ((items < 2) || (items > 2)) {
-            SWIG_croak("Usage: fs_ivr_play_file2(session,file);");
-        }
-        {
-            if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session_t,0) < 0) {
-                SWIG_croak("Type error in argument 1 of fs_ivr_play_file2. Expected _p_switch_core_session_t");
-            }
-        }
-        if (!SvOK((SV*) ST(1))) arg2 = 0;
-        else arg2 = (char *) SvPV(ST(1), PL_na);
-        result = (int)fs_ivr_play_file2(arg1,arg2);
-        
-        ST(argvi) = sv_newmortal();
-        sv_setiv(ST(argvi++), (IV) result);
-        XSRETURN(argvi);
-        fail:
-        ;
-    }
-    croak(Nullch);
-}
+	XS(_wrap_fs_channel_set_variable) {
+		{
+			switch_core_session_t *arg1 = (switch_core_session_t *) 0;
+			char *arg2;
+			char *arg3;
+			int argvi = 0;
+			dXSARGS;
+
+			if ((items < 3) || (items > 3)) {
+				SWIG_croak("Usage: fs_channel_set_variable(session,var,val);");
+			}
+			{
+				if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session_t, 0) < 0) {
+					SWIG_croak
+						("Type error in argument 1 of fs_channel_set_variable. Expected _p_switch_core_session_t");
+				}
+			}
+			if (!SvOK((SV *) ST(1)))
+				arg2 = 0;
+			else
+				arg2 = (char *) SvPV(ST(1), PL_na);
+			if (!SvOK((SV *) ST(2)))
+				arg3 = 0;
+			else
+				arg3 = (char *) SvPV(ST(2), PL_na);
+			fs_channel_set_variable(arg1, arg2, arg3);
 
 
-XS(_wrap_fs_switch_ivr_collect_digits_callback) {
-    {
-        switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
-        switch_input_callback_function_t arg2 ;
-        void *arg3 = (void *) 0 ;
-        unsigned int arg4 ;
-        unsigned int arg5 ;
-        int result;
-        int argvi = 0;
-        dXSARGS;
-        
-        if ((items < 5) || (items > 5)) {
-            SWIG_croak("Usage: fs_switch_ivr_collect_digits_callback(session,dtmf_callback,buf,buflen,timeout);");
-        }
-        {
-            if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session_t,0) < 0) {
-                SWIG_croak("Type error in argument 1 of fs_switch_ivr_collect_digits_callback. Expected _p_switch_core_session_t");
-            }
-        }
-        {
-            switch_input_callback_function_t * argp;
-            if (SWIG_ConvertPtr(ST(1),(void **) &argp, SWIGTYPE_p_switch_input_callback_function_t,0) < 0) {
-                SWIG_croak("Type error in argument 2 of fs_switch_ivr_collect_digits_callback. Expected _p_switch_input_callback_function_t");
-            }
-            arg2 = *argp;
-        }
-        {
-            if (SWIG_ConvertPtr(ST(2), (void **) &arg3, 0,0) < 0) {
-                SWIG_croak("Type error in argument 3 of fs_switch_ivr_collect_digits_callback. Expected _p_void");
-            }
-        }
-        arg4 = (unsigned int) SvUV(ST(3));
-        arg5 = (unsigned int) SvUV(ST(4));
-        result = (int)fs_switch_ivr_collect_digits_callback(arg1,arg2,arg3,arg4,arg5);
-        
-        ST(argvi) = sv_newmortal();
-        sv_setiv(ST(argvi++), (IV) result);
-        XSRETURN(argvi);
-        fail:
-        ;
-    }
-    croak(Nullch);
-}
+			XSRETURN(argvi);
+		  fail:
+			;
+		}
+		croak(Nullch);
+	}
 
 
-XS(_wrap_fs_switch_ivr_collect_digits_count) {
-    {
-        switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
-        char *arg2 ;
-        unsigned int arg3 ;
-        unsigned int arg4 ;
-        char *arg5 ;
-        char *arg6 ;
-        unsigned int arg7 ;
-        int result;
-        int argvi = 0;
-        dXSARGS;
-        
-        if ((items < 7) || (items > 7)) {
-            SWIG_croak("Usage: fs_switch_ivr_collect_digits_count(session,buf,buflen,maxdigits,terminators,terminator,timeout);");
-        }
-        {
-            if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session_t,0) < 0) {
-                SWIG_croak("Type error in argument 1 of fs_switch_ivr_collect_digits_count. Expected _p_switch_core_session_t");
-            }
-        }
-        if (!SvOK((SV*) ST(1))) arg2 = 0;
-        else arg2 = (char *) SvPV(ST(1), PL_na);
-        arg3 = (unsigned int) SvUV(ST(2));
-        arg4 = (unsigned int) SvUV(ST(3));
-        if (!SvOK((SV*) ST(4))) arg5 = 0;
-        else arg5 = (char *) SvPV(ST(4), PL_na);
-        if (!SvOK((SV*) ST(5))) arg6 = 0;
-        else arg6 = (char *) SvPV(ST(5), PL_na);
-        arg7 = (unsigned int) SvUV(ST(6));
-        result = (int)fs_switch_ivr_collect_digits_count(arg1,arg2,arg3,arg4,(char const *)arg5,arg6,arg7);
-        
-        ST(argvi) = sv_newmortal();
-        sv_setiv(ST(argvi++), (IV) result);
-        XSRETURN(argvi);
-        fail:
-        ;
-    }
-    croak(Nullch);
-}
+	XS(_wrap_fs_channel_get_variable) {
+		{
+			switch_core_session_t *arg1 = (switch_core_session_t *) 0;
+			char *arg2;
+			int argvi = 0;
+			dXSARGS;
+
+			if ((items < 2) || (items > 2)) {
+				SWIG_croak("Usage: fs_channel_get_variable(session,var);");
+			}
+			{
+				if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session_t, 0) < 0) {
+					SWIG_croak
+						("Type error in argument 1 of fs_channel_get_variable. Expected _p_switch_core_session_t");
+				}
+			}
+			if (!SvOK((SV *) ST(1)))
+				arg2 = 0;
+			else
+				arg2 = (char *) SvPV(ST(1), PL_na);
+			fs_channel_get_variable(arg1, arg2);
 
 
-XS(_wrap_fs_switch_ivr_originate) {
-    {
-        switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
-        switch_core_session_t **arg2 = (switch_core_session_t **) 0 ;
-        char *arg3 ;
-        uint32_t arg4 ;
-        int result;
-        int argvi = 0;
-        dXSARGS;
-        
-        if ((items < 4) || (items > 4)) {
-            SWIG_croak("Usage: fs_switch_ivr_originate(session,bleg,bridgeto,timelimit_sec);");
-        }
-        {
-            if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session_t,0) < 0) {
-                SWIG_croak("Type error in argument 1 of fs_switch_ivr_originate. Expected _p_switch_core_session_t");
-            }
-        }
-        {
-            if (SWIG_ConvertPtr(ST(1), (void **) &arg2, SWIGTYPE_p_p_switch_core_session_t,0) < 0) {
-                SWIG_croak("Type error in argument 2 of fs_switch_ivr_originate. Expected _p_p_switch_core_session_t");
-            }
-        }
-        if (!SvOK((SV*) ST(2))) arg3 = 0;
-        else arg3 = (char *) SvPV(ST(2), PL_na);
-        {
-            uint32_t * argp;
-            if (SWIG_ConvertPtr(ST(3),(void **) &argp, SWIGTYPE_p_uint32_t,0) < 0) {
-                SWIG_croak("Type error in argument 4 of fs_switch_ivr_originate. Expected _p_uint32_t");
-            }
-            arg4 = *argp;
-        }
-        result = (int)fs_switch_ivr_originate(arg1,arg2,arg3,arg4);
-        
-        ST(argvi) = sv_newmortal();
-        sv_setiv(ST(argvi++), (IV) result);
-        XSRETURN(argvi);
-        fail:
-        ;
-    }
-    croak(Nullch);
-}
+			XSRETURN(argvi);
+		  fail:
+			;
+		}
+		croak(Nullch);
+	}
 
 
-XS(_wrap_fs_switch_ivr_session_transfer) {
-    {
-        switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
-        char *arg2 ;
-        char *arg3 ;
-        char *arg4 ;
-        int result;
-        int argvi = 0;
-        dXSARGS;
-        
-        if ((items < 4) || (items > 4)) {
-            SWIG_croak("Usage: fs_switch_ivr_session_transfer(session,extension,dialplan,context);");
-        }
-        {
-            if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session_t,0) < 0) {
-                SWIG_croak("Type error in argument 1 of fs_switch_ivr_session_transfer. Expected _p_switch_core_session_t");
-            }
-        }
-        if (!SvOK((SV*) ST(1))) arg2 = 0;
-        else arg2 = (char *) SvPV(ST(1), PL_na);
-        if (!SvOK((SV*) ST(2))) arg3 = 0;
-        else arg3 = (char *) SvPV(ST(2), PL_na);
-        if (!SvOK((SV*) ST(3))) arg4 = 0;
-        else arg4 = (char *) SvPV(ST(3), PL_na);
-        result = (int)fs_switch_ivr_session_transfer(arg1,arg2,arg3,arg4);
-        
-        ST(argvi) = sv_newmortal();
-        sv_setiv(ST(argvi++), (IV) result);
-        XSRETURN(argvi);
-        fail:
-        ;
-    }
-    croak(Nullch);
-}
+	XS(_wrap_fs_channel_set_state) {
+		{
+			switch_core_session_t *arg1 = (switch_core_session_t *) 0;
+			char *arg2;
+			int argvi = 0;
+			dXSARGS;
+
+			if ((items < 2) || (items > 2)) {
+				SWIG_croak("Usage: fs_channel_set_state(session,state);");
+			}
+			{
+				if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session_t, 0) < 0) {
+					SWIG_croak("Type error in argument 1 of fs_channel_set_state. Expected _p_switch_core_session_t");
+				}
+			}
+			if (!SvOK((SV *) ST(1)))
+				arg2 = 0;
+			else
+				arg2 = (char *) SvPV(ST(1), PL_na);
+			fs_channel_set_state(arg1, arg2);
 
 
-XS(_wrap_fs_switch_ivr_speak_text) {
-    {
-        switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
-        char *arg2 ;
-        char *arg3 ;
-        uint32_t arg4 ;
-        char *arg5 ;
-        int result;
-        int argvi = 0;
-        dXSARGS;
-        
-        if ((items < 5) || (items > 5)) {
-            SWIG_croak("Usage: fs_switch_ivr_speak_text(session,tts_name,voice_name,rate,text);");
-        }
-        {
-            if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session_t,0) < 0) {
-                SWIG_croak("Type error in argument 1 of fs_switch_ivr_speak_text. Expected _p_switch_core_session_t");
-            }
-        }
-        if (!SvOK((SV*) ST(1))) arg2 = 0;
-        else arg2 = (char *) SvPV(ST(1), PL_na);
-        if (!SvOK((SV*) ST(2))) arg3 = 0;
-        else arg3 = (char *) SvPV(ST(2), PL_na);
-        {
-            uint32_t * argp;
-            if (SWIG_ConvertPtr(ST(3),(void **) &argp, SWIGTYPE_p_uint32_t,0) < 0) {
-                SWIG_croak("Type error in argument 4 of fs_switch_ivr_speak_text. Expected _p_uint32_t");
-            }
-            arg4 = *argp;
-        }
-        if (!SvOK((SV*) ST(4))) arg5 = 0;
-        else arg5 = (char *) SvPV(ST(4), PL_na);
-        result = (int)fs_switch_ivr_speak_text(arg1,arg2,arg3,arg4,arg5);
-        
-        ST(argvi) = sv_newmortal();
-        sv_setiv(ST(argvi++), (IV) result);
-        XSRETURN(argvi);
-        fail:
-        ;
-    }
-    croak(Nullch);
-}
+			XSRETURN(argvi);
+		  fail:
+			;
+		}
+		croak(Nullch);
+	}
 
 
-XS(_wrap_fs_switch_channel_get_variable) {
-    {
-        switch_channel_t *arg1 = (switch_channel_t *) 0 ;
-        char *arg2 ;
-        char *result;
-        int argvi = 0;
-        dXSARGS;
-        
-        if ((items < 2) || (items > 2)) {
-            SWIG_croak("Usage: fs_switch_channel_get_variable(channel,varname);");
-        }
-        {
-            if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_channel_t,0) < 0) {
-                SWIG_croak("Type error in argument 1 of fs_switch_channel_get_variable. Expected _p_switch_channel_t");
-            }
-        }
-        if (!SvOK((SV*) ST(1))) arg2 = 0;
-        else arg2 = (char *) SvPV(ST(1), PL_na);
-        result = (char *)fs_switch_channel_get_variable(arg1,arg2);
-        
-        ST(argvi) = sv_newmortal();
-        if (result) {
-            sv_setpv((SV*)ST(argvi++), (char *) result);
-        } else {
-            sv_setsv((SV*)ST(argvi++), &PL_sv_undef);
-        }
-        XSRETURN(argvi);
-        fail:
-        ;
-    }
-    croak(Nullch);
-}
+	XS(_wrap_fs_ivr_play_file) {
+		{
+			switch_core_session_t *arg1 = (switch_core_session_t *) 0;
+			char *arg2;
+			int result;
+			int argvi = 0;
+			dXSARGS;
+
+			if ((items < 2) || (items > 2)) {
+				SWIG_croak("Usage: fs_ivr_play_file(session,file);");
+			}
+			{
+				if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session_t, 0) < 0) {
+					SWIG_croak("Type error in argument 1 of fs_ivr_play_file. Expected _p_switch_core_session_t");
+				}
+			}
+			if (!SvOK((SV *) ST(1)))
+				arg2 = 0;
+			else
+				arg2 = (char *) SvPV(ST(1), PL_na);
+			result = (int) fs_ivr_play_file(arg1, arg2);
+
+			ST(argvi) = sv_newmortal();
+			sv_setiv(ST(argvi++), (IV) result);
+			XSRETURN(argvi);
+		  fail:
+			;
+		}
+		croak(Nullch);
+	}
 
 
-XS(_wrap_fs_switch_channel_set_variable) {
-    {
-        switch_channel_t *arg1 = (switch_channel_t *) 0 ;
-        char *arg2 ;
-        char *arg3 ;
-        int result;
-        int argvi = 0;
-        dXSARGS;
-        
-        if ((items < 3) || (items > 3)) {
-            SWIG_croak("Usage: fs_switch_channel_set_variable(channel,varname,value);");
-        }
-        {
-            if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_channel_t,0) < 0) {
-                SWIG_croak("Type error in argument 1 of fs_switch_channel_set_variable. Expected _p_switch_channel_t");
-            }
-        }
-        if (!SvOK((SV*) ST(1))) arg2 = 0;
-        else arg2 = (char *) SvPV(ST(1), PL_na);
-        if (!SvOK((SV*) ST(2))) arg3 = 0;
-        else arg3 = (char *) SvPV(ST(2), PL_na);
-        result = (int)fs_switch_channel_set_variable(arg1,arg2,arg3);
-        
-        ST(argvi) = sv_newmortal();
-        sv_setiv(ST(argvi++), (IV) result);
-        XSRETURN(argvi);
-        fail:
-        ;
-    }
-    croak(Nullch);
-}
+	XS(_wrap_fs_switch_ivr_record_file) {
+		{
+			switch_core_session_t *arg1 = (switch_core_session_t *) 0;
+			switch_file_handle_t *arg2 = (switch_file_handle_t *) 0;
+			char *arg3;
+			switch_input_callback_function_t arg4;
+			void *arg5 = (void *) 0;
+			unsigned int arg6;
+			unsigned int arg7;
+			int result;
+			int argvi = 0;
+			dXSARGS;
+
+			if ((items < 7) || (items > 7)) {
+				SWIG_croak("Usage: fs_switch_ivr_record_file(session,fh,file,dtmf_callback,buf,buflen,limit);");
+			}
+			{
+				if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session_t, 0) < 0) {
+					SWIG_croak
+						("Type error in argument 1 of fs_switch_ivr_record_file. Expected _p_switch_core_session_t");
+				}
+			}
+			{
+				if (SWIG_ConvertPtr(ST(1), (void **) &arg2, SWIGTYPE_p_switch_file_handle_t, 0) < 0) {
+					SWIG_croak
+						("Type error in argument 2 of fs_switch_ivr_record_file. Expected _p_switch_file_handle_t");
+				}
+			}
+			if (!SvOK((SV *) ST(2)))
+				arg3 = 0;
+			else
+				arg3 = (char *) SvPV(ST(2), PL_na);
+			{
+				switch_input_callback_function_t *argp;
+				if (SWIG_ConvertPtr(ST(3), (void **) &argp, SWIGTYPE_p_switch_input_callback_function_t, 0) < 0) {
+					SWIG_croak
+						("Type error in argument 4 of fs_switch_ivr_record_file. Expected _p_switch_input_callback_function_t");
+				}
+				arg4 = *argp;
+			}
+			{
+				if (SWIG_ConvertPtr(ST(4), (void **) &arg5, 0, 0) < 0) {
+					SWIG_croak("Type error in argument 5 of fs_switch_ivr_record_file. Expected _p_void");
+				}
+			}
+			arg6 = (unsigned int) SvUV(ST(5));
+			arg7 = (unsigned int) SvUV(ST(6));
+			result = (int) fs_switch_ivr_record_file(arg1, arg2, arg3, arg4, arg5, arg6, arg7);
+
+			ST(argvi) = sv_newmortal();
+			sv_setiv(ST(argvi++), (IV) result);
+			XSRETURN(argvi);
+		  fail:
+			;
+		}
+		croak(Nullch);
+	}
+
+
+	XS(_wrap_fs_switch_ivr_sleep) {
+		{
+			switch_core_session_t *arg1 = (switch_core_session_t *) 0;
+			uint32_t arg2;
+			int result;
+			int argvi = 0;
+			dXSARGS;
+
+			if ((items < 2) || (items > 2)) {
+				SWIG_croak("Usage: fs_switch_ivr_sleep(session,ms);");
+			}
+			{
+				if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session_t, 0) < 0) {
+					SWIG_croak("Type error in argument 1 of fs_switch_ivr_sleep. Expected _p_switch_core_session_t");
+				}
+			}
+			{
+				uint32_t *argp;
+				if (SWIG_ConvertPtr(ST(1), (void **) &argp, SWIGTYPE_p_uint32_t, 0) < 0) {
+					SWIG_croak("Type error in argument 2 of fs_switch_ivr_sleep. Expected _p_uint32_t");
+				}
+				arg2 = *argp;
+			}
+			result = (int) fs_switch_ivr_sleep(arg1, arg2);
+
+			ST(argvi) = sv_newmortal();
+			sv_setiv(ST(argvi++), (IV) result);
+			XSRETURN(argvi);
+		  fail:
+			;
+		}
+		croak(Nullch);
+	}
+
+
+	XS(_wrap_fs_ivr_play_file2) {
+		{
+			switch_core_session_t *arg1 = (switch_core_session_t *) 0;
+			char *arg2;
+			int result;
+			int argvi = 0;
+			dXSARGS;
+
+			if ((items < 2) || (items > 2)) {
+				SWIG_croak("Usage: fs_ivr_play_file2(session,file);");
+			}
+			{
+				if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session_t, 0) < 0) {
+					SWIG_croak("Type error in argument 1 of fs_ivr_play_file2. Expected _p_switch_core_session_t");
+				}
+			}
+			if (!SvOK((SV *) ST(1)))
+				arg2 = 0;
+			else
+				arg2 = (char *) SvPV(ST(1), PL_na);
+			result = (int) fs_ivr_play_file2(arg1, arg2);
+
+			ST(argvi) = sv_newmortal();
+			sv_setiv(ST(argvi++), (IV) result);
+			XSRETURN(argvi);
+		  fail:
+			;
+		}
+		croak(Nullch);
+	}
+
+
+	XS(_wrap_fs_switch_ivr_collect_digits_callback) {
+		{
+			switch_core_session_t *arg1 = (switch_core_session_t *) 0;
+			switch_input_callback_function_t arg2;
+			void *arg3 = (void *) 0;
+			unsigned int arg4;
+			unsigned int arg5;
+			int result;
+			int argvi = 0;
+			dXSARGS;
+
+			if ((items < 5) || (items > 5)) {
+				SWIG_croak("Usage: fs_switch_ivr_collect_digits_callback(session,dtmf_callback,buf,buflen,timeout);");
+			}
+			{
+				if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session_t, 0) < 0) {
+					SWIG_croak
+						("Type error in argument 1 of fs_switch_ivr_collect_digits_callback. Expected _p_switch_core_session_t");
+				}
+			}
+			{
+				switch_input_callback_function_t *argp;
+				if (SWIG_ConvertPtr(ST(1), (void **) &argp, SWIGTYPE_p_switch_input_callback_function_t, 0) < 0) {
+					SWIG_croak
+						("Type error in argument 2 of fs_switch_ivr_collect_digits_callback. Expected _p_switch_input_callback_function_t");
+				}
+				arg2 = *argp;
+			}
+			{
+				if (SWIG_ConvertPtr(ST(2), (void **) &arg3, 0, 0) < 0) {
+					SWIG_croak("Type error in argument 3 of fs_switch_ivr_collect_digits_callback. Expected _p_void");
+				}
+			}
+			arg4 = (unsigned int) SvUV(ST(3));
+			arg5 = (unsigned int) SvUV(ST(4));
+			result = (int) fs_switch_ivr_collect_digits_callback(arg1, arg2, arg3, arg4, arg5);
+
+			ST(argvi) = sv_newmortal();
+			sv_setiv(ST(argvi++), (IV) result);
+			XSRETURN(argvi);
+		  fail:
+			;
+		}
+		croak(Nullch);
+	}
+
+
+	XS(_wrap_fs_switch_ivr_collect_digits_count) {
+		{
+			switch_core_session_t *arg1 = (switch_core_session_t *) 0;
+			char *arg2;
+			unsigned int arg3;
+			unsigned int arg4;
+			char *arg5;
+			char *arg6;
+			unsigned int arg7;
+			int result;
+			int argvi = 0;
+			dXSARGS;
+
+			if ((items < 7) || (items > 7)) {
+				SWIG_croak
+					("Usage: fs_switch_ivr_collect_digits_count(session,buf,buflen,maxdigits,terminators,terminator,timeout);");
+			}
+			{
+				if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session_t, 0) < 0) {
+					SWIG_croak
+						("Type error in argument 1 of fs_switch_ivr_collect_digits_count. Expected _p_switch_core_session_t");
+				}
+			}
+			if (!SvOK((SV *) ST(1)))
+				arg2 = 0;
+			else
+				arg2 = (char *) SvPV(ST(1), PL_na);
+			arg3 = (unsigned int) SvUV(ST(2));
+			arg4 = (unsigned int) SvUV(ST(3));
+			if (!SvOK((SV *) ST(4)))
+				arg5 = 0;
+			else
+				arg5 = (char *) SvPV(ST(4), PL_na);
+			if (!SvOK((SV *) ST(5)))
+				arg6 = 0;
+			else
+				arg6 = (char *) SvPV(ST(5), PL_na);
+			arg7 = (unsigned int) SvUV(ST(6));
+			result = (int) fs_switch_ivr_collect_digits_count(arg1, arg2, arg3, arg4, (char const *) arg5, arg6, arg7);
+
+			ST(argvi) = sv_newmortal();
+			sv_setiv(ST(argvi++), (IV) result);
+			XSRETURN(argvi);
+		  fail:
+			;
+		}
+		croak(Nullch);
+	}
+
+
+	XS(_wrap_fs_switch_ivr_originate) {
+		{
+			switch_core_session_t *arg1 = (switch_core_session_t *) 0;
+			switch_core_session_t **arg2 = (switch_core_session_t **) 0;
+			char *arg3;
+			uint32_t arg4;
+			int result;
+			int argvi = 0;
+			dXSARGS;
+
+			if ((items < 4) || (items > 4)) {
+				SWIG_croak("Usage: fs_switch_ivr_originate(session,bleg,bridgeto,timelimit_sec);");
+			}
+			{
+				if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session_t, 0) < 0) {
+					SWIG_croak
+						("Type error in argument 1 of fs_switch_ivr_originate. Expected _p_switch_core_session_t");
+				}
+			}
+			{
+				if (SWIG_ConvertPtr(ST(1), (void **) &arg2, SWIGTYPE_p_p_switch_core_session_t, 0) < 0) {
+					SWIG_croak
+						("Type error in argument 2 of fs_switch_ivr_originate. Expected _p_p_switch_core_session_t");
+				}
+			}
+			if (!SvOK((SV *) ST(2)))
+				arg3 = 0;
+			else
+				arg3 = (char *) SvPV(ST(2), PL_na);
+			{
+				uint32_t *argp;
+				if (SWIG_ConvertPtr(ST(3), (void **) &argp, SWIGTYPE_p_uint32_t, 0) < 0) {
+					SWIG_croak("Type error in argument 4 of fs_switch_ivr_originate. Expected _p_uint32_t");
+				}
+				arg4 = *argp;
+			}
+			result = (int) fs_switch_ivr_originate(arg1, arg2, arg3, arg4);
+
+			ST(argvi) = sv_newmortal();
+			sv_setiv(ST(argvi++), (IV) result);
+			XSRETURN(argvi);
+		  fail:
+			;
+		}
+		croak(Nullch);
+	}
+
+
+	XS(_wrap_fs_switch_ivr_session_transfer) {
+		{
+			switch_core_session_t *arg1 = (switch_core_session_t *) 0;
+			char *arg2;
+			char *arg3;
+			char *arg4;
+			int result;
+			int argvi = 0;
+			dXSARGS;
+
+			if ((items < 4) || (items > 4)) {
+				SWIG_croak("Usage: fs_switch_ivr_session_transfer(session,extension,dialplan,context);");
+			}
+			{
+				if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session_t, 0) < 0) {
+					SWIG_croak
+						("Type error in argument 1 of fs_switch_ivr_session_transfer. Expected _p_switch_core_session_t");
+				}
+			}
+			if (!SvOK((SV *) ST(1)))
+				arg2 = 0;
+			else
+				arg2 = (char *) SvPV(ST(1), PL_na);
+			if (!SvOK((SV *) ST(2)))
+				arg3 = 0;
+			else
+				arg3 = (char *) SvPV(ST(2), PL_na);
+			if (!SvOK((SV *) ST(3)))
+				arg4 = 0;
+			else
+				arg4 = (char *) SvPV(ST(3), PL_na);
+			result = (int) fs_switch_ivr_session_transfer(arg1, arg2, arg3, arg4);
+
+			ST(argvi) = sv_newmortal();
+			sv_setiv(ST(argvi++), (IV) result);
+			XSRETURN(argvi);
+		  fail:
+			;
+		}
+		croak(Nullch);
+	}
+
+
+	XS(_wrap_fs_switch_ivr_speak_text) {
+		{
+			switch_core_session_t *arg1 = (switch_core_session_t *) 0;
+			char *arg2;
+			char *arg3;
+			uint32_t arg4;
+			char *arg5;
+			int result;
+			int argvi = 0;
+			dXSARGS;
+
+			if ((items < 5) || (items > 5)) {
+				SWIG_croak("Usage: fs_switch_ivr_speak_text(session,tts_name,voice_name,rate,text);");
+			}
+			{
+				if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session_t, 0) < 0) {
+					SWIG_croak
+						("Type error in argument 1 of fs_switch_ivr_speak_text. Expected _p_switch_core_session_t");
+				}
+			}
+			if (!SvOK((SV *) ST(1)))
+				arg2 = 0;
+			else
+				arg2 = (char *) SvPV(ST(1), PL_na);
+			if (!SvOK((SV *) ST(2)))
+				arg3 = 0;
+			else
+				arg3 = (char *) SvPV(ST(2), PL_na);
+			{
+				uint32_t *argp;
+				if (SWIG_ConvertPtr(ST(3), (void **) &argp, SWIGTYPE_p_uint32_t, 0) < 0) {
+					SWIG_croak("Type error in argument 4 of fs_switch_ivr_speak_text. Expected _p_uint32_t");
+				}
+				arg4 = *argp;
+			}
+			if (!SvOK((SV *) ST(4)))
+				arg5 = 0;
+			else
+				arg5 = (char *) SvPV(ST(4), PL_na);
+			result = (int) fs_switch_ivr_speak_text(arg1, arg2, arg3, arg4, arg5);
+
+			ST(argvi) = sv_newmortal();
+			sv_setiv(ST(argvi++), (IV) result);
+			XSRETURN(argvi);
+		  fail:
+			;
+		}
+		croak(Nullch);
+	}
+
+
+	XS(_wrap_fs_switch_channel_get_variable) {
+		{
+			switch_channel_t *arg1 = (switch_channel_t *) 0;
+			char *arg2;
+			char *result;
+			int argvi = 0;
+			dXSARGS;
+
+			if ((items < 2) || (items > 2)) {
+				SWIG_croak("Usage: fs_switch_channel_get_variable(channel,varname);");
+			}
+			{
+				if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_channel_t, 0) < 0) {
+					SWIG_croak
+						("Type error in argument 1 of fs_switch_channel_get_variable. Expected _p_switch_channel_t");
+				}
+			}
+			if (!SvOK((SV *) ST(1)))
+				arg2 = 0;
+			else
+				arg2 = (char *) SvPV(ST(1), PL_na);
+			result = (char *) fs_switch_channel_get_variable(arg1, arg2);
+
+			ST(argvi) = sv_newmortal();
+			if (result) {
+				sv_setpv((SV *) ST(argvi++), (char *) result);
+			} else {
+				sv_setsv((SV *) ST(argvi++), &PL_sv_undef);
+			}
+			XSRETURN(argvi);
+		  fail:
+			;
+		}
+		croak(Nullch);
+	}
+
+
+	XS(_wrap_fs_switch_channel_set_variable) {
+		{
+			switch_channel_t *arg1 = (switch_channel_t *) 0;
+			char *arg2;
+			char *arg3;
+			int result;
+			int argvi = 0;
+			dXSARGS;
+
+			if ((items < 3) || (items > 3)) {
+				SWIG_croak("Usage: fs_switch_channel_set_variable(channel,varname,value);");
+			}
+			{
+				if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_channel_t, 0) < 0) {
+					SWIG_croak
+						("Type error in argument 1 of fs_switch_channel_set_variable. Expected _p_switch_channel_t");
+				}
+			}
+			if (!SvOK((SV *) ST(1)))
+				arg2 = 0;
+			else
+				arg2 = (char *) SvPV(ST(1), PL_na);
+			if (!SvOK((SV *) ST(2)))
+				arg3 = 0;
+			else
+				arg3 = (char *) SvPV(ST(2), PL_na);
+			result = (int) fs_switch_channel_set_variable(arg1, arg2, arg3);
+
+			ST(argvi) = sv_newmortal();
+			sv_setiv(ST(argvi++), (IV) result);
+			XSRETURN(argvi);
+		  fail:
+			;
+		}
+		croak(Nullch);
+	}
 
 
 
 /* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */
 
-static swig_type_info _swigt__p_switch_channel_t[] = {{"_p_switch_channel_t", 0, "switch_channel_t *", 0},{"_p_switch_channel_t"},{0}};
-static swig_type_info _swigt__p_switch_file_handle_t[] = {{"_p_switch_file_handle_t", 0, "switch_file_handle_t *", 0},{"_p_switch_file_handle_t"},{0}};
-static swig_type_info _swigt__p_switch_core_session_t[] = {{"_p_switch_core_session_t", 0, "switch_core_session_t *", 0},{"_p_switch_core_session_t"},{0}};
-static swig_type_info _swigt__p_p_switch_core_session_t[] = {{"_p_p_switch_core_session_t", 0, "switch_core_session_t **", 0},{"_p_p_switch_core_session_t"},{0}};
-static swig_type_info _swigt__p_uint32_t[] = {{"_p_uint32_t", 0, "uint32_t *", 0},{"_p_uint32_t"},{0}};
-static swig_type_info _swigt__p_switch_input_callback_function_t[] = {{"_p_switch_input_callback_function_t", 0, "switch_input_callback_function_t *", 0},{"_p_switch_input_callback_function_t"},{0}};
+	static swig_type_info _swigt__p_switch_channel_t[] =
+		{ {"_p_switch_channel_t", 0, "switch_channel_t *", 0}, {"_p_switch_channel_t"}, {0} };
+	static swig_type_info _swigt__p_switch_file_handle_t[] =
+		{ {"_p_switch_file_handle_t", 0, "switch_file_handle_t *", 0}, {"_p_switch_file_handle_t"}, {0} };
+	static swig_type_info _swigt__p_switch_core_session_t[] =
+		{ {"_p_switch_core_session_t", 0, "switch_core_session_t *", 0}, {"_p_switch_core_session_t"}, {0} };
+	static swig_type_info _swigt__p_p_switch_core_session_t[] =
+		{ {"_p_p_switch_core_session_t", 0, "switch_core_session_t **", 0}, {"_p_p_switch_core_session_t"}, {0} };
+	static swig_type_info _swigt__p_uint32_t[] = { {"_p_uint32_t", 0, "uint32_t *", 0}, {"_p_uint32_t"}, {0} };
+	static swig_type_info _swigt__p_switch_input_callback_function_t[] =
+		{ {"_p_switch_input_callback_function_t", 0, "switch_input_callback_function_t *", 0},
+	{"_p_switch_input_callback_function_t"}, {0}
+	};
 
-static swig_type_info *swig_types_initial[] = {
-_swigt__p_switch_channel_t, 
-_swigt__p_switch_file_handle_t, 
-_swigt__p_switch_core_session_t, 
-_swigt__p_p_switch_core_session_t, 
-_swigt__p_uint32_t, 
-_swigt__p_switch_input_callback_function_t, 
-0
-};
+	static swig_type_info *swig_types_initial[] = {
+		_swigt__p_switch_channel_t,
+		_swigt__p_switch_file_handle_t,
+		_swigt__p_switch_core_session_t,
+		_swigt__p_p_switch_core_session_t,
+		_swigt__p_uint32_t,
+		_swigt__p_switch_input_callback_function_t,
+		0
+	};
 
 
 /* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */
 
-static swig_constant_info swig_constants[] = {
-{0}
-};
+	static swig_constant_info swig_constants[] = {
+		{0}
+	};
 #ifdef __cplusplus
 }
 #endif
 static swig_variable_info swig_variables[] = {
-{0}
+	{0}
 };
 static swig_command_info swig_commands[] = {
-{"fs_perlc::fs_core_set_globals", _wrap_fs_core_set_globals},
-{"fs_perlc::fs_core_init", _wrap_fs_core_init},
-{"fs_perlc::fs_core_destroy", _wrap_fs_core_destroy},
-{"fs_perlc::fs_loadable_module_init", _wrap_fs_loadable_module_init},
-{"fs_perlc::fs_loadable_module_shutdown", _wrap_fs_loadable_module_shutdown},
-{"fs_perlc::fs_console_loop", _wrap_fs_console_loop},
-{"fs_perlc::fs_consol_log", _wrap_fs_consol_log},
-{"fs_perlc::fs_consol_clean", _wrap_fs_consol_clean},
-{"fs_perlc::fs_core_session_locate", _wrap_fs_core_session_locate},
-{"fs_perlc::fs_channel_answer", _wrap_fs_channel_answer},
-{"fs_perlc::fs_channel_pre_answer", _wrap_fs_channel_pre_answer},
-{"fs_perlc::fs_channel_hangup", _wrap_fs_channel_hangup},
-{"fs_perlc::fs_channel_set_variable", _wrap_fs_channel_set_variable},
-{"fs_perlc::fs_channel_get_variable", _wrap_fs_channel_get_variable},
-{"fs_perlc::fs_channel_set_state", _wrap_fs_channel_set_state},
-{"fs_perlc::fs_ivr_play_file", _wrap_fs_ivr_play_file},
-{"fs_perlc::fs_switch_ivr_record_file", _wrap_fs_switch_ivr_record_file},
-{"fs_perlc::fs_switch_ivr_sleep", _wrap_fs_switch_ivr_sleep},
-{"fs_perlc::fs_ivr_play_file2", _wrap_fs_ivr_play_file2},
-{"fs_perlc::fs_switch_ivr_collect_digits_callback", _wrap_fs_switch_ivr_collect_digits_callback},
-{"fs_perlc::fs_switch_ivr_collect_digits_count", _wrap_fs_switch_ivr_collect_digits_count},
-{"fs_perlc::fs_switch_ivr_originate", _wrap_fs_switch_ivr_originate},
-{"fs_perlc::fs_switch_ivr_session_transfer", _wrap_fs_switch_ivr_session_transfer},
-{"fs_perlc::fs_switch_ivr_speak_text", _wrap_fs_switch_ivr_speak_text},
-{"fs_perlc::fs_switch_channel_get_variable", _wrap_fs_switch_channel_get_variable},
-{"fs_perlc::fs_switch_channel_set_variable", _wrap_fs_switch_channel_set_variable},
-{0,0}
+	{"fs_perlc::fs_core_set_globals", _wrap_fs_core_set_globals},
+	{"fs_perlc::fs_core_init", _wrap_fs_core_init},
+	{"fs_perlc::fs_core_destroy", _wrap_fs_core_destroy},
+	{"fs_perlc::fs_loadable_module_init", _wrap_fs_loadable_module_init},
+	{"fs_perlc::fs_loadable_module_shutdown", _wrap_fs_loadable_module_shutdown},
+	{"fs_perlc::fs_console_loop", _wrap_fs_console_loop},
+	{"fs_perlc::fs_consol_log", _wrap_fs_consol_log},
+	{"fs_perlc::fs_consol_clean", _wrap_fs_consol_clean},
+	{"fs_perlc::fs_core_session_locate", _wrap_fs_core_session_locate},
+	{"fs_perlc::fs_channel_answer", _wrap_fs_channel_answer},
+	{"fs_perlc::fs_channel_pre_answer", _wrap_fs_channel_pre_answer},
+	{"fs_perlc::fs_channel_hangup", _wrap_fs_channel_hangup},
+	{"fs_perlc::fs_channel_set_variable", _wrap_fs_channel_set_variable},
+	{"fs_perlc::fs_channel_get_variable", _wrap_fs_channel_get_variable},
+	{"fs_perlc::fs_channel_set_state", _wrap_fs_channel_set_state},
+	{"fs_perlc::fs_ivr_play_file", _wrap_fs_ivr_play_file},
+	{"fs_perlc::fs_switch_ivr_record_file", _wrap_fs_switch_ivr_record_file},
+	{"fs_perlc::fs_switch_ivr_sleep", _wrap_fs_switch_ivr_sleep},
+	{"fs_perlc::fs_ivr_play_file2", _wrap_fs_ivr_play_file2},
+	{"fs_perlc::fs_switch_ivr_collect_digits_callback", _wrap_fs_switch_ivr_collect_digits_callback},
+	{"fs_perlc::fs_switch_ivr_collect_digits_count", _wrap_fs_switch_ivr_collect_digits_count},
+	{"fs_perlc::fs_switch_ivr_originate", _wrap_fs_switch_ivr_originate},
+	{"fs_perlc::fs_switch_ivr_session_transfer", _wrap_fs_switch_ivr_session_transfer},
+	{"fs_perlc::fs_switch_ivr_speak_text", _wrap_fs_switch_ivr_speak_text},
+	{"fs_perlc::fs_switch_channel_get_variable", _wrap_fs_switch_channel_get_variable},
+	{"fs_perlc::fs_switch_channel_set_variable", _wrap_fs_switch_channel_set_variable},
+	{0, 0}
 };
 
 #ifdef __cplusplus
 extern "C"
 #endif
+XS(SWIG_init)
+{
+	dXSARGS;
+	int i;
+	static int _init = 0;
+	if (!_init) {
+		for (i = 0; swig_types_initial[i]; i++) {
+			swig_types[i] = SWIG_TypeRegister(swig_types_initial[i]);
+		}
+		_init = 1;
+	}
 
-XS(SWIG_init) {
-    dXSARGS;
-    int i;
-    static int _init = 0;
-    if (!_init) {
-        for (i = 0; swig_types_initial[i]; i++) {
-            swig_types[i] = SWIG_TypeRegister(swig_types_initial[i]);
-        }	
-        _init = 1;
-    }
-    
-    /* Install commands */
-    for (i = 0; swig_commands[i].name; i++) {
-        newXS((char*) swig_commands[i].name,swig_commands[i].wrapper, (char*)__FILE__);
-    }
-    
-    /* Install variables */
-    for (i = 0; swig_variables[i].name; i++) {
-        SV *sv;
-        sv = perl_get_sv((char*) swig_variables[i].name, TRUE | 0x2);
-        if (swig_variables[i].type) {
-            SWIG_MakePtr(sv,(void *)1, *swig_variables[i].type,0);
-        } else {
-            sv_setiv(sv,(IV) 0);
-        }
-        swig_create_magic(sv, (char *) swig_variables[i].name, swig_variables[i].set, swig_variables[i].get); 
-    }
-    
-    /* Install constant */
-    for (i = 0; swig_constants[i].type; i++) {
-        SV *sv;
-        sv = perl_get_sv((char*)swig_constants[i].name, TRUE | 0x2);
-        switch(swig_constants[i].type) {
-            case SWIG_INT:
-            sv_setiv(sv, (IV) swig_constants[i].lvalue);
-            break;
-            case SWIG_FLOAT:
-            sv_setnv(sv, (double) swig_constants[i].dvalue);
-            break;
-            case SWIG_STRING:
-            sv_setpv(sv, (char *) swig_constants[i].pvalue);
-            break;
-            case SWIG_POINTER:
-            SWIG_MakePtr(sv, swig_constants[i].pvalue, *(swig_constants[i].ptype),0);
-            break;
-            case SWIG_BINARY:
-            SWIG_MakePackedObj(sv, swig_constants[i].pvalue, swig_constants[i].lvalue, *(swig_constants[i].ptype));
-            break;
-            default:
-            break;
-        }
-        SvREADONLY_on(sv);
-    }
-    
-    ST(0) = &PL_sv_yes;
-    XSRETURN(1);
+	/* Install commands */
+	for (i = 0; swig_commands[i].name; i++) {
+		newXS((char *) swig_commands[i].name, swig_commands[i].wrapper, (char *) __FILE__);
+	}
+
+	/* Install variables */
+	for (i = 0; swig_variables[i].name; i++) {
+		SV *sv;
+		sv = perl_get_sv((char *) swig_variables[i].name, TRUE | 0x2);
+		if (swig_variables[i].type) {
+			SWIG_MakePtr(sv, (void *) 1, *swig_variables[i].type, 0);
+		} else {
+			sv_setiv(sv, (IV) 0);
+		}
+		swig_create_magic(sv, (char *) swig_variables[i].name, swig_variables[i].set, swig_variables[i].get);
+	}
+
+	/* Install constant */
+	for (i = 0; swig_constants[i].type; i++) {
+		SV *sv;
+		sv = perl_get_sv((char *) swig_constants[i].name, TRUE | 0x2);
+		switch (swig_constants[i].type) {
+		case SWIG_INT:
+			sv_setiv(sv, (IV) swig_constants[i].lvalue);
+			break;
+		case SWIG_FLOAT:
+			sv_setnv(sv, (double) swig_constants[i].dvalue);
+			break;
+		case SWIG_STRING:
+			sv_setpv(sv, (char *) swig_constants[i].pvalue);
+			break;
+		case SWIG_POINTER:
+			SWIG_MakePtr(sv, swig_constants[i].pvalue, *(swig_constants[i].ptype), 0);
+			break;
+		case SWIG_BINARY:
+			SWIG_MakePackedObj(sv, swig_constants[i].pvalue, swig_constants[i].lvalue, *(swig_constants[i].ptype));
+			break;
+		default:
+			break;
+		}
+		SvREADONLY_on(sv);
+	}
+
+	ST(0) = &PL_sv_yes;
+	XSRETURN(1);
 }
-
diff --git a/src/mod/languages/mod_python/freeswitch_python.h b/src/mod/languages/mod_python/freeswitch_python.h
index 7c1bbae4be..87799e4670 100644
--- a/src/mod/languages/mod_python/freeswitch_python.h
+++ b/src/mod/languages/mod_python/freeswitch_python.h
@@ -1,4 +1,4 @@
-#ifndef FREESWITCH_PYTHON_H 
+#ifndef FREESWITCH_PYTHON_H
 #define FREESWITCH_PYTHON_H
 
 #include 
@@ -9,45 +9,41 @@ extern "C" {
 
 #include 
 
-extern void *globalDTMFCallbackFunction;
-extern switch_status_t PythonDTMFCallback(switch_core_session *session, 
-                                    void *input, 
-                                    switch_input_type_t itype,
-                                    void *buf,
-                                    unsigned int buflen);
+	extern void *globalDTMFCallbackFunction;
+	extern switch_status_t PythonDTMFCallback(switch_core_session * session,
+											  void *input, switch_input_type_t itype, void *buf, unsigned int buflen);
 
-class SessionContainer {
-    private:
-        switch_core_session_t *session;
-        switch_channel_t *channel;
-        char *uuid;
-        PyObject *dtmfCallbackFunction;
-        char *tts_name;
-        char *voice_name;
-    public:
-        SessionContainer(char *uuid);
-        ~SessionContainer();
-        void console_log(char *level_str, char *msg);
-        void console_clean_log(char *msg);
-        int  answer();
-        int  pre_answer();
-        void hangup(char *cause);
-        void set_variable(char *var, char *val);
-        void get_variable(char *var, char *val);
-        void set_state(char *state);
-        int  play_file(char *file, char *timer_name);
-        void set_dtmf_callback(PyObject *pyfunc);
-        int  speak_text(char *text);
-        void set_tts_parms(char *tts_name, char *voice_name);
-        int  get_digits(char *dtmf_buf, int len, char *terminators, char *terminator, int timeout);
-        int  transfer(char *extensions, char *dialplan, char *context);
-        int  play_and_get_digits(int min_digits, int max_digits, int max_tries, int timeout, char *terminators, 
-                char *audio_files, char *bad_input_audio_files, char *dtmf_buf, char *digits_regex);
-    protected:
-};
+	class SessionContainer {
+	  private:
+		switch_core_session_t *session;
+		switch_channel_t *channel;
+		char *uuid;
+		PyObject *dtmfCallbackFunction;
+		char *tts_name;
+		char *voice_name;
+	  public:
+		     SessionContainer(char *uuid);
+		    ~SessionContainer();
+		void console_log(char *level_str, char *msg);
+		void console_clean_log(char *msg);
+		int answer();
+		int pre_answer();
+		void hangup(char *cause);
+		void set_variable(char *var, char *val);
+		void get_variable(char *var, char *val);
+		void set_state(char *state);
+		int play_file(char *file, char *timer_name);
+		void set_dtmf_callback(PyObject * pyfunc);
+		int speak_text(char *text);
+		void set_tts_parms(char *tts_name, char *voice_name);
+		int get_digits(char *dtmf_buf, int len, char *terminators, char *terminator, int timeout);
+		int transfer(char *extensions, char *dialplan, char *context);
+		int play_and_get_digits(int min_digits, int max_digits, int max_tries, int timeout, char *terminators,
+								char *audio_files, char *bad_input_audio_files, char *dtmf_buf, char *digits_regex);
+	  protected:
+	};
 
 #ifdef __cplusplus
 }
 #endif
-
 #endif
diff --git a/src/mod/languages/mod_python/mod_python.c b/src/mod/languages/mod_python/mod_python.c
index c288850364..ce309dc06c 100644
--- a/src/mod/languages/mod_python/mod_python.c
+++ b/src/mod/languages/mod_python/mod_python.c
@@ -50,54 +50,55 @@ const char modname[] = "mod_python";
 static void python_function(switch_core_session_t *session, char *data)
 {
 	char *uuid = switch_core_session_get_uuid(session);
-    char *argv[1];
-    FILE* pythonfile;
+	char *argv[1];
+	FILE *pythonfile;
 
-    argv[0] = uuid;
-    pythonfile = fopen(data, "r");
+	argv[0] = uuid;
+	pythonfile = fopen(data, "r");
 
-    Py_Initialize();
-    PySys_SetArgv(1, argv);
-    init_freeswitch();
-    PyRun_SimpleFile(pythonfile, "");
-    Py_Finalize();
+	Py_Initialize();
+	PySys_SetArgv(1, argv);
+	init_freeswitch();
+	PyRun_SimpleFile(pythonfile, "");
+	Py_Finalize();
 
 }
 
 static switch_status_t launch_python(char *text, switch_core_session_t *session, switch_stream_handle_t *stream)
 {
-    FILE* pythonfile;
+	FILE *pythonfile;
 
-    if (switch_strlen_zero(text)) {
-        stream->write_function(stream, "USAGE: %s\n", python_run_interface.syntax);
-        return SWITCH_STATUS_SUCCESS;
-    }
+	if (switch_strlen_zero(text)) {
+		stream->write_function(stream, "USAGE: %s\n", python_run_interface.syntax);
+		return SWITCH_STATUS_SUCCESS;
+	}
 
-    pythonfile = fopen(text, "r");
+	pythonfile = fopen(text, "r");
 
-    Py_Initialize();
-    init_freeswitch();
-    PyRun_SimpleFile(pythonfile, "");
-    Py_Finalize();
+	Py_Initialize();
+	init_freeswitch();
+	PyRun_SimpleFile(pythonfile, "");
+	Py_Finalize();
 
-    stream->write_function(stream, "OK\n");
-    return SWITCH_STATUS_SUCCESS;
+	stream->write_function(stream, "OK\n");
+	return SWITCH_STATUS_SUCCESS;
 }
 
 static const switch_application_interface_t python_application_interface = {
 	/*.interface_name */ "python",
 	/*.application_function */ python_function,
 	NULL, NULL, NULL,
-	/* flags */ SAF_NONE, /* should we support no media mode here?  If so, we need to detect the mode, and either disable the media functions or indicate media if/when we need */
-	/*.next*/ NULL
+	/* flags */ SAF_NONE,
+	/* should we support no media mode here?  If so, we need to detect the mode, and either disable the media functions or indicate media if/when we need */
+	/*.next */ NULL
 };
 
 static switch_api_interface_t python_run_interface = {
-    /*.interface_name */ "python",
-    /*.desc */ "run a python script",
-    /*.function */ launch_python,
-    /*.syntax */ "python ",
-    /*.next */ NULL
+	/*.interface_name */ "python",
+	/*.desc */ "run a python script",
+	/*.function */ launch_python,
+	/*.syntax */ "python ",
+	/*.next */ NULL
 };
 
 static switch_loadable_module_interface_t python_module_interface = {
@@ -113,7 +114,8 @@ static switch_loadable_module_interface_t python_module_interface = {
 	/*.directory_interface */ NULL
 };
 
-SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
+													   char *filename)
 {
 	/* connect my internal structure to the blank pointer passed to me */
 	*module_interface = &python_module_interface;
diff --git a/src/mod/languages/mod_python/switch_swig_wrap.c b/src/mod/languages/mod_python/switch_swig_wrap.c
index 6a94494d0a..ade2ceb380 100644
--- a/src/mod/languages/mod_python/switch_swig_wrap.c
+++ b/src/mod/languages/mod_python/switch_swig_wrap.c
@@ -21,7 +21,7 @@
 #  if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560)
 #    define SWIGTEMPLATEDISAMBIGUATOR template
 #  else
-#    define SWIGTEMPLATEDISAMBIGUATOR 
+#    define SWIGTEMPLATEDISAMBIGUATOR
 #  endif
 #endif
 
@@ -37,9 +37,9 @@
 /* attribute recognised by some compilers to avoid 'unused' warnings */
 #ifndef SWIGUNUSED
 # if defined(__GNUC__) || defined(__ICC)
-#   define SWIGUNUSED __attribute__ ((unused)) 
+#   define SWIGUNUSED __attribute__ ((unused))
 # else
-#   define SWIGUNUSED 
+#   define SWIGUNUSED
 # endif
 #endif
 
@@ -72,7 +72,7 @@
 #   define SWIGSTDCALL __stdcall
 # else
 #   define SWIGSTDCALL
-# endif 
+# endif
 #endif
 
 
@@ -123,37 +123,37 @@
 extern "C" {
 #endif
 
-typedef void *(*swig_converter_func)(void *);
-typedef struct swig_type_info *(*swig_dycast_func)(void **);
+	typedef void *(*swig_converter_func) (void *);
+	typedef struct swig_type_info *(*swig_dycast_func) (void **);
 
 /* Structure to store inforomation on one type */
-typedef struct swig_type_info {
-  const char             *name;			/* mangled name of this type */
-  const char             *str;			/* human readable name of this type */
-  swig_dycast_func        dcast;		/* dynamic cast function down a hierarchy */
-  struct swig_cast_info  *cast;			/* linked list of types that can cast into this type */
-  void                   *clientdata;		/* language specific type data */
-} swig_type_info;
+	typedef struct swig_type_info {
+		const char *name;		/* mangled name of this type */
+		const char *str;		/* human readable name of this type */
+		swig_dycast_func dcast;	/* dynamic cast function down a hierarchy */
+		struct swig_cast_info *cast;	/* linked list of types that can cast into this type */
+		void *clientdata;		/* language specific type data */
+	} swig_type_info;
 
 /* Structure to store a type and conversion function used for casting */
-typedef struct swig_cast_info {
-  swig_type_info         *type;			/* pointer to type that is equivalent to this type */
-  swig_converter_func     converter;		/* function to cast the void pointers */
-  struct swig_cast_info  *next;			/* pointer to next cast in linked list */
-  struct swig_cast_info  *prev;			/* pointer to the previous cast */
-} swig_cast_info;
+	typedef struct swig_cast_info {
+		swig_type_info *type;	/* pointer to type that is equivalent to this type */
+		swig_converter_func converter;	/* function to cast the void pointers */
+		struct swig_cast_info *next;	/* pointer to next cast in linked list */
+		struct swig_cast_info *prev;	/* pointer to the previous cast */
+	} swig_cast_info;
 
 /* Structure used to store module information
  * Each module generates one structure like this, and the runtime collects
  * all of these structures and stores them in a circularly linked list.*/
-typedef struct swig_module_info {
-  swig_type_info         **types;		/* Array of pointers to swig_type_info structures that are in this module */
-  size_t                 size;		        /* Number of types in this module */
-  struct swig_module_info *next;		/* Pointer to next element in circularly linked list */
-  swig_type_info         **type_initial;	/* Array of initially generated type structures */
-  swig_cast_info         **cast_initial;	/* Array of initially generated casting structures */
-  void                    *clientdata;		/* Language specific module data */
-} swig_module_info;
+	typedef struct swig_module_info {
+		swig_type_info **types;	/* Array of pointers to swig_type_info structures that are in this module */
+		size_t size;			/* Number of types in this module */
+		struct swig_module_info *next;	/* Pointer to next element in circularly linked list */
+		swig_type_info **type_initial;	/* Array of initially generated type structures */
+		swig_cast_info **cast_initial;	/* Array of initially generated casting structures */
+		void *clientdata;		/* Language specific module data */
+	} swig_module_info;
 
 
 /* 
@@ -163,54 +163,59 @@ typedef struct swig_module_info {
   Return 0 when the two name types are equivalent, as in
   strncmp, but skipping ' '.
 */
-SWIGRUNTIME int
-SWIG_TypeNameComp(const char *f1, const char *l1,
-		  const char *f2, const char *l2) {
-  for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) {
-    while ((*f1 == ' ') && (f1 != l1)) ++f1;
-    while ((*f2 == ' ') && (f2 != l2)) ++f2;
-    if (*f1 != *f2) return (int)(*f1 - *f2);
-  }
-  return (l1 - f1) - (l2 - f2);
-}
+	SWIGRUNTIME int
+	    SWIG_TypeNameComp(const char *f1, const char *l1, const char *f2, const char *l2) {
+		for (; (f1 != l1) && (f2 != l2); ++f1, ++f2) {
+			while ((*f1 == ' ') && (f1 != l1))
+				++f1;
+			while ((*f2 == ' ') && (f2 != l2))
+				++f2;
+			if (*f1 != *f2)
+				return (int) (*f1 - *f2);
+		} return (l1 - f1) - (l2 - f2);
+	}
 
 /*
   Check type equivalence in a name list like ||...
   Return 0 if not equal, 1 if equal
 */
-SWIGRUNTIME int
-SWIG_TypeEquiv(const char *nb, const char *tb) {
-  int equiv = 0;
-  const char* te = tb + strlen(tb);
-  const char* ne = nb;
-  while (!equiv && *ne) {
-    for (nb = ne; *ne; ++ne) {
-      if (*ne == '|') break;
-    }
-    equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0;
-    if (*ne) ++ne;
-  }
-  return equiv;
-}
+	SWIGRUNTIME int
+	    SWIG_TypeEquiv(const char *nb, const char *tb) {
+		int equiv = 0;
+		const char *te = tb + strlen(tb);
+		const char *ne = nb;
+		while (!equiv && *ne) {
+			for (nb = ne; *ne; ++ne) {
+				if (*ne == '|')
+					break;
+			}
+			equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0;
+			if (*ne)
+				++ne;
+		}
+		return equiv;
+	}
 
 /*
   Check type equivalence in a name list like ||...
   Return 0 if equal, -1 if nb < tb, 1 if nb > tb
 */
-SWIGRUNTIME int
-SWIG_TypeCompare(const char *nb, const char *tb) {
-  int equiv = 0;
-  const char* te = tb + strlen(tb);
-  const char* ne = nb;
-  while (!equiv && *ne) {
-    for (nb = ne; *ne; ++ne) {
-      if (*ne == '|') break;
-    }
-    equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0;
-    if (*ne) ++ne;
-  }
-  return equiv;
-}
+	SWIGRUNTIME int
+	    SWIG_TypeCompare(const char *nb, const char *tb) {
+		int equiv = 0;
+		const char *te = tb + strlen(tb);
+		const char *ne = nb;
+		while (!equiv && *ne) {
+			for (nb = ne; *ne; ++ne) {
+				if (*ne == '|')
+					break;
+			}
+			equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0;
+			if (*ne)
+				++ne;
+		}
+		return equiv;
+	}
 
 
 /* think of this as a c++ template<> or a scheme macro */
@@ -238,87 +243,83 @@ SWIG_TypeCompare(const char *nb, const char *tb) {
 /*
   Check the typename
 */
-SWIGRUNTIME swig_cast_info *
-SWIG_TypeCheck(const char *c, swig_type_info *ty) {
-  SWIG_TypeCheck_Template(strcmp(iter->type->name, c) == 0, ty);
-}
+	SWIGRUNTIME swig_cast_info *SWIG_TypeCheck(const char *c, swig_type_info * ty) {
+		SWIG_TypeCheck_Template(strcmp(iter->type->name, c) == 0, ty);
+	}
 
 /* Same as previous function, except strcmp is replaced with a pointer comparison */
-SWIGRUNTIME swig_cast_info *
-SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *into) {
-  SWIG_TypeCheck_Template(iter->type == from, into);
-}
+	SWIGRUNTIME swig_cast_info *SWIG_TypeCheckStruct(swig_type_info * from, swig_type_info * into) {
+		SWIG_TypeCheck_Template(iter->type == from, into);
+	}
 
 /*
   Cast a pointer up an inheritance hierarchy
 */
-SWIGRUNTIMEINLINE void *
-SWIG_TypeCast(swig_cast_info *ty, void *ptr) {
-  return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr);
-}
+	SWIGRUNTIMEINLINE void *SWIG_TypeCast(swig_cast_info * ty, void *ptr) {
+		return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter) (ptr);
+	}
 
 /* 
    Dynamic pointer casting. Down an inheritance hierarchy
 */
-SWIGRUNTIME swig_type_info *
-SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) {
-  swig_type_info *lastty = ty;
-  if (!ty || !ty->dcast) return ty;
-  while (ty && (ty->dcast)) {
-    ty = (*ty->dcast)(ptr);
-    if (ty) lastty = ty;
-  }
-  return lastty;
-}
+	SWIGRUNTIME swig_type_info *SWIG_TypeDynamicCast(swig_type_info * ty, void **ptr) {
+		swig_type_info *lastty = ty;
+		if (!ty || !ty->dcast)
+			return ty;
+		while (ty && (ty->dcast)) {
+			ty = (*ty->dcast) (ptr);
+			if (ty)
+				lastty = ty;
+		}
+		return lastty;
+	}
 
 /*
   Return the name associated with this type
 */
-SWIGRUNTIMEINLINE const char *
-SWIG_TypeName(const swig_type_info *ty) {
-  return ty->name;
-}
+	SWIGRUNTIMEINLINE const char *SWIG_TypeName(const swig_type_info * ty) {
+		return ty->name;
+	}
 
 /*
   Return the pretty name associated with this type,
   that is an unmangled type name in a form presentable to the user.
 */
-SWIGRUNTIME const char *
-SWIG_TypePrettyName(const swig_type_info *type) {
-  /* The "str" field contains the equivalent pretty names of the
-     type, separated by vertical-bar characters.  We choose
-     to print the last name, as it is often (?) the most
-     specific. */
-  if (type->str != NULL) {
-    const char *last_name = type->str;
-    const char *s;
-    for (s = type->str; *s; s++)
-      if (*s == '|') last_name = s+1;
-    return last_name;
-  }
-  else
-    return type->name;
-}
+	SWIGRUNTIME const char *SWIG_TypePrettyName(const swig_type_info * type) {
+		/* The "str" field contains the equivalent pretty names of the
+		   type, separated by vertical-bar characters.  We choose
+		   to print the last name, as it is often (?) the most
+		   specific. */
+		if (type->str != NULL) {
+			const char *last_name = type->str;
+			const char *s;
+			for (s = type->str; *s; s++)
+				if (*s == '|')
+					last_name = s + 1;
+			return last_name;
+		} else
+			return type->name;
+	}
 
 /* 
    Set the clientdata field for a type
 */
-SWIGRUNTIME void
-SWIG_TypeClientData(swig_type_info *ti, void *clientdata) {
-  swig_cast_info *cast = ti->cast;
-  /* if (ti->clientdata == clientdata) return; */
-  ti->clientdata = clientdata;
-  
-  while (cast) {
-    if (!cast->converter) {
-      swig_type_info *tc = cast->type;
-      if (!tc->clientdata) {
-	SWIG_TypeClientData(tc, clientdata);
-      }
-    }    
-    cast = cast->next;
-  }
-}
+	SWIGRUNTIME void
+	     SWIG_TypeClientData(swig_type_info * ti, void *clientdata) {
+		swig_cast_info *cast = ti->cast;
+		/* if (ti->clientdata == clientdata) return; */
+		ti->clientdata = clientdata;
+
+		while (cast) {
+			if (!cast->converter) {
+				swig_type_info *tc = cast->type;
+				if (!tc->clientdata) {
+					SWIG_TypeClientData(tc, clientdata);
+				}
+			}
+			cast = cast->next;
+		}
+	}
 
 /*
   Search for a swig_type_info structure only by mangled name
@@ -328,41 +329,39 @@ SWIG_TypeClientData(swig_type_info *ti, void *clientdata) {
   Note: if start == end at the beginning of the function, we go all the way around
   the circular list.
 */
-SWIGRUNTIME swig_type_info *
-SWIG_MangledTypeQueryModule(swig_module_info *start, 
-                            swig_module_info *end, 
-		            const char *name) {
-  swig_module_info *iter = start;
-  do {
-    if (iter->size) {
-      register size_t l = 0;
-      register size_t r = iter->size - 1;
-      do {
-	/* since l+r >= 0, we can (>> 1) instead (/ 2) */
-	register size_t i = (l + r) >> 1; 
-	const char *iname = iter->types[i]->name;
-	if (iname) {
-	  register int compare = strcmp(name, iname);
-	  if (compare == 0) {	    
-	    return iter->types[i];
-	  } else if (compare < 0) {
-	    if (i) {
-	      r = i - 1;
-	    } else {
-	      break;
-	    }
-	  } else if (compare > 0) {
-	    l = i + 1;
-	  }
-	} else {
-	  break; /* should never happen */
+	SWIGRUNTIME swig_type_info *SWIG_MangledTypeQueryModule(swig_module_info * start,
+															swig_module_info * end, const char *name) {
+		swig_module_info *iter = start;
+		do {
+			if (iter->size) {
+				register size_t l = 0;
+				register size_t r = iter->size - 1;
+				do {
+					/* since l+r >= 0, we can (>> 1) instead (/ 2) */
+					register size_t i = (l + r) >> 1;
+					const char *iname = iter->types[i]->name;
+					if (iname) {
+						register int compare = strcmp(name, iname);
+						if (compare == 0) {
+							return iter->types[i];
+						} else if (compare < 0) {
+							if (i) {
+								r = i - 1;
+							} else {
+								break;
+							}
+						} else if (compare > 0) {
+							l = i + 1;
+						}
+					} else {
+						break;	/* should never happen */
+					}
+				} while (l <= r);
+			}
+			iter = iter->next;
+		} while (iter != end);
+		return 0;
 	}
-      } while (l <= r);
-    }
-    iter = iter->next;
-  } while (iter != end);
-  return 0;
-}
 
 /*
   Search for a swig_type_info structure for either a mangled name or a human readable name.
@@ -373,131 +372,125 @@ SWIG_MangledTypeQueryModule(swig_module_info *start,
   Note: if start == end at the beginning of the function, we go all the way around
   the circular list.
 */
-SWIGRUNTIME swig_type_info *
-SWIG_TypeQueryModule(swig_module_info *start, 
-                     swig_module_info *end, 
-		     const char *name) {
-  /* STEP 1: Search the name field using binary search */
-  swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name);
-  if (ret) {
-    return ret;
-  } else {
-    /* STEP 2: If the type hasn't been found, do a complete search
-       of the str field (the human readable name) */
-    swig_module_info *iter = start;
-    do {
-      register size_t i = 0;
-      for (; i < iter->size; ++i) {
-	if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name)))
-	  return iter->types[i];
-      }
-      iter = iter->next;
-    } while (iter != end);
-  }
-  
-  /* neither found a match */
-  return 0;
-}
+	SWIGRUNTIME swig_type_info *SWIG_TypeQueryModule(swig_module_info * start, swig_module_info * end, const char *name) {
+		/* STEP 1: Search the name field using binary search */
+		swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name);
+		if (ret) {
+			return ret;
+		} else {
+			/* STEP 2: If the type hasn't been found, do a complete search
+			   of the str field (the human readable name) */
+			swig_module_info *iter = start;
+			do {
+				register size_t i = 0;
+				for (; i < iter->size; ++i) {
+					if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name)))
+						return iter->types[i];
+				}
+				iter = iter->next;
+			} while (iter != end);
+		}
+
+		/* neither found a match */
+		return 0;
+	}
 
 
 /* 
    Pack binary data into a string
 */
-SWIGRUNTIME char *
-SWIG_PackData(char *c, void *ptr, size_t sz) {
-  static const char hex[17] = "0123456789abcdef";
-  register const unsigned char *u = (unsigned char *) ptr;
-  register const unsigned char *eu =  u + sz;
-  for (; u != eu; ++u) {
-    register unsigned char uu = *u;
-    *(c++) = hex[(uu & 0xf0) >> 4];
-    *(c++) = hex[uu & 0xf];
-  }
-  return c;
-}
+	SWIGRUNTIME char *SWIG_PackData(char *c, void *ptr, size_t sz) {
+		static const char hex[17] = "0123456789abcdef";
+		register const unsigned char *u = (unsigned char *) ptr;
+		register const unsigned char *eu = u + sz;
+		for (; u != eu; ++u) {
+			register unsigned char uu = *u;
+			*(c++) = hex[(uu & 0xf0) >> 4];
+			*(c++) = hex[uu & 0xf];
+		}
+		return c;
+	}
 
 /* 
    Unpack binary data from a string
 */
-SWIGRUNTIME const char *
-SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
-  register unsigned char *u = (unsigned char *) ptr;
-  register const unsigned char *eu = u + sz;
-  for (; u != eu; ++u) {
-    register char d = *(c++);
-    register unsigned char uu = 0;
-    if ((d >= '0') && (d <= '9'))
-      uu = ((d - '0') << 4);
-    else if ((d >= 'a') && (d <= 'f'))
-      uu = ((d - ('a'-10)) << 4);
-    else 
-      return (char *) 0;
-    d = *(c++);
-    if ((d >= '0') && (d <= '9'))
-      uu |= (d - '0');
-    else if ((d >= 'a') && (d <= 'f'))
-      uu |= (d - ('a'-10));
-    else 
-      return (char *) 0;
-    *u = uu;
-  }
-  return c;
-}
+	SWIGRUNTIME const char *SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
+		register unsigned char *u = (unsigned char *) ptr;
+		register const unsigned char *eu = u + sz;
+		for (; u != eu; ++u) {
+			register char d = *(c++);
+			register unsigned char uu = 0;
+			if ((d >= '0') && (d <= '9'))
+				uu = ((d - '0') << 4);
+			else if ((d >= 'a') && (d <= 'f'))
+				uu = ((d - ('a' - 10)) << 4);
+			else
+				return (char *) 0;
+			d = *(c++);
+			if ((d >= '0') && (d <= '9'))
+				uu |= (d - '0');
+			else if ((d >= 'a') && (d <= 'f'))
+				uu |= (d - ('a' - 10));
+			else
+				return (char *) 0;
+			*u = uu;
+		}
+		return c;
+	}
 
 /* 
    Pack 'void *' into a string buffer.
 */
-SWIGRUNTIME char *
-SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) {
-  char *r = buff;
-  if ((2*sizeof(void *) + 2) > bsz) return 0;
-  *(r++) = '_';
-  r = SWIG_PackData(r,&ptr,sizeof(void *));
-  if (strlen(name) + 1 > (bsz - (r - buff))) return 0;
-  strcpy(r,name);
-  return buff;
-}
+	SWIGRUNTIME char *SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) {
+		char *r = buff;
+		if ((2 * sizeof(void *) + 2) > bsz)
+			return 0;
+		*(r++) = '_';
+		r = SWIG_PackData(r, &ptr, sizeof(void *));
+		if (strlen(name) + 1 > (bsz - (r - buff)))
+			return 0;
+		strcpy(r, name);
+		return buff;
+	}
 
-SWIGRUNTIME const char *
-SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) {
-  if (*c != '_') {
-    if (strcmp(c,"NULL") == 0) {
-      *ptr = (void *) 0;
-      return name;
-    } else {
-      return 0;
-    }
-  }
-  return SWIG_UnpackData(++c,ptr,sizeof(void *));
-}
+	SWIGRUNTIME const char *SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) {
+		if (*c != '_') {
+			if (strcmp(c, "NULL") == 0) {
+				*ptr = (void *) 0;
+				return name;
+			} else {
+				return 0;
+			}
+		}
+		return SWIG_UnpackData(++c, ptr, sizeof(void *));
+	}
 
-SWIGRUNTIME char *
-SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) {
-  char *r = buff;
-  size_t lname = (name ? strlen(name) : 0);
-  if ((2*sz + 2 + lname) > bsz) return 0;
-  *(r++) = '_';
-  r = SWIG_PackData(r,ptr,sz);
-  if (lname) {
-    strncpy(r,name,lname+1);
-  } else {
-    *r = 0;
-  }
-  return buff;
-}
+	SWIGRUNTIME char *SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) {
+		char *r = buff;
+		size_t lname = (name ? strlen(name) : 0);
+		if ((2 * sz + 2 + lname) > bsz)
+			return 0;
+		*(r++) = '_';
+		r = SWIG_PackData(r, ptr, sz);
+		if (lname) {
+			strncpy(r, name, lname + 1);
+		} else {
+			*r = 0;
+		}
+		return buff;
+	}
 
-SWIGRUNTIME const char *
-SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) {
-  if (*c != '_') {
-    if (strcmp(c,"NULL") == 0) {
-      memset(ptr,0,sz);
-      return name;
-    } else {
-      return 0;
-    }
-  }
-  return SWIG_UnpackData(++c,ptr,sz);
-}
+	SWIGRUNTIME const char *SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) {
+		if (*c != '_') {
+			if (strcmp(c, "NULL") == 0) {
+				memset(ptr, 0, sz);
+				return name;
+			} else {
+				return 0;
+			}
+		}
+		return SWIG_UnpackData(++c, ptr, sz);
+	}
 
 #ifdef __cplusplus
 }
@@ -551,14 +544,14 @@ extern "C" {
 #define SWIG_PY_BINARY  5
 
 /* Constant information structure */
-typedef struct swig_const_info {
-    int type;
-    char *name;
-    long lvalue;
-    double dvalue;
-    void   *pvalue;
-    swig_type_info **ptype;
-} swig_const_info;
+	typedef struct swig_const_info {
+		int type;
+		char *name;
+		long lvalue;
+		double dvalue;
+		void *pvalue;
+		swig_type_info **ptype;
+	} swig_const_info;
 
 
 /* -----------------------------------------------------------------------------
@@ -571,8 +564,6 @@ typedef struct swig_const_info {
 #ifdef __cplusplus
 }
 #endif
-
-
 /***********************************************************************
  * pyrun.swg
  *
@@ -581,44 +572,33 @@ typedef struct swig_const_info {
  *     type checking.
  *
  * Author : David Beazley (beazley@cs.uchicago.edu)
- ************************************************************************/
-
-/* Common SWIG API */
+																																																																																																																																	   ************************************************************************//* Common SWIG API */
 #define SWIG_ConvertPtr(obj, pp, type, flags)    SWIG_Python_ConvertPtr(obj, pp, type, flags)
 #define SWIG_NewPointerObj(p, type, flags)       SWIG_Python_NewPointerObj(p, type, flags)
 #define SWIG_MustGetPtr(p, type, argnum, flags)  SWIG_Python_MustGetPtr(p, type, argnum, flags)
- 
-
 /* Python-specific SWIG API */
 #define SWIG_ConvertPacked(obj, ptr, sz, ty, flags)   SWIG_Python_ConvertPacked(obj, ptr, sz, ty, flags)
 #define SWIG_NewPackedObj(ptr, sz, type)              SWIG_Python_NewPackedObj(ptr, sz, type)
-
 /* Runtime API */
 #define SWIG_GetModule(clientdata) SWIG_Python_GetModule()
 #define SWIG_SetModule(clientdata, pointer) SWIG_Python_SetModule(pointer)
-
 /* -----------------------------------------------------------------------------
  * Pointer declarations
- * ----------------------------------------------------------------------------- */
-/*
-  Use SWIG_NO_COBJECT_TYPES to force the use of strings to represent
-  C/C++ pointers in the python side. Very useful for debugging, but
-  not always safe.
-*/
+																																																																																		  																																									  																				    * ----------------------------------------------------------------------------- *//*
+																																																																																		     Use SWIG_NO_COBJECT_TYPES to force the use of strings to represent
+																																																																																		     C/C++ pointers in the python side. Very useful for debugging, but
+																																																																																		     not always safe.
+																																																																																		   */
 #if !defined(SWIG_NO_COBJECT_TYPES) && !defined(SWIG_COBJECT_TYPES)
 #  define SWIG_COBJECT_TYPES
 #endif
-
 /* Flags for pointer conversion */
 #define SWIG_POINTER_EXCEPTION     0x1
 #define SWIG_POINTER_DISOWN        0x2
-
-
 /* Add PyOS_snprintf for old Pythons */
 #if PY_VERSION_HEX < 0x02020000
 #define PyOS_snprintf snprintf
 #endif
-
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -632,507 +612,451 @@ extern "C" {
 
 /* A crude PyString_FromFormat implementation for old Pythons */
 #if PY_VERSION_HEX < 0x02020000
-static PyObject *
-PyString_FromFormat(const char *fmt, ...) {
-  va_list ap;
-  char buf[SWIG_BUFFER_SIZE * 2];
-  int res;
-  va_start(ap, fmt);
-  res = vsnprintf(buf, sizeof(buf), fmt, ap);
-  va_end(ap);
-  return (res < 0 || res >= sizeof(buf)) ? 0 : PyString_FromString(buf);
-}
+	static PyObject *PyString_FromFormat(const char *fmt, ...) {
+		va_list ap;
+		char buf[SWIG_BUFFER_SIZE * 2];
+		int res;
+		    va_start(ap, fmt);
+		    res = vsnprintf(buf, sizeof(buf), fmt, ap);
+		    va_end(ap);
+		    return (res < 0 || res >= sizeof(buf)) ? 0 : PyString_FromString(buf);
+	}
 #endif
-
 #if PY_VERSION_HEX < 0x01060000
 #define PyObject_Del(op) PyMem_DEL((op))
 #endif
-
 #if defined(SWIG_COBJECT_TYPES)
 #if !defined(SWIG_COBJECT_PYTHON)
 /* -----------------------------------------------------------------------------
  * Implements a simple Swig Object type, and use it instead of PyCObject
- * ----------------------------------------------------------------------------- */
-
-typedef struct {
-  PyObject_HEAD
-  void *ptr;
-  const char *desc;
-} PySwigObject;
+ * ----------------------------------------------------------------------------- */ typedef struct {
+		PyObject_HEAD void *ptr;
+		const char *desc;
+	} PySwigObject;
 
 /* Declarations for objects of type PySwigObject */
 
-SWIGRUNTIME int
-PySwigObject_print(PySwigObject *v, FILE *fp, int flags)
-{
-  char result[SWIG_BUFFER_SIZE];
-  flags = flags;
-  if (SWIG_PackVoidPtr(result, v->ptr, v->desc, sizeof(result))) {
-    fputs("", fp);
-    return 0; 
-  } else {
-    return 1; 
-  }
-}
-  
-SWIGRUNTIME PyObject *
-PySwigObject_repr(PySwigObject *v)
-{
-  char result[SWIG_BUFFER_SIZE];
-  return SWIG_PackVoidPtr(result, v->ptr, v->desc, sizeof(result)) ?
-    PyString_FromFormat("", result) : 0;
-}
+	SWIGRUNTIME int
+	    PySwigObject_print(PySwigObject * v, FILE * fp, int flags) {
+		char result[SWIG_BUFFER_SIZE];
+		flags = flags;
+		if (SWIG_PackVoidPtr(result, v->ptr, v->desc, sizeof(result))) {
+			fputs("", fp);
+			return 0;
+		} else {
+			return 1;
+		}
+	}
 
-SWIGRUNTIME PyObject *
-PySwigObject_str(PySwigObject *v)
-{
-  char result[SWIG_BUFFER_SIZE];
-  return SWIG_PackVoidPtr(result, v->ptr, v->desc, sizeof(result)) ?
-    PyString_FromString(result) : 0;
-}
+	SWIGRUNTIME PyObject *PySwigObject_repr(PySwigObject * v) {
+		char result[SWIG_BUFFER_SIZE];
+		return SWIG_PackVoidPtr(result, v->ptr, v->desc, sizeof(result)) ?
+			PyString_FromFormat("", result) : 0;
+	}
 
-SWIGRUNTIME PyObject *
-PySwigObject_long(PySwigObject *v)
-{
-  return PyLong_FromVoidPtr(v->ptr);
-}
+	SWIGRUNTIME PyObject *PySwigObject_str(PySwigObject * v) {
+		char result[SWIG_BUFFER_SIZE];
+		return SWIG_PackVoidPtr(result, v->ptr, v->desc, sizeof(result)) ? PyString_FromString(result) : 0;
+	}
 
-SWIGRUNTIME PyObject *
-PySwigObject_format(const char* fmt, PySwigObject *v)
-{
-  PyObject *res = NULL;
-  PyObject *args = PyTuple_New(1);
-  if (args && (PyTuple_SetItem(args, 0, PySwigObject_long(v)) == 0)) {
-    PyObject *ofmt = PyString_FromString(fmt);
-    if (ofmt) {
-      res = PyString_Format(ofmt,args);
-      Py_DECREF(ofmt);
-    }
-    Py_DECREF(args);
-  }  
-  return res;
-}
+	SWIGRUNTIME PyObject *PySwigObject_long(PySwigObject * v) {
+		return PyLong_FromVoidPtr(v->ptr);
+	}
 
-SWIGRUNTIME PyObject *
-PySwigObject_oct(PySwigObject *v)
-{
-  return PySwigObject_format("%o",v);
-}
+	SWIGRUNTIME PyObject *PySwigObject_format(const char *fmt, PySwigObject * v) {
+		PyObject *res = NULL;
+		PyObject *args = PyTuple_New(1);
+		if (args && (PyTuple_SetItem(args, 0, PySwigObject_long(v)) == 0)) {
+			PyObject *ofmt = PyString_FromString(fmt);
+			if (ofmt) {
+				res = PyString_Format(ofmt, args);
+				Py_DECREF(ofmt);
+			}
+			Py_DECREF(args);
+		}
+		return res;
+	}
 
-SWIGRUNTIME PyObject *
-PySwigObject_hex(PySwigObject *v)
-{
-  return PySwigObject_format("%x",v);
-}
+	SWIGRUNTIME PyObject *PySwigObject_oct(PySwigObject * v) {
+		return PySwigObject_format("%o", v);
+	}
 
-SWIGRUNTIME int
-PySwigObject_compare(PySwigObject *v, PySwigObject *w)
-{
-  int c = strcmp(v->desc, w->desc);
-  if (c) {
-    return (c > 0) ? 1 : -1;
-  } else {
-    void *i = v->ptr;
-    void *j = w->ptr;
-    return (i < j) ? -1 : ((i > j) ? 1 : 0);
-  }
-}
+	SWIGRUNTIME PyObject *PySwigObject_hex(PySwigObject * v) {
+		return PySwigObject_format("%x", v);
+	}
 
-SWIGRUNTIME void
-PySwigObject_dealloc(PySwigObject *self)
-{
-  PyObject_Del(self);
-}
+	SWIGRUNTIME int
+	    PySwigObject_compare(PySwigObject * v, PySwigObject * w) {
+		int c = strcmp(v->desc, w->desc);
+		if (c) {
+			return (c > 0) ? 1 : -1;
+		} else {
+			void *i = v->ptr;
+			void *j = w->ptr;
+			return (i < j) ? -1 : ((i > j) ? 1 : 0);
+		}
+	}
 
-SWIGRUNTIME PyTypeObject*
-PySwigObject_type(void) {
-  static char pyswigobject_type__doc__[] = 
-    "Swig object carries a C/C++ instance pointer";
-  
-  static PyNumberMethods PySwigObject_as_number = {
-    (binaryfunc)0, /*nb_add*/
-    (binaryfunc)0, /*nb_subtract*/
-    (binaryfunc)0, /*nb_multiply*/
-    (binaryfunc)0, /*nb_divide*/
-    (binaryfunc)0, /*nb_remainder*/
-    (binaryfunc)0, /*nb_divmod*/
-    (ternaryfunc)0,/*nb_power*/
-    (unaryfunc)0,  /*nb_negative*/
-    (unaryfunc)0,  /*nb_positive*/
-    (unaryfunc)0,  /*nb_absolute*/
-    (inquiry)0,    /*nb_nonzero*/
-    0,		   /*nb_invert*/
-    0,		   /*nb_lshift*/
-    0,		   /*nb_rshift*/
-    0,		   /*nb_and*/
-    0,		   /*nb_xor*/
-    0,		   /*nb_or*/
-    (coercion)0,   /*nb_coerce*/
-    (unaryfunc)PySwigObject_long, /*nb_int*/
-    (unaryfunc)PySwigObject_long, /*nb_long*/
-    (unaryfunc)0,                 /*nb_float*/
-    (unaryfunc)PySwigObject_oct,  /*nb_oct*/
-    (unaryfunc)PySwigObject_hex,  /*nb_hex*/
+	SWIGRUNTIME void
+	     PySwigObject_dealloc(PySwigObject * self) {
+		PyObject_Del(self);
+	}
+
+	SWIGRUNTIME PyTypeObject *PySwigObject_type(void) {
+		static char pyswigobject_type__doc__[] = "Swig object carries a C/C++ instance pointer";
+
+		static PyNumberMethods PySwigObject_as_number = {
+			(binaryfunc) 0,		/*nb_add */
+			(binaryfunc) 0,		/*nb_subtract */
+			(binaryfunc) 0,		/*nb_multiply */
+			(binaryfunc) 0,		/*nb_divide */
+			(binaryfunc) 0,		/*nb_remainder */
+			(binaryfunc) 0,		/*nb_divmod */
+			(ternaryfunc) 0,	/*nb_power */
+			(unaryfunc) 0,		/*nb_negative */
+			(unaryfunc) 0,		/*nb_positive */
+			(unaryfunc) 0,		/*nb_absolute */
+			(inquiry) 0,		/*nb_nonzero */
+			0,					/*nb_invert */
+			0,					/*nb_lshift */
+			0,					/*nb_rshift */
+			0,					/*nb_and */
+			0,					/*nb_xor */
+			0,					/*nb_or */
+			(coercion) 0,		/*nb_coerce */
+			(unaryfunc) PySwigObject_long,	/*nb_int */
+			(unaryfunc) PySwigObject_long,	/*nb_long */
+			(unaryfunc) 0,		/*nb_float */
+			(unaryfunc) PySwigObject_oct,	/*nb_oct */
+			(unaryfunc) PySwigObject_hex,	/*nb_hex */
 #if PY_VERSION_HEX >= 0x02020000
-    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_true_divide */ 
+			0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0	/* nb_inplace_add -> nb_inplace_true_divide */
 #elif PY_VERSION_HEX >= 0x02000000
-    0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_or */
+			0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0	/* nb_inplace_add -> nb_inplace_or */
 #endif
-  };
+		};
 
-  static PyTypeObject pyswigobject_type
+		static PyTypeObject pyswigobject_type
 #if !defined(__cplusplus)
-  ;  
-  static int type_init = 0;
-  if (!type_init) {
-    PyTypeObject tmp
+		            ;
+		static int type_init = 0;
+		if (!type_init) {
+			PyTypeObject tmp
 #endif
-    = {
-    PyObject_HEAD_INIT(&PyType_Type)
-    0,					/*ob_size*/
-    (char *)"PySwigObject",		/*tp_name*/
-    sizeof(PySwigObject),		/*tp_basicsize*/
-    0,					/*tp_itemsize*/
-    /* methods */
-    (destructor)PySwigObject_dealloc,	/*tp_dealloc*/
-    (printfunc)PySwigObject_print,	/*tp_print*/
-    (getattrfunc)0,			/*tp_getattr*/
-    (setattrfunc)0,			/*tp_setattr*/
-    (cmpfunc)PySwigObject_compare,	/*tp_compare*/
-    (reprfunc)PySwigObject_repr,	/*tp_repr*/
-    &PySwigObject_as_number,	        /*tp_as_number*/
-    0,					/*tp_as_sequence*/
-    0,					/*tp_as_mapping*/
-    (hashfunc)0,			/*tp_hash*/
-    (ternaryfunc)0,			/*tp_call*/
-    (reprfunc)PySwigObject_str,		/*tp_str*/
-    /* Space for future expansion */
-    0,0,0,0,
-    pyswigobject_type__doc__, 	        /* Documentation string */
+				= {
+				PyObject_HEAD_INIT(&PyType_Type)
+					0,			/*ob_size */
+				(char *) "PySwigObject",	/*tp_name */
+				sizeof(PySwigObject),	/*tp_basicsize */
+				0,				/*tp_itemsize */
+				/* methods */
+				(destructor) PySwigObject_dealloc,	/*tp_dealloc */
+				(printfunc) PySwigObject_print,	/*tp_print */
+				(getattrfunc) 0,	/*tp_getattr */
+				(setattrfunc) 0,	/*tp_setattr */
+				(cmpfunc) PySwigObject_compare,	/*tp_compare */
+				(reprfunc) PySwigObject_repr,	/*tp_repr */
+				&PySwigObject_as_number,	/*tp_as_number */
+				0,				/*tp_as_sequence */
+				0,				/*tp_as_mapping */
+				(hashfunc) 0,	/*tp_hash */
+				(ternaryfunc) 0,	/*tp_call */
+				(reprfunc) PySwigObject_str,	/*tp_str */
+				/* Space for future expansion */
+				0, 0, 0, 0,
+				pyswigobject_type__doc__,	/* Documentation string */
 #if PY_VERSION_HEX >= 0x02000000
-    0,                                  /* tp_traverse */
-    0,                                  /* tp_clear */
+				0,				/* tp_traverse */
+				0,				/* tp_clear */
 #endif
 #if PY_VERSION_HEX >= 0x02010000
-    0,                                  /* tp_richcompare */
-    0,                                  /* tp_weaklistoffset */
+				0,				/* tp_richcompare */
+				0,				/* tp_weaklistoffset */
 #endif
 #if PY_VERSION_HEX >= 0x02020000
-    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* tp_iter -> tp_weaklist */
+				0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,	/* tp_iter -> tp_weaklist */
 #endif
 #if PY_VERSION_HEX >= 0x02030000
-    0,                                  /* tp_del */
+				0,				/* tp_del */
 #endif
 #ifdef COUNT_ALLOCS
-    0,0,0,0                             /* tp_alloc -> tp_next */
+				0, 0, 0, 0		/* tp_alloc -> tp_next */
 #endif
-    };
+			};
 #if !defined(__cplusplus)
-    pyswigobject_type = tmp;
-    type_init = 1;
-  }
+			pyswigobject_type = tmp;
+			type_init = 1;
+		}
 #endif
-  return &pyswigobject_type;
-}
+		return &pyswigobject_type;
+	}
 
-SWIGRUNTIME PyObject *
-PySwigObject_FromVoidPtrAndDesc(void *ptr, const char *desc)
-{
-  PySwigObject *self = PyObject_NEW(PySwigObject, PySwigObject_type());
-  if (self) {
-    self->ptr = ptr;
-    self->desc = desc;
-  }
-  return (PyObject *)self;
-}
+	SWIGRUNTIME PyObject *PySwigObject_FromVoidPtrAndDesc(void *ptr, const char *desc) {
+		PySwigObject *self = PyObject_NEW(PySwigObject, PySwigObject_type());
+		if (self) {
+			self->ptr = ptr;
+			self->desc = desc;
+		}
+		return (PyObject *) self;
+	}
 
-SWIGRUNTIMEINLINE void *
-PySwigObject_AsVoidPtr(PyObject *self)
-{
-  return ((PySwigObject *)self)->ptr;
-}
+	SWIGRUNTIMEINLINE void *PySwigObject_AsVoidPtr(PyObject * self) {
+		return ((PySwigObject *) self)->ptr;
+	}
 
-SWIGRUNTIMEINLINE const char *
-PySwigObject_GetDesc(PyObject *self)
-{
-  return ((PySwigObject *)self)->desc;
-}
+	SWIGRUNTIMEINLINE const char *PySwigObject_GetDesc(PyObject * self) {
+		return ((PySwigObject *) self)->desc;
+	}
 
-SWIGRUNTIMEINLINE int
-PySwigObject_Check(PyObject *op) {
-  return ((op)->ob_type == PySwigObject_type()) 
-    || (strcmp((op)->ob_type->tp_name,"PySwigObject") == 0);
-}
+	SWIGRUNTIMEINLINE int
+	    PySwigObject_Check(PyObject * op) {
+		return ((op)->ob_type == PySwigObject_type())
+			|| (strcmp((op)->ob_type->tp_name, "PySwigObject") == 0);
+	}
 
 /* -----------------------------------------------------------------------------
  * Implements a simple Swig Packed type, and use it instead of string
  * ----------------------------------------------------------------------------- */
 
-typedef struct {
-  PyObject_HEAD
-  void *pack;
-  const char *desc;
-  size_t size;
-} PySwigPacked;
+	typedef struct {
+		PyObject_HEAD void *pack;
+		const char *desc;
+		size_t size;
+	} PySwigPacked;
 
-SWIGRUNTIME int
-PySwigPacked_print(PySwigPacked *v, FILE *fp, int flags)
-{
-  char result[SWIG_BUFFER_SIZE];
-  flags = flags;
-  fputs("pack, v->size, 0, sizeof(result))) {
-    fputs("at ", fp); 
-    fputs(result, fp); 
-  }
-  fputs(v->desc,fp); 
-  fputs(">", fp);
-  return 0; 
-}
-  
-SWIGRUNTIME PyObject *
-PySwigPacked_repr(PySwigPacked *v)
-{
-  char result[SWIG_BUFFER_SIZE];
-  if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) {
-    return PyString_FromFormat("", result, v->desc);
-  } else {
-    return PyString_FromFormat("", v->desc);
-  }  
-}
+	SWIGRUNTIME int
+	    PySwigPacked_print(PySwigPacked * v, FILE * fp, int flags) {
+		char result[SWIG_BUFFER_SIZE];
+		flags = flags;
+		fputs("pack, v->size, 0, sizeof(result))) {
+			fputs("at ", fp);
+			fputs(result, fp);
+		}
+		fputs(v->desc, fp);
+		fputs(">", fp);
+		return 0;
+	}
 
-SWIGRUNTIME PyObject *
-PySwigPacked_str(PySwigPacked *v)
-{
-  char result[SWIG_BUFFER_SIZE];
-  if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))){
-    return PyString_FromFormat("%s%s", result, v->desc);
-  } else {
-    return PyString_FromString(v->desc);
-  }  
-}
+	SWIGRUNTIME PyObject *PySwigPacked_repr(PySwigPacked * v) {
+		char result[SWIG_BUFFER_SIZE];
+		if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) {
+			return PyString_FromFormat("", result, v->desc);
+		} else {
+			return PyString_FromFormat("", v->desc);
+		}
+	}
 
-SWIGRUNTIME int
-PySwigPacked_compare(PySwigPacked *v, PySwigPacked *w)
-{
-  int c = strcmp(v->desc, w->desc);
-  if (c) {
-    return (c > 0) ? 1 : -1;
-  } else {
-    size_t i = v->size;
-    size_t j = w->size;
-    int s = (i < j) ? -1 : ((i > j) ? 1 : 0);
-    return s ? s : strncmp((char *)v->pack, (char *)w->pack, 2*v->size);
-  }
-}
+	SWIGRUNTIME PyObject *PySwigPacked_str(PySwigPacked * v) {
+		char result[SWIG_BUFFER_SIZE];
+		if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) {
+			return PyString_FromFormat("%s%s", result, v->desc);
+		} else {
+			return PyString_FromString(v->desc);
+		}
+	}
 
-SWIGRUNTIME void
-PySwigPacked_dealloc(PySwigPacked *self)
-{
-  free(self->pack);
-  PyObject_Del(self);
-}
+	SWIGRUNTIME int
+	    PySwigPacked_compare(PySwigPacked * v, PySwigPacked * w) {
+		int c = strcmp(v->desc, w->desc);
+		if (c) {
+			return (c > 0) ? 1 : -1;
+		} else {
+			size_t i = v->size;
+			size_t j = w->size;
+			int s = (i < j) ? -1 : ((i > j) ? 1 : 0);
+			return s ? s : strncmp((char *) v->pack, (char *) w->pack, 2 * v->size);
+		}
+	}
 
-SWIGRUNTIME PyTypeObject*
-PySwigPacked_type(void) {
-  static char pyswigpacked_type__doc__[] = 
-    "Swig object carries a C/C++ instance pointer";
-  static PyTypeObject pyswigpacked_type
+	SWIGRUNTIME void
+	     PySwigPacked_dealloc(PySwigPacked * self) {
+		free(self->pack);
+		PyObject_Del(self);
+	}
+
+	SWIGRUNTIME PyTypeObject *PySwigPacked_type(void) {
+		static char pyswigpacked_type__doc__[] = "Swig object carries a C/C++ instance pointer";
+		static PyTypeObject pyswigpacked_type
 #if !defined(__cplusplus)
-  ;
-  static int type_init = 0;  
-  if (!type_init) {
-    PyTypeObject tmp
+		            ;
+		static int type_init = 0;
+		if (!type_init) {
+			PyTypeObject tmp
 #endif
-    = {
-    PyObject_HEAD_INIT(&PyType_Type)
-    0,					/*ob_size*/
-    (char *)"PySwigPacked",		/*tp_name*/
-    sizeof(PySwigPacked),		/*tp_basicsize*/
-    0,					/*tp_itemsize*/
-    /* methods */
-    (destructor)PySwigPacked_dealloc,	/*tp_dealloc*/
-    (printfunc)PySwigPacked_print,	/*tp_print*/
-    (getattrfunc)0,			/*tp_getattr*/
-    (setattrfunc)0,			/*tp_setattr*/
-    (cmpfunc)PySwigPacked_compare,	/*tp_compare*/
-    (reprfunc)PySwigPacked_repr,	/*tp_repr*/
-    0,	                                /*tp_as_number*/
-    0,					/*tp_as_sequence*/
-    0,					/*tp_as_mapping*/
-    (hashfunc)0,			/*tp_hash*/
-    (ternaryfunc)0,			/*tp_call*/
-    (reprfunc)PySwigPacked_str,		/*tp_str*/
-    /* Space for future expansion */
-    0,0,0,0,
-    pyswigpacked_type__doc__, 	        /* Documentation string */
+				= {
+				PyObject_HEAD_INIT(&PyType_Type)
+					0,			/*ob_size */
+				(char *) "PySwigPacked",	/*tp_name */
+				sizeof(PySwigPacked),	/*tp_basicsize */
+				0,				/*tp_itemsize */
+				/* methods */
+				(destructor) PySwigPacked_dealloc,	/*tp_dealloc */
+				(printfunc) PySwigPacked_print,	/*tp_print */
+				(getattrfunc) 0,	/*tp_getattr */
+				(setattrfunc) 0,	/*tp_setattr */
+				(cmpfunc) PySwigPacked_compare,	/*tp_compare */
+				(reprfunc) PySwigPacked_repr,	/*tp_repr */
+				0,				/*tp_as_number */
+				0,				/*tp_as_sequence */
+				0,				/*tp_as_mapping */
+				(hashfunc) 0,	/*tp_hash */
+				(ternaryfunc) 0,	/*tp_call */
+				(reprfunc) PySwigPacked_str,	/*tp_str */
+				/* Space for future expansion */
+				0, 0, 0, 0,
+				pyswigpacked_type__doc__,	/* Documentation string */
 #if PY_VERSION_HEX >= 0x02000000
-    0,                                  /* tp_traverse */
-    0,                                  /* tp_clear */
+				0,				/* tp_traverse */
+				0,				/* tp_clear */
 #endif
 #if PY_VERSION_HEX >= 0x02010000
-    0,                                  /* tp_richcompare */
-    0,                                  /* tp_weaklistoffset */
+				0,				/* tp_richcompare */
+				0,				/* tp_weaklistoffset */
 #endif
-#if PY_VERSION_HEX >= 0x02020000         
-    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* tp_iter -> tp_weaklist */
+#if PY_VERSION_HEX >= 0x02020000
+				0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,	/* tp_iter -> tp_weaklist */
 #endif
 #if PY_VERSION_HEX >= 0x02030000
-    0,                                  /* tp_del */
+				0,				/* tp_del */
 #endif
 #ifdef COUNT_ALLOCS
-    0,0,0,0                             /* tp_alloc -> tp_next */
+				0, 0, 0, 0		/* tp_alloc -> tp_next */
 #endif
-    };
+			};
 #if !defined(__cplusplus)
-    pyswigpacked_type = tmp;
-    type_init = 1;
-  }
+			pyswigpacked_type = tmp;
+			type_init = 1;
+		}
 #endif
-  return &pyswigpacked_type;
-}
+		return &pyswigpacked_type;
+	}
 
-SWIGRUNTIME PyObject *
-PySwigPacked_FromDataAndDesc(void *ptr, size_t size, const char *desc)
-{
-  PySwigPacked *self = PyObject_NEW(PySwigPacked, PySwigPacked_type());
-  if (self == NULL) {
-    return NULL;
-  } else {
-    void *pack = malloc(size);
-    if (pack) {
-      memcpy(pack, ptr, size);
-      self->pack = pack;
-      self->desc = desc;
-      self->size = size;
-      return (PyObject *) self;
-    }
-    return NULL;
-  }
-}
+	SWIGRUNTIME PyObject *PySwigPacked_FromDataAndDesc(void *ptr, size_t size, const char *desc) {
+		PySwigPacked *self = PyObject_NEW(PySwigPacked, PySwigPacked_type());
+		if (self == NULL) {
+			return NULL;
+		} else {
+			void *pack = malloc(size);
+			if (pack) {
+				memcpy(pack, ptr, size);
+				self->pack = pack;
+				self->desc = desc;
+				self->size = size;
+				return (PyObject *) self;
+			}
+			return NULL;
+		}
+	}
 
-SWIGRUNTIMEINLINE const char *
-PySwigPacked_UnpackData(PyObject *obj, void *ptr, size_t size)
-{
-  PySwigPacked *self = (PySwigPacked *)obj;
-  if (self->size != size) return 0;
-  memcpy(ptr, self->pack, size);
-  return self->desc;
-}
+	SWIGRUNTIMEINLINE const char *PySwigPacked_UnpackData(PyObject * obj, void *ptr, size_t size) {
+		PySwigPacked *self = (PySwigPacked *) obj;
+		if (self->size != size)
+			return 0;
+		memcpy(ptr, self->pack, size);
+		return self->desc;
+	}
 
-SWIGRUNTIMEINLINE const char *
-PySwigPacked_GetDesc(PyObject *self)
-{
-  return ((PySwigPacked *)self)->desc;
-}
+	SWIGRUNTIMEINLINE const char *PySwigPacked_GetDesc(PyObject * self) {
+		return ((PySwigPacked *) self)->desc;
+	}
 
-SWIGRUNTIMEINLINE int
-PySwigPacked_Check(PyObject *op) {
-  return ((op)->ob_type == PySwigPacked_type()) 
-    || (strcmp((op)->ob_type->tp_name,"PySwigPacked") == 0);
-}
+	SWIGRUNTIMEINLINE int
+	    PySwigPacked_Check(PyObject * op) {
+		return ((op)->ob_type == PySwigPacked_type())
+			|| (strcmp((op)->ob_type->tp_name, "PySwigPacked") == 0);
+	}
 
 #else
 /* -----------------------------------------------------------------------------
  * Use the old Python PyCObject instead of PySwigObject
  * ----------------------------------------------------------------------------- */
-
 #define PySwigObject_GetDesc(obj)	           PyCObject_GetDesc(obj)
 #define PySwigObject_Check(obj)	           PyCObject_Check(obj)
 #define PySwigObject_AsVoidPtr(obj)	   PyCObject_AsVoidPtr(obj)
 #define PySwigObject_FromVoidPtrAndDesc(p, d)  PyCObject_FromVoidPtrAndDesc(p, d, NULL)
-
 #endif
-
 #endif
-
 /* -----------------------------------------------------------------------------
  * errors manipulation
- * ----------------------------------------------------------------------------- */
-
-SWIGRUNTIME void
-SWIG_Python_TypeError(const char *type, PyObject *obj)
-{
-  if (type) {
+ * ----------------------------------------------------------------------------- */ SWIGRUNTIME void
+	     SWIG_Python_TypeError(const char *type, PyObject * obj) {
+		if (type) {
 #if defined(SWIG_COBJECT_TYPES)
-    if (obj && PySwigObject_Check(obj)) {
-      const char *otype = (const char *) PySwigObject_GetDesc(obj);
-      if (otype) {
-	PyErr_Format(PyExc_TypeError, "a '%s' is expected, 'PySwigObject(%s)' is received",
-		     type, otype);
-	return;
-      }
-    } else 
-#endif      
-    {
-      const char *otype = (obj ? obj->ob_type->tp_name : 0); 
-      if (otype) {
-	PyObject *str = PyObject_Str(obj);
-	const char *cstr = str ? PyString_AsString(str) : 0;
-	if (cstr) {
-	  PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s(%s)' is received",
-		       type, otype, cstr);
-	} else {
-	  PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s' is received",
-		       type, otype);
+			if (obj && PySwigObject_Check(obj)) {
+				const char *otype = (const char *) PySwigObject_GetDesc(obj);
+				if (otype) {
+					PyErr_Format(PyExc_TypeError, "a '%s' is expected, 'PySwigObject(%s)' is received", type, otype);
+					return;
+				}
+			} else
+#endif
+			{
+				const char *otype = (obj ? obj->ob_type->tp_name : 0);
+				if (otype) {
+					PyObject *str = PyObject_Str(obj);
+					const char *cstr = str ? PyString_AsString(str) : 0;
+					if (cstr) {
+						PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s(%s)' is received", type, otype, cstr);
+					} else {
+						PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s' is received", type, otype);
+					}
+					Py_XDECREF(str);
+					return;
+				}
+			}
+			PyErr_Format(PyExc_TypeError, "a '%s' is expected", type);
+		} else {
+			PyErr_Format(PyExc_TypeError, "unexpected type is received");
+		}
 	}
-	Py_XDECREF(str);
-	return;
-      }
-    }   
-    PyErr_Format(PyExc_TypeError, "a '%s' is expected", type);
-  } else {
-    PyErr_Format(PyExc_TypeError, "unexpected type is received");
-  }
-}
 
-SWIGRUNTIMEINLINE void
-SWIG_Python_NullRef(const char *type)
-{
-  if (type) {
-    PyErr_Format(PyExc_TypeError, "null reference of type '%s' was received",type);
-  } else {
-    PyErr_Format(PyExc_TypeError, "null reference was received");
-  }
-}
+	SWIGRUNTIMEINLINE void
+	     SWIG_Python_NullRef(const char *type) {
+		if (type) {
+			PyErr_Format(PyExc_TypeError, "null reference of type '%s' was received", type);
+		} else {
+			PyErr_Format(PyExc_TypeError, "null reference was received");
+		}
+	}
 
-SWIGRUNTIME int
-SWIG_Python_AddErrMesg(const char* mesg, int infront)
-{
-  if (PyErr_Occurred()) {
-    PyObject *type = 0;
-    PyObject *value = 0;
-    PyObject *traceback = 0;
-    PyErr_Fetch(&type, &value, &traceback);
-    if (value) {
-      PyObject *old_str = PyObject_Str(value);
-      Py_XINCREF(type);
-      PyErr_Clear();
-      if (infront) {
-	PyErr_Format(type, "%s %s", mesg, PyString_AsString(old_str));
-      } else {
-	PyErr_Format(type, "%s %s", PyString_AsString(old_str), mesg);
-      }
-      Py_DECREF(old_str);
-    }
-    return 1;
-  } else {
-    return 0;
-  }
-}
+	SWIGRUNTIME int
+	    SWIG_Python_AddErrMesg(const char *mesg, int infront) {
+		if (PyErr_Occurred()) {
+			PyObject *type = 0;
+			PyObject *value = 0;
+			PyObject *traceback = 0;
+			PyErr_Fetch(&type, &value, &traceback);
+			if (value) {
+				PyObject *old_str = PyObject_Str(value);
+				Py_XINCREF(type);
+				PyErr_Clear();
+				if (infront) {
+					PyErr_Format(type, "%s %s", mesg, PyString_AsString(old_str));
+				} else {
+					PyErr_Format(type, "%s %s", PyString_AsString(old_str), mesg);
+				}
+				Py_DECREF(old_str);
+			}
+			return 1;
+		} else {
+			return 0;
+		}
+	}
 
-SWIGRUNTIME int
-SWIG_Python_ArgFail(int argnum)
-{
-  if (PyErr_Occurred()) {
-    /* add information about failing argument */
-    char mesg[256];
-    PyOS_snprintf(mesg, sizeof(mesg), "argument number %d:", argnum);
-    return SWIG_Python_AddErrMesg(mesg, 1);
-  } else {
-    return 0;
-  }
-}
+	SWIGRUNTIME int
+	    SWIG_Python_ArgFail(int argnum) {
+		if (PyErr_Occurred()) {
+			/* add information about failing argument */
+			char mesg[256];
+			PyOS_snprintf(mesg, sizeof(mesg), "argument number %d:", argnum);
+			return SWIG_Python_AddErrMesg(mesg, 1);
+		} else {
+			return 0;
+		}
+	}
 
 
 /* -----------------------------------------------------------------------------
@@ -1140,272 +1064,275 @@ SWIG_Python_ArgFail(int argnum)
  * ----------------------------------------------------------------------------- */
 
 /* Convert a pointer value */
-SWIGRUNTIME int
-SWIG_Python_ConvertPtr(PyObject *obj, void **ptr, swig_type_info *ty, int flags) {
-  swig_cast_info *tc;
-  const char *c = 0;
-  static PyObject *SWIG_this = 0;
-  int    newref = 0;
-  PyObject  *pyobj = 0;
-  void *vptr;
-  
-  if (!obj) return 0;
-  if (obj == Py_None) {
-    *ptr = 0;
-    return 0;
-  }
+	SWIGRUNTIME int
+	    SWIG_Python_ConvertPtr(PyObject * obj, void **ptr, swig_type_info * ty, int flags) {
+		swig_cast_info *tc;
+		const char *c = 0;
+		static PyObject *SWIG_this = 0;
+		int newref = 0;
+		PyObject *pyobj = 0;
+		void *vptr;
 
+		if (!obj)
+			return 0;
+		if (obj == Py_None) {
+			*ptr = 0;
+			return 0;
+		}
 #ifdef SWIG_COBJECT_TYPES
-  if (!(PySwigObject_Check(obj))) {
-    if (!SWIG_this)
-      SWIG_this = PyString_FromString("this");
-    pyobj = obj;
-    obj = PyObject_GetAttr(obj,SWIG_this);
-    newref = 1;
-    if (!obj) goto type_error;
-    if (!PySwigObject_Check(obj)) {
-      Py_DECREF(obj);
-      goto type_error;
-    }
-  }  
-  vptr = PySwigObject_AsVoidPtr(obj);
-  c = (const char *) PySwigObject_GetDesc(obj);
-  if (newref) { Py_DECREF(obj); }
-  goto type_check;
+		if (!(PySwigObject_Check(obj))) {
+			if (!SWIG_this)
+				SWIG_this = PyString_FromString("this");
+			pyobj = obj;
+			obj = PyObject_GetAttr(obj, SWIG_this);
+			newref = 1;
+			if (!obj)
+				goto type_error;
+			if (!PySwigObject_Check(obj)) {
+				Py_DECREF(obj);
+				goto type_error;
+			}
+		}
+		vptr = PySwigObject_AsVoidPtr(obj);
+		c = (const char *) PySwigObject_GetDesc(obj);
+		if (newref) {
+			Py_DECREF(obj);
+		}
+		goto type_check;
 #else
-  if (!(PyString_Check(obj))) {
-    if (!SWIG_this)
-      SWIG_this = PyString_FromString("this");
-    pyobj = obj;
-    obj = PyObject_GetAttr(obj,SWIG_this);
-    newref = 1;
-    if (!obj) goto type_error;
-    if (!PyString_Check(obj)) {
-      Py_DECREF(obj);
-      goto type_error;
-    }
-  } 
-  c = PyString_AsString(obj);
-  /* Pointer values must start with leading underscore */
-  c = SWIG_UnpackVoidPtr(c, &vptr, ty->name);
-  if (newref) { Py_DECREF(obj); }
-  if (!c) goto type_error;
+		if (!(PyString_Check(obj))) {
+			if (!SWIG_this)
+				SWIG_this = PyString_FromString("this");
+			pyobj = obj;
+			obj = PyObject_GetAttr(obj, SWIG_this);
+			newref = 1;
+			if (!obj)
+				goto type_error;
+			if (!PyString_Check(obj)) {
+				Py_DECREF(obj);
+				goto type_error;
+			}
+		}
+		c = PyString_AsString(obj);
+		/* Pointer values must start with leading underscore */
+		c = SWIG_UnpackVoidPtr(c, &vptr, ty->name);
+		if (newref) {
+			Py_DECREF(obj);
+		}
+		if (!c)
+			goto type_error;
 #endif
 
-type_check:
-  if (ty) {
-    tc = SWIG_TypeCheck(c,ty);
-    if (!tc) goto type_error;
-    *ptr = SWIG_TypeCast(tc,vptr);
-  } else {
-    *ptr = vptr;
-  }
-  if ((pyobj) && (flags & SWIG_POINTER_DISOWN)) {
-    PyObject_SetAttrString(pyobj,(char*)"thisown",Py_False);
-  }
-  return 0;
+	  type_check:
+		if (ty) {
+			tc = SWIG_TypeCheck(c, ty);
+			if (!tc)
+				goto type_error;
+			*ptr = SWIG_TypeCast(tc, vptr);
+		} else {
+			*ptr = vptr;
+		}
+		if ((pyobj) && (flags & SWIG_POINTER_DISOWN)) {
+			PyObject_SetAttrString(pyobj, (char *) "thisown", Py_False);
+		}
+		return 0;
 
-type_error:
-  PyErr_Clear();
-  if (pyobj && !obj) {    
-    obj = pyobj;
-    if (PyCFunction_Check(obj)) {
-      /* here we get the method pointer for callbacks */
-      char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc);
-      c = doc ? strstr(doc, "swig_ptr: ") : 0;
-      if (c) {
-	c = ty ? SWIG_UnpackVoidPtr(c + 10, &vptr, ty->name) : 0;
-	if (!c) goto type_error;
-	goto type_check;
-      }
-    }
-  }
-  if (flags & SWIG_POINTER_EXCEPTION) {
-    if (ty) {
-      SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj);
-    } else {
-      SWIG_Python_TypeError("C/C++ pointer", obj);
-    }
-  }
-  return -1;
-}
+	  type_error:
+		PyErr_Clear();
+		if (pyobj && !obj) {
+			obj = pyobj;
+			if (PyCFunction_Check(obj)) {
+				/* here we get the method pointer for callbacks */
+				char *doc = (((PyCFunctionObject *) obj)->m_ml->ml_doc);
+				c = doc ? strstr(doc, "swig_ptr: ") : 0;
+				if (c) {
+					c = ty ? SWIG_UnpackVoidPtr(c + 10, &vptr, ty->name) : 0;
+					if (!c)
+						goto type_error;
+					goto type_check;
+				}
+			}
+		}
+		if (flags & SWIG_POINTER_EXCEPTION) {
+			if (ty) {
+				SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj);
+			} else {
+				SWIG_Python_TypeError("C/C++ pointer", obj);
+			}
+		}
+		return -1;
+	}
 
 /* Convert a pointer value, signal an exception on a type mismatch */
-SWIGRUNTIME void *
-SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int argnum, int flags) {
-  void *result;
-  if (SWIG_Python_ConvertPtr(obj, &result, ty, flags) == -1) {
-    PyErr_Clear();
-    if (flags & SWIG_POINTER_EXCEPTION) {
-      SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj);
-      SWIG_Python_ArgFail(argnum);
-    }
-  }
-  return result;
-}
+	SWIGRUNTIME void *SWIG_Python_MustGetPtr(PyObject * obj, swig_type_info * ty, int argnum, int flags) {
+		void *result;
+		if (SWIG_Python_ConvertPtr(obj, &result, ty, flags) == -1) {
+			PyErr_Clear();
+			if (flags & SWIG_POINTER_EXCEPTION) {
+				SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj);
+				SWIG_Python_ArgFail(argnum);
+			}
+		}
+		return result;
+	}
 
 /* Convert a packed value value */
-SWIGRUNTIME int
-SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *ty, int flags) {
-  swig_cast_info *tc;
-  const char *c = 0;
+	SWIGRUNTIME int
+	    SWIG_Python_ConvertPacked(PyObject * obj, void *ptr, size_t sz, swig_type_info * ty, int flags) {
+		swig_cast_info *tc;
+		const char *c = 0;
 
 #if defined(SWIG_COBJECT_TYPES) && !defined(SWIG_COBJECT_PYTHON)
-  c = PySwigPacked_UnpackData(obj, ptr, sz);
+		c = PySwigPacked_UnpackData(obj, ptr, sz);
 #else
-  if ((!obj) || (!PyString_Check(obj))) goto type_error;
-  c = PyString_AsString(obj);
-  /* Pointer values must start with leading underscore */
-  c = SWIG_UnpackDataName(c, ptr, sz, ty->name);
+		if ((!obj) || (!PyString_Check(obj)))
+			goto type_error;
+		c = PyString_AsString(obj);
+		/* Pointer values must start with leading underscore */
+		c = SWIG_UnpackDataName(c, ptr, sz, ty->name);
 #endif
-  if (!c) goto type_error;
-  if (ty) {
-    tc = SWIG_TypeCheck(c,ty);
-    if (!tc) goto type_error;
-  }
-  return 0;
+		if (!c)
+			goto type_error;
+		if (ty) {
+			tc = SWIG_TypeCheck(c, ty);
+			if (!tc)
+				goto type_error;
+		}
+		return 0;
 
-type_error:
-  PyErr_Clear();
-  if (flags & SWIG_POINTER_EXCEPTION) {
-    if (ty) {
-      SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj);
-    } else {
-      SWIG_Python_TypeError("C/C++ packed data", obj);
-    }
-  }
-  return -1;
-}  
+	  type_error:
+		PyErr_Clear();
+		if (flags & SWIG_POINTER_EXCEPTION) {
+			if (ty) {
+				SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj);
+			} else {
+				SWIG_Python_TypeError("C/C++ packed data", obj);
+			}
+		}
+		return -1;
+	}
 
 /* Create a new array object */
-SWIGRUNTIME PyObject *
-SWIG_Python_NewPointerObj(void *ptr, swig_type_info *type, int own) {
-  PyObject *robj = 0;
-  if (!type) {
-    if (!PyErr_Occurred()) {
-      PyErr_Format(PyExc_TypeError, "Swig: null type passed to NewPointerObj");
-    }
-    return robj;
-  }
-  if (!ptr) {
-    Py_INCREF(Py_None);
-    return Py_None;
-  }
+	SWIGRUNTIME PyObject *SWIG_Python_NewPointerObj(void *ptr, swig_type_info * type, int own) {
+		PyObject *robj = 0;
+		if (!type) {
+			if (!PyErr_Occurred()) {
+				PyErr_Format(PyExc_TypeError, "Swig: null type passed to NewPointerObj");
+			}
+			return robj;
+		}
+		if (!ptr) {
+			Py_INCREF(Py_None);
+			return Py_None;
+		}
 #ifdef SWIG_COBJECT_TYPES
-  robj = PySwigObject_FromVoidPtrAndDesc((void *) ptr, (char *)type->name);
+		robj = PySwigObject_FromVoidPtrAndDesc((void *) ptr, (char *) type->name);
 #else
-  {
-    char result[SWIG_BUFFER_SIZE];
-    robj = SWIG_PackVoidPtr(result, ptr, type->name, sizeof(result)) ?
-      PyString_FromString(result) : 0;
-  }
+		{
+			char result[SWIG_BUFFER_SIZE];
+			robj = SWIG_PackVoidPtr(result, ptr, type->name, sizeof(result)) ? PyString_FromString(result) : 0;
+		}
 #endif
-  if (!robj || (robj == Py_None)) return robj;
-  if (type->clientdata) {
-    PyObject *inst;
-    PyObject *args = Py_BuildValue((char*)"(O)", robj);
-    Py_DECREF(robj);
-    inst = PyObject_CallObject((PyObject *) type->clientdata, args);
-    Py_DECREF(args);
-    if (inst) {
-      if (own) {
-        PyObject_SetAttrString(inst,(char*)"thisown",Py_True);
-      }
-      robj = inst;
-    }
-  }
-  return robj;
-}
+		if (!robj || (robj == Py_None))
+			return robj;
+		if (type->clientdata) {
+			PyObject *inst;
+			PyObject *args = Py_BuildValue((char *) "(O)", robj);
+			Py_DECREF(robj);
+			inst = PyObject_CallObject((PyObject *) type->clientdata, args);
+			Py_DECREF(args);
+			if (inst) {
+				if (own) {
+					PyObject_SetAttrString(inst, (char *) "thisown", Py_True);
+				}
+				robj = inst;
+			}
+		}
+		return robj;
+	}
 
-SWIGRUNTIME PyObject *
-SWIG_Python_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) {
-  PyObject *robj = 0;
-  if (!ptr) {
-    Py_INCREF(Py_None);
-    return Py_None;
-  }
+	SWIGRUNTIME PyObject *SWIG_Python_NewPackedObj(void *ptr, size_t sz, swig_type_info * type) {
+		PyObject *robj = 0;
+		if (!ptr) {
+			Py_INCREF(Py_None);
+			return Py_None;
+		}
 #if defined(SWIG_COBJECT_TYPES) && !defined(SWIG_COBJECT_PYTHON)
-  robj = PySwigPacked_FromDataAndDesc((void *) ptr, sz, (char *)type->name);
+		robj = PySwigPacked_FromDataAndDesc((void *) ptr, sz, (char *) type->name);
 #else
-  {
-    char result[SWIG_BUFFER_SIZE];
-    robj = SWIG_PackDataName(result, ptr, sz, type->name, sizeof(result)) ?
-      PyString_FromString(result) : 0;
-  }
+		{
+			char result[SWIG_BUFFER_SIZE];
+			robj = SWIG_PackDataName(result, ptr, sz, type->name, sizeof(result)) ? PyString_FromString(result) : 0;
+		}
 #endif
-  return robj;
-}
+		return robj;
+	}
 
 /* -----------------------------------------------------------------------------*
  *  Get type list 
  * -----------------------------------------------------------------------------*/
 
 #ifdef SWIG_LINK_RUNTIME
-void *SWIG_ReturnGlobalTypeList(void *);
+	void *SWIG_ReturnGlobalTypeList(void *);
 #endif
 
-SWIGRUNTIME swig_module_info *
-SWIG_Python_GetModule(void) {
-  static void *type_pointer = (void *)0;
-  /* first check if module already created */
-  if (!type_pointer) {
+	SWIGRUNTIME swig_module_info *SWIG_Python_GetModule(void) {
+		static void *type_pointer = (void *) 0;
+		/* first check if module already created */
+		if (!type_pointer) {
 #ifdef SWIG_LINK_RUNTIME
-    type_pointer = SWIG_ReturnGlobalTypeList((void *)0);
+			type_pointer = SWIG_ReturnGlobalTypeList((void *) 0);
 #else
-    type_pointer = PyCObject_Import((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION,
-				    (char*)"type_pointer" SWIG_TYPE_TABLE_NAME);
-    if (PyErr_Occurred()) {
-      PyErr_Clear();
-      type_pointer = (void *)0;
-    }
+			type_pointer = PyCObject_Import((char *) "swig_runtime_data" SWIG_RUNTIME_VERSION,
+											(char *) "type_pointer" SWIG_TYPE_TABLE_NAME);
+			if (PyErr_Occurred()) {
+				PyErr_Clear();
+				type_pointer = (void *) 0;
+			}
 #endif
-  }
-  return (swig_module_info *) type_pointer;
-}
+		}
+		return (swig_module_info *) type_pointer;
+	}
 
 #if PY_MAJOR_VERSION < 2
 /* PyModule_AddObject function was introduced in Python 2.0.  The following function
 is copied out of Python/modsupport.c in python version 2.3.4 */
-SWIGINTERN int
-PyModule_AddObject(PyObject *m, char *name, PyObject *o)
-{
-  PyObject *dict;
-  if (!PyModule_Check(m)) {
-    PyErr_SetString(PyExc_TypeError,
-		    "PyModule_AddObject() needs module as first arg");
-    return -1;
-  }
-  if (!o) {
-    PyErr_SetString(PyExc_TypeError,
-		    "PyModule_AddObject() needs non-NULL value");
-    return -1;
-  }
-  
-  dict = PyModule_GetDict(m);
-  if (dict == NULL) {
-    /* Internal error -- modules must have a dict! */
-    PyErr_Format(PyExc_SystemError, "module '%s' has no __dict__",
-		 PyModule_GetName(m));
-    return -1;
-  }
-  if (PyDict_SetItemString(dict, name, o))
-    return -1;
-  Py_DECREF(o);
-  return 0;
-}
+	SWIGINTERN int
+	    PyModule_AddObject(PyObject * m, char *name, PyObject * o) {
+		PyObject *dict;
+		if (!PyModule_Check(m)) {
+			PyErr_SetString(PyExc_TypeError, "PyModule_AddObject() needs module as first arg");
+			return -1;
+		}
+		if (!o) {
+			PyErr_SetString(PyExc_TypeError, "PyModule_AddObject() needs non-NULL value");
+			return -1;
+		}
+
+		dict = PyModule_GetDict(m);
+		if (dict == NULL) {
+			/* Internal error -- modules must have a dict! */
+			PyErr_Format(PyExc_SystemError, "module '%s' has no __dict__", PyModule_GetName(m));
+			return -1;
+		}
+		if (PyDict_SetItemString(dict, name, o))
+			return -1;
+		Py_DECREF(o);
+		return 0;
+	}
 #endif
 
-SWIGRUNTIME void
-SWIG_Python_SetModule(swig_module_info *swig_module) {
-  static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} };/* Sentinel */
+	SWIGRUNTIME void
+	     SWIG_Python_SetModule(swig_module_info * swig_module) {
+		static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} };	/* Sentinel */
 
-  PyObject *module = Py_InitModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION,
-				   swig_empty_runtime_method_table);
-  PyObject *pointer = PyCObject_FromVoidPtr((void *) swig_module, NULL);
-  if (pointer && module) {
-    PyModule_AddObject(module, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME, pointer);
-  }
-}
+		PyObject *module = Py_InitModule((char *) "swig_runtime_data" SWIG_RUNTIME_VERSION,
+										 swig_empty_runtime_method_table);
+		PyObject *pointer = PyCObject_FromVoidPtr((void *) swig_module, NULL);
+		if (pointer && module) {
+			PyModule_AddObject(module, (char *) "type_pointer" SWIG_TYPE_TABLE_NAME, pointer);
+		}
+	}
 
 #ifdef __cplusplus
 }
@@ -1424,7 +1351,8 @@ SWIG_Python_SetModule(swig_module_info *swig_module) {
 #define SWIGTYPE_ptrdiff_t swig_types[7]
 #define SWIGTYPE_size_t swig_types[8]
 static swig_type_info *swig_types[10];
-static swig_module_info swig_module = {swig_types, 9, 0, 0, 0, 0};
+static swig_module_info swig_module = { swig_types, 9, 0, 0, 0, 0 };
+
 #define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name)
 #define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name)
 
@@ -1439,50 +1367,51 @@ static swig_module_info swig_module = {swig_types, 9, 0, 0, 0, 0};
 #define SWIG_name    "_freeswitch"
 
 /* returns SWIG_OLDOBJ if the input is a raw char*, SWIG_PYSTR if is a PyString */
-SWIGINTERN int
-SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize)
+SWIGINTERN int SWIG_AsCharPtrAndSize(PyObject * obj, char **cptr, size_t *psize)
 {
-  static swig_type_info* pchar_info = 0;
-  char* vptr = 0;
-  if (!pchar_info) pchar_info = SWIG_TypeQuery("char *");
-  if (SWIG_ConvertPtr(obj, (void**)&vptr, pchar_info, 0) != -1) {
-    if (cptr) *cptr = vptr;
-    if (psize) *psize = vptr ? (strlen(vptr) + 1) : 0;
-    return SWIG_OLDOBJ;
-  } else {
-    PyErr_Clear();
-    if (PyString_Check(obj)) {
-      if (cptr) {
-	*cptr = PyString_AS_STRING(obj);
-	if (psize) {
-	  *psize = PyString_GET_SIZE(obj) + 1;
+	static swig_type_info *pchar_info = 0;
+	char *vptr = 0;
+	if (!pchar_info)
+		pchar_info = SWIG_TypeQuery("char *");
+	if (SWIG_ConvertPtr(obj, (void **) &vptr, pchar_info, 0) != -1) {
+		if (cptr)
+			*cptr = vptr;
+		if (psize)
+			*psize = vptr ? (strlen(vptr) + 1) : 0;
+		return SWIG_OLDOBJ;
+	} else {
+		PyErr_Clear();
+		if (PyString_Check(obj)) {
+			if (cptr) {
+				*cptr = PyString_AS_STRING(obj);
+				if (psize) {
+					*psize = PyString_GET_SIZE(obj) + 1;
+				}
+			}
+			return SWIG_PYSTR;
+		}
 	}
-      }
-      return SWIG_PYSTR;
-    }
-  }
-  if (cptr) {
-    SWIG_type_error("char *", obj);
-  }
-  return 0;
+	if (cptr) {
+		SWIG_type_error("char *", obj);
+	}
+	return 0;
 }
 
 
-SWIGINTERNINLINE int
-SWIG_AsCharPtr(PyObject *obj, char **val)
+SWIGINTERNINLINE int SWIG_AsCharPtr(PyObject * obj, char **val)
 {
-  if (SWIG_AsCharPtrAndSize(obj, val, (size_t*)(0))) {
-    return 1;
-  }
-  if (val) {
-    PyErr_Clear();
-    SWIG_type_error("char *", obj);
-  }
-  return 0;
+	if (SWIG_AsCharPtrAndSize(obj, val, (size_t *) (0))) {
+		return 1;
+	}
+	if (val) {
+		PyErr_Clear();
+		SWIG_type_error("char *", obj);
+	}
+	return 0;
 }
 
 
-  /*@/usr/share/swig1.3/python/pymacros.swg,72,SWIG_define@*/
+  /*@/usr/share/swig1.3/python/pymacros.swg,72,SWIG_define@ */
 #define SWIG_From_int PyInt_FromLong
 /*@@*/
 
@@ -1490,117 +1419,109 @@ SWIG_AsCharPtr(PyObject *obj, char **val)
 #include 
 
 
-SWIGINTERNINLINE int
-  SWIG_CheckUnsignedLongInRange(unsigned long value,
-				unsigned long max_value,
-				const char *errmsg) 
+SWIGINTERNINLINE int SWIG_CheckUnsignedLongInRange(unsigned long value, unsigned long max_value, const char *errmsg)
 {
-  if (value > max_value) {
-    if (errmsg) {
-      PyErr_Format(PyExc_OverflowError,
-		   "value %lu is greater than '%s' minimum %lu",
-		   value, errmsg, max_value);
-    }
-    return 0;
-  }
-  return 1;
- }
+	if (value > max_value) {
+		if (errmsg) {
+			PyErr_Format(PyExc_OverflowError, "value %lu is greater than '%s' minimum %lu", value, errmsg, max_value);
+		}
+		return 0;
+	}
+	return 1;
+}
 
 
-SWIGINTERN int
-  SWIG_AsVal_unsigned_SS_long(PyObject *obj, unsigned long *val) 
+SWIGINTERN int SWIG_AsVal_unsigned_SS_long(PyObject * obj, unsigned long *val)
 {
-  if (PyLong_Check(obj)) {
-    unsigned long v = PyLong_AsUnsignedLong(obj);
-    if (!PyErr_Occurred()) {
-      if (val) *val = v;
-      return 1;
-    } else {
-      if (!val) PyErr_Clear();
-      return 0;
-    }
-  } 
-  if (PyInt_Check(obj)) {
-    long v = PyInt_AsLong(obj);
-    if (v >= 0) {
-      if (val) *val = v;
-      return 1;
-    }   
-  }
-  if (val) {
-    SWIG_type_error("unsigned long", obj);
-  }
-  return 0;
+	if (PyLong_Check(obj)) {
+		unsigned long v = PyLong_AsUnsignedLong(obj);
+		if (!PyErr_Occurred()) {
+			if (val)
+				*val = v;
+			return 1;
+		} else {
+			if (!val)
+				PyErr_Clear();
+			return 0;
+		}
+	}
+	if (PyInt_Check(obj)) {
+		long v = PyInt_AsLong(obj);
+		if (v >= 0) {
+			if (val)
+				*val = v;
+			return 1;
+		}
+	}
+	if (val) {
+		SWIG_type_error("unsigned long", obj);
+	}
+	return 0;
 }
 
 
 #if UINT_MAX != ULONG_MAX
-SWIGINTERN int
-  SWIG_AsVal_unsigned_SS_int(PyObject *obj, unsigned int *val)
-{ 
-  const char* errmsg = val ? "unsigned int" : (char*)0;
-  unsigned long v;
-  if (SWIG_AsVal_unsigned_SS_long(obj, &v)) {
-    if (SWIG_CheckUnsignedLongInRange(v, INT_MAX, errmsg)) {
-      if (val) *val = (unsigned int)(v);
-      return 1;
-    }
-  } else {
-    PyErr_Clear();
-  }
-  if (val) {
-    SWIG_type_error(errmsg, obj);
-  }
-  return 0;    
+SWIGINTERN int SWIG_AsVal_unsigned_SS_int(PyObject * obj, unsigned int *val)
+{
+	const char *errmsg = val ? "unsigned int" : (char *) 0;
+	unsigned long v;
+	if (SWIG_AsVal_unsigned_SS_long(obj, &v)) {
+		if (SWIG_CheckUnsignedLongInRange(v, INT_MAX, errmsg)) {
+			if (val)
+				*val = (unsigned int) (v);
+			return 1;
+		}
+	} else {
+		PyErr_Clear();
+	}
+	if (val) {
+		SWIG_type_error(errmsg, obj);
+	}
+	return 0;
 }
 #else
-SWIGINTERNINLINE unsigned int
-  SWIG_AsVal_unsigned_SS_int(PyObject *obj, unsigned int *val)
+SWIGINTERNINLINE unsigned int SWIG_AsVal_unsigned_SS_int(PyObject * obj, unsigned int *val)
 {
-  return SWIG_AsVal_unsigned_SS_long(obj,(unsigned long *)val);
+	return SWIG_AsVal_unsigned_SS_long(obj, (unsigned long *) val);
 }
 #endif
 
 
-SWIGINTERNINLINE unsigned int
-SWIG_As_unsigned_SS_int(PyObject* obj)
+SWIGINTERNINLINE unsigned int SWIG_As_unsigned_SS_int(PyObject * obj)
 {
-  unsigned int v;
-  if (!SWIG_AsVal_unsigned_SS_int(obj, &v)) {
-    /*
-      this is needed to make valgrind/purify happier. 
-     */
-    memset((void*)&v, 0, sizeof(unsigned int));
-  }
-  return v;
-}
-
-  
-SWIGINTERNINLINE int
-SWIG_Check_unsigned_SS_int(PyObject* obj)
-{
-  return SWIG_AsVal_unsigned_SS_int(obj, (unsigned int*)0);
+	unsigned int v;
+	if (!SWIG_AsVal_unsigned_SS_int(obj, &v)) {
+		/*
+		   this is needed to make valgrind/purify happier. 
+		 */
+		memset((void *) &v, 0, sizeof(unsigned int));
+	}
+	return v;
 }
 
 
-SWIGINTERN PyObject *
-SWIG_FromCharPtr(const char* cptr)
-{ 
-  if (cptr) {
-    size_t size = strlen(cptr);
-    if (size > INT_MAX) {
-      return SWIG_NewPointerObj((char*)(cptr), 
-				SWIG_TypeQuery("char *"), 0);
-    } else {
-      if (size != 0) {
-	return PyString_FromStringAndSize(cptr, size);
-      } else {
-	return PyString_FromString(cptr);
-      }
-    }
-  }
-  Py_INCREF(Py_None);
-  return Py_None;
+SWIGINTERNINLINE int SWIG_Check_unsigned_SS_int(PyObject * obj)
+{
+	return SWIG_AsVal_unsigned_SS_int(obj, (unsigned int *) 0);
+}
+
+
+SWIGINTERN PyObject *SWIG_FromCharPtr(const char *cptr)
+{
+	if (cptr) {
+		size_t size = strlen(cptr);
+		if (size > INT_MAX) {
+			return SWIG_NewPointerObj((char *) (cptr), SWIG_TypeQuery("char *"), 0);
+		} else {
+			if (size != 0) {
+				return PyString_FromStringAndSize(cptr, size);
+			} else {
+				return PyString_FromString(cptr);
+			}
+		}
+	}
+	Py_INCREF(Py_None);
+	return Py_None;
 }
 
 
@@ -1609,867 +1530,996 @@ SWIG_FromCharPtr(const char* cptr)
 #ifdef __cplusplus
 extern "C" {
 #endif
-static PyObject *_wrap_fs_core_set_globals(PyObject *self, PyObject *args) {
-    PyObject *resultobj = NULL;
-    
-    if(!PyArg_ParseTuple(args,(char *)":fs_core_set_globals")) goto fail;
-    fs_core_set_globals();
-    
-    Py_INCREF(Py_None); resultobj = Py_None;
-    return resultobj;
-    fail:
-    return NULL;
-}
+	static PyObject *_wrap_fs_core_set_globals(PyObject * self, PyObject * args) {
+		PyObject *resultobj = NULL;
+
+		if       (!PyArg_ParseTuple(args, (char *) ":fs_core_set_globals"))
+			         goto fail;
+		         fs_core_set_globals();
+
+		         Py_INCREF(Py_None);
+		         resultobj = Py_None;
+		         return resultobj;
+		         fail:return NULL;
+	}
+	static PyObject *_wrap_fs_core_init(PyObject * self, PyObject * args) {
+		PyObject *resultobj = NULL;
+		char *arg1 = (char *) 0;
+		int result;
+		PyObject *obj0 = 0;
+
+		if (!PyArg_ParseTuple(args, (char *) "O:fs_core_init", &obj0))
+			goto fail;
+		if (!SWIG_AsCharPtr(obj0, (char **) &arg1)) {
+			SWIG_arg_fail(1);
+			SWIG_fail;
+		}
+		result = (int) fs_core_init(arg1);
+
+		{
+			resultobj = SWIG_From_int((int) (result));
+		}
+		return resultobj;
+	  fail:
+		return NULL;
+	}
 
 
-static PyObject *_wrap_fs_core_init(PyObject *self, PyObject *args) {
-    PyObject *resultobj = NULL;
-    char *arg1 = (char *) 0 ;
-    int result;
-    PyObject * obj0 = 0 ;
-    
-    if(!PyArg_ParseTuple(args,(char *)"O:fs_core_init",&obj0)) goto fail;
-    if (!SWIG_AsCharPtr(obj0, (char**)&arg1)) {
-        SWIG_arg_fail(1);SWIG_fail;
-    }
-    result = (int)fs_core_init(arg1);
-    
-    {
-        resultobj = SWIG_From_int((int)(result)); 
-    }
-    return resultobj;
-    fail:
-    return NULL;
-}
+	static PyObject *_wrap_fs_core_destroy(PyObject * self, PyObject * args) {
+		PyObject *resultobj = NULL;
+		int result;
+
+		if (!PyArg_ParseTuple(args, (char *) ":fs_core_destroy"))
+			goto fail;
+		result = (int) fs_core_destroy();
+
+		{
+			resultobj = SWIG_From_int((int) (result));
+		}
+		return resultobj;
+	  fail:
+		return NULL;
+	}
 
 
-static PyObject *_wrap_fs_core_destroy(PyObject *self, PyObject *args) {
-    PyObject *resultobj = NULL;
-    int result;
-    
-    if(!PyArg_ParseTuple(args,(char *)":fs_core_destroy")) goto fail;
-    result = (int)fs_core_destroy();
-    
-    {
-        resultobj = SWIG_From_int((int)(result)); 
-    }
-    return resultobj;
-    fail:
-    return NULL;
-}
+	static PyObject *_wrap_fs_loadable_module_init(PyObject * self, PyObject * args) {
+		PyObject *resultobj = NULL;
+		int result;
+
+		if (!PyArg_ParseTuple(args, (char *) ":fs_loadable_module_init"))
+			goto fail;
+		result = (int) fs_loadable_module_init();
+
+		{
+			resultobj = SWIG_From_int((int) (result));
+		}
+		return resultobj;
+	  fail:
+		return NULL;
+	}
 
 
-static PyObject *_wrap_fs_loadable_module_init(PyObject *self, PyObject *args) {
-    PyObject *resultobj = NULL;
-    int result;
-    
-    if(!PyArg_ParseTuple(args,(char *)":fs_loadable_module_init")) goto fail;
-    result = (int)fs_loadable_module_init();
-    
-    {
-        resultobj = SWIG_From_int((int)(result)); 
-    }
-    return resultobj;
-    fail:
-    return NULL;
-}
+	static PyObject *_wrap_fs_loadable_module_shutdown(PyObject * self, PyObject * args) {
+		PyObject *resultobj = NULL;
+		int result;
+
+		if (!PyArg_ParseTuple(args, (char *) ":fs_loadable_module_shutdown"))
+			goto fail;
+		result = (int) fs_loadable_module_shutdown();
+
+		{
+			resultobj = SWIG_From_int((int) (result));
+		}
+		return resultobj;
+	  fail:
+		return NULL;
+	}
 
 
-static PyObject *_wrap_fs_loadable_module_shutdown(PyObject *self, PyObject *args) {
-    PyObject *resultobj = NULL;
-    int result;
-    
-    if(!PyArg_ParseTuple(args,(char *)":fs_loadable_module_shutdown")) goto fail;
-    result = (int)fs_loadable_module_shutdown();
-    
-    {
-        resultobj = SWIG_From_int((int)(result)); 
-    }
-    return resultobj;
-    fail:
-    return NULL;
-}
+	static PyObject *_wrap_fs_console_loop(PyObject * self, PyObject * args) {
+		PyObject *resultobj = NULL;
+		int result;
+
+		if (!PyArg_ParseTuple(args, (char *) ":fs_console_loop"))
+			goto fail;
+		result = (int) fs_console_loop();
+
+		{
+			resultobj = SWIG_From_int((int) (result));
+		}
+		return resultobj;
+	  fail:
+		return NULL;
+	}
 
 
-static PyObject *_wrap_fs_console_loop(PyObject *self, PyObject *args) {
-    PyObject *resultobj = NULL;
-    int result;
-    
-    if(!PyArg_ParseTuple(args,(char *)":fs_console_loop")) goto fail;
-    result = (int)fs_console_loop();
-    
-    {
-        resultobj = SWIG_From_int((int)(result)); 
-    }
-    return resultobj;
-    fail:
-    return NULL;
-}
+	static PyObject *_wrap_fs_console_log(PyObject * self, PyObject * args) {
+		PyObject *resultobj = NULL;
+		char *arg1 = (char *) 0;
+		char *arg2 = (char *) 0;
+		PyObject *obj0 = 0;
+		PyObject *obj1 = 0;
+
+		if (!PyArg_ParseTuple(args, (char *) "OO:fs_console_log", &obj0, &obj1))
+			goto fail;
+		if (!SWIG_AsCharPtr(obj0, (char **) &arg1)) {
+			SWIG_arg_fail(1);
+			SWIG_fail;
+		}
+		if (!SWIG_AsCharPtr(obj1, (char **) &arg2)) {
+			SWIG_arg_fail(2);
+			SWIG_fail;
+		}
+		fs_console_log(arg1, arg2);
+
+		Py_INCREF(Py_None);
+		resultobj = Py_None;
+		return resultobj;
+	  fail:
+		return NULL;
+	}
 
 
-static PyObject *_wrap_fs_console_log(PyObject *self, PyObject *args) {
-    PyObject *resultobj = NULL;
-    char *arg1 = (char *) 0 ;
-    char *arg2 = (char *) 0 ;
-    PyObject * obj0 = 0 ;
-    PyObject * obj1 = 0 ;
-    
-    if(!PyArg_ParseTuple(args,(char *)"OO:fs_console_log",&obj0,&obj1)) goto fail;
-    if (!SWIG_AsCharPtr(obj0, (char**)&arg1)) {
-        SWIG_arg_fail(1);SWIG_fail;
-    }
-    if (!SWIG_AsCharPtr(obj1, (char**)&arg2)) {
-        SWIG_arg_fail(2);SWIG_fail;
-    }
-    fs_console_log(arg1,arg2);
-    
-    Py_INCREF(Py_None); resultobj = Py_None;
-    return resultobj;
-    fail:
-    return NULL;
-}
+	static PyObject *_wrap_fs_console_clean(PyObject * self, PyObject * args) {
+		PyObject *resultobj = NULL;
+		char *arg1 = (char *) 0;
+		PyObject *obj0 = 0;
+
+		if (!PyArg_ParseTuple(args, (char *) "O:fs_console_clean", &obj0))
+			goto fail;
+		if (!SWIG_AsCharPtr(obj0, (char **) &arg1)) {
+			SWIG_arg_fail(1);
+			SWIG_fail;
+		}
+		fs_console_clean(arg1);
+
+		Py_INCREF(Py_None);
+		resultobj = Py_None;
+		return resultobj;
+	  fail:
+		return NULL;
+	}
 
 
-static PyObject *_wrap_fs_console_clean(PyObject *self, PyObject *args) {
-    PyObject *resultobj = NULL;
-    char *arg1 = (char *) 0 ;
-    PyObject * obj0 = 0 ;
-    
-    if(!PyArg_ParseTuple(args,(char *)"O:fs_console_clean",&obj0)) goto fail;
-    if (!SWIG_AsCharPtr(obj0, (char**)&arg1)) {
-        SWIG_arg_fail(1);SWIG_fail;
-    }
-    fs_console_clean(arg1);
-    
-    Py_INCREF(Py_None); resultobj = Py_None;
-    return resultobj;
-    fail:
-    return NULL;
-}
+	static PyObject *_wrap_fs_core_session_locate(PyObject * self, PyObject * args) {
+		PyObject *resultobj = NULL;
+		char *arg1 = (char *) 0;
+		switch_core_session_t *result;
+		PyObject *obj0 = 0;
+
+		if (!PyArg_ParseTuple(args, (char *) "O:fs_core_session_locate", &obj0))
+			goto fail;
+		if (!SWIG_AsCharPtr(obj0, (char **) &arg1)) {
+			SWIG_arg_fail(1);
+			SWIG_fail;
+		}
+		result = (switch_core_session_t *) fs_core_session_locate(arg1);
+
+		resultobj = SWIG_NewPointerObj((void *) (result), SWIGTYPE_p_switch_core_session_t, 0);
+		return resultobj;
+	  fail:
+		return NULL;
+	}
 
 
-static PyObject *_wrap_fs_core_session_locate(PyObject *self, PyObject *args) {
-    PyObject *resultobj = NULL;
-    char *arg1 = (char *) 0 ;
-    switch_core_session_t *result;
-    PyObject * obj0 = 0 ;
-    
-    if(!PyArg_ParseTuple(args,(char *)"O:fs_core_session_locate",&obj0)) goto fail;
-    if (!SWIG_AsCharPtr(obj0, (char**)&arg1)) {
-        SWIG_arg_fail(1);SWIG_fail;
-    }
-    result = (switch_core_session_t *)fs_core_session_locate(arg1);
-    
-    resultobj = SWIG_NewPointerObj((void*)(result), SWIGTYPE_p_switch_core_session_t, 0);
-    return resultobj;
-    fail:
-    return NULL;
-}
+	static PyObject *_wrap_fs_channel_answer(PyObject * self, PyObject * args) {
+		PyObject *resultobj = NULL;
+		switch_core_session_t *arg1 = (switch_core_session_t *) 0;
+		PyObject *obj0 = 0;
+
+		if (!PyArg_ParseTuple(args, (char *) "O:fs_channel_answer", &obj0))
+			goto fail;
+		SWIG_Python_ConvertPtr(obj0, (void **) &arg1, SWIGTYPE_p_switch_core_session_t, SWIG_POINTER_EXCEPTION | 0);
+		if (SWIG_arg_fail(1))
+			SWIG_fail;
+		fs_channel_answer(arg1);
+
+		Py_INCREF(Py_None);
+		resultobj = Py_None;
+		return resultobj;
+	  fail:
+		return NULL;
+	}
 
 
-static PyObject *_wrap_fs_channel_answer(PyObject *self, PyObject *args) {
-    PyObject *resultobj = NULL;
-    switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
-    PyObject * obj0 = 0 ;
-    
-    if(!PyArg_ParseTuple(args,(char *)"O:fs_channel_answer",&obj0)) goto fail;
-    SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_switch_core_session_t, SWIG_POINTER_EXCEPTION | 0);
-    if (SWIG_arg_fail(1)) SWIG_fail;
-    fs_channel_answer(arg1);
-    
-    Py_INCREF(Py_None); resultobj = Py_None;
-    return resultobj;
-    fail:
-    return NULL;
-}
+	static PyObject *_wrap_fs_channel_pre_answer(PyObject * self, PyObject * args) {
+		PyObject *resultobj = NULL;
+		switch_core_session_t *arg1 = (switch_core_session_t *) 0;
+		PyObject *obj0 = 0;
+
+		if (!PyArg_ParseTuple(args, (char *) "O:fs_channel_pre_answer", &obj0))
+			goto fail;
+		SWIG_Python_ConvertPtr(obj0, (void **) &arg1, SWIGTYPE_p_switch_core_session_t, SWIG_POINTER_EXCEPTION | 0);
+		if (SWIG_arg_fail(1))
+			SWIG_fail;
+		fs_channel_pre_answer(arg1);
+
+		Py_INCREF(Py_None);
+		resultobj = Py_None;
+		return resultobj;
+	  fail:
+		return NULL;
+	}
 
 
-static PyObject *_wrap_fs_channel_pre_answer(PyObject *self, PyObject *args) {
-    PyObject *resultobj = NULL;
-    switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
-    PyObject * obj0 = 0 ;
-    
-    if(!PyArg_ParseTuple(args,(char *)"O:fs_channel_pre_answer",&obj0)) goto fail;
-    SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_switch_core_session_t, SWIG_POINTER_EXCEPTION | 0);
-    if (SWIG_arg_fail(1)) SWIG_fail;
-    fs_channel_pre_answer(arg1);
-    
-    Py_INCREF(Py_None); resultobj = Py_None;
-    return resultobj;
-    fail:
-    return NULL;
-}
+	static PyObject *_wrap_fs_channel_hangup(PyObject * self, PyObject * args) {
+		PyObject *resultobj = NULL;
+		switch_core_session_t *arg1 = (switch_core_session_t *) 0;
+		char *arg2 = (char *) 0;
+		PyObject *obj0 = 0;
+		PyObject *obj1 = 0;
+
+		if (!PyArg_ParseTuple(args, (char *) "OO:fs_channel_hangup", &obj0, &obj1))
+			goto fail;
+		SWIG_Python_ConvertPtr(obj0, (void **) &arg1, SWIGTYPE_p_switch_core_session_t, SWIG_POINTER_EXCEPTION | 0);
+		if (SWIG_arg_fail(1))
+			SWIG_fail;
+		if (!SWIG_AsCharPtr(obj1, (char **) &arg2)) {
+			SWIG_arg_fail(2);
+			SWIG_fail;
+		}
+		fs_channel_hangup(arg1, arg2);
+
+		Py_INCREF(Py_None);
+		resultobj = Py_None;
+		return resultobj;
+	  fail:
+		return NULL;
+	}
 
 
-static PyObject *_wrap_fs_channel_hangup(PyObject *self, PyObject *args) {
-    PyObject *resultobj = NULL;
-    switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
-    char *arg2 = (char *) 0 ;
-    PyObject * obj0 = 0 ;
-    PyObject * obj1 = 0 ;
-    
-    if(!PyArg_ParseTuple(args,(char *)"OO:fs_channel_hangup",&obj0,&obj1)) goto fail;
-    SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_switch_core_session_t, SWIG_POINTER_EXCEPTION | 0);
-    if (SWIG_arg_fail(1)) SWIG_fail;
-    if (!SWIG_AsCharPtr(obj1, (char**)&arg2)) {
-        SWIG_arg_fail(2);SWIG_fail;
-    }
-    fs_channel_hangup(arg1,arg2);
-    
-    Py_INCREF(Py_None); resultobj = Py_None;
-    return resultobj;
-    fail:
-    return NULL;
-}
+	static PyObject *_wrap_fs_channel_set_variable(PyObject * self, PyObject * args) {
+		PyObject *resultobj = NULL;
+		switch_core_session_t *arg1 = (switch_core_session_t *) 0;
+		char *arg2 = (char *) 0;
+		char *arg3 = (char *) 0;
+		PyObject *obj0 = 0;
+		PyObject *obj1 = 0;
+		PyObject *obj2 = 0;
+
+		if (!PyArg_ParseTuple(args, (char *) "OOO:fs_channel_set_variable", &obj0, &obj1, &obj2))
+			goto fail;
+		SWIG_Python_ConvertPtr(obj0, (void **) &arg1, SWIGTYPE_p_switch_core_session_t, SWIG_POINTER_EXCEPTION | 0);
+		if (SWIG_arg_fail(1))
+			SWIG_fail;
+		if (!SWIG_AsCharPtr(obj1, (char **) &arg2)) {
+			SWIG_arg_fail(2);
+			SWIG_fail;
+		}
+		if (!SWIG_AsCharPtr(obj2, (char **) &arg3)) {
+			SWIG_arg_fail(3);
+			SWIG_fail;
+		}
+		fs_channel_set_variable(arg1, arg2, arg3);
+
+		Py_INCREF(Py_None);
+		resultobj = Py_None;
+		return resultobj;
+	  fail:
+		return NULL;
+	}
 
 
-static PyObject *_wrap_fs_channel_set_variable(PyObject *self, PyObject *args) {
-    PyObject *resultobj = NULL;
-    switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
-    char *arg2 = (char *) 0 ;
-    char *arg3 = (char *) 0 ;
-    PyObject * obj0 = 0 ;
-    PyObject * obj1 = 0 ;
-    PyObject * obj2 = 0 ;
-    
-    if(!PyArg_ParseTuple(args,(char *)"OOO:fs_channel_set_variable",&obj0,&obj1,&obj2)) goto fail;
-    SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_switch_core_session_t, SWIG_POINTER_EXCEPTION | 0);
-    if (SWIG_arg_fail(1)) SWIG_fail;
-    if (!SWIG_AsCharPtr(obj1, (char**)&arg2)) {
-        SWIG_arg_fail(2);SWIG_fail;
-    }
-    if (!SWIG_AsCharPtr(obj2, (char**)&arg3)) {
-        SWIG_arg_fail(3);SWIG_fail;
-    }
-    fs_channel_set_variable(arg1,arg2,arg3);
-    
-    Py_INCREF(Py_None); resultobj = Py_None;
-    return resultobj;
-    fail:
-    return NULL;
-}
+	static PyObject *_wrap_fs_channel_get_variable(PyObject * self, PyObject * args) {
+		PyObject *resultobj = NULL;
+		switch_core_session_t *arg1 = (switch_core_session_t *) 0;
+		char *arg2 = (char *) 0;
+		PyObject *obj0 = 0;
+		PyObject *obj1 = 0;
+
+		if (!PyArg_ParseTuple(args, (char *) "OO:fs_channel_get_variable", &obj0, &obj1))
+			goto fail;
+		SWIG_Python_ConvertPtr(obj0, (void **) &arg1, SWIGTYPE_p_switch_core_session_t, SWIG_POINTER_EXCEPTION | 0);
+		if (SWIG_arg_fail(1))
+			SWIG_fail;
+		if (!SWIG_AsCharPtr(obj1, (char **) &arg2)) {
+			SWIG_arg_fail(2);
+			SWIG_fail;
+		}
+		fs_channel_get_variable(arg1, arg2);
+
+		Py_INCREF(Py_None);
+		resultobj = Py_None;
+		return resultobj;
+	  fail:
+		return NULL;
+	}
 
 
-static PyObject *_wrap_fs_channel_get_variable(PyObject *self, PyObject *args) {
-    PyObject *resultobj = NULL;
-    switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
-    char *arg2 = (char *) 0 ;
-    PyObject * obj0 = 0 ;
-    PyObject * obj1 = 0 ;
-    
-    if(!PyArg_ParseTuple(args,(char *)"OO:fs_channel_get_variable",&obj0,&obj1)) goto fail;
-    SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_switch_core_session_t, SWIG_POINTER_EXCEPTION | 0);
-    if (SWIG_arg_fail(1)) SWIG_fail;
-    if (!SWIG_AsCharPtr(obj1, (char**)&arg2)) {
-        SWIG_arg_fail(2);SWIG_fail;
-    }
-    fs_channel_get_variable(arg1,arg2);
-    
-    Py_INCREF(Py_None); resultobj = Py_None;
-    return resultobj;
-    fail:
-    return NULL;
-}
+	static PyObject *_wrap_fs_channel_set_state(PyObject * self, PyObject * args) {
+		PyObject *resultobj = NULL;
+		switch_core_session_t *arg1 = (switch_core_session_t *) 0;
+		char *arg2 = (char *) 0;
+		PyObject *obj0 = 0;
+		PyObject *obj1 = 0;
+
+		if (!PyArg_ParseTuple(args, (char *) "OO:fs_channel_set_state", &obj0, &obj1))
+			goto fail;
+		SWIG_Python_ConvertPtr(obj0, (void **) &arg1, SWIGTYPE_p_switch_core_session_t, SWIG_POINTER_EXCEPTION | 0);
+		if (SWIG_arg_fail(1))
+			SWIG_fail;
+		if (!SWIG_AsCharPtr(obj1, (char **) &arg2)) {
+			SWIG_arg_fail(2);
+			SWIG_fail;
+		}
+		fs_channel_set_state(arg1, arg2);
+
+		Py_INCREF(Py_None);
+		resultobj = Py_None;
+		return resultobj;
+	  fail:
+		return NULL;
+	}
 
 
-static PyObject *_wrap_fs_channel_set_state(PyObject *self, PyObject *args) {
-    PyObject *resultobj = NULL;
-    switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
-    char *arg2 = (char *) 0 ;
-    PyObject * obj0 = 0 ;
-    PyObject * obj1 = 0 ;
-    
-    if(!PyArg_ParseTuple(args,(char *)"OO:fs_channel_set_state",&obj0,&obj1)) goto fail;
-    SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_switch_core_session_t, SWIG_POINTER_EXCEPTION | 0);
-    if (SWIG_arg_fail(1)) SWIG_fail;
-    if (!SWIG_AsCharPtr(obj1, (char**)&arg2)) {
-        SWIG_arg_fail(2);SWIG_fail;
-    }
-    fs_channel_set_state(arg1,arg2);
-    
-    Py_INCREF(Py_None); resultobj = Py_None;
-    return resultobj;
-    fail:
-    return NULL;
-}
+	static PyObject *_wrap_fs_ivr_play_file(PyObject * self, PyObject * args) {
+		PyObject *resultobj = NULL;
+		switch_core_session_t *arg1 = (switch_core_session_t *) 0;
+		char *arg2 = (char *) 0;
+		char *arg3 = (char *) 0;
+		switch_input_callback_function_t arg4;
+		void *arg5 = (void *) 0;
+		unsigned int arg6;
+		int result;
+		PyObject *obj0 = 0;
+		PyObject *obj1 = 0;
+		PyObject *obj2 = 0;
+		PyObject *obj3 = 0;
+		PyObject *obj4 = 0;
+		PyObject *obj5 = 0;
+
+		if (!PyArg_ParseTuple(args, (char *) "OOOOOO:fs_ivr_play_file", &obj0, &obj1, &obj2, &obj3, &obj4, &obj5))
+			goto fail;
+		SWIG_Python_ConvertPtr(obj0, (void **) &arg1, SWIGTYPE_p_switch_core_session_t, SWIG_POINTER_EXCEPTION | 0);
+		if (SWIG_arg_fail(1))
+			SWIG_fail;
+		if (!SWIG_AsCharPtr(obj1, (char **) &arg2)) {
+			SWIG_arg_fail(2);
+			SWIG_fail;
+		}
+		if (!SWIG_AsCharPtr(obj2, (char **) &arg3)) {
+			SWIG_arg_fail(3);
+			SWIG_fail;
+		}
+		{
+			switch_input_callback_function_t *argp;
+			SWIG_Python_ConvertPtr(obj3, (void **) &argp, SWIGTYPE_p_switch_input_callback_function_t,
+								   SWIG_POINTER_EXCEPTION);
+			if (SWIG_arg_fail(4))
+				SWIG_fail;
+			if (argp == NULL) {
+				SWIG_null_ref("switch_input_callback_function_t");
+			}
+			if (SWIG_arg_fail(4))
+				SWIG_fail;
+			arg4 = *argp;
+		}
+		{
+			if ((SWIG_ConvertPtr(obj4, (void **) (&arg5), 0, SWIG_POINTER_EXCEPTION | 0)) == -1) {
+				SWIG_arg_fail(5);
+				SWIG_fail;
+			}
+		}
+		{
+			arg6 = (unsigned int) (SWIG_As_unsigned_SS_int(obj5));
+			if (SWIG_arg_fail(6))
+				SWIG_fail;
+		}
+		result = (int) fs_ivr_play_file(arg1, arg2, arg3, arg4, arg5, arg6);
+
+		{
+			resultobj = SWIG_From_int((int) (result));
+		}
+		return resultobj;
+	  fail:
+		return NULL;
+	}
 
 
-static PyObject *_wrap_fs_ivr_play_file(PyObject *self, PyObject *args) {
-    PyObject *resultobj = NULL;
-    switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
-    char *arg2 = (char *) 0 ;
-    char *arg3 = (char *) 0 ;
-    switch_input_callback_function_t arg4 ;
-    void *arg5 = (void *) 0 ;
-    unsigned int arg6 ;
-    int result;
-    PyObject * obj0 = 0 ;
-    PyObject * obj1 = 0 ;
-    PyObject * obj2 = 0 ;
-    PyObject * obj3 = 0 ;
-    PyObject * obj4 = 0 ;
-    PyObject * obj5 = 0 ;
-    
-    if(!PyArg_ParseTuple(args,(char *)"OOOOOO:fs_ivr_play_file",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) goto fail;
-    SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_switch_core_session_t, SWIG_POINTER_EXCEPTION | 0);
-    if (SWIG_arg_fail(1)) SWIG_fail;
-    if (!SWIG_AsCharPtr(obj1, (char**)&arg2)) {
-        SWIG_arg_fail(2);SWIG_fail;
-    }
-    if (!SWIG_AsCharPtr(obj2, (char**)&arg3)) {
-        SWIG_arg_fail(3);SWIG_fail;
-    }
-    {
-        switch_input_callback_function_t * argp;
-        SWIG_Python_ConvertPtr(obj3, (void **)&argp, SWIGTYPE_p_switch_input_callback_function_t, SWIG_POINTER_EXCEPTION);
-        if (SWIG_arg_fail(4)) SWIG_fail;
-        if (argp == NULL) {
-            SWIG_null_ref("switch_input_callback_function_t");
-        }
-        if (SWIG_arg_fail(4)) SWIG_fail;
-        arg4 = *argp;
-    }
-    {
-        if ((SWIG_ConvertPtr(obj4,(void **)(&arg5),0,SWIG_POINTER_EXCEPTION|0))== -1) {
-            SWIG_arg_fail(5);SWIG_fail;
-        }
-    }
-    {
-        arg6 = (unsigned int)(SWIG_As_unsigned_SS_int(obj5)); 
-        if (SWIG_arg_fail(6)) SWIG_fail;
-    }
-    result = (int)fs_ivr_play_file(arg1,arg2,arg3,arg4,arg5,arg6);
-    
-    {
-        resultobj = SWIG_From_int((int)(result)); 
-    }
-    return resultobj;
-    fail:
-    return NULL;
-}
+	static PyObject *_wrap_fs_switch_ivr_record_file(PyObject * self, PyObject * args) {
+		PyObject *resultobj = NULL;
+		switch_core_session_t *arg1 = (switch_core_session_t *) 0;
+		switch_file_handle_t *arg2 = (switch_file_handle_t *) 0;
+		char *arg3 = (char *) 0;
+		switch_input_callback_function_t arg4;
+		void *arg5 = (void *) 0;
+		unsigned int arg6;
+		int result;
+		PyObject *obj0 = 0;
+		PyObject *obj1 = 0;
+		PyObject *obj2 = 0;
+		PyObject *obj3 = 0;
+		PyObject *obj4 = 0;
+		PyObject *obj5 = 0;
+
+		if (!PyArg_ParseTuple
+			(args, (char *) "OOOOOO:fs_switch_ivr_record_file", &obj0, &obj1, &obj2, &obj3, &obj4, &obj5))
+			goto fail;
+		SWIG_Python_ConvertPtr(obj0, (void **) &arg1, SWIGTYPE_p_switch_core_session_t, SWIG_POINTER_EXCEPTION | 0);
+		if (SWIG_arg_fail(1))
+			SWIG_fail;
+		SWIG_Python_ConvertPtr(obj1, (void **) &arg2, SWIGTYPE_p_switch_file_handle_t, SWIG_POINTER_EXCEPTION | 0);
+		if (SWIG_arg_fail(2))
+			SWIG_fail;
+		if (!SWIG_AsCharPtr(obj2, (char **) &arg3)) {
+			SWIG_arg_fail(3);
+			SWIG_fail;
+		}
+		{
+			switch_input_callback_function_t *argp;
+			SWIG_Python_ConvertPtr(obj3, (void **) &argp, SWIGTYPE_p_switch_input_callback_function_t,
+								   SWIG_POINTER_EXCEPTION);
+			if (SWIG_arg_fail(4))
+				SWIG_fail;
+			if (argp == NULL) {
+				SWIG_null_ref("switch_input_callback_function_t");
+			}
+			if (SWIG_arg_fail(4))
+				SWIG_fail;
+			arg4 = *argp;
+		}
+		{
+			if ((SWIG_ConvertPtr(obj4, (void **) (&arg5), 0, SWIG_POINTER_EXCEPTION | 0)) == -1) {
+				SWIG_arg_fail(5);
+				SWIG_fail;
+			}
+		}
+		{
+			arg6 = (unsigned int) (SWIG_As_unsigned_SS_int(obj5));
+			if (SWIG_arg_fail(6))
+				SWIG_fail;
+		}
+		result = (int) fs_switch_ivr_record_file(arg1, arg2, arg3, arg4, arg5, arg6);
+
+		{
+			resultobj = SWIG_From_int((int) (result));
+		}
+		return resultobj;
+	  fail:
+		return NULL;
+	}
 
 
-static PyObject *_wrap_fs_switch_ivr_record_file(PyObject *self, PyObject *args) {
-    PyObject *resultobj = NULL;
-    switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
-    switch_file_handle_t *arg2 = (switch_file_handle_t *) 0 ;
-    char *arg3 = (char *) 0 ;
-    switch_input_callback_function_t arg4 ;
-    void *arg5 = (void *) 0 ;
-    unsigned int arg6 ;
-    int result;
-    PyObject * obj0 = 0 ;
-    PyObject * obj1 = 0 ;
-    PyObject * obj2 = 0 ;
-    PyObject * obj3 = 0 ;
-    PyObject * obj4 = 0 ;
-    PyObject * obj5 = 0 ;
-    
-    if(!PyArg_ParseTuple(args,(char *)"OOOOOO:fs_switch_ivr_record_file",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) goto fail;
-    SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_switch_core_session_t, SWIG_POINTER_EXCEPTION | 0);
-    if (SWIG_arg_fail(1)) SWIG_fail;
-    SWIG_Python_ConvertPtr(obj1, (void **)&arg2, SWIGTYPE_p_switch_file_handle_t, SWIG_POINTER_EXCEPTION | 0);
-    if (SWIG_arg_fail(2)) SWIG_fail;
-    if (!SWIG_AsCharPtr(obj2, (char**)&arg3)) {
-        SWIG_arg_fail(3);SWIG_fail;
-    }
-    {
-        switch_input_callback_function_t * argp;
-        SWIG_Python_ConvertPtr(obj3, (void **)&argp, SWIGTYPE_p_switch_input_callback_function_t, SWIG_POINTER_EXCEPTION);
-        if (SWIG_arg_fail(4)) SWIG_fail;
-        if (argp == NULL) {
-            SWIG_null_ref("switch_input_callback_function_t");
-        }
-        if (SWIG_arg_fail(4)) SWIG_fail;
-        arg4 = *argp;
-    }
-    {
-        if ((SWIG_ConvertPtr(obj4,(void **)(&arg5),0,SWIG_POINTER_EXCEPTION|0))== -1) {
-            SWIG_arg_fail(5);SWIG_fail;
-        }
-    }
-    {
-        arg6 = (unsigned int)(SWIG_As_unsigned_SS_int(obj5)); 
-        if (SWIG_arg_fail(6)) SWIG_fail;
-    }
-    result = (int)fs_switch_ivr_record_file(arg1,arg2,arg3,arg4,arg5,arg6);
-    
-    {
-        resultobj = SWIG_From_int((int)(result)); 
-    }
-    return resultobj;
-    fail:
-    return NULL;
-}
+	static PyObject *_wrap_fs_switch_ivr_sleep(PyObject * self, PyObject * args) {
+		PyObject *resultobj = NULL;
+		switch_core_session_t *arg1 = (switch_core_session_t *) 0;
+		unsigned int arg2;
+		int result;
+		PyObject *obj0 = 0;
+		PyObject *obj1 = 0;
+
+		if (!PyArg_ParseTuple(args, (char *) "OO:fs_switch_ivr_sleep", &obj0, &obj1))
+			goto fail;
+		SWIG_Python_ConvertPtr(obj0, (void **) &arg1, SWIGTYPE_p_switch_core_session_t, SWIG_POINTER_EXCEPTION | 0);
+		if (SWIG_arg_fail(1))
+			SWIG_fail;
+		{
+			arg2 = (unsigned int) (SWIG_As_unsigned_SS_int(obj1));
+			if (SWIG_arg_fail(2))
+				SWIG_fail;
+		}
+		result = (int) fs_switch_ivr_sleep(arg1, arg2);
+
+		{
+			resultobj = SWIG_From_int((int) (result));
+		}
+		return resultobj;
+	  fail:
+		return NULL;
+	}
 
 
-static PyObject *_wrap_fs_switch_ivr_sleep(PyObject *self, PyObject *args) {
-    PyObject *resultobj = NULL;
-    switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
-    unsigned int arg2 ;
-    int result;
-    PyObject * obj0 = 0 ;
-    PyObject * obj1 = 0 ;
-    
-    if(!PyArg_ParseTuple(args,(char *)"OO:fs_switch_ivr_sleep",&obj0,&obj1)) goto fail;
-    SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_switch_core_session_t, SWIG_POINTER_EXCEPTION | 0);
-    if (SWIG_arg_fail(1)) SWIG_fail;
-    {
-        arg2 = (unsigned int)(SWIG_As_unsigned_SS_int(obj1)); 
-        if (SWIG_arg_fail(2)) SWIG_fail;
-    }
-    result = (int)fs_switch_ivr_sleep(arg1,arg2);
-    
-    {
-        resultobj = SWIG_From_int((int)(result)); 
-    }
-    return resultobj;
-    fail:
-    return NULL;
-}
+	static PyObject *_wrap_fs_ivr_play_file2(PyObject * self, PyObject * args) {
+		PyObject *resultobj = NULL;
+		switch_core_session_t *arg1 = (switch_core_session_t *) 0;
+		char *arg2 = (char *) 0;
+		int result;
+		PyObject *obj0 = 0;
+		PyObject *obj1 = 0;
+
+		if (!PyArg_ParseTuple(args, (char *) "OO:fs_ivr_play_file2", &obj0, &obj1))
+			goto fail;
+		SWIG_Python_ConvertPtr(obj0, (void **) &arg1, SWIGTYPE_p_switch_core_session_t, SWIG_POINTER_EXCEPTION | 0);
+		if (SWIG_arg_fail(1))
+			SWIG_fail;
+		if (!SWIG_AsCharPtr(obj1, (char **) &arg2)) {
+			SWIG_arg_fail(2);
+			SWIG_fail;
+		}
+		result = (int) fs_ivr_play_file2(arg1, arg2);
+
+		{
+			resultobj = SWIG_From_int((int) (result));
+		}
+		return resultobj;
+	  fail:
+		return NULL;
+	}
 
 
-static PyObject *_wrap_fs_ivr_play_file2(PyObject *self, PyObject *args) {
-    PyObject *resultobj = NULL;
-    switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
-    char *arg2 = (char *) 0 ;
-    int result;
-    PyObject * obj0 = 0 ;
-    PyObject * obj1 = 0 ;
-    
-    if(!PyArg_ParseTuple(args,(char *)"OO:fs_ivr_play_file2",&obj0,&obj1)) goto fail;
-    SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_switch_core_session_t, SWIG_POINTER_EXCEPTION | 0);
-    if (SWIG_arg_fail(1)) SWIG_fail;
-    if (!SWIG_AsCharPtr(obj1, (char**)&arg2)) {
-        SWIG_arg_fail(2);SWIG_fail;
-    }
-    result = (int)fs_ivr_play_file2(arg1,arg2);
-    
-    {
-        resultobj = SWIG_From_int((int)(result)); 
-    }
-    return resultobj;
-    fail:
-    return NULL;
-}
+	static PyObject *_wrap_fs_switch_ivr_collect_digits_callback(PyObject * self, PyObject * args) {
+		PyObject *resultobj = NULL;
+		switch_core_session_t *arg1 = (switch_core_session_t *) 0;
+		switch_input_callback_function_t arg2;
+		void *arg3 = (void *) 0;
+		unsigned int arg4;
+		unsigned int arg5;
+		int result;
+		PyObject *obj0 = 0;
+		PyObject *obj1 = 0;
+		PyObject *obj2 = 0;
+		PyObject *obj3 = 0;
+		PyObject *obj4 = 0;
+
+		if (!PyArg_ParseTuple
+			(args, (char *) "OOOOO:fs_switch_ivr_collect_digits_callback", &obj0, &obj1, &obj2, &obj3, &obj4))
+			goto fail;
+		SWIG_Python_ConvertPtr(obj0, (void **) &arg1, SWIGTYPE_p_switch_core_session_t, SWIG_POINTER_EXCEPTION | 0);
+		if (SWIG_arg_fail(1))
+			SWIG_fail;
+		{
+			switch_input_callback_function_t *argp;
+			SWIG_Python_ConvertPtr(obj1, (void **) &argp, SWIGTYPE_p_switch_input_callback_function_t,
+								   SWIG_POINTER_EXCEPTION);
+			if (SWIG_arg_fail(2))
+				SWIG_fail;
+			if (argp == NULL) {
+				SWIG_null_ref("switch_input_callback_function_t");
+			}
+			if (SWIG_arg_fail(2))
+				SWIG_fail;
+			arg2 = *argp;
+		}
+		{
+			if ((SWIG_ConvertPtr(obj2, (void **) (&arg3), 0, SWIG_POINTER_EXCEPTION | 0)) == -1) {
+				SWIG_arg_fail(3);
+				SWIG_fail;
+			}
+		}
+		{
+			arg4 = (unsigned int) (SWIG_As_unsigned_SS_int(obj3));
+			if (SWIG_arg_fail(4))
+				SWIG_fail;
+		}
+		{
+			arg5 = (unsigned int) (SWIG_As_unsigned_SS_int(obj4));
+			if (SWIG_arg_fail(5))
+				SWIG_fail;
+		}
+		result = (int) fs_switch_ivr_collect_digits_callback(arg1, arg2, arg3, arg4, arg5);
+
+		{
+			resultobj = SWIG_From_int((int) (result));
+		}
+		return resultobj;
+	  fail:
+		return NULL;
+	}
 
 
-static PyObject *_wrap_fs_switch_ivr_collect_digits_callback(PyObject *self, PyObject *args) {
-    PyObject *resultobj = NULL;
-    switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
-    switch_input_callback_function_t arg2 ;
-    void *arg3 = (void *) 0 ;
-    unsigned int arg4 ;
-    unsigned int arg5 ;
-    int result;
-    PyObject * obj0 = 0 ;
-    PyObject * obj1 = 0 ;
-    PyObject * obj2 = 0 ;
-    PyObject * obj3 = 0 ;
-    PyObject * obj4 = 0 ;
-    
-    if(!PyArg_ParseTuple(args,(char *)"OOOOO:fs_switch_ivr_collect_digits_callback",&obj0,&obj1,&obj2,&obj3,&obj4)) goto fail;
-    SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_switch_core_session_t, SWIG_POINTER_EXCEPTION | 0);
-    if (SWIG_arg_fail(1)) SWIG_fail;
-    {
-        switch_input_callback_function_t * argp;
-        SWIG_Python_ConvertPtr(obj1, (void **)&argp, SWIGTYPE_p_switch_input_callback_function_t, SWIG_POINTER_EXCEPTION);
-        if (SWIG_arg_fail(2)) SWIG_fail;
-        if (argp == NULL) {
-            SWIG_null_ref("switch_input_callback_function_t");
-        }
-        if (SWIG_arg_fail(2)) SWIG_fail;
-        arg2 = *argp;
-    }
-    {
-        if ((SWIG_ConvertPtr(obj2,(void **)(&arg3),0,SWIG_POINTER_EXCEPTION|0))== -1) {
-            SWIG_arg_fail(3);SWIG_fail;
-        }
-    }
-    {
-        arg4 = (unsigned int)(SWIG_As_unsigned_SS_int(obj3)); 
-        if (SWIG_arg_fail(4)) SWIG_fail;
-    }
-    {
-        arg5 = (unsigned int)(SWIG_As_unsigned_SS_int(obj4)); 
-        if (SWIG_arg_fail(5)) SWIG_fail;
-    }
-    result = (int)fs_switch_ivr_collect_digits_callback(arg1,arg2,arg3,arg4,arg5);
-    
-    {
-        resultobj = SWIG_From_int((int)(result)); 
-    }
-    return resultobj;
-    fail:
-    return NULL;
-}
+	static PyObject *_wrap_fs_switch_ivr_collect_digits_count(PyObject * self, PyObject * args) {
+		PyObject *resultobj = NULL;
+		switch_core_session_t *arg1 = (switch_core_session_t *) 0;
+		char *arg2 = (char *) 0;
+		unsigned int arg3;
+		unsigned int arg4;
+		char *arg5 = (char *) 0;
+		char *arg6 = (char *) 0;
+		unsigned int arg7;
+		int result;
+		PyObject *obj0 = 0;
+		PyObject *obj1 = 0;
+		PyObject *obj2 = 0;
+		PyObject *obj3 = 0;
+		PyObject *obj4 = 0;
+		PyObject *obj5 = 0;
+		PyObject *obj6 = 0;
+
+		if (!PyArg_ParseTuple
+			(args, (char *) "OOOOOOO:fs_switch_ivr_collect_digits_count", &obj0, &obj1, &obj2, &obj3, &obj4, &obj5,
+			 &obj6))
+			goto fail;
+		SWIG_Python_ConvertPtr(obj0, (void **) &arg1, SWIGTYPE_p_switch_core_session_t, SWIG_POINTER_EXCEPTION | 0);
+		if (SWIG_arg_fail(1))
+			SWIG_fail;
+		if (!SWIG_AsCharPtr(obj1, (char **) &arg2)) {
+			SWIG_arg_fail(2);
+			SWIG_fail;
+		}
+		{
+			arg3 = (unsigned int) (SWIG_As_unsigned_SS_int(obj2));
+			if (SWIG_arg_fail(3))
+				SWIG_fail;
+		}
+		{
+			arg4 = (unsigned int) (SWIG_As_unsigned_SS_int(obj3));
+			if (SWIG_arg_fail(4))
+				SWIG_fail;
+		}
+		if (!SWIG_AsCharPtr(obj4, (char **) &arg5)) {
+			SWIG_arg_fail(5);
+			SWIG_fail;
+		}
+		if (!SWIG_AsCharPtr(obj5, (char **) &arg6)) {
+			SWIG_arg_fail(6);
+			SWIG_fail;
+		}
+		{
+			arg7 = (unsigned int) (SWIG_As_unsigned_SS_int(obj6));
+			if (SWIG_arg_fail(7))
+				SWIG_fail;
+		}
+		result = (int) fs_switch_ivr_collect_digits_count(arg1, arg2, arg3, arg4, (char const *) arg5, arg6, arg7);
+
+		{
+			resultobj = SWIG_From_int((int) (result));
+		}
+		return resultobj;
+	  fail:
+		return NULL;
+	}
 
 
-static PyObject *_wrap_fs_switch_ivr_collect_digits_count(PyObject *self, PyObject *args) {
-    PyObject *resultobj = NULL;
-    switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
-    char *arg2 = (char *) 0 ;
-    unsigned int arg3 ;
-    unsigned int arg4 ;
-    char *arg5 = (char *) 0 ;
-    char *arg6 = (char *) 0 ;
-    unsigned int arg7 ;
-    int result;
-    PyObject * obj0 = 0 ;
-    PyObject * obj1 = 0 ;
-    PyObject * obj2 = 0 ;
-    PyObject * obj3 = 0 ;
-    PyObject * obj4 = 0 ;
-    PyObject * obj5 = 0 ;
-    PyObject * obj6 = 0 ;
-    
-    if(!PyArg_ParseTuple(args,(char *)"OOOOOOO:fs_switch_ivr_collect_digits_count",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6)) goto fail;
-    SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_switch_core_session_t, SWIG_POINTER_EXCEPTION | 0);
-    if (SWIG_arg_fail(1)) SWIG_fail;
-    if (!SWIG_AsCharPtr(obj1, (char**)&arg2)) {
-        SWIG_arg_fail(2);SWIG_fail;
-    }
-    {
-        arg3 = (unsigned int)(SWIG_As_unsigned_SS_int(obj2)); 
-        if (SWIG_arg_fail(3)) SWIG_fail;
-    }
-    {
-        arg4 = (unsigned int)(SWIG_As_unsigned_SS_int(obj3)); 
-        if (SWIG_arg_fail(4)) SWIG_fail;
-    }
-    if (!SWIG_AsCharPtr(obj4, (char**)&arg5)) {
-        SWIG_arg_fail(5);SWIG_fail;
-    }
-    if (!SWIG_AsCharPtr(obj5, (char**)&arg6)) {
-        SWIG_arg_fail(6);SWIG_fail;
-    }
-    {
-        arg7 = (unsigned int)(SWIG_As_unsigned_SS_int(obj6)); 
-        if (SWIG_arg_fail(7)) SWIG_fail;
-    }
-    result = (int)fs_switch_ivr_collect_digits_count(arg1,arg2,arg3,arg4,(char const *)arg5,arg6,arg7);
-    
-    {
-        resultobj = SWIG_From_int((int)(result)); 
-    }
-    return resultobj;
-    fail:
-    return NULL;
-}
+	static PyObject *_wrap_fs_switch_ivr_originate(PyObject * self, PyObject * args) {
+		PyObject *resultobj = NULL;
+		switch_core_session_t *arg1 = (switch_core_session_t *) 0;
+		switch_core_session_t **arg2 = (switch_core_session_t **) 0;
+		char *arg3 = (char *) 0;
+		unsigned int arg4;
+		int result;
+		PyObject *obj0 = 0;
+		PyObject *obj1 = 0;
+		PyObject *obj2 = 0;
+		PyObject *obj3 = 0;
+
+		if (!PyArg_ParseTuple(args, (char *) "OOOO:fs_switch_ivr_originate", &obj0, &obj1, &obj2, &obj3))
+			goto fail;
+		SWIG_Python_ConvertPtr(obj0, (void **) &arg1, SWIGTYPE_p_switch_core_session_t, SWIG_POINTER_EXCEPTION | 0);
+		if (SWIG_arg_fail(1))
+			SWIG_fail;
+		SWIG_Python_ConvertPtr(obj1, (void **) &arg2, SWIGTYPE_p_p_switch_core_session_t, SWIG_POINTER_EXCEPTION | 0);
+		if (SWIG_arg_fail(2))
+			SWIG_fail;
+		if (!SWIG_AsCharPtr(obj2, (char **) &arg3)) {
+			SWIG_arg_fail(3);
+			SWIG_fail;
+		}
+		{
+			arg4 = (unsigned int) (SWIG_As_unsigned_SS_int(obj3));
+			if (SWIG_arg_fail(4))
+				SWIG_fail;
+		}
+		result = (int) fs_switch_ivr_originate(arg1, arg2, arg3, arg4);
+
+		{
+			resultobj = SWIG_From_int((int) (result));
+		}
+		return resultobj;
+	  fail:
+		return NULL;
+	}
 
 
-static PyObject *_wrap_fs_switch_ivr_originate(PyObject *self, PyObject *args) {
-    PyObject *resultobj = NULL;
-    switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
-    switch_core_session_t **arg2 = (switch_core_session_t **) 0 ;
-    char *arg3 = (char *) 0 ;
-    unsigned int arg4 ;
-    int result;
-    PyObject * obj0 = 0 ;
-    PyObject * obj1 = 0 ;
-    PyObject * obj2 = 0 ;
-    PyObject * obj3 = 0 ;
-    
-    if(!PyArg_ParseTuple(args,(char *)"OOOO:fs_switch_ivr_originate",&obj0,&obj1,&obj2,&obj3)) goto fail;
-    SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_switch_core_session_t, SWIG_POINTER_EXCEPTION | 0);
-    if (SWIG_arg_fail(1)) SWIG_fail;
-    SWIG_Python_ConvertPtr(obj1, (void **)&arg2, SWIGTYPE_p_p_switch_core_session_t, SWIG_POINTER_EXCEPTION | 0);
-    if (SWIG_arg_fail(2)) SWIG_fail;
-    if (!SWIG_AsCharPtr(obj2, (char**)&arg3)) {
-        SWIG_arg_fail(3);SWIG_fail;
-    }
-    {
-        arg4 = (unsigned int)(SWIG_As_unsigned_SS_int(obj3)); 
-        if (SWIG_arg_fail(4)) SWIG_fail;
-    }
-    result = (int)fs_switch_ivr_originate(arg1,arg2,arg3,arg4);
-    
-    {
-        resultobj = SWIG_From_int((int)(result)); 
-    }
-    return resultobj;
-    fail:
-    return NULL;
-}
+	static PyObject *_wrap_fs_switch_ivr_session_transfer(PyObject * self, PyObject * args) {
+		PyObject *resultobj = NULL;
+		switch_core_session_t *arg1 = (switch_core_session_t *) 0;
+		char *arg2 = (char *) 0;
+		char *arg3 = (char *) 0;
+		char *arg4 = (char *) 0;
+		int result;
+		PyObject *obj0 = 0;
+		PyObject *obj1 = 0;
+		PyObject *obj2 = 0;
+		PyObject *obj3 = 0;
+
+		if (!PyArg_ParseTuple(args, (char *) "OOOO:fs_switch_ivr_session_transfer", &obj0, &obj1, &obj2, &obj3))
+			goto fail;
+		SWIG_Python_ConvertPtr(obj0, (void **) &arg1, SWIGTYPE_p_switch_core_session_t, SWIG_POINTER_EXCEPTION | 0);
+		if (SWIG_arg_fail(1))
+			SWIG_fail;
+		if (!SWIG_AsCharPtr(obj1, (char **) &arg2)) {
+			SWIG_arg_fail(2);
+			SWIG_fail;
+		}
+		if (!SWIG_AsCharPtr(obj2, (char **) &arg3)) {
+			SWIG_arg_fail(3);
+			SWIG_fail;
+		}
+		if (!SWIG_AsCharPtr(obj3, (char **) &arg4)) {
+			SWIG_arg_fail(4);
+			SWIG_fail;
+		}
+		result = (int) fs_switch_ivr_session_transfer(arg1, arg2, arg3, arg4);
+
+		{
+			resultobj = SWIG_From_int((int) (result));
+		}
+		return resultobj;
+	  fail:
+		return NULL;
+	}
 
 
-static PyObject *_wrap_fs_switch_ivr_session_transfer(PyObject *self, PyObject *args) {
-    PyObject *resultobj = NULL;
-    switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
-    char *arg2 = (char *) 0 ;
-    char *arg3 = (char *) 0 ;
-    char *arg4 = (char *) 0 ;
-    int result;
-    PyObject * obj0 = 0 ;
-    PyObject * obj1 = 0 ;
-    PyObject * obj2 = 0 ;
-    PyObject * obj3 = 0 ;
-    
-    if(!PyArg_ParseTuple(args,(char *)"OOOO:fs_switch_ivr_session_transfer",&obj0,&obj1,&obj2,&obj3)) goto fail;
-    SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_switch_core_session_t, SWIG_POINTER_EXCEPTION | 0);
-    if (SWIG_arg_fail(1)) SWIG_fail;
-    if (!SWIG_AsCharPtr(obj1, (char**)&arg2)) {
-        SWIG_arg_fail(2);SWIG_fail;
-    }
-    if (!SWIG_AsCharPtr(obj2, (char**)&arg3)) {
-        SWIG_arg_fail(3);SWIG_fail;
-    }
-    if (!SWIG_AsCharPtr(obj3, (char**)&arg4)) {
-        SWIG_arg_fail(4);SWIG_fail;
-    }
-    result = (int)fs_switch_ivr_session_transfer(arg1,arg2,arg3,arg4);
-    
-    {
-        resultobj = SWIG_From_int((int)(result)); 
-    }
-    return resultobj;
-    fail:
-    return NULL;
-}
+	static PyObject *_wrap_fs_switch_ivr_speak_text(PyObject * self, PyObject * args) {
+		PyObject *resultobj = NULL;
+		switch_core_session_t *arg1 = (switch_core_session_t *) 0;
+		char *arg2 = (char *) 0;
+		char *arg3 = (char *) 0;
+		char *arg4 = (char *) 0;
+		unsigned int arg5;
+		switch_input_callback_function_t arg6;
+		char *arg7 = (char *) 0;
+		void *arg8 = (void *) 0;
+		unsigned int arg9;
+		int result;
+		PyObject *obj0 = 0;
+		PyObject *obj1 = 0;
+		PyObject *obj2 = 0;
+		PyObject *obj3 = 0;
+		PyObject *obj4 = 0;
+		PyObject *obj5 = 0;
+		PyObject *obj6 = 0;
+		PyObject *obj7 = 0;
+		PyObject *obj8 = 0;
+
+		if (!PyArg_ParseTuple
+			(args, (char *) "OOOOOOOOO:fs_switch_ivr_speak_text", &obj0, &obj1, &obj2, &obj3, &obj4, &obj5, &obj6,
+			 &obj7, &obj8))
+			goto fail;
+		SWIG_Python_ConvertPtr(obj0, (void **) &arg1, SWIGTYPE_p_switch_core_session_t, SWIG_POINTER_EXCEPTION | 0);
+		if (SWIG_arg_fail(1))
+			SWIG_fail;
+		if (!SWIG_AsCharPtr(obj1, (char **) &arg2)) {
+			SWIG_arg_fail(2);
+			SWIG_fail;
+		}
+		if (!SWIG_AsCharPtr(obj2, (char **) &arg3)) {
+			SWIG_arg_fail(3);
+			SWIG_fail;
+		}
+		if (!SWIG_AsCharPtr(obj3, (char **) &arg4)) {
+			SWIG_arg_fail(4);
+			SWIG_fail;
+		}
+		{
+			arg5 = (unsigned int) (SWIG_As_unsigned_SS_int(obj4));
+			if (SWIG_arg_fail(5))
+				SWIG_fail;
+		}
+		{
+			switch_input_callback_function_t *argp;
+			SWIG_Python_ConvertPtr(obj5, (void **) &argp, SWIGTYPE_p_switch_input_callback_function_t,
+								   SWIG_POINTER_EXCEPTION);
+			if (SWIG_arg_fail(6))
+				SWIG_fail;
+			if (argp == NULL) {
+				SWIG_null_ref("switch_input_callback_function_t");
+			}
+			if (SWIG_arg_fail(6))
+				SWIG_fail;
+			arg6 = *argp;
+		}
+		if (!SWIG_AsCharPtr(obj6, (char **) &arg7)) {
+			SWIG_arg_fail(7);
+			SWIG_fail;
+		}
+		{
+			if ((SWIG_ConvertPtr(obj7, (void **) (&arg8), 0, SWIG_POINTER_EXCEPTION | 0)) == -1) {
+				SWIG_arg_fail(8);
+				SWIG_fail;
+			}
+		}
+		{
+			arg9 = (unsigned int) (SWIG_As_unsigned_SS_int(obj8));
+			if (SWIG_arg_fail(9))
+				SWIG_fail;
+		}
+		result = (int) fs_switch_ivr_speak_text(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9);
+
+		{
+			resultobj = SWIG_From_int((int) (result));
+		}
+		return resultobj;
+	  fail:
+		return NULL;
+	}
 
 
-static PyObject *_wrap_fs_switch_ivr_speak_text(PyObject *self, PyObject *args) {
-    PyObject *resultobj = NULL;
-    switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
-    char *arg2 = (char *) 0 ;
-    char *arg3 = (char *) 0 ;
-    char *arg4 = (char *) 0 ;
-    unsigned int arg5 ;
-    switch_input_callback_function_t arg6 ;
-    char *arg7 = (char *) 0 ;
-    void *arg8 = (void *) 0 ;
-    unsigned int arg9 ;
-    int result;
-    PyObject * obj0 = 0 ;
-    PyObject * obj1 = 0 ;
-    PyObject * obj2 = 0 ;
-    PyObject * obj3 = 0 ;
-    PyObject * obj4 = 0 ;
-    PyObject * obj5 = 0 ;
-    PyObject * obj6 = 0 ;
-    PyObject * obj7 = 0 ;
-    PyObject * obj8 = 0 ;
-    
-    if(!PyArg_ParseTuple(args,(char *)"OOOOOOOOO:fs_switch_ivr_speak_text",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7,&obj8)) goto fail;
-    SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_switch_core_session_t, SWIG_POINTER_EXCEPTION | 0);
-    if (SWIG_arg_fail(1)) SWIG_fail;
-    if (!SWIG_AsCharPtr(obj1, (char**)&arg2)) {
-        SWIG_arg_fail(2);SWIG_fail;
-    }
-    if (!SWIG_AsCharPtr(obj2, (char**)&arg3)) {
-        SWIG_arg_fail(3);SWIG_fail;
-    }
-    if (!SWIG_AsCharPtr(obj3, (char**)&arg4)) {
-        SWIG_arg_fail(4);SWIG_fail;
-    }
-    {
-        arg5 = (unsigned int)(SWIG_As_unsigned_SS_int(obj4)); 
-        if (SWIG_arg_fail(5)) SWIG_fail;
-    }
-    {
-        switch_input_callback_function_t * argp;
-        SWIG_Python_ConvertPtr(obj5, (void **)&argp, SWIGTYPE_p_switch_input_callback_function_t, SWIG_POINTER_EXCEPTION);
-        if (SWIG_arg_fail(6)) SWIG_fail;
-        if (argp == NULL) {
-            SWIG_null_ref("switch_input_callback_function_t");
-        }
-        if (SWIG_arg_fail(6)) SWIG_fail;
-        arg6 = *argp;
-    }
-    if (!SWIG_AsCharPtr(obj6, (char**)&arg7)) {
-        SWIG_arg_fail(7);SWIG_fail;
-    }
-    {
-        if ((SWIG_ConvertPtr(obj7,(void **)(&arg8),0,SWIG_POINTER_EXCEPTION|0))== -1) {
-            SWIG_arg_fail(8);SWIG_fail;
-        }
-    }
-    {
-        arg9 = (unsigned int)(SWIG_As_unsigned_SS_int(obj8)); 
-        if (SWIG_arg_fail(9)) SWIG_fail;
-    }
-    result = (int)fs_switch_ivr_speak_text(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9);
-    
-    {
-        resultobj = SWIG_From_int((int)(result)); 
-    }
-    return resultobj;
-    fail:
-    return NULL;
-}
+	static PyObject *_wrap_fs_switch_ivr_speak_text2(PyObject * self, PyObject * args) {
+		PyObject *resultobj = NULL;
+		switch_core_session_t *arg1 = (switch_core_session_t *) 0;
+		char *arg2 = (char *) 0;
+		char *arg3 = (char *) 0;
+		char *arg4 = (char *) 0;
+		int result;
+		PyObject *obj0 = 0;
+		PyObject *obj1 = 0;
+		PyObject *obj2 = 0;
+		PyObject *obj3 = 0;
+
+		if (!PyArg_ParseTuple(args, (char *) "OOOO:fs_switch_ivr_speak_text2", &obj0, &obj1, &obj2, &obj3))
+			goto fail;
+		SWIG_Python_ConvertPtr(obj0, (void **) &arg1, SWIGTYPE_p_switch_core_session_t, SWIG_POINTER_EXCEPTION | 0);
+		if (SWIG_arg_fail(1))
+			SWIG_fail;
+		if (!SWIG_AsCharPtr(obj1, (char **) &arg2)) {
+			SWIG_arg_fail(2);
+			SWIG_fail;
+		}
+		if (!SWIG_AsCharPtr(obj2, (char **) &arg3)) {
+			SWIG_arg_fail(3);
+			SWIG_fail;
+		}
+		if (!SWIG_AsCharPtr(obj3, (char **) &arg4)) {
+			SWIG_arg_fail(4);
+			SWIG_fail;
+		}
+		result = (int) fs_switch_ivr_speak_text2(arg1, arg2, arg3, arg4);
+
+		{
+			resultobj = SWIG_From_int((int) (result));
+		}
+		return resultobj;
+	  fail:
+		return NULL;
+	}
 
 
-static PyObject *_wrap_fs_switch_ivr_speak_text2(PyObject *self, PyObject *args) {
-    PyObject *resultobj = NULL;
-    switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
-    char *arg2 = (char *) 0 ;
-    char *arg3 = (char *) 0 ;
-    char *arg4 = (char *) 0 ;
-    int result;
-    PyObject * obj0 = 0 ;
-    PyObject * obj1 = 0 ;
-    PyObject * obj2 = 0 ;
-    PyObject * obj3 = 0 ;
-    
-    if(!PyArg_ParseTuple(args,(char *)"OOOO:fs_switch_ivr_speak_text2",&obj0,&obj1,&obj2,&obj3)) goto fail;
-    SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_switch_core_session_t, SWIG_POINTER_EXCEPTION | 0);
-    if (SWIG_arg_fail(1)) SWIG_fail;
-    if (!SWIG_AsCharPtr(obj1, (char**)&arg2)) {
-        SWIG_arg_fail(2);SWIG_fail;
-    }
-    if (!SWIG_AsCharPtr(obj2, (char**)&arg3)) {
-        SWIG_arg_fail(3);SWIG_fail;
-    }
-    if (!SWIG_AsCharPtr(obj3, (char**)&arg4)) {
-        SWIG_arg_fail(4);SWIG_fail;
-    }
-    result = (int)fs_switch_ivr_speak_text2(arg1,arg2,arg3,arg4);
-    
-    {
-        resultobj = SWIG_From_int((int)(result)); 
-    }
-    return resultobj;
-    fail:
-    return NULL;
-}
+	static PyObject *_wrap_fs_switch_channel_get_variable(PyObject * self, PyObject * args) {
+		PyObject *resultobj = NULL;
+		switch_channel_t *arg1 = (switch_channel_t *) 0;
+		char *arg2 = (char *) 0;
+		char *result;
+		PyObject *obj0 = 0;
+		PyObject *obj1 = 0;
+
+		if (!PyArg_ParseTuple(args, (char *) "OO:fs_switch_channel_get_variable", &obj0, &obj1))
+			goto fail;
+		SWIG_Python_ConvertPtr(obj0, (void **) &arg1, SWIGTYPE_p_switch_channel_t, SWIG_POINTER_EXCEPTION | 0);
+		if (SWIG_arg_fail(1))
+			SWIG_fail;
+		if (!SWIG_AsCharPtr(obj1, (char **) &arg2)) {
+			SWIG_arg_fail(2);
+			SWIG_fail;
+		}
+		result = (char *) fs_switch_channel_get_variable(arg1, arg2);
+
+		resultobj = SWIG_FromCharPtr(result);
+		return resultobj;
+	  fail:
+		return NULL;
+	}
 
 
-static PyObject *_wrap_fs_switch_channel_get_variable(PyObject *self, PyObject *args) {
-    PyObject *resultobj = NULL;
-    switch_channel_t *arg1 = (switch_channel_t *) 0 ;
-    char *arg2 = (char *) 0 ;
-    char *result;
-    PyObject * obj0 = 0 ;
-    PyObject * obj1 = 0 ;
-    
-    if(!PyArg_ParseTuple(args,(char *)"OO:fs_switch_channel_get_variable",&obj0,&obj1)) goto fail;
-    SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_switch_channel_t, SWIG_POINTER_EXCEPTION | 0);
-    if (SWIG_arg_fail(1)) SWIG_fail;
-    if (!SWIG_AsCharPtr(obj1, (char**)&arg2)) {
-        SWIG_arg_fail(2);SWIG_fail;
-    }
-    result = (char *)fs_switch_channel_get_variable(arg1,arg2);
-    
-    resultobj = SWIG_FromCharPtr(result);
-    return resultobj;
-    fail:
-    return NULL;
-}
+	static PyObject *_wrap_fs_switch_channel_set_variable(PyObject * self, PyObject * args) {
+		PyObject *resultobj = NULL;
+		switch_channel_t *arg1 = (switch_channel_t *) 0;
+		char *arg2 = (char *) 0;
+		char *arg3 = (char *) 0;
+		int result;
+		PyObject *obj0 = 0;
+		PyObject *obj1 = 0;
+		PyObject *obj2 = 0;
+
+		if (!PyArg_ParseTuple(args, (char *) "OOO:fs_switch_channel_set_variable", &obj0, &obj1, &obj2))
+			goto fail;
+		SWIG_Python_ConvertPtr(obj0, (void **) &arg1, SWIGTYPE_p_switch_channel_t, SWIG_POINTER_EXCEPTION | 0);
+		if (SWIG_arg_fail(1))
+			SWIG_fail;
+		if (!SWIG_AsCharPtr(obj1, (char **) &arg2)) {
+			SWIG_arg_fail(2);
+			SWIG_fail;
+		}
+		if (!SWIG_AsCharPtr(obj2, (char **) &arg3)) {
+			SWIG_arg_fail(3);
+			SWIG_fail;
+		}
+		result = (int) fs_switch_channel_set_variable(arg1, arg2, arg3);
+
+		{
+			resultobj = SWIG_From_int((int) (result));
+		}
+		return resultobj;
+	  fail:
+		return NULL;
+	}
 
 
-static PyObject *_wrap_fs_switch_channel_set_variable(PyObject *self, PyObject *args) {
-    PyObject *resultobj = NULL;
-    switch_channel_t *arg1 = (switch_channel_t *) 0 ;
-    char *arg2 = (char *) 0 ;
-    char *arg3 = (char *) 0 ;
-    int result;
-    PyObject * obj0 = 0 ;
-    PyObject * obj1 = 0 ;
-    PyObject * obj2 = 0 ;
-    
-    if(!PyArg_ParseTuple(args,(char *)"OOO:fs_switch_channel_set_variable",&obj0,&obj1,&obj2)) goto fail;
-    SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_switch_channel_t, SWIG_POINTER_EXCEPTION | 0);
-    if (SWIG_arg_fail(1)) SWIG_fail;
-    if (!SWIG_AsCharPtr(obj1, (char**)&arg2)) {
-        SWIG_arg_fail(2);SWIG_fail;
-    }
-    if (!SWIG_AsCharPtr(obj2, (char**)&arg3)) {
-        SWIG_arg_fail(3);SWIG_fail;
-    }
-    result = (int)fs_switch_channel_set_variable(arg1,arg2,arg3);
-    
-    {
-        resultobj = SWIG_From_int((int)(result)); 
-    }
-    return resultobj;
-    fail:
-    return NULL;
-}
-
-
-static PyMethodDef SwigMethods[] = {
-	 { (char *)"fs_core_set_globals", _wrap_fs_core_set_globals, METH_VARARGS, NULL},
-	 { (char *)"fs_core_init", _wrap_fs_core_init, METH_VARARGS, NULL},
-	 { (char *)"fs_core_destroy", _wrap_fs_core_destroy, METH_VARARGS, NULL},
-	 { (char *)"fs_loadable_module_init", _wrap_fs_loadable_module_init, METH_VARARGS, NULL},
-	 { (char *)"fs_loadable_module_shutdown", _wrap_fs_loadable_module_shutdown, METH_VARARGS, NULL},
-	 { (char *)"fs_console_loop", _wrap_fs_console_loop, METH_VARARGS, NULL},
-	 { (char *)"fs_console_log", _wrap_fs_console_log, METH_VARARGS, NULL},
-	 { (char *)"fs_console_clean", _wrap_fs_console_clean, METH_VARARGS, NULL},
-	 { (char *)"fs_core_session_locate", _wrap_fs_core_session_locate, METH_VARARGS, NULL},
-	 { (char *)"fs_channel_answer", _wrap_fs_channel_answer, METH_VARARGS, NULL},
-	 { (char *)"fs_channel_pre_answer", _wrap_fs_channel_pre_answer, METH_VARARGS, NULL},
-	 { (char *)"fs_channel_hangup", _wrap_fs_channel_hangup, METH_VARARGS, NULL},
-	 { (char *)"fs_channel_set_variable", _wrap_fs_channel_set_variable, METH_VARARGS, NULL},
-	 { (char *)"fs_channel_get_variable", _wrap_fs_channel_get_variable, METH_VARARGS, NULL},
-	 { (char *)"fs_channel_set_state", _wrap_fs_channel_set_state, METH_VARARGS, NULL},
-	 { (char *)"fs_ivr_play_file", _wrap_fs_ivr_play_file, METH_VARARGS, NULL},
-	 { (char *)"fs_switch_ivr_record_file", _wrap_fs_switch_ivr_record_file, METH_VARARGS, NULL},
-	 { (char *)"fs_switch_ivr_sleep", _wrap_fs_switch_ivr_sleep, METH_VARARGS, NULL},
-	 { (char *)"fs_ivr_play_file2", _wrap_fs_ivr_play_file2, METH_VARARGS, NULL},
-	 { (char *)"fs_switch_ivr_collect_digits_callback", _wrap_fs_switch_ivr_collect_digits_callback, METH_VARARGS, NULL},
-	 { (char *)"fs_switch_ivr_collect_digits_count", _wrap_fs_switch_ivr_collect_digits_count, METH_VARARGS, NULL},
-	 { (char *)"fs_switch_ivr_originate", _wrap_fs_switch_ivr_originate, METH_VARARGS, NULL},
-	 { (char *)"fs_switch_ivr_session_transfer", _wrap_fs_switch_ivr_session_transfer, METH_VARARGS, NULL},
-	 { (char *)"fs_switch_ivr_speak_text", _wrap_fs_switch_ivr_speak_text, METH_VARARGS, NULL},
-	 { (char *)"fs_switch_ivr_speak_text2", _wrap_fs_switch_ivr_speak_text2, METH_VARARGS, NULL},
-	 { (char *)"fs_switch_channel_get_variable", _wrap_fs_switch_channel_get_variable, METH_VARARGS, NULL},
-	 { (char *)"fs_switch_channel_set_variable", _wrap_fs_switch_channel_set_variable, METH_VARARGS, NULL},
-	 { NULL, NULL, 0, NULL }
-};
+	static PyMethodDef SwigMethods[] = {
+		{(char *) "fs_core_set_globals", _wrap_fs_core_set_globals, METH_VARARGS, NULL},
+		{(char *) "fs_core_init", _wrap_fs_core_init, METH_VARARGS, NULL},
+		{(char *) "fs_core_destroy", _wrap_fs_core_destroy, METH_VARARGS, NULL},
+		{(char *) "fs_loadable_module_init", _wrap_fs_loadable_module_init, METH_VARARGS, NULL},
+		{(char *) "fs_loadable_module_shutdown", _wrap_fs_loadable_module_shutdown, METH_VARARGS, NULL},
+		{(char *) "fs_console_loop", _wrap_fs_console_loop, METH_VARARGS, NULL},
+		{(char *) "fs_console_log", _wrap_fs_console_log, METH_VARARGS, NULL},
+		{(char *) "fs_console_clean", _wrap_fs_console_clean, METH_VARARGS, NULL},
+		{(char *) "fs_core_session_locate", _wrap_fs_core_session_locate, METH_VARARGS, NULL},
+		{(char *) "fs_channel_answer", _wrap_fs_channel_answer, METH_VARARGS, NULL},
+		{(char *) "fs_channel_pre_answer", _wrap_fs_channel_pre_answer, METH_VARARGS, NULL},
+		{(char *) "fs_channel_hangup", _wrap_fs_channel_hangup, METH_VARARGS, NULL},
+		{(char *) "fs_channel_set_variable", _wrap_fs_channel_set_variable, METH_VARARGS, NULL},
+		{(char *) "fs_channel_get_variable", _wrap_fs_channel_get_variable, METH_VARARGS, NULL},
+		{(char *) "fs_channel_set_state", _wrap_fs_channel_set_state, METH_VARARGS, NULL},
+		{(char *) "fs_ivr_play_file", _wrap_fs_ivr_play_file, METH_VARARGS, NULL},
+		{(char *) "fs_switch_ivr_record_file", _wrap_fs_switch_ivr_record_file, METH_VARARGS, NULL},
+		{(char *) "fs_switch_ivr_sleep", _wrap_fs_switch_ivr_sleep, METH_VARARGS, NULL},
+		{(char *) "fs_ivr_play_file2", _wrap_fs_ivr_play_file2, METH_VARARGS, NULL},
+		{(char *) "fs_switch_ivr_collect_digits_callback", _wrap_fs_switch_ivr_collect_digits_callback, METH_VARARGS,
+		 NULL},
+		{(char *) "fs_switch_ivr_collect_digits_count", _wrap_fs_switch_ivr_collect_digits_count, METH_VARARGS, NULL},
+		{(char *) "fs_switch_ivr_originate", _wrap_fs_switch_ivr_originate, METH_VARARGS, NULL},
+		{(char *) "fs_switch_ivr_session_transfer", _wrap_fs_switch_ivr_session_transfer, METH_VARARGS, NULL},
+		{(char *) "fs_switch_ivr_speak_text", _wrap_fs_switch_ivr_speak_text, METH_VARARGS, NULL},
+		{(char *) "fs_switch_ivr_speak_text2", _wrap_fs_switch_ivr_speak_text2, METH_VARARGS, NULL},
+		{(char *) "fs_switch_channel_get_variable", _wrap_fs_switch_channel_get_variable, METH_VARARGS, NULL},
+		{(char *) "fs_switch_channel_set_variable", _wrap_fs_switch_channel_set_variable, METH_VARARGS, NULL},
+		{NULL, NULL, 0, NULL}
+	};
 
 
 /* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */
 
-static swig_type_info _swigt__p_char = {"_p_char", "char *", 0, 0, 0};
-static swig_type_info _swigt__p_p_switch_core_session_t = {"_p_p_switch_core_session_t", "switch_core_session_t **", 0, 0, 0};
-static swig_type_info _swigt__p_switch_channel_state_t = {"_p_switch_channel_state_t", "enum switch_channel_state_t *|switch_channel_state_t *", 0, 0, 0};
-static swig_type_info _swigt__p_switch_channel_t = {"_p_switch_channel_t", "switch_channel_t *", 0, 0, 0};
-static swig_type_info _swigt__p_switch_core_session_t = {"_p_switch_core_session_t", "switch_core_session_t *", 0, 0, 0};
-static swig_type_info _swigt__p_switch_file_handle_t = {"_p_switch_file_handle_t", "switch_file_handle_t *", 0, 0, 0};
-static swig_type_info _swigt__p_switch_input_callback_function_t = {"_p_switch_input_callback_function_t", "switch_input_callback_function_t *", 0, 0, 0};
-static swig_type_info _swigt__ptrdiff_t = {"_ptrdiff_t", "ptrdiff_t", 0, 0, 0};
-static swig_type_info _swigt__size_t = {"_size_t", "size_t", 0, 0, 0};
+	static swig_type_info _swigt__p_char = { "_p_char", "char *", 0, 0, 0 };
+	static swig_type_info _swigt__p_p_switch_core_session_t =
+		{ "_p_p_switch_core_session_t", "switch_core_session_t **", 0, 0, 0 };
+	static swig_type_info _swigt__p_switch_channel_state_t =
+		{ "_p_switch_channel_state_t", "enum switch_channel_state_t *|switch_channel_state_t *", 0, 0, 0 };
+	static swig_type_info _swigt__p_switch_channel_t = { "_p_switch_channel_t", "switch_channel_t *", 0, 0, 0 };
+	static swig_type_info _swigt__p_switch_core_session_t =
+		{ "_p_switch_core_session_t", "switch_core_session_t *", 0, 0, 0 };
+	static swig_type_info _swigt__p_switch_file_handle_t =
+		{ "_p_switch_file_handle_t", "switch_file_handle_t *", 0, 0, 0 };
+	static swig_type_info _swigt__p_switch_input_callback_function_t =
+		{ "_p_switch_input_callback_function_t", "switch_input_callback_function_t *", 0, 0, 0 };
+	static swig_type_info _swigt__ptrdiff_t = { "_ptrdiff_t", "ptrdiff_t", 0, 0, 0 };
+	static swig_type_info _swigt__size_t = { "_size_t", "size_t", 0, 0, 0 };
 
-static swig_type_info *swig_type_initial[] = {
-  &_swigt__p_char,
-  &_swigt__p_p_switch_core_session_t,
-  &_swigt__p_switch_channel_state_t,
-  &_swigt__p_switch_channel_t,
-  &_swigt__p_switch_core_session_t,
-  &_swigt__p_switch_file_handle_t,
-  &_swigt__p_switch_input_callback_function_t,
-  &_swigt__ptrdiff_t,
-  &_swigt__size_t,
-};
+	static swig_type_info *swig_type_initial[] = {
+		&_swigt__p_char,
+		&_swigt__p_p_switch_core_session_t,
+		&_swigt__p_switch_channel_state_t,
+		&_swigt__p_switch_channel_t,
+		&_swigt__p_switch_core_session_t,
+		&_swigt__p_switch_file_handle_t,
+		&_swigt__p_switch_input_callback_function_t,
+		&_swigt__ptrdiff_t,
+		&_swigt__size_t,
+	};
 
-static swig_cast_info _swigc__p_char[] = {  {&_swigt__p_char, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_p_switch_core_session_t[] = {  {&_swigt__p_p_switch_core_session_t, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_switch_channel_state_t[] = {  {&_swigt__p_switch_channel_state_t, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_switch_channel_t[] = {  {&_swigt__p_switch_channel_t, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_switch_core_session_t[] = {  {&_swigt__p_switch_core_session_t, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_switch_file_handle_t[] = {  {&_swigt__p_switch_file_handle_t, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_switch_input_callback_function_t[] = {  {&_swigt__p_switch_input_callback_function_t, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__ptrdiff_t[] = {  {&_swigt__ptrdiff_t, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__size_t[] = {  {&_swigt__size_t, 0, 0, 0},{0, 0, 0, 0}};
+	static swig_cast_info _swigc__p_char[] = { {&_swigt__p_char, 0, 0, 0}, {0, 0, 0, 0} };
+	static swig_cast_info _swigc__p_p_switch_core_session_t[] =
+		{ {&_swigt__p_p_switch_core_session_t, 0, 0, 0}, {0, 0, 0, 0} };
+	static swig_cast_info _swigc__p_switch_channel_state_t[] =
+		{ {&_swigt__p_switch_channel_state_t, 0, 0, 0}, {0, 0, 0, 0} };
+	static swig_cast_info _swigc__p_switch_channel_t[] = { {&_swigt__p_switch_channel_t, 0, 0, 0}, {0, 0, 0, 0} };
+	static swig_cast_info _swigc__p_switch_core_session_t[] =
+		{ {&_swigt__p_switch_core_session_t, 0, 0, 0}, {0, 0, 0, 0} };
+	static swig_cast_info _swigc__p_switch_file_handle_t[] =
+		{ {&_swigt__p_switch_file_handle_t, 0, 0, 0}, {0, 0, 0, 0} };
+	static swig_cast_info _swigc__p_switch_input_callback_function_t[] =
+		{ {&_swigt__p_switch_input_callback_function_t, 0, 0, 0}, {0, 0, 0, 0} };
+	static swig_cast_info _swigc__ptrdiff_t[] = { {&_swigt__ptrdiff_t, 0, 0, 0}, {0, 0, 0, 0} };
+	static swig_cast_info _swigc__size_t[] = { {&_swigt__size_t, 0, 0, 0}, {0, 0, 0, 0} };
 
-static swig_cast_info *swig_cast_initial[] = {
-  _swigc__p_char,
-  _swigc__p_p_switch_core_session_t,
-  _swigc__p_switch_channel_state_t,
-  _swigc__p_switch_channel_t,
-  _swigc__p_switch_core_session_t,
-  _swigc__p_switch_file_handle_t,
-  _swigc__p_switch_input_callback_function_t,
-  _swigc__ptrdiff_t,
-  _swigc__size_t,
-};
+	static swig_cast_info *swig_cast_initial[] = {
+		_swigc__p_char,
+		_swigc__p_p_switch_core_session_t,
+		_swigc__p_switch_channel_state_t,
+		_swigc__p_switch_channel_t,
+		_swigc__p_switch_core_session_t,
+		_swigc__p_switch_file_handle_t,
+		_swigc__p_switch_input_callback_function_t,
+		_swigc__ptrdiff_t,
+		_swigc__size_t,
+	};
 
 
 /* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */
 
-static swig_const_info swig_const_table[] = {
-{0, 0, 0, 0.0, 0, 0}};
+	static swig_const_info swig_const_table[] = {
+		{0, 0, 0, 0.0, 0, 0}
+	};
 
 #ifdef __cplusplus
 }
@@ -2518,108 +2568,109 @@ static swig_const_info swig_const_table[] = {
 #ifdef __cplusplus
 extern "C" {
 #endif
-    
-    SWIGRUNTIME void
-    SWIG_InitializeModule(void *clientdata) {
-        swig_type_info *type, *ret;
-        swig_cast_info *cast;
-        size_t i;
-        swig_module_info *module_head;
-        static int init_run = 0;
-        
-        clientdata = clientdata;
-        
-        if (init_run) return;
-        init_run = 1;
-        
-        /* Initialize the swig_module */
-        swig_module.type_initial = swig_type_initial;
-        swig_module.cast_initial = swig_cast_initial;
-        
-        /* Try and load any already created modules */
-        module_head = SWIG_GetModule(clientdata);
-        if (module_head) {
-            swig_module.next = module_head->next;
-            module_head->next = &swig_module;
-        } else {
-            /* This is the first module loaded */
-            swig_module.next = &swig_module;
-            SWIG_SetModule(clientdata, &swig_module);
-        }
-        
-        /* Now work on filling in swig_module.types */
-        for (i = 0; i < swig_module.size; ++i) {
-            type = 0;
-            
-            /* if there is another module already loaded */
-            if (swig_module.next != &swig_module) {
-                type = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, swig_module.type_initial[i]->name);
-            }
-            if (type) {
-                /* Overwrite clientdata field */
-                if (swig_module.type_initial[i]->clientdata) type->clientdata = swig_module.type_initial[i]->clientdata;
-            } else {
-                type = swig_module.type_initial[i];
-            }
-            
-            /* Insert casting types */
-            cast = swig_module.cast_initial[i];
-            while (cast->type) {
-                /* Don't need to add information already in the list */
-                ret = 0;
-                if (swig_module.next != &swig_module) {
-                    ret = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, cast->type->name);
-                }
-                if (ret && type == swig_module.type_initial[i]) {
-                    cast->type = ret;
-                    ret = 0;
-                }
-                
-                if (!ret) {
-                    if (type->cast) {
-                        type->cast->prev = cast;
-                        cast->next = type->cast;
-                    }
-                    type->cast = cast;
-                }
-                
-                cast++;
-            }
-            
-            /* Set entry in modules->types array equal to the type */
-            swig_module.types[i] = type;
-        }
-        swig_module.types[i] = 0;
-    }
-    
-    /* This function will propagate the clientdata field of type to
-    * any new swig_type_info structures that have been added into the list
-    * of equivalent types.  It is like calling
-    * SWIG_TypeClientData(type, clientdata) a second time.
-    */
-    SWIGRUNTIME void
-    SWIG_PropagateClientData(void) {
-        size_t i;
-        swig_cast_info *equiv;
-        static int init_run = 0;
-        
-        if (init_run) return;
-        init_run = 1;
-        
-        for (i = 0; i < swig_module.size; i++) {
-            if (swig_module.types[i]->clientdata) {
-                equiv = swig_module.types[i]->cast;
-                while (equiv) {
-                    if (!equiv->converter) {
-                        if (equiv->type && !equiv->type->clientdata)
-                        SWIG_TypeClientData(equiv->type, swig_module.types[i]->clientdata);
-                    }
-                    equiv = equiv->next;
-                }
-            }
-        }
-    }
-    
+
+	SWIGRUNTIME void SWIG_InitializeModule(void *clientdata) {
+		swig_type_info *type, *ret;
+		swig_cast_info *cast;
+		size_t i;
+		swig_module_info *module_head;
+		static int init_run = 0;
+
+		    clientdata = clientdata;
+
+		if  (init_run)
+			    return;
+		    init_run = 1;
+
+		/* Initialize the swig_module */
+		    swig_module.type_initial = swig_type_initial;
+		    swig_module.cast_initial = swig_cast_initial;
+
+		/* Try and load any already created modules */
+		    module_head = SWIG_GetModule(clientdata);
+		if  (module_head) {
+			swig_module.next = module_head->next;
+			module_head->next = &swig_module;
+		} else {
+			/* This is the first module loaded */
+			swig_module.next = &swig_module;
+			SWIG_SetModule(clientdata, &swig_module);
+		}
+
+		/* Now work on filling in swig_module.types */
+		for (i = 0; i < swig_module.size; ++i) {
+			type = 0;
+
+			/* if there is another module already loaded */
+			if (swig_module.next != &swig_module) {
+				type = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, swig_module.type_initial[i]->name);
+			}
+			if (type) {
+				/* Overwrite clientdata field */
+				if (swig_module.type_initial[i]->clientdata)
+					type->clientdata = swig_module.type_initial[i]->clientdata;
+			} else {
+				type = swig_module.type_initial[i];
+			}
+
+			/* Insert casting types */
+			cast = swig_module.cast_initial[i];
+			while (cast->type) {
+				/* Don't need to add information already in the list */
+				ret = 0;
+				if (swig_module.next != &swig_module) {
+					ret = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, cast->type->name);
+				}
+				if (ret && type == swig_module.type_initial[i]) {
+					cast->type = ret;
+					ret = 0;
+				}
+
+				if (!ret) {
+					if (type->cast) {
+						type->cast->prev = cast;
+						cast->next = type->cast;
+					}
+					type->cast = cast;
+				}
+
+				cast++;
+			}
+
+			/* Set entry in modules->types array equal to the type */
+			swig_module.types[i] = type;
+		}
+		swig_module.types[i] = 0;
+	}
+
+	/* This function will propagate the clientdata field of type to
+	 * any new swig_type_info structures that have been added into the list
+	 * of equivalent types.  It is like calling
+	 * SWIG_TypeClientData(type, clientdata) a second time.
+	 */
+	SWIGRUNTIME void SWIG_PropagateClientData(void) {
+		size_t i;
+		swig_cast_info *equiv;
+		static int init_run = 0;
+
+		if (init_run)
+			return;
+		init_run = 1;
+
+		for (i = 0; i < swig_module.size; i++) {
+			if (swig_module.types[i]->clientdata) {
+				equiv = swig_module.types[i]->cast;
+				while (equiv) {
+					if (!equiv->converter) {
+						if (equiv->type && !equiv->type->clientdata)
+							SWIG_TypeClientData(equiv->type, swig_module.types[i]->clientdata);
+					}
+					equiv = equiv->next;
+				}
+			}
+		}
+	}
+
 #ifdef __cplusplus
 }
 #endif
@@ -2629,251 +2680,242 @@ extern "C" {
 #ifdef __cplusplus
 extern "C" {
 #endif
-    
-    /* Python-specific SWIG API */
+
+	/* Python-specific SWIG API */
 #define SWIG_newvarlink()                             SWIG_Python_newvarlink()
 #define SWIG_addvarlink(p, name, get_attr, set_attr)  SWIG_Python_addvarlink(p, name, get_attr, set_attr)
 #define SWIG_InstallConstants(d, constants)           SWIG_Python_InstallConstants(d, constants)
-    
-    /* -----------------------------------------------------------------------------
-     * global variable support code.
-     * ----------------------------------------------------------------------------- */
-    
-    typedef struct swig_globalvar {
-        char       *name;                  /* Name of global variable */
-        PyObject *(*get_attr)(void);       /* Return the current value */
-        int       (*set_attr)(PyObject *); /* Set the value */
-        struct swig_globalvar *next;
-    } swig_globalvar;
-    
-    typedef struct swig_varlinkobject {
-        PyObject_HEAD
-        swig_globalvar *vars;
-    } swig_varlinkobject;
-    
-    SWIGINTERN PyObject *
-    swig_varlink_repr(swig_varlinkobject *v) {
-        v = v;
-        return PyString_FromString("");
-    }
-    
-    SWIGINTERN int
-    swig_varlink_print(swig_varlinkobject *v, FILE *fp, int flags) {
-        swig_globalvar  *var;
-        flags = flags;
-        fprintf(fp,"Swig global variables { ");
-        for (var = v->vars; var; var=var->next) {
-            fprintf(fp,"%s", var->name);
-            if (var->next) fprintf(fp,", ");
-        }
-        fprintf(fp," }\n");
-        return 0;
-    }
-    
-    SWIGINTERN PyObject *
-    swig_varlink_getattr(swig_varlinkobject *v, char *n) {
-        swig_globalvar *var = v->vars;
-        while (var) {
-            if (strcmp(var->name,n) == 0) {
-                return (*var->get_attr)();
-            }
-            var = var->next;
-        }
-        PyErr_SetString(PyExc_NameError,"Unknown C global variable");
-        return NULL;
-    }
-    
-    SWIGINTERN int
-    swig_varlink_setattr(swig_varlinkobject *v, char *n, PyObject *p) {
-        swig_globalvar *var = v->vars;
-        while (var) {
-            if (strcmp(var->name,n) == 0) {
-                return (*var->set_attr)(p);
-            }
-            var = var->next;
-        }
-        PyErr_SetString(PyExc_NameError,"Unknown C global variable");
-        return 1;
-    }
-    
-    SWIGINTERN PyTypeObject*
-    swig_varlink_type(void) {
-        static char varlink__doc__[] = "Swig var link object";
-        static PyTypeObject varlink_type
+
+	/* -----------------------------------------------------------------------------
+	 * global variable support code.
+	 * ----------------------------------------------------------------------------- */
+
+	typedef struct swig_globalvar {
+		char *name;				/* Name of global variable */
+		PyObject *(*get_attr) (void);	/* Return the current value */
+		int (*set_attr) (PyObject *);	/* Set the value */
+		struct swig_globalvar *next;
+	} swig_globalvar;
+
+	typedef struct swig_varlinkobject {
+		PyObject_HEAD swig_globalvar *vars;
+	} swig_varlinkobject;
+
+	SWIGINTERN PyObject *swig_varlink_repr(swig_varlinkobject * v) {
+		v = v;
+		return PyString_FromString("");
+	}
+	SWIGINTERN int swig_varlink_print(swig_varlinkobject * v, FILE * fp, int flags) {
+		swig_globalvar *var;
+		flags = flags;
+		fprintf(fp, "Swig global variables { ");
+		for (var = v->vars; var; var = var->next) {
+			fprintf(fp, "%s", var->name);
+			if (var->next)
+				fprintf(fp, ", ");
+		}
+		fprintf(fp, " }\n");
+		return 0;
+	}
+
+	SWIGINTERN PyObject *swig_varlink_getattr(swig_varlinkobject * v, char *n) {
+		swig_globalvar *var = v->vars;
+		while (var) {
+			if (strcmp(var->name, n) == 0) {
+				return (*var->get_attr) ();
+			}
+			var = var->next;
+		}
+		PyErr_SetString(PyExc_NameError, "Unknown C global variable");
+		return NULL;
+	}
+
+	SWIGINTERN int swig_varlink_setattr(swig_varlinkobject * v, char *n, PyObject * p) {
+		swig_globalvar *var = v->vars;
+		while (var) {
+			if (strcmp(var->name, n) == 0) {
+				return (*var->set_attr) (p);
+			}
+			var = var->next;
+		}
+		PyErr_SetString(PyExc_NameError, "Unknown C global variable");
+		return 1;
+	}
+
+	SWIGINTERN PyTypeObject *swig_varlink_type(void) {
+		static char varlink__doc__[] = "Swig var link object";
+		static PyTypeObject varlink_type
 #if !defined(__cplusplus)
-        ;
-        static int type_init = 0;  
-        if (!type_init) {
-            PyTypeObject tmp
+		            ;
+		static int type_init = 0;
+		if (!type_init) {
+			PyTypeObject tmp
 #endif
-            = {
-                PyObject_HEAD_INIT(&PyType_Type)
-                0,                                  /* Number of items in variable part (ob_size) */
-                (char *)"swigvarlink",              /* Type name (tp_name) */
-                sizeof(swig_varlinkobject),         /* Basic size (tp_basicsize) */
-                0,                                  /* Itemsize (tp_itemsize) */
-                0,                                  /* Deallocator (tp_dealloc) */ 
-                (printfunc) swig_varlink_print,     /* Print (tp_print) */
-                (getattrfunc) swig_varlink_getattr, /* get attr (tp_getattr) */
-                (setattrfunc) swig_varlink_setattr, /* Set attr (tp_setattr) */
-                0,                                  /* tp_compare */
-                (reprfunc) swig_varlink_repr,       /* tp_repr */
-                0,                                  /* tp_as_number */
-                0,                                  /* tp_as_sequence */
-                0,                                  /* tp_as_mapping */
-                0,                                  /* tp_hash */
-                0,                                  /* tp_call */
-                0,                                  /* tp_str */
-                0,                                  /* tp_getattro */
-                0,                                  /* tp_setattro */
-                0,                                  /* tp_as_buffer */
-                0,                                  /* tp_flags */
-                varlink__doc__,                     /* tp_doc */
+				= {
+				PyObject_HEAD_INIT(&PyType_Type)
+					0,			/* Number of items in variable part (ob_size) */
+				(char *) "swigvarlink",	/* Type name (tp_name) */
+				sizeof(swig_varlinkobject),	/* Basic size (tp_basicsize) */
+				0,				/* Itemsize (tp_itemsize) */
+				0,				/* Deallocator (tp_dealloc) */
+				(printfunc) swig_varlink_print,	/* Print (tp_print) */
+				(getattrfunc) swig_varlink_getattr,	/* get attr (tp_getattr) */
+				(setattrfunc) swig_varlink_setattr,	/* Set attr (tp_setattr) */
+				0,				/* tp_compare */
+				(reprfunc) swig_varlink_repr,	/* tp_repr */
+				0,				/* tp_as_number */
+				0,				/* tp_as_sequence */
+				0,				/* tp_as_mapping */
+				0,				/* tp_hash */
+				0,				/* tp_call */
+				0,				/* tp_str */
+				0,				/* tp_getattro */
+				0,				/* tp_setattro */
+				0,				/* tp_as_buffer */
+				0,				/* tp_flags */
+				varlink__doc__,	/* tp_doc */
 #if PY_VERSION_HEX >= 0x02000000
-                0,                                  /* tp_traverse */
-                0,                                  /* tp_clear */
+				0,				/* tp_traverse */
+				0,				/* tp_clear */
 #endif
 #if PY_VERSION_HEX >= 0x02010000
-                0,                                  /* tp_richcompare */
-                0,                                  /* tp_weaklistoffset */
+				0,				/* tp_richcompare */
+				0,				/* tp_weaklistoffset */
 #endif
 #if PY_VERSION_HEX >= 0x02020000
-                0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* tp_iter -> tp_weaklist */
+				0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,	/* tp_iter -> tp_weaklist */
 #endif
 #if PY_VERSION_HEX >= 0x02030000
-                0,                                  /* tp_del */
+				0,				/* tp_del */
 #endif
 #ifdef COUNT_ALLOCS
-                0,0,0,0                             /* tp_alloc -> tp_next */
+				0, 0, 0, 0		/* tp_alloc -> tp_next */
 #endif
-            };
+			};
 #if !defined(__cplusplus)
-            varlink_type = tmp;
-            type_init = 1;
-        }
+			varlink_type = tmp;
+			type_init = 1;
+		}
 #endif
-        return &varlink_type;
-    }
-    
-    /* Create a variable linking object for use later */
-    SWIGINTERN PyObject *
-    SWIG_Python_newvarlink(void) {
-        swig_varlinkobject *result = PyObject_NEW(swig_varlinkobject, swig_varlink_type());
-        if (result) {
-            result->vars = 0;
-        }
-        return ((PyObject*) result);
-    }
-    
-    SWIGINTERN void 
-    SWIG_Python_addvarlink(PyObject *p, char *name, PyObject *(*get_attr)(void), int (*set_attr)(PyObject *p)) {
-        swig_varlinkobject *v = (swig_varlinkobject *) p;
-        swig_globalvar *gv = (swig_globalvar *) malloc(sizeof(swig_globalvar));
-        if (gv) {
-            size_t size = strlen(name)+1;
-            gv->name = (char *)malloc(size);
-            if (gv->name) {
-                strncpy(gv->name,name,size);
-                gv->get_attr = get_attr;
-                gv->set_attr = set_attr;
-                gv->next = v->vars;
-            }
-        }
-        v->vars = gv;
-    }
-    
-    /* -----------------------------------------------------------------------------
-     * constants/methods manipulation
-     * ----------------------------------------------------------------------------- */
-    
-    /* Install Constants */
-    SWIGINTERN void
-    SWIG_Python_InstallConstants(PyObject *d, swig_const_info constants[]) {
-        PyObject *obj = 0;
-        size_t i;
-        for (i = 0; constants[i].type; ++i) {
-            switch(constants[i].type) {
-                case SWIG_PY_INT:
-                obj = PyInt_FromLong(constants[i].lvalue);
-                break;
-                case SWIG_PY_FLOAT:
-                obj = PyFloat_FromDouble(constants[i].dvalue);
-                break;
-                case SWIG_PY_STRING:
-                if (constants[i].pvalue) {
-                    obj = PyString_FromString((char *) constants[i].pvalue);
-                } else {
-                    Py_INCREF(Py_None);
-                    obj = Py_None;
-                }
-                break;
-                case SWIG_PY_POINTER:
-                obj = SWIG_NewPointerObj(constants[i].pvalue, *(constants[i]).ptype,0);
-                break;
-                case SWIG_PY_BINARY:
-                obj = SWIG_NewPackedObj(constants[i].pvalue, constants[i].lvalue, *(constants[i].ptype));
-                break;
-                default:
-                obj = 0;
-                break;
-            }
-            if (obj) {
-                PyDict_SetItemString(d,constants[i].name,obj);
-                Py_DECREF(obj);
-            }
-        }
-    }
-    
-    /* -----------------------------------------------------------------------------*/
-    /* Fix SwigMethods to carry the callback ptrs when needed */
-    /* -----------------------------------------------------------------------------*/
-    
-    SWIGINTERN void
-    SWIG_Python_FixMethods(PyMethodDef *methods,
-    swig_const_info *const_table,
-    swig_type_info **types,
-    swig_type_info **types_initial) {
-        size_t i;
-        for (i = 0; methods[i].ml_name; ++i) {
-            char *c = methods[i].ml_doc;
-            if (c && (c = strstr(c, "swig_ptr: "))) {
-                int j;
-                swig_const_info *ci = 0;
-                char *name = c + 10;
-                for (j = 0; const_table[j].type; ++j) {
-                    if (strncmp(const_table[j].name, name, 
-                    strlen(const_table[j].name)) == 0) {
-                        ci = &(const_table[j]);
-                        break;
-                    }
-                }
-                if (ci) {
-                    size_t shift = (ci->ptype) - types;
-                    swig_type_info *ty = types_initial[shift];
-                    size_t ldoc = (c - methods[i].ml_doc);
-                    size_t lptr = strlen(ty->name)+2*sizeof(void*)+2;
-                    char *ndoc = (char*)malloc(ldoc + lptr + 10);
-                    if (ndoc) {
-                        char *buff = ndoc;
-                        void *ptr = (ci->type == SWIG_PY_POINTER) ? ci->pvalue : 0;
-                        if (ptr) {
-                            strncpy(buff, methods[i].ml_doc, ldoc);
-                            buff += ldoc;
-                            strncpy(buff, "swig_ptr: ", 10);
-                            buff += 10;
-                            SWIG_PackVoidPtr(buff, ptr, ty->name, lptr);
-                            methods[i].ml_doc = ndoc;
-                        }
-                    }
-                }
-            }
-        }
-    }
-    
-    /* -----------------------------------------------------------------------------*
-     *  Initialize type list
-     * -----------------------------------------------------------------------------*/
-    
+		return &varlink_type;
+	}
+
+	/* Create a variable linking object for use later */
+	SWIGINTERN PyObject *SWIG_Python_newvarlink(void) {
+		swig_varlinkobject *result = PyObject_NEW(swig_varlinkobject, swig_varlink_type());
+		if (result) {
+			result->vars = 0;
+		}
+		return ((PyObject *) result);
+	}
+
+	SWIGINTERN void
+		SWIG_Python_addvarlink(PyObject * p, char *name, PyObject * (*get_attr) (void),
+							   int (*set_attr) (PyObject * p)) {
+		swig_varlinkobject *v = (swig_varlinkobject *) p;
+		swig_globalvar *gv = (swig_globalvar *) malloc(sizeof(swig_globalvar));
+		if (gv) {
+			size_t size = strlen(name) + 1;
+			gv->name = (char *) malloc(size);
+			if (gv->name) {
+				strncpy(gv->name, name, size);
+				gv->get_attr = get_attr;
+				gv->set_attr = set_attr;
+				gv->next = v->vars;
+			}
+		}
+		v->vars = gv;
+	}
+
+	/* -----------------------------------------------------------------------------
+	 * constants/methods manipulation
+	 * ----------------------------------------------------------------------------- */
+
+	/* Install Constants */
+	SWIGINTERN void SWIG_Python_InstallConstants(PyObject * d, swig_const_info constants[]) {
+		PyObject *obj = 0;
+		size_t i;
+		for (i = 0; constants[i].type; ++i) {
+			switch (constants[i].type) {
+			case SWIG_PY_INT:
+				obj = PyInt_FromLong(constants[i].lvalue);
+				break;
+			case SWIG_PY_FLOAT:
+				obj = PyFloat_FromDouble(constants[i].dvalue);
+				break;
+			case SWIG_PY_STRING:
+				if (constants[i].pvalue) {
+					obj = PyString_FromString((char *) constants[i].pvalue);
+				} else {
+					Py_INCREF(Py_None);
+					obj = Py_None;
+				}
+				break;
+			case SWIG_PY_POINTER:
+				obj = SWIG_NewPointerObj(constants[i].pvalue, *(constants[i]).ptype, 0);
+				break;
+			case SWIG_PY_BINARY:
+				obj = SWIG_NewPackedObj(constants[i].pvalue, constants[i].lvalue, *(constants[i].ptype));
+				break;
+			default:
+				obj = 0;
+				break;
+			}
+			if (obj) {
+				PyDict_SetItemString(d, constants[i].name, obj);
+				Py_DECREF(obj);
+			}
+		}
+	}
+
+	/* ----------------------------------------------------------------------------- */
+	/* Fix SwigMethods to carry the callback ptrs when needed */
+	/* ----------------------------------------------------------------------------- */
+
+	SWIGINTERN void
+		SWIG_Python_FixMethods(PyMethodDef * methods,
+							   swig_const_info * const_table,
+							   swig_type_info ** types, swig_type_info ** types_initial) {
+		size_t i;
+		for (i = 0; methods[i].ml_name; ++i) {
+			char *c = methods[i].ml_doc;
+			if (c && (c = strstr(c, "swig_ptr: "))) {
+				int j;
+				swig_const_info *ci = 0;
+				char *name = c + 10;
+				for (j = 0; const_table[j].type; ++j) {
+					if (strncmp(const_table[j].name, name, strlen(const_table[j].name)) == 0) {
+						ci = &(const_table[j]);
+						break;
+					}
+				}
+				if (ci) {
+					size_t shift = (ci->ptype) - types;
+					swig_type_info *ty = types_initial[shift];
+					size_t ldoc = (c - methods[i].ml_doc);
+					size_t lptr = strlen(ty->name) + 2 * sizeof(void *) + 2;
+					char *ndoc = (char *) malloc(ldoc + lptr + 10);
+					if (ndoc) {
+						char *buff = ndoc;
+						void *ptr = (ci->type == SWIG_PY_POINTER) ? ci->pvalue : 0;
+						if (ptr) {
+							strncpy(buff, methods[i].ml_doc, ldoc);
+							buff += ldoc;
+							strncpy(buff, "swig_ptr: ", 10);
+							buff += 10;
+							SWIG_PackVoidPtr(buff, ptr, ty->name, lptr);
+							methods[i].ml_doc = ndoc;
+						}
+					}
+				}
+			}
+		}
+	}
+
+	/* -----------------------------------------------------------------------------*
+	 *  Initialize type list
+	 * -----------------------------------------------------------------------------*/
+
 #ifdef __cplusplus
 }
 #endif
@@ -2885,49 +2927,50 @@ extern "C" {
 #ifdef __cplusplus
 extern "C"
 #endif
-SWIGEXPORT void SWIG_init(void) {
-    static PyObject *SWIG_globals = 0; 
-    PyObject *m, *d;
-    if (!SWIG_globals) SWIG_globals = SWIG_newvarlink();
-    
-    /* Fix SwigMethods to carry the callback ptrs when needed */
-    SWIG_Python_FixMethods(SwigMethods, swig_const_table, swig_types, swig_type_initial);
-    
-    m = Py_InitModule((char *) SWIG_name, SwigMethods);
-    d = PyModule_GetDict(m);
-    
-    SWIG_InitializeModule(0);
-    SWIG_InstallConstants(d,swig_const_table);
-    
-    {
-        PyDict_SetItemString(d,"CS_NEW", SWIG_From_int((int)(CS_NEW))); 
-    }
-    {
-        PyDict_SetItemString(d,"CS_INIT", SWIG_From_int((int)(CS_INIT))); 
-    }
-    {
-        PyDict_SetItemString(d,"CS_RING", SWIG_From_int((int)(CS_RING))); 
-    }
-    {
-        PyDict_SetItemString(d,"CS_TRANSMIT", SWIG_From_int((int)(CS_TRANSMIT))); 
-    }
-    {
-        PyDict_SetItemString(d,"CS_EXECUTE", SWIG_From_int((int)(CS_EXECUTE))); 
-    }
-    {
-        PyDict_SetItemString(d,"CS_LOOPBACK", SWIG_From_int((int)(CS_LOOPBACK))); 
-    }
-    {
-        PyDict_SetItemString(d,"CS_HOLD", SWIG_From_int((int)(CS_HOLD))); 
-    }
-    {
-        PyDict_SetItemString(d,"CS_HIBERNATE", SWIG_From_int((int)(CS_HIBERNATE))); 
-    }
-    {
-        PyDict_SetItemString(d,"CS_HANGUP", SWIG_From_int((int)(CS_HANGUP))); 
-    }
-    {
-        PyDict_SetItemString(d,"CS_DONE", SWIG_From_int((int)(CS_DONE))); 
-    }
-}
+       SWIGEXPORT void SWIG_init(void)
+{
+	static PyObject *SWIG_globals = 0;
+	PyObject *m, *d;
+	if (!SWIG_globals)
+		SWIG_globals = SWIG_newvarlink();
 
+	/* Fix SwigMethods to carry the callback ptrs when needed */
+	SWIG_Python_FixMethods(SwigMethods, swig_const_table, swig_types, swig_type_initial);
+
+	m = Py_InitModule((char *) SWIG_name, SwigMethods);
+	d = PyModule_GetDict(m);
+
+	SWIG_InitializeModule(0);
+	SWIG_InstallConstants(d, swig_const_table);
+
+	{
+		PyDict_SetItemString(d, "CS_NEW", SWIG_From_int((int) (CS_NEW)));
+	}
+	{
+		PyDict_SetItemString(d, "CS_INIT", SWIG_From_int((int) (CS_INIT)));
+	}
+	{
+		PyDict_SetItemString(d, "CS_RING", SWIG_From_int((int) (CS_RING)));
+	}
+	{
+		PyDict_SetItemString(d, "CS_TRANSMIT", SWIG_From_int((int) (CS_TRANSMIT)));
+	}
+	{
+		PyDict_SetItemString(d, "CS_EXECUTE", SWIG_From_int((int) (CS_EXECUTE)));
+	}
+	{
+		PyDict_SetItemString(d, "CS_LOOPBACK", SWIG_From_int((int) (CS_LOOPBACK)));
+	}
+	{
+		PyDict_SetItemString(d, "CS_HOLD", SWIG_From_int((int) (CS_HOLD)));
+	}
+	{
+		PyDict_SetItemString(d, "CS_HIBERNATE", SWIG_From_int((int) (CS_HIBERNATE)));
+	}
+	{
+		PyDict_SetItemString(d, "CS_HANGUP", SWIG_From_int((int) (CS_HANGUP)));
+	}
+	{
+		PyDict_SetItemString(d, "CS_DONE", SWIG_From_int((int) (CS_DONE)));
+	}
+}
diff --git a/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c b/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
index fbb11aca9b..643d5ac87d 100644
--- a/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
+++ b/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
@@ -41,9 +41,9 @@
 static const char modname[] = "mod_spidermonkey";
 
 
-static void session_destroy(JSContext *cx, JSObject *obj);
-static JSBool session_construct(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
-static JSBool session_originate(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
+static void session_destroy(JSContext * cx, JSObject * obj);
+static JSBool session_construct(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval);
+static JSBool session_originate(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval);
 static switch_api_interface_t js_run_interface;
 
 static struct {
@@ -59,16 +59,16 @@ static struct {
 
 
 static JSClass global_class = {
-	"Global", JSCLASS_HAS_PRIVATE, 
-	JS_PropertyStub,  JS_PropertyStub,	JS_PropertyStub,  JS_PropertyStub, 
-	JS_EnumerateStub, JS_ResolveStub,	JS_ConvertStub,	  JS_FinalizeStub
+	"Global", JSCLASS_HAS_PRIVATE,
+	JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
+	JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub
 };
 
 
 static struct {
 	switch_hash_t *mod_hash;
 	switch_hash_t *load_hash;
-    switch_memory_pool_t *pool;
+	switch_memory_pool_t *pool;
 } module_manager;
 
 struct sm_loadable_module {
@@ -96,7 +96,7 @@ struct input_callback_state {
 	jsval ret;
 	JSContext *cx;
 	JSObject *obj;
-    jsrefcount saveDepth;
+	jsrefcount saveDepth;
 	void *extra;
 };
 
@@ -117,7 +117,7 @@ struct event_obj {
 
 /* Event Object */
 /*********************************************************************************/
-static JSBool event_construct(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
+static JSBool event_construct(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
 {
 	if (argc > 0) {
 		switch_event_t *event;
@@ -128,26 +128,26 @@ static JSBool event_construct(JSContext *cx, JSObject *obj, uintN argc, jsval *a
 		if ((eo = malloc(sizeof(*eo)))) {
 
 			if (switch_name_event(ename, &etype) != SWITCH_STATUS_SUCCESS) {
-				*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+				*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
 				return JS_TRUE;
 			}
 
 			if (etype == SWITCH_EVENT_CUSTOM) {
 				char *subclass_name;
 				if (argc < 1) {
-					*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+					*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
 					return JS_TRUE;
 				}
-				
+
 				subclass_name = JS_GetStringBytes(JS_ValueToString(cx, argv[1]));
 				if (switch_event_create_subclass(&event, etype, subclass_name) != SWITCH_STATUS_SUCCESS) {
-					*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+					*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
 					return JS_TRUE;
 				}
 
 			} else {
 				if (!switch_event_create(&event, etype) != SWITCH_STATUS_SUCCESS) {
-					*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+					*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
 					return JS_TRUE;
 				}
 			}
@@ -163,7 +163,7 @@ static JSBool event_construct(JSContext *cx, JSObject *obj, uintN argc, jsval *a
 	return JS_FALSE;
 }
 
-static void event_destroy(JSContext *cx, JSObject *obj)
+static void event_destroy(JSContext * cx, JSObject * obj)
 {
 	struct event_obj *eo = JS_GetPrivate(cx, obj);
 
@@ -175,12 +175,12 @@ static void event_destroy(JSContext *cx, JSObject *obj)
 	}
 }
 
-static JSBool event_add_header(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
+static JSBool event_add_header(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
 {
 	struct event_obj *eo = JS_GetPrivate(cx, obj);
 
 	if (!eo || eo->freed) {
-		*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+		*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
 		return JS_TRUE;
 	}
 
@@ -188,90 +188,90 @@ static JSBool event_add_header(JSContext *cx, JSObject *obj, uintN argc, jsval *
 		char *hname = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
 		char *hval = JS_GetStringBytes(JS_ValueToString(cx, argv[1]));
 		switch_event_add_header(eo->event, SWITCH_STACK_BOTTOM, hname, "%s", hval);
-		*rval = BOOLEAN_TO_JSVAL( JS_TRUE );
+		*rval = BOOLEAN_TO_JSVAL(JS_TRUE);
 		return JS_TRUE;
 	}
 
-	*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+	*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
 	return JS_TRUE;
 }
 
-static JSBool event_get_header(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
+static JSBool event_get_header(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
 {
 	struct event_obj *eo = JS_GetPrivate(cx, obj);
 
 	if (!eo) {
-		*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+		*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
 		return JS_TRUE;
 	}
 
 	if (argc > 0) {
 		char *hname = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
 		char *val = switch_event_get_header(eo->event, hname);
-		*rval = STRING_TO_JSVAL (JS_NewStringCopyZ(cx, val));
+		*rval = STRING_TO_JSVAL(JS_NewStringCopyZ(cx, val));
 		return JS_TRUE;
 	}
 
-	*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+	*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
 	return JS_TRUE;
 }
 
-static JSBool event_add_body(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
+static JSBool event_add_body(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
 {
 	struct event_obj *eo = JS_GetPrivate(cx, obj);
 
 	if (!eo || eo->freed) {
-		*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+		*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
 		return JS_TRUE;
 	}
 
 	if (argc > 0) {
 		char *body = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
 		switch_event_add_body(eo->event, "%s", body);
-		*rval = BOOLEAN_TO_JSVAL( JS_TRUE );
+		*rval = BOOLEAN_TO_JSVAL(JS_TRUE);
 		return JS_TRUE;
 	}
 
-	*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+	*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
 	return JS_TRUE;
 }
 
-static JSBool event_get_body(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
+static JSBool event_get_body(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
 {
 	struct event_obj *eo = JS_GetPrivate(cx, obj);
 
 	if (!eo) {
-		*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+		*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
 		return JS_TRUE;
 	}
 
-	*rval = STRING_TO_JSVAL (JS_NewStringCopyZ(cx, switch_event_get_body(eo->event)));
+	*rval = STRING_TO_JSVAL(JS_NewStringCopyZ(cx, switch_event_get_body(eo->event)));
 
 	return JS_TRUE;
 }
 
-static JSBool event_get_type(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
+static JSBool event_get_type(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
 {
 	struct event_obj *eo = JS_GetPrivate(cx, obj);
 
 	if (!eo) {
-		*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+		*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
 		return JS_TRUE;
 	}
 
-	*rval = STRING_TO_JSVAL (JS_NewStringCopyZ(cx, switch_event_name(eo->event->event_id)));
-	
+	*rval = STRING_TO_JSVAL(JS_NewStringCopyZ(cx, switch_event_name(eo->event->event_id)));
+
 	return JS_TRUE;
 }
 
-static JSBool event_serialize(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
+static JSBool event_serialize(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
 {
 	struct event_obj *eo = JS_GetPrivate(cx, obj);
 	char *buf;
 	uint8_t isxml = 0;
 
 	if (!eo) {
-		*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+		*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
 		return JS_TRUE;
 	}
 
@@ -285,17 +285,17 @@ static JSBool event_serialize(JSContext *cx, JSObject *obj, uintN argc, jsval *a
 	if (isxml) {
 		switch_xml_t xml;
 		char *xmlstr;
-		if ((xml = switch_event_xmlize(eo->event, ""))) {
-            xmlstr = switch_xml_toxml(xml);
-			*rval = STRING_TO_JSVAL (JS_NewStringCopyZ(cx, xmlstr));
+		if ((xml = switch_event_xmlize(eo->event, SWITCH_VA_NONE))) {
+			xmlstr = switch_xml_toxml(xml);
+			*rval = STRING_TO_JSVAL(JS_NewStringCopyZ(cx, xmlstr));
 			switch_xml_free(xml);
-            free(xmlstr);
+			free(xmlstr);
 		} else {
-			*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+			*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
 		}
 	} else {
 		if (switch_event_serialize(eo->event, &buf) == SWITCH_STATUS_SUCCESS) {
-			*rval = STRING_TO_JSVAL (JS_NewStringCopyZ(cx, buf));
+			*rval = STRING_TO_JSVAL(JS_NewStringCopyZ(cx, buf));
 			switch_safe_free(buf);
 		}
 	}
@@ -303,7 +303,7 @@ static JSBool event_serialize(JSContext *cx, JSObject *obj, uintN argc, jsval *a
 	return JS_TRUE;
 }
 
-static JSBool event_fire(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
+static JSBool event_fire(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
 {
 	struct event_obj *eo = JS_GetPrivate(cx, obj);
 
@@ -311,29 +311,29 @@ static JSBool event_fire(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
 		switch_event_fire(&eo->event);
 		JS_SetPrivate(cx, obj, NULL);
 		switch_safe_free(eo);
-		*rval = BOOLEAN_TO_JSVAL( JS_TRUE );
+		*rval = BOOLEAN_TO_JSVAL(JS_TRUE);
 		return JS_TRUE;
 	}
 
-	*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+	*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
 	return JS_TRUE;
 }
 
-static JSBool event_destroy_(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
+static JSBool event_destroy_(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
 {
 	struct event_obj *eo = JS_GetPrivate(cx, obj);
-	
+
 	if (eo) {
 		if (!eo->freed) {
 			switch_event_destroy(&eo->event);
 		}
 		JS_SetPrivate(cx, obj, NULL);
 		switch_safe_free(eo);
-		*rval = BOOLEAN_TO_JSVAL( JS_TRUE );
+		*rval = BOOLEAN_TO_JSVAL(JS_TRUE);
 		return JS_TRUE;
 	}
 
-	*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+	*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
 	return JS_TRUE;
 }
 
@@ -357,35 +357,35 @@ static JSFunctionSpec event_methods[] = {
 
 
 static JSPropertySpec event_props[] = {
-	{"ready", EVENT_READY, JSPROP_READONLY|JSPROP_PERMANENT}, 
+	{"ready", EVENT_READY, JSPROP_READONLY | JSPROP_PERMANENT},
 	{0}
 };
 
 
-static JSBool event_getProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
+static JSBool event_getProperty(JSContext * cx, JSObject * obj, jsval id, jsval * vp)
 {
 	JSBool res = JS_TRUE;
 	switch_event_t *event = JS_GetPrivate(cx, obj);
 	char *name;
 	int param = 0;
 
-    if (!event) {
-        *vp = BOOLEAN_TO_JSVAL( JS_FALSE );
+	if (!event) {
+		*vp = BOOLEAN_TO_JSVAL(JS_FALSE);
 		return JS_TRUE;
-    }
+	}
+
 
-	
 	name = JS_GetStringBytes(JS_ValueToString(cx, id));
-    /* numbers are our props anything else is a method */
-    if (name[0] >= 48 && name[0] <= 57) {
-        param = atoi(name);
-    } else {
-        return JS_TRUE;
-    }
-	
-	switch(param) {
+	/* numbers are our props anything else is a method */
+	if (name[0] >= 48 && name[0] <= 57) {
+		param = atoi(name);
+	} else {
+		return JS_TRUE;
+	}
+
+	switch (param) {
 	case EVENT_READY:
-		*vp = BOOLEAN_TO_JSVAL( JS_TRUE );
+		*vp = BOOLEAN_TO_JSVAL(JS_TRUE);
 		break;
 	}
 
@@ -393,46 +393,38 @@ static JSBool event_getProperty(JSContext *cx, JSObject *obj, jsval id, jsval *v
 }
 
 JSClass event_class = {
-	"Event", JSCLASS_HAS_PRIVATE, 
-	JS_PropertyStub,  JS_PropertyStub,	event_getProperty,  JS_PropertyStub, 
-	JS_EnumerateStub, JS_ResolveStub,	JS_ConvertStub,	  event_destroy, NULL, NULL, NULL,
+	"Event", JSCLASS_HAS_PRIVATE,
+	JS_PropertyStub, JS_PropertyStub, event_getProperty, JS_PropertyStub,
+	JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, event_destroy, NULL, NULL, NULL,
 	event_construct
 };
 
 
 
 
-static void js_error(JSContext *cx, const char *message, JSErrorReport *report)
+static void js_error(JSContext * cx, const char *message, JSErrorReport * report)
 {
-    const char *filename = __FILE__;
-    int line = __LINE__;
-    const char *text = "";
-    char *ex = "";
-    
+	const char *filename = __FILE__;
+	int line = __LINE__;
+	const char *text = "";
+	char *ex = "";
+
 	if (message && report) {
-        if (report->filename) {
-            filename = report->filename;
-        }
-        line = report->lineno;
-        if (report->linebuf) {
-            text = report->linebuf;
-            ex = "near ";
-        }
+		if (report->filename) {
+			filename = report->filename;
+		}
+		line = report->lineno;
+		if (report->linebuf) {
+			text = report->linebuf;
+			ex = "near ";
+		}
 	}
-    
-    if (!message) {
-        message = "(N/A)";
-    }
-    
-    switch_log_printf(SWITCH_CHANNEL_ID_LOG, 
-                      filename,
-                      modname,
-                      line,
-                      SWITCH_LOG_ERROR,
-                      "%s %s%s\n",
-                      ex,
-                      message,
-                      text);
+
+	if (!message) {
+		message = "(N/A)";
+	}
+
+	switch_log_printf(SWITCH_CHANNEL_ID_LOG, filename, modname, line, SWITCH_LOG_ERROR, "%s %s%s\n", ex, message, text);
 
 }
 
@@ -462,13 +454,13 @@ static switch_status_t sm_load_file(char *filename)
 		}
 
 		status = switch_dso_sym(&function_handle, dso, "spidermonkey_init");
-		spidermonkey_init = (spidermonkey_init_t)(intptr_t) function_handle;
-			
+		spidermonkey_init = (spidermonkey_init_t) (intptr_t) function_handle;
+
 		if (spidermonkey_init == NULL) {
 			err = "Cannot Load";
 			break;
 		}
-		
+
 		if (spidermonkey_init(&module_interface) != SWITCH_STATUS_SUCCESS) {
 			err = "Module load routine returned an error";
 			break;
@@ -490,17 +482,17 @@ static switch_status_t sm_load_file(char *filename)
 	module->filename = switch_core_permanent_strdup(filename);
 	module->spidermonkey_init = spidermonkey_init;
 	module->module_interface = module_interface;
-	
+
 	module->lib = dso;
 
 	switch_core_hash_insert(module_manager.mod_hash, (char *) module->filename, (void *) module);
-	
+
 	for (mp = module->module_interface; mp; mp = mp->next) {
-		switch_core_hash_insert(module_manager.load_hash, (char *)mp->name, (void *) mp);
+		switch_core_hash_insert(module_manager.load_hash, (char *) mp->name, (void *) mp);
 	}
-	
+
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Successfully Loaded [%s]\n", module->filename);
-	
+
 	return SWITCH_STATUS_SUCCESS;
 
 }
@@ -541,7 +533,7 @@ static switch_status_t sm_load_module(char *dir, char *fname)
 			snprintf(path, len, "%s%s%s%s", dir, SWITCH_PATH_SEPARATOR, file, ext);
 		}
 	}
-	
+
 	return sm_load_file(path);
 }
 
@@ -583,7 +575,7 @@ static switch_status_t load_modules(void)
 			}
 		}
 		switch_xml_free(xml);
-		
+
 	} else {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "open of %s failed\n", cf);
 	}
@@ -598,14 +590,14 @@ static switch_status_t init_js(void)
 	globals.gErrFile = NULL;
 	globals.gOutFile = NULL;
 	globals.gStackChunkSize = 8192;
-	globals.gStackBase = (jsuword)&globals.stackDummy;
+	globals.gStackBase = (jsuword) & globals.stackDummy;
 	globals.gErrFile = stderr;
 	globals.gOutFile = stdout;
 
 	if (!(globals.rt = JS_NewRuntime(64L * 1024L * 1024L))) {
 		return SWITCH_STATUS_FALSE;
 	}
-	
+
 	if (load_modules() != SWITCH_STATUS_SUCCESS) {
 		return SWITCH_STATUS_FALSE;
 	}
@@ -613,7 +605,7 @@ static switch_status_t init_js(void)
 	return SWITCH_STATUS_SUCCESS;
 }
 
-JSObject *new_js_event(switch_event_t *event, char *name, JSContext *cx, JSObject *obj)
+JSObject *new_js_event(switch_event_t *event, char *name, JSContext * cx, JSObject * obj)
 {
 	struct event_obj *eo;
 	JSObject *Event = NULL;
@@ -623,8 +615,7 @@ JSObject *new_js_event(switch_event_t *event, char *name, JSContext *cx, JSObjec
 		eo->freed = 1;
 		if ((Event = JS_DefineObject(cx, obj, name, &event_class, NULL, 0))) {
 			if ((JS_SetPrivate(cx, Event, eo) &&
-				 JS_DefineProperties(cx, Event, event_props) &&
-				 JS_DefineFunctions(cx, Event, event_methods))) {
+				 JS_DefineProperties(cx, Event, event_props) && JS_DefineFunctions(cx, Event, event_methods))) {
 			}
 		}
 	}
@@ -632,7 +623,8 @@ JSObject *new_js_event(switch_event_t *event, char *name, JSContext *cx, JSObjec
 }
 
 
-static switch_status_t js_common_callback(switch_core_session_t *session, void *input, switch_input_type_t itype, void *buf, unsigned int buflen)
+static switch_status_t js_common_callback(switch_core_session_t *session, void *input, switch_input_type_t itype,
+										  void *buf, unsigned int buflen)
 {
 	char *dtmf = NULL;
 	switch_event_t *event = NULL;
@@ -643,7 +635,8 @@ static switch_status_t js_common_callback(switch_core_session_t *session, void *
 	JSObject *Event = NULL;
 
 	if (!jss || !jss->session) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
+						  "You must call the session.originate method before calling this method!\n");
 		return SWITCH_STATUS_FALSE;
 	}
 
@@ -651,7 +644,7 @@ static switch_status_t js_common_callback(switch_core_session_t *session, void *
 	case SWITCH_INPUT_TYPE_EVENT:
 		if ((event = (switch_event_t *) input)) {
 			if ((Event = new_js_event(event, "_XX_EVENT_XX_", cb_state->cx, cb_state->obj))) {
-				argv[argc++] = STRING_TO_JSVAL (JS_NewStringCopyZ(cb_state->cx, "event"));
+				argv[argc++] = STRING_TO_JSVAL(JS_NewStringCopyZ(cb_state->cx, "event"));
 				argv[argc++] = OBJECT_TO_JSVAL(Event);
 			}
 		}
@@ -659,10 +652,10 @@ static switch_status_t js_common_callback(switch_core_session_t *session, void *
 			return SWITCH_STATUS_FALSE;
 		}
 		break;
-	case SWITCH_INPUT_TYPE_DTMF: 
+	case SWITCH_INPUT_TYPE_DTMF:
 		dtmf = (char *) input;
-		argv[argc++] = STRING_TO_JSVAL (JS_NewStringCopyZ(cb_state->cx, "dtmf"));
-		argv[argc++] = STRING_TO_JSVAL (JS_NewStringCopyZ(cb_state->cx, dtmf));
+		argv[argc++] = STRING_TO_JSVAL(JS_NewStringCopyZ(cb_state->cx, "dtmf"));
+		argv[argc++] = STRING_TO_JSVAL(JS_NewStringCopyZ(cb_state->cx, dtmf));
 		break;
 	}
 
@@ -670,14 +663,15 @@ static switch_status_t js_common_callback(switch_core_session_t *session, void *
 		argv[argc++] = cb_state->arg;
 	}
 
-    JS_ResumeRequest(cb_state->cx, cb_state->saveDepth);
+	JS_ResumeRequest(cb_state->cx, cb_state->saveDepth);
 	JS_CallFunction(cb_state->cx, cb_state->obj, cb_state->function, argc, argv, &cb_state->ret);
-    cb_state->saveDepth = JS_SuspendRequest(cb_state->cx);
+	cb_state->saveDepth = JS_SuspendRequest(cb_state->cx);
 
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status_t js_stream_input_callback(switch_core_session_t *session, void *input, switch_input_type_t itype, void *buf, unsigned int buflen)
+static switch_status_t js_stream_input_callback(switch_core_session_t *session, void *input, switch_input_type_t itype,
+												void *buf, unsigned int buflen)
 {
 	char *ret;
 	switch_status_t status;
@@ -693,7 +687,7 @@ static switch_status_t js_stream_input_callback(switch_core_session_t *session,
 	if ((ret = JS_GetStringBytes(JS_ValueToString(cb_state->cx, cb_state->ret)))) {
 		if (!strncasecmp(ret, "speed", 4)) {
 			char *p;
-			
+
 			if ((p = strchr(ret, ':'))) {
 				p++;
 				if (*p == '+' || *p == '-') {
@@ -708,7 +702,7 @@ static switch_status_t js_stream_input_callback(switch_core_session_t *session,
 				}
 				return SWITCH_STATUS_SUCCESS;
 			}
-			
+
 			return SWITCH_STATUS_FALSE;
 		} else if (!strcasecmp(ret, "pause")) {
 			if (switch_test_flag(fh, SWITCH_FILE_PAUSE)) {
@@ -738,7 +732,7 @@ static switch_status_t js_stream_input_callback(switch_core_session_t *session,
 					}
 					if (step > 0) {
 						samps = step * (codec->implementation->samples_per_second / 1000);
-						switch_core_file_seek(fh, &pos, samps, SEEK_CUR);		
+						switch_core_file_seek(fh, &pos, samps, SEEK_CUR);
 					} else {
 						samps = step * (codec->implementation->samples_per_second / 1000);
 						switch_core_file_seek(fh, &pos, fh->pos - samps, SEEK_SET);
@@ -753,8 +747,8 @@ static switch_status_t js_stream_input_callback(switch_core_session_t *session,
 		}
 
 		if (!strcmp(ret, "true") || !strcmp(ret, "undefined")) {
-            return SWITCH_STATUS_SUCCESS;
-        }
+			return SWITCH_STATUS_SUCCESS;
+		}
 
 		return SWITCH_STATUS_BREAK;
 
@@ -762,7 +756,8 @@ static switch_status_t js_stream_input_callback(switch_core_session_t *session,
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status_t js_record_input_callback(switch_core_session_t *session, void *input, switch_input_type_t itype, void *buf, unsigned int buflen)
+static switch_status_t js_record_input_callback(switch_core_session_t *session, void *input, switch_input_type_t itype,
+												void *buf, unsigned int buflen)
 {
 	char *ret;
 	switch_status_t status;
@@ -772,7 +767,7 @@ static switch_status_t js_record_input_callback(switch_core_session_t *session,
 	if ((status = js_common_callback(session, input, itype, buf, buflen)) != SWITCH_STATUS_SUCCESS) {
 		return status;
 	}
-	
+
 	if ((ret = JS_GetStringBytes(JS_ValueToString(cb_state->cx, cb_state->ret)))) {
 		if (!strcasecmp(ret, "pause")) {
 			if (switch_test_flag(fh, SWITCH_FILE_PAUSE)) {
@@ -789,8 +784,8 @@ static switch_status_t js_record_input_callback(switch_core_session_t *session,
 		}
 
 		if (!strcmp(ret, "true") || !strcmp(ret, "undefined")) {
-            return SWITCH_STATUS_SUCCESS;
-        }
+			return SWITCH_STATUS_SUCCESS;
+		}
 
 		return SWITCH_STATUS_BREAK;
 
@@ -799,7 +794,8 @@ static switch_status_t js_record_input_callback(switch_core_session_t *session,
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status_t js_collect_input_callback(switch_core_session_t *session, void *input, switch_input_type_t itype, void *buf, unsigned int buflen)
+static switch_status_t js_collect_input_callback(switch_core_session_t *session, void *input, switch_input_type_t itype,
+												 void *buf, unsigned int buflen)
 {
 	char *ret;
 	switch_status_t status;
@@ -818,7 +814,7 @@ static switch_status_t js_collect_input_callback(switch_core_session_t *session,
 	return SWITCH_STATUS_BREAK;
 }
 
-static JSBool session_flush_digits(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
+static JSBool session_flush_digits(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
 {
 	struct js_session *jss = JS_GetPrivate(cx, obj);
 	char buf[256];
@@ -826,47 +822,48 @@ static JSBool session_flush_digits(JSContext *cx, JSObject *obj, uintN argc, jsv
 	switch_channel_t *channel;
 
 	if (!jss || !jss->session) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
-		*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
+						  "You must call the session.originate method before calling this method!\n");
+		*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
 		return JS_TRUE;
 	}
 
 	channel = switch_core_session_get_channel(jss->session);
-    assert(channel != NULL);
+	assert(channel != NULL);
 
 	while ((has = switch_channel_has_dtmf(channel))) {
 		switch_channel_dequeue_dtmf(channel, buf, sizeof(buf));
 	}
 
-	*rval = BOOLEAN_TO_JSVAL( JS_TRUE );
-    return JS_TRUE;
+	*rval = BOOLEAN_TO_JSVAL(JS_TRUE);
+	return JS_TRUE;
 }
 
-static JSBool session_flush_events(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
+static JSBool session_flush_events(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
 {
 	struct js_session *jss = JS_GetPrivate(cx, obj);
 	switch_event_t *event;
-    switch_channel_t *channel;
+	switch_channel_t *channel;
 
 	if (!jss || !jss->session) {
-		*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+		*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
 		return JS_TRUE;
 	}
 
-    channel = switch_core_session_get_channel(jss->session);
-    assert(channel != NULL);
+	channel = switch_core_session_get_channel(jss->session);
+	assert(channel != NULL);
 
 
 	while (switch_core_session_dequeue_event(jss->session, &event) == SWITCH_STATUS_SUCCESS) {
 		switch_event_destroy(&event);
 	}
-	
-	*rval = BOOLEAN_TO_JSVAL( JS_TRUE );
-    return JS_TRUE;
-	
+
+	*rval = BOOLEAN_TO_JSVAL(JS_TRUE);
+	return JS_TRUE;
+
 }
 
-static JSBool session_recordfile(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
+static JSBool session_recordfile(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
 {
 	struct js_session *jss = JS_GetPrivate(cx, obj);
 	switch_channel_t *channel;
@@ -874,28 +871,29 @@ static JSBool session_recordfile(JSContext *cx, JSObject *obj, uintN argc, jsval
 	void *bp = NULL;
 	int len = 0;
 	switch_input_callback_function_t dtmf_func = NULL;
-	struct input_callback_state cb_state = {0};
-	switch_file_handle_t fh = {0};
+	struct input_callback_state cb_state = { 0 };
+	switch_file_handle_t fh = { 0 };
 	JSFunction *function;
-    int32 limit = 0;
-    switch_input_args_t args = {0};
+	int32 limit = 0;
+	switch_input_args_t args = { 0 };
 
 	if (!jss || !jss->session) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
-		*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
+						  "You must call the session.originate method before calling this method!\n");
+		*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
 		return JS_TRUE;
 	}
 
 	channel = switch_core_session_get_channel(jss->session);
 	assert(channel != NULL);
 
-    if (!switch_channel_ready(channel)) {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Session is not active!\n");
-        *rval = BOOLEAN_TO_JSVAL( JS_FALSE );
-        return JS_TRUE;
-    }
+	if (!switch_channel_ready(channel)) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Session is not active!\n");
+		*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
+		return JS_TRUE;
+	}
+
 
-	
 	if (argc > 0) {
 		file_name = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
 		if (switch_strlen_zero(file_name)) {
@@ -908,49 +906,49 @@ static JSBool session_recordfile(JSContext *cx, JSObject *obj, uintN argc, jsval
 			cb_state.session_state = jss;
 			cb_state.function = function;
 			cb_state.cx = cx;
-            cb_state.obj = obj;
+			cb_state.obj = obj;
 			if (argc > 2) {
-                cb_state.arg = argv[2];
-            }
+				cb_state.arg = argv[2];
+			}
 
 			dtmf_func = js_record_input_callback;
 			bp = &cb_state;
 			len = sizeof(cb_state);
 		}
 
-        if (argc > 3) {
-            JS_ValueToInt32(cx, argv[3], &limit);
-        }
+		if (argc > 3) {
+			JS_ValueToInt32(cx, argv[3], &limit);
+		}
 
-        if (argc > 4) {
-            int32 thresh;
-            JS_ValueToInt32(cx, argv[4], &thresh);
-            fh.thresh = thresh;
-        }
+		if (argc > 4) {
+			int32 thresh;
+			JS_ValueToInt32(cx, argv[4], &thresh);
+			fh.thresh = thresh;
+		}
 
-        if (argc > 5) {
-            int32 silence_hits;
-            JS_ValueToInt32(cx, argv[5], &silence_hits);
-            fh.silence_hits = silence_hits;
-        }
+		if (argc > 5) {
+			int32 silence_hits;
+			JS_ValueToInt32(cx, argv[5], &silence_hits);
+			fh.silence_hits = silence_hits;
+		}
 	}
 
-    
+
 	cb_state.extra = &fh;
-	cb_state.ret = BOOLEAN_TO_JSVAL( JS_FALSE );
-    cb_state.saveDepth = JS_SuspendRequest(cx);
-    args.input_callback = dtmf_func;
-    args.buf = bp;
-    args.buflen = len;
+	cb_state.ret = BOOLEAN_TO_JSVAL(JS_FALSE);
+	cb_state.saveDepth = JS_SuspendRequest(cx);
+	args.input_callback = dtmf_func;
+	args.buf = bp;
+	args.buflen = len;
 	switch_ivr_record_file(jss->session, &fh, file_name, &args, limit);
-    JS_ResumeRequest(cx, cb_state.saveDepth);
+	JS_ResumeRequest(cx, cb_state.saveDepth);
 	*rval = cb_state.ret;
 
 	return JS_TRUE;
 }
 
 
-static JSBool session_collect_input(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
+static JSBool session_collect_input(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
 {
 	struct js_session *jss = JS_GetPrivate(cx, obj);
 	switch_channel_t *channel;
@@ -958,39 +956,40 @@ static JSBool session_collect_input(JSContext *cx, JSObject *obj, uintN argc, js
 	int len = 0;
 	int32 to = 0;
 	switch_input_callback_function_t dtmf_func = NULL;
-	struct input_callback_state cb_state = {0};
+	struct input_callback_state cb_state = { 0 };
 	JSFunction *function;
-    switch_input_args_t args = {0};
+	switch_input_args_t args = { 0 };
 
 
 	if (!jss || !jss->session) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
-		*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
+						  "You must call the session.originate method before calling this method!\n");
+		*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
 		return JS_TRUE;
 	}
 
 	channel = switch_core_session_get_channel(jss->session);
 	assert(channel != NULL);
 
-    if (!switch_channel_ready(channel)) {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Session is not active!\n");
-        *rval = BOOLEAN_TO_JSVAL( JS_FALSE );
-        return JS_TRUE;
-    }
+	if (!switch_channel_ready(channel)) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Session is not active!\n");
+		*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
+		return JS_TRUE;
+	}
+
 
-	
 	if (argc > 0) {
 		if ((function = JS_ValueToFunction(cx, argv[0]))) {
 			memset(&cb_state, 0, sizeof(cb_state));
 			cb_state.function = function;
 
 			if (argc > 1) {
-                cb_state.arg = argv[1];
-            }
-			
+				cb_state.arg = argv[1];
+			}
+
 			cb_state.session_state = jss;
 			cb_state.cx = cx;
-            cb_state.obj = obj;
+			cb_state.obj = obj;
 			dtmf_func = js_collect_input_callback;
 			bp = &cb_state;
 			len = sizeof(cb_state);
@@ -1001,12 +1000,12 @@ static JSBool session_collect_input(JSContext *cx, JSObject *obj, uintN argc, js
 		JS_ValueToInt32(jss->cx, argv[2], &to);
 	}
 
-    cb_state.saveDepth = JS_SuspendRequest(cx);
-    args.input_callback = dtmf_func;
-    args.buf = bp;
-    args.buflen = len;
+	cb_state.saveDepth = JS_SuspendRequest(cx);
+	args.input_callback = dtmf_func;
+	args.buf = bp;
+	args.buflen = len;
 	switch_ivr_collect_digits_callback(jss->session, &args, to);
-    JS_ResumeRequest(cx, cb_state.saveDepth);
+	JS_ResumeRequest(cx, cb_state.saveDepth);
 
 	*rval = cb_state.ret;
 
@@ -1015,37 +1014,38 @@ static JSBool session_collect_input(JSContext *cx, JSObject *obj, uintN argc, js
 
 /* session.sayphrase(phrase_name, phrase_data, language, dtmf_callback, dtmf_callback_args)*/
 
-static JSBool session_sayphrase(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
+static JSBool session_sayphrase(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
 {
 	struct js_session *jss = JS_GetPrivate(cx, obj);
 	switch_channel_t *channel;
 	char *phrase_name = NULL;
-    char *phrase_data = NULL;
-    char *phrase_lang = NULL;
+	char *phrase_data = NULL;
+	char *phrase_lang = NULL;
 	//char *input_callback = NULL;
 	void *bp = NULL;
 	int len = 0;
 	switch_input_callback_function_t dtmf_func = NULL;
-	struct input_callback_state cb_state = {0};
+	struct input_callback_state cb_state = { 0 };
 	JSFunction *function;
-    switch_input_args_t args = {0};
+	switch_input_args_t args = { 0 };
 
 	if (!jss || !jss->session) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
-		*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
+						  "You must call the session.originate method before calling this method!\n");
+		*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
 		return JS_TRUE;
 	}
 
 	channel = switch_core_session_get_channel(jss->session);
 	assert(channel != NULL);
 
-    if (!switch_channel_ready(channel)) {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Session is not active!\n");
-        *rval = BOOLEAN_TO_JSVAL( JS_FALSE );
-        return JS_TRUE;
-    }
+	if (!switch_channel_ready(channel)) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Session is not active!\n");
+		*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
+		return JS_TRUE;
+	}
+
 
-	
 	if (argc > 0) {
 		phrase_name = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
 		if (switch_strlen_zero(phrase_name)) {
@@ -1056,13 +1056,13 @@ static JSBool session_sayphrase(JSContext *cx, JSObject *obj, uintN argc, jsval
 	}
 
 
-    if (argc > 1) {
-        phrase_data = JS_GetStringBytes(JS_ValueToString(cx, argv[1]));
-    }
+	if (argc > 1) {
+		phrase_data = JS_GetStringBytes(JS_ValueToString(cx, argv[1]));
+	}
 
-    if (argc > 2) {
-        phrase_lang = JS_GetStringBytes(JS_ValueToString(cx, argv[2]));
-    }
+	if (argc > 2) {
+		phrase_lang = JS_GetStringBytes(JS_ValueToString(cx, argv[2]));
+	}
 
 	if (argc > 3) {
 		if ((function = JS_ValueToFunction(cx, argv[3]))) {
@@ -1082,27 +1082,27 @@ static JSBool session_sayphrase(JSContext *cx, JSObject *obj, uintN argc, jsval
 		}
 	}
 
-	cb_state.ret = BOOLEAN_TO_JSVAL( JS_FALSE );
-    cb_state.saveDepth = JS_SuspendRequest(cx);
-    args.input_callback = dtmf_func;
-    args.buf = bp;
-    args.buflen = len;
+	cb_state.ret = BOOLEAN_TO_JSVAL(JS_FALSE);
+	cb_state.saveDepth = JS_SuspendRequest(cx);
+	args.input_callback = dtmf_func;
+	args.buf = bp;
+	args.buflen = len;
 
-    switch_ivr_phrase_macro(jss->session, phrase_name, phrase_data, phrase_lang, &args);
+	switch_ivr_phrase_macro(jss->session, phrase_name, phrase_data, phrase_lang, &args);
 
-    JS_ResumeRequest(cx, cb_state.saveDepth);
+	JS_ResumeRequest(cx, cb_state.saveDepth);
 	*rval = cb_state.ret;
-	
+
 	return JS_TRUE;
 }
 
 static void check_hangup_hook(struct js_session *jss)
 {
-	jsval argv[2] = {0};
+	jsval argv[2] = { 0 };
 	int argc = 0;
 	jsval ret;
-	if (jss->on_hangup ) {
-		argv[argc++] = OBJECT_TO_JSVAL(jss->obj);			
+	if (jss->on_hangup) {
+		argv[argc++] = OBJECT_TO_JSVAL(jss->obj);
 		JS_CallFunction(jss->cx, jss->obj, jss->on_hangup, argc, argv, &ret);
 	}
 }
@@ -1114,7 +1114,8 @@ static switch_status_t hanguphook(switch_core_session_t *session)
 
 	channel = switch_core_session_get_channel(session);
 	assert(channel != NULL);
-	if (switch_channel_get_state(channel) == CS_HANGUP) {
+
+	if (switch_channel_get_state(channel) != CS_EXECUTE) {
 		if ((jss = switch_channel_get_private(channel, "jss"))) {
 			check_hangup_hook(jss);
 		}
@@ -1123,11 +1124,11 @@ static switch_status_t hanguphook(switch_core_session_t *session)
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static JSBool session_hanguphook(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
+static JSBool session_hanguphook(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
 {
 	JSFunction *function;
 	struct js_session *jss;
-	*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+	*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
 
 	if ((jss = JS_GetPrivate(cx, obj)) && jss->session) {
 		if (argc > 0) {
@@ -1136,8 +1137,8 @@ static JSBool session_hanguphook(JSContext *cx, JSObject *obj, uintN argc, jsval
 				assert(channel != NULL);
 				jss->on_hangup = function;
 				switch_channel_set_private(channel, "jss", jss);
-				switch_core_session_add_event_hook_state_change(jss->session, hanguphook);
-				*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+				switch_core_event_hook_add_state_change(jss->session, hanguphook);
+				*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
 			}
 		}
 	}
@@ -1145,7 +1146,7 @@ static JSBool session_hanguphook(JSContext *cx, JSObject *obj, uintN argc, jsval
 	return JS_TRUE;
 }
 
-static JSBool session_streamfile(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
+static JSBool session_streamfile(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
 {
 	struct js_session *jss = JS_GetPrivate(cx, obj);
 	switch_channel_t *channel;
@@ -1154,27 +1155,28 @@ static JSBool session_streamfile(JSContext *cx, JSObject *obj, uintN argc, jsval
 	void *bp = NULL;
 	int len = 0;
 	switch_input_callback_function_t dtmf_func = NULL;
-	struct input_callback_state cb_state = {0};
-	switch_file_handle_t fh = {0};
+	struct input_callback_state cb_state = { 0 };
+	switch_file_handle_t fh = { 0 };
 	JSFunction *function;
-    switch_input_args_t args = {0};
+	switch_input_args_t args = { 0 };
 
 	if (!jss || !jss->session) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
-		*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
+						  "You must call the session.originate method before calling this method!\n");
+		*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
 		return JS_TRUE;
 	}
 
 	channel = switch_core_session_get_channel(jss->session);
 	assert(channel != NULL);
 
-    if (!switch_channel_ready(channel)) {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Session is not active!\n");
-        *rval = BOOLEAN_TO_JSVAL( JS_FALSE );
-        return JS_TRUE;
-    }
+	if (!switch_channel_ready(channel)) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Session is not active!\n");
+		*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
+		return JS_TRUE;
+	}
+
 
-	
 	if (argc > 0) {
 		file_name = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
 		if (switch_strlen_zero(file_name)) {
@@ -1200,38 +1202,39 @@ static JSBool session_streamfile(JSContext *cx, JSObject *obj, uintN argc, jsval
 		}
 	}
 
-    if (argc > 3) {
-        int32 samps;
-        JS_ValueToInt32(cx, argv[3], &samps);
-        fh.samples = samps;
-    }
+	if (argc > 3) {
+		int32 samps;
+		JS_ValueToInt32(cx, argv[3], &samps);
+		fh.samples = samps;
+	}
 
 	cb_state.extra = &fh;
-	cb_state.ret = BOOLEAN_TO_JSVAL( JS_FALSE );
-    cb_state.saveDepth = JS_SuspendRequest(cx);
-    args.input_callback = dtmf_func;
-    args.buf = bp;
-    args.buflen = len;
+	cb_state.ret = BOOLEAN_TO_JSVAL(JS_FALSE);
+	cb_state.saveDepth = JS_SuspendRequest(cx);
+	args.input_callback = dtmf_func;
+	args.buf = bp;
+	args.buflen = len;
 	switch_ivr_play_file(jss->session, &fh, file_name, &args);
-    JS_ResumeRequest(cx, cb_state.saveDepth);
+	JS_ResumeRequest(cx, cb_state.saveDepth);
 	*rval = cb_state.ret;
-	
+
 	return JS_TRUE;
 }
 
-static JSBool session_set_variable(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
+static JSBool session_set_variable(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
 {
 	struct js_session *jss = JS_GetPrivate(cx, obj);
-    switch_channel_t *channel;
+	switch_channel_t *channel;
 
 	if (!jss || !jss->session) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
-		*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
+						  "You must call the session.originate method before calling this method!\n");
+		*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
 		return JS_TRUE;
 	}
 
 	channel = switch_core_session_get_channel(jss->session);
-    assert(channel != NULL);
+	assert(channel != NULL);
 
 	if (argc > 1) {
 		char *var, *val;
@@ -1239,47 +1242,47 @@ static JSBool session_set_variable(JSContext *cx, JSObject *obj, uintN argc, jsv
 		var = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
 		val = JS_GetStringBytes(JS_ValueToString(cx, argv[1]));
 		switch_channel_set_variable(channel, var, val);
-		*rval = BOOLEAN_TO_JSVAL( JS_TRUE );
+		*rval = BOOLEAN_TO_JSVAL(JS_TRUE);
 	} else {
-		*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+		*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
 	}
- 	
+
 	return JS_TRUE;
 }
 
-static JSBool session_get_variable(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
+static JSBool session_get_variable(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
 {
 	struct js_session *jss = JS_GetPrivate(cx, obj);
-    switch_channel_t *channel;
+	switch_channel_t *channel;
 
 	if (!jss || !jss->session) {
-		*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+		*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
 		return JS_TRUE;
 	}
 
 	channel = switch_core_session_get_channel(jss->session);
-    assert(channel != NULL);
+	assert(channel != NULL);
 
 	if (argc > 0) {
 		char *var, *val;
-		
+
 		var = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
 		val = switch_channel_get_variable(channel, var);
 
 		if (val) {
-			*rval = STRING_TO_JSVAL (JS_NewStringCopyZ(cx, val));
+			*rval = STRING_TO_JSVAL(JS_NewStringCopyZ(cx, val));
 		} else {
-			*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+			*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
 		}
 	} else {
-		*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+		*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
 	}
- 	
+
 	return JS_TRUE;
 }
 
 
-static JSBool session_speak(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
+static JSBool session_speak(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
 {
 	struct js_session *jss = JS_GetPrivate(cx, obj);
 	switch_channel_t *channel;
@@ -1289,32 +1292,33 @@ static JSBool session_speak(JSContext *cx, JSObject *obj, uintN argc, jsval *arg
 	switch_codec_t *codec;
 	void *bp = NULL;
 	int len = 0;
-	struct input_callback_state cb_state = {0};
+	struct input_callback_state cb_state = { 0 };
 	switch_input_callback_function_t dtmf_func = NULL;
 	JSFunction *function;
-    switch_input_args_t args = {0};
+	switch_input_args_t args = { 0 };
 
 	if (!jss || !jss->session) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
-		*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
+						  "You must call the session.originate method before calling this method!\n");
+		*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
 		return JS_TRUE;
 	}
 
 	channel = switch_core_session_get_channel(jss->session);
 	assert(channel != NULL);
 
-    if (!switch_channel_ready(channel)) {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Session is not active!\n");
-        *rval = BOOLEAN_TO_JSVAL( JS_FALSE );
-        return JS_TRUE;
-    }
+	if (!switch_channel_ready(channel)) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Session is not active!\n");
+		*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
+		return JS_TRUE;
+	}
+
 
-	
 	if (argc > 0) {
 		tts_name = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
 	}
 	if (argc > 1) {
-		voice_name= JS_GetStringBytes(JS_ValueToString(cx, argv[1]));
+		voice_name = JS_GetStringBytes(JS_ValueToString(cx, argv[1]));
 	}
 	if (argc > 2) {
 		text = JS_GetStringBytes(JS_ValueToString(cx, argv[2]));
@@ -1324,11 +1328,11 @@ static JSBool session_speak(JSContext *cx, JSObject *obj, uintN argc, jsval *arg
 			memset(&cb_state, 0, sizeof(cb_state));
 			cb_state.function = function;
 			if (argc > 4) {
-                cb_state.arg = argv[4];
-            }
+				cb_state.arg = argv[4];
+			}
 
 			cb_state.cx = cx;
-            cb_state.obj = obj;
+			cb_state.obj = obj;
 			cb_state.session_state = jss;
 			dtmf_func = js_collect_input_callback;
 			bp = &cb_state;
@@ -1341,56 +1345,56 @@ static JSBool session_speak(JSContext *cx, JSObject *obj, uintN argc, jsval *arg
 	}
 
 	codec = switch_core_session_get_read_codec(jss->session);
-	cb_state.ret = BOOLEAN_TO_JSVAL( JS_FALSE );
-    cb_state.saveDepth = JS_SuspendRequest(cx);
-    args.input_callback = dtmf_func;
-    args.buf = bp;
-    args.buflen = len;
+	cb_state.ret = BOOLEAN_TO_JSVAL(JS_FALSE);
+	cb_state.saveDepth = JS_SuspendRequest(cx);
+	args.input_callback = dtmf_func;
+	args.buf = bp;
+	args.buflen = len;
 	switch_ivr_speak_text(jss->session,
 						  tts_name,
-						  voice_name && strlen(voice_name) ? voice_name : NULL, 
-						  codec->implementation->samples_per_second,
-						  text,
-                          &args);
-    JS_ResumeRequest(cx, cb_state.saveDepth);
+						  voice_name && strlen(voice_name) ? voice_name : NULL,
+						  codec->implementation->samples_per_second, text, &args);
+	JS_ResumeRequest(cx, cb_state.saveDepth);
 	*rval = cb_state.ret;
 
 	return JS_TRUE;
 }
 
-static JSBool session_get_digits(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
+static JSBool session_get_digits(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
 {
 	struct js_session *jss = JS_GetPrivate(cx, obj);
 	char *terminators = NULL;
-	char buf[513] = {0};
+	char buf[513] = { 0 };
 	int32 digits = 0, timeout = 5000;
 	switch_channel_t *channel;
 
 	if (!jss || !jss->session) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
-		*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
+						  "You must call the session.originate method before calling this method!\n");
+		*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
 		return JS_TRUE;
 	}
 
 	channel = switch_core_session_get_channel(jss->session);
-    assert(channel != NULL);
+	assert(channel != NULL);
+
+	if (!switch_channel_ready(channel)) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Session is not active!\n");
+		*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
+		return JS_TRUE;
+	}
 
-    if (!switch_channel_ready(channel)) {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Session is not active!\n");
-        *rval = BOOLEAN_TO_JSVAL( JS_FALSE );
-        return JS_TRUE;
-    }
 
-	
 	if (argc > 0) {
 		char term;
 		JS_ValueToInt32(cx, argv[0], &digits);
 
 		if (digits > sizeof(buf) - 1) {
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Exceeded max digits of %"SWITCH_SIZE_T_FMT"\n",  sizeof(buf) - 1);
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Exceeded max digits of %" SWITCH_SIZE_T_FMT "\n",
+							  sizeof(buf) - 1);
 			return JS_FALSE;
 		}
-		
+
 		if (argc > 1) {
 			terminators = JS_GetStringBytes(JS_ValueToString(cx, argv[1]));
 		}
@@ -1400,24 +1404,25 @@ static JSBool session_get_digits(JSContext *cx, JSObject *obj, uintN argc, jsval
 
 
 		switch_ivr_collect_digits_count(jss->session, buf, sizeof(buf), digits, terminators, &term, timeout);
-		*rval = STRING_TO_JSVAL ( JS_NewStringCopyZ(cx, buf) );
+		*rval = STRING_TO_JSVAL(JS_NewStringCopyZ(cx, buf));
 		return JS_TRUE;
 	}
 
 	return JS_FALSE;
 }
 
-static JSBool session_autohangup(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
+static JSBool session_autohangup(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
 {
 	struct js_session *jss = JS_GetPrivate(cx, obj);
 	*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
 
 	if (!jss || !jss->session) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
-		*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
+						  "You must call the session.originate method before calling this method!\n");
+		*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
 		return JS_TRUE;
 	}
-	
+
 	if (argv[0]) {
 		JSBool tf;
 		JS_ValueToBoolean(cx, argv[0], &tf);
@@ -1432,25 +1437,26 @@ static JSBool session_autohangup(JSContext *cx, JSObject *obj, uintN argc, jsval
 	return JS_TRUE;
 }
 
-static JSBool session_answer(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
+static JSBool session_answer(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
 {
 	struct js_session *jss = JS_GetPrivate(cx, obj);
 	switch_channel_t *channel;
 
 	if (!jss || !jss->session) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
-		*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
+						  "You must call the session.originate method before calling this method!\n");
+		*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
 		return JS_TRUE;
 	}
 
 	channel = switch_core_session_get_channel(jss->session);
 	assert(channel != NULL);
 
-    if (!switch_channel_ready(channel)) {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Session is not active!\n");
-        *rval = BOOLEAN_TO_JSVAL( JS_FALSE );
-        return JS_TRUE;
-    }
+	if (!switch_channel_ready(channel)) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Session is not active!\n");
+		*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
+		return JS_TRUE;
+	}
 
 
 	switch_channel_answer(channel);
@@ -1458,23 +1464,24 @@ static JSBool session_answer(JSContext *cx, JSObject *obj, uintN argc, jsval *ar
 }
 
 
-static JSBool session_cdr(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
+static JSBool session_cdr(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
 {
 	struct js_session *jss = JS_GetPrivate(cx, obj);
 	switch_xml_t cdr;
 
-	/*Always a pessimist... sheesh!*/
-	*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+	/*Always a pessimist... sheesh! */
+	*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
 
 	if (!jss || !jss->session) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
+						  "You must call the session.originate method before calling this method!\n");
 		return JS_TRUE;
 	}
 
-    if (switch_ivr_generate_xml_cdr(jss->session, &cdr) == SWITCH_STATUS_SUCCESS) {
+	if (switch_ivr_generate_xml_cdr(jss->session, &cdr) == SWITCH_STATUS_SUCCESS) {
 		char *xml_text;
 		if ((xml_text = switch_xml_toxml(cdr))) {
-			*rval = STRING_TO_JSVAL (JS_NewStringCopyZ(cx, xml_text));
+			*rval = STRING_TO_JSVAL(JS_NewStringCopyZ(cx, xml_text));
 		}
 		switch_safe_free(xml_text);
 		switch_xml_free(cdr);
@@ -1483,28 +1490,29 @@ static JSBool session_cdr(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
 	return JS_TRUE;
 }
 
-static JSBool session_ready(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
+static JSBool session_ready(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
 {
 	struct js_session *jss = JS_GetPrivate(cx, obj);
 	switch_channel_t *channel;
 
 	if (!jss || !jss->session) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
-		*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
+						  "You must call the session.originate method before calling this method!\n");
+		*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
 		return JS_TRUE;
 	}
 
 	channel = switch_core_session_get_channel(jss->session);
 	assert(channel != NULL);
 
-	*rval = BOOLEAN_TO_JSVAL( switch_channel_ready(channel) ? JS_TRUE : JS_FALSE );
+	*rval = BOOLEAN_TO_JSVAL(switch_channel_ready(channel) ? JS_TRUE : JS_FALSE);
 
 	return JS_TRUE;
 }
 
 
 
-static JSBool session_wait_for_media(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
+static JSBool session_wait_for_media(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
 {
 	struct js_session *jss = JS_GetPrivate(cx, obj);
 	switch_channel_t *channel;
@@ -1513,8 +1521,9 @@ static JSBool session_wait_for_media(JSContext *cx, JSObject *obj, uintN argc, j
 	int32 timeout = 60;
 
 	if (!jss || !jss->session) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
-		*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
+						  "You must call the session.originate method before calling this method!\n");
+		*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
 		return JS_TRUE;
 	}
 
@@ -1527,25 +1536,27 @@ static JSBool session_wait_for_media(JSContext *cx, JSObject *obj, uintN argc, j
 		JS_ValueToInt32(cx, argv[0], &timeout);
 	}
 
-	for(;;) {
-		if (((elapsed = (unsigned int)((switch_time_now() - started) / 1000)) > (switch_time_t)timeout) || switch_channel_get_state(channel) >= CS_HANGUP) {
-			*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
-            break;
-		}
-
-		if (switch_channel_ready(channel) && (switch_channel_test_flag(channel, CF_ANSWERED) || switch_channel_test_flag(channel, CF_EARLY_MEDIA))) {
-			*rval = BOOLEAN_TO_JSVAL( JS_TRUE );
+	for (;;) {
+		if (((elapsed = (unsigned int) ((switch_time_now() - started) / 1000)) > (switch_time_t) timeout)
+			|| switch_channel_get_state(channel) >= CS_HANGUP) {
+			*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
 			break;
 		}
-		
+
+		if (switch_channel_ready(channel)
+			&& (switch_channel_test_flag(channel, CF_ANSWERED) || switch_channel_test_flag(channel, CF_EARLY_MEDIA))) {
+			*rval = BOOLEAN_TO_JSVAL(JS_TRUE);
+			break;
+		}
+
 		switch_yield(1000);
 	}
-	
+
 	return JS_TRUE;
 }
 
 
-static JSBool session_wait_for_answer(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
+static JSBool session_wait_for_answer(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
 {
 	struct js_session *jss = JS_GetPrivate(cx, obj);
 	switch_channel_t *channel;
@@ -1554,8 +1565,9 @@ static JSBool session_wait_for_answer(JSContext *cx, JSObject *obj, uintN argc,
 	int32 timeout = 60;
 
 	if (!jss || !jss->session) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
-		*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
+						  "You must call the session.originate method before calling this method!\n");
+		*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
 		return JS_TRUE;
 	}
 
@@ -1568,43 +1580,45 @@ static JSBool session_wait_for_answer(JSContext *cx, JSObject *obj, uintN argc,
 		JS_ValueToInt32(cx, argv[0], &timeout);
 	}
 
-	for(;;) {
-		if (((elapsed = (unsigned int)((switch_time_now() - started) / 1000)) > (switch_time_t)timeout) || switch_channel_get_state(channel) >= CS_HANGUP) {
-			*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
-            break;
+	for (;;) {
+		if (((elapsed = (unsigned int) ((switch_time_now() - started) / 1000)) > (switch_time_t) timeout)
+			|| switch_channel_get_state(channel) >= CS_HANGUP) {
+			*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
+			break;
 		}
 
 		if (switch_channel_ready(channel) && switch_channel_test_flag(channel, CF_ANSWERED)) {
-			*rval = BOOLEAN_TO_JSVAL( JS_TRUE );
+			*rval = BOOLEAN_TO_JSVAL(JS_TRUE);
 			break;
 		}
-		
+
 		switch_yield(1000);
 	}
-	
+
 	return JS_TRUE;
 }
 
-static JSBool session_execute(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
+static JSBool session_execute(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
 {
 	JSBool retval = JS_FALSE;
 	switch_channel_t *channel;
-    struct js_session *jss = JS_GetPrivate(cx, obj);
+	struct js_session *jss = JS_GetPrivate(cx, obj);
 
 	if (!jss || !jss->session) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
-		*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
+						  "You must call the session.originate method before calling this method!\n");
+		*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
 		return JS_TRUE;
 	}
 
 	channel = switch_core_session_get_channel(jss->session);
-    assert(channel != NULL);
+	assert(channel != NULL);
 
-    if (!switch_channel_ready(channel)) {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Session is not active!\n");
-        *rval = BOOLEAN_TO_JSVAL( JS_FALSE );
-        return JS_TRUE;
-    }
+	if (!switch_channel_ready(channel)) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Session is not active!\n");
+		*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
+		return JS_TRUE;
+	}
 
 
 	if (argc > 1) {
@@ -1615,8 +1629,9 @@ static JSBool session_execute(JSContext *cx, JSObject *obj, uintN argc, jsval *a
 		jsrefcount saveDepth;
 
 		if (!jss || !jss->session) {
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
-			*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
+							  "You must call the session.originate method before calling this method!\n");
+			*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
 			return JS_TRUE;
 		}
 
@@ -1627,57 +1642,58 @@ static JSBool session_execute(JSContext *cx, JSObject *obj, uintN argc, jsval *a
 				JS_ResumeRequest(cx, saveDepth);
 				retval = JS_TRUE;
 			}
-		} 
+		}
 	}
-	
-	*rval = BOOLEAN_TO_JSVAL( retval );
+
+	*rval = BOOLEAN_TO_JSVAL(retval);
 	return JS_TRUE;
 }
 
-static JSBool session_get_event(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
+static JSBool session_get_event(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
 {
 	struct js_session *jss = JS_GetPrivate(cx, obj);
 	switch_event_t *event;
 
 	if (!jss || !jss->session) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
-		*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
+						  "You must call the session.originate method before calling this method!\n");
+		*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
 		return JS_TRUE;
 	}
 
 	if (switch_core_session_dequeue_event(jss->session, &event) == SWITCH_STATUS_SUCCESS) {
 		JSObject *Event;
 		struct event_obj *eo;
-			
+
 		if ((eo = malloc(sizeof(*eo)))) {
 			eo->event = event;
 			eo->freed = 0;
 
 			if ((Event = JS_DefineObject(cx, obj, "__event__", &event_class, NULL, 0))) {
 				if ((JS_SetPrivate(cx, Event, eo) &&
-					 JS_DefineProperties(cx, Event, event_props) &&
-					 JS_DefineFunctions(cx, Event, event_methods))) {
-					*rval = OBJECT_TO_JSVAL ( Event );
+					 JS_DefineProperties(cx, Event, event_props) && JS_DefineFunctions(cx, Event, event_methods))) {
+					*rval = OBJECT_TO_JSVAL(Event);
 					return JS_TRUE;
 				}
 			}
 		}
 	}
-	
-	*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
-    return JS_TRUE;
-	
+
+	*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
+	return JS_TRUE;
+
 }
 
-static JSBool session_send_event(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
+static JSBool session_send_event(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
 {
 	struct js_session *jss = JS_GetPrivate(cx, obj);
 	JSObject *Event;
 	struct event_obj *eo;
 
 	if (!jss || !jss->session) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
-		*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
+						  "You must call the session.originate method before calling this method!\n");
+		*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
 		return JS_TRUE;
 	}
 
@@ -1685,7 +1701,7 @@ static JSBool session_send_event(JSContext *cx, JSObject *obj, uintN argc, jsval
 		if (JS_ValueToObject(cx, argv[0], &Event)) {
 			if ((eo = JS_GetPrivate(cx, Event))) {
 				if (switch_core_session_receive_event(jss->session, &eo->event) != SWITCH_STATUS_SUCCESS) {
-					*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+					*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
 					return JS_TRUE;
 				}
 
@@ -1694,13 +1710,13 @@ static JSBool session_send_event(JSContext *cx, JSObject *obj, uintN argc, jsval
 		}
 	}
 
-	*rval = BOOLEAN_TO_JSVAL( JS_TRUE );
-    return JS_TRUE;
-	
+	*rval = BOOLEAN_TO_JSVAL(JS_TRUE);
+	return JS_TRUE;
+
 }
 
 
-static JSBool session_hangup(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
+static JSBool session_hangup(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
 {
 	struct js_session *jss = JS_GetPrivate(cx, obj);
 	switch_channel_t *channel;
@@ -1708,19 +1724,20 @@ static JSBool session_hangup(JSContext *cx, JSObject *obj, uintN argc, jsval *ar
 	switch_call_cause_t cause = SWITCH_CAUSE_NORMAL_CLEARING;
 
 	if (!jss || !jss->session) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
-		*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
+						  "You must call the session.originate method before calling this method!\n");
+		*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
 		return JS_TRUE;
 	}
 
 	channel = switch_core_session_get_channel(jss->session);
 	assert(channel != NULL);
 
-    if (!switch_channel_ready(channel)) {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Session is not active!\n");
-        *rval = BOOLEAN_TO_JSVAL( JS_FALSE );
-        return JS_TRUE;
-    }
+	if (!switch_channel_ready(channel)) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Session is not active!\n");
+		*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
+		return JS_TRUE;
+	}
 
 	if (argc > 1) {
 		cause_name = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
@@ -1758,7 +1775,7 @@ static size_t hash_callback(void *ptr, size_t size, size_t nmemb, void *data)
 				*nextline = '\0';
 				nextline++;
 			}
-			
+
 			if ((val = strchr(line, '='))) {
 				*val = '\0';
 				val++;
@@ -1766,14 +1783,14 @@ static size_t hash_callback(void *ptr, size_t size, size_t nmemb, void *data)
 					*val = '\0';
 					val++;
 				}
-				
+
 				for (p = line; p && *p == ' '; p++);
 				line = p;
-				for (p=line+strlen(line)-1;*p == ' '; p--)
+				for (p = line + strlen(line) - 1; *p == ' '; p--)
 					*p = '\0';
 				for (p = val; p && *p == ' '; p++);
 				val = p;
-				for (p=val+strlen(val)-1;*p == ' '; p--)
+				for (p = val + strlen(val) - 1; *p == ' '; p--)
 					*p = '\0';
 
 				snprintf(code, sizeof(code), "~%s[\"%s\"] = \"%s\"", config_data->name, line, val);
@@ -1783,7 +1800,7 @@ static size_t hash_callback(void *ptr, size_t size, size_t nmemb, void *data)
 
 			line = nextline;
 		}
-	} 
+	}
 	return realsize;
 
 }
@@ -1792,7 +1809,7 @@ static size_t hash_callback(void *ptr, size_t size, size_t nmemb, void *data)
 
 static size_t file_callback(void *ptr, size_t size, size_t nmemb, void *data)
 {
-	register unsigned int realsize = (unsigned int)(size * nmemb);
+	register unsigned int realsize = (unsigned int) (size * nmemb);
 	struct config_data *config_data = data;
 
 	write(config_data->fd, ptr, realsize);
@@ -1800,13 +1817,13 @@ static size_t file_callback(void *ptr, size_t size, size_t nmemb, void *data)
 }
 
 
-static JSBool js_fetchurl_hash(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
+static JSBool js_fetchurl_hash(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
 {
 	char *url = NULL, *name = NULL;
 	CURL *curl_handle = NULL;
 	struct config_data config_data;
-	
-	if ( argc > 1 ) {
+
+	if (argc > 1) {
 		url = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
 		name = JS_GetStringBytes(JS_ValueToString(cx, argv[1]));
 
@@ -1823,7 +1840,7 @@ static JSBool js_fetchurl_hash(JSContext *cx, JSObject *obj, uintN argc, jsval *
 		}
 		curl_easy_setopt(curl_handle, CURLOPT_URL, url);
 		curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, hash_callback);
-		curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *)&config_data);
+		curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *) &config_data);
 		curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, "freeswitch-js/1.0");
 		curl_easy_perform(curl_handle);
 		curl_easy_cleanup(curl_handle);
@@ -1837,13 +1854,13 @@ static JSBool js_fetchurl_hash(JSContext *cx, JSObject *obj, uintN argc, jsval *
 
 
 
-static JSBool js_fetchurl_file(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
+static JSBool js_fetchurl_file(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
 {
 	char *url = NULL, *filename = NULL;
 	CURL *curl_handle = NULL;
 	struct config_data config_data;
-	
-	if ( argc > 1 ) {
+
+	if (argc > 1) {
 		url = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
 		filename = JS_GetStringBytes(JS_ValueToString(cx, argv[1]));
 
@@ -1860,7 +1877,7 @@ static JSBool js_fetchurl_file(JSContext *cx, JSObject *obj, uintN argc, jsval *
 		if ((config_data.fd = open(filename, O_CREAT | O_RDWR | O_TRUNC)) > -1) {
 			curl_easy_setopt(curl_handle, CURLOPT_URL, url);
 			curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, file_callback);
-			curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *)&config_data);
+			curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *) &config_data);
 			curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, "freeswitch-js/1.0");
 			curl_easy_perform(curl_handle);
 			curl_easy_cleanup(curl_handle);
@@ -1881,52 +1898,53 @@ static JSBool js_fetchurl_file(JSContext *cx, JSObject *obj, uintN argc, jsval *
 /*********************************************************************************/
 enum session_tinyid {
 	SESSION_NAME, SESSION_STATE,
-	PROFILE_DIALPLAN, PROFILE_CID_NAME, PROFILE_CID_NUM, PROFILE_IP, PROFILE_ANI, PROFILE_ANI_II, PROFILE_DEST, SESSION_UUID, SESSION_CAUSE
+	PROFILE_DIALPLAN, PROFILE_CID_NAME, PROFILE_CID_NUM, PROFILE_IP, PROFILE_ANI, PROFILE_ANI_II, PROFILE_DEST,
+	SESSION_UUID, SESSION_CAUSE
 };
 
 static JSFunctionSpec session_methods[] = {
-	{"originate", session_originate, 2}, 
-	{"setHangupHook", session_hanguphook, 1}, 
-	{"setAutoHangup", session_autohangup, 1}, 
-    {"sayPhrase", session_sayphrase, 1}, 
-    {"streamFile", session_streamfile, 1}, 
-	{"collectInput", session_collect_input, 1}, 
-	{"recordFile", session_recordfile, 1}, 
-	{"flushEvents", session_flush_events, 1}, 
-	{"flushDigits", session_flush_digits, 1}, 
-	{"speak", session_speak, 1}, 
-	{"setVariable", session_set_variable, 1}, 
-	{"getVariable", session_get_variable, 1}, 
+	{"originate", session_originate, 2},
+	{"setHangupHook", session_hanguphook, 1},
+	{"setAutoHangup", session_autohangup, 1},
+	{"sayPhrase", session_sayphrase, 1},
+	{"streamFile", session_streamfile, 1},
+	{"collectInput", session_collect_input, 1},
+	{"recordFile", session_recordfile, 1},
+	{"flushEvents", session_flush_events, 1},
+	{"flushDigits", session_flush_digits, 1},
+	{"speak", session_speak, 1},
+	{"setVariable", session_set_variable, 1},
+	{"getVariable", session_get_variable, 1},
 	{"getDigits", session_get_digits, 1},
-	{"answer", session_answer, 0}, 
-	{"generateXmlCdr", session_cdr, 0}, 
-	{"ready", session_ready, 0}, 
-	{"waitForAnswer", session_wait_for_answer, 0}, 
-	{"waitForMedia", session_wait_for_media, 0}, 
+	{"answer", session_answer, 0},
+	{"generateXmlCdr", session_cdr, 0},
+	{"ready", session_ready, 0},
+	{"waitForAnswer", session_wait_for_answer, 0},
+	{"waitForMedia", session_wait_for_media, 0},
 	{"getEvent", session_get_event, 0},
 	{"sendEvent", session_send_event, 0},
-	{"hangup", session_hangup, 0}, 
-	{"execute", session_execute, 0}, 
+	{"hangup", session_hangup, 0},
+	{"execute", session_execute, 0},
 	{0}
 };
 
 
 static JSPropertySpec session_props[] = {
-	{"name", SESSION_NAME, JSPROP_READONLY|JSPROP_PERMANENT}, 
-	{"state", SESSION_STATE, JSPROP_READONLY|JSPROP_PERMANENT}, 
-	{"dialplan", PROFILE_DIALPLAN, JSPROP_READONLY|JSPROP_PERMANENT},
-	{"caller_id_name", PROFILE_CID_NAME, JSPROP_READONLY|JSPROP_PERMANENT}, 
-	{"caller_id_num", PROFILE_CID_NUM, JSPROP_READONLY|JSPROP_PERMANENT}, 
-	{"network_addr", PROFILE_IP, JSPROP_READONLY|JSPROP_PERMANENT}, 
-	{"ani", PROFILE_ANI, JSPROP_READONLY|JSPROP_PERMANENT}, 
-	{"aniii", PROFILE_ANI_II, JSPROP_READONLY|JSPROP_PERMANENT}, 
-	{"destination", PROFILE_DEST, JSPROP_READONLY|JSPROP_PERMANENT}, 
-	{"uuid", SESSION_UUID, JSPROP_READONLY|JSPROP_PERMANENT}, 
-	{"cause", SESSION_CAUSE, JSPROP_READONLY|JSPROP_PERMANENT}, 
+	{"name", SESSION_NAME, JSPROP_READONLY | JSPROP_PERMANENT},
+	{"state", SESSION_STATE, JSPROP_READONLY | JSPROP_PERMANENT},
+	{"dialplan", PROFILE_DIALPLAN, JSPROP_READONLY | JSPROP_PERMANENT},
+	{"caller_id_name", PROFILE_CID_NAME, JSPROP_READONLY | JSPROP_PERMANENT},
+	{"caller_id_num", PROFILE_CID_NUM, JSPROP_READONLY | JSPROP_PERMANENT},
+	{"network_addr", PROFILE_IP, JSPROP_READONLY | JSPROP_PERMANENT},
+	{"ani", PROFILE_ANI, JSPROP_READONLY | JSPROP_PERMANENT},
+	{"aniii", PROFILE_ANI_II, JSPROP_READONLY | JSPROP_PERMANENT},
+	{"destination", PROFILE_DEST, JSPROP_READONLY | JSPROP_PERMANENT},
+	{"uuid", SESSION_UUID, JSPROP_READONLY | JSPROP_PERMANENT},
+	{"cause", SESSION_CAUSE, JSPROP_READONLY | JSPROP_PERMANENT},
 	{0}
 };
 
-static JSBool session_getProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
+static JSBool session_getProperty(JSContext * cx, JSObject * obj, jsval id, jsval * vp)
 {
 	struct js_session *jss = JS_GetPrivate(cx, obj);
 	int param = 0;
@@ -1950,9 +1968,9 @@ static JSBool session_getProperty(JSContext *cx, JSObject *obj, jsval id, jsval
 	}
 
 	if (!channel) {
-		switch(param) {
+		switch (param) {
 		case SESSION_CAUSE:
-			*vp = STRING_TO_JSVAL (JS_NewStringCopyZ(cx, switch_channel_cause2str(jss->cause)));
+			*vp = STRING_TO_JSVAL(JS_NewStringCopyZ(cx, switch_channel_cause2str(jss->cause)));
 			break;
 		default:
 			*vp = BOOLEAN_TO_JSVAL(JS_FALSE);
@@ -1960,9 +1978,9 @@ static JSBool session_getProperty(JSContext *cx, JSObject *obj, jsval id, jsval
 		return JS_TRUE;
 	}
 
-	switch(param) {
+	switch (param) {
 	case SESSION_CAUSE:
-		*vp = STRING_TO_JSVAL (JS_NewStringCopyZ(cx, switch_channel_cause2str(switch_channel_get_cause(channel))));
+		*vp = STRING_TO_JSVAL(JS_NewStringCopyZ(cx, switch_channel_cause2str(switch_channel_get_cause(channel))));
 		break;
 	case SESSION_NAME:
 		*vp = STRING_TO_JSVAL(JS_NewStringCopyZ(cx, switch_channel_get_name(channel)));
@@ -2011,21 +2029,22 @@ static JSBool session_getProperty(JSContext *cx, JSObject *obj, jsval id, jsval
 	default:
 		*vp = BOOLEAN_TO_JSVAL(JS_FALSE);
 		break;
-		
+
 	}
 
 	return JS_TRUE;
 }
 
 JSClass session_class = {
-	"Session", JSCLASS_HAS_PRIVATE, 
-	JS_PropertyStub,  JS_PropertyStub,	session_getProperty,  JS_PropertyStub, 
-	JS_EnumerateStub, JS_ResolveStub,	JS_ConvertStub,	  session_destroy, NULL, NULL, NULL,
+	"Session", JSCLASS_HAS_PRIVATE,
+	JS_PropertyStub, JS_PropertyStub, session_getProperty, JS_PropertyStub,
+	JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, session_destroy, NULL, NULL, NULL,
 	session_construct
 };
 
 
-static JSObject *new_js_session(JSContext *cx, JSObject *obj, switch_core_session_t *session, struct js_session *jss, char *name, int flags) 
+static JSObject *new_js_session(JSContext * cx, JSObject * obj, switch_core_session_t *session, struct js_session *jss,
+								char *name, int flags)
 {
 	JSObject *session_obj;
 	if ((session_obj = JS_DefineObject(cx, obj, name, &session_class, NULL, 0))) {
@@ -2040,14 +2059,14 @@ static JSObject *new_js_session(JSContext *cx, JSObject *obj, switch_core_sessio
 			return session_obj;
 		}
 	}
-	
+
 	return NULL;
 }
 
 /* Session Object */
 /*********************************************************************************/
 
-static JSBool session_construct(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
+static JSBool session_construct(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
 {
 	struct js_session *jss = NULL;
 
@@ -2062,7 +2081,7 @@ static JSBool session_construct(JSContext *cx, JSObject *obj, uintN argc, jsval
 	return JS_TRUE;
 }
 
-static JSBool session_originate(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
+static JSBool session_originate(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
 {
 	struct js_session *jss = NULL;
 	switch_memory_pool_t *pool = NULL;
@@ -2141,7 +2160,7 @@ static JSBool session_originate(JSContext *cx, JSObject *obj, uintN argc, jsval
 		if (argc > 11) {
 			to = JS_GetStringBytes(JS_ValueToString(cx, argv[11]));
 		}
-		
+
 		if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "OH OH no pool\n");
 			return JS_FALSE;
@@ -2152,15 +2171,11 @@ static JSBool session_originate(JSContext *cx, JSObject *obj, uintN argc, jsval
 												   dialplan,
 												   cid_name,
 												   cid_num,
-												   network_addr,
-												   ani,
-												   aniii,
-												   rdnis,
-												   (char *)modname,
-												   context,
-												   dest);
-		
-		if (switch_ivr_originate(session, &peer_session, &jss->cause, dest, to ? atoi(to) : 60, NULL, NULL, NULL, caller_profile) != SWITCH_STATUS_SUCCESS) {
+												   network_addr, ani, aniii, rdnis, (char *) modname, context, dest);
+
+		if (switch_ivr_originate
+			(session, &peer_session, &jss->cause, dest, to ? atoi(to) : 60, NULL, NULL, NULL,
+			 caller_profile) != SWITCH_STATUS_SUCCESS) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Cannot Create Outgoing Channel! [%s]\n", dest);
 			goto done;
 		}
@@ -2174,18 +2189,18 @@ static JSBool session_originate(JSContext *cx, JSObject *obj, uintN argc, jsval
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Missing Args\n");
 	}
 
- done:
+  done:
 	return JS_TRUE;
 }
 
 
 
 
-static void session_destroy(JSContext *cx, JSObject *obj)
+static void session_destroy(JSContext * cx, JSObject * obj)
 {
 	struct js_session *jss;
 	switch_channel_t *channel = NULL;
-	
+
 	if (cx && obj) {
 		if ((jss = JS_GetPrivate(cx, obj))) {
 			if (jss->session) {
@@ -2202,13 +2217,13 @@ static void session_destroy(JSContext *cx, JSObject *obj)
 			}
 		}
 	}
-		
+
 	return;
 }
 
 /* FileIO Object */
 /*********************************************************************************/
-static JSBool fileio_construct(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
+static JSBool fileio_construct(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
 {
 	switch_memory_pool_t *pool;
 	switch_file_t *fd;
@@ -2219,7 +2234,7 @@ static JSBool fileio_construct(JSContext *cx, JSObject *obj, uintN argc, jsval *
 	if (argc > 1) {
 		path = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
 		flags_str = JS_GetStringBytes(JS_ValueToString(cx, argv[1]));
-		
+
 		if (strchr(flags_str, 'r')) {
 			flags |= SWITCH_FOPEN_READ;
 		}
@@ -2239,10 +2254,10 @@ static JSBool fileio_construct(JSContext *cx, JSObject *obj, uintN argc, jsval *
 			flags |= SWITCH_FOPEN_BINARY;
 		}
 		switch_core_new_memory_pool(&pool);
-		if (switch_file_open(&fd, path, flags, SWITCH_FPROT_UREAD|SWITCH_FPROT_UWRITE, pool) != SWITCH_STATUS_SUCCESS) {
+		if (switch_file_open(&fd, path, flags, SWITCH_FPROT_UREAD | SWITCH_FPROT_UWRITE, pool) != SWITCH_STATUS_SUCCESS) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot Open File: %s\n", path);
 			switch_core_destroy_memory_pool(&pool);
-			*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+			*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
 			return JS_TRUE;
 		}
 		fio = switch_core_alloc(pool, sizeof(*fio));
@@ -2256,13 +2271,13 @@ static JSBool fileio_construct(JSContext *cx, JSObject *obj, uintN argc, jsval *
 
 	return JS_TRUE;
 }
-static void fileio_destroy(JSContext *cx, JSObject *obj)
+static void fileio_destroy(JSContext * cx, JSObject * obj)
 {
 	struct fileio_obj *fio = JS_GetPrivate(cx, obj);
 
 	if (fio) {
 		switch_memory_pool_t *pool;
-			if (fio->fd) {
+		if (fio->fd) {
 			switch_file_close(fio->fd);
 		}
 		pool = fio->pool;
@@ -2271,23 +2286,23 @@ static void fileio_destroy(JSContext *cx, JSObject *obj)
 	}
 }
 
-static JSBool fileio_read(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
+static JSBool fileio_read(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
 {
 	struct fileio_obj *fio = JS_GetPrivate(cx, obj);
 	int32 bytes = 0;
 	switch_size_t read = 0;
 
-	*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
-	
+	*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
+
 	if (!fio) {
-		*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+		*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
 		return JS_TRUE;
 	}
 
 	if (!(fio->flags & SWITCH_FOPEN_READ)) {
 		return JS_TRUE;
 	}
-	
+
 	if (argc > 0) {
 		JS_ValueToInt32(cx, argv[0], &bytes);
 	}
@@ -2300,51 +2315,52 @@ static JSBool fileio_read(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
 		read = bytes;
 		switch_file_read(fio->fd, fio->buf, &read);
 		fio->buflen = read;
-		*rval = BOOLEAN_TO_JSVAL( (read > 0) ? JS_TRUE : JS_FALSE );
-	} 
+		*rval = BOOLEAN_TO_JSVAL((read > 0) ? JS_TRUE : JS_FALSE);
+	}
 
 	return JS_TRUE;
 }
 
-static JSBool fileio_data(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
+static JSBool fileio_data(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
 {
 	struct fileio_obj *fio = JS_GetPrivate(cx, obj);
 
 	if (!fio) {
-		*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+		*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
 		return JS_TRUE;
 	}
 
-	*rval = STRING_TO_JSVAL (JS_NewStringCopyZ(cx, fio->buf));
+	*rval = STRING_TO_JSVAL(JS_NewStringCopyZ(cx, fio->buf));
 	return JS_TRUE;
 }
 
-static JSBool fileio_write(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
+static JSBool fileio_write(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
 {
 	struct fileio_obj *fio = JS_GetPrivate(cx, obj);
 	switch_size_t wrote = 0;
 	char *data = NULL;
 
 	if (!fio) {
-		*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+		*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
 		return JS_TRUE;
 	}
 
 	if (!(fio->flags & SWITCH_FOPEN_WRITE)) {
-		*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+		*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
 		return JS_TRUE;
 	}
-	
+
 	if (argc > 0) {
 		data = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
 	}
 
 	if (data) {
 		wrote = strlen(data);
-		*rval = BOOLEAN_TO_JSVAL( (switch_file_write(fio->fd, data, &wrote) == SWITCH_STATUS_SUCCESS) ? JS_TRUE : JS_FALSE);
+		*rval =
+			BOOLEAN_TO_JSVAL((switch_file_write(fio->fd, data, &wrote) == SWITCH_STATUS_SUCCESS) ? JS_TRUE : JS_FALSE);
 	}
 
-	*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+	*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
 	return JS_TRUE;
 }
 
@@ -2361,37 +2377,37 @@ static JSFunctionSpec fileio_methods[] = {
 
 
 static JSPropertySpec fileio_props[] = {
-	{"path", FILEIO_PATH, JSPROP_READONLY|JSPROP_PERMANENT}, 
-	{"open", FILEIO_OPEN, JSPROP_READONLY|JSPROP_PERMANENT}, 
+	{"path", FILEIO_PATH, JSPROP_READONLY | JSPROP_PERMANENT},
+	{"open", FILEIO_OPEN, JSPROP_READONLY | JSPROP_PERMANENT},
 	{0}
 };
 
 
-static JSBool fileio_getProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
+static JSBool fileio_getProperty(JSContext * cx, JSObject * obj, jsval id, jsval * vp)
 {
 	JSBool res = JS_TRUE;
 	struct fileio_obj *fio = JS_GetPrivate(cx, obj);
 	char *name;
 	int param = 0;
-	
+
 	name = JS_GetStringBytes(JS_ValueToString(cx, id));
-    /* numbers are our props anything else is a method */
-    if (name[0] >= 48 && name[0] <= 57) {
-        param = atoi(name);
-    } else {
-        return JS_TRUE;
-    }
-	
-	switch(param) {
+	/* numbers are our props anything else is a method */
+	if (name[0] >= 48 && name[0] <= 57) {
+		param = atoi(name);
+	} else {
+		return JS_TRUE;
+	}
+
+	switch (param) {
 	case FILEIO_PATH:
 		if (fio) {
 			*vp = STRING_TO_JSVAL(JS_NewStringCopyZ(cx, fio->path));
 		} else {
-			*vp = BOOLEAN_TO_JSVAL( JS_FALSE );
+			*vp = BOOLEAN_TO_JSVAL(JS_FALSE);
 		}
 		break;
 	case FILEIO_OPEN:
-		*vp = BOOLEAN_TO_JSVAL( fio ? JS_TRUE : JS_FALSE );
+		*vp = BOOLEAN_TO_JSVAL(fio ? JS_TRUE : JS_FALSE);
 		break;
 	}
 
@@ -2399,21 +2415,21 @@ static JSBool fileio_getProperty(JSContext *cx, JSObject *obj, jsval id, jsval *
 }
 
 JSClass fileio_class = {
-	"FileIO", JSCLASS_HAS_PRIVATE, 
-	JS_PropertyStub,  JS_PropertyStub,	fileio_getProperty,  JS_PropertyStub, 
-	JS_EnumerateStub, JS_ResolveStub,	JS_ConvertStub,	  fileio_destroy, NULL, NULL, NULL,
+	"FileIO", JSCLASS_HAS_PRIVATE,
+	JS_PropertyStub, JS_PropertyStub, fileio_getProperty, JS_PropertyStub,
+	JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, fileio_destroy, NULL, NULL, NULL,
 	fileio_construct
 };
 
 
 /* Built-In*/
 /*********************************************************************************/
-static JSBool js_exit(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
+static JSBool js_exit(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
 {
 	return JS_FALSE;
 }
 
-static JSBool js_log(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
+static JSBool js_log(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
 {
 	char *level_str, *msg;
 	switch_log_level_t level = SWITCH_LOG_DEBUG;
@@ -2421,14 +2437,14 @@ static JSBool js_log(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsva
 	const char *file = __FILE__;
 	int line = __LINE__;
 	JSStackFrame *caller;
-	
+
 	caller = JS_GetScriptedCaller(cx, NULL);
 	script = JS_GetFrameScript(cx, caller);
 
 	if (script) {
 		file = JS_GetScriptFilename(cx, script);
 		line = JS_GetScriptBaseLineNumber(cx, script);
-	}	
+	}
 
 
 	if (argc > 1) {
@@ -2439,7 +2455,7 @@ static JSBool js_log(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsva
 		if ((msg = JS_GetStringBytes(JS_ValueToString(cx, argv[1])))) {
 			switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, "console_log", line, level, "%s", msg);
 			return JS_TRUE;
-		} 
+		}
 	} else if (argc > 0) {
 		if ((msg = JS_GetStringBytes(JS_ValueToString(cx, argv[0])))) {
 			switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, "console_log", line, level, "%s", msg);
@@ -2450,10 +2466,10 @@ static JSBool js_log(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsva
 	return JS_FALSE;
 }
 
-static JSBool js_include(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
+static JSBool js_include(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
 {
 	char *code;
-	if ( argc > 0 && (code = JS_GetStringBytes(JS_ValueToString(cx, argv[0])))) {
+	if (argc > 0 && (code = JS_GetStringBytes(JS_ValueToString(cx, argv[0])))) {
 		if (eval_some_js(code, cx, obj, rval) < 0) {
 			return JS_FALSE;
 		}
@@ -2463,7 +2479,7 @@ static JSBool js_include(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
 	return JS_FALSE;
 }
 
-static JSBool js_api_use(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
+static JSBool js_api_use(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
 {
 	char *mod_name = NULL;
 
@@ -2481,17 +2497,17 @@ static JSBool js_api_use(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
 	}
 
 	return JS_TRUE;
-	
+
 }
 
-static JSBool js_api_execute(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
+static JSBool js_api_execute(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
 {
 
 	if (argc > 1) {
 		char *cmd = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
 		char *arg = JS_GetStringBytes(JS_ValueToString(cx, argv[1]));
 		switch_core_session_t *session = NULL;
-		switch_stream_handle_t stream = {0};
+		switch_stream_handle_t stream = { 0 };
 		char retbuf[2048] = "";
 
 		if (argc > 2) {
@@ -2503,30 +2519,30 @@ static JSBool js_api_execute(JSContext *cx, JSObject *obj, uintN argc, jsval *ar
 				}
 			}
 		}
-		
-		
+
+
 		stream.data = retbuf;
 		stream.end = stream.data;
 		stream.data_size = sizeof(retbuf);
 		stream.write_function = switch_console_stream_write;
 		switch_api_execute(cmd, arg, session, &stream);
 
-		*rval = STRING_TO_JSVAL (JS_NewStringCopyZ(cx, retbuf));
+		*rval = STRING_TO_JSVAL(JS_NewStringCopyZ(cx, retbuf));
 	} else {
-		*rval = STRING_TO_JSVAL (JS_NewStringCopyZ(cx, ""));
+		*rval = STRING_TO_JSVAL(JS_NewStringCopyZ(cx, ""));
 	}
 
 	return JS_TRUE;
 }
 
-static JSBool js_bridge(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
+static JSBool js_bridge(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
 {
 	struct js_session *jss_a = NULL, *jss_b = NULL;
 	JSObject *session_obj_a = NULL, *session_obj_b = NULL;
 	void *bp = NULL;
 	int len = 0;
 	switch_input_callback_function_t dtmf_func = NULL;
-	struct input_callback_state cb_state = {0};
+	struct input_callback_state cb_state = { 0 };
 	JSFunction *function;
 
 	if (argc > 1) {
@@ -2535,17 +2551,18 @@ static JSBool js_bridge(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, j
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot Find Session [1]\n");
 				return JS_FALSE;
 			}
-		} 
+		}
 		if (JS_ValueToObject(cx, argv[1], &session_obj_b)) {
 			if (!(jss_b = JS_GetPrivate(cx, session_obj_b))) {
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot Find Session [1]\n");
 				return JS_FALSE;
 			}
-		} 
+		}
 	}
-	
+
 	if (!(jss_a && jss_b)) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failure! %s %s\n", jss_a ? "y" : "n", jss_b ? "y" : "n");
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failure! %s %s\n", jss_a ? "y" : "n",
+						  jss_b ? "y" : "n");
 		return JS_FALSE;
 	}
 
@@ -2556,12 +2573,12 @@ static JSBool js_bridge(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, j
 			cb_state.function = function;
 
 			if (argc > 3) {
-                cb_state.arg = argv[3];
-            }
+				cb_state.arg = argv[3];
+			}
 
 			cb_state.cx = cx;
-            cb_state.obj = obj;
-			
+			cb_state.obj = obj;
+
 			cb_state.session_state = jss_a;
 			dtmf_func = js_collect_input_callback;
 			bp = &cb_state;
@@ -2569,37 +2586,37 @@ static JSBool js_bridge(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, j
 		}
 	}
 
-    cb_state.saveDepth = JS_SuspendRequest(cx);
+	cb_state.saveDepth = JS_SuspendRequest(cx);
 	switch_ivr_multi_threaded_bridge(jss_a->session, jss_b->session, dtmf_func, bp, bp);
-    JS_ResumeRequest(cx, cb_state.saveDepth);
+	JS_ResumeRequest(cx, cb_state.saveDepth);
 
 
 	return JS_TRUE;
 }
 
 /* Replace this with more robust version later */
-static JSBool js_system(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
+static JSBool js_system(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
 {
-    char *cmd;
-    *rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+	char *cmd;
+	*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
 
-    if (argc > 0 && (cmd = JS_GetStringBytes(JS_ValueToString(cx, argv[0])))) {
-        *rval = INT_TO_JSVAL( system(cmd) );
-        return JS_TRUE;
-    }
+	if (argc > 0 && (cmd = JS_GetStringBytes(JS_ValueToString(cx, argv[0])))) {
+		*rval = INT_TO_JSVAL(system(cmd));
+		return JS_TRUE;
+	}
 
-    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Arguements\n");
-    return JS_FALSE;
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Arguements\n");
+	return JS_FALSE;
 }
 
 
-static JSBool js_file_unlink(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
+static JSBool js_file_unlink(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
 {
 	const char *path;
-	*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
-	if ( argc > 0 && (path = (const char *)JS_GetStringBytes(JS_ValueToString(cx, argv[0])))) {
+	*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
+	if (argc > 0 && (path = (const char *) JS_GetStringBytes(JS_ValueToString(cx, argv[0])))) {
 		if ((switch_file_remove(path, NULL)) == SWITCH_STATUS_SUCCESS) {
-			*rval = BOOLEAN_TO_JSVAL( JS_TRUE );
+			*rval = BOOLEAN_TO_JSVAL(JS_TRUE);
 		}
 		return JS_TRUE;
 	}
@@ -2608,23 +2625,23 @@ static JSBool js_file_unlink(JSContext *cx, JSObject *obj, uintN argc, jsval *ar
 }
 
 static JSFunctionSpec fs_functions[] = {
-	{"console_log", js_log, 2}, 
-	{"exit", js_exit, 0}, 
-	{"include", js_include, 1}, 
+	{"console_log", js_log, 2},
+	{"exit", js_exit, 0},
+	{"include", js_include, 1},
 	{"bridge", js_bridge, 2},
 	{"apiExecute", js_api_execute, 2},
 	{"use", js_api_use, 1},
 	{"fileDelete", js_file_unlink, 1},
 	{"system", js_system, 1},
 #ifdef HAVE_CURL
-	{"fetchURLHash", js_fetchurl_hash, 1}, 
-	{"fetchURLFile", js_fetchurl_file, 1}, 
-#endif 
+	{"fetchURLHash", js_fetchurl_hash, 1},
+	{"fetchURLFile", js_fetchurl_file, 1},
+#endif
 	{0}
 };
 
 
-static int env_init(JSContext *cx, JSObject *javascript_object)
+static int env_init(JSContext * cx, JSObject * javascript_object)
 {
 
 	JS_DefineFunctions(cx, javascript_object, fs_functions);
@@ -2634,38 +2651,15 @@ static int env_init(JSContext *cx, JSObject *javascript_object)
 	JS_InitClass(cx,
 				 javascript_object,
 				 NULL,
-				 &session_class,
-				 session_construct,
-				 3,
-				 session_props,
-				 session_methods,
-				 session_props,
-				 session_methods
-				 );
+				 &session_class, session_construct, 3, session_props, session_methods, session_props, session_methods);
 
 	JS_InitClass(cx,
 				 javascript_object,
-				 NULL,
-				 &fileio_class,
-				 fileio_construct,
-				 3,
-				 fileio_props,
-				 fileio_methods,
-				 fileio_props,
-				 fileio_methods
-				 );
+				 NULL, &fileio_class, fileio_construct, 3, fileio_props, fileio_methods, fileio_props, fileio_methods);
 
 	JS_InitClass(cx,
 				 javascript_object,
-				 NULL,
-				 &event_class,
-				 event_construct,
-				 3,
-				 event_props,
-				 event_methods,
-				 event_props,
-				 event_methods
-				 );
+				 NULL, &event_class, event_construct, 3, event_props, event_methods, event_props, event_methods);
 
 	return 1;
 }
@@ -2680,7 +2674,7 @@ static void js_parse_and_execute(switch_core_session_t *session, char *input_cod
 	JSContext *cx = NULL;
 	jsval rval;
 
-	
+
 	if ((cx = JS_NewContext(globals.rt, globals.gStackChunkSize))) {
 		JS_BeginRequest(cx);
 		JS_SetErrorReporter(cx, js_error);
@@ -2703,8 +2697,8 @@ static void js_parse_and_execute(switch_core_session_t *session, char *input_cod
 		*arg++ = '\0';
 		argc = switch_separate_string(arg, ':', argv, (sizeof(argv) / sizeof(argv[0])));
 	}
-	
-	if (argc) { /* create a js doppleganger of this argc/argv*/
+
+	if (argc) {					/* create a js doppleganger of this argc/argv */
 		snprintf(buf, sizeof(buf), "~var argv = new Array(%d);", argc);
 		eval_some_js(buf, cx, javascript_global_object, &rval);
 		snprintf(buf, sizeof(buf), "~var argc = %d", argc);
@@ -2753,7 +2747,7 @@ static void js_thread_launch(char *text)
 			return;
 		}
 	}
-	
+
 	switch_threadattr_create(&thd_attr, module_pool);
 	switch_threadattr_detach_set(thd_attr, 1);
 	switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
@@ -2781,8 +2775,9 @@ static const switch_application_interface_t ivrtest_application_interface = {
 	/* long_desc */ "Run a javascript ivr on a channel",
 	/* short_desc */ "Launch JS ivr.",
 	/* syntax */ "