[Freeswitch-svn] [commit] r8686 - in freeswitch/trunk: build src src/include

Freeswitch SVN anthm at freeswitch.org
Tue May 27 00:30:04 EDT 2008


Author: anthm
Date: Tue May 27 00:30:03 2008
New Revision: 8686

Modified:
   freeswitch/trunk/build/indent_options.sh
   freeswitch/trunk/src/include/SimpleGlob.h
   freeswitch/trunk/src/include/g711.h
   freeswitch/trunk/src/include/switch_apr.h
   freeswitch/trunk/src/include/switch_bitpack.h
   freeswitch/trunk/src/include/switch_buffer.h
   freeswitch/trunk/src/include/switch_caller.h
   freeswitch/trunk/src/include/switch_channel.h
   freeswitch/trunk/src/include/switch_config.h
   freeswitch/trunk/src/include/switch_console.h
   freeswitch/trunk/src/include/switch_core.h
   freeswitch/trunk/src/include/switch_core_event_hook.h
   freeswitch/trunk/src/include/switch_cpp.h
   freeswitch/trunk/src/include/switch_event.h
   freeswitch/trunk/src/include/switch_frame.h
   freeswitch/trunk/src/include/switch_ivr.h
   freeswitch/trunk/src/include/switch_loadable_module.h
   freeswitch/trunk/src/include/switch_log.h
   freeswitch/trunk/src/include/switch_module_interfaces.h
   freeswitch/trunk/src/include/switch_odbc.h
   freeswitch/trunk/src/include/switch_platform.h
   freeswitch/trunk/src/include/switch_rtp.h
   freeswitch/trunk/src/include/switch_stun.h
   freeswitch/trunk/src/include/switch_types.h
   freeswitch/trunk/src/include/switch_utils.h
   freeswitch/trunk/src/include/switch_xml.h
   freeswitch/trunk/src/switch_apr.c
   freeswitch/trunk/src/switch_buffer.c
   freeswitch/trunk/src/switch_caller.c
   freeswitch/trunk/src/switch_channel.c
   freeswitch/trunk/src/switch_config.c
   freeswitch/trunk/src/switch_console.c
   freeswitch/trunk/src/switch_core.c
   freeswitch/trunk/src/switch_core_asr.c
   freeswitch/trunk/src/switch_core_codec.c
   freeswitch/trunk/src/switch_core_db.c
   freeswitch/trunk/src/switch_core_event_hook.c
   freeswitch/trunk/src/switch_core_file.c
   freeswitch/trunk/src/switch_core_hash.c
   freeswitch/trunk/src/switch_core_io.c
   freeswitch/trunk/src/switch_core_media_bug.c
   freeswitch/trunk/src/switch_core_memory.c
   freeswitch/trunk/src/switch_core_port_allocator.c
   freeswitch/trunk/src/switch_core_rwlock.c
   freeswitch/trunk/src/switch_core_session.c
   freeswitch/trunk/src/switch_core_speech.c
   freeswitch/trunk/src/switch_core_state_machine.c
   freeswitch/trunk/src/switch_core_timer.c
   freeswitch/trunk/src/switch_event.c
   freeswitch/trunk/src/switch_ivr.c
   freeswitch/trunk/src/switch_ivr_async.c
   freeswitch/trunk/src/switch_ivr_bridge.c
   freeswitch/trunk/src/switch_ivr_originate.c
   freeswitch/trunk/src/switch_ivr_play_say.c
   freeswitch/trunk/src/switch_loadable_module.c
   freeswitch/trunk/src/switch_log.c
   freeswitch/trunk/src/switch_odbc.c
   freeswitch/trunk/src/switch_pcm.c
   freeswitch/trunk/src/switch_regex.c
   freeswitch/trunk/src/switch_resample.c
   freeswitch/trunk/src/switch_rtp.c
   freeswitch/trunk/src/switch_scheduler.c
   freeswitch/trunk/src/switch_stun.c
   freeswitch/trunk/src/switch_swig.c
   freeswitch/trunk/src/switch_time.c
   freeswitch/trunk/src/switch_utils.c

Log:
indent pass 1

Modified: freeswitch/trunk/build/indent_options.sh
==============================================================================
--- freeswitch/trunk/build/indent_options.sh	(original)
+++ freeswitch/trunk/build/indent_options.sh	Tue May 27 00:30:03 2008
@@ -1,4 +1,5 @@
 #!/bin/bash
 echo -n "-brs -npsl -di0 -br -ce -d0 -cli0 -npcs -nfc1 -ut -i4 -ts4 -l155 -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 typedef `find ./src/include/ -name \*.h` | grep apr_ | grep -v "\*\|{"  | sed -e s/struct// | perl -ne '@l = split; $l[2] =~ s/;//g ; print "-T $l[2] "' >> ./.indent.pro
+grep typedef `find ./src/include/ -name \*.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

Modified: freeswitch/trunk/src/include/SimpleGlob.h
==============================================================================
--- freeswitch/trunk/src/include/SimpleGlob.h	(original)
+++ freeswitch/trunk/src/include/SimpleGlob.h	Tue May 27 00:30:03 2008
@@ -123,23 +123,23 @@
         Do not return the "." or ".." special directories.
  */
 enum SG_Flags {
-    SG_GLOB_ERR         = 1 << 0,
-    SG_GLOB_MARK        = 1 << 1,
-    SG_GLOB_NOSORT      = 1 << 2,
-    SG_GLOB_NOCHECK     = 1 << 3,
-    SG_GLOB_TILDE       = 1 << 4,
-    SG_GLOB_ONLYDIR     = 1 << 5,
-    SG_GLOB_ONLYFILE    = 1 << 6,
-    SG_GLOB_NODOT       = 1 << 7,
-    SG_GLOB_FULLSORT    = 1 << 8
+	SG_GLOB_ERR = 1 << 0,
+	SG_GLOB_MARK = 1 << 1,
+	SG_GLOB_NOSORT = 1 << 2,
+	SG_GLOB_NOCHECK = 1 << 3,
+	SG_GLOB_TILDE = 1 << 4,
+	SG_GLOB_ONLYDIR = 1 << 5,
+	SG_GLOB_ONLYFILE = 1 << 6,
+	SG_GLOB_NODOT = 1 << 7,
+	SG_GLOB_FULLSORT = 1 << 8
 };
 
 /*! @brief Error return codes */
 enum SG_Error {
-    SG_SUCCESS          =  0,
-    SG_ERR_NOMATCH      =  1,
-    SG_ERR_MEMORY       = -1,
-    SG_ERR_FAILURE      = -2
+	SG_SUCCESS = 0,
+	SG_ERR_NOMATCH = 1,
+	SG_ERR_MEMORY = -1,
+	SG_ERR_FAILURE = -2
 };
 
 // ----------------------------------------------------------------------------
@@ -196,61 +196,63 @@
 #endif
 
 /*! @brief String manipulation functions. */
-class SimpleGlobUtil
-{
-public:
-    static const char * strchr(const char *s, char c) {
-        return (char *) sg_strchr((const SOCHAR_T *)s, c);
-    }
-    static const wchar_t * strchr(const wchar_t *s, wchar_t c) {
-        return ::wcschr(s, c);
-    }
-
-    static const char * strrchr(const char *s, char c) {
-        return (char *) sg_strrchr((const SOCHAR_T *)s, c);
-    }
-    static const wchar_t * strrchr(const wchar_t *s, wchar_t c) {
-        return ::wcsrchr(s, c);
-    }
-
-    // Note: char strlen returns number of bytes, not characters
-    static size_t strlen(const char *s) { return ::strlen(s); }
-    static size_t strlen(const wchar_t *s) { return ::wcslen(s); }
-
-    static void strcpy_s(char *dst, size_t n, const char *src)  {
-        (void) n;
-        sg_strcpy_s((SOCHAR_T *)dst, n, (const SOCHAR_T *)src);
-    }
-    static void strcpy_s(wchar_t *dst, size_t n, const wchar_t *src) {
+class SimpleGlobUtil {
+  public:
+	static const char *strchr(const char *s, char c) {
+		return (char *) sg_strchr((const SOCHAR_T *) s, c);
+	} static const wchar_t *strchr(const wchar_t *s, wchar_t c) {
+		return::wcschr(s, c);
+	}
+
+	static const char *strrchr(const char *s, char c) {
+		return (char *) sg_strrchr((const SOCHAR_T *) s, c);
+	}
+	static const wchar_t *strrchr(const wchar_t *s, wchar_t c) {
+		return::wcsrchr(s, c);
+	}
+
+	// Note: char strlen returns number of bytes, not characters
+	static size_t strlen(const char *s) {
+		return::strlen(s);
+	}
+	static size_t strlen(const wchar_t *s) {
+		return::wcslen(s);
+	}
+
+	static void strcpy_s(char *dst, size_t n, const char *src) {
+		(void) n;
+		sg_strcpy_s((SOCHAR_T *) dst, n, (const SOCHAR_T *) src);
+	}
+	static void strcpy_s(wchar_t *dst, size_t n, const wchar_t *src) {
 # if __STDC_WANT_SECURE_LIB__
-        ::wcscpy_s(dst, n, src);
+		::wcscpy_s(dst, n, src);
 #else
-        (void) n;
-        ::wcscpy(dst, src);
+		(void) n;
+		::wcscpy(dst, src);
 #endif
-    }
+	}
 
-    static int strcmp(const char *s1, const char *s2) {
-        return sg_strcmp((const SOCHAR_T *)s1, (const SOCHAR_T *)s2);
-    }
-    static int strcmp(const wchar_t *s1, const wchar_t *s2) {
-        return ::wcscmp(s1, s2);
-    }
-
-    static int strcasecmp(const char *s1, const char *s2) {
-        return sg_strcasecmp((const SOCHAR_T *)s1, (const SOCHAR_T *)s2);
-    }
+	static int strcmp(const char *s1, const char *s2) {
+		return sg_strcmp((const SOCHAR_T *) s1, (const SOCHAR_T *) s2);
+	}
+	static int strcmp(const wchar_t *s1, const wchar_t *s2) {
+		return::wcscmp(s1, s2);
+	}
+
+	static int strcasecmp(const char *s1, const char *s2) {
+		return sg_strcasecmp((const SOCHAR_T *) s1, (const SOCHAR_T *) s2);
+	}
 #if _WIN32
-    static int strcasecmp(const wchar_t *s1, const wchar_t *s2) {
-        return ::_wcsicmp(s1, s2);
-    }
+	static int strcasecmp(const wchar_t *s1, const wchar_t *s2) {
+		return::_wcsicmp(s1, s2);
+	}
 #endif // _WIN32
 };
 
 enum SG_FileType {
-    SG_FILETYPE_INVALID,
-    SG_FILETYPE_FILE,
-    SG_FILETYPE_DIR
+	SG_FILETYPE_INVALID,
+	SG_FILETYPE_FILE,
+	SG_FILETYPE_DIR
 };
 
 #ifdef _WIN32
@@ -262,79 +264,70 @@
 #define SG_PATH_CHAR    '\\'
 
 /*! @brief Windows glob implementation. */
-template<class SOCHAR>
-struct SimpleGlobBase
-{
-    SimpleGlobBase() : m_hFind(INVALID_HANDLE_VALUE) { }
-
-    int FindFirstFileS(const char * a_pszFileSpec, unsigned int) {
-        m_hFind = FindFirstFileA(a_pszFileSpec, &m_oFindDataA);
-        if (m_hFind != INVALID_HANDLE_VALUE) {
-            return SG_SUCCESS;
-        }
-        DWORD dwErr = GetLastError();
-        if (dwErr == ERROR_FILE_NOT_FOUND) {
-            return SG_ERR_NOMATCH;
-        }
-        return SG_ERR_FAILURE;
-    }
-    int FindFirstFileS(const wchar_t * a_pszFileSpec, unsigned int) {
-        m_hFind = FindFirstFileW(a_pszFileSpec, &m_oFindDataW);
-        if (m_hFind != INVALID_HANDLE_VALUE) {
-            return SG_SUCCESS;
-        }
-        DWORD dwErr = GetLastError();
-        if (dwErr == ERROR_FILE_NOT_FOUND) {
-            return SG_ERR_NOMATCH;
-        }
-        return SG_ERR_FAILURE;
-    }
-
-    bool FindNextFileS(char) {
-        return FindNextFileA(m_hFind, &m_oFindDataA) != FALSE;
-    }
-    bool FindNextFileS(wchar_t) {
-        return FindNextFileW(m_hFind, &m_oFindDataW) != FALSE;
-    }
-
-    void FindDone() {
-        FindClose(m_hFind);
-    }
-
-    const char * GetFileNameS(char) const {
-        return m_oFindDataA.cFileName;
-    }
-    const wchar_t * GetFileNameS(wchar_t) const {
-        return m_oFindDataW.cFileName;
-    }
-
-    bool IsDirS(char) const {
-        return GetFileTypeS(m_oFindDataA.dwFileAttributes) == SG_FILETYPE_DIR;
-    }
-    bool IsDirS(wchar_t) const {
-        return GetFileTypeS(m_oFindDataW.dwFileAttributes) == SG_FILETYPE_DIR;
-    }
-
-    SG_FileType GetFileTypeS(const char * a_pszPath) {
-        return GetFileTypeS(GetFileAttributesA(a_pszPath));
-    }
-    SG_FileType GetFileTypeS(const wchar_t * a_pszPath)  {
-        return GetFileTypeS(GetFileAttributesW(a_pszPath));
-    }
-    SG_FileType GetFileTypeS(DWORD a_dwAttribs) const {
-        if (a_dwAttribs == INVALID_FILE_ATTRIBUTES) {
-            return SG_FILETYPE_INVALID;
-        }
-        if (a_dwAttribs & FILE_ATTRIBUTE_DIRECTORY) {
-            return SG_FILETYPE_DIR;
-        }
-        return SG_FILETYPE_FILE;
-    }
-
-private:
-    HANDLE              m_hFind;
-    WIN32_FIND_DATAA    m_oFindDataA;
-    WIN32_FIND_DATAW    m_oFindDataW;
+template < class SOCHAR > struct SimpleGlobBase {
+	SimpleGlobBase():m_hFind(INVALID_HANDLE_VALUE) {
+	} int FindFirstFileS(const char *a_pszFileSpec, unsigned int) {
+		m_hFind = FindFirstFileA(a_pszFileSpec, &m_oFindDataA);
+		if (m_hFind != INVALID_HANDLE_VALUE) {
+			return SG_SUCCESS;
+		}
+		DWORD dwErr = GetLastError();
+		if (dwErr == ERROR_FILE_NOT_FOUND) {
+			return SG_ERR_NOMATCH;
+		}
+		return SG_ERR_FAILURE;
+	}
+	int FindFirstFileS(const wchar_t *a_pszFileSpec, unsigned int) {
+		m_hFind = FindFirstFileW(a_pszFileSpec, &m_oFindDataW);
+		if (m_hFind != INVALID_HANDLE_VALUE) {
+			return SG_SUCCESS;
+		}
+		DWORD dwErr = GetLastError();
+		if (dwErr == ERROR_FILE_NOT_FOUND) {
+			return SG_ERR_NOMATCH;
+		}
+		return SG_ERR_FAILURE;
+	}
+
+	bool FindNextFileS(char) {
+		return FindNextFileA(m_hFind, &m_oFindDataA) != FALSE;
+	}
+	bool FindNextFileS(wchar_t) {
+		return FindNextFileW(m_hFind, &m_oFindDataW) != FALSE;
+	}
+
+	void FindDone() {
+		FindClose(m_hFind);
+	}
+
+	const char *GetFileNameS(char) const {
+		return m_oFindDataA.cFileName;
+	} const wchar_t *GetFileNameS(wchar_t) const {
+		return m_oFindDataW.cFileName;
+	} bool IsDirS(char) const {
+		return GetFileTypeS(m_oFindDataA.dwFileAttributes) == SG_FILETYPE_DIR;
+	} bool IsDirS(wchar_t) const {
+		return GetFileTypeS(m_oFindDataW.dwFileAttributes) == SG_FILETYPE_DIR;
+	} SG_FileType GetFileTypeS(const char *a_pszPath) {
+		return GetFileTypeS(GetFileAttributesA(a_pszPath));
+	}
+	SG_FileType GetFileTypeS(const wchar_t *a_pszPath) {
+		return GetFileTypeS(GetFileAttributesW(a_pszPath));
+	}
+	SG_FileType GetFileTypeS(DWORD a_dwAttribs) const {
+		if (a_dwAttribs == INVALID_FILE_ATTRIBUTES) {
+			return SG_FILETYPE_INVALID;
+		}
+		if    (a_dwAttribs & FILE_ATTRIBUTE_DIRECTORY) {
+			return SG_FILETYPE_DIR;
+		}
+		return SG_FILETYPE_FILE;
+	}
+
+  private:
+	HANDLE m_hFind;
+	WIN32_FIND_DATAA m_oFindDataA;
+	WIN32_FIND_DATAW m_oFindDataW;
 };
 
 #else // !_WIN32
@@ -342,85 +335,82 @@
 #define SG_PATH_CHAR    '/'
 
 /*! @brief Unix glob implementation. */
-template<class SOCHAR>
-struct SimpleGlobBase
-{
-    SimpleGlobBase() {
-        memset(&m_glob, 0, sizeof(m_glob));
-        m_uiCurr = (size_t)-1;
-    }
-
-    ~SimpleGlobBase() {
-        globfree(&m_glob);
-    }
-
-    void FilePrep() {
-        m_bIsDir = false;
-        size_t len = strlen(m_glob.gl_pathv[m_uiCurr]);
-        if (m_glob.gl_pathv[m_uiCurr][len-1] == '/') {
-            m_bIsDir = true;
-            m_glob.gl_pathv[m_uiCurr][len-1] = 0;
-        }
-    }
-
-    int FindFirstFileS(const char * a_pszFileSpec, unsigned int a_uiFlags) {
-        int nFlags = GLOB_MARK | GLOB_NOSORT;
-        if (a_uiFlags & SG_GLOB_ERR)    nFlags |= GLOB_ERR;
+template < class SOCHAR > struct SimpleGlobBase {
+	SimpleGlobBase() {
+		memset(&m_glob, 0, sizeof(m_glob));
+		m_uiCurr = (size_t) -1;
+	}             ~SimpleGlobBase() {
+		globfree(&m_glob);
+	}
+
+	void FilePrep() {
+		m_bIsDir = false;
+		size_t len = strlen(m_glob.gl_pathv[m_uiCurr]);
+		if (m_glob.gl_pathv[m_uiCurr][len - 1] == '/') {
+			m_bIsDir = true;
+			m_glob.gl_pathv[m_uiCurr][len - 1] = 0;
+		}
+	}
+
+	int FindFirstFileS(const char *a_pszFileSpec, unsigned int a_uiFlags) {
+		int nFlags = GLOB_MARK | GLOB_NOSORT;
+		if (a_uiFlags & SG_GLOB_ERR)
+			nFlags |= GLOB_ERR;
 #ifdef GLOB_TILDE
-        if (a_uiFlags & SG_GLOB_TILDE)  nFlags |= GLOB_TILDE;
+		if (a_uiFlags & SG_GLOB_TILDE)
+			nFlags |= GLOB_TILDE;
 #endif
-        int rc = glob(a_pszFileSpec, nFlags, NULL, &m_glob);
-        if (rc == GLOB_NOSPACE) return SG_ERR_MEMORY;
-        if (rc == GLOB_ABORTED) return SG_ERR_FAILURE;
-        if (rc == GLOB_NOMATCH) return SG_ERR_NOMATCH;
-        m_uiCurr = 0;
-        FilePrep();
-        return SG_SUCCESS;
-    }
-
-    bool FindNextFileS(char) {
-        SG_ASSERT(m_uiCurr != (size_t)-1);
-        if (++m_uiCurr >= m_glob.gl_pathc) {
-            return false;
-        }
-        FilePrep();
-        return true;
-    }
-
-    void FindDone() {
-        globfree(&m_glob);
-        memset(&m_glob, 0, sizeof(m_glob));
-        m_uiCurr = (size_t)-1;
-    }
-
-    const char * GetFileNameS(char) const {
-        SG_ASSERT(m_uiCurr != (size_t)-1);
-        return m_glob.gl_pathv[m_uiCurr];
-    }
-
-    bool IsDirS(char) const {
-        SG_ASSERT(m_uiCurr != (size_t)-1);
-        return m_bIsDir;
-    }
-
-    SG_FileType GetFileTypeS(const char * a_pszPath) const {
-        struct stat sb;
-        if (0 != stat(a_pszPath, &sb)) {
-            return SG_FILETYPE_INVALID;
-        }
-        if (S_ISDIR(sb.st_mode)) {
-            return SG_FILETYPE_DIR;
-        }
-        if (S_ISREG(sb.st_mode)) {
-            return SG_FILETYPE_FILE;
-        }
-        return SG_FILETYPE_INVALID;
-    }
-
-private:
-    glob_t  m_glob;
-    size_t  m_uiCurr;
-    bool    m_bIsDir;
+		int rc = glob(a_pszFileSpec, nFlags, NULL, &m_glob);
+		if (rc == GLOB_NOSPACE)
+			return SG_ERR_MEMORY;
+		if (rc == GLOB_ABORTED)
+			return SG_ERR_FAILURE;
+		if (rc == GLOB_NOMATCH)
+			return SG_ERR_NOMATCH;
+		m_uiCurr = 0;
+		FilePrep();
+		return SG_SUCCESS;
+	}
+
+	bool FindNextFileS(char) {
+		SG_ASSERT(m_uiCurr != (size_t) -1);
+		if (++m_uiCurr >= m_glob.gl_pathc) {
+			return false;
+		}
+		FilePrep();
+		return true;
+	}
+
+	void FindDone() {
+		globfree(&m_glob);
+		memset(&m_glob, 0, sizeof(m_glob));
+		m_uiCurr = (size_t) -1;
+	}
+
+	const char *GetFileNameS(char) const {
+		SG_ASSERT(m_uiCurr != (size_t) -1);
+		return m_glob.gl_pathv[m_uiCurr];
+	} bool IsDirS(char) const {
+		SG_ASSERT(m_uiCurr != (size_t) -1);
+		return m_bIsDir;
+	} SG_FileType GetFileTypeS(const char *a_pszPath) const {
+		struct stat sb;
+		if   (0 != stat(a_pszPath, &sb)) {
+			return SG_FILETYPE_INVALID;
+		}
+		if    (S_ISDIR(sb.st_mode)) {
+			return SG_FILETYPE_DIR;
+		}
+		if (S_ISREG(sb.st_mode)) {
+			return SG_FILETYPE_FILE;
+		}
+		return SG_FILETYPE_INVALID;
+	}
+
+  private:
+	glob_t m_glob;
+	size_t m_uiCurr;
+	bool m_bIsDir;
 };
 
 #endif // _WIN32
@@ -432,419 +422,366 @@
 // ---------------------------------------------------------------------------
 
 /*! @brief Implementation of the SimpleGlob class */
-template<class SOCHAR>
-class CSimpleGlobTempl : private SimpleGlobBase<SOCHAR>
-{
-public:
-    /*! @brief Initialize the class.
-
-        @param a_uiFlags            Combination of SG_GLOB flags.
-        @param a_nReservedSlots     Number of slots in the argv array that
-            should be reserved. In the returned array these slots
-            argv[0] ... argv[a_nReservedSlots-1] will be left empty for
-            the caller to fill in.
-     */
-    CSimpleGlobTempl(unsigned int a_uiFlags = 0, int a_nReservedSlots = 0);
-
-    /*! @brief Deallocate all memory buffers. */
-    ~CSimpleGlobTempl();
-
-    /*! @brief Initialize (or re-initialize) the class in preparation for
-        adding new filespecs.
-
-        All existing files are cleared. Note that allocated memory is only
-        deallocated at object destruction.
-
-        @param a_uiFlags            Combination of SG_GLOB flags.
-        @param a_nReservedSlots     Number of slots in the argv array that
-            should be reserved. In the returned array these slots
-            argv[0] ... argv[a_nReservedSlots-1] will be left empty for
-            the caller to fill in.
-     */
-    int Init(unsigned int a_uiFlags = 0, int a_nReservedSlots = 0);
-
-    /*! @brief Add a new filespec to the glob.
-
-        The filesystem will be immediately scanned for all matching files and
-        directories and they will be added to the glob.
-
-        @param a_pszFileSpec    Filespec to add to the glob.
-
-        @return SG_SUCCESS      Matching files were added to the glob.
-        @return SG_ERR_NOMATCH  Nothing matched the pattern. To ignore this error
-                                compare the return value to >= SG_SUCCESS.
-        @return SG_ERR_MEMORY   Out of memory failure.
-        @return SG_ERR_FAILURE  General failure.
-     */
-    int Add(const SOCHAR *a_pszFileSpec);
-
-    /*! @brief Add an array of filespec to the glob.
-
-        The filesystem will be immediately scanned for all matching files and
-        directories in each filespec and they will be added to the glob.
-
-        @param a_nCount         Number of filespec in the array.
-        @param a_rgpszFileSpec  Array of filespec to add to the glob.
-
-        @return SG_SUCCESS      Matching files were added to the glob.
-        @return SG_ERR_NOMATCH  Nothing matched the pattern. To ignore this error
-                                compare the return value to >= SG_SUCCESS.
-        @return SG_ERR_MEMORY   Out of memory failure.
-        @return SG_ERR_FAILURE  General failure.
-     */
-    int Add(int a_nCount, const SOCHAR * const * a_rgpszFileSpec);
-
-    /*! @brief Return the number of files in the argv array.
-     */
-    inline int FileCount() const { return m_nArgsLen; }
-
-    /*! @brief Return the full argv array. */
-    inline SOCHAR ** Files() {
-        SetArgvArrayType(POINTERS);
-        return m_rgpArgs;
-    }
-
-    /*! @brief Return the a single file. */
-    inline SOCHAR * File(int n) {
-        SG_ASSERT(n >= 0 && n < m_nArgsLen);
-        return Files()[n];
-    }
-
-private:
-    /*! @brief The argv array has it's members stored as either an offset into
-        the string buffer, or as pointers to their string in the buffer. The offsets
-        are used because if the string buffer is dynamically resized, all pointers
-        into that buffer would become invalid.
-     */
-    enum ARG_ARRAY_TYPE { OFFSETS, POINTERS };
-
-    /*! @brief Change the type of data stored in the argv array. */
-    void SetArgvArrayType(ARG_ARRAY_TYPE a_nNewType);
-
-    /*! @brief Add a filename to the array if it passes all requirements. */
-    int AppendName(const SOCHAR *a_pszFileName, bool a_bIsDir);
-
-    /*! @brief Grow the argv array to the required size. */
-    bool GrowArgvArray(int a_nNewLen);
-
-    /*! @brief Grow the string buffer to the required size. */
-    bool GrowStringBuffer(size_t a_uiMinSize);
-
-    /*! @brief Compare two (possible NULL) strings */
-    static int fileSortCompare(const void *a1, const void *a2);
-
-private:
-    unsigned int        m_uiFlags;
-    ARG_ARRAY_TYPE      m_nArgArrayType;    //!< is the argv array storing indexes or pointers
-    SOCHAR **           m_rgpArgs;          //!< argv array
-    int                 m_nReservedSlots;   //!< number of client reserved slots in the argv array
-    int                 m_nArgsSize;        //!< allocated size of array
-    int                 m_nArgsLen;         //!< used length
-    SOCHAR *            m_pBuffer;          //!< argv string buffer
-    size_t              m_uiBufferSize;     //!< allocated size of buffer
-    size_t              m_uiBufferLen;      //!< used length of buffer
-    SOCHAR              m_szPathPrefix[MAX_PATH]; //!< path prefix of any wildcard filenames
+template < class SOCHAR > class CSimpleGlobTempl:private SimpleGlobBase < SOCHAR > {
+  public:
+	/*! @brief Initialize the class.
+
+	   @param a_uiFlags            Combination of SG_GLOB flags.
+	   @param a_nReservedSlots     Number of slots in the argv array that
+	   should be reserved. In the returned array these slots
+	   argv[0] ... argv[a_nReservedSlots-1] will be left empty for
+	   the caller to fill in.
+	 */
+	CSimpleGlobTempl(unsigned int a_uiFlags = 0, int a_nReservedSlots = 0);
+
+	/*! @brief Deallocate all memory buffers. */
+	~CSimpleGlobTempl();
+
+	/*! @brief Initialize (or re-initialize) the class in preparation for
+	   adding new filespecs.
+
+	   All existing files are cleared. Note that allocated memory is only
+	   deallocated at object destruction.
+
+	   @param a_uiFlags            Combination of SG_GLOB flags.
+	   @param a_nReservedSlots     Number of slots in the argv array that
+	   should be reserved. In the returned array these slots
+	   argv[0] ... argv[a_nReservedSlots-1] will be left empty for
+	   the caller to fill in.
+	 */
+	int Init(unsigned int a_uiFlags = 0, int a_nReservedSlots = 0);
+
+	/*! @brief Add a new filespec to the glob.
+
+	   The filesystem will be immediately scanned for all matching files and
+	   directories and they will be added to the glob.
+
+	   @param a_pszFileSpec    Filespec to add to the glob.
+
+	   @return SG_SUCCESS      Matching files were added to the glob.
+	   @return SG_ERR_NOMATCH  Nothing matched the pattern. To ignore this error
+	   compare the return value to >= SG_SUCCESS.
+	   @return SG_ERR_MEMORY   Out of memory failure.
+	   @return SG_ERR_FAILURE  General failure.
+	 */
+	int Add(const SOCHAR * a_pszFileSpec);
+
+	/*! @brief Add an array of filespec to the glob.
+
+	   The filesystem will be immediately scanned for all matching files and
+	   directories in each filespec and they will be added to the glob.
+
+	   @param a_nCount         Number of filespec in the array.
+	   @param a_rgpszFileSpec  Array of filespec to add to the glob.
+
+	   @return SG_SUCCESS      Matching files were added to the glob.
+	   @return SG_ERR_NOMATCH  Nothing matched the pattern. To ignore this error
+	   compare the return value to >= SG_SUCCESS.
+	   @return SG_ERR_MEMORY   Out of memory failure.
+	   @return SG_ERR_FAILURE  General failure.
+	 */
+	int Add(int a_nCount, const SOCHAR * const *a_rgpszFileSpec);
+
+	/*! @brief Return the number of files in the argv array.
+	 */
+	inline int FileCount() const {
+		return m_nArgsLen;
+	}
+	/*! @brief Return the full argv array. */ inline SOCHAR **Files() {
+		SetArgvArrayType(POINTERS);
+		return m_rgpArgs;
+	}
+
+	/*! @brief Return the a single file. */
+	inline SOCHAR *File(int n) {
+		SG_ASSERT(n >= 0 && n < m_nArgsLen);
+		return Files()[n];
+	}
+
+  private:
+	/*! @brief The argv array has it's members stored as either an offset into
+	   the string buffer, or as pointers to their string in the buffer. The offsets
+	   are used because if the string buffer is dynamically resized, all pointers
+	   into that buffer would become invalid.
+	 */
+	enum ARG_ARRAY_TYPE { OFFSETS, POINTERS };
+
+	/*! @brief Change the type of data stored in the argv array. */
+	void SetArgvArrayType(ARG_ARRAY_TYPE a_nNewType);
+
+	/*! @brief Add a filename to the array if it passes all requirements. */
+	int AppendName(const SOCHAR * a_pszFileName, bool a_bIsDir);
+
+	/*! @brief Grow the argv array to the required size. */
+	bool GrowArgvArray(int a_nNewLen);
+
+	/*! @brief Grow the string buffer to the required size. */
+	bool GrowStringBuffer(size_t a_uiMinSize);
+
+	/*! @brief Compare two (possible NULL) strings */
+	static int fileSortCompare(const void *a1, const void *a2);
+
+  private:
+	unsigned int m_uiFlags;
+	ARG_ARRAY_TYPE m_nArgArrayType;	//!< is the argv array storing indexes or pointers
+	SOCHAR **m_rgpArgs;			//!< argv array
+	int m_nReservedSlots;		//!< number of client reserved slots in the argv array
+	int m_nArgsSize;			//!< allocated size of array
+	int m_nArgsLen;				//!< used length
+	SOCHAR *m_pBuffer;			//!< argv string buffer
+	size_t m_uiBufferSize;		//!< allocated size of buffer
+	size_t m_uiBufferLen;		//!< used length of buffer
+	SOCHAR m_szPathPrefix[MAX_PATH];	//!< path prefix of any wildcard filenames
 };
 
 // ---------------------------------------------------------------------------
 //                                  IMPLEMENTATION
 // ---------------------------------------------------------------------------
 
-template<class SOCHAR>
-CSimpleGlobTempl<SOCHAR>::CSimpleGlobTempl(
-    unsigned int    a_uiFlags,
-    int             a_nReservedSlots
-    )
+template < class SOCHAR > CSimpleGlobTempl < SOCHAR >::CSimpleGlobTempl(unsigned int a_uiFlags, int a_nReservedSlots)
 {
-    m_rgpArgs           = NULL;
-    m_nArgsSize         = 0;
-    m_pBuffer           = NULL;
-    m_uiBufferSize      = 0;
+	m_rgpArgs = NULL;
+	m_nArgsSize = 0;
+	m_pBuffer = NULL;
+	m_uiBufferSize = 0;
 
-    Init(a_uiFlags, a_nReservedSlots);
+	Init(a_uiFlags, a_nReservedSlots);
 }
 
-template<class SOCHAR>
-CSimpleGlobTempl<SOCHAR>::~CSimpleGlobTempl()
+template < class SOCHAR > CSimpleGlobTempl < SOCHAR >::~CSimpleGlobTempl()
 {
-    if (m_rgpArgs) free(m_rgpArgs);
-    if (m_pBuffer) free(m_pBuffer);
+	if (m_rgpArgs)
+		free(m_rgpArgs);
+	if (m_pBuffer)
+		free(m_pBuffer);
 }
 
-template<class SOCHAR>
-int
-CSimpleGlobTempl<SOCHAR>::Init(
-    unsigned int    a_uiFlags,
-    int             a_nReservedSlots
-    )
+template < class SOCHAR > int CSimpleGlobTempl < SOCHAR >::Init(unsigned int a_uiFlags, int a_nReservedSlots)
 {
-    m_nArgArrayType     = POINTERS;
-    m_uiFlags           = a_uiFlags;
-    m_nArgsLen          = a_nReservedSlots;
-    m_nReservedSlots    = a_nReservedSlots;
-    m_uiBufferLen       = 0;
-
-    if (m_nReservedSlots > 0) {
-        if (!GrowArgvArray(m_nReservedSlots)) {
-            return SG_ERR_MEMORY;
-        }
-        for (int n = 0; n < m_nReservedSlots; ++n) {
-            m_rgpArgs[n] = NULL;
-        }
-    }
+	m_nArgArrayType = POINTERS;
+	m_uiFlags = a_uiFlags;
+	m_nArgsLen = a_nReservedSlots;
+	m_nReservedSlots = a_nReservedSlots;
+	m_uiBufferLen = 0;
+
+	if (m_nReservedSlots > 0) {
+		if (!GrowArgvArray(m_nReservedSlots)) {
+			return SG_ERR_MEMORY;
+		}
+		for (int n = 0; n < m_nReservedSlots; ++n) {
+			m_rgpArgs[n] = NULL;
+		}
+	}
 
-    return SG_SUCCESS;
+	return SG_SUCCESS;
 }
 
-template<class SOCHAR>
-int
-CSimpleGlobTempl<SOCHAR>::Add(
-    const SOCHAR *a_pszFileSpec
-    )
+template < class SOCHAR > int CSimpleGlobTempl < SOCHAR >::Add(const SOCHAR * a_pszFileSpec)
 {
 #ifdef _WIN32
-    // Windows FindFirst/FindNext recognizes forward slash as the same as backward slash
-    // and follows the directories. We need to do the same when calculating the prefix
-    // and when we have no wildcards.
-    SOCHAR szFileSpec[MAX_PATH];
-    SimpleGlobUtil::strcpy_s(szFileSpec, MAX_PATH, a_pszFileSpec);
-    const SOCHAR * pszPath = SimpleGlobUtil::strchr(szFileSpec, '/');
-    while (pszPath) {
-        szFileSpec[pszPath - szFileSpec] = SG_PATH_CHAR;
-        pszPath = SimpleGlobUtil::strchr(pszPath + 1, '/');
-    }
-    a_pszFileSpec = szFileSpec;
+	// Windows FindFirst/FindNext recognizes forward slash as the same as backward slash
+	// and follows the directories. We need to do the same when calculating the prefix
+	// and when we have no wildcards.
+	SOCHAR szFileSpec[MAX_PATH];
+	SimpleGlobUtil::strcpy_s(szFileSpec, MAX_PATH, a_pszFileSpec);
+	const SOCHAR *pszPath = SimpleGlobUtil::strchr(szFileSpec, '/');
+	while (pszPath) {
+		szFileSpec[pszPath - szFileSpec] = SG_PATH_CHAR;
+		pszPath = SimpleGlobUtil::strchr(pszPath + 1, '/');
+	}
+	a_pszFileSpec = szFileSpec;
 #endif
 
-    // if this doesn't contain wildcards then we can just add it directly
-    m_szPathPrefix[0] = 0;
-    if (!SimpleGlobUtil::strchr(a_pszFileSpec, '*') &&
-        !SimpleGlobUtil::strchr(a_pszFileSpec, '?'))
-    {
-        SG_FileType nType = GetFileTypeS(a_pszFileSpec);
-        if (nType == SG_FILETYPE_INVALID) {
-            if (m_uiFlags & SG_GLOB_NOCHECK) {
-                return AppendName(a_pszFileSpec, false);
-            }
-            return SG_ERR_NOMATCH;
-        }
-        return AppendName(a_pszFileSpec, nType == SG_FILETYPE_DIR);
-    }
-
+	// if this doesn't contain wildcards then we can just add it directly
+	m_szPathPrefix[0] = 0;
+	if (!SimpleGlobUtil::strchr(a_pszFileSpec, '*') && !SimpleGlobUtil::strchr(a_pszFileSpec, '?')) {
+		SG_FileType nType = GetFileTypeS(a_pszFileSpec);
+		if (nType == SG_FILETYPE_INVALID) {
+			if (m_uiFlags & SG_GLOB_NOCHECK) {
+				return AppendName(a_pszFileSpec, false);
+			}
+			return SG_ERR_NOMATCH;
+		}
+		return AppendName(a_pszFileSpec, nType == SG_FILETYPE_DIR);
+	}
 #ifdef _WIN32
-    // Windows doesn't return the directory with the filename, so we need to extract the
-    // path from the search string ourselves and prefix it to the filename we get back.
-    const SOCHAR * pszFilename = SimpleGlobUtil::strrchr(a_pszFileSpec, SG_PATH_CHAR);
-    if (pszFilename) {
-        SimpleGlobUtil::strcpy_s(m_szPathPrefix, MAX_PATH, a_pszFileSpec);
-        m_szPathPrefix[pszFilename - a_pszFileSpec + 1] = 0;
-    }
+	// Windows doesn't return the directory with the filename, so we need to extract the
+	// path from the search string ourselves and prefix it to the filename we get back.
+	const SOCHAR *pszFilename = SimpleGlobUtil::strrchr(a_pszFileSpec, SG_PATH_CHAR);
+	if (pszFilename) {
+		SimpleGlobUtil::strcpy_s(m_szPathPrefix, MAX_PATH, a_pszFileSpec);
+		m_szPathPrefix[pszFilename - a_pszFileSpec + 1] = 0;
+	}
 #endif
 
-    // search for the first match on the file
-    int rc = FindFirstFileS(a_pszFileSpec, m_uiFlags);
-    if (rc != SG_SUCCESS) {
-        if (rc == SG_ERR_NOMATCH && (m_uiFlags & SG_GLOB_NOCHECK)) {
-            int ok = AppendName(a_pszFileSpec, false);
-            if (ok != SG_SUCCESS) rc = ok;
-        }
-        return rc;
-    }
-
-    // add it and find all subsequent matches
-    int nError, nStartLen = m_nArgsLen;
-    bool bSuccess;
-    do {
-        nError = AppendName(GetFileNameS((SOCHAR)0), IsDirS((SOCHAR)0));
-        bSuccess = FindNextFileS((SOCHAR)0);
-    }
-    while (nError == SG_SUCCESS && bSuccess);
-    SimpleGlobBase<SOCHAR>::FindDone();
-
-    // sort these files if required
-    if (m_nArgsLen > nStartLen && !(m_uiFlags & SG_GLOB_NOSORT)) {
-        if (m_uiFlags & SG_GLOB_FULLSORT) {
-            nStartLen = m_nReservedSlots;
-        }
-        SetArgvArrayType(POINTERS);
-        qsort(
-            m_rgpArgs + nStartLen,
-            m_nArgsLen - nStartLen,
-            sizeof(m_rgpArgs[0]), fileSortCompare);
-    }
+	// search for the first match on the file
+	int rc = FindFirstFileS(a_pszFileSpec, m_uiFlags);
+	if (rc != SG_SUCCESS) {
+		if (rc == SG_ERR_NOMATCH && (m_uiFlags & SG_GLOB_NOCHECK)) {
+			int ok = AppendName(a_pszFileSpec, false);
+			if (ok != SG_SUCCESS)
+				rc = ok;
+		}
+		return rc;
+	}
+	// add it and find all subsequent matches
+	int nError, nStartLen = m_nArgsLen;
+	bool bSuccess;
+	do {
+		nError = AppendName(GetFileNameS((SOCHAR) 0), IsDirS((SOCHAR) 0));
+		bSuccess = FindNextFileS((SOCHAR) 0);
+	}
+	while (nError == SG_SUCCESS && bSuccess);
+	SimpleGlobBase < SOCHAR >::FindDone();
+
+	// sort these files if required
+	if (m_nArgsLen > nStartLen && !(m_uiFlags & SG_GLOB_NOSORT)) {
+		if (m_uiFlags & SG_GLOB_FULLSORT) {
+			nStartLen = m_nReservedSlots;
+		}
+		SetArgvArrayType(POINTERS);
+		qsort(m_rgpArgs + nStartLen, m_nArgsLen - nStartLen, sizeof(m_rgpArgs[0]), fileSortCompare);
+	}
 
-    return nError;
+	return nError;
 }
 
-template<class SOCHAR>
-int
-CSimpleGlobTempl<SOCHAR>::Add(
-    int                     a_nCount,
-    const SOCHAR * const *  a_rgpszFileSpec
-    )
+template < class SOCHAR > int CSimpleGlobTempl < SOCHAR >::Add(int a_nCount, const SOCHAR * const *a_rgpszFileSpec)
 {
-    int nResult;
-    for (int n = 0; n < a_nCount; ++n) {
-        nResult = Add(a_rgpszFileSpec[n]);
-        if (nResult != SG_SUCCESS) {
-            return nResult;
-        }
-    }
-    return SG_SUCCESS;
+	int nResult;
+	for (int n = 0; n < a_nCount; ++n) {
+		nResult = Add(a_rgpszFileSpec[n]);
+		if (nResult != SG_SUCCESS) {
+			return nResult;
+		}
+	}
+	return SG_SUCCESS;
 }
 
-template<class SOCHAR>
-int
-CSimpleGlobTempl<SOCHAR>::AppendName(
-    const SOCHAR *  a_pszFileName,
-    bool            a_bIsDir
-    )
+template < class SOCHAR > int CSimpleGlobTempl < SOCHAR >::AppendName(const SOCHAR * a_pszFileName, bool a_bIsDir)
 {
-    // we need the argv array as offsets in case we resize it
-    SetArgvArrayType(OFFSETS);
+	// we need the argv array as offsets in case we resize it
+	SetArgvArrayType(OFFSETS);
 
-    // check for special cases which cause us to ignore this entry
-    if ((m_uiFlags & SG_GLOB_ONLYDIR) && !a_bIsDir) {
-        return SG_SUCCESS;
-    }
-    if ((m_uiFlags & SG_GLOB_ONLYFILE) && a_bIsDir) {
-        return SG_SUCCESS;
-    }
-    if ((m_uiFlags & SG_GLOB_NODOT) && a_bIsDir) {
-        if (a_pszFileName[0] == '.') {
-            if (a_pszFileName[1] == '\0') {
-                return SG_SUCCESS;
-            }
-            if (a_pszFileName[1] == '.' && a_pszFileName[2] == '\0') {
-                return SG_SUCCESS;
-            }
-        }
-    }
-
-    // ensure that we have enough room in the argv array
-    if (!GrowArgvArray(m_nArgsLen + 1)) {
-        return SG_ERR_MEMORY;
-    }
-
-    // ensure that we have enough room in the string buffer
-    size_t uiPrefixLen = SimpleGlobUtil::strlen(m_szPathPrefix);
-    size_t uiLen = uiPrefixLen + SimpleGlobUtil::strlen(a_pszFileName) + 1; // + null character
-    if (a_bIsDir && (m_uiFlags & SG_GLOB_MARK) == SG_GLOB_MARK) {
-        ++uiLen;    // need space for the backslash
-    }
-    if (!GrowStringBuffer(m_uiBufferLen + uiLen)) {
-        return SG_ERR_MEMORY;
-    }
-
-    // add this entry
-    m_rgpArgs[m_nArgsLen++] = (SOCHAR*)m_uiBufferLen;    // offset from beginning of buffer
-    SimpleGlobUtil::strcpy_s(m_pBuffer + m_uiBufferLen,
-        m_uiBufferSize - m_uiBufferLen, m_szPathPrefix);
-    SimpleGlobUtil::strcpy_s(m_pBuffer + m_uiBufferLen + uiPrefixLen,
-        m_uiBufferSize - m_uiBufferLen - uiPrefixLen, a_pszFileName);
-    m_uiBufferLen += uiLen;
-
-    // add the directory slash if desired
-    if (a_bIsDir && (m_uiFlags & SG_GLOB_MARK) == SG_GLOB_MARK) {
-        const static SOCHAR szDirSlash[] = { SG_PATH_CHAR, 0 };
-        SimpleGlobUtil::strcpy_s(m_pBuffer + m_uiBufferLen - 2,
-            m_uiBufferSize - (m_uiBufferLen - 2), szDirSlash);
-    }
+	// check for special cases which cause us to ignore this entry
+	if ((m_uiFlags & SG_GLOB_ONLYDIR) && !a_bIsDir) {
+		return SG_SUCCESS;
+	}
+	if ((m_uiFlags & SG_GLOB_ONLYFILE) && a_bIsDir) {
+		return SG_SUCCESS;
+	}
+	if ((m_uiFlags & SG_GLOB_NODOT) && a_bIsDir) {
+		if (a_pszFileName[0] == '.') {
+			if (a_pszFileName[1] == '\0') {
+				return SG_SUCCESS;
+			}
+			if (a_pszFileName[1] == '.' && a_pszFileName[2] == '\0') {
+				return SG_SUCCESS;
+			}
+		}
+	}
+	// ensure that we have enough room in the argv array
+	if (!GrowArgvArray(m_nArgsLen + 1)) {
+		return SG_ERR_MEMORY;
+	}
+	// ensure that we have enough room in the string buffer
+	size_t uiPrefixLen = SimpleGlobUtil::strlen(m_szPathPrefix);
+	size_t uiLen = uiPrefixLen + SimpleGlobUtil::strlen(a_pszFileName) + 1;	// + null character
+	if (a_bIsDir && (m_uiFlags & SG_GLOB_MARK) == SG_GLOB_MARK) {
+		++uiLen;				// need space for the backslash
+	}
+	if (!GrowStringBuffer(m_uiBufferLen + uiLen)) {
+		return SG_ERR_MEMORY;
+	}
+	// add this entry
+	m_rgpArgs[m_nArgsLen++] = (SOCHAR *) m_uiBufferLen;	// offset from beginning of buffer
+	SimpleGlobUtil::strcpy_s(m_pBuffer + m_uiBufferLen, m_uiBufferSize - m_uiBufferLen, m_szPathPrefix);
+	SimpleGlobUtil::strcpy_s(m_pBuffer + m_uiBufferLen + uiPrefixLen, m_uiBufferSize - m_uiBufferLen - uiPrefixLen, a_pszFileName);
+	m_uiBufferLen += uiLen;
+
+	// add the directory slash if desired
+	if (a_bIsDir && (m_uiFlags & SG_GLOB_MARK) == SG_GLOB_MARK) {
+		const static SOCHAR szDirSlash[] = { SG_PATH_CHAR, 0 };
+		SimpleGlobUtil::strcpy_s(m_pBuffer + m_uiBufferLen - 2, m_uiBufferSize - (m_uiBufferLen - 2), szDirSlash);
+	}
 
-    return SG_SUCCESS;
+	return SG_SUCCESS;
 }
 
-template<class SOCHAR>
-void
-CSimpleGlobTempl<SOCHAR>::SetArgvArrayType(
-    ARG_ARRAY_TYPE  a_nNewType
-    )
+template < class SOCHAR > void CSimpleGlobTempl < SOCHAR >::SetArgvArrayType(ARG_ARRAY_TYPE a_nNewType)
 {
-    if (m_nArgArrayType == a_nNewType) return;
-    if (a_nNewType == POINTERS) {
-        SG_ASSERT(m_nArgArrayType == OFFSETS);
-        for (int n = 0; n < m_nArgsLen; ++n) {
-            m_rgpArgs[n] = (m_rgpArgs[n] == (SOCHAR*)-1) ?
-                NULL : m_pBuffer + (size_t) m_rgpArgs[n];
-        }
-    }
-    else {
-        SG_ASSERT(a_nNewType == OFFSETS);
-        SG_ASSERT(m_nArgArrayType == POINTERS);
-        for (int n = 0; n < m_nArgsLen; ++n) {
-            m_rgpArgs[n] = (m_rgpArgs[n] == NULL) ?
-                (SOCHAR*) -1 : (SOCHAR*) (m_rgpArgs[n] - m_pBuffer);
-        }
-    }
-    m_nArgArrayType = a_nNewType;
+	if (m_nArgArrayType == a_nNewType)
+		return;
+	if (a_nNewType == POINTERS) {
+		SG_ASSERT(m_nArgArrayType == OFFSETS);
+		for (int n = 0; n < m_nArgsLen; ++n) {
+			m_rgpArgs[n] = (m_rgpArgs[n] == (SOCHAR *) - 1) ? NULL : m_pBuffer + (size_t) m_rgpArgs[n];
+		}
+	} else {
+		SG_ASSERT(a_nNewType == OFFSETS);
+		SG_ASSERT(m_nArgArrayType == POINTERS);
+		for (int n = 0; n < m_nArgsLen; ++n) {
+			m_rgpArgs[n] = (m_rgpArgs[n] == NULL) ? (SOCHAR *) - 1 : (SOCHAR *) (m_rgpArgs[n] - m_pBuffer);
+		}
+	}
+	m_nArgArrayType = a_nNewType;
 }
 
-template<class SOCHAR>
-bool
-CSimpleGlobTempl<SOCHAR>::GrowArgvArray(
-    int a_nNewLen
-    )
+template < class SOCHAR > bool CSimpleGlobTempl < SOCHAR >::GrowArgvArray(int a_nNewLen)
 {
-    if (a_nNewLen >= m_nArgsSize) {
-        static const int SG_ARGV_INITIAL_SIZE = 32;
-        int nNewSize = (m_nArgsSize > 0) ? m_nArgsSize * 2 : SG_ARGV_INITIAL_SIZE;
-        while (a_nNewLen >= nNewSize) {
-            nNewSize *= 2;
-        }
-        void * pNewBuffer = realloc(m_rgpArgs, nNewSize * sizeof(SOCHAR*));
-        if (!pNewBuffer) return false;
-        m_nArgsSize = nNewSize;
-        m_rgpArgs = (SOCHAR**) pNewBuffer;
-    }
-    return true;
+	if (a_nNewLen >= m_nArgsSize) {
+		static const int SG_ARGV_INITIAL_SIZE = 32;
+		int nNewSize = (m_nArgsSize > 0) ? m_nArgsSize * 2 : SG_ARGV_INITIAL_SIZE;
+		while (a_nNewLen >= nNewSize) {
+			nNewSize *= 2;
+		}
+		void *pNewBuffer = realloc(m_rgpArgs, nNewSize * sizeof(SOCHAR *));
+		if (!pNewBuffer)
+			return false;
+		m_nArgsSize = nNewSize;
+		m_rgpArgs = (SOCHAR **) pNewBuffer;
+	}
+	return true;
 }
 
-template<class SOCHAR>
-bool
-CSimpleGlobTempl<SOCHAR>::GrowStringBuffer(
-    size_t a_uiMinSize
-    )
+template < class SOCHAR > bool CSimpleGlobTempl < SOCHAR >::GrowStringBuffer(size_t a_uiMinSize)
 {
-    if (a_uiMinSize >= m_uiBufferSize) {
-        static const int SG_BUFFER_INITIAL_SIZE = 1024;
-        size_t uiNewSize = (m_uiBufferSize > 0) ? m_uiBufferSize * 2 : SG_BUFFER_INITIAL_SIZE;
-        while (a_uiMinSize >= uiNewSize) {
-            uiNewSize *= 2;
-        }
-        void * pNewBuffer = realloc(m_pBuffer, uiNewSize * sizeof(SOCHAR));
-        if (!pNewBuffer) return false;
-        m_uiBufferSize = uiNewSize;
-        m_pBuffer = (SOCHAR*) pNewBuffer;
-    }
-    return true;
+	if (a_uiMinSize >= m_uiBufferSize) {
+		static const int SG_BUFFER_INITIAL_SIZE = 1024;
+		size_t uiNewSize = (m_uiBufferSize > 0) ? m_uiBufferSize * 2 : SG_BUFFER_INITIAL_SIZE;
+		while (a_uiMinSize >= uiNewSize) {
+			uiNewSize *= 2;
+		}
+		void *pNewBuffer = realloc(m_pBuffer, uiNewSize * sizeof(SOCHAR));
+		if (!pNewBuffer)
+			return false;
+		m_uiBufferSize = uiNewSize;
+		m_pBuffer = (SOCHAR *) pNewBuffer;
+	}
+	return true;
 }
 
-template<class SOCHAR>
-int
-CSimpleGlobTempl<SOCHAR>::fileSortCompare(
-    const void *a1,
-    const void *a2
-    )
+template < class SOCHAR > int CSimpleGlobTempl < SOCHAR >::fileSortCompare(const void *a1, const void *a2)
 {
-    const SOCHAR * s1 = *(const SOCHAR **)a1;
-    const SOCHAR * s2 = *(const SOCHAR **)a2;
-    if (s1 && s2) {
-        return SimpleGlobUtil::strcasecmp(s1, s2);
-    }
-    // NULL sorts first
-    return s1 == s2 ? 0 : (s1 ? 1 : -1);
+	const SOCHAR *s1 = *(const SOCHAR **) a1;
+	const SOCHAR *s2 = *(const SOCHAR **) a2;
+	if (s1 && s2) {
+		return SimpleGlobUtil::strcasecmp(s1, s2);
+	}
+	// NULL sorts first
+	return s1 == s2 ? 0 : (s1 ? 1 : -1);
 }
 
 // ---------------------------------------------------------------------------
 //                                  TYPE DEFINITIONS
 // ---------------------------------------------------------------------------
 
-typedef CSimpleGlobTempl<char>    CSimpleGlobA; /*!< @brief ASCII/MBCS version of CSimpleGlob */
-typedef CSimpleGlobTempl<wchar_t> CSimpleGlobW; /*!< @brief wchar_t version of CSimpleGlob */
+typedef CSimpleGlobTempl < char >CSimpleGlobA;	/*!< @brief ASCII/MBCS version of CSimpleGlob */
+typedef CSimpleGlobTempl < wchar_t >CSimpleGlobW;	/*!< @brief wchar_t version of CSimpleGlob */
 #if defined(_UNICODE)
-# define CSimpleGlob CSimpleGlobW   /*!< @brief TCHAR version dependent on if _UNICODE is defined */
+# define CSimpleGlob CSimpleGlobW	/*!< @brief TCHAR version dependent on if _UNICODE is defined */
 #else
-# define CSimpleGlob CSimpleGlobA   /*!< @brief TCHAR version dependent on if _UNICODE is defined */
+# define CSimpleGlob CSimpleGlobA	/*!< @brief TCHAR version dependent on if _UNICODE is defined */
 #endif
 
 #endif // INCLUDED_SimpleGlob

Modified: freeswitch/trunk/src/include/g711.h
==============================================================================
--- freeswitch/trunk/src/include/g711.h	(original)
+++ freeswitch/trunk/src/include/g711.h	Tue May 27 00:30:03 2008
@@ -50,137 +50,108 @@
 #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;
-
-    __asm__ __volatile__(" movl $-1,%%edx;\n"
-                         " bsrl %%eax,%%edx;\n"
-                         : "=d" (res)
-                         : "a" (bits));
-    return res;
-}
-/*- End of function --------------------------------------------------------*/
+	static __inline__ int top_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" " 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;
+
+		__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;
-
-    __asm__ __volatile__(" movq $-1,%%rdx;\n"
-                         " bsrq %%rax,%%rdx;\n"
-                         : "=d" (res)
-                         : "a" (bits));
-    return res;
-}
-/*- End of function --------------------------------------------------------*/
+	static __inline__ int top_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" " bsrq %%rax,%%rdx;\n":"=d"(res)
+							 :"a"    (bits));
+		        return res;
+	}
+/*- End of function --------------------------------------------------------*/ 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;
+	}
 /*- 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 +165,7 @@
  *      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 +193,61 @@
  */
 
 //#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;
-
-    /* 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;
-
-    /*
-     * 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);
+	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;
+		}
+
+		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);
 #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 +274,64 @@
     \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;
-    }
-
-    /* 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);
-}
+	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;
+		}
+
+		/* 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;
-
-    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);
-}
+	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);
+	}
 /*- 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 ulaw 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
 }

Modified: freeswitch/trunk/src/include/switch_apr.h
==============================================================================
--- freeswitch/trunk/src/include/switch_apr.h	(original)
+++ freeswitch/trunk/src/include/switch_apr.h	Tue May 27 00:30:03 2008
@@ -56,8 +56,6 @@
  */
 /** The fundamental pool type */
 /* see switch types.h 	typedef struct apr_pool_t switch_memory_pool_t;*/
-
-
 /**
  * Clear all memory in the pool and run all the cleanups. This also destroys all
  * subpools.
@@ -93,13 +91,13 @@
  * @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.
  * @param handle handle to close.
  */
-SWITCH_DECLARE(switch_status_t) switch_dso_unload(switch_dso_handle_t * handle);
+SWITCH_DECLARE(switch_status_t) switch_dso_unload(switch_dso_handle_t *handle);
 
 /**
  * Load a symbol from a DSO handle.
@@ -107,7 +105,7 @@
  * @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.
@@ -115,7 +113,7 @@
  * @param buf Location to store the dso error
  * @param bufsize The size of the provided buffer
  */
-SWITCH_DECLARE(const char *) switch_dso_error(switch_dso_handle_t * dso, char *buf, size_t bufsize);
+SWITCH_DECLARE(const char *) switch_dso_error(switch_dso_handle_t *dso, char *buf, size_t bufsize);
 
 /** @} */
 
@@ -125,11 +123,13 @@
  * @{
  */
 
-SWITCH_DECLARE(int) switch_snprintf(_Out_z_cap_(len) char *buf, _In_ switch_size_t len, _In_z_ _Printf_format_string_ const char *format, ...);
+SWITCH_DECLARE(int) switch_snprintf(_Out_z_cap_(len)
+									char *buf, _In_ switch_size_t len, _In_z_ _Printf_format_string_ const char *format, ...);
 
 SWITCH_DECLARE(int) switch_vasprintf(_Out_opt_ char **buf, _In_z_ _Printf_format_string_ const char *format, _In_ va_list ap);
 
-SWITCH_DECLARE(char *) switch_copy_string(_Out_z_cap_(dst_size) char *dst, _In_z_ const char *src, _In_ switch_size_t dst_size);
+SWITCH_DECLARE(char *) switch_copy_string(_Out_z_cap_(dst_size)
+										  char *dst, _In_z_ const char *src, _In_ switch_size_t dst_size);
 
 /** @} */
 
@@ -164,7 +164,7 @@
  * progress at the same time.
 
  */
-SWITCH_DECLARE(switch_hash_index_t *) switch_hash_first(switch_memory_pool_t *p, switch_hash_t * ht);
+SWITCH_DECLARE(switch_hash_index_t *) switch_hash_first(switch_memory_pool_t *p, switch_hash_t *ht);
 
 /**
  * Continue iterating over the entries in a hash table.
@@ -172,7 +172,7 @@
  * @return a pointer to the updated iteration state.  NULL if there are no more  
  *         entries.
  */
-SWITCH_DECLARE(switch_hash_index_t *) switch_hash_next(switch_hash_index_t * ht);
+SWITCH_DECLARE(switch_hash_index_t *) switch_hash_next(switch_hash_index_t *ht);
 
 /**
  * Get the current entry's details from the iteration state.
@@ -183,11 +183,11 @@
  * @remark The return pointers should point to a variable that will be set to the
  *         corresponding data, or they may be NULL if the data isn't interesting.
  */
-SWITCH_DECLARE(void) switch_hash_this(switch_hash_index_t * hi, const void **key, switch_ssize_t *klen, void **val);
+SWITCH_DECLARE(void) switch_hash_this(switch_hash_index_t *hi, const void **key, switch_ssize_t *klen, void **val);
 
 
 
-SWITCH_DECLARE(switch_memory_pool_t *) switch_hash_pool_get(switch_hash_t * ht);
+SWITCH_DECLARE(switch_memory_pool_t *) switch_hash_pool_get(switch_hash_t *ht);
 
 /** @} */
 
@@ -258,7 +258,7 @@
  * @param result the resulting imploded time
  * @param input the input exploded time
  */
-SWITCH_DECLARE(switch_status_t) switch_time_exp_gmt_get(switch_time_t * result, switch_time_exp_t * input);
+SWITCH_DECLARE(switch_status_t) switch_time_exp_gmt_get(switch_time_t *result, switch_time_exp_t *input);
 
 /**
  * formats the exploded time according to the format specified
@@ -268,7 +268,7 @@
  * @param format The format for the time string
  * @param tm The time to convert
  */
-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_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_rfc822_date formats dates in the RFC822
@@ -285,7 +285,7 @@
  * @param result the exploded time
  * @param input the time to explode
  */
-SWITCH_DECLARE(switch_status_t) switch_time_exp_gmt(switch_time_exp_t * result, switch_time_t input);
+SWITCH_DECLARE(switch_status_t) switch_time_exp_gmt(switch_time_exp_t *result, switch_time_t input);
 
 /**
  * Convert time value from human readable format to a numeric apr_time_t 
@@ -293,14 +293,14 @@
  * @param result the resulting imploded time
  * @param input the input exploded time
  */
-SWITCH_DECLARE(switch_status_t) switch_time_exp_get(switch_time_t * result, switch_time_exp_t * input);
+SWITCH_DECLARE(switch_status_t) switch_time_exp_get(switch_time_t *result, switch_time_exp_t *input);
 
 /**
  * convert a time to its human readable components in local timezone
  * @param result the exploded time
  * @param input the time to explode
  */
-SWITCH_DECLARE(switch_status_t) switch_time_exp_lt(switch_time_exp_t * result, switch_time_t input);
+SWITCH_DECLARE(switch_status_t) switch_time_exp_lt(switch_time_exp_t *result, switch_time_t input);
 
 /**
  * Sleep for the specified number of micro-seconds.
@@ -341,27 +341,27 @@
  * it will behave as either a nested or an unnested lock.
  *
 */
-SWITCH_DECLARE(switch_status_t) switch_mutex_init(switch_mutex_t ** lock, unsigned int flags, switch_memory_pool_t *pool);
+SWITCH_DECLARE(switch_status_t) switch_mutex_init(switch_mutex_t **lock, unsigned int flags, switch_memory_pool_t *pool);
 
 
 /**
  * Destroy the mutex and free the memory associated with the lock.
  * @param lock the mutex to destroy.
  */
-SWITCH_DECLARE(switch_status_t) switch_mutex_destroy(switch_mutex_t * lock);
+SWITCH_DECLARE(switch_status_t) switch_mutex_destroy(switch_mutex_t *lock);
 
 /**
  * Acquire the lock for the given mutex. If the mutex is already locked,
  * the current thread will be put to sleep until the lock becomes available.
  * @param lock the mutex on which to acquire the lock.
  */
-SWITCH_DECLARE(switch_status_t) switch_mutex_lock(switch_mutex_t * lock);
+SWITCH_DECLARE(switch_status_t) switch_mutex_lock(switch_mutex_t *lock);
 
 /**
  * Release the lock for the given mutex.
  * @param lock the mutex from which to release the lock.
  */
-SWITCH_DECLARE(switch_status_t) switch_mutex_unlock(switch_mutex_t * lock);
+SWITCH_DECLARE(switch_status_t) switch_mutex_unlock(switch_mutex_t *lock);
 
 /**
  * Attempt to acquire the lock for the given mutex. If the mutex has already
@@ -370,7 +370,7 @@
  * if the return value was APR_EBUSY, for portability reasons.
  * @param lock the mutex on which to attempt the lock acquiring.
  */
-SWITCH_DECLARE(switch_status_t) switch_mutex_trylock(switch_mutex_t * lock);
+SWITCH_DECLARE(switch_status_t) switch_mutex_trylock(switch_mutex_t *lock);
 
 /** @} */
 
@@ -383,14 +383,14 @@
 /** Opaque structure used for the rwlock */
 	 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_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);
-SWITCH_DECLARE(switch_status_t) switch_thread_rwlock_tryrdlock(switch_thread_rwlock_t * rwlock);
-SWITCH_DECLARE(switch_status_t) switch_thread_rwlock_wrlock(switch_thread_rwlock_t * rwlock);
-SWITCH_DECLARE(switch_status_t) switch_thread_rwlock_trywrlock(switch_thread_rwlock_t * rwlock);
-SWITCH_DECLARE(switch_status_t) switch_thread_rwlock_unlock(switch_thread_rwlock_t * rwlock);
+SWITCH_DECLARE(switch_status_t) switch_thread_rwlock_create(switch_thread_rwlock_t **rwlock, 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);
+SWITCH_DECLARE(switch_status_t) switch_thread_rwlock_tryrdlock(switch_thread_rwlock_t *rwlock);
+SWITCH_DECLARE(switch_status_t) switch_thread_rwlock_wrlock(switch_thread_rwlock_t *rwlock);
+SWITCH_DECLARE(switch_status_t) switch_thread_rwlock_trywrlock(switch_thread_rwlock_t *rwlock);
+SWITCH_DECLARE(switch_status_t) switch_thread_rwlock_unlock(switch_thread_rwlock_t *rwlock);
 
 /** @} */
 
@@ -416,7 +416,7 @@
  *        will be stored.
  * @param pool the pool from which to allocate the mutex.
  */
-SWITCH_DECLARE(switch_status_t) switch_thread_cond_create(switch_thread_cond_t ** cond, switch_memory_pool_t *pool);
+SWITCH_DECLARE(switch_status_t) switch_thread_cond_create(switch_thread_cond_t **cond, switch_memory_pool_t *pool);
 
 /**
  * Put the active calling thread to sleep until signaled to wake up. Each
@@ -430,7 +430,7 @@
  *        is released while the thread is asleep, and is again acquired before
  *        returning from this function.
  */
-SWITCH_DECLARE(switch_status_t) switch_thread_cond_wait(switch_thread_cond_t * cond, switch_mutex_t * mutex);
+SWITCH_DECLARE(switch_status_t) switch_thread_cond_wait(switch_thread_cond_t *cond, switch_mutex_t *mutex);
 
 /**
  * Put the active calling thread to sleep until signaled to wake up or
@@ -448,7 +448,7 @@
  *        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
@@ -457,7 +457,7 @@
  * is desired, that mutex must be locked while calling this function.
  * @param cond the condition variable on which to produce the signal.
  */
-SWITCH_DECLARE(switch_status_t) switch_thread_cond_signal(switch_thread_cond_t * cond);
+SWITCH_DECLARE(switch_status_t) switch_thread_cond_signal(switch_thread_cond_t *cond);
 
 /**
  * Signals all threads blocking on the given condition variable.
@@ -465,13 +465,13 @@
  * the associated mutex. This will happen in a serialized manner.
  * @param cond the condition variable on which to produce the broadcast.
  */
-SWITCH_DECLARE(switch_status_t) switch_thread_cond_broadcast(switch_thread_cond_t * cond);
+SWITCH_DECLARE(switch_status_t) switch_thread_cond_broadcast(switch_thread_cond_t *cond);
 
 /**
  * Destroy the condition variable and free the associated memory.
  * @param cond the condition variable to destroy.
  */
-SWITCH_DECLARE(switch_status_t) switch_thread_cond_destroy(switch_thread_cond_t * cond);
+SWITCH_DECLARE(switch_status_t) switch_thread_cond_destroy(switch_thread_cond_t *cond);
 
 /** @} */
 
@@ -498,20 +498,20 @@
  *               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);
+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);
+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);
+SWITCH_DECLARE(switch_status_t) switch_uuid_parse(switch_uuid_t *uuid, const char *uuid_str);
 
 /** @} */
 
@@ -530,7 +530,7 @@
  * @param queue_capacity maximum size of the queue
  * @param pool 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
@@ -541,7 +541,7 @@
  * @returns APR_EOF if the queue has been terminated
  * @returns APR_SUCCESS on a successfull pop
  */
-SWITCH_DECLARE(switch_status_t) switch_queue_pop(switch_queue_t * queue, void **data);
+SWITCH_DECLARE(switch_status_t) switch_queue_pop(switch_queue_t *queue, void **data);
 
 /**
  * push/add a object to the queue, blocking if the queue is already full
@@ -552,7 +552,7 @@
  * @returns APR_EOF the queue has been terminated
  * @returns APR_SUCCESS on a successfull push
  */
-SWITCH_DECLARE(switch_status_t) switch_queue_push(switch_queue_t * queue, void *data);
+SWITCH_DECLARE(switch_status_t) switch_queue_push(switch_queue_t *queue, void *data);
 
 /**
  * returns the size of the queue.
@@ -562,7 +562,7 @@
  * @param queue the queue
  * @returns the size of the queue
  */
-SWITCH_DECLARE(unsigned int) switch_queue_size(switch_queue_t * queue);
+SWITCH_DECLARE(unsigned int) switch_queue_size(switch_queue_t *queue);
 
 /**
  * pop/get an object to the queue, returning immediatly if the queue is empty
@@ -574,7 +574,7 @@
  * @returns APR_EOF the queue has been terminated
  * @returns APR_SUCCESS on a successfull push
  */
-SWITCH_DECLARE(switch_status_t) switch_queue_trypop(switch_queue_t * queue, void **data);
+SWITCH_DECLARE(switch_status_t) switch_queue_trypop(switch_queue_t *queue, void **data);
 
 /**
  * push/add a object to the queue, returning immediatly if the queue is full
@@ -586,7 +586,7 @@
  * @returns APR_EOF the queue has been terminated
  * @returns APR_SUCCESS on a successfull push
  */
-SWITCH_DECLARE(switch_status_t) switch_queue_trypush(switch_queue_t * queue, void *data);
+SWITCH_DECLARE(switch_status_t) switch_queue_trypush(switch_queue_t *queue, void *data);
 
 /** @} */
 
@@ -650,13 +650,13 @@
  * @{
  */
 
-#define SWITCH_FLOCK_SHARED        1       /**< Shared lock. More than one process
+#define SWITCH_FLOCK_SHARED        1	   /**< Shared lock. More than one process
                                            or thread can hold a shared lock
                                            at any given time. Essentially,
                                            this is a "read lock", preventing
                                            writers from establishing an
                                            exclusive lock. */
-#define SWITCH_FLOCK_EXCLUSIVE     2       /**< Exclusive lock. Only one process
+#define SWITCH_FLOCK_EXCLUSIVE     2	   /**< Exclusive lock. Only one process
                                            may hold an exclusive lock at any
                                            given time. This is analogous to
                                            a "write lock". */
@@ -722,19 +722,19 @@
  * @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_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);
+SWITCH_DECLARE(switch_status_t) switch_file_seek(switch_file_t *thefile, switch_seek_where_t where, int64_t *offset);
 
 /**
  * Close the specified file.
  * @param thefile The file descriptor to close.
  */
-SWITCH_DECLARE(switch_status_t) switch_file_close(switch_file_t * thefile);
+SWITCH_DECLARE(switch_status_t) switch_file_close(switch_file_t *thefile);
 
-SWITCH_DECLARE(switch_status_t) switch_file_lock(switch_file_t * thefile, int type);
+SWITCH_DECLARE(switch_status_t) switch_file_lock(switch_file_t *thefile, int type);
 
 /**
  * Delete the specified file.
@@ -764,7 +764,7 @@
  * @remark It is not possible for both bytes to be read and an APR_EOF
  * or other error to be returned.  APR_EINTR is never returned.
  */
-SWITCH_DECLARE(switch_status_t) switch_file_read(switch_file_t * thefile, void *buf, switch_size_t *nbytes);
+SWITCH_DECLARE(switch_status_t) switch_file_read(switch_file_t *thefile, void *buf, switch_size_t *nbytes);
 
 /**
  * Write data to the specified file.
@@ -781,7 +781,7 @@
  * @remark It is possible for both bytes to be written and an error to
  * be returned.  APR_EINTR is never returned.
  */
-SWITCH_DECLARE(switch_status_t) switch_file_write(switch_file_t * thefile, const void *buf, switch_size_t *nbytes);
+SWITCH_DECLARE(switch_status_t) switch_file_write(switch_file_t *thefile, const void *buf, switch_size_t *nbytes);
 SWITCH_DECLARE(int) switch_file_printf(switch_file_t *thefile, const char *format, ...);
 
 SWITCH_DECLARE(switch_status_t) switch_file_mktemp(switch_file_t **thefile, char *templ, int32_t flags, switch_memory_pool_t *pool);
@@ -798,8 +798,7 @@
 * @param perm Permissions for the new direcoty.
 * @param pool the pool to use.
 */
-SWITCH_DECLARE(switch_status_t) switch_dir_make(const char *path, switch_fileperms_t perm,
-												switch_memory_pool_t *pool);
+SWITCH_DECLARE(switch_status_t) switch_dir_make(const char *path, switch_fileperms_t perm, switch_memory_pool_t *pool);
 
 /** Creates a new directory on the file system, but behaves like
 * 'mkdir -p'. Creates intermediate directories as required. No error
@@ -808,24 +807,23 @@
 * @param perm Permissions for the new direcoty.
 * @param pool the pool to use.
 */
-SWITCH_DECLARE(switch_status_t) switch_dir_make_recursive(const char *path, switch_fileperms_t perm,
-														  switch_memory_pool_t *pool);
+SWITCH_DECLARE(switch_status_t) switch_dir_make_recursive(const char *path, switch_fileperms_t perm, switch_memory_pool_t *pool);
 
-typedef struct switch_dir switch_dir_t;
+	 typedef struct switch_dir switch_dir_t;
 
-struct switch_array_header_t {
-    /** The pool the array is allocated out of */
-    switch_memory_pool_t *pool;
-    /** The amount of memory allocated for each element of the array */
-    int elt_size;
-    /** The number of active elements in the array */
-    int nelts;
-    /** The number of elements allocated in the array */
-    int nalloc;
-    /** The elements in the array */
-    char *elts;
-};
-typedef struct switch_array_header_t switch_array_header_t;
+	 struct switch_array_header_t {
+	/** The pool the array is allocated out of */
+		 switch_memory_pool_t *pool;
+	/** The amount of memory allocated for each element of the array */
+		 int elt_size;
+	/** The number of active elements in the array */
+		 int nelts;
+	/** The number of elements allocated in the array */
+		 int nalloc;
+	/** The elements in the array */
+		 char *elts;
+	 };
+	 typedef struct switch_array_header_t switch_array_header_t;
 
 SWITCH_DECLARE(switch_status_t) switch_dir_open(switch_dir_t **new_dir, const char *dirname, switch_memory_pool_t *pool);
 SWITCH_DECLARE(switch_status_t) switch_dir_close(switch_dir_t *thedir);
@@ -852,7 +850,7 @@
 	 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);
+SWITCH_DECLARE(switch_status_t) switch_threadattr_stacksize_set(switch_threadattr_t *attr, switch_size_t stacksize);
 
 SWITCH_DECLARE(switch_status_t) switch_threadattr_priority_increase(switch_threadattr_t *attr);
 
@@ -862,14 +860,14 @@
  * @param new_attr The newly created threadattr.
  * @param pool The pool to use
  */
-SWITCH_DECLARE(switch_status_t) switch_threadattr_create(switch_threadattr_t ** new_attr, switch_memory_pool_t *pool);
+SWITCH_DECLARE(switch_status_t) switch_threadattr_create(switch_threadattr_t **new_attr, switch_memory_pool_t *pool);
 
 /**
  * Set if newly created threads should be created in detached state.
  * @param attr The threadattr to affect 
  * @param on Non-zero if detached threads should be created.
  */
-SWITCH_DECLARE(switch_status_t) switch_threadattr_detach_set(switch_threadattr_t * attr, int32_t on);
+SWITCH_DECLARE(switch_status_t) switch_threadattr_detach_set(switch_threadattr_t *attr, int32_t on);
 
 /**
  * Create a new thread of execution
@@ -879,7 +877,7 @@
  * @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_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);
 
 /** @} */
@@ -946,7 +944,7 @@
  * @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.
@@ -961,13 +959,13 @@
  * @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
@@ -976,7 +974,7 @@
  * @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.
@@ -985,7 +983,7 @@
  *                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
@@ -995,7 +993,7 @@
  * @param sock The socket we are listening on.
  * @param 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 
@@ -1003,12 +1001,12 @@
  * @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(const 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(const 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);
 
 
 /**
@@ -1034,7 +1032,7 @@
  * </PRE>
  * @param pool 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,
+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);
 
 /**
@@ -1054,7 +1052,7 @@
  * APR_EINTR is never returned.
  * </PRE>
  */
-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
@@ -1063,8 +1061,7 @@
  * @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
@@ -1074,7 +1071,7 @@
  * @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);
 
 
 /**
@@ -1096,7 +1093,7 @@
  * APR_EINTR is never returned.
  * </PRE>
  */
-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
@@ -1120,7 +1117,7 @@
  * </PRE>
  * @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
@@ -1133,7 +1130,7 @@
  *   t < 0  -- read and write calls block
  * </PRE>
  */
-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
@@ -1144,7 +1141,7 @@
  * @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);
 
 
 
@@ -1185,7 +1182,7 @@
  * 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
@@ -1204,7 +1201,7 @@
  *         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
@@ -1219,7 +1216,7 @@
  *         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
@@ -1229,7 +1226,7 @@
   \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);
 
 SWITCH_DECLARE(switch_status_t) switch_match_glob(const char *pattern, switch_array_header_t **result, switch_memory_pool_t *p);
 SWITCH_DECLARE(switch_status_t) switch_socket_addr_get(switch_sockaddr_t **sa, switch_bool_t remote, switch_socket_t *sock);

Modified: freeswitch/trunk/src/include/switch_bitpack.h
==============================================================================
--- freeswitch/trunk/src/include/switch_bitpack.h	(original)
+++ freeswitch/trunk/src/include/switch_bitpack.h	Tue May 27 00:30:03 2008
@@ -106,7 +106,7 @@
 			pack->cur++;
 		} else {
 			switch_byte_t mask = SWITCH_BITS_PER_BYTE - pack->over;
-			switch_assert(mask < 8); /* if pack->over this will allways be true */
+			switch_assert(mask < 8);	/* if pack->over this will allways be true */
 			this_byte &= SWITCH_REVERSE_BITPACKED_MASKS[mask];
 			this_byte >>= mask;
 

Modified: freeswitch/trunk/src/include/switch_buffer.h
==============================================================================
--- freeswitch/trunk/src/include/switch_buffer.h	(original)
+++ freeswitch/trunk/src/include/switch_buffer.h	Tue May 27 00:30:03 2008
@@ -122,7 +122,8 @@
  * \param datalen amount of data to be written
  * \return int amount of buffer used after the write, or 0 if no space available
  */
-SWITCH_DECLARE(switch_size_t) switch_buffer_write(_In_ switch_buffer_t *buffer, _In_bytecount_(datalen) const void *data, _In_ switch_size_t datalen);
+SWITCH_DECLARE(switch_size_t) switch_buffer_write(_In_ switch_buffer_t *buffer, _In_bytecount_(datalen)
+												  const void *data, _In_ switch_size_t datalen);
 
 /*! \brief Remove data from the buffer
  * \param buffer any buffer of type switch_buffer_t
@@ -142,7 +143,8 @@
  */
 SWITCH_DECLARE(void) switch_buffer_destroy(switch_buffer_t **buffer);
 
-SWITCH_DECLARE(switch_size_t) switch_buffer_zwrite(_In_ switch_buffer_t *buffer, _In_bytecount_(datalen) const void *data, _In_ switch_size_t datalen);
+SWITCH_DECLARE(switch_size_t) switch_buffer_zwrite(_In_ switch_buffer_t *buffer, _In_bytecount_(datalen)
+												   const void *data, _In_ switch_size_t datalen);
 
 /** @} */
 

Modified: freeswitch/trunk/src/include/switch_caller.h
==============================================================================
--- freeswitch/trunk/src/include/switch_caller.h	(original)
+++ freeswitch/trunk/src/include/switch_caller.h	Tue May 27 00:30:03 2008
@@ -140,8 +140,7 @@
   \return a new extension object allocated from the session's memory pool
 */
 SWITCH_DECLARE(switch_caller_extension_t *) switch_caller_extension_new(_In_ switch_core_session_t *session,
-																		_In_z_ const char *extension_name,
-																		_In_z_ const char *extension_number);
+																		_In_z_ const char *extension_name, _In_z_ const char *extension_number);
 
 /*!
   \brief Add an application (instruction) to the given extension
@@ -152,8 +151,7 @@
 */
 SWITCH_DECLARE(void) switch_caller_extension_add_application(_In_ switch_core_session_t *session,
 															 _In_ switch_caller_extension_t *caller_extension,
-															 _In_z_ const char *application_name,
-															 _In_z_ const char *extra_data);
+															 _In_z_ const char *application_name, _In_z_ const char *extra_data);
 
 
 /*!
@@ -162,8 +160,8 @@
   \param name the name
   \note this function is meant for situations where the name paramater is the contents of the variable
 */
-_Check_return_ _Ret_opt_z_ SWITCH_DECLARE(const char *) switch_caller_get_field_by_name(_In_ switch_caller_profile_t *caller_profile,
-																						_In_z_ const char *name);
+	 _Check_return_ _Ret_opt_z_ SWITCH_DECLARE(const char *) switch_caller_get_field_by_name(_In_ switch_caller_profile_t *caller_profile,
+																							 _In_z_ const char *name);
 
 /*!
   \brief Create a new caller profile object
@@ -191,8 +189,7 @@
 																	_In_opt_z_ const char *aniii,
 																	_In_opt_z_ const char *rdnis,
 																	_In_opt_z_ const char *source,
-																	_In_opt_z_ const char *context,
-																	_In_opt_z_ const char *destination_number);
+																	_In_opt_z_ const char *context, _In_opt_z_ const char *destination_number);
 
 /*!
   \brief Clone an existing caller profile object
@@ -216,8 +213,7 @@
 */
 
 SWITCH_DECLARE(void) switch_caller_profile_event_set_data(_In_ switch_caller_profile_t *caller_profile,
-														  _In_opt_z_ const char *prefix,
-														  _In_ switch_event_t *event);
+														  _In_opt_z_ const char *prefix, _In_ switch_event_t *event);
 
 SWITCH_END_EXTERN_C
 /** @} */

Modified: freeswitch/trunk/src/include/switch_channel.h
==============================================================================
--- freeswitch/trunk/src/include/switch_channel.h	(original)
+++ freeswitch/trunk/src/include/switch_channel.h	Tue May 27 00:30:03 2008
@@ -438,7 +438,8 @@
 */
 SWITCH_DECLARE(switch_status_t) switch_channel_dequeue_dtmf(_In_ switch_channel_t *channel, _In_ switch_dtmf_t *dtmf);
 SWITCH_DECLARE(void) switch_channel_flush_dtmf(_In_ switch_channel_t *channel);
-SWITCH_DECLARE(switch_size_t) switch_channel_dequeue_dtmf_string(_In_ switch_channel_t *channel, _Out_opt_bytecapcount_(len) char *dtmf_str, _In_ switch_size_t len);
+SWITCH_DECLARE(switch_size_t) switch_channel_dequeue_dtmf_string(_In_ switch_channel_t *channel, _Out_opt_bytecapcount_(len)
+																 char *dtmf_str, _In_ switch_size_t len);
 
 /*!
   \brief Render the name of the provided state enum
@@ -469,7 +470,8 @@
   \note it's necessary to test if the return val is the same as the input and free the string if it is not.
 */
 SWITCH_DECLARE(char *) switch_channel_expand_variables(_In_ switch_channel_t *channel, _In_ const char *in);
-SWITCH_DECLARE(char *) switch_channel_build_param_string(_In_ switch_channel_t *channel, _In_opt_ switch_caller_profile_t *caller_profile, _In_opt_ const char *prefix);
+SWITCH_DECLARE(char *) switch_channel_build_param_string(_In_ switch_channel_t *channel, _In_opt_ switch_caller_profile_t *caller_profile,
+														 _In_opt_ const char *prefix);
 SWITCH_DECLARE(switch_status_t) switch_channel_set_timestamps(_In_ switch_channel_t *channel);
 
 #define switch_channel_stop_broadcast(_channel)	if (switch_channel_test_flag(_channel, CF_BROADCAST)) switch_channel_set_flag(_channel, CF_BREAK | CF_STOP_BROADCAST)

Modified: freeswitch/trunk/src/include/switch_config.h
==============================================================================
--- freeswitch/trunk/src/include/switch_config.h	(original)
+++ freeswitch/trunk/src/include/switch_config.h	Tue May 27 00:30:03 2008
@@ -88,13 +88,13 @@
   \param file_path path to the file
   \return 1 (true) on success 0 (false) on failure
 */
-SWITCH_DECLARE(int) switch_config_open_file(switch_config_t * cfg, char *file_path);
+SWITCH_DECLARE(int) switch_config_open_file(switch_config_t *cfg, char *file_path);
 
 /*!
   \brief Close a previously opened configuration file
   \param cfg (switch_config_t *) config handle to use
 */
-SWITCH_DECLARE(void) switch_config_close_file(switch_config_t * cfg);
+SWITCH_DECLARE(void) switch_config_close_file(switch_config_t *cfg);
 
 /*!
   \brief Retrieve next name/value pair from configuration file
@@ -102,7 +102,7 @@
   \param var pointer to aim at the new variable name
   \param val pointer to aim at the new value
 */
-SWITCH_DECLARE(int) switch_config_next_pair(switch_config_t * cfg, char **var, char **val);
+SWITCH_DECLARE(int) switch_config_next_pair(switch_config_t *cfg, char **var, char **val);
 
 SWITCH_END_EXTERN_C
 /** @} */

Modified: freeswitch/trunk/src/include/switch_console.h
==============================================================================
--- freeswitch/trunk/src/include/switch_console.h	(original)
+++ freeswitch/trunk/src/include/switch_console.h	Tue May 27 00:30:03 2008
@@ -52,7 +52,6 @@
 	s.raw_write_function = switch_console_stream_raw_write;				\
 	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
 */

Modified: freeswitch/trunk/src/include/switch_core.h
==============================================================================
--- freeswitch/trunk/src/include/switch_core.h	(original)
+++ freeswitch/trunk/src/include/switch_core.h	Tue May 27 00:30:03 2008
@@ -43,7 +43,7 @@
 SWITCH_BEGIN_EXTERN_C
 #define SWITCH_MAX_CORE_THREAD_SESSION_OBJS 128
 #define SWITCH_MAX_STREAMS 128
-struct switch_core_time_duration {
+	struct switch_core_time_duration {
 	uint32_t mms;
 	uint32_t ms;
 	uint32_t sec;
@@ -132,9 +132,7 @@
 SWITCH_DECLARE(switch_status_t) switch_core_media_bug_add(_In_ switch_core_session_t *session,
 														  _In_ switch_media_bug_callback_t callback,
 														  _In_opt_ void *user_data,
-														  _In_ time_t stop_time,
-														  _In_ switch_media_bug_flag_t flags,
-														  _Out_ switch_media_bug_t **new_bug);
+														  _In_ time_t stop_time, _In_ switch_media_bug_flag_t flags, _Out_ switch_media_bug_t **new_bug);
 /*!
   \brief Obtain private data from a media bug
   \param bug the bug to get the data from
@@ -220,9 +218,8 @@
   \return SWITCH_STATUS_SUCCESS if the operation was a success
 */
 SWITCH_DECLARE(switch_status_t) switch_core_port_allocator_new(_In_ switch_port_t start,
-								   _In_ switch_port_t end,
-								   _In_ switch_port_flag_t flags,
-								   _Out_ switch_core_port_allocator_t **new_allocator);
+															   _In_ switch_port_t end,
+															   _In_ switch_port_flag_t flags, _Out_ switch_core_port_allocator_t **new_allocator);
 
 /*!
   \brief Get a port from the port allocator
@@ -406,7 +403,8 @@
 #define switch_core_permanent_alloc(_memory) switch_core_perform_permanent_alloc(_memory, __FILE__, __SWITCH_FUNC__, __LINE__)
 
 
-SWITCH_DECLARE(void *) switch_core_perform_alloc(_In_ switch_memory_pool_t *pool, _In_ switch_size_t memory, _In_z_ const char *file, _In_z_ const char *func, _In_ int line);
+SWITCH_DECLARE(void *) switch_core_perform_alloc(_In_ switch_memory_pool_t *pool, _In_ switch_size_t memory, _In_z_ const char *file,
+												 _In_z_ const char *func, _In_ int line);
 
 /*! 
   \brief Allocate memory directly from a memory pool
@@ -416,7 +414,8 @@
 */
 #define switch_core_alloc(_pool, _mem) switch_core_perform_alloc(_pool, _mem, __FILE__, __SWITCH_FUNC__, __LINE__)
 
-_Ret_ SWITCH_DECLARE(void *) switch_core_perform_session_alloc(_In_ switch_core_session_t *session, _In_ switch_size_t memory, const char *file, const char *func, int line);
+	 _Ret_ SWITCH_DECLARE(void *) switch_core_perform_session_alloc(_In_ switch_core_session_t *session, _In_ switch_size_t memory, const char *file,
+																	const char *func, int line);
 
 /*! 
   \brief Allocate memory from a session's pool
@@ -429,7 +428,7 @@
 
 
 
-SWITCH_DECLARE(char *) switch_core_perform_permanent_strdup(_In_z_ const char *todup,  _In_z_ const char *file, _In_z_ const char *func, _In_ int line);
+SWITCH_DECLARE(char *) switch_core_perform_permanent_strdup(_In_z_ const char *todup, _In_z_ const char *file, _In_z_ const char *func, _In_ int line);
 
 /*! 
   \brief Copy a string using permanent memory allocation
@@ -439,7 +438,8 @@
 #define switch_core_permanent_strdup(_todup) switch_core_perform_permanent_strdup(_todup, __FILE__, __SWITCH_FUNC__, __LINE__)
 
 
-SWITCH_DECLARE(char *) switch_core_perform_session_strdup(_In_ switch_core_session_t *session, _In_z_ const char *todup, _In_z_ const char *file, _In_z_ const char *func, _In_ int line);
+SWITCH_DECLARE(char *) switch_core_perform_session_strdup(_In_ switch_core_session_t *session, _In_z_ const char *todup, _In_z_ const char *file,
+														  _In_z_ const char *func, _In_ int line);
 
 /*! 
   \brief Copy a string using memory allocation from a session's pool
@@ -450,7 +450,8 @@
 #define switch_core_session_strdup(_session, _todup) switch_core_perform_session_strdup(_session, _todup, __FILE__, __SWITCH_FUNC__, __LINE__)
 
 
-SWITCH_DECLARE(char *) switch_core_perform_strdup(_In_ switch_memory_pool_t *pool, _In_z_ const char *todup, _In_z_ const char *file, _In_z_ const char *func, _In_ int line);
+SWITCH_DECLARE(char *) switch_core_perform_strdup(_In_ switch_memory_pool_t *pool, _In_z_ const char *todup, _In_z_ const char *file,
+												  _In_z_ const char *func, _In_ int line);
 
 /*! 
   \brief Copy a string using memory allocation from a given pool
@@ -542,7 +543,7 @@
   \param session the session to retrieve from
   \return a pointer to the channel object
 */
-_Ret_ SWITCH_DECLARE(switch_channel_t *) switch_core_session_get_channel(_In_ switch_core_session_t *session);
+	 _Ret_ SWITCH_DECLARE(switch_channel_t *) switch_core_session_get_channel(_In_ switch_core_session_t *session);
 
 /*! 
   \brief Signal a session's state machine thread that a state change has occured
@@ -620,7 +621,8 @@
   \param indication the indication message to pass
   \return SWITCH_STATUS_SUCCESS if the message was passed
 */
-SWITCH_DECLARE(switch_status_t) switch_core_session_pass_indication(_In_ switch_core_session_t *session, _In_ switch_core_session_message_types_t indication);
+SWITCH_DECLARE(switch_status_t) switch_core_session_pass_indication(_In_ switch_core_session_t *session,
+																	_In_ switch_core_session_message_types_t indication);
 
 /*! 
   \brief Queue an indication message on a session
@@ -628,7 +630,8 @@
   \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(_In_ switch_core_session_t *session, _In_ switch_core_session_message_types_t indication);
+SWITCH_DECLARE(switch_status_t) switch_core_session_queue_indication(_In_ switch_core_session_t *session,
+																	 _In_ switch_core_session_message_types_t indication);
 
 /*! 
   \brief DE-Queue an message on a given session
@@ -656,17 +659,14 @@
 SWITCH_DECLARE(switch_app_log_t *) switch_core_session_get_app_log(_In_ switch_core_session_t *session);
 
 SWITCH_DECLARE(switch_status_t) switch_core_session_exec(_In_ switch_core_session_t *session,
-														 _In_ const switch_application_interface_t *application_interface,
-														 _In_opt_z_ const char *arg);
+														 _In_ const switch_application_interface_t *application_interface, _In_opt_z_ const char *arg);
 
 SWITCH_DECLARE(switch_status_t) switch_core_session_execute_application(_In_ switch_core_session_t *session,
-																		_In_ const char *app,
-																		_In_opt_z_ const char *arg);
+																		_In_ const char *app, _In_opt_z_ const char *arg);
 
 SWITCH_DECLARE(switch_status_t) switch_core_session_execute_exten(_In_ switch_core_session_t *session,
 																  _In_z_ const char *exten,
-																  _In_opt_z_ const char *dialplan,
-																  _In_opt_z_ const char *context);
+																  _In_opt_z_ const char *dialplan, _In_opt_z_ const char *context);
 
 /*! 
   \brief Send an event to a session translating it to it's native message format
@@ -721,8 +721,7 @@
   \param obj an arguement
 */
 SWITCH_DECLARE(void) switch_core_session_launch_thread(_In_ switch_core_session_t *session,
-													   _In_ void *(*func) (switch_thread_t *, void *),
-													   _In_opt_ void *obj);
+													   _In_ void *(*func) (switch_thread_t *, void *), _In_opt_ void *obj);
 
 /*! 
   \brief Signal a thread using a thread session to terminate
@@ -737,8 +736,7 @@
   \param thread_session the thread_session to use
 */
 SWITCH_DECLARE(void) switch_core_service_session(_In_ switch_core_session_t *session,
-												 _In_ switch_core_thread_session_t *thread_session,
-												 _In_ int stream_id);
+												 _In_ switch_core_thread_session_t *thread_session, _In_ int stream_id);
 
 /*! 
   \brief Request an outgoing session spawned from an existing session using a desired endpoing module
@@ -756,13 +754,11 @@
 																		 _In_z_ const char *endpoint_name,
 																		 _In_ switch_caller_profile_t *caller_profile,
 																		 _Inout_ switch_core_session_t **new_session,
-																		 _Inout_ switch_memory_pool_t **pool,
-																		 _In_ switch_originate_flag_t flags);
+																		 _Inout_ switch_memory_pool_t **pool, _In_ switch_originate_flag_t flags);
 
 SWITCH_DECLARE(switch_call_cause_t) switch_core_session_resurrect_channel(_In_z_ const char *endpoint_name,
 																		  _Inout_ switch_core_session_t **new_session,
-																		  _Inout_ switch_memory_pool_t **pool,
-																		  _In_ void *data);
+																		  _Inout_ switch_memory_pool_t **pool, _In_ void *data);
 
 /*! 
   \brief Receive a message on a given session
@@ -837,7 +833,8 @@
   \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(_In_ switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags, int stream_id);
+SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(_In_ switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags,
+															   int stream_id);
 
 /*! 
   \brief Read a video frame from a session
@@ -847,7 +844,8 @@
   \param stream_id which logical media channel to use
   \return SWITCH_STATUS_SUCCESS a if the frame was read
 */
-SWITCH_DECLARE(switch_status_t) switch_core_session_read_video_frame(_In_ switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags, int stream_id);
+SWITCH_DECLARE(switch_status_t) switch_core_session_read_video_frame(_In_ switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags,
+																	 int stream_id);
 
 /*! 
   \brief Write a video frame to a session
@@ -857,7 +855,8 @@
   \param stream_id which logical media channel to use
   \return SWITCH_STATUS_SUCCESS a if the frame was written
 */
-SWITCH_DECLARE(switch_status_t) switch_core_session_write_video_frame(_In_ switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags, int stream_id);
+SWITCH_DECLARE(switch_status_t) switch_core_session_write_video_frame(_In_ switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags,
+																	  int stream_id);
 
 /*! 
   \brief Reset the buffers and resampler on a session
@@ -874,7 +873,8 @@
   \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(_In_ switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags, int stream_id);
+SWITCH_DECLARE(switch_status_t) switch_core_session_write_frame(_In_ switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags,
+																int stream_id);
 
 
 SWITCH_DECLARE(switch_status_t) switch_core_session_perform_kill_channel(_In_ switch_core_session_t *session,
@@ -916,7 +916,7 @@
   \param pool the pool to use for the new hash
   \return SWITCH_STATUS_SUCCESS if the hash is created
 */
-SWITCH_DECLARE(switch_status_t) switch_core_hash_init(_Out_ switch_hash_t ** hash, _In_ switch_memory_pool_t *pool);
+SWITCH_DECLARE(switch_status_t) switch_core_hash_init(_Out_ switch_hash_t **hash, _In_ switch_memory_pool_t *pool);
 
 /*! 
   \brief Destroy an existing hash table
@@ -933,7 +933,7 @@
   \return SWITCH_STATUS_SUCCESS if the data is added
   \note the string key must be a constant or a dynamic string
 */
-SWITCH_DECLARE(switch_status_t) switch_core_hash_insert(_In_ switch_hash_t * hash, _In_z_ const char *key, _In_opt_ const void *data);
+SWITCH_DECLARE(switch_status_t) switch_core_hash_insert(_In_ switch_hash_t *hash, _In_z_ const char *key, _In_opt_ const void *data);
 
 /*! 
   \brief Insert data into a hash
@@ -944,7 +944,8 @@
   \return SWITCH_STATUS_SUCCESS if the data is added
   \note the string key must be a constant or a dynamic string
 */
-SWITCH_DECLARE(switch_status_t) switch_core_hash_insert_locked(_In_ switch_hash_t * hash, _In_z_ const char *key, _In_opt_ const void *data, _In_ switch_mutex_t *mutex);
+SWITCH_DECLARE(switch_status_t) switch_core_hash_insert_locked(_In_ switch_hash_t *hash, _In_z_ const char *key, _In_opt_ const void *data,
+															   _In_ switch_mutex_t *mutex);
 
 /*! 
   \brief Delete data from a hash based on desired key
@@ -952,7 +953,7 @@
   \param key the key from which to delete the data
   \return SWITCH_STATUS_SUCCESS if the data is deleted
 */
-SWITCH_DECLARE(switch_status_t) switch_core_hash_delete(_In_ switch_hash_t * hash, _In_z_ const char *key);
+SWITCH_DECLARE(switch_status_t) switch_core_hash_delete(_In_ switch_hash_t *hash, _In_z_ const char *key);
 
 /*! 
   \brief Delete data from a hash based on desired key
@@ -961,7 +962,7 @@
   \param mutex optional mutex to lock
   \return SWITCH_STATUS_SUCCESS if the data is deleted
 */
-SWITCH_DECLARE(switch_status_t) switch_core_hash_delete_locked(_In_ switch_hash_t * hash, _In_z_ const char *key, _In_ switch_mutex_t *mutex);
+SWITCH_DECLARE(switch_status_t) switch_core_hash_delete_locked(_In_ switch_hash_t *hash, _In_z_ const char *key, _In_ switch_mutex_t *mutex);
 
 /*! 
   \brief Retrieve data from a given hash
@@ -969,7 +970,7 @@
   \param key the key to retrieve
   \return a pointer to the data held in the key
 */
-SWITCH_DECLARE(void *) switch_core_hash_find(_In_ switch_hash_t * hash, _In_z_ const char *key);
+SWITCH_DECLARE(void *) switch_core_hash_find(_In_ switch_hash_t *hash, _In_z_ const char *key);
 
 
 /*! 
@@ -979,11 +980,12 @@
   \param mutex optional mutex to lock
   \return a pointer to the data held in the key
 */
-SWITCH_DECLARE(void *) switch_core_hash_find_locked(_In_ switch_hash_t * hash, _In_z_ const char *key, _In_ switch_mutex_t *mutex);
+SWITCH_DECLARE(void *) switch_core_hash_find_locked(_In_ switch_hash_t *hash, _In_z_ const char *key, _In_ switch_mutex_t *mutex);
 
 SWITCH_DECLARE(switch_hash_index_t *) switch_hash_first(char *depricate_me, _In_ switch_hash_t *hash);
 SWITCH_DECLARE(switch_hash_index_t *) switch_hash_next(_In_ switch_hash_index_t *hi);
-SWITCH_DECLARE(void) switch_hash_this(_In_ switch_hash_index_t *hi, _Out_opt_ptrdiff_cap_(klen) const void **key, _Out_opt_ switch_ssize_t *klen, _Out_ void **val);
+SWITCH_DECLARE(void) switch_hash_this(_In_ switch_hash_index_t *hi, _Out_opt_ptrdiff_cap_(klen)
+									  const void **key, _Out_opt_ switch_ssize_t *klen, _Out_ void **val);
 
 ///\}
 
@@ -999,7 +1001,8 @@
   \param pool the memory pool to use for allocation
   \return
 */
-SWITCH_DECLARE(switch_status_t) switch_core_timer_init(switch_timer_t *timer, const 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, const char *timer_name, int interval, int samples,
+													   switch_memory_pool_t *pool);
 
 /*! 
   \brief Wait for one cycle on an existing timer
@@ -1078,7 +1081,7 @@
 														 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);
+														 void *encoded_data, uint32_t *encoded_data_len, uint32_t *encoded_rate, unsigned int *flag);
 
 /*! 
   \brief Decode data using a codec handle
@@ -1099,7 +1102,7 @@
 														 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);
+														 void *decoded_data, uint32_t *decoded_data_len, uint32_t *decoded_rate, unsigned int *flag);
 
 /*! 
   \brief Destroy an initalized codec handle
@@ -1214,9 +1217,7 @@
 															  _In_ switch_file_handle_t *fh,
 															  _In_z_ const char *file_path,
 															  _In_ uint8_t channels,
-															  _In_ uint32_t rate,
-															  _In_ unsigned int flags,
-															  _In_opt_ switch_memory_pool_t *pool);
+															  _In_ uint32_t rate, _In_ unsigned int flags, _In_opt_ switch_memory_pool_t *pool);
 
 /*! 
   \brief Open a media file using file format modules
@@ -1303,10 +1304,9 @@
 */
 SWITCH_DECLARE(switch_status_t) switch_core_speech_open(_In_ switch_speech_handle_t *sh,
 														const char *module_name,
-														const char *voice_name, 
-														_In_ unsigned int rate, 
-														_In_ unsigned int interval, 
-														switch_speech_flag_t *flags, _In_ switch_memory_pool_t *pool);
+														const char *voice_name,
+														_In_ unsigned int rate,
+														_In_ unsigned int interval, switch_speech_flag_t *flags, _In_ switch_memory_pool_t *pool);
 /*! 
   \brief Feed text to the TTS module
   \param sh the speech handle to feed
@@ -1356,7 +1356,7 @@
   \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);
+															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
@@ -1379,11 +1379,7 @@
 */
 SWITCH_DECLARE(switch_status_t) switch_core_asr_open(switch_asr_handle_t *ah,
 													 const char *module_name,
-													 const char *codec,
-													 int rate,
-													 const char *dest,
-													 switch_asr_flag_t *flags,
-													 switch_memory_pool_t *pool);
+													 const char *codec, int rate, const char *dest, switch_asr_flag_t *flags, switch_memory_pool_t *pool);
 
 /*!
   \brief Close an asr handle
@@ -1587,7 +1583,7 @@
   \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, int32_t * val);
+SWITCH_DECLARE(int32_t) switch_core_session_ctl(switch_session_ctl_t cmd, int32_t *val);
 
 /*!
   \brief Get the output console

Modified: freeswitch/trunk/src/include/switch_core_event_hook.h
==============================================================================
--- freeswitch/trunk/src/include/switch_core_event_hook.h	(original)
+++ freeswitch/trunk/src/include/switch_core_event_hook.h	Tue May 27 00:30:03 2008
@@ -32,8 +32,7 @@
 #define SWITCH_EVENT_HOOKS_H
 
 #include <switch.h>
-SWITCH_BEGIN_EXTERN_C 
-typedef struct switch_io_event_hooks switch_io_event_hooks_t;
+SWITCH_BEGIN_EXTERN_C typedef struct switch_io_event_hooks switch_io_event_hooks_t;
 
 typedef struct switch_io_event_hook_outgoing_channel switch_io_event_hook_outgoing_channel_t;
 typedef struct switch_io_event_hook_receive_message switch_io_event_hook_receive_message_t;
@@ -48,7 +47,7 @@
 typedef struct switch_io_event_hook_state_change switch_io_event_hook_state_change_t;
 typedef struct switch_io_event_hook_resurrect_session switch_io_event_hook_resurrect_session_t;
 typedef switch_status_t (*switch_outgoing_channel_hook_t)
-(switch_core_session_t *, switch_event_t *, switch_caller_profile_t *, switch_core_session_t *, switch_originate_flag_t);
+                               (switch_core_session_t *, switch_event_t *, switch_caller_profile_t *, switch_core_session_t *, switch_originate_flag_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 **, switch_io_flag_t, int);
@@ -59,7 +58,7 @@
 typedef switch_status_t (*switch_send_dtmf_hook_t) (switch_core_session_t *, const switch_dtmf_t *, switch_dtmf_direction_t direction);
 typedef switch_status_t (*switch_recv_dtmf_hook_t) (switch_core_session_t *, const switch_dtmf_t *, switch_dtmf_direction_t direction);
 typedef switch_status_t (*switch_state_change_hook_t) (switch_core_session_t *);
-typedef switch_call_cause_t (*switch_resurrect_session_hook_t)(switch_core_session_t **, switch_memory_pool_t **, void *);
+typedef switch_call_cause_t (*switch_resurrect_session_hook_t) (switch_core_session_t **, switch_memory_pool_t **, void *);
 
 /*! \brief Node in which to store custom receive message callback hooks */
 struct switch_io_event_hook_outgoing_channel {
@@ -210,7 +209,7 @@
 			last = ptr;													\
 		}																\
 		return SWITCH_STATUS_FALSE;										\
-	}																	
+	}
 
 
 NEW_HOOK_DECL_ADD_P(outgoing_channel);

Modified: freeswitch/trunk/src/include/switch_cpp.h
==============================================================================
--- freeswitch/trunk/src/include/switch_cpp.h	(original)
+++ freeswitch/trunk/src/include/switch_cpp.h	Tue May 27 00:30:03 2008
@@ -8,41 +8,28 @@
 #ifdef DOH
 }
 #endif
-
 #include <switch.h>
-
 #define this_check(x) do { if (!this) { switch_log_printf(SWITCH_CHANNEL_LOG,SWITCH_LOG_ERROR, "object is not initalized\n"); return x;}} while(0)
 #define this_check_void() do { if (!this) { switch_log_printf(SWITCH_CHANNEL_LOG,SWITCH_LOG_ERROR, "object is not initalized\n");}} while(0)
-
 #define sanity_check(x) do { if (!(session && allocated)) { switch_log_printf(SWITCH_CHANNEL_LOG,SWITCH_LOG_ERROR, "session is not initalized\n"); return x;}} while(0)
 #define sanity_check_noreturn do { if (!(session && allocated)) { switch_log_printf(SWITCH_CHANNEL_LOG,SWITCH_LOG_ERROR, "session is not initalized\n"); return;}} while(0)
 #define init_vars() do { allocated = 0; session = NULL; channel = NULL; uuid = NULL; tts_name = NULL; voice_name = NULL; xml_cdr_text = NULL; memset(&args, 0, sizeof(args)); ap = NULL; caller_profile.source = "mod_unknown";  caller_profile.dialplan = ""; caller_profile.context = ""; caller_profile.caller_id_name = ""; caller_profile.caller_id_number = ""; caller_profile.network_addr = ""; caller_profile.ani = ""; caller_profile.aniii = ""; caller_profile.rdnis = "";  caller_profile.username = ""; on_hangup = NULL; memset(&cb_state, 0, sizeof(cb_state)); hook_state = CS_NEW; } while(0)
-
-
-//
-// C++ Interface: switch_to_cpp_mempool
-//
-// Description: This class allows for overloading the new operator to allocate from a switch_memory_pool_t
-//
-// Author: Yossi Neiman <freeswitch at cartissolutions.com>, (C) 2007
-//
-// Copyright: See COPYING file that comes with this distribution
-//
-
+//// C++ Interface: switch_to_cpp_mempool//// Description: This class allows for overloading the new operator to allocate from a switch_memory_pool_t//// Author: Yossi Neiman <freeswitch at cartissolutions.com>, (C) 2007//// Copyright: See COPYING file that comes with this distribution//
 #if 0
 #ifndef SWITCHTOMEMPOOL
 #define SWITCHTOMEMPOOL
 class SwitchToMempool {
-	public:
-		SwitchToMempool() { }
-		SwitchToMempool(switch_memory_pool_t *mem) { memorypool = mem; }
-		void *operator new(switch_size_t num_bytes, switch_memory_pool_t *mem)
-		{
-			void *ptr = switch_core_alloc(mem, (switch_size_t) num_bytes);
-			return ptr;
-		}
-	protected:
-		switch_memory_pool_t *memorypool;
+  public:
+	SwitchToMempool() {
+	} SwitchToMempool(switch_memory_pool_t *mem) {
+		memorypool = mem;
+	}
+	void *operator  new(switch_size_t num_bytes, switch_memory_pool_t *mem) {
+		void *ptr = switch_core_alloc(mem, (switch_size_t) num_bytes);
+		return ptr;
+	}
+  protected:
+	switch_memory_pool_t *memorypool;
 };
 #endif
 #endif
@@ -66,135 +53,130 @@
 SWITCH_DECLARE(void) consoleLog(char *level_str, char *msg);
 SWITCH_DECLARE(void) consoleCleanLog(char *msg);
 
-class CoreSession;
-
-class IVRMenu {
- protected:
-	switch_ivr_menu_t *menu;
-	switch_memory_pool_t *pool;
- public:
-	SWITCH_DECLARE_CONSTRUCTOR IVRMenu(IVRMenu *main,
-									   const char *name,
-									   const char *greeting_sound,
-									   const char *short_greeting_sound,
-									   const char *invalid_sound,
-									   const char *exit_sound,
-									   const char *confirm_macro,
-									   const char *confirm_key,
-									   int confirm_attempts,
-									   int inter_timeout,
-									   int digit_len,
-									   int timeout,
-									   int max_failures
-									   );
-	virtual SWITCH_DECLARE_CONSTRUCTOR ~IVRMenu();
-	SWITCH_DECLARE(void) bindAction(char *action, const char *arg, const char *bind);
-	SWITCH_DECLARE(void) execute(CoreSession *session, const char *name);
-};
-
-
-class API {
- protected:
-	char *last_data;
- public:
-	SWITCH_DECLARE_CONSTRUCTOR API(void);
-	virtual SWITCH_DECLARE_CONSTRUCTOR ~API();
-	SWITCH_DECLARE(const char *) execute(const char *command, const char *data);
-	SWITCH_DECLARE(const char *) executeString(const char *command);
-};
+	 class CoreSession;
 
-
-typedef struct input_callback_state {
-    void *function;           // pointer to the language specific callback function
-                              // eg, PyObject *pyfunc
-    void *threadState;        // pointer to the language specific thread state
-                              // eg, PyThreadState *threadState
-    void *extra;              // currently used to store a switch_file_handle_t
-    char *funcargs;           // extra string that will be passed to callback function 
-} input_callback_state_t;
-
-typedef enum {
-	S_HUP = (1 << 0),
-	S_FREE = (1 << 1),
-	S_RDLOCK = (1 << 2)
-} session_flag_t;
-
-class Stream {
- protected: 
-	switch_stream_handle_t mystream;
-	switch_stream_handle_t *stream_p;
-	int mine;
- public: 
-	SWITCH_DECLARE_CONSTRUCTOR Stream(void);
-	SWITCH_DECLARE_CONSTRUCTOR Stream(switch_stream_handle_t *);
-	virtual SWITCH_DECLARE_CONSTRUCTOR ~Stream();
-	SWITCH_DECLARE(void) write(const char *data);	
-	SWITCH_DECLARE(const char *)get_data(void);
-};
-
-class Event {
- protected:
- public:
-	switch_event_t *event;
-	char *serialized_string;
-	int mine;
-
-	SWITCH_DECLARE_CONSTRUCTOR Event(const char *type, const char *subclass_name = NULL);
-	SWITCH_DECLARE_CONSTRUCTOR Event(switch_event_t *wrap_me, int free_me=0);
-	virtual SWITCH_DECLARE_CONSTRUCTOR ~Event();
-	SWITCH_DECLARE(const char *)serialize(const char *format=NULL);
-	SWITCH_DECLARE(bool) setPriority(switch_priority_t priority = SWITCH_PRIORITY_NORMAL);
-	SWITCH_DECLARE(const char *)getHeader(char *header_name);
-	SWITCH_DECLARE(char *)getBody(void);
-	SWITCH_DECLARE(const char *)getType(void);
-	SWITCH_DECLARE(bool) addBody(const char *value);
-	SWITCH_DECLARE(bool) addHeader(const char *header_name, const char *value);
-	SWITCH_DECLARE(bool) delHeader(const char *header_name);
-	SWITCH_DECLARE(bool) fire(void);
-	
-};
-
-
-class CoreSession {
- protected:
-	switch_input_args_t args; // holds ptr to cb function and input_callback_state struct
-                              // which has a language specific callback function
-	switch_input_args_t *ap;  // ptr to args .. (is this really needed?)
-	switch_caller_profile_t caller_profile; // avoid passing so many args to originate, 
-	                                        // instead set them here first
-	char *xml_cdr_text;
-	char *uuid;
-	char *tts_name;
-	char *voice_name;
-	void store_file_handle(switch_file_handle_t *fh);
-	void *on_hangup; // language specific callback function, cast as void * 
-	switch_file_handle_t local_fh;
-	switch_file_handle_t *fhp;
-	char dtmf_buf[512];
-
- public:
-	SWITCH_DECLARE_CONSTRUCTOR CoreSession();
-	SWITCH_DECLARE_CONSTRUCTOR CoreSession(char *uuid);
-	SWITCH_DECLARE_CONSTRUCTOR CoreSession(switch_core_session_t *new_session);
-	SWITCH_DECLARE_CONSTRUCTOR ~CoreSession();
-	switch_core_session_t *session;
-	switch_channel_t *channel;
-	unsigned int flags;
-	int allocated;
-	input_callback_state cb_state; // callback state, always pointed to by the buf
-                                   // field in this->args
-	switch_channel_state_t hook_state; // store hookstate for on_hangup callback
-
-	SWITCH_DECLARE(int) answer();
-	SWITCH_DECLARE(int) preAnswer();
-	SWITCH_DECLARE(void) hangup(char *cause = "normal_clearing");
-	SWITCH_DECLARE(void) setVariable(char *var, char *val);
-	SWITCH_DECLARE(void) setPrivate(char *var, void *val);
-	SWITCH_DECLARE(void *)getPrivate(char *var);
-	SWITCH_DECLARE(const char *)getVariable(char *var);
-	SWITCH_DECLARE(switch_status_t) process_callback_result(char *result);	
-	SWITCH_DECLARE(void) say(const char *tosay, const char *module_name, const char *say_type, const char *say_method);
-	SWITCH_DECLARE(void) sayPhrase(const char *phrase_name, const char *phrase_data = "", const char *phrase_lang = NULL);
+	 class IVRMenu {
+	   protected:
+		 switch_ivr_menu_t *menu;
+		 switch_memory_pool_t *pool;
+	   public:
+		 SWITCH_DECLARE_CONSTRUCTOR IVRMenu(IVRMenu * main,
+											const char *name,
+											const char *greeting_sound,
+											const char *short_greeting_sound,
+											const char *invalid_sound,
+											const char *exit_sound,
+											const char *confirm_macro,
+											const char *confirm_key,
+											int confirm_attempts, int inter_timeout, int digit_len, int timeout, int max_failures);
+		 virtual SWITCH_DECLARE_CONSTRUCTOR ~ IVRMenu();
+		 SWITCH_DECLARE(void) bindAction(char *action, const char *arg, const char *bind);
+		 SWITCH_DECLARE(void) execute(CoreSession * session, const char *name);
+	 };
+
+
+	 class API {
+	   protected:
+		 char *last_data;
+	   public:
+		 SWITCH_DECLARE_CONSTRUCTOR API(void);
+		 virtual SWITCH_DECLARE_CONSTRUCTOR ~ API();
+		 SWITCH_DECLARE(const char *) execute(const char *command, const char *data);
+		 SWITCH_DECLARE(const char *) executeString(const char *command);
+	 };
+
+
+	 typedef struct input_callback_state {
+		 void *function;		// pointer to the language specific callback function
+		 // eg, PyObject *pyfunc
+		 void *threadState;		// pointer to the language specific thread state
+		 // eg, PyThreadState *threadState
+		 void *extra;			// currently used to store a switch_file_handle_t
+		 char *funcargs;		// extra string that will be passed to callback function 
+	 } input_callback_state_t;
+
+	 typedef enum {
+		 S_HUP = (1 << 0),
+		 S_FREE = (1 << 1),
+		 S_RDLOCK = (1 << 2)
+	 } session_flag_t;
+
+	 class Stream {
+	   protected:
+		 switch_stream_handle_t mystream;
+		 switch_stream_handle_t *stream_p;
+		 int mine;
+	   public:
+		 SWITCH_DECLARE_CONSTRUCTOR Stream(void);
+		 SWITCH_DECLARE_CONSTRUCTOR Stream(switch_stream_handle_t *);
+		 virtual SWITCH_DECLARE_CONSTRUCTOR ~ Stream();
+		 SWITCH_DECLARE(void) write(const char *data);
+		 SWITCH_DECLARE(const char *) get_data(void);
+	 };
+
+	 class Event {
+	   protected:
+	   public:
+		 switch_event_t *event;
+		 char *serialized_string;
+		 int mine;
+
+		 SWITCH_DECLARE_CONSTRUCTOR Event(const char *type, const char *subclass_name = NULL);
+		 SWITCH_DECLARE_CONSTRUCTOR Event(switch_event_t *wrap_me, int free_me = 0);
+		 virtual SWITCH_DECLARE_CONSTRUCTOR ~ Event();
+		 SWITCH_DECLARE(const char *) serialize(const char *format = NULL);
+		 SWITCH_DECLARE(bool) setPriority(switch_priority_t priority = SWITCH_PRIORITY_NORMAL);
+		 SWITCH_DECLARE(const char *) getHeader(char *header_name);
+		 SWITCH_DECLARE(char *) getBody(void);
+		 SWITCH_DECLARE(const char *) getType(void);
+		 SWITCH_DECLARE(bool) addBody(const char *value);
+		 SWITCH_DECLARE(bool) addHeader(const char *header_name, const char *value);
+		 SWITCH_DECLARE(bool) delHeader(const char *header_name);
+		 SWITCH_DECLARE(bool) fire(void);
+
+	 };
+
+
+	 class CoreSession {
+	   protected:
+		 switch_input_args_t args;	// holds ptr to cb function and input_callback_state struct
+		 // which has a language specific callback function
+		 switch_input_args_t *ap;	// ptr to args .. (is this really needed?)
+		 switch_caller_profile_t caller_profile;	// avoid passing so many args to originate, 
+		 // instead set them here first
+		 char *xml_cdr_text;
+		 char *uuid;
+		 char *tts_name;
+		 char *voice_name;
+		 void store_file_handle(switch_file_handle_t *fh);
+		 void *on_hangup;		// language specific callback function, cast as void * 
+		 switch_file_handle_t local_fh;
+		 switch_file_handle_t *fhp;
+		 char dtmf_buf[512];
+
+	   public:
+		 SWITCH_DECLARE_CONSTRUCTOR CoreSession();
+		 SWITCH_DECLARE_CONSTRUCTOR CoreSession(char *uuid);
+		 SWITCH_DECLARE_CONSTRUCTOR CoreSession(switch_core_session_t *new_session);
+		 SWITCH_DECLARE_CONSTRUCTOR ~ CoreSession();
+		 switch_core_session_t *session;
+		 switch_channel_t *channel;
+		 unsigned int flags;
+		 int allocated;
+		 input_callback_state cb_state;	// callback state, always pointed to by the buf
+		 // field in this->args
+		 switch_channel_state_t hook_state;	// store hookstate for on_hangup callback
+
+		 SWITCH_DECLARE(int) answer();
+		 SWITCH_DECLARE(int) preAnswer();
+		 SWITCH_DECLARE(void) hangup(char *cause = "normal_clearing");
+		 SWITCH_DECLARE(void) setVariable(char *var, char *val);
+		 SWITCH_DECLARE(void) setPrivate(char *var, void *val);
+		 SWITCH_DECLARE(void *) getPrivate(char *var);
+		 SWITCH_DECLARE(const char *) getVariable(char *var);
+		 SWITCH_DECLARE(switch_status_t) process_callback_result(char *result);
+		 SWITCH_DECLARE(void) say(const char *tosay, const char *module_name, const char *say_type, const char *say_method);
+		 SWITCH_DECLARE(void) sayPhrase(const char *phrase_name, const char *phrase_data = "", const char *phrase_lang = NULL);
 
 	/** \brief Record to a file
 	 * \param file_name 
@@ -203,14 +185,14 @@
 	 *        to be considered silence (500 is a good starting point).
 	 * \param <[silence_secs]> seconds of silence to interrupt the record.
 	 */
-	SWITCH_DECLARE(int) recordFile(char *file_name, int max_len=0, int silence_threshold=0, int silence_secs=0);
+		 SWITCH_DECLARE(int) recordFile(char *file_name, int max_len = 0, int silence_threshold = 0, int silence_secs = 0);
 
 
 	/** \brief Set attributes of caller data for purposes of outgoing calls
 	 * \param var - the variable name, eg, "caller_id_name"
 	 * \param val - the data to set, eg, "bob"
 	 */
-	SWITCH_DECLARE(void) setCallerData(char *var, char *val);
+		 SWITCH_DECLARE(void) setCallerData(char *var, char *val);
 
 	/** \brief Originate a call to a destination
 	 *
@@ -222,9 +204,7 @@
 	 * \return an int status code indicating success or failure
 	 *
 	 */
-	SWITCH_DECLARE(int) originate(CoreSession *a_leg_session, 
-				  char *dest, 
-				  int timeout=60);
+		 SWITCH_DECLARE(int) originate(CoreSession * a_leg_session, char *dest, int timeout = 60);
 
 
 	/** \brief set a DTMF callback function
@@ -235,16 +215,16 @@
 	 * certain other methods are executing.
 	 *
 	 */
-	SWITCH_DECLARE(void) setDTMFCallback(void *cbfunc, char *funcargs);
+		 SWITCH_DECLARE(void) setDTMFCallback(void *cbfunc, char *funcargs);
 
-	SWITCH_DECLARE(int) speak(char *text);
-	SWITCH_DECLARE(void) set_tts_parms(char *tts_name, char *voice_name);
+		 SWITCH_DECLARE(int) speak(char *text);
+		 SWITCH_DECLARE(void) set_tts_parms(char *tts_name, char *voice_name);
 
 	/**
 	 * For timeout milliseconds, call the dtmf function set previously
 	 * by setDTMFCallback whenever a dtmf or event is received
 	 */
-	SWITCH_DECLARE(int) collectDigits(int timeout);
+		 SWITCH_DECLARE(int) collectDigits(int timeout);
 
 	/** 
 	 * Collect up to maxdigits digits worth of digits
@@ -253,20 +233,13 @@
 	 * (see mod_python.i).  This does NOT call any callbacks upon
 	 * receiving dtmf digits.  For that, use collectDigits.
 	 */
-	SWITCH_DECLARE(char *) getDigits(
-								  int maxdigits, 
-								  char *terminators, 
-								  int timeout);
-	
-	SWITCH_DECLARE(int) transfer(char *extensions, char *dialplan, char *context);
+		 SWITCH_DECLARE(char *) getDigits(int maxdigits, char *terminators, int timeout);
+
+		 SWITCH_DECLARE(int) transfer(char *extensions, char *dialplan, char *context);
+
 
+		 SWITCH_DECLARE(char *) read(int min_digits, int max_digits, const char *prompt_audio_file, int timeout, const char *valid_terminators);
 
-	SWITCH_DECLARE(char *) read(int min_digits,
-								int max_digits,
-								const char *prompt_audio_file,
-								int timeout,
-								const char *valid_terminators);
-	
 	/** \brief Play a file into channel and collect dtmfs
 	 * 
 	 * See API docs in switch_ivr.h: switch_play_and_get_digits(..)
@@ -275,14 +248,10 @@
 	 *       setDTMFCallback(..) as it uses its own internal callback
 	 *       handler.
 	 */
-	SWITCH_DECLARE(char *) playAndGetDigits(int min_digits, 
-						 int max_digits, 
-						 int max_tries, 
-						 int timeout, 
-						 char *terminators,
-						 char *audio_files, 
-						 char *bad_input_audio_files, 
-						 char *digits_regex);
+		 SWITCH_DECLARE(char *) playAndGetDigits(int min_digits,
+												 int max_digits,
+												 int max_tries,
+												 int timeout, char *terminators, char *audio_files, char *bad_input_audio_files, char *digits_regex);
 
 	/** \brief Play a file that resides on disk into the channel
 	 *
@@ -292,53 +261,56 @@
 	 * \return an int status code indicating success or failure
 	 *
 	 */
-	SWITCH_DECLARE(int) streamFile(char *file, int starting_sample_count=0);
+		 SWITCH_DECLARE(int) streamFile(char *file, int starting_sample_count = 0);
 
 	/** \brief flush any pending events
 	 */
-	SWITCH_DECLARE(int) flushEvents();
+		 SWITCH_DECLARE(int) flushEvents();
 
 	/** \brief flush any pending digits
 	 */
-	SWITCH_DECLARE(int) flushDigits();
+		 SWITCH_DECLARE(int) flushDigits();
 
-	SWITCH_DECLARE(int) setAutoHangup(bool val);
+		 SWITCH_DECLARE(int) setAutoHangup(bool val);
 
 	/** \brief Set the hangup callback function
 	 * \param hangup_func - language specific function ptr cast into void *
 	 */
-	SWITCH_DECLARE(void) setHangupHook(void *hangup_func);
+		 SWITCH_DECLARE(void) setHangupHook(void *hangup_func);
 
-	SWITCH_DECLARE(bool) ready();
+		 SWITCH_DECLARE(bool) ready();
 
-	SWITCH_DECLARE(void) execute(char *app, char *data=NULL);
+		 SWITCH_DECLARE(void) execute(char *app, char *data = NULL);
 
-	SWITCH_DECLARE(void) sendEvent(Event *sendME);
+		 SWITCH_DECLARE(void) sendEvent(Event * sendME);
 
-	SWITCH_DECLARE(void) setEventData(Event *e);
-	SWITCH_DECLARE(char *) getXMLCDR();
+		 SWITCH_DECLARE(void) setEventData(Event * e);
+		 SWITCH_DECLARE(char *) getXMLCDR();
 
-	virtual bool begin_allow_threads() = 0;
-	virtual bool end_allow_threads() = 0;
+		 virtual bool begin_allow_threads() = 0;
+		 virtual bool end_allow_threads() = 0;
 
 	/** \brief Get the uuid of this session	
 	 * \return the uuid of this session
 	 */
-	char* get_uuid() const { return uuid; };
+		 char *get_uuid() const {
+			 return uuid;
+		 };
 
 	/** \brief Get the callback function arguments associated with this session
 	 * \return a const reference to the callback function arguments
 	 */
-	const switch_input_args_t& get_cb_args() const { return args; };
+		 const switch_input_args_t &get_cb_args() const {
+			 return args;
+		 };
 
 	/** \brief Callback to the language specific hangup callback
 	 */
-	virtual void check_hangup_hook() = 0;
+		 virtual void check_hangup_hook() = 0;
 
-	virtual switch_status_t run_dtmf_callback(void *input, 
-											  switch_input_type_t itype) = 0;
+		 virtual switch_status_t run_dtmf_callback(void *input, switch_input_type_t itype) = 0;
 
-};
+	 };
 
 
 /* ---- functions not bound to CoreSession instance ----- */
@@ -351,7 +323,7 @@
  * NOTE: the stuff regarding the dtmf callback might be completely
  *       wrong and has not been reviewed or tested
  */
-SWITCH_DECLARE(void) bridge(CoreSession &session_a, CoreSession &session_b);
+SWITCH_DECLARE(void) bridge(CoreSession & session_a, CoreSession & session_b);
 
 
 /** \brief the actual hangup hook called back by freeswitch core
@@ -360,11 +332,8 @@
  */
 SWITCH_DECLARE_NONSTD(switch_status_t) hanguphook(switch_core_session_t *session);
 
-SWITCH_DECLARE_NONSTD(switch_status_t) dtmf_callback(switch_core_session_t *session, 
-							  void *input, 
-							  switch_input_type_t itype, 
-							  void *buf,  
-							  unsigned int buflen);
+SWITCH_DECLARE_NONSTD(switch_status_t) dtmf_callback(switch_core_session_t *session,
+													 void *input, switch_input_type_t itype, void *buf, unsigned int buflen);
 
 
 #ifdef __cplusplus
@@ -382,4 +351,3 @@
  * For VIM:
  * vim:set softtabstop=4 shiftwidth=4 tabstop=4 expandtab:
  */
-

Modified: freeswitch/trunk/src/include/switch_event.h
==============================================================================
--- freeswitch/trunk/src/include/switch_event.h	(original)
+++ freeswitch/trunk/src/include/switch_event.h	Tue May 27 00:30:03 2008
@@ -156,7 +156,7 @@
   \param header_name the name of the header to read
   \return the value of the requested header
 */
-_Ret_opt_z_ SWITCH_DECLARE(char *) switch_event_get_header(switch_event_t *event, char *header_name);
+	 _Ret_opt_z_ SWITCH_DECLARE(char *) switch_event_get_header(switch_event_t *event, char *header_name);
 
 #define switch_event_get_header_nil(e, h) switch_str_nil(switch_event_get_header(e,h))
 
@@ -292,7 +292,7 @@
 #endif
 SWITCH_DECLARE(char *) switch_event_expand_headers(switch_event_t *event, const char *in);
 
-SWITCH_DECLARE(switch_status_t) switch_event_create_pres_in_detailed(_In_z_ char *file, _In_z_ char *func, _In_ int line, 
+SWITCH_DECLARE(switch_status_t) switch_event_create_pres_in_detailed(_In_z_ char *file, _In_z_ char *func, _In_ int line,
 																	 _In_z_ const char *proto, _In_z_ const char *login,
 																	 _In_z_ const char *from, _In_z_ const char *from_domain,
 																	 _In_z_ const char *status, _In_z_ const char *event_type,
@@ -344,7 +344,7 @@
 */
 #define switch_event_fire_data(event, data) switch_event_fire_detailed(__FILE__, (char * )__SWITCH_FUNC__, __LINE__, event, data)
 
-SWITCH_DECLARE(char *) switch_event_build_param_string(switch_event_t *event, const char *prefix,switch_hash_t* vars_map);
+SWITCH_DECLARE(char *) switch_event_build_param_string(switch_event_t *event, const char *prefix, switch_hash_t *vars_map);
 
 ///\}
 

Modified: freeswitch/trunk/src/include/switch_frame.h
==============================================================================
--- freeswitch/trunk/src/include/switch_frame.h	(original)
+++ freeswitch/trunk/src/include/switch_frame.h	Tue May 27 00:30:03 2008
@@ -40,7 +40,7 @@
 
 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 */

Modified: freeswitch/trunk/src/include/switch_ivr.h
==============================================================================
--- freeswitch/trunk/src/include/switch_ivr.h	(original)
+++ freeswitch/trunk/src/include/switch_ivr.h	Tue May 27 00:30:03 2008
@@ -41,9 +41,7 @@
 
 #include <switch.h>
 
-SWITCH_BEGIN_EXTERN_C
-
-struct switch_unicast_conninfo {
+SWITCH_BEGIN_EXTERN_C struct switch_unicast_conninfo {
 	switch_core_session_t *session;
 	switch_codec_t read_codec;
 	switch_frame_t write_frame;
@@ -73,13 +71,10 @@
  */
 
 SWITCH_DECLARE(switch_status_t) switch_ivr_deactivate_unicast(switch_core_session_t *session);
-SWITCH_DECLARE(switch_status_t) switch_ivr_activate_unicast(switch_core_session_t *session, 
+SWITCH_DECLARE(switch_status_t) switch_ivr_activate_unicast(switch_core_session_t *session,
 															char *local_ip,
 															switch_port_t local_port,
-															char *remote_ip,
-															switch_port_t remote_port,
-															char *transport,
-															char *flags);
+															char *remote_ip, switch_port_t remote_port, char *transport, char *flags);
 
 /*!
   \brief Generate an XML CDR report.
@@ -88,7 +83,7 @@
   \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);
 SWITCH_DECLARE(int) switch_ivr_set_xml_profile_data(switch_xml_t xml, switch_caller_profile_t *caller_profile, int off);
 SWITCH_DECLARE(int) switch_ivr_set_xml_chan_vars(switch_xml_t xml, switch_channel_t *channel, int off);
 
@@ -143,11 +138,9 @@
 SWITCH_DECLARE(switch_status_t) switch_ivr_collect_digits_count(switch_core_session_t *session,
 																char *buf,
 																switch_size_t buflen,
-																switch_size_t maxdigits, 
-																const char *terminators, char *terminator, 
-																uint32_t first_timeout,
-																uint32_t digit_timeout,
-																uint32_t abs_timeout);
+																switch_size_t maxdigits,
+																const char *terminators, char *terminator,
+																uint32_t first_timeout, uint32_t digit_timeout, uint32_t abs_timeout);
 
 /*!
   \brief Engage background Speech detection on a session
@@ -161,9 +154,7 @@
 */
 SWITCH_DECLARE(switch_status_t) switch_ivr_detect_speech(switch_core_session_t *session,
 														 const char *mod_name,
-														 const char *grammar,
-														 const char *path,
-														 const char *dest, switch_asr_handle_t *ah);
+														 const char *grammar, const char *path, const char *dest, switch_asr_handle_t *ah);
 
 /*!
   \brief Stop background Speech detection on a session
@@ -221,10 +212,8 @@
   \param flags tweak read-mux, write-mux and dtmf
   \return SWITCH_STATUS_SUCESS if all is well
 */
-SWITCH_DECLARE(switch_status_t) switch_ivr_eavesdrop_session(switch_core_session_t *session, 
-															 const char *uuid, 
-															 const char *require_group, 
-															 switch_eavesdrop_flag_t flags);
+SWITCH_DECLARE(switch_status_t) switch_ivr_eavesdrop_session(switch_core_session_t *session,
+															 const char *uuid, const char *require_group, switch_eavesdrop_flag_t flags);
 
 /*!
   \brief displace the media for a session with the audio from a file
@@ -307,10 +296,9 @@
   \param data optional data for appliaction
   \return SWITCH_STATUS_SUCCESS if all is well
 */
-SWITCH_DECLARE(switch_status_t) switch_ivr_tone_detect_session(switch_core_session_t *session, 
+SWITCH_DECLARE(switch_status_t) switch_ivr_tone_detect_session(switch_core_session_t *session,
 															   const char *key, const char *tone_spec,
-															   const char *flags, time_t timeout,
-															   const char *app, const char *data);
+															   const char *flags, time_t timeout, const char *app, const char *data);
 
 
 
@@ -322,7 +310,8 @@
   \param args arguements to pass for callbacks etc
   \return SWITCH_STATUS_SUCCESS if all is well
 */
-SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *session, switch_file_handle_t *fh, const char *file, switch_input_args_t *args);
+SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *session, switch_file_handle_t *fh, const char *file,
+													 switch_input_args_t *args);
 
 SWITCH_DECLARE(switch_status_t) switch_ivr_gentones(switch_core_session_t *session, char *script, int32_t loops, switch_input_args_t *args);
 
@@ -337,9 +326,7 @@
 */
 SWITCH_DECLARE(switch_status_t) switch_ivr_record_file(_In_ switch_core_session_t *session,
 													   _In_ switch_file_handle_t *fh,
-													   _In_z_ const char *file,
-													   _In_opt_ switch_input_args_t *args,
-													   _In_ uint32_t limit);
+													   _In_z_ const char *file, _In_opt_ switch_input_args_t *args, _In_ uint32_t limit);
 
 
 /*!
@@ -407,8 +394,7 @@
 													 const switch_state_handler_table_t *table,
 													 const char *cid_name_override,
 													 const char *cid_num_override,
-													 switch_caller_profile_t *caller_profile_override,
-													 switch_originate_flag_t flags);
+													 switch_caller_profile_t *caller_profile_override, switch_originate_flag_t flags);
 
 /*!
   \brief Bridge Audio from one session to another
@@ -439,7 +425,8 @@
   \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(_In_ switch_core_session_t *session, const char *extension, const char *dialplan, const char *context);
+SWITCH_DECLARE(switch_status_t) switch_ivr_session_transfer(_In_ switch_core_session_t *session, const char *extension, const char *dialplan,
+															const char *context);
 
 /*!
   \brief Transfer an existing session to another location in the future
@@ -560,14 +547,14 @@
   \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
   \param parser a pointer to the parser object
   \return SWITCH_STATUS_SUCCESS if all is well 
 */
-SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_parser_destroy(switch_ivr_digit_stream_parser_t * parser);
+SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_parser_destroy(switch_ivr_digit_stream_parser_t *parser);
 
 /*!
   \brief Create a new digit stream object
@@ -575,14 +562,14 @@
   \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
   \param stream a pointer to the stream object
   \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_destroy(switch_ivr_digit_stream_t * stream);
+SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_destroy(switch_ivr_digit_stream_t *stream);
 
 /*!
   \brief Set a digit string to action mapping
@@ -591,7 +578,7 @@
   \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
@@ -599,7 +586,7 @@
   \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
@@ -608,14 +595,14 @@
   \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
   \param stream a pointer to the parser stream object created by switch_ivr_digit_stream_new
   \return SWITCH_STATUS_SUCCESS if all is well 
 */
-SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_reset(switch_ivr_digit_stream_t * stream);
+SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_reset(switch_ivr_digit_stream_t *stream);
 
 /*!
   \brief Set a digit string terminator
@@ -623,7 +610,7 @@
   \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);
 
 
 /******************************************************************************************************/
@@ -655,7 +642,7 @@
 		 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 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;
 /******************************************************************************************************/
@@ -680,20 +667,17 @@
  *\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 *invalid_sound,
-													 const char *exit_sound,
-													 const char *confirm_macro,
-													 const char *confirm_key,
-													 int confirm_attempts,
-													 int inter_timeout,
-													 int digit_len,
-													 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 *invalid_sound,
+														  const char *exit_sound,
+														  const char *confirm_macro,
+														  const char *confirm_key,
+														  int confirm_attempts,
+														  int inter_timeout, int digit_len, int timeout, int max_failures, switch_memory_pool_t *pool);
 
 /*!
  *\brief switch_ivr_menu_bind_action: Bind a keystroke to an action.
@@ -703,7 +687,8 @@
  *\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);
 
 
 /*!
@@ -717,8 +702,8 @@
  *\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);
 
 
 /*!
@@ -729,14 +714,14 @@
  *\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;
@@ -748,10 +733,10 @@
  *\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);
 
-SWITCH_DECLARE(switch_status_t) switch_ivr_menu_str2action(const char *action_name, switch_ivr_action_t *action);
+	 SWITCH_DECLARE(switch_status_t) switch_ivr_menu_str2action(const char *action_name, switch_ivr_action_t *action);
 
 /*!
  *\param xml_menu_ctx The XML menu parser context previously created by switch_ivr_menu_stack_xml_init
@@ -759,46 +744,45 @@
  *\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,
-																	 const 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,
+																		  const 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, const char *macro_name, const char *data, const char *lang,
-														switch_input_args_t *args);
-SWITCH_DECLARE(void) switch_ivr_delay_echo(switch_core_session_t *session, uint32_t delay_ms);
-SWITCH_DECLARE(switch_status_t) switch_ivr_find_bridged_uuid(const char *uuid, char *b_uuid, switch_size_t blen);
-SWITCH_DECLARE(void) switch_ivr_intercept_session(switch_core_session_t *session, const char *uuid, switch_bool_t bleg);
-SWITCH_DECLARE(void) switch_ivr_park_session(switch_core_session_t *session);
-SWITCH_DECLARE(switch_status_t) switch_ivr_wait_for_answer(switch_core_session_t *session, switch_core_session_t *peer_session);
-
-SWITCH_DECLARE(switch_status_t) switch_ivr_read(switch_core_session_t *session,
-												uint32_t min_digits,
-												uint32_t max_digits,
-												const char *prompt_audio_file,
-												const char *var_name,
-												char *digit_buffer, 
-												switch_size_t digit_buffer_length,
-												uint32_t timeout,
-												const char *valid_terminators);
-
-SWITCH_DECLARE(switch_status_t) switch_ivr_bind_dtmf_meta_session(switch_core_session_t *session, uint32_t key, 
-																  switch_bind_flag_t bind_flags, const char *app);
-SWITCH_DECLARE(switch_status_t) switch_ivr_unbind_dtmf_meta_session(switch_core_session_t *session);
-SWITCH_DECLARE(switch_status_t) switch_ivr_soft_hold(switch_core_session_t *session, const char *unhold_key, const char *moh_a, const char *moh_b);
-SWITCH_DECLARE(switch_status_t) switch_ivr_say(switch_core_session_t *session, const char *tosay, const char *module_name, const char *say_type, const char *say_method, switch_input_args_t *args);
+	 SWITCH_DECLARE(switch_status_t) switch_ivr_phrase_macro(switch_core_session_t *session, const char *macro_name, const char *data, const char *lang,
+															 switch_input_args_t *args);
+	 SWITCH_DECLARE(void) switch_ivr_delay_echo(switch_core_session_t *session, uint32_t delay_ms);
+	 SWITCH_DECLARE(switch_status_t) switch_ivr_find_bridged_uuid(const char *uuid, char *b_uuid, switch_size_t blen);
+	 SWITCH_DECLARE(void) switch_ivr_intercept_session(switch_core_session_t *session, const char *uuid, switch_bool_t bleg);
+	 SWITCH_DECLARE(void) switch_ivr_park_session(switch_core_session_t *session);
+	 SWITCH_DECLARE(switch_status_t) switch_ivr_wait_for_answer(switch_core_session_t *session, switch_core_session_t *peer_session);
+
+	 SWITCH_DECLARE(switch_status_t) switch_ivr_read(switch_core_session_t *session,
+													 uint32_t min_digits,
+													 uint32_t max_digits,
+													 const char *prompt_audio_file,
+													 const char *var_name,
+													 char *digit_buffer,
+													 switch_size_t digit_buffer_length, uint32_t timeout, const char *valid_terminators);
+
+	 SWITCH_DECLARE(switch_status_t) switch_ivr_bind_dtmf_meta_session(switch_core_session_t *session, uint32_t key,
+																	   switch_bind_flag_t bind_flags, const char *app);
+	 SWITCH_DECLARE(switch_status_t) switch_ivr_unbind_dtmf_meta_session(switch_core_session_t *session);
+	 SWITCH_DECLARE(switch_status_t) switch_ivr_soft_hold(switch_core_session_t *session, const char *unhold_key, const char *moh_a, const char *moh_b);
+	 SWITCH_DECLARE(switch_status_t) switch_ivr_say(switch_core_session_t *session, const char *tosay, const char *module_name, const char *say_type,
+													const char *say_method, switch_input_args_t *args);
 
-SWITCH_DECLARE(switch_say_method_t) switch_ivr_get_say_method_by_name(const char *name);
-SWITCH_DECLARE(switch_say_type_t) switch_ivr_get_say_type_by_name(const char *name);
+	 SWITCH_DECLARE(switch_say_method_t) switch_ivr_get_say_method_by_name(const char *name);
+	 SWITCH_DECLARE(switch_say_type_t) switch_ivr_get_say_type_by_name(const char *name);
 
 /** @} */
 
-SWITCH_END_EXTERN_C
+	 SWITCH_END_EXTERN_C
 #endif
 /* For Emacs:
  * Local Variables:

Modified: freeswitch/trunk/src/include/switch_loadable_module.h
==============================================================================
--- freeswitch/trunk/src/include/switch_loadable_module.h	(original)
+++ freeswitch/trunk/src/include/switch_loadable_module.h	Tue May 27 00:30:03 2008
@@ -128,9 +128,8 @@
 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_bool_t runtime);
-																	 
+																	 switch_module_shutdown_t switch_module_shutdown, switch_bool_t runtime);
+
 
 /*!
   \brief Retrieve the timer interface by it's registered name
@@ -259,7 +258,7 @@
   \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( switch_loadable_module_interface_t **module_interface, char *filename);
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(switch_loadable_module_interface_t **module_interface, char *filename);
 SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void);
 
 /*!
@@ -317,44 +316,43 @@
 	}
 
 
-static inline void switch_core_codec_add_implementation(switch_memory_pool_t *pool,
-                                                        switch_codec_interface_t *codec_interface,
-                                                        /*! enumeration defining the type of the codec */
-                                                        const switch_codec_type_t codec_type,
-                                                        /*! the IANA code number */
-                                                        switch_payload_t ianacode,
-                                                        /*! the IANA code name */
-                                                        const char *iananame,
-                                                        /*! default fmtp to send (can be overridden by the init function) */
-                                                        char *fmtp,
-                                                        /*! samples transferred per second */
-                                                        uint32_t samples_per_second,
-                                                        /*! actual samples transferred per second for those who are not moron g722 RFC writers*/
-                                                        uint32_t actual_samples_per_second,
-                                                        /*! bits transferred per second */
-                                                        int bits_per_second,
-                                                        /*! number of microseconds that denote one frame */
-                                                        int microseconds_per_frame,
-                                                        /*! number of samples that denote one frame */
-                                                        uint32_t samples_per_frame,
-                                                        /*! number of bytes that denote one frame decompressed */
-                                                        uint32_t bytes_per_frame,
-                                                        /*! number of bytes that denote one frame compressed */
-                                                        uint32_t encoded_bytes_per_frame,
-                                                        /*! number of channels represented */
-                                                        uint8_t number_of_channels,
-                                                        /*! number of frames to send in one netowrk packet */
-                                                        int pref_frames_per_packet,
-                                                        /*! 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_core_codec_init_func_t init,
-                                                        /*! function to encode raw data into encoded data */
-                                                        switch_core_codec_encode_func_t encode,
-                                                        /*! function to decode encoded data into raw data */
-                                                        switch_core_codec_decode_func_t decode,
-                                                        /*! deinitalize a codec handle using this implementation */
-                                                        switch_core_codec_destroy_func_t destroy)
+	 static inline void switch_core_codec_add_implementation(switch_memory_pool_t *pool, switch_codec_interface_t *codec_interface,
+															 /*! enumeration defining the type of the codec */
+															 const switch_codec_type_t codec_type,
+															 /*! the IANA code number */
+															 switch_payload_t ianacode,
+															 /*! the IANA code name */
+															 const char *iananame,
+															 /*! default fmtp to send (can be overridden by the init function) */
+															 char *fmtp,
+															 /*! samples transferred per second */
+															 uint32_t samples_per_second,
+															 /*! actual samples transferred per second for those who are not moron g722 RFC writers */
+															 uint32_t actual_samples_per_second,
+															 /*! bits transferred per second */
+															 int bits_per_second,
+															 /*! number of microseconds that denote one frame */
+															 int microseconds_per_frame,
+															 /*! number of samples that denote one frame */
+															 uint32_t samples_per_frame,
+															 /*! number of bytes that denote one frame decompressed */
+															 uint32_t bytes_per_frame,
+															 /*! number of bytes that denote one frame compressed */
+															 uint32_t encoded_bytes_per_frame,
+															 /*! number of channels represented */
+															 uint8_t number_of_channels,
+															 /*! number of frames to send in one netowrk packet */
+															 int pref_frames_per_packet,
+															 /*! 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_core_codec_init_func_t init,
+															 /*! function to encode raw data into encoded data */
+															 switch_core_codec_encode_func_t encode,
+															 /*! function to decode encoded data into raw data */
+															 switch_core_codec_decode_func_t decode,
+															 /*! deinitalize a codec handle using this implementation */
+															 switch_core_codec_destroy_func_t destroy)
 {
 	if (codec_type == SWITCH_CODEC_TYPE_VIDEO || SWITCH_ACCEPTABLE_INTERVAL(microseconds_per_frame / 1000)) {
 		switch_codec_implementation_t *impl = (switch_codec_implementation_t *) switch_core_alloc(pool, sizeof(*impl));

Modified: freeswitch/trunk/src/include/switch_log.h
==============================================================================
--- freeswitch/trunk/src/include/switch_log.h	(original)
+++ freeswitch/trunk/src/include/switch_log.h	Tue May 27 00:30:03 2008
@@ -111,7 +111,7 @@
   \param level the level
   \return the name of the log level
 */
-_Ret_z_  SWITCH_DECLARE(const char *) switch_log_level2str(_In_ switch_log_level_t level);
+	 _Ret_z_ SWITCH_DECLARE(const char *) switch_log_level2str(_In_ switch_log_level_t level);
 
 /*! 
   \brief Return the level number of the specified log level name

Modified: freeswitch/trunk/src/include/switch_module_interfaces.h
==============================================================================
--- freeswitch/trunk/src/include/switch_module_interfaces.h	(original)
+++ freeswitch/trunk/src/include/switch_module_interfaces.h	Tue May 27 00:30:03 2008
@@ -45,8 +45,7 @@
 SWITCH_BEGIN_EXTERN_C
 /*! \brief A table of functions to execute at various states 
 */
-
-typedef enum {
+	typedef enum {
 	SWITCH_SHN_ON_INIT,
 	SWITCH_SHN_ON_ROUTING,
 	SWITCH_SHN_ON_EXECUTE,
@@ -100,7 +99,31 @@
 
 
 typedef switch_call_cause_t (*switch_io_outgoing_channel_t)
-(switch_core_session_t *, switch_event_t *, switch_caller_profile_t *, switch_core_session_t **, switch_memory_pool_t **, switch_originate_flag_t);
+ 
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	    (switch_core_session_t *, switch_event_t *, switch_caller_profile_t *, switch_core_session_t **, switch_memory_pool_t **, switch_originate_flag_t);
 typedef switch_status_t (*switch_io_read_frame_t) (switch_core_session_t *, switch_frame_t **, switch_io_flag_t, int);
 typedef switch_status_t (*switch_io_write_frame_t) (switch_core_session_t *, switch_frame_t *, switch_io_flag_t, int);
 typedef switch_status_t (*switch_io_kill_channel_t) (switch_core_session_t *, int);
@@ -108,9 +131,9 @@
 typedef switch_status_t (*switch_io_receive_message_t) (switch_core_session_t *, switch_core_session_message_t *);
 typedef switch_status_t (*switch_io_receive_event_t) (switch_core_session_t *, switch_event_t *);
 typedef switch_status_t (*switch_io_state_change_t) (switch_core_session_t *);
-typedef	switch_status_t (*switch_io_read_video_frame_t) (switch_core_session_t *, switch_frame_t **, switch_io_flag_t, int);
+typedef switch_status_t (*switch_io_read_video_frame_t) (switch_core_session_t *, switch_frame_t **, switch_io_flag_t, int);
 typedef switch_status_t (*switch_io_write_video_frame_t) (switch_core_session_t *, switch_frame_t *, switch_io_flag_t, int);
-typedef switch_call_cause_t (*switch_io_resurrect_session_t)(switch_core_session_t **, switch_memory_pool_t **, void *);
+typedef switch_call_cause_t (*switch_io_resurrect_session_t) (switch_core_session_t **, switch_memory_pool_t **, void *);
 
 typedef enum {
 	SWITCH_IO_OUTGOING_CHANNEL,
@@ -192,7 +215,7 @@
 	switch_memory_pool_t *memory_pool;
 	/*! private data for loadable modules to store information */
 	void *private_info;
-	/*! remaining time from last call to _check()*/
+	/*! remaining time from last call to _check() */
 	switch_size_t diff;
 	switch_size_t tick;
 };
@@ -346,7 +369,7 @@
 	/*! The Rate */
 	uint32_t rate;
 	char *grammar;
-	/*! module specific param*/
+	/*! module specific param */
 	char *param;
 	/*! the handle's memory pool */
 	switch_memory_pool_t *memory_pool;
@@ -365,7 +388,7 @@
 	/*! 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);
+	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, const char *val);
 	void (*speech_numeric_param_tts) (switch_speech_handle_t *sh, char *param, int val);
@@ -389,7 +412,7 @@
 	uint32_t samples;
 	char voice[80];
 	char *engine;
-	/*! module specific param*/
+	/*! module specific param */
 	char *param;
 	/*! the handle's memory pool */
 	switch_memory_pool_t *memory_pool;
@@ -526,7 +549,7 @@
 	char *fmtp;
 	/*! samples transferred per second */
 	uint32_t samples_per_second;
-	/*! actual samples transferred per second for those who are not moron g722 RFC writers*/
+	/*! actual samples transferred per second for those who are not moron g722 RFC writers */
 	uint32_t actual_samples_per_second;
 	/*! bits transferred per second */
 	int bits_per_second;
@@ -545,13 +568,13 @@
 	/*! 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_core_codec_init_func_t init;
+	switch_core_codec_init_func_t init;
 	/*! function to encode raw data into encoded data */
-    switch_core_codec_encode_func_t encode;
+	switch_core_codec_encode_func_t encode;
 	/*! function to decode encoded data into raw data */
-    switch_core_codec_decode_func_t decode;
+	switch_core_codec_decode_func_t decode;
 	/*! deinitalize a codec handle using this implementation */
-    switch_core_codec_destroy_func_t destroy;
+	switch_core_codec_destroy_func_t destroy;
 	uint32_t codec_id;
 	struct switch_codec_implementation *next;
 };

Modified: freeswitch/trunk/src/include/switch_odbc.h
==============================================================================
--- freeswitch/trunk/src/include/switch_odbc.h	(original)
+++ freeswitch/trunk/src/include/switch_odbc.h	Tue May 27 00:30:03 2008
@@ -44,9 +44,7 @@
 #endif
 #include <sqltypes.h>
 
-SWITCH_BEGIN_EXTERN_C 
-
-struct switch_odbc_handle;
+SWITCH_BEGIN_EXTERN_C struct switch_odbc_handle;
 
 typedef enum {
 	SWITCH_ODBC_STATE_INIT,
@@ -70,7 +68,6 @@
 																	  char *sql, switch_core_db_callback_func_t callback, void *pdata);
 SWITCH_DECLARE(char *) switch_odbc_handle_get_error(switch_odbc_handle_t *handle, SQLHSTMT stmt);
 SWITCH_END_EXTERN_C
-
 #endif
 /* For Emacs:
  * Local Variables:

Modified: freeswitch/trunk/src/include/switch_platform.h
==============================================================================
--- freeswitch/trunk/src/include/switch_platform.h	(original)
+++ freeswitch/trunk/src/include/switch_platform.h	Tue May 27 00:30:03 2008
@@ -59,21 +59,16 @@
  * C4610: struct  can never be instantiated - user defined constructor required
  */
 #pragma warning(disable:4100 4200 4204 4706 4819 4132 4510 4512 4610 4996)
-
 #define SWITCH_HAVE_ODBC 1
-
 #ifdef _MSC_VER
 #  pragma comment(lib, "odbc32.lib")
 #endif
-
 #pragma include_alias(<libteletone.h>,				<../../libs/libteletone/src/libteletone.h>)
 #pragma include_alias(<libteletone_generate.h>,		<../../libs/libteletone/src/libteletone_generate.h>)
 #pragma include_alias(<libteletone_detect.h>,		<../../libs/libteletone/src/libteletone_detect.h>)
-
 #if (_MSC_VER >= 1400)			// VC8+
 #define switch_assert(expr) assert(expr);__analysis_assume( expr )
 #endif
-
 #if (_MSC_VER >= 1400)			// VC8+
 #ifndef _CRT_SECURE_NO_DEPRECATE
 #define _CRT_SECURE_NO_DEPRECATE
@@ -90,7 +85,7 @@
 #undef inline
 #define inline __inline
 #ifndef uint32_t
-typedef unsigned __int8 uint8_t;
+	typedef unsigned __int8 uint8_t;
 typedef unsigned __int16 uint16_t;
 typedef unsigned __int32 uint32_t;
 typedef unsigned __int64 uint64_t;
@@ -187,9 +182,9 @@
 #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
@@ -298,10 +293,9 @@
 #ifndef switch_assert
 #define switch_assert(expr) assert(expr)
 #endif
-
 #ifndef __ATTR_SAL
- /* used for msvc code analysis */
- /* http://msdn2.microsoft.com/en-us/library/ms235402.aspx */
+	/* used for msvc code analysis */
+	/* http://msdn2.microsoft.com/en-us/library/ms235402.aspx */
 #define _In_
 #define _In_z_
 #define _In_opt_z_
@@ -324,8 +318,6 @@
 #define _Out_ptrdiff_cap_(x)
 #define _Out_opt_ptrdiff_cap_(x)
 #endif
-
-
 /* For Emacs:
  * Local Variables:
  * mode:c

Modified: freeswitch/trunk/src/include/switch_rtp.h
==============================================================================
--- freeswitch/trunk/src/include/switch_rtp.h	(original)
+++ freeswitch/trunk/src/include/switch_rtp.h	Tue May 27 00:30:03 2008
@@ -45,9 +45,7 @@
 #define SWITCH_RTP_KEY_LEN 30
 #define SWITCH_RTP_CRYPTO_KEY_32 "AES_CM_128_HMAC_SHA1_32"
 #define SWITCH_RTP_CRYPTO_KEY_80 "AES_CM_128_HMAC_SHA1_80"
-
-
-typedef enum {
+	typedef enum {
 	SWITCH_RTP_CRYPTO_SEND,
 	SWITCH_RTP_CRYPTO_RECV,
 	SWITCH_RTP_CRYPTO_MAX
@@ -72,16 +70,13 @@
 
 SWITCH_DECLARE(switch_status_t) switch_rtp_add_crypto_key(switch_rtp_t *rtp_session,
 														  switch_rtp_crypto_direction_t direction,
-														  uint32_t index,
-														  switch_rtp_crypto_key_type_t type,
-														  unsigned char *key,
-														  switch_size_t keylen);
+														  uint32_t index, switch_rtp_crypto_key_type_t type, unsigned char *key, switch_size_t keylen);
 
 ///\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);
 
 
 SWITCH_DECLARE(void) switch_rtp_get_random(void *buf, uint32_t len);
@@ -130,10 +125,7 @@
 												  switch_payload_t payload,
 												  uint32_t samples_per_interval,
 												  uint32_t ms_per_packet,
-												  switch_rtp_flag_t flags,
-												  char *timer_name, 
-												  const char **err,
-												  switch_memory_pool_t *pool);
+												  switch_rtp_flag_t flags, char *timer_name, const char **err, switch_memory_pool_t *pool);
 
 
 /*!
@@ -158,10 +150,7 @@
 											  switch_payload_t payload,
 											  uint32_t samples_per_interval,
 											  uint32_t ms_per_packet,
-											  switch_rtp_flag_t flags,
-											  char *timer_name,
-											  const char **err,
-											  switch_memory_pool_t *pool);
+											  switch_rtp_flag_t flags, char *timer_name, const char **err, switch_memory_pool_t *pool);
 
 
 /*! 
@@ -296,7 +285,7 @@
   \param io_flags i/o 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_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_io_flag_t io_flags);
 
 /*! 
@@ -341,7 +330,8 @@
   \return the number of bytes read
 */
 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, switch_io_flag_t io_flags);
+														 void **data, uint32_t *datalen, switch_payload_t *payload_type, switch_frame_flag_t *flags,
+														 switch_io_flag_t io_flags);
 
 /*! 
   \brief Read data from a given RTP session without copying
@@ -390,9 +380,7 @@
   \return the number of bytes written
 */
 SWITCH_DECLARE(int) switch_rtp_write_manual(switch_rtp_t *rtp_session,
-											void *data,
-											uint32_t datalen,
-											uint8_t m, switch_payload_t payload, uint32_t ts, switch_frame_flag_t *flags);
+											void *data, uint32_t datalen, uint8_t m, switch_payload_t payload, uint32_t ts, switch_frame_flag_t *flags);
 
 /*! 
   \brief Retrieve the SSRC from a given RTP session

Modified: freeswitch/trunk/src/include/switch_stun.h
==============================================================================
--- freeswitch/trunk/src/include/switch_stun.h	(original)
+++ freeswitch/trunk/src/include/switch_stun.h	Tue May 27 00:30:03 2008
@@ -137,7 +137,7 @@
   \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
@@ -155,7 +155,7 @@
   \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
@@ -174,7 +174,7 @@
   \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

Modified: freeswitch/trunk/src/include/switch_types.h
==============================================================================
--- freeswitch/trunk/src/include/switch_types.h	(original)
+++ freeswitch/trunk/src/include/switch_types.h	Tue May 27 00:30:03 2008
@@ -91,11 +91,9 @@
 #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
-
 #define SWITCH_DEFAULT_DTMF_DURATION 2000
 #define SWITCH_MAX_DTMF_DURATION 192000
 #define SWITCH_DEFAULT_DIR_PERMS SWITCH_FPROT_UREAD | SWITCH_FPROT_UWRITE | SWITCH_FPROT_UEXECUTE | SWITCH_FPROT_GREAD | SWITCH_FPROT_GEXECUTE
-
 #ifdef WIN32
 #define SWITCH_PATH_SEPARATOR "\\"
 #else
@@ -144,7 +142,7 @@
 #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 struct {
 	char digit;
@@ -168,7 +166,7 @@
 typedef enum {
 	SOF_NONE = 0,
 	SOF_NOBLOCK = (1 << 0),
-	SOF_FORKED_DIAL = (1 << 1) 
+	SOF_FORKED_DIAL = (1 << 1)
 } switch_originate_flag_t;
 
 typedef enum {
@@ -185,7 +183,7 @@
 
 typedef enum {
 	SCF_NONE = 0,
-	SCF_USE_SQL = ( 1 << 0),
+	SCF_USE_SQL = (1 << 0),
 	SCF_NO_NEW_SESSIONS = (1 << 1),
 	SCF_SHUTTING_DOWN = (1 << 2),
 	SCF_CRASH_PROT = (1 << 3)
@@ -320,10 +318,10 @@
 
 #define SWITCH_MAX_STACKS 32
 #define SWITCH_THREAD_STACKSIZE 240 * 1024
-#define SWITCH_MAX_INTERVAL 120 /* we only do up to 120ms */
-#define SWITCH_INTERVAL_PAD 10 /* A little extra buffer space to be safe */
+#define SWITCH_MAX_INTERVAL 120	/* we only do up to 120ms */
+#define SWITCH_INTERVAL_PAD 10	/* A little extra buffer space to be safe */
 #define SWITCH_MAX_SAMPLE_LEN 32
-#define SWITCH_BYTES_PER_SAMPLE 2 /* slin is 2 bytes per sample */
+#define SWITCH_BYTES_PER_SAMPLE 2	/* slin is 2 bytes per sample */
 #define SWITCH_RECOMMENDED_BUFFER_SIZE (SWITCH_BYTES_PER_SAMPLE * SWITCH_MAX_SAMPLE_LEN * (SWITCH_MAX_INTERVAL + SWITCH_INTERVAL_PAD))
 #define SWITCH_MAX_CODECS 30
 #define SWITCH_MAX_STATE_HANDLERS 30
@@ -425,29 +423,29 @@
 
 #if __BYTE_ORDER == __BIG_ENDIAN
 typedef struct {
-	unsigned version:2;   /* protocol version       */
-	unsigned p:1;     /* padding flag           */
-	unsigned x:1;     /* header extension flag  */
-	unsigned cc:4;    /* CSRC count             */
-	unsigned m:1;     /* marker bit             */
-	unsigned pt:7;    /* payload type           */
-	unsigned seq:16;      /* sequence number        */
-	unsigned ts:32;       /* timestamp              */
-	unsigned ssrc:32; /* synchronization source */
+	unsigned version:2;			/* protocol version       */
+	unsigned p:1;				/* padding flag           */
+	unsigned x:1;				/* header extension flag  */
+	unsigned cc:4;				/* CSRC count             */
+	unsigned m:1;				/* marker bit             */
+	unsigned pt:7;				/* payload type           */
+	unsigned seq:16;			/* sequence number        */
+	unsigned ts:32;				/* timestamp              */
+	unsigned ssrc:32;			/* synchronization source */
 } switch_rtp_hdr_t;
 
 #else /*  BIG_ENDIAN */
 
 typedef struct {
-	unsigned cc:4;    /* CSRC count             */
-	unsigned x:1;     /* header extension flag  */
-	unsigned p:1;     /* padding flag           */
-	unsigned version:2;   /* protocol version       */
-	unsigned pt:7;    /* payload type           */
-	unsigned m:1;     /* marker bit             */
-	unsigned seq:16;      /* sequence number        */
-	unsigned ts:32;       /* timestamp              */
-	unsigned ssrc:32; /* synchronization source */
+	unsigned cc:4;				/* CSRC count             */
+	unsigned x:1;				/* header extension flag  */
+	unsigned p:1;				/* padding flag           */
+	unsigned version:2;			/* protocol version       */
+	unsigned pt:7;				/* payload type           */
+	unsigned m:1;				/* marker bit             */
+	unsigned seq:16;			/* sequence number        */
+	unsigned ts:32;				/* timestamp              */
+	unsigned ssrc:32;			/* synchronization source */
 } switch_rtp_hdr_t;
 
 #endif
@@ -1210,25 +1208,19 @@
 
 
 typedef switch_status_t (*switch_core_codec_encode_func_t) (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);
 
 
 typedef switch_status_t (*switch_core_codec_decode_func_t) (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);
 
 typedef switch_status_t (*switch_core_codec_init_func_t) (switch_codec_t *, switch_codec_flag_t, const switch_codec_settings_t *codec_settings);
 typedef switch_status_t (*switch_core_codec_destroy_func_t) (switch_codec_t *);
@@ -1255,7 +1247,8 @@
 typedef switch_status_t (*switch_stream_handle_write_function_t) (switch_stream_handle_t *handle, const char *fmt, ...);
 typedef switch_status_t (*switch_stream_handle_raw_write_function_t) (switch_stream_handle_t *handle, uint8_t *data, switch_size_t datalen);
 
-typedef switch_status_t (*switch_api_function_t) (_In_opt_z_ const char *cmd, _In_opt_ switch_core_session_t *session, _In_ switch_stream_handle_t *stream);
+typedef switch_status_t (*switch_api_function_t) (_In_opt_z_ const char *cmd, _In_opt_ switch_core_session_t *session,
+												  _In_ switch_stream_handle_t *stream);
 
 #define SWITCH_STANDARD_API(name) static switch_status_t name (_In_opt_z_ const char *cmd, _In_opt_ switch_core_session_t *session, _In_ switch_stream_handle_t *stream)
 
@@ -1274,9 +1267,9 @@
 												  char *tosay, switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args);
 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,
-													 const char *tag_name, const char *key_name, const char *key_value, switch_event_t *params,
-													 void *user_data);
+typedef switch_xml_t (*switch_xml_search_function_t) (const char *section,
+													  const char *tag_name, const char *key_name, const char *key_value, switch_event_t *params,
+													  void *user_data);
 
 typedef struct switch_hash switch_hash_t;
 struct HashElem;
@@ -1290,9 +1283,9 @@
 #define SWITCH_MODULE_LOAD_ARGS (switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool)
 #define SWITCH_MODULE_RUNTIME_ARGS (void)
 #define SWITCH_MODULE_SHUTDOWN_ARGS (void)
-typedef switch_status_t (*switch_module_load_t) SWITCH_MODULE_LOAD_ARGS ;
-typedef switch_status_t (*switch_module_runtime_t) SWITCH_MODULE_RUNTIME_ARGS ;
-typedef switch_status_t (*switch_module_shutdown_t) SWITCH_MODULE_SHUTDOWN_ARGS ;
+typedef switch_status_t (*switch_module_load_t) SWITCH_MODULE_LOAD_ARGS;
+typedef switch_status_t (*switch_module_runtime_t) SWITCH_MODULE_RUNTIME_ARGS;
+typedef switch_status_t (*switch_module_shutdown_t) SWITCH_MODULE_SHUTDOWN_ARGS;
 #define SWITCH_MODULE_LOAD_FUNCTION(name) switch_status_t name SWITCH_MODULE_LOAD_ARGS
 #define SWITCH_MODULE_RUNTIME_FUNCTION(name) switch_status_t name SWITCH_MODULE_RUNTIME_ARGS
 #define SWITCH_MODULE_SHUTDOWN_FUNCTION(name) switch_status_t name SWITCH_MODULE_SHUTDOWN_ARGS

Modified: freeswitch/trunk/src/include/switch_utils.h
==============================================================================
--- freeswitch/trunk/src/include/switch_utils.h	(original)
+++ freeswitch/trunk/src/include/switch_utils.h	Tue May 27 00:30:03 2008
@@ -54,15 +54,12 @@
 #else
 #define switch_is_file_path(file) (file && ((*file == '/') || strstr(file, SWITCH_URL_SEPARATOR)))
 #endif
-
 /*!
   \brief Test for NULL or zero length string
   \param s the string to test
   \return true value if the string is NULL or zero length
 */
 #define switch_strlen_zero(s) (!s || *s == '\0')
-
-
 static inline switch_bool_t switch_is_moh(const char *s)
 {
 	if (switch_strlen_zero(s) || !strcasecmp(s, "silence") || !strcasecmp(s, "indicate_hold")) {
@@ -78,9 +75,10 @@
 SWITCH_DECLARE(switch_size_t) switch_b64_decode(char *in, char *out, switch_size_t olen);
 SWITCH_DECLARE(char *) switch_amp_encode(char *s, char *buf, switch_size_t len);
 
-static inline switch_bool_t switch_is_digit_string(const char *s) {
+	 static inline switch_bool_t switch_is_digit_string(const char *s)
+{
 
-	while(s && *s) {
+	while (s && *s) {
 		if (*s < 48 || *s > 57) {
 			return SWITCH_FALSE;
 		}
@@ -113,7 +111,8 @@
   \param family the address family to return (AF_INET or AF_INET6)
   \return SWITCH_STATUS_SUCCESSS for success, otherwise failure
 */
-SWITCH_DECLARE(switch_status_t) switch_find_local_ip(_Out_opt_bytecapcount_(len) char *buf, _In_ int len, _In_ int family);
+SWITCH_DECLARE(switch_status_t) switch_find_local_ip(_Out_opt_bytecapcount_(len)
+													 char *buf, _In_ int len, _In_ int family);
 
 /*!
   \brief find the char representation of an ip adress
@@ -205,7 +204,7 @@
 
 #define switch_set_string(_dst, _src) switch_copy_string(_dst, _src, sizeof(_dst))
 
-static inline char *switch_clean_string(char *s)
+	 static inline char *switch_clean_string(char *s)
 {
 	char *p;
 	for (p = s; p && *p; p++) {
@@ -247,11 +246,11 @@
 	}
 
 	S = strdup(s);
-	
+
 	assert(S != NULL);
 
 	for (p = S; p && *p; p++) {
-		*p = (char)toupper(*p);
+		*p = (char) toupper(*p);
 	}
 
 	if (strstr(S, q)) {
@@ -263,9 +262,9 @@
 	assert(Q != NULL);
 
 	for (p = Q; p && *p; p++) {
-		*p = (char)toupper(*p);
+		*p = (char) toupper(*p);
 	}
-	
+
 	if (strstr(s, Q)) {
 		tf = SWITCH_TRUE;
 		goto done;
@@ -275,8 +274,8 @@
 		tf = SWITCH_TRUE;
 		goto done;
 	}
-	
- done:
+
+  done:
 	switch_safe_free(S);
 	switch_safe_free(Q);
 
@@ -345,7 +344,7 @@
   \param ms the number of milliseconds to wait
   \return the requested condition
 */
-SWITCH_DECLARE(int) switch_socket_waitfor(switch_pollfd_t * poll, int ms);
+SWITCH_DECLARE(int) switch_socket_waitfor(switch_pollfd_t *poll, int ms);
 
 /*!
   \brief Create a pointer to the file name in a given file path eliminating the directory name
@@ -369,7 +368,7 @@
 SWITCH_DECLARE(switch_bool_t) switch_network_list_validate_ip(switch_network_list_t *list, uint32_t ip);
 #define switch_test_subnet(_ip, _net, _mask) (_mask ? ((_net & _mask) == (_ip & _mask)) : _net ? _net == _ip : 1)
 
-int switch_inet_pton(int af, const char *src, void *dst);
+	 int switch_inet_pton(int af, const char *src, void *dst);
 
 /* malloc or DIE macros */
 #ifdef NDEBUG

Modified: freeswitch/trunk/src/include/switch_xml.h
==============================================================================
--- freeswitch/trunk/src/include/switch_xml.h	(original)
+++ freeswitch/trunk/src/include/switch_xml.h	Tue May 27 00:30:03 2008
@@ -184,7 +184,7 @@
 ///\ 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.
@@ -234,7 +234,7 @@
 ///\param name the name of the tag
 ///\param off the offset
 ///\return an xml node or NULL
-	 SWITCH_DECLARE(switch_xml_t) switch_xml_add_child(switch_xml_t xml, const char *name, switch_size_t off);
+SWITCH_DECLARE(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
@@ -247,7 +247,7 @@
 ///\param xml the xml node
 ///\param txt the text
 ///\return an xml node or NULL
-	 SWITCH_DECLARE(switch_xml_t) switch_xml_set_txt(switch_xml_t xml, const char *txt);
+SWITCH_DECLARE(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
@@ -324,25 +324,22 @@
 ///\return SWITCH_STATUS_SUCCESS if successful root and node will be assigned
 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 *key_name, const char *key_value, switch_xml_t *root, switch_xml_t *node,
 												  switch_event_t *params);
 
 SWITCH_DECLARE(switch_status_t) switch_xml_locate_domain(const char *domain_name, switch_event_t *params, switch_xml_t *root, switch_xml_t *domain);
 SWITCH_DECLARE(switch_status_t) switch_xml_locate_user(const char *key,
-													   const char *user_name, 
-													   const char *domain_name, 
-													   const char *ip, 
-													   switch_xml_t *root,
-													   switch_xml_t *domain,
-													   switch_xml_t *user,
-													   switch_event_t *params);
+													   const char *user_name,
+													   const char *domain_name,
+													   const char *ip,
+													   switch_xml_t *root, switch_xml_t *domain, switch_xml_t *user, switch_event_t *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, switch_event_t *params);
+SWITCH_DECLARE(switch_xml_t) switch_xml_open_cfg(const char *file_path, switch_xml_t *node, switch_event_t *params);
 
 ///\brief bind a search function to an external gateway
 ///\param function the search function to bind

Modified: freeswitch/trunk/src/switch_apr.c
==============================================================================
--- freeswitch/trunk/src/switch_apr.c	(original)
+++ freeswitch/trunk/src/switch_apr.c	Tue May 27 00:30:03 2008
@@ -80,29 +80,29 @@
 
 /* DSO functions */
 
-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)
 {
 	return apr_dso_load(res_handle, path, ctx);
 }
 
-SWITCH_DECLARE(switch_status_t) switch_dso_unload(switch_dso_handle_t * handle)
+SWITCH_DECLARE(switch_status_t) switch_dso_unload(switch_dso_handle_t *handle)
 {
 	return apr_dso_unload(handle);
 }
 
-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)
 {
 	return apr_dso_sym(ressym, handle, symname);
 }
 
-SWITCH_DECLARE(const char *) switch_dso_error(switch_dso_handle_t * dso, char *buf, size_t bufsize)
+SWITCH_DECLARE(const char *) switch_dso_error(switch_dso_handle_t *dso, char *buf, size_t bufsize)
 {
 	return apr_dso_error(dso, buf, bufsize);
 }
 
 /* string functions */
 
-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_DECLARE(switch_status_t) switch_strftime(char *s, switch_size_t *retsize, switch_size_t max, const char *format, switch_time_exp_t *tm)
 {
 	return apr_strftime(s, retsize, max, format, (apr_time_exp_t *) tm);
 }
@@ -124,7 +124,8 @@
 
 SWITCH_DECLARE(char *) switch_copy_string(char *dst, const char *src, switch_size_t dst_size)
 {
-	if (!dst) return NULL;
+	if (!dst)
+		return NULL;
 	if (!src) {
 		*dst = '\0';
 		return dst;
@@ -134,69 +135,69 @@
 
 /* thread read write lock functions */
 
-SWITCH_DECLARE(switch_status_t) switch_thread_rwlock_create(switch_thread_rwlock_t ** rwlock, switch_memory_pool_t *pool)
+SWITCH_DECLARE(switch_status_t) switch_thread_rwlock_create(switch_thread_rwlock_t **rwlock, switch_memory_pool_t *pool)
 {
 	return apr_thread_rwlock_create(rwlock, pool);
 }
 
-SWITCH_DECLARE(switch_status_t) switch_thread_rwlock_destroy(switch_thread_rwlock_t * rwlock)
+SWITCH_DECLARE(switch_status_t) switch_thread_rwlock_destroy(switch_thread_rwlock_t *rwlock)
 {
 	return apr_thread_rwlock_destroy(rwlock);
 }
 
-SWITCH_DECLARE(switch_memory_pool_t *) switch_thread_rwlock_pool_get(switch_thread_rwlock_t * rwlock)
+SWITCH_DECLARE(switch_memory_pool_t *) switch_thread_rwlock_pool_get(switch_thread_rwlock_t *rwlock)
 {
 	return apr_thread_rwlock_pool_get(rwlock);
 }
 
-SWITCH_DECLARE(switch_status_t) switch_thread_rwlock_rdlock(switch_thread_rwlock_t * rwlock)
+SWITCH_DECLARE(switch_status_t) switch_thread_rwlock_rdlock(switch_thread_rwlock_t *rwlock)
 {
 	return apr_thread_rwlock_rdlock(rwlock);
 }
 
-SWITCH_DECLARE(switch_status_t) switch_thread_rwlock_tryrdlock(switch_thread_rwlock_t * rwlock)
+SWITCH_DECLARE(switch_status_t) switch_thread_rwlock_tryrdlock(switch_thread_rwlock_t *rwlock)
 {
 	return apr_thread_rwlock_tryrdlock(rwlock);
 }
 
-SWITCH_DECLARE(switch_status_t) switch_thread_rwlock_wrlock(switch_thread_rwlock_t * rwlock)
+SWITCH_DECLARE(switch_status_t) switch_thread_rwlock_wrlock(switch_thread_rwlock_t *rwlock)
 {
 	return apr_thread_rwlock_wrlock(rwlock);
 }
 
-SWITCH_DECLARE(switch_status_t) switch_thread_rwlock_trywrlock(switch_thread_rwlock_t * rwlock)
+SWITCH_DECLARE(switch_status_t) switch_thread_rwlock_trywrlock(switch_thread_rwlock_t *rwlock)
 {
 	return apr_thread_rwlock_trywrlock(rwlock);
 }
 
-SWITCH_DECLARE(switch_status_t) switch_thread_rwlock_unlock(switch_thread_rwlock_t * rwlock)
+SWITCH_DECLARE(switch_status_t) switch_thread_rwlock_unlock(switch_thread_rwlock_t *rwlock)
 {
 	return apr_thread_rwlock_unlock(rwlock);
 }
 
 /* thread mutex functions */
 
-SWITCH_DECLARE(switch_status_t) switch_mutex_init(switch_mutex_t ** lock, unsigned int flags, switch_memory_pool_t *pool)
+SWITCH_DECLARE(switch_status_t) switch_mutex_init(switch_mutex_t **lock, unsigned int flags, switch_memory_pool_t *pool)
 {
 	return apr_thread_mutex_create(lock, flags, pool);
 }
 
-SWITCH_DECLARE(switch_status_t) switch_mutex_destroy(switch_mutex_t * lock)
+SWITCH_DECLARE(switch_status_t) switch_mutex_destroy(switch_mutex_t *lock)
 {
 	return apr_thread_mutex_destroy(lock);
 }
 
-SWITCH_DECLARE(switch_status_t) switch_mutex_lock(switch_mutex_t * lock)
+SWITCH_DECLARE(switch_status_t) switch_mutex_lock(switch_mutex_t *lock)
 {
 	return apr_thread_mutex_lock(lock);
 }
 
-SWITCH_DECLARE(switch_status_t) switch_mutex_unlock(switch_mutex_t * lock)
+SWITCH_DECLARE(switch_status_t) switch_mutex_unlock(switch_mutex_t *lock)
 {
 	return apr_thread_mutex_unlock(lock);
 }
 
-SWITCH_DECLARE(switch_status_t) switch_mutex_trylock(switch_mutex_t * lock)
+SWITCH_DECLARE(switch_status_t) switch_mutex_trylock(switch_mutex_t *lock)
 {
 	return apr_thread_mutex_trylock(lock);
 }
@@ -207,29 +208,29 @@
 {
 #if defined(HAVE_CLOCK_GETTIME) && defined(SWITCH_USE_CLOCK_FUNCS)
 	struct timespec ts;
-	clock_gettime(CLOCK_REALTIME,&ts);
-	return ts.tv_sec * APR_USEC_PER_SEC + (ts.tv_nsec/1000);
+	clock_gettime(CLOCK_REALTIME, &ts);
+	return ts.tv_sec * APR_USEC_PER_SEC + (ts.tv_nsec / 1000);
 #else
 	return (switch_time_t) apr_time_now();
 #endif
 }
 
-SWITCH_DECLARE(switch_status_t) switch_time_exp_gmt_get(switch_time_t * result, switch_time_exp_t * input)
+SWITCH_DECLARE(switch_status_t) switch_time_exp_gmt_get(switch_time_t *result, switch_time_exp_t *input)
 {
 	return apr_time_exp_gmt_get(result, (apr_time_exp_t *) input);
 }
 
-SWITCH_DECLARE(switch_status_t) switch_time_exp_get(switch_time_t * result, switch_time_exp_t * input)
+SWITCH_DECLARE(switch_status_t) switch_time_exp_get(switch_time_t *result, switch_time_exp_t *input)
 {
 	return apr_time_exp_get(result, (apr_time_exp_t *) input);
 }
 
-SWITCH_DECLARE(switch_status_t) switch_time_exp_lt(switch_time_exp_t * result, switch_time_t input)
+SWITCH_DECLARE(switch_status_t) switch_time_exp_lt(switch_time_exp_t *result, switch_time_t input)
 {
 	return apr_time_exp_lt((apr_time_exp_t *) result, input);
 }
 
-SWITCH_DECLARE(switch_status_t) switch_time_exp_gmt(switch_time_exp_t * result, switch_time_t input)
+SWITCH_DECLARE(switch_status_t) switch_time_exp_gmt(switch_time_exp_t *result, switch_time_t input)
 {
 	return apr_time_exp_gmt((apr_time_exp_t *) result, input);
 }
@@ -246,45 +247,45 @@
 
 /* Thread condition locks */
 
-SWITCH_DECLARE(switch_status_t) switch_thread_cond_create(switch_thread_cond_t ** cond, switch_memory_pool_t *pool)
+SWITCH_DECLARE(switch_status_t) switch_thread_cond_create(switch_thread_cond_t **cond, switch_memory_pool_t *pool)
 {
 	return apr_thread_cond_create(cond, pool);
 }
 
-SWITCH_DECLARE(switch_status_t) switch_thread_cond_wait(switch_thread_cond_t * cond, switch_mutex_t * mutex)
+SWITCH_DECLARE(switch_status_t) switch_thread_cond_wait(switch_thread_cond_t *cond, switch_mutex_t *mutex)
 {
 	return apr_thread_cond_wait(cond, mutex);
 }
 
-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)
 {
 	return apr_thread_cond_timedwait(cond, mutex, timeout);
 }
 
-SWITCH_DECLARE(switch_status_t) switch_thread_cond_signal(switch_thread_cond_t * cond)
+SWITCH_DECLARE(switch_status_t) switch_thread_cond_signal(switch_thread_cond_t *cond)
 {
 	return apr_thread_cond_signal(cond);
 }
 
-SWITCH_DECLARE(switch_status_t) switch_thread_cond_broadcast(switch_thread_cond_t * cond)
+SWITCH_DECLARE(switch_status_t) switch_thread_cond_broadcast(switch_thread_cond_t *cond)
 {
 	return apr_thread_cond_broadcast(cond);
 }
 
-SWITCH_DECLARE(switch_status_t) switch_thread_cond_destroy(switch_thread_cond_t * cond)
+SWITCH_DECLARE(switch_status_t) switch_thread_cond_destroy(switch_thread_cond_t *cond)
 {
 	return apr_thread_cond_destroy(cond);
 }
 
 /* file i/o stubs */
 
-SWITCH_DECLARE(switch_status_t) switch_file_open(switch_file_t ** newf, const char *fname, int32_t flag, switch_fileperms_t perm,
+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)
 {
 	return apr_file_open(newf, fname, flag, perm, pool);
 }
 
-SWITCH_DECLARE(switch_status_t) switch_file_seek(switch_file_t * thefile, switch_seek_where_t where, int64_t *offset)
+SWITCH_DECLARE(switch_status_t) switch_file_seek(switch_file_t *thefile, switch_seek_where_t where, int64_t *offset)
 {
 	apr_status_t rv;
 	apr_off_t off = (apr_off_t) (*offset);
@@ -293,12 +294,12 @@
 	return rv;
 }
 
-SWITCH_DECLARE(switch_status_t) switch_file_close(switch_file_t * thefile)
+SWITCH_DECLARE(switch_status_t) switch_file_close(switch_file_t *thefile)
 {
 	return apr_file_close(thefile);
 }
 
-SWITCH_DECLARE(switch_status_t) switch_file_lock(switch_file_t * thefile, int type)
+SWITCH_DECLARE(switch_status_t) switch_file_lock(switch_file_t *thefile, int type)
 {
 	return apr_file_lock(thefile, type);
 }
@@ -313,12 +314,12 @@
 	return apr_file_remove(path, pool);
 }
 
-SWITCH_DECLARE(switch_status_t) switch_file_read(switch_file_t * thefile, void *buf, switch_size_t *nbytes)
+SWITCH_DECLARE(switch_status_t) switch_file_read(switch_file_t *thefile, void *buf, switch_size_t *nbytes)
 {
 	return apr_file_read(thefile, buf, nbytes);
 }
 
-SWITCH_DECLARE(switch_status_t) switch_file_write(switch_file_t * thefile, const void *buf, switch_size_t *nbytes)
+SWITCH_DECLARE(switch_status_t) switch_file_write(switch_file_t *thefile, const void *buf, switch_size_t *nbytes)
 {
 	return apr_file_write(thefile, buf, nbytes);
 }
@@ -341,7 +342,7 @@
 SWITCH_DECLARE(switch_size_t) switch_file_get_size(switch_file_t *thefile)
 {
 	struct apr_finfo_t finfo;
-	return apr_file_info_get(&finfo, APR_FINFO_SIZE, thefile) == SWITCH_STATUS_SUCCESS ? (switch_size_t)finfo.size : 0;
+	return apr_file_info_get(&finfo, APR_FINFO_SIZE, thefile) == SWITCH_STATUS_SUCCESS ? (switch_size_t) finfo.size : 0;
 }
 
 SWITCH_DECLARE(switch_status_t) switch_directory_exists(const char *dirname, switch_memory_pool_t *pool)
@@ -380,7 +381,7 @@
 	if (filename) {
 		apr_stat(&info, filename, wanted, pool ? pool : our_pool);
 		if (info.filetype != APR_NOFILE) {
-			status =  SWITCH_STATUS_SUCCESS;
+			status = SWITCH_STATUS_SUCCESS;
 		}
 	}
 
@@ -391,15 +392,12 @@
 	return status;
 }
 
-SWITCH_DECLARE(switch_status_t) switch_dir_make(const char *path, switch_fileperms_t perm,
-												switch_memory_pool_t *pool)
+SWITCH_DECLARE(switch_status_t) switch_dir_make(const char *path, switch_fileperms_t perm, switch_memory_pool_t *pool)
 {
 	return apr_dir_make(path, perm, pool);
 }
 
-SWITCH_DECLARE(switch_status_t) switch_dir_make_recursive(const char *path,
-														  switch_fileperms_t perm,
-														  switch_memory_pool_t *pool)
+SWITCH_DECLARE(switch_status_t) switch_dir_make_recursive(const char *path, switch_fileperms_t perm, switch_memory_pool_t *pool)
 {
 	return apr_dir_make_recursive(path, perm, pool);
 }
@@ -427,7 +425,7 @@
 		*new_dir = NULL;
 	}
 
-	return status;	 
+	return status;
 }
 
 SWITCH_DECLARE(switch_status_t) switch_dir_close(switch_dir_t *thedir)
@@ -438,7 +436,7 @@
 	return status;
 }
 
-SWITCH_DECLARE(const char *) switch_dir_next_file(switch_dir_t *thedir, char *buf, switch_size_t len) 
+SWITCH_DECLARE(const char *) switch_dir_next_file(switch_dir_t *thedir, char *buf, switch_size_t len)
 {
 	const char *fname = NULL;
 	apr_int32_t finfo_flags = APR_FINFO_DIRENT | APR_FINFO_TYPE | APR_FINFO_NAME;
@@ -471,25 +469,25 @@
 
 /* thread stubs */
 
-SWITCH_DECLARE(switch_status_t) switch_threadattr_create(switch_threadattr_t ** new_attr, switch_memory_pool_t *pool)
+SWITCH_DECLARE(switch_status_t) switch_threadattr_create(switch_threadattr_t **new_attr, switch_memory_pool_t *pool)
 {
 	return apr_threadattr_create(new_attr, pool);
 }
 
-SWITCH_DECLARE(switch_status_t) switch_threadattr_detach_set(switch_threadattr_t * attr, int32_t on)
+SWITCH_DECLARE(switch_status_t) switch_threadattr_detach_set(switch_threadattr_t *attr, int32_t on)
 {
 	return apr_threadattr_detach_set(attr, on);
 }
 
-SWITCH_DECLARE(switch_status_t) switch_threadattr_stacksize_set(switch_threadattr_t * attr, switch_size_t stacksize)
+SWITCH_DECLARE(switch_status_t) switch_threadattr_stacksize_set(switch_threadattr_t *attr, switch_size_t stacksize)
 {
 	return apr_threadattr_stacksize_set(attr, stacksize);
 }
 
 #ifndef WIN32
 struct apr_threadattr_t {
-    apr_pool_t *pool;
-    pthread_attr_t attr;
+	apr_pool_t *pool;
+	pthread_attr_t attr;
 };
 #endif
 
@@ -497,23 +495,22 @@
 {
 	int stat = 0;
 #ifndef WIN32
-	struct sched_param    param;
+	struct sched_param param;
 	struct apr_threadattr_t *myattr = attr;
 
 	pthread_attr_getschedparam(&myattr->attr, &param);
 	param.sched_priority = 50;
 	stat = pthread_attr_setschedparam(&myattr->attr, &param);
 
-    if (stat == 0) {
-        return SWITCH_STATUS_SUCCESS;
-    }
-
+	if (stat == 0) {
+		return SWITCH_STATUS_SUCCESS;
+	}
 #endif
-    return stat;
+	return stat;
 }
 
 
-SWITCH_DECLARE(switch_status_t) switch_thread_create(switch_thread_t ** new_thread, switch_threadattr_t * attr,
+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)
 {
 	return apr_thread_create(new_thread, attr, func, data, cont);
@@ -526,42 +523,42 @@
 	return apr_socket_addr_get(sa, remote, sock);
 }
 
-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)
 {
 	return apr_socket_create(new_sock, family, type, protocol, pool);
 }
 
-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)
 {
-	return apr_socket_shutdown(sock, (apr_shutdown_how_e)how);
+	return apr_socket_shutdown(sock, (apr_shutdown_how_e) how);
 }
 
-SWITCH_DECLARE(switch_status_t) switch_socket_close(switch_socket_t * sock)
+SWITCH_DECLARE(switch_status_t) switch_socket_close(switch_socket_t *sock)
 {
 	return apr_socket_close(sock);
 }
 
-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)
 {
 	return apr_socket_bind(sock, sa);
 }
 
-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)
 {
 	return apr_socket_listen(sock, backlog);
 }
 
-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)
 {
 	return apr_socket_accept(new_sock, sock, pool);
 }
 
-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)
 {
 	return apr_socket_connect(sock, sa);
 }
 
-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)
 {
 	switch_status_t status = SWITCH_STATUS_SUCCESS;
 	switch_size_t req = *len, wrote = 0, need = *len;
@@ -585,7 +582,7 @@
 	return status;
 }
 
-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)
 {
 	if (!where || !buf || !len || !*len) {
 		return SWITCH_STATUS_GENERR;
@@ -593,33 +590,33 @@
 	return apr_socket_sendto(sock, where, flags, buf, len);
 }
 
-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)
 {
 	return apr_socket_recv(sock, buf, len);
 }
 
-SWITCH_DECLARE(switch_status_t) switch_sockaddr_info_get(switch_sockaddr_t ** sa, const char *hostname, int32_t family,
+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)
 {
 	return apr_sockaddr_info_get(sa, hostname, family, port, flags, pool);
 }
 
-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)
 {
 	return apr_socket_opt_set(sock, opt, on);
 }
 
-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)
 {
 	return apr_socket_timeout_set(sock, t);
 }
 
-SWITCH_DECLARE(switch_status_t) switch_sockaddr_ip_get(char **addr, switch_sockaddr_t * sa)
+SWITCH_DECLARE(switch_status_t) switch_sockaddr_ip_get(char **addr, switch_sockaddr_t *sa)
 {
 	return apr_sockaddr_ip_get(addr, sa);
 }
 
-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)
 {
 	return apr_mcast_join(sock, join, iface, source);
 }
@@ -627,7 +624,7 @@
 
 /* socket functions */
 
-SWITCH_DECLARE(const char *) switch_get_addr(char *buf, switch_size_t len, switch_sockaddr_t * in)
+SWITCH_DECLARE(const char *) switch_get_addr(char *buf, switch_size_t len, switch_sockaddr_t *in)
 {
 	if (!in) {
 		return "";
@@ -635,52 +632,52 @@
 	return get_addr(buf, len, &in->sa.sin.sin_addr);
 }
 
-SWITCH_DECLARE(uint16_t) switch_sockaddr_get_port(switch_sockaddr_t * sa)
+SWITCH_DECLARE(uint16_t) switch_sockaddr_get_port(switch_sockaddr_t *sa)
 {
 	return sa->port;
 }
 
-SWITCH_DECLARE(int32_t) switch_sockaddr_get_family(switch_sockaddr_t * sa)
+SWITCH_DECLARE(int32_t) switch_sockaddr_get_family(switch_sockaddr_t *sa)
 {
 	return sa->family;
 }
 
-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)
 {
 	apr_status_t r;
 
 	if ((r = apr_socket_recvfrom(from, sock, flags, buf, len)) == APR_SUCCESS) {
 		from->port = ntohs(from->sa.sin.sin_port);
 		/* from->ipaddr_ptr = &(from->sa.sin.sin_addr);
-		* from->ipaddr_ptr = inet_ntoa(from->sa.sin.sin_addr);
-		*/
+		 * from->ipaddr_ptr = inet_ntoa(from->sa.sin.sin_addr);
+		 */
+	}
+
+	if (r == 35) {
+		r = SWITCH_STATUS_BREAK;
 	}
-    
-    if (r == 35 ) {
-        r = SWITCH_STATUS_BREAK;
-    }
 
 	return r;
 }
 
 /* poll stubs */
 
-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)
 {
 	return apr_pollset_create(pollset, size, p, flags);
 }
 
-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)
 {
 	return apr_pollset_add(pollset, descriptor);
 }
 
-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)
 {
 	return apr_poll(aprset, numsock, nsds, timeout);
 }
 
-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)
 {
 	switch_pollset_t *pollset;
 
@@ -713,39 +710,39 @@
 
 /* UUID Handling (apr-util) */
 
-SWITCH_DECLARE(void) switch_uuid_format(char *buffer, const switch_uuid_t * uuid)
+SWITCH_DECLARE(void) switch_uuid_format(char *buffer, const switch_uuid_t *uuid)
 {
 	apr_uuid_format(buffer, (const apr_uuid_t *) uuid);
 }
 
-SWITCH_DECLARE(void) switch_uuid_get(switch_uuid_t * uuid)
+SWITCH_DECLARE(void) switch_uuid_get(switch_uuid_t *uuid)
 {
 	apr_uuid_get((apr_uuid_t *) uuid);
 }
 
-SWITCH_DECLARE(switch_status_t) switch_uuid_parse(switch_uuid_t * uuid, const char *uuid_str)
+SWITCH_DECLARE(switch_status_t) switch_uuid_parse(switch_uuid_t *uuid, const char *uuid_str)
 {
 	return apr_uuid_parse((apr_uuid_t *) uuid, uuid_str);
 }
 
 /* FIFO queues (apr-util) */
 
-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)
 {
 	return apr_queue_create(queue, queue_capacity, pool);
 }
 
-SWITCH_DECLARE(unsigned int) switch_queue_size(switch_queue_t * queue)
+SWITCH_DECLARE(unsigned int) switch_queue_size(switch_queue_t *queue)
 {
 	return apr_queue_size(queue);
 }
 
-SWITCH_DECLARE(switch_status_t) switch_queue_pop(switch_queue_t * queue, void **data)
+SWITCH_DECLARE(switch_status_t) switch_queue_pop(switch_queue_t *queue, void **data)
 {
 	return apr_queue_pop(queue, data);
 }
 
-SWITCH_DECLARE(switch_status_t) switch_queue_push(switch_queue_t * queue, void *data)
+SWITCH_DECLARE(switch_status_t) switch_queue_push(switch_queue_t *queue, void *data)
 {
 	apr_status_t s;
 
@@ -756,12 +753,12 @@
 	return s;
 }
 
-SWITCH_DECLARE(switch_status_t) switch_queue_trypop(switch_queue_t * queue, void **data)
+SWITCH_DECLARE(switch_status_t) switch_queue_trypop(switch_queue_t *queue, void **data)
 {
 	return apr_queue_trypop(queue, data);
 }
 
-SWITCH_DECLARE(switch_status_t) switch_queue_trypush(switch_queue_t * queue, void *data)
+SWITCH_DECLARE(switch_status_t) switch_queue_trypush(switch_queue_t *queue, void *data)
 {
 	apr_status_t s;
 
@@ -810,9 +807,9 @@
 
 SWITCH_DECLARE(switch_status_t) switch_match_glob(const char *pattern, switch_array_header_t **result, switch_memory_pool_t *p)
 {
-	return apr_match_glob(pattern, (apr_array_header_t **)result, p);
+	return apr_match_glob(pattern, (apr_array_header_t **) result, p);
 }
-													
+
 /* For Emacs:
  * Local Variables:
  * mode:c

Modified: freeswitch/trunk/src/switch_buffer.c
==============================================================================
--- freeswitch/trunk/src/switch_buffer.c	(original)
+++ freeswitch/trunk/src/switch_buffer.c	Tue May 27 00:30:03 2008
@@ -280,7 +280,7 @@
 
 SWITCH_DECLARE(void) switch_buffer_destroy(switch_buffer_t **buffer)
 {
-	if (buffer && *buffer) { 
+	if (buffer && *buffer) {
 		if ((switch_test_flag((*buffer), SWITCH_BUFFER_FLAG_DYNAMIC))) {
 			switch_safe_free((*buffer)->data);
 			free(*buffer);

Modified: freeswitch/trunk/src/switch_caller.c
==============================================================================
--- freeswitch/trunk/src/switch_caller.c	(original)
+++ freeswitch/trunk/src/switch_caller.c	Tue May 27 00:30:03 2008
@@ -44,16 +44,14 @@
 																	const char *network_addr,
 																	const char *ani,
 																	const char *aniii,
-																	const char *rdnis, 
-																	const char *source, 
-																	const char *context,
-																	const char *destination_number)
+																	const char *rdnis,
+																	const char *source, const char *context, const char *destination_number)
 {
 	switch_caller_profile_t *profile = NULL;
 
 	profile = switch_core_alloc(pool, sizeof(*profile));
 	switch_assert(profile != NULL);
-		
+
 	if (!context) {
 		context = "default";
 	}
@@ -276,7 +274,8 @@
 	switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, switch_test_flag(caller_profile, SWITCH_CPF_HIDE_NUMBER) ? "yes" : "no");
 }
 
-SWITCH_DECLARE(switch_caller_extension_t *) switch_caller_extension_new(switch_core_session_t *session, const char *extension_name, const char *extension_number)
+SWITCH_DECLARE(switch_caller_extension_t *) switch_caller_extension_new(switch_core_session_t *session, const char *extension_name,
+																		const char *extension_number)
 {
 	switch_caller_extension_t *caller_extension = NULL;
 
@@ -290,7 +289,8 @@
 }
 
 SWITCH_DECLARE(void) switch_caller_extension_add_application(switch_core_session_t *session,
-															 switch_caller_extension_t *caller_extension, const char *application_name, const char *application_data)
+															 switch_caller_extension_t *caller_extension, const char *application_name,
+															 const char *application_data)
 {
 	switch_caller_application_t *caller_application = NULL;
 

Modified: freeswitch/trunk/src/switch_channel.c
==============================================================================
--- freeswitch/trunk/src/switch_channel.c	(original)
+++ freeswitch/trunk/src/switch_channel.c	Tue May 27 00:30:03 2008
@@ -130,7 +130,7 @@
 	uint8_t x;
 	const char *str = "UNKNOWN";
 
-	for (x = 0; x < (sizeof(CAUSE_CHART) / sizeof(struct switch_cause_table)) -1 ; x++) {
+	for (x = 0; x < (sizeof(CAUSE_CHART) / sizeof(struct switch_cause_table)) - 1; x++) {
 		if (CAUSE_CHART[x].cause == cause) {
 			str = CAUSE_CHART[x].name;
 			break;
@@ -214,12 +214,12 @@
 	switch_status_t status;
 	void *pop;
 	switch_dtmf_t new_dtmf;
-	
+
 	switch_assert(dtmf);
 
-	switch_mutex_lock(channel->dtmf_mutex);	
+	switch_mutex_lock(channel->dtmf_mutex);
 	new_dtmf = *dtmf;
-	
+
 	if ((status = switch_core_session_recv_dtmf(channel->session, dtmf) != SWITCH_STATUS_SUCCESS)) {
 		goto done;
 	}
@@ -229,13 +229,13 @@
 		int x = 0;
 
 		if (new_dtmf.duration > switch_core_max_dtmf_duration(0)) {
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "%s EXECSSIVE DTMF DIGIT [%c] LEN [%d]\n", 
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "%s EXECSSIVE DTMF DIGIT [%c] LEN [%d]\n",
 							  switch_channel_get_name(channel), new_dtmf.digit, new_dtmf.duration);
 			new_dtmf.duration = switch_core_max_dtmf_duration(0);
 		} else if (!new_dtmf.duration) {
 			new_dtmf.duration = switch_core_default_dtmf_duration(0);
 		}
-		
+
 		switch_zmalloc(dt, sizeof(*dt));
 		*dt = new_dtmf;
 
@@ -251,7 +251,7 @@
 
 	status = SWITCH_STATUS_SUCCESS;
 
-done:
+  done:
 
 	switch_mutex_unlock(channel->dtmf_mutex);
 
@@ -261,7 +261,7 @@
 SWITCH_DECLARE(switch_status_t) switch_channel_queue_dtmf_string(switch_channel_t *channel, const char *dtmf_string)
 {
 	char *p;
-	switch_dtmf_t dtmf = {0, switch_core_default_dtmf_duration(0)};
+	switch_dtmf_t dtmf = { 0, switch_core_default_dtmf_duration(0) };
 	int sent = 0, dur;
 	char *string;
 	int i, argc;
@@ -274,7 +274,7 @@
 	string = switch_core_session_strdup(channel->session, dtmf_string);
 	argc = switch_separate_string(string, '+', argv, (sizeof(argv) / sizeof(argv[0])));
 
-	for(i = 0; i < argc; i++) {
+	for (i = 0; i < argc; i++) {
 		dtmf.duration = switch_core_default_dtmf_duration(0);
 		dur = switch_core_default_dtmf_duration(0) / 8;
 		if ((p = strchr(argv[i], '@'))) {
@@ -297,7 +297,7 @@
 				dtmf.digit = *p;
 				if (switch_channel_queue_dtmf(channel, &dtmf) == SWITCH_STATUS_SUCCESS) {
 					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s Queue dtmf\ndigit=%c ms=%u samples=%u\n",
-						switch_channel_get_name(channel), dtmf.digit, dur, dtmf.duration);
+									  switch_channel_get_name(channel), dtmf.digit, dur, dtmf.duration);
 					sent++;
 				}
 			}
@@ -323,7 +323,7 @@
 		free(dt);
 
 		if (dtmf->duration > switch_core_max_dtmf_duration(0)) {
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "%s EXECSSIVE DTMF DIGIT [%c] LEN [%d]\n", 
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "%s EXECSSIVE DTMF DIGIT [%c] LEN [%d]\n",
 							  switch_channel_get_name(channel), dtmf->digit, dtmf->duration);
 			dtmf->duration = switch_core_max_dtmf_duration(0);
 		} else if (!dtmf->duration) {
@@ -347,11 +347,11 @@
 SWITCH_DECLARE(switch_size_t) switch_channel_dequeue_dtmf_string(switch_channel_t *channel, char *dtmf_str, switch_size_t len)
 {
 	switch_size_t x = 0;
-	switch_dtmf_t dtmf = {0};
+	switch_dtmf_t dtmf = { 0 };
 
 	memset(dtmf_str, 0, len);
 
-	while(x < len - 1 && switch_channel_dequeue_dtmf(channel, &dtmf) == SWITCH_STATUS_SUCCESS) {
+	while (x < len - 1 && switch_channel_dequeue_dtmf(channel, &dtmf) == SWITCH_STATUS_SUCCESS) {
 		dtmf_str[x++] = dtmf.digit;
 	}
 
@@ -363,7 +363,7 @@
 {
 	void *pop;
 	switch_mutex_lock(channel->dtmf_mutex);
-	while(switch_queue_trypop(channel->dtmf_queue, &pop) == SWITCH_STATUS_SUCCESS) {
+	while (switch_queue_trypop(channel->dtmf_queue, &pop) == SWITCH_STATUS_SUCCESS) {
 		switch_safe_free(pop);
 	}
 	switch_mutex_unlock(channel->dtmf_mutex);
@@ -426,7 +426,7 @@
 	switch_assert(channel != NULL);
 
 	switch_mutex_lock(channel->profile_mutex);
-	if (!channel->variables || !(v = switch_event_get_header(channel->variables, (char*)varname))) {
+	if (!channel->variables || !(v = switch_event_get_header(channel->variables, (char *) varname))) {
 		switch_caller_profile_t *cp = channel->caller_profile;
 
 		if (cp) {
@@ -551,7 +551,7 @@
 		switch_event_del_header(channel->variables, varname);
 		if (!switch_strlen_zero(value)) {
 			switch_event_add_header(channel->variables, SWITCH_STACK_BOTTOM, varname, "%s", value);
-		} 
+		}
 		switch_mutex_unlock(channel->profile_mutex);
 		return SWITCH_STATUS_SUCCESS;
 	}
@@ -634,7 +634,7 @@
 	switch_channel_state_t state, mystate, ostate;
 	ostate = switch_channel_get_state(channel);
 
-	for(;;) {
+	for (;;) {
 		state = switch_channel_get_running_state(other_channel);
 		mystate = switch_channel_get_running_state(channel);
 
@@ -652,7 +652,7 @@
 		to++;
 	}
 
-	for(;;) {
+	for (;;) {
 		if (pres) {
 			if (switch_test_flag(channel, want_flag)) {
 				break;
@@ -723,9 +723,9 @@
 
 	switch_assert(channel != NULL);
 
-	if (!channel->hangup_cause && channel->state > CS_ROUTING && channel->state < CS_HANGUP && channel->state != CS_RESET && 
+	if (!channel->hangup_cause && channel->state > CS_ROUTING && channel->state < CS_HANGUP && channel->state != CS_RESET &&
 		!switch_test_flag(channel, CF_TRANSFER)) {
-			ret++;
+		ret++;
 	}
 
 	return ret;
@@ -769,8 +769,7 @@
 																				const char *file, const char *func, int line)
 {
 	switch_mutex_lock(channel->flag_mutex);
-	switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_DEBUG, "%s Running State Change %s\n",
-		channel->name, state_names[state]);
+	switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_DEBUG, "%s Running State Change %s\n", channel->name, state_names[state]);
 	channel->running_state = state;
 
 	if (channel->state_flags) {
@@ -797,7 +796,8 @@
 				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Channel-State-Number", "%s", (char *) state_num);
 				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Channel-Name", "%s", channel->name);
 				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Unique-ID", "%s", switch_core_session_get_uuid(channel->session));
-				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Call-Direction", "%s", switch_channel_test_flag(channel, CF_OUTBOUND) ? "outbound" : "inbound");
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Call-Direction", "%s",
+										switch_channel_test_flag(channel, CF_OUTBOUND) ? "outbound" : "inbound");
 				if (switch_channel_test_flag(channel, CF_ANSWERED)) {
 					switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Answer-State", "answered");
 				} else if (switch_channel_test_flag(channel, CF_EARLY_MEDIA)) {
@@ -837,172 +837,172 @@
 	}
 
 	/* STUB for more dev
-	case CS_INIT:
-	switch(state) {
+	   case CS_INIT:
+	   switch(state) {
 
+	   case CS_NEW:
+	   case CS_INIT:
+	   case CS_EXCHANGE_MEDIA:
+	   case CS_SOFT_EXECUTE:
+	   case CS_ROUTING:
+	   case CS_EXECUTE:
+	   case CS_HANGUP:
+	   case CS_DONE:
+
+	   default:
+	   break;
+	   }
+	   break;
+	 */
+
+	switch (last_state) {
 	case CS_NEW:
+	case CS_RESET:
+		switch (state) {
+		default:
+			ok++;
+			break;
+		}
+		break;
+
 	case CS_INIT:
+		switch (state) {
+		case CS_EXCHANGE_MEDIA:
+		case CS_SOFT_EXECUTE:
+		case CS_ROUTING:
+		case CS_EXECUTE:
+		case CS_PARK:
+		case CS_CONSUME_MEDIA:
+		case CS_HIBERNATE:
+		case CS_RESET:
+			ok++;
+		default:
+			break;
+		}
+		break;
+
 	case CS_EXCHANGE_MEDIA:
+		switch (state) {
+		case CS_SOFT_EXECUTE:
+		case CS_ROUTING:
+		case CS_EXECUTE:
+		case CS_PARK:
+		case CS_CONSUME_MEDIA:
+		case CS_HIBERNATE:
+		case CS_RESET:
+			ok++;
+		default:
+			break;
+		}
+		break;
+
 	case CS_SOFT_EXECUTE:
+		switch (state) {
+		case CS_EXCHANGE_MEDIA:
+		case CS_ROUTING:
+		case CS_EXECUTE:
+		case CS_PARK:
+		case CS_CONSUME_MEDIA:
+		case CS_HIBERNATE:
+		case CS_RESET:
+			ok++;
+		default:
+			break;
+		}
+		break;
+
+	case CS_PARK:
+		switch (state) {
+		case CS_EXCHANGE_MEDIA:
+		case CS_ROUTING:
+		case CS_EXECUTE:
+		case CS_SOFT_EXECUTE:
+		case CS_HIBERNATE:
+		case CS_RESET:
+		case CS_CONSUME_MEDIA:
+			ok++;
+		default:
+			break;
+		}
+		break;
+
+	case CS_CONSUME_MEDIA:
+		switch (state) {
+		case CS_EXCHANGE_MEDIA:
+		case CS_ROUTING:
+		case CS_EXECUTE:
+		case CS_SOFT_EXECUTE:
+		case CS_HIBERNATE:
+		case CS_RESET:
+		case CS_PARK:
+			ok++;
+		default:
+			break;
+		}
+		break;
+	case CS_HIBERNATE:
+		switch (state) {
+		case CS_EXCHANGE_MEDIA:
+		case CS_INIT:
+		case CS_ROUTING:
+		case CS_EXECUTE:
+		case CS_SOFT_EXECUTE:
+		case CS_PARK:
+		case CS_CONSUME_MEDIA:
+		case CS_RESET:
+			ok++;
+		default:
+			break;
+		}
+		break;
+
 	case CS_ROUTING:
+		switch (state) {
+		case CS_EXCHANGE_MEDIA:
+		case CS_EXECUTE:
+		case CS_SOFT_EXECUTE:
+		case CS_PARK:
+		case CS_CONSUME_MEDIA:
+		case CS_HIBERNATE:
+		case CS_RESET:
+			ok++;
+		default:
+			break;
+		}
+		break;
+
 	case CS_EXECUTE:
+		switch (state) {
+		case CS_EXCHANGE_MEDIA:
+		case CS_SOFT_EXECUTE:
+		case CS_ROUTING:
+		case CS_PARK:
+		case CS_CONSUME_MEDIA:
+		case CS_HIBERNATE:
+		case CS_RESET:
+			ok++;
+		default:
+			break;
+		}
+		break;
+
 	case CS_HANGUP:
-	case CS_DONE:
+		switch (state) {
+		case CS_DONE:
+			ok++;
+		default:
+			break;
+		}
+		break;
 
 	default:
-	break;
-	}
-	break;
-	*/
-
-	switch (last_state) {
-case CS_NEW:
-case CS_RESET:
-	switch (state) {
-default:
-	ok++;
-	break;
-	}
-	break;
-
-case CS_INIT:
-	switch (state) {
-case CS_EXCHANGE_MEDIA:
-case CS_SOFT_EXECUTE:
-case CS_ROUTING:
-case CS_EXECUTE:
-case CS_PARK:
-case CS_CONSUME_MEDIA:
-case CS_HIBERNATE:
-case CS_RESET:
-	ok++;
-default:
-	break;
-	}
-	break;
-
-case CS_EXCHANGE_MEDIA:
-	switch (state) {
-case CS_SOFT_EXECUTE:
-case CS_ROUTING:
-case CS_EXECUTE:
-case CS_PARK:
-case CS_CONSUME_MEDIA:
-case CS_HIBERNATE:
-case CS_RESET:
-	ok++;
-default:
-	break;
-	}
-	break;
-
-case CS_SOFT_EXECUTE:
-	switch (state) {
-case CS_EXCHANGE_MEDIA:
-case CS_ROUTING:
-case CS_EXECUTE:
-case CS_PARK:
-case CS_CONSUME_MEDIA:
-case CS_HIBERNATE:
-case CS_RESET:
-	ok++;
-default:
-	break;
-	}
-	break;
-
-case CS_PARK:
-	switch (state) {
-case CS_EXCHANGE_MEDIA:
-case CS_ROUTING:
-case CS_EXECUTE:
-case CS_SOFT_EXECUTE:
-case CS_HIBERNATE:
-case CS_RESET:
-case CS_CONSUME_MEDIA:
-	ok++;
-default:
-	break;
-	}
-	break;
-
-case CS_CONSUME_MEDIA:
-	switch (state) {
-case CS_EXCHANGE_MEDIA:
-case CS_ROUTING:
-case CS_EXECUTE:
-case CS_SOFT_EXECUTE:
-case CS_HIBERNATE:
-case CS_RESET:
-case CS_PARK:
-	ok++;
-default:
-	break;
-	}
-	break;
-case CS_HIBERNATE:
-	switch (state) {
-case CS_EXCHANGE_MEDIA:
-case CS_INIT:
-case CS_ROUTING:
-case CS_EXECUTE:
-case CS_SOFT_EXECUTE:
-case CS_PARK:
-case CS_CONSUME_MEDIA:
-case CS_RESET:
-	ok++;
-default:
-	break;
-	}
-	break;
-
-case CS_ROUTING:
-	switch (state) {
-case CS_EXCHANGE_MEDIA:
-case CS_EXECUTE:
-case CS_SOFT_EXECUTE:
-case CS_PARK:
-case CS_CONSUME_MEDIA:
-case CS_HIBERNATE:
-case CS_RESET:
-	ok++;
-default:
-	break;
-	}
-	break;
-
-case CS_EXECUTE:
-	switch (state) {
-case CS_EXCHANGE_MEDIA:
-case CS_SOFT_EXECUTE:
-case CS_ROUTING:
-case CS_PARK:
-case CS_CONSUME_MEDIA:
-case CS_HIBERNATE:
-case CS_RESET:
-	ok++;
-default:
-	break;
-	}
-	break;
-
-case CS_HANGUP:
-	switch (state) {
-case CS_DONE:
-	ok++;
-default:
-	break;
-	}
-	break;
-
-default:
-	break;
+		break;
 
 	}
 
 	if (ok) {
 		switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_DEBUG, "%s State Change %s -> %s\n",
-			channel->name, state_names[last_state], state_names[state]);
+						  channel->name, state_names[last_state], state_names[state]);
 		switch_mutex_lock(channel->flag_mutex);
 		channel->state = state;
 		switch_mutex_unlock(channel->flag_mutex);
@@ -1016,12 +1016,12 @@
 		}
 	} else {
 		switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_WARNING,
-			"%s Invalid State Change %s -> %s\n", channel->name, state_names[last_state], state_names[state]);
+						  "%s Invalid State Change %s -> %s\n", channel->name, state_names[last_state], state_names[state]);
 		/* we won't tolerate an invalid state change so we can make sure we are as robust as a nice cup of dark coffee! */
 		/* not cool lets crash this bad boy and figure out wtf is going on */
 		switch_assert(channel->state >= CS_HANGUP);
 	}
-done:
+  done:
 
 	switch_mutex_unlock(channel->flag_mutex);
 	return channel->state;
@@ -1081,7 +1081,7 @@
 		/* Index Originator's Profile */
 		if (originator_caller_profile) {
 			switch_caller_profile_event_set_data(originator_caller_profile, "Other-Leg", event);
-		} else if (originatee_caller_profile) { /* Index Originatee's Profile */
+		} else if (originatee_caller_profile) {	/* Index Originatee's Profile */
 			switch_caller_profile_event_set_data(originatee_caller_profile, "Other-Leg", event);
 		}
 	}
@@ -1152,7 +1152,7 @@
 	caller_profile->next = channel->caller_profile;
 	channel->caller_profile = caller_profile;
 	caller_profile->profile_index = switch_core_sprintf(caller_profile->pool, "%d", ++channel->profile_index);
-	
+
 	switch_mutex_unlock(channel->profile_mutex);
 }
 
@@ -1190,7 +1190,7 @@
 		channel->caller_profile->originatee_caller_profile = caller_profile;
 	}
 	switch_assert(channel->caller_profile->originatee_caller_profile->next != channel->caller_profile->originatee_caller_profile);
-	switch_mutex_unlock(channel->profile_mutex);		
+	switch_mutex_unlock(channel->profile_mutex);
 }
 
 SWITCH_DECLARE(switch_caller_profile_t *) switch_channel_get_originator_caller_profile(switch_channel_t *channel)
@@ -1249,7 +1249,7 @@
 
 	channel->state_handlers[index] = state_handler;
 
-end:
+  end:
 	switch_mutex_unlock(channel->flag_mutex);
 	return index;
 }
@@ -1347,7 +1347,7 @@
 		channel->state = CS_HANGUP;
 		channel->hangup_cause = hangup_cause;
 		switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_NOTICE, "Hangup %s [%s] [%s]\n",
-			channel->name, state_names[last_state], switch_channel_cause2str(channel->hangup_cause));
+						  channel->name, state_names[last_state], switch_channel_cause2str(channel->hangup_cause));
 		if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_HANGUP) == SWITCH_STATUS_SUCCESS) {
 			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Hangup-Cause", "%s", switch_channel_cause2str(channel->hangup_cause));
 			switch_channel_event_set_data(channel, event);
@@ -1408,12 +1408,12 @@
 		}
 
 		/* if we're the child of another channel and the other channel is in a blocking read they will never realize we have answered so send 
-		a SWITCH_SIG_BREAK to interrupt any blocking reads on that channel
-		*/
+		   a SWITCH_SIG_BREAK to interrupt any blocking reads on that channel
+		 */
 		if ((uuid = switch_channel_get_variable(channel, SWITCH_ORIGINATOR_VARIABLE))
 			&& (other_session = switch_core_session_locate(uuid))) {
-				switch_core_session_kill_channel(other_session, SWITCH_SIG_BREAK);
-				switch_core_session_rwunlock(other_session);
+			switch_core_session_kill_channel(other_session, SWITCH_SIG_BREAK);
+			switch_core_session_rwunlock(other_session);
 		}
 		return SWITCH_STATUS_SUCCESS;
 	}
@@ -1443,7 +1443,7 @@
 	msg.message_id = SWITCH_MESSAGE_INDICATE_PROGRESS;
 	msg.from = channel->name;
 	status = switch_core_session_receive_message(channel->session, &msg);
-	
+
 	if (status == SWITCH_STATUS_SUCCESS) {
 		switch_channel_perform_mark_pre_answered(channel, file, func, line);
 	} else {
@@ -1515,12 +1515,12 @@
 	}
 
 	/* if we're the child of another channel and the other channel is in a blocking read they will never realize we have answered so send 
-	a SWITCH_SIG_BREAK to interrupt any blocking reads on that channel
-	*/
+	   a SWITCH_SIG_BREAK to interrupt any blocking reads on that channel
+	 */
 	if ((uuid = switch_channel_get_variable(channel, SWITCH_ORIGINATOR_VARIABLE))
 		&& (other_session = switch_core_session_locate(uuid))) {
-			switch_core_session_kill_channel(other_session, SWITCH_SIG_BREAK);
-			switch_core_session_rwunlock(other_session);
+		switch_core_session_kill_channel(other_session, SWITCH_SIG_BREAK);
+		switch_core_session_rwunlock(other_session);
 	}
 
 	switch_channel_set_variable(channel, "endpoint_disposition", "ANSWER");
@@ -1588,16 +1588,16 @@
 	int nv = 0;
 
 	if (switch_strlen_zero(in)) {
-		return (char *)in;
+		return (char *) in;
 	}
 
 	q = in;
-	while(q && *q) {
+	while (q && *q) {
 		if (!(p = strchr(q, '$'))) {
 			break;
 		}
 
-		if (*(p+1) != '{') {
+		if (*(p + 1) != '{') {
 			q = p + 1;
 			continue;
 		}
@@ -1607,10 +1607,10 @@
 	}
 
 	if (!nv) {
-		return (char *)in;
+		return (char *) in;
 	}
 
-	
+
 	nv = 0;
 	olen = strlen(in) + 1;
 	indup = strdup(in);
@@ -1633,8 +1633,8 @@
 			}
 
 			if (*p == '$' && !nv) {
-				if (*(p+1)) {
-					if (*(p+1) == '{') {
+				if (*(p + 1)) {
+					if (*(p + 1) == '{') {
 						vtype = 1;
 					} else {
 						nv = 1;
@@ -1686,12 +1686,12 @@
 				if ((vval = strchr(vname, '('))) {
 					e = vval - 1;
 					*vval++ = '\0';
-					while(*e == ' ') {
+					while (*e == ' ') {
 						*e-- = '\0';
 					}
 					e = vval;
 					br = 1;
-					while(e && *e) {
+					while (e && *e) {
 						if (*e == '(') {
 							br++;
 						} else if (br > 1 && *e == ')') {
@@ -1712,7 +1712,7 @@
 					int ooffset = 0;
 					char *ptr;
 
-					if ((expanded = switch_channel_expand_variables(channel, (char *)vname)) == vname) {
+					if ((expanded = switch_channel_expand_variables(channel, (char *) vname)) == vname) {
 						expanded = NULL;
 					} else {
 						vname = expanded;
@@ -1735,12 +1735,12 @@
 
 						if (offset >= 0) {
 							sub_val += offset;
-						} else if ((size_t)abs(offset) <= strlen(sub_val)) {
+						} else if ((size_t) abs(offset) <= strlen(sub_val)) {
 							sub_val = cloned_sub_val + (strlen(cloned_sub_val) + offset);
 						}
 
-						if (ooffset > 0 && (size_t)ooffset < strlen(sub_val)) {
-							if ((ptr = (char *)sub_val + ooffset)) {
+						if (ooffset > 0 && (size_t) ooffset < strlen(sub_val)) {
+							if ((ptr = (char *) sub_val + ooffset)) {
 								*ptr = '\0';
 							}
 						}
@@ -1756,7 +1756,7 @@
 					if (stream.data) {
 						char *expanded_vname = NULL;
 
-						if ((expanded_vname = switch_channel_expand_variables(channel, (char *)vname)) == vname) {
+						if ((expanded_vname = switch_channel_expand_variables(channel, (char *) vname)) == vname) {
 							expanded_vname = NULL;
 						} else {
 							vname = expanded_vname;
@@ -1782,7 +1782,7 @@
 						switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
 						free(data);
 						free(indup);
-						return (char *)in;
+						return (char *) in;
 					}
 				}
 				if ((nlen = sub_val ? strlen(sub_val) : 0)) {
@@ -1830,7 +1830,8 @@
 	switch_stream_handle_t stream = { 0 };
 	switch_size_t encode_len = 1024, new_len = 0;
 	char *encode_buf = NULL;
-	const char *prof[12] = { 0 }, *prof_names[12] = {0};
+	const char *prof[12] = { 0 }, *prof_names[12] = {
+	0};
 	char *e = NULL;
 	switch_event_header_t *hi;
 	uint32_t x = 0;
@@ -1938,7 +1939,8 @@
 	char start[80] = "", answer[80] = "", progress[80] = "", progress_media[80] = "", end[80] = "", tmp[80] = "", profile_start[80] = "";
 	int32_t duration = 0, legbillsec = 0, billsec = 0, mduration = 0, billmsec = 0, legbillmsec = 0, progressmsec = 0, progress_mediamsec = 0;
 	switch_time_t uduration = 0, legbillusec = 0, billusec = 0, progresssec = 0, progressusec = 0, progress_mediasec = 0, progress_mediausec = 0;
-	time_t tt_created = 0, tt_answered = 0, tt_progress = 0, tt_progress_media = 0, tt_hungup = 0, mtt_created = 0, mtt_answered = 0, mtt_hungup = 0, tt_prof_created, mtt_prof_created, mtt_progress = 0 , mtt_progress_media = 0;
+	time_t tt_created = 0, tt_answered = 0, tt_progress = 0, tt_progress_media = 0, tt_hungup = 0, mtt_created = 0, mtt_answered = 0, mtt_hungup =
+		0, tt_prof_created, mtt_prof_created, mtt_progress = 0, mtt_progress_media = 0;
 
 	if (!(caller_profile = switch_channel_get_caller_profile(channel)) || !channel->variables) {
 		return SWITCH_STATUS_FALSE;
@@ -1949,13 +1951,13 @@
 		last_app = ap->app;
 		last_arg = ap->arg;
 	}
-	
+
 	if (!(ocp = switch_channel_get_originatee_caller_profile(channel))) {
 		ocp = switch_channel_get_originator_caller_profile(channel);
 	}
 
 	if (!switch_strlen_zero(caller_profile->caller_id_name)) {
-		cid_buf = switch_core_session_sprintf(channel->session, "\"%s\" <%s>", caller_profile->caller_id_name, 
+		cid_buf = switch_core_session_sprintf(channel->session, "\"%s\" <%s>", caller_profile->caller_id_name,
 											  switch_str_nil(caller_profile->caller_id_number));
 	} else {
 		cid_buf = caller_profile->caller_id_number;
@@ -2016,21 +2018,21 @@
 		switch_snprintf(tmp, sizeof(tmp), "%" TIME_T_FMT, tt_answered);
 		switch_channel_set_variable(channel, "answer_epoch", tmp);
 		switch_snprintf(tmp, sizeof(tmp), "%" SWITCH_TIME_T_FMT, caller_profile->times->answered);
-		switch_channel_set_variable(channel, "answer_uepoch", tmp);		
+		switch_channel_set_variable(channel, "answer_uepoch", tmp);
 
 		tt_progress = (time_t) (caller_profile->times->progress / 1000000);
 		mtt_progress = (time_t) (caller_profile->times->progress / 1000);
 		switch_snprintf(tmp, sizeof(tmp), "%" TIME_T_FMT, tt_progress);
 		switch_channel_set_variable(channel, "answer_epoch", tmp);
 		switch_snprintf(tmp, sizeof(tmp), "%" SWITCH_TIME_T_FMT, caller_profile->times->progress);
-		switch_channel_set_variable(channel, "answer_uepoch", tmp);		
+		switch_channel_set_variable(channel, "answer_uepoch", tmp);
 
 		tt_progress_media = (time_t) (caller_profile->times->progress_media / 1000000);
 		mtt_progress_media = (time_t) (caller_profile->times->progress_media / 1000);
 		switch_snprintf(tmp, sizeof(tmp), "%" TIME_T_FMT, tt_progress_media);
 		switch_channel_set_variable(channel, "answer_epoch", tmp);
 		switch_snprintf(tmp, sizeof(tmp), "%" SWITCH_TIME_T_FMT, caller_profile->times->progress_media);
-		switch_channel_set_variable(channel, "answer_uepoch", tmp);		
+		switch_channel_set_variable(channel, "answer_uepoch", tmp);
 
 
 		tt_hungup = (time_t) (caller_profile->times->hungup / 1000000);
@@ -2041,28 +2043,28 @@
 		switch_channel_set_variable(channel, "end_uepoch", tmp);
 
 		uduration = caller_profile->times->hungup - caller_profile->times->created;
-		duration = (int32_t)(tt_hungup - tt_created);
-		mduration = (int32_t)(mtt_hungup - mtt_created);
+		duration = (int32_t) (tt_hungup - tt_created);
+		mduration = (int32_t) (mtt_hungup - mtt_created);
 
 		if (caller_profile->times->answered) {
-			billsec = (int32_t)(tt_hungup - tt_answered);
-			billmsec = (int32_t)(mtt_hungup - mtt_answered);
+			billsec = (int32_t) (tt_hungup - tt_answered);
+			billmsec = (int32_t) (mtt_hungup - mtt_answered);
 			billusec = caller_profile->times->hungup - caller_profile->times->answered;
 
-			legbillsec = (int32_t)(tt_hungup - tt_prof_created);
-			legbillmsec = (int32_t)(mtt_hungup - mtt_prof_created);
+			legbillsec = (int32_t) (tt_hungup - tt_prof_created);
+			legbillmsec = (int32_t) (mtt_hungup - mtt_prof_created);
 			legbillusec = caller_profile->times->hungup - caller_profile->times->profile_created;
 		}
 
 		if (caller_profile->times->progress) {
-			progresssec = (int32_t)(tt_progress - tt_created);
-			progressmsec = (int32_t)(mtt_progress - mtt_created);
+			progresssec = (int32_t) (tt_progress - tt_created);
+			progressmsec = (int32_t) (mtt_progress - mtt_created);
 			progressusec = caller_profile->times->progress - caller_profile->times->created;
 		}
 
 		if (caller_profile->times->progress_media) {
-			progress_mediasec = (int32_t)(tt_progress - tt_created);
-			progress_mediamsec = (int32_t)(mtt_progress - mtt_created);
+			progress_mediasec = (int32_t) (tt_progress - tt_created);
+			progress_mediamsec = (int32_t) (mtt_progress - mtt_created);
 			progress_mediausec = caller_profile->times->progress - caller_profile->times->created;
 		}
 

Modified: freeswitch/trunk/src/switch_config.c
==============================================================================
--- freeswitch/trunk/src/switch_config.c	(original)
+++ freeswitch/trunk/src/switch_config.c	Tue May 27 00:30:03 2008
@@ -33,7 +33,7 @@
 #include <switch.h>
 #include <switch_config.h>
 
-SWITCH_DECLARE(int) switch_config_open_file(switch_config_t * cfg, char *file_path)
+SWITCH_DECLARE(int) switch_config_open_file(switch_config_t *cfg, char *file_path)
 {
 	FILE *f;
 	char *path = NULL;
@@ -88,7 +88,7 @@
 	}
 }
 
-SWITCH_DECLARE(void) switch_config_close_file(switch_config_t * cfg)
+SWITCH_DECLARE(void) switch_config_close_file(switch_config_t *cfg)
 {
 
 	if (cfg->file) {
@@ -98,7 +98,7 @@
 	memset(cfg, 0, sizeof(*cfg));
 }
 
-SWITCH_DECLARE(int) switch_config_next_pair(switch_config_t * cfg, char **var, char **val)
+SWITCH_DECLARE(int) switch_config_next_pair(switch_config_t *cfg, char **var, char **val)
 {
 	int ret = 0;
 	char *p, *end;

Modified: freeswitch/trunk/src/switch_console.c
==============================================================================
--- freeswitch/trunk/src/switch_console.c	(original)
+++ freeswitch/trunk/src/switch_console.c	Tue May 27 00:30:03 2008
@@ -53,12 +53,12 @@
 	char *cf = "switch.conf";
 	switch_xml_t cfg, xml, settings, param;
 
-    /* clear the keybind array */
-    int i;
+	/* clear the keybind array */
+	int i;
 
-    for (i = 0; i < 12; i++) {
-        console_fnkeys[i] = NULL;
-    }
+	for (i = 0; i < 12; i++) {
+		console_fnkeys[i] = NULL;
+	}
 
 	if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
@@ -69,13 +69,13 @@
 		for (param = switch_xml_child(settings, "key"); param; param = param->next) {
 			char *var = (char *) switch_xml_attr_soft(param, "name");
 			char *val = (char *) switch_xml_attr_soft(param, "value");
-            int i = atoi(var);
-            if ((i < 1) || (i > 12)) {
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "keybind %s is invalid, range is from 1 to 12\n", var);
-            } else {
-                // Add the command to the fnkey array
-                console_fnkeys[i - 1] = switch_core_permanent_strdup(val);
-            }
+			int i = atoi(var);
+			if ((i < 1) || (i > 12)) {
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "keybind %s is invalid, range is from 1 to 12\n", var);
+			} else {
+				// Add the command to the fnkey array
+				console_fnkeys[i - 1] = switch_core_permanent_strdup(val);
+			}
 		}
 	}
 
@@ -169,7 +169,7 @@
 	char *exp = NULL;
 	switch_core_db_t *db = switch_core_db_handle();
 	int full = 0;
-	
+
 	sql = switch_mprintf("select command from aliases where alias='%q'", cmd);
 
 	switch_core_db_exec(db, sql, alias_callback, &r, &errmsg);
@@ -181,9 +181,9 @@
 
 	if (!r) {
 		sql = switch_mprintf("select command from aliases where alias='%q %q'", cmd, arg);
-		
+
 		switch_core_db_exec(db, sql, alias_callback, &r, &errmsg);
-		
+
 		if (errmsg) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "error [%s][%s]\n", sql, errmsg);
 			free(errmsg);
@@ -270,7 +270,7 @@
 	if (ret == -1) {
 		fprintf(stderr, "Memory Error\n");
 		goto done;
-	} 
+	}
 
 	if (channel == SWITCH_CHANNEL_ID_LOG_CLEAN) {
 		fprintf(handle, "%s", data);
@@ -283,11 +283,10 @@
 	if (channel == SWITCH_CHANNEL_ID_LOG) {
 		fprintf(handle, "[%d] %s %s:%d %s() %s", (int) getpid(), date, filep, line, func, data);
 		goto done;
-	} 
+	}
 
 	if (channel == SWITCH_CHANNEL_ID_EVENT &&
-		switch_event_running() == SWITCH_STATUS_SUCCESS && 
-		switch_event_create(&event, SWITCH_EVENT_LOG) == SWITCH_STATUS_SUCCESS) {
+		switch_event_running() == SWITCH_STATUS_SUCCESS && switch_event_create(&event, SWITCH_EVENT_LOG) == SWITCH_STATUS_SUCCESS) {
 
 		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Log-Data", "%s", data);
 		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Log-File", "%s", filep);
@@ -296,7 +295,7 @@
 		switch_event_fire(&event);
 	}
 
-done:
+  done:
 	if (data) {
 		free(data);
 	}
@@ -313,71 +312,85 @@
 /*
  * If a fnkey is configured then process the command
  */
-static unsigned char console_fnkey_pressed(int i) {
+static unsigned char console_fnkey_pressed(int i)
+{
 	char *c, *cmd;
 
-    assert((i > 0) && (i <= 12));
+	assert((i > 0) && (i <= 12));
 
-    c = console_fnkeys[i-1];
+	c = console_fnkeys[i - 1];
 
-    // This new line is necessary to avoid output to begin after the ">" of the CLI's prompt
-	switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_CONSOLE,"\n");
+	// This new line is necessary to avoid output to begin after the ">" of the CLI's prompt
+	switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_CONSOLE, "\n");
+
+	if (c == NULL) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "FUNCTION KEY F%d IS NOT BOUND, please edit switch.conf XML file\n", i);
+		return CC_REDISPLAY;
+	}
 
-    if (c == NULL) {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "FUNCTION KEY F%d IS NOT BOUND, please edit switch.conf XML file\n", i);
-        return CC_REDISPLAY;
-    }
-	
 	cmd = strdup(c);
 	switch_console_process(cmd, 0);
 	free(cmd);
 
-    return CC_REDISPLAY;
+	return CC_REDISPLAY;
 }
 
-static unsigned char console_f1key(EditLine *el, int ch) {
-    return console_fnkey_pressed(1);
+static unsigned char console_f1key(EditLine * el, int ch)
+{
+	return console_fnkey_pressed(1);
 }
-static unsigned char console_f2key(EditLine *el, int ch) {
-    return console_fnkey_pressed(2);
+static unsigned char console_f2key(EditLine * el, int ch)
+{
+	return console_fnkey_pressed(2);
 }
-static unsigned char console_f3key(EditLine *el, int ch) {
-    return console_fnkey_pressed(3);
+static unsigned char console_f3key(EditLine * el, int ch)
+{
+	return console_fnkey_pressed(3);
 }
-static unsigned char console_f4key(EditLine *el, int ch) {
-    return console_fnkey_pressed(4);
+static unsigned char console_f4key(EditLine * el, int ch)
+{
+	return console_fnkey_pressed(4);
 }
-static unsigned char console_f5key(EditLine *el, int ch) {
-    return console_fnkey_pressed(5);
+static unsigned char console_f5key(EditLine * el, int ch)
+{
+	return console_fnkey_pressed(5);
 }
-static unsigned char console_f6key(EditLine *el, int ch) {
-    return console_fnkey_pressed(6);
+static unsigned char console_f6key(EditLine * el, int ch)
+{
+	return console_fnkey_pressed(6);
 }
-static unsigned char console_f7key(EditLine *el, int ch) {
-    return console_fnkey_pressed(7);
+static unsigned char console_f7key(EditLine * el, int ch)
+{
+	return console_fnkey_pressed(7);
 }
-static unsigned char console_f8key(EditLine *el, int ch) {
-    return console_fnkey_pressed(8);
+static unsigned char console_f8key(EditLine * el, int ch)
+{
+	return console_fnkey_pressed(8);
 }
-static unsigned char console_f9key(EditLine *el, int ch) {
-    return console_fnkey_pressed(9);
+static unsigned char console_f9key(EditLine * el, int ch)
+{
+	return console_fnkey_pressed(9);
 }
-static unsigned char console_f10key(EditLine *el, int ch) {
-    return console_fnkey_pressed(10);
+static unsigned char console_f10key(EditLine * el, int ch)
+{
+	return console_fnkey_pressed(10);
 }
-static unsigned char console_f11key(EditLine *el, int ch) {
-    return console_fnkey_pressed(11);
+static unsigned char console_f11key(EditLine * el, int ch)
+{
+	return console_fnkey_pressed(11);
 }
-static unsigned char console_f12key(EditLine *el, int ch) {
-    return console_fnkey_pressed(12);
+static unsigned char console_f12key(EditLine * el, int ch)
+{
+	return console_fnkey_pressed(12);
 }
 
 
-char * prompt(EditLine *e) {
+char *prompt(EditLine * e)
+{
 	if (*prompt_str == '\0') {
 		gethostname(hostname, sizeof(hostname));
 		switch_snprintf(prompt_str, sizeof(prompt_str), "freeswitch@%s> ", hostname);
-	}	
+	}
 
 	return prompt_str;
 }
@@ -408,22 +421,22 @@
 				char *cmd = strdup(line);
 				char *p;
 				const LineInfo *lf = el_line(el);
-				char *foo = (char *)lf->buffer;
+				char *foo = (char *) lf->buffer;
 				if ((p = strrchr(cmd, '\r')) || (p = strrchr(cmd, '\n'))) {
 					*p = '\0';
 				}
 				assert(cmd != NULL);
 				history(myhistory, &ev, H_ENTER, line);
 				running = switch_console_process(cmd, 0);
-				el_deletestr(el, strlen(foo)+1);
+				el_deletestr(el, strlen(foo) + 1);
 				memset(foo, 0, strlen(foo));
 				free(cmd);
 			}
 		}
 		switch_yield(1000);
 	}
-	
-  	switch_core_destroy_memory_pool(&pool);	
+
+	switch_core_destroy_memory_pool(&pool);
 	return NULL;
 }
 
@@ -441,7 +454,7 @@
 {
 	struct helper *h = (struct helper *) pArg;
 	char *target = NULL;
-	
+
 	target = argv[0];
 
 	if (!target) {
@@ -449,17 +462,17 @@
 	}
 
 	fprintf(h->out, "%20s\t", target);
-	
+
 	switch_copy_string(h->last, target, sizeof(h->last));
 
 	if ((++h->hits % 4) == 0) {
 		fprintf(h->out, "\n");
 	}
-	
+
 	return 0;
 }
 
-static unsigned char complete(EditLine *el, int ch)
+static unsigned char complete(EditLine * el, int ch)
 {
 	switch_core_db_t *db = switch_core_db_handle();
 	char *sql;
@@ -475,13 +488,13 @@
 
 	if ((p = strchr(buf, '\r')) || (p = strchr(buf, '\n'))) {
 		*p = '\0';
-	}	
-	
-	while(*buf == ' ') {
+	}
+
+	while (*buf == ' ') {
 		buf++;
 	}
 
-	for(p = buf; p && *p; p++) {
+	for (p = buf; p && *p; p++) {
 		if (*p == ' ') {
 			lp = p;
 			h.words++;
@@ -491,9 +504,9 @@
 	if (lp) {
 		buf = lp + 1;
 	}
-	
+
 	h.len = strlen(buf);
-	
+
 	fprintf(h.out, "\n\n");
 
 	if (h.words == 0) {
@@ -503,7 +516,7 @@
 	}
 
 	switch_core_db_exec(db, sql, comp_callback, &h, &errmsg);
-	
+
 	if (errmsg) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "error [%s][%s]\n", sql, errmsg);
 		free(errmsg);
@@ -515,28 +528,25 @@
 		char *dupdup = strdup(dup);
 		switch_assert(dupdup);
 		int x, argc = 0;
-		char *argv[10] = {0};
+		char *argv[10] = { 0 };
 		switch_stream_handle_t stream = { 0 };
 		SWITCH_STANDARD_STREAM(stream);
 
-		
+
 		argc = switch_separate_string(dupdup, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
 
 		if (h.words == 0) {
-			stream.write_function(&stream, 
-								  "select distinct a1 from complete where "
-								  "a1 not in (select name from interfaces) %s ", argc ? "and" : "");
+			stream.write_function(&stream, "select distinct a1 from complete where " "a1 not in (select name from interfaces) %s ", argc ? "and" : "");
 		} else {
-			stream.write_function(&stream, 
-								  "select distinct a%d from complete where ", h.words + 1);
-								  
+			stream.write_function(&stream, "select distinct a%d from complete where ", h.words + 1);
+
 		}
 
-		for(x = 0; x < argc; x++) {
-			stream.write_function(&stream, "(a%d = '' or a%d like '%s%%')%s", x+1, x+1, switch_str_nil(argv[x]), x == argc -1 ? "" : " and ");
+		for (x = 0; x < argc; x++) {
+			stream.write_function(&stream, "(a%d = '' or a%d like '%s%%')%s", x + 1, x + 1, switch_str_nil(argv[x]), x == argc - 1 ? "" : " and ");
 		}
-		
-		switch_core_db_exec(db, stream.data, comp_callback, &h, &errmsg);	
+
+		switch_core_db_exec(db, stream.data, comp_callback, &h, &errmsg);
 
 		if (errmsg) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "error [%s][%s]\n", (char *) stream.data, errmsg);
@@ -546,20 +556,20 @@
 
 		switch_safe_free(dupdup);
 		switch_safe_free(stream.data);
-		
+
 		if (ret == CC_ERROR) {
 			goto end;
 		}
 	}
 
 	fprintf(h.out, "\n\n");
-	
+
 	if (h.hits == 1) {
 		el_deletestr(el, h.len);
 		el_insertstr(el, h.last);
 	}
 
- end:
+  end:
 
 	fflush(h.out);
 
@@ -567,14 +577,14 @@
 	switch_safe_free(dup);
 
 	switch_core_db_close(db);
-	
+
 	return (ret);
 }
 
 
 SWITCH_DECLARE(switch_status_t) switch_console_set_complete(const char *string)
 {
-	char *mydata = NULL, *argv[11] = {0};
+	char *mydata = NULL, *argv[11] = { 0 };
 	int argc, x;
 	switch_status_t status = SWITCH_STATUS_FALSE;
 
@@ -587,26 +597,26 @@
 
 			if (!strcasecmp(argv[0], "stickyadd")) {
 				mystream.write_function(&mystream, "insert into complete values (1,");
-				for(x = 0; x < 10; x++) {
-					mystream.write_function(&mystream, "'%s'%s", switch_str_nil(argv[x+1]), x == 9 ? ")" : ", ");
+				for (x = 0; x < 10; x++) {
+					mystream.write_function(&mystream, "'%s'%s", switch_str_nil(argv[x + 1]), x == 9 ? ")" : ", ");
 				}
 				switch_core_db_persistant_execute(db, mystream.data, 5);
 				status = SWITCH_STATUS_SUCCESS;
 			} else if (!strcasecmp(argv[0], "add")) {
 				mystream.write_function(&mystream, "insert into complete values (0,");
-				for(x = 0; x < 10; x++) {
-					mystream.write_function(&mystream, "'%s'%s", switch_str_nil(argv[x+1]), x == 9 ? ")" : ", ");
+				for (x = 0; x < 10; x++) {
+					mystream.write_function(&mystream, "'%s'%s", switch_str_nil(argv[x + 1]), x == 9 ? ")" : ", ");
 				}
 				switch_core_db_persistant_execute(db, mystream.data, 5);
 				status = SWITCH_STATUS_SUCCESS;
 			} else if (!strcasecmp(argv[0], "del")) {
 				char *what = argv[1];
-                if (!strcasecmp(what, "*")) {
+				if (!strcasecmp(what, "*")) {
 					switch_core_db_persistant_execute(db, "delete from complete", 1);
 				} else {
 					mystream.write_function(&mystream, "delete from complete where ");
-					for(x = 0; x < argc - 1; x++) {
-						mystream.write_function(&mystream, "a%d = '%s'%s", x+1, switch_str_nil(argv[x+1]), x == argc - 2 ? "" : " and ");
+					for (x = 0; x < argc - 1; x++) {
+						mystream.write_function(&mystream, "a%d = '%s'%s", x + 1, switch_str_nil(argv[x + 1]), x == argc - 2 ? "" : " and ");
 					}
 					switch_core_db_persistant_execute(db, mystream.data, 1);
 				}
@@ -626,10 +636,10 @@
 
 SWITCH_DECLARE(switch_status_t) switch_console_set_alias(const char *string)
 {
-	char *mydata = NULL, *argv[3] = {0};
+	char *mydata = NULL, *argv[3] = { 0 };
 	int argc;
 	switch_status_t status = SWITCH_STATUS_FALSE;
-	
+
 	if (string && (mydata = strdup(string))) {
 		if ((argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) >= 2) {
 			switch_core_db_t *db = switch_core_db_handle();
@@ -652,7 +662,7 @@
 				status = SWITCH_STATUS_SUCCESS;
 			} else if (!strcasecmp(argv[0], "del") && argc == 2) {
 				char *what = argv[1];
-                if (!strcasecmp(what, "*")) {
+				if (!strcasecmp(what, "*")) {
 					switch_core_db_persistant_execute(db, "delete from aliases", 1);
 				} else {
 					sql = switch_mprintf("delete from aliases where alias='%q'", argv[1]);
@@ -664,7 +674,7 @@
 			switch_core_db_close(db);
 		}
 	}
-	
+
 	switch_safe_free(mydata);
 
 	return status;
@@ -686,44 +696,44 @@
 	el = el_init(__FILE__, switch_core_get_console(), switch_core_get_console(), switch_core_get_console());
 	el_set(el, EL_PROMPT, &prompt);
 	el_set(el, EL_EDITOR, "emacs");
-    /* AGX: Bind Keyboard function keys. This has been tested with:
-     * - linux console keyabord
-     * - putty.exe connected via ssh to linux
-     */
-    /* Load/Init the config first */
-    console_xml_config();
-    /* Bind the functions to the key */
-    el_set(el, EL_ADDFN, "f1-key", "F1 KEY PRESS", console_f1key );
-    el_set(el, EL_ADDFN, "f2-key", "F2 KEY PRESS", console_f2key );
-    el_set(el, EL_ADDFN, "f3-key", "F3 KEY PRESS", console_f3key );
-    el_set(el, EL_ADDFN, "f4-key", "F4 KEY PRESS", console_f4key );
-    el_set(el, EL_ADDFN, "f5-key", "F5 KEY PRESS", console_f5key );
-    el_set(el, EL_ADDFN, "f6-key", "F6 KEY PRESS", console_f6key );
-    el_set(el, EL_ADDFN, "f7-key", "F7 KEY PRESS", console_f7key );
-    el_set(el, EL_ADDFN, "f8-key", "F8 KEY PRESS", console_f8key );
-    el_set(el, EL_ADDFN, "f9-key", "F9 KEY PRESS", console_f9key );
-    el_set(el, EL_ADDFN, "f10-key", "F10 KEY PRESS", console_f10key );
-    el_set(el, EL_ADDFN, "f11-key", "F11 KEY PRESS", console_f11key );
-    el_set(el, EL_ADDFN, "f12-key", "F12 KEY PRESS", console_f12key );
-
-    el_set(el, EL_BIND, "\033OP", "f1-key", NULL);
-    el_set(el, EL_BIND, "\033OQ", "f2-key", NULL);
-    el_set(el, EL_BIND, "\033OR", "f3-key", NULL);
-    el_set(el, EL_BIND, "\033OS", "f4-key", NULL);
-
-	
-    el_set(el, EL_BIND, "\033[11~", "f1-key", NULL);
-    el_set(el, EL_BIND, "\033[12~", "f2-key", NULL);
-    el_set(el, EL_BIND, "\033[13~", "f3-key", NULL);
-    el_set(el, EL_BIND, "\033[14~", "f4-key", NULL);
-    el_set(el, EL_BIND, "\033[15~", "f5-key", NULL);
-    el_set(el, EL_BIND, "\033[17~", "f6-key", NULL);
-    el_set(el, EL_BIND, "\033[18~", "f7-key", NULL);
-    el_set(el, EL_BIND, "\033[19~", "f8-key", NULL);
-    el_set(el, EL_BIND, "\033[20~", "f9-key", NULL);
-    el_set(el, EL_BIND, "\033[21~", "f10-key", NULL);
-    el_set(el, EL_BIND, "\033[23~", "f11-key", NULL);
-    el_set(el, EL_BIND, "\033[24~", "f12-key", NULL);
+	/* AGX: Bind Keyboard function keys. This has been tested with:
+	 * - linux console keyabord
+	 * - putty.exe connected via ssh to linux
+	 */
+	/* Load/Init the config first */
+	console_xml_config();
+	/* Bind the functions to the key */
+	el_set(el, EL_ADDFN, "f1-key", "F1 KEY PRESS", console_f1key);
+	el_set(el, EL_ADDFN, "f2-key", "F2 KEY PRESS", console_f2key);
+	el_set(el, EL_ADDFN, "f3-key", "F3 KEY PRESS", console_f3key);
+	el_set(el, EL_ADDFN, "f4-key", "F4 KEY PRESS", console_f4key);
+	el_set(el, EL_ADDFN, "f5-key", "F5 KEY PRESS", console_f5key);
+	el_set(el, EL_ADDFN, "f6-key", "F6 KEY PRESS", console_f6key);
+	el_set(el, EL_ADDFN, "f7-key", "F7 KEY PRESS", console_f7key);
+	el_set(el, EL_ADDFN, "f8-key", "F8 KEY PRESS", console_f8key);
+	el_set(el, EL_ADDFN, "f9-key", "F9 KEY PRESS", console_f9key);
+	el_set(el, EL_ADDFN, "f10-key", "F10 KEY PRESS", console_f10key);
+	el_set(el, EL_ADDFN, "f11-key", "F11 KEY PRESS", console_f11key);
+	el_set(el, EL_ADDFN, "f12-key", "F12 KEY PRESS", console_f12key);
+
+	el_set(el, EL_BIND, "\033OP", "f1-key", NULL);
+	el_set(el, EL_BIND, "\033OQ", "f2-key", NULL);
+	el_set(el, EL_BIND, "\033OR", "f3-key", NULL);
+	el_set(el, EL_BIND, "\033OS", "f4-key", NULL);
+
+
+	el_set(el, EL_BIND, "\033[11~", "f1-key", NULL);
+	el_set(el, EL_BIND, "\033[12~", "f2-key", NULL);
+	el_set(el, EL_BIND, "\033[13~", "f3-key", NULL);
+	el_set(el, EL_BIND, "\033[14~", "f4-key", NULL);
+	el_set(el, EL_BIND, "\033[15~", "f5-key", NULL);
+	el_set(el, EL_BIND, "\033[17~", "f6-key", NULL);
+	el_set(el, EL_BIND, "\033[18~", "f7-key", NULL);
+	el_set(el, EL_BIND, "\033[19~", "f8-key", NULL);
+	el_set(el, EL_BIND, "\033[20~", "f9-key", NULL);
+	el_set(el, EL_BIND, "\033[21~", "f10-key", NULL);
+	el_set(el, EL_BIND, "\033[23~", "f11-key", NULL);
+	el_set(el, EL_BIND, "\033[24~", "f12-key", NULL);
 
 
 	el_set(el, EL_ADDFN, "ed-complete", "Complete argument", complete);
@@ -746,7 +756,7 @@
 	switch_threadattr_detach_set(thd_attr, 1);
 	switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
 	switch_thread_create(&thread, thd_attr, console_thread, pool, pool);
-	
+
 	while (running) {
 		int32_t arg = 0;
 		switch_core_session_ctl(SCSC_CHECK_RUNNING, &arg);
@@ -758,7 +768,7 @@
 
 	history(myhistory, &ev, H_SAVE, hfile);
 	free(hfile);
-	
+
 	/* Clean up our memory */
 	history_end(myhistory);
 	el_end(el);

Modified: freeswitch/trunk/src/switch_core.c
==============================================================================
--- freeswitch/trunk/src/switch_core.c	(original)
+++ freeswitch/trunk/src/switch_core.c	Tue May 27 00:30:03 2008
@@ -172,7 +172,7 @@
 }
 
 
-static void *switch_core_service_thread(switch_thread_t * thread, void *obj)
+static void *switch_core_service_thread(switch_thread_t *thread, void *obj)
 {
 	switch_core_thread_session_t *data = obj;
 	switch_core_session_t *session = data->objs[0];
@@ -362,7 +362,7 @@
 #endif
 #endif
 	}
-	
+
 	dir_path = switch_mprintf("%s%ssounds", SWITCH_GLOBAL_dirs.base_dir, SWITCH_PATH_SEPARATOR);
 	switch_dir_make_recursive(dir_path,
 							  SWITCH_FPROT_UREAD | SWITCH_FPROT_UWRITE | SWITCH_FPROT_UEXECUTE | SWITCH_FPROT_GREAD | SWITCH_FPROT_GEXECUTE,
@@ -436,8 +436,7 @@
 	 * So let's try to remove the mlock limit here...
 	 */
 	if (setrlimit(RLIMIT_MEMLOCK, &lim) < 0) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT,
-			 "Failed to disable memlock limit, application may crash if run as non-root user!\n");
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Failed to disable memlock limit, application may crash if run as non-root user!\n");
 	}
 #endif
 
@@ -463,7 +462,7 @@
 		/*
 		 * Lookup user information in the system's db
 		 */
-		runas_pw = getpwnam( user );
+		runas_pw = getpwnam(user);
 		if (!runas_pw) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Unknown user \"%s\"\n", user);
 			return -1;
@@ -477,7 +476,7 @@
 		/*
 		 * Lookup group information in the system's db
 		 */
-		gr = getgrnam( group );
+		gr = getgrnam(group);
 		if (!gr) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Unknown group \"%s\"\n", group);
 			return -1;
@@ -514,7 +513,6 @@
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Failed to change gid!\n");
 				return -1;
 			}
-
 #ifdef HAVE_INITGROUPS
 			/*
 			 * Set all the other groups the user is a member of
@@ -573,7 +571,7 @@
 	return (const char *) switch_core_hash_find(runtime.mime_types, ext);
 }
 
-                         
+
 SWITCH_DECLARE(switch_hash_index_t *) switch_core_mime_index(void)
 {
 	return switch_hash_first(NULL, runtime.mime_types);
@@ -605,17 +603,17 @@
 					switch_core_hash_insert(runtime.mime_types, argv[x], ptype);
 				}
 			}
-			
+
 			status = SWITCH_STATUS_SUCCESS;
 		}
-		
+
 		free(ext_list);
 	}
 
 	return status;
 }
 
-static void load_mime_types(void) 
+static void load_mime_types(void)
 {
 	char *cf = "mime.types";
 	int fd = -1;
@@ -630,7 +628,7 @@
 		return;
 	}
 
-	while((switch_fd_read_line(fd, line_buf, sizeof(line_buf)))) {
+	while ((switch_fd_read_line(fd, line_buf, sizeof(line_buf)))) {
 		char *p;
 		char *type = line_buf;
 
@@ -645,20 +643,20 @@
 		if ((p = strchr(type, '\t')) || (p = strchr(type, ' '))) {
 			*p++ = '\0';
 
-			while(*p == ' ' || *p == '\t') {
+			while (*p == ' ' || *p == '\t') {
 				p++;
 			}
 
 			switch_core_mime_add_type(type, p);
 		}
-		
+
 	}
 
 	if (fd > -1) {
 		close(fd);
 		fd = -1;
 	}
-}	
+}
 
 SWITCH_DECLARE(void) switch_core_setrlimits(void)
 {
@@ -667,10 +665,10 @@
 
 	/* 
 	   Setting the stack size on FreeBSD results in an instant crash.
-		 
+
 	   If anyone knows how to fix this,
 	   feel free to submit a patch to http://jira.freeswitch.org 
-	*/
+	 */
 
 #ifndef __FreeBSD__
 	memset(&rlp, 0, sizeof(rlp));
@@ -710,10 +708,10 @@
 	switch_network_list_t *list;
 	uint32_t ip, net, mask, bits;
 	switch_bool_t ok = SWITCH_FALSE;
-	
+
 	switch_mutex_lock(runtime.global_mutex);
 	switch_inet_pton(AF_INET, ip_str, &ip);
-	
+
 	if ((list = switch_core_hash_find(IP_LIST.hash, list_name))) {
 		ok = switch_network_list_validate_ip(list, ip);
 	} else if (strchr(list_name, '/')) {
@@ -721,7 +719,7 @@
 		ok = switch_test_subnet(ip, net, mask);
 	}
 	switch_mutex_unlock(runtime.global_mutex);
-	
+
 	return ok;
 }
 
@@ -741,11 +739,11 @@
 	if (IP_LIST.pool) {
 		switch_core_destroy_memory_pool(&IP_LIST.pool);
 	}
-	
+
 	memset(&IP_LIST, 0, sizeof(IP_LIST));
 	switch_core_new_memory_pool(&IP_LIST.pool);
 	switch_core_hash_init(&IP_LIST.hash, IP_LIST.pool);
-	
+
 	if ((xml = switch_xml_open_cfg("acl.conf", &cfg, NULL))) {
 		if ((x_lists = switch_xml_child(cfg, "network-lists"))) {
 			for (x_list = switch_xml_child(x_lists, "list"); x_list; x_list = x_list->next) {
@@ -760,7 +758,7 @@
 				if (dft) {
 					default_type = switch_true(dft);
 				}
-				
+
 				if (switch_network_list_create(&list, default_type, IP_LIST.pool) != SWITCH_STATUS_SUCCESS) {
 					abort();
 				}
@@ -779,35 +777,36 @@
 
 					if (type) {
 						ok = switch_true(type);
-					}					
+					}
 
 					cidr = switch_xml_attr(x_node, "cidr");
 					host = switch_xml_attr(x_node, "host");
 					mask = switch_xml_attr(x_node, "mask");
-					
+
 					if (cidr) {
 						if (switch_network_list_add_cidr(list, cidr, ok) == SWITCH_STATUS_SUCCESS) {
 							if (reload) {
 								switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Adding %s (%s) to list %s\n", cidr, ok ? "allow" : "deny", name);
 							} else {
-								switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Adding %s (%s) to list %s\n", cidr, ok ? "allow" : "deny", name);
+								switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Adding %s (%s) to list %s\n", cidr, ok ? "allow" : "deny",
+												  name);
 							}
 						} else {
 							if (reload) {
-								switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, 
+								switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
 												  "Error Adding %s (%s) to list %s\n", cidr, ok ? "allow" : "deny", name);
 							} else {
-								switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, 
+								switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE,
 												  "Error Adding %s (%s) to list %s\n", cidr, ok ? "allow" : "deny", name);
 							}
 						}
 					} else if (host && mask) {
 						if (switch_network_list_add_host_mask(list, host, mask, ok) == SWITCH_STATUS_SUCCESS) {
 							if (reload) {
-								switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, 
+								switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE,
 												  "Adding %s/%s (%s) to list %s\n", host, mask, ok ? "allow" : "deny", name);
 							} else {
-								switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, 
+								switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE,
 												  "Adding %s/%s (%s) to list %s\n", host, mask, ok ? "allow" : "deny", name);
 							}
 						}
@@ -855,8 +854,8 @@
 	memset(&runtime, 0, sizeof(runtime));
 
 	runtime.dummy_cng_frame.data = runtime.dummy_data;
-	runtime.dummy_cng_frame.datalen= sizeof(runtime.dummy_data);
-	runtime.dummy_cng_frame.buflen= sizeof(runtime.dummy_data);
+	runtime.dummy_cng_frame.datalen = sizeof(runtime.dummy_data);
+	runtime.dummy_cng_frame.buflen = sizeof(runtime.dummy_data);
 	runtime.dummy_cng_frame.flags = SFF_CNG;
 
 	switch_set_flag((&runtime), SCF_NO_NEW_SESSIONS);
@@ -914,17 +913,16 @@
 						switch_set_flag((&runtime), SCF_CRASH_PROT);
 					}
 				} else if (!strcasecmp(var, "loglevel")) {
-                    int level;                                                                                                                                  
-                    if (*val > 47 && *val < 58) {
-                        level = atoi(val);
-                    } else {
-                        level = switch_log_str2level(val);
-                    }
+					int level;
+					if (*val > 47 && *val < 58) {
+						level = atoi(val);
+					} else {
+						level = switch_log_str2level(val);
+					}
 
 					if (level != SWITCH_LOG_INVALID) {
-	                    switch_core_session_ctl(SCSC_LOGLEVEL, &level);
+						switch_core_session_ctl(SCSC_LOGLEVEL, &level);
 					}
-					
 #ifdef HAVE_SETRLIMIT
 				} else if (!strcasecmp(var, "dump-cores")) {
 					struct rlimit rlp;
@@ -942,23 +940,21 @@
 				} else if (!strcasecmp(var, "max_dtmf_duration")) {
 					int tmp = atoi(val);
 					if (tmp > 0) {
-						switch_core_max_dtmf_duration((uint32_t)tmp);
+						switch_core_max_dtmf_duration((uint32_t) tmp);
 					}
 				} else if (!strcasecmp(var, "default_dtmf_duration")) {
 					int tmp = atoi(val);
 					if (tmp > 0) {
-						switch_core_default_dtmf_duration((uint32_t)tmp);
+						switch_core_default_dtmf_duration((uint32_t) tmp);
 					}
 				} else if (!strcasecmp(var, "disable-monotonic-timing")) {
 					switch_time_set_monotonic(SWITCH_FALSE);
 				} else if (!strcasecmp(var, "max-sessions")) {
 					switch_core_session_limit(atoi(val));
-				}
-				else if (!strcasecmp(var, "rtp-start-port")) {
-					switch_rtp_set_start_port((switch_port_t)atoi(val));
-				}
-				else if (!strcasecmp(var, "rtp-end-port")) {
-					switch_rtp_set_end_port((switch_port_t)atoi(val));
+				} else if (!strcasecmp(var, "rtp-start-port")) {
+					switch_rtp_set_start_port((switch_port_t) atoi(val));
+				} else if (!strcasecmp(var, "rtp-end-port")) {
+					switch_rtp_set_end_port((switch_port_t) atoi(val));
 				}
 			}
 		}
@@ -1059,7 +1055,7 @@
 {
 	if (sig) {
 		switch_event_t *event;
-		
+
 		if (switch_event_create(&event, SWITCH_EVENT_TRAP) == SWITCH_STATUS_SUCCESS) {
 			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Trapped-Signal", "HUP");
 			switch_event_fire(&event);
@@ -1094,7 +1090,7 @@
 #endif
 
 	signal(SIGHUP, handle_SIGHUP);
-	switch_load_network_lists(SWITCH_FALSE);	
+	switch_load_network_lists(SWITCH_FALSE);
 
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Bringing up environment.\n");
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Loading Modules.\n");
@@ -1110,12 +1106,10 @@
 	}
 
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE,
-					  "\nFreeSWITCH Version %s Started.\nCrash Protection [%s]\nMax Sessions[%u]\nSession Rate[%d]\nSQL [%s]\n", SWITCH_VERSION_FULL, 
+					  "\nFreeSWITCH Version %s Started.\nCrash Protection [%s]\nMax Sessions[%u]\nSession Rate[%d]\nSQL [%s]\n", SWITCH_VERSION_FULL,
 					  switch_test_flag((&runtime), SCF_CRASH_PROT) ? "Enabled" : "Disabled",
 					  switch_core_session_limit(0),
-					  switch_core_sessions_per_second(0),
-					  switch_test_flag((&runtime), SCF_USE_SQL) ? "Enabled" : "Disabled"
-					  );
+					  switch_core_sessions_per_second(0), switch_test_flag((&runtime), SCF_USE_SQL) ? "Enabled" : "Disabled");
 
 	switch_clear_flag((&runtime), SCF_NO_NEW_SESSIONS);
 
@@ -1145,7 +1139,7 @@
 	return switch_timestamp_now() - runtime.initiated;
 }
 
-SWITCH_DECLARE(int32_t) switch_core_session_ctl(switch_session_ctl_t cmd, int32_t * val)
+SWITCH_DECLARE(int32_t) switch_core_session_ctl(switch_session_ctl_t cmd, int32_t *val)
 {
 	if (switch_test_flag((&runtime), SCF_SHUTTING_DOWN)) {
 		return -1;
@@ -1292,7 +1286,7 @@
 
 SWITCH_DECLARE(void) switch_core_memory_reclaim_all(void)
 {
-	switch_core_memory_reclaim_logger();	
+	switch_core_memory_reclaim_logger();
 	switch_core_memory_reclaim_events();
 	switch_core_memory_reclaim();
 }

Modified: freeswitch/trunk/src/switch_core_asr.c
==============================================================================
--- freeswitch/trunk/src/switch_core_asr.c	(original)
+++ freeswitch/trunk/src/switch_core_asr.c	Tue May 27 00:30:03 2008
@@ -37,11 +37,7 @@
 
 SWITCH_DECLARE(switch_status_t) switch_core_asr_open(switch_asr_handle_t *ah,
 													 const char *module_name,
-													 const char *codec,
-													 int rate,
-													 const char *dest,
-													 switch_asr_flag_t *flags,
-													 switch_memory_pool_t *pool)
+													 const char *codec, int rate, const char *dest, switch_asr_flag_t *flags, switch_memory_pool_t *pool)
 {
 	switch_status_t status;
 	char buf[256] = "";

Modified: freeswitch/trunk/src/switch_core_codec.c
==============================================================================
--- freeswitch/trunk/src/switch_core_codec.c	(original)
+++ freeswitch/trunk/src/switch_core_codec.c	Tue May 27 00:30:03 2008
@@ -50,7 +50,7 @@
 	char tmp[30];
 
 	switch_assert(codec->implementation);
-	
+
 	if (switch_event_create(&event, SWITCH_EVENT_CODEC) == SWITCH_STATUS_SUCCESS) {
 		switch_channel_event_set_data(session->channel, event);
 		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "channel-read-codec-name", "%s", codec->implementation->iananame);
@@ -92,7 +92,8 @@
 		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "channel-write-codec-name", "%s", codec->implementation->iananame);
 		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "channel-write-codec-rate", "%d", codec->implementation->actual_samples_per_second);
 		if (codec->implementation->actual_samples_per_second != codec->implementation->samples_per_second) {
-			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "channel-reported-write-codec-rate", "%d", codec->implementation->actual_samples_per_second);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "channel-reported-write-codec-rate", "%d",
+									codec->implementation->actual_samples_per_second);
 		}
 		switch_event_fire(&event);
 	}
@@ -185,14 +186,14 @@
 	new_codec->codec_interface = codec->codec_interface;
 	new_codec->implementation = codec->implementation;
 	new_codec->flags = codec->flags;
-	
+
 	if (codec->fmtp_in) {
 		new_codec->fmtp_in = switch_core_strdup(new_codec->memory_pool, codec->fmtp_in);
 	}
-	
+
 	new_codec->implementation->init(new_codec, new_codec->flags, NULL);
-	
-	return SWITCH_STATUS_SUCCESS;	
+
+	return SWITCH_STATUS_SUCCESS;
 }
 
 SWITCH_DECLARE(switch_status_t) switch_core_codec_init(switch_codec_t *codec, char *codec_name, char *fmtp,
@@ -286,7 +287,7 @@
 														 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)
+														 void *encoded_data, uint32_t *encoded_data_len, uint32_t *encoded_rate, unsigned int *flag)
 {
 	switch_assert(codec != NULL);
 	switch_assert(encoded_data != NULL);
@@ -311,7 +312,7 @@
 														 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)
+														 void *decoded_data, uint32_t *decoded_data_len, uint32_t *decoded_rate, unsigned int *flag)
 {
 	switch_assert(codec != NULL);
 	switch_assert(encoded_data != NULL);

Modified: freeswitch/trunk/src/switch_core_db.c
==============================================================================
--- freeswitch/trunk/src/switch_core_db.c	(original)
+++ freeswitch/trunk/src/switch_core_db.c	Tue May 27 00:30:03 2008
@@ -81,7 +81,7 @@
 	int sane = 100;
 	char *err = NULL;
 
-	while(--sane > 0) {
+	while (--sane > 0) {
 		ret = sqlite3_exec(db, sql, callback, data, &err);
 		if (ret == SQLITE_BUSY || ret == SQLITE_LOCKED) {
 			if (sane > 1) {
@@ -165,8 +165,9 @@
 	sqlite3_free(z);
 }
 
-SWITCH_DECLARE(int) switch_core_db_changes(switch_core_db_t *db) {
-    return sqlite3_changes(db);
+SWITCH_DECLARE(int) switch_core_db_changes(switch_core_db_t *db)
+{
+	return sqlite3_changes(db);
 }
 
 SWITCH_DECLARE(char *) switch_mprintf(const char *zFormat, ...)
@@ -212,7 +213,7 @@
 					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "SQL ERR [%s]\n[%s]\n", errmsg, reactive_sql);
 					switch_core_db_free(errmsg);
 					errmsg = NULL;
-				} 
+				}
 				switch_core_db_exec(db, reactive_sql, NULL, NULL, &errmsg);
 				if (errmsg) {
 					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "SQL ERR [%s]\n[%s]\n", errmsg, reactive_sql);

Modified: freeswitch/trunk/src/switch_core_event_hook.c
==============================================================================
--- freeswitch/trunk/src/switch_core_event_hook.c	(original)
+++ freeswitch/trunk/src/switch_core_event_hook.c	Tue May 27 00:30:03 2008
@@ -32,17 +32,17 @@
 #include "private/switch_core_pvt.h"
 
 NEW_HOOK_DECL(outgoing_channel)
-NEW_HOOK_DECL(receive_message)
-NEW_HOOK_DECL(receive_event)
-NEW_HOOK_DECL(state_change)
-NEW_HOOK_DECL(read_frame)
-NEW_HOOK_DECL(write_frame)
-NEW_HOOK_DECL(video_read_frame)
-NEW_HOOK_DECL(video_write_frame)
-NEW_HOOK_DECL(kill_channel)
-NEW_HOOK_DECL(send_dtmf)
-NEW_HOOK_DECL(recv_dtmf)
-NEW_HOOK_DECL(resurrect_session)
+	NEW_HOOK_DECL(receive_message)
+	NEW_HOOK_DECL(receive_event)
+	NEW_HOOK_DECL(state_change)
+	NEW_HOOK_DECL(read_frame)
+	NEW_HOOK_DECL(write_frame)
+	NEW_HOOK_DECL(video_read_frame)
+	NEW_HOOK_DECL(video_write_frame)
+	NEW_HOOK_DECL(kill_channel)
+	NEW_HOOK_DECL(send_dtmf)
+	NEW_HOOK_DECL(recv_dtmf)
+	NEW_HOOK_DECL(resurrect_session)
 
 /* For Emacs:
  * Local Variables:

Modified: freeswitch/trunk/src/switch_core_file.c
==============================================================================
--- freeswitch/trunk/src/switch_core_file.c	(original)
+++ freeswitch/trunk/src/switch_core_file.c	Tue May 27 00:30:03 2008
@@ -37,11 +37,8 @@
 
 SWITCH_DECLARE(switch_status_t) switch_core_perform_file_open(const char *file, const char *func, int line,
 															  switch_file_handle_t *fh,
-															  const char *file_path, 
-															  uint8_t channels, 
-															  uint32_t rate, 
-															  unsigned int flags, 
-															  switch_memory_pool_t *pool)
+															  const char *file_path,
+															  uint8_t channels, uint32_t rate, unsigned int flags, switch_memory_pool_t *pool)
 {
 	char *ext;
 	switch_status_t status;
@@ -69,7 +66,7 @@
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "invalid file format [%s] for [%s]!\n", ext, file_path);
 		return SWITCH_STATUS_GENERR;
 	}
-	
+
 	fh->file = file;
 	fh->func = func;
 	fh->line = line;
@@ -109,8 +106,8 @@
 	} else {
 		fh->native_rate = rate;
 	}
-	
-	if (fh->samplerate && rate &&  fh->samplerate != rate) {
+
+	if (fh->samplerate && rate && fh->samplerate != rate) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Sample rate doesn't match\n");
 		if ((flags & SWITCH_FILE_FLAG_READ)) {
 			fh->samplerate = rate;
@@ -126,7 +123,7 @@
 {
 	switch_status_t status;
 	switch_size_t orig_len = *len;
-	
+
 	switch_assert(fh != NULL);
 	switch_assert(fh->file_interface != NULL);
 
@@ -142,20 +139,16 @@
 	if (!switch_test_flag(fh, SWITCH_FILE_NATIVE) && fh->native_rate != fh->samplerate) {
 		if (!fh->resampler) {
 			if (switch_resample_create(&fh->resampler,
-									   fh->native_rate,
-									   orig_len,
-									   fh->samplerate,
-									   (uint32_t)orig_len,
-									   fh->memory_pool) != SWITCH_STATUS_SUCCESS) {
+									   fh->native_rate, orig_len, fh->samplerate, (uint32_t) orig_len, fh->memory_pool) != SWITCH_STATUS_SUCCESS) {
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Unable to create resampler!\n");
 				return SWITCH_STATUS_GENERR;
 			}
 		}
-		
+
 		fh->resampler->from_len = switch_short_to_float(data, fh->resampler->from, (int) *len);
-		fh->resampler->to_len = 
+		fh->resampler->to_len =
 			switch_resample_process(fh->resampler, fh->resampler->from, fh->resampler->from_len, fh->resampler->to, fh->resampler->to_size, 0);
-		
+
 		if (fh->resampler->to_len > orig_len) {
 			if (!fh->buffer) {
 				switch_buffer_create_dynamic(&fh->buffer, fh->resampler->to_len * 2, fh->resampler->to_len * 4, fh->resampler->to_len * 8);
@@ -166,7 +159,7 @@
 				fh->dbuf = switch_core_alloc(fh->memory_pool, fh->dbuflen);
 			}
 			switch_assert(fh->resampler->to_len <= fh->dbuflen);
-			
+
 			switch_float_to_short(fh->resampler->to, (int16_t *) fh->dbuf, fh->resampler->to_len);
 			switch_buffer_write(fh->buffer, fh->dbuf, fh->resampler->to_len * 2);
 			*len = switch_buffer_read(fh->buffer, data, orig_len * 2) / 2;
@@ -174,10 +167,10 @@
 			switch_float_to_short(fh->resampler->to, data, fh->resampler->to_len);
 			*len = fh->resampler->to_len;
 		}
-		
+
 	}
 
- done:
+  done:
 
 	return status;
 }
@@ -192,22 +185,18 @@
 	if (!fh->file_interface->file_write) {
 		return SWITCH_STATUS_FALSE;
 	}
-	
+
 	if (!switch_test_flag(fh, SWITCH_FILE_NATIVE) && fh->native_rate != fh->samplerate) {
 		if (!fh->resampler) {
 			if (switch_resample_create(&fh->resampler,
-									   fh->native_rate,
-									   orig_len,
-									   fh->samplerate,
-									   (uint32_t)orig_len,
-									   fh->memory_pool) != SWITCH_STATUS_SUCCESS) {
+									   fh->native_rate, orig_len, fh->samplerate, (uint32_t) orig_len, fh->memory_pool) != SWITCH_STATUS_SUCCESS) {
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Unable to create resampler!\n");
 				return SWITCH_STATUS_GENERR;
 			}
 		}
-		
+
 		fh->resampler->from_len = switch_short_to_float(data, fh->resampler->from, (int) *len);
-		fh->resampler->to_len = 
+		fh->resampler->to_len =
 			switch_resample_process(fh->resampler, fh->resampler->from, fh->resampler->from_len, fh->resampler->to, fh->resampler->to_size, 0);
 		if (fh->resampler->to_len > orig_len) {
 			if (!fh->dbuf) {
@@ -222,7 +211,7 @@
 		}
 
 		*len = fh->resampler->to_len;
-		
+
 	}
 
 	if (!*len) {

Modified: freeswitch/trunk/src/switch_core_hash.c
==============================================================================
--- freeswitch/trunk/src/switch_core_hash.c	(original)
+++ freeswitch/trunk/src/switch_core_hash.c	Tue May 27 00:30:03 2008
@@ -41,16 +41,16 @@
 	Hash table;
 };
 
-SWITCH_DECLARE(switch_status_t) switch_core_hash_init(switch_hash_t ** hash, switch_memory_pool_t *pool)
+SWITCH_DECLARE(switch_status_t) switch_core_hash_init(switch_hash_t **hash, switch_memory_pool_t *pool)
 {
 	switch_hash_t *newhash;
-	
+
 	newhash = switch_core_alloc(pool, sizeof(*newhash));
 	switch_assert(newhash);
 
 	sqlite3HashInit(&newhash->table, SQLITE_HASH_STRING, 1);
 	*hash = newhash;
-	
+
 	return SWITCH_STATUS_SUCCESS;
 }
 
@@ -62,54 +62,54 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-SWITCH_DECLARE(switch_status_t) switch_core_hash_insert(switch_hash_t * hash, const char *key, const void *data)
+SWITCH_DECLARE(switch_status_t) switch_core_hash_insert(switch_hash_t *hash, const char *key, const void *data)
 {
-	sqlite3HashInsert(&hash->table, key, (int)strlen(key)+1, (void *)data);
+	sqlite3HashInsert(&hash->table, key, (int) strlen(key) + 1, (void *) data);
 	return SWITCH_STATUS_SUCCESS;
 }
 
-SWITCH_DECLARE(switch_status_t) switch_core_hash_insert_locked(switch_hash_t * hash, const char *key, const void *data, switch_mutex_t *mutex)
+SWITCH_DECLARE(switch_status_t) switch_core_hash_insert_locked(switch_hash_t *hash, const char *key, const void *data, switch_mutex_t *mutex)
 {
 	if (mutex) {
-        switch_mutex_lock(mutex);
-    }
+		switch_mutex_lock(mutex);
+	}
 
-	sqlite3HashInsert(&hash->table, key, (int)strlen(key)+1, (void *)data);
+	sqlite3HashInsert(&hash->table, key, (int) strlen(key) + 1, (void *) data);
 
 	if (mutex) {
-        switch_mutex_unlock(mutex);
-    }	
+		switch_mutex_unlock(mutex);
+	}
 
 	return SWITCH_STATUS_SUCCESS;
 }
 
-SWITCH_DECLARE(switch_status_t) switch_core_hash_delete(switch_hash_t * hash, const char *key)
+SWITCH_DECLARE(switch_status_t) switch_core_hash_delete(switch_hash_t *hash, const char *key)
 {
-	sqlite3HashInsert(&hash->table, key, (int)strlen(key)+1, NULL);
+	sqlite3HashInsert(&hash->table, key, (int) strlen(key) + 1, NULL);
 	return SWITCH_STATUS_SUCCESS;
 }
 
-SWITCH_DECLARE(switch_status_t) switch_core_hash_delete_locked(switch_hash_t * hash, const char *key, switch_mutex_t *mutex)
+SWITCH_DECLARE(switch_status_t) switch_core_hash_delete_locked(switch_hash_t *hash, const char *key, switch_mutex_t *mutex)
 {
 	if (mutex) {
-        switch_mutex_lock(mutex);
-    }
-	
-	sqlite3HashInsert(&hash->table, key, (int)strlen(key)+1, NULL);
-	
+		switch_mutex_lock(mutex);
+	}
+
+	sqlite3HashInsert(&hash->table, key, (int) strlen(key) + 1, NULL);
+
 	if (mutex) {
-        switch_mutex_unlock(mutex);
-    }
+		switch_mutex_unlock(mutex);
+	}
 
 	return SWITCH_STATUS_SUCCESS;
 }
 
-SWITCH_DECLARE(void *) switch_core_hash_find(switch_hash_t * hash, const char *key)
+SWITCH_DECLARE(void *) switch_core_hash_find(switch_hash_t *hash, const char *key)
 {
-	return sqlite3HashFind(&hash->table, key, (int)strlen(key)+1);
+	return sqlite3HashFind(&hash->table, key, (int) strlen(key) + 1);
 }
 
-SWITCH_DECLARE(void *) switch_core_hash_find_locked(switch_hash_t * hash, const char *key, switch_mutex_t *mutex)
+SWITCH_DECLARE(void *) switch_core_hash_find_locked(switch_hash_t *hash, const char *key, switch_mutex_t *mutex)
 {
 	void *val;
 
@@ -117,8 +117,8 @@
 		switch_mutex_lock(mutex);
 	}
 
-	val = sqlite3HashFind(&hash->table, key, (int)strlen(key)+1);
-	
+	val = sqlite3HashFind(&hash->table, key, (int) strlen(key) + 1);
+
 	if (mutex) {
 		switch_mutex_unlock(mutex);
 	}

Modified: freeswitch/trunk/src/switch_core_io.c
==============================================================================
--- freeswitch/trunk/src/switch_core_io.c	(original)
+++ freeswitch/trunk/src/switch_core_io.c	Tue May 27 00:30:03 2008
@@ -35,7 +35,8 @@
 #include <switch.h>
 #include "private/switch_core_pvt.h"
 
-SWITCH_DECLARE(switch_status_t) switch_core_session_write_video_frame(switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags, int stream_id)
+SWITCH_DECLARE(switch_status_t) switch_core_session_write_video_frame(switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags,
+																	  int stream_id)
 {
 	switch_io_event_hook_video_write_frame_t *ptr;
 	switch_status_t status = SWITCH_STATUS_FALSE;
@@ -56,7 +57,8 @@
 	return status;
 }
 
-SWITCH_DECLARE(switch_status_t) switch_core_session_read_video_frame(switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags, int stream_id)
+SWITCH_DECLARE(switch_status_t) switch_core_session_read_video_frame(switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags,
+																	 int stream_id)
 {
 	switch_status_t status = SWITCH_STATUS_FALSE;
 	switch_io_event_hook_video_read_frame_t *ptr;
@@ -68,8 +70,7 @@
 	}
 
 	if (session->endpoint_interface->io_routines->read_video_frame) {
-		if ((status =
-			 session->endpoint_interface->io_routines->read_video_frame(session, frame, flags, stream_id)) == SWITCH_STATUS_SUCCESS) {
+		if ((status = session->endpoint_interface->io_routines->read_video_frame(session, frame, flags, stream_id)) == SWITCH_STATUS_SUCCESS) {
 			for (ptr = session->event_hooks.video_read_frame; ptr; ptr = ptr->next) {
 				if ((status = ptr->video_read_frame(session, frame, flags, stream_id)) != SWITCH_STATUS_SUCCESS) {
 					break;
@@ -93,12 +94,13 @@
 		goto done;
 	}
 
- done:
+  done:
 
 	return status;
 }
 
-SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags, int stream_id)
+SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags,
+															   int stream_id)
 {
 	switch_io_event_hook_read_frame_t *ptr;
 	switch_status_t status;
@@ -107,7 +109,7 @@
 
 	switch_assert(session != NULL);
 
-top:
+  top:
 
 	if (switch_channel_get_state(session->channel) >= CS_HANGUP) {
 		*frame = NULL;
@@ -126,8 +128,7 @@
 	}
 
 	if (session->endpoint_interface->io_routines->read_frame) {
-		if ((status =
-			 session->endpoint_interface->io_routines->read_frame(session, frame, flags, stream_id)) == SWITCH_STATUS_SUCCESS) {
+		if ((status = session->endpoint_interface->io_routines->read_frame(session, frame, flags, stream_id)) == SWITCH_STATUS_SUCCESS) {
 			for (ptr = session->event_hooks.read_frame; ptr; ptr = ptr->next) {
 				if ((status = ptr->read_frame(session, frame, flags, stream_id)) != SWITCH_STATUS_SUCCESS) {
 					break;
@@ -150,7 +151,7 @@
 		/* Fast PASS! */
 		status = SWITCH_STATUS_SUCCESS;
 		goto done;
-	} 
+	}
 
 	if (switch_test_flag(*frame, SFF_CNG)) {
 		status = SWITCH_STATUS_SUCCESS;
@@ -158,7 +159,7 @@
 			goto done;
 		}
 		is_cng = 1;
-	} 
+	}
 
 	switch_assert((*frame)->codec != NULL);
 
@@ -195,15 +196,15 @@
 
 		if (!switch_test_flag(session, SSF_WARN_TRANSCODE)) {
 			switch_core_session_message_t msg = { 0 };
-			
+
 			msg.message_id = SWITCH_MESSAGE_INDICATE_TRANSCODING_NECESSARY;
 			switch_core_session_receive_message(session, &msg);
 			switch_set_flag(session, SSF_WARN_TRANSCODE);
 		}
-		
+
 		if (read_frame->codec || is_cng) {
 			session->raw_read_frame.datalen = session->raw_read_frame.buflen;
-			
+
 			if (is_cng) {
 				memset(session->raw_read_frame.data, 255, read_frame->codec->implementation->bytes_per_frame);
 				session->raw_read_frame.datalen = read_frame->codec->implementation->bytes_per_frame;
@@ -241,7 +242,7 @@
 													session->read_codec->implementation->actual_samples_per_second,
 													session->read_codec->implementation->bytes_per_frame, session->pool);
 					switch_mutex_unlock(session->resample_mutex);
-					
+
 					if (status != SWITCH_STATUS_SUCCESS) {
 						switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to allocate resampler\n");
 						status = SWITCH_STATUS_FALSE;
@@ -263,7 +264,7 @@
 					switch_mutex_lock(session->resample_mutex);
 					switch_resample_destroy(&session->read_resampler);
 					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Deactivating read resampler\n");
-					switch_mutex_unlock(session->resample_mutex);					
+					switch_mutex_unlock(session->resample_mutex);
 				}
 
 				status = SWITCH_STATUS_SUCCESS;
@@ -296,12 +297,13 @@
 					switch_mutex_lock(bp->read_mutex);
 					switch_buffer_write(bp->raw_read_buffer, read_frame->data, read_frame->datalen);
 					if (bp->callback) {
-						if (bp->callback(bp, bp->user_data, SWITCH_ABC_TYPE_READ) == SWITCH_FALSE || (bp->stop_time && bp->stop_time <= switch_timestamp(NULL))) {
+						if (bp->callback(bp, bp->user_data, SWITCH_ABC_TYPE_READ) == SWITCH_FALSE
+							|| (bp->stop_time && bp->stop_time <= switch_timestamp(NULL))) {
 							ok = SWITCH_FALSE;
 						}
 					}
 					switch_mutex_unlock(bp->read_mutex);
-				} 
+				}
 
 				if (switch_test_flag(bp, SMBF_READ_REPLACE)) {
 					do_bugs = 0;
@@ -339,21 +341,21 @@
 		}
 
 		if (session->read_codec) {
-            if (session->read_resampler) {
-                short *data = read_frame->data;
-                switch_mutex_lock(session->resample_mutex);
-                
-                session->read_resampler->from_len = switch_short_to_float(data, session->read_resampler->from, (int) read_frame->datalen / 2);
-                session->read_resampler->to_len =
-                    switch_resample_process(session->read_resampler, session->read_resampler->from,
-                                            session->read_resampler->from_len, session->read_resampler->to, session->read_resampler->to_size, 0);
-                switch_float_to_short(session->read_resampler->to, data, read_frame->datalen);
-                read_frame->samples = session->read_resampler->to_len;
-                read_frame->datalen = session->read_resampler->to_len * 2;
-                read_frame->rate = session->read_resampler->to_rate;
-                switch_mutex_unlock(session->resample_mutex);
-                
-            }
+			if (session->read_resampler) {
+				short *data = read_frame->data;
+				switch_mutex_lock(session->resample_mutex);
+
+				session->read_resampler->from_len = switch_short_to_float(data, session->read_resampler->from, (int) read_frame->datalen / 2);
+				session->read_resampler->to_len =
+					switch_resample_process(session->read_resampler, session->read_resampler->from,
+											session->read_resampler->from_len, session->read_resampler->to, session->read_resampler->to_size, 0);
+				switch_float_to_short(session->read_resampler->to, data, read_frame->datalen);
+				read_frame->samples = session->read_resampler->to_len;
+				read_frame->datalen = session->read_resampler->to_len * 2;
+				read_frame->rate = session->read_resampler->to_rate;
+				switch_mutex_unlock(session->resample_mutex);
+
+			}
 
 			if ((*frame)->datalen == session->read_codec->implementation->bytes_per_frame) {
 				perfect = TRUE;
@@ -368,7 +370,7 @@
 					goto done;
 				}
 			}
-			
+
 
 			if (perfect || switch_buffer_inuse(session->raw_read_buffer) >= session->read_codec->implementation->bytes_per_frame) {
 				if (perfect) {
@@ -448,7 +450,8 @@
 				if (bp->ready && switch_test_flag(bp, SMBF_READ_PING)) {
 					switch_mutex_lock(bp->read_mutex);
 					if (bp->callback) {
-						if (bp->callback(bp, bp->user_data, SWITCH_ABC_TYPE_READ_PING) == SWITCH_FALSE || (bp->stop_time && bp->stop_time <= switch_timestamp(NULL))) {
+						if (bp->callback(bp, bp->user_data, SWITCH_ABC_TYPE_READ_PING) == SWITCH_FALSE
+							|| (bp->stop_time && bp->stop_time <= switch_timestamp(NULL))) {
 							ok = SWITCH_FALSE;
 						}
 					}
@@ -476,7 +479,7 @@
 		}
 	}
 
- even_more_done:
+  even_more_done:
 
 	if (!*frame) {
 		*frame = &runtime.dummy_cng_frame;
@@ -504,7 +507,8 @@
 	return status;
 }
 
-SWITCH_DECLARE(switch_status_t) switch_core_session_write_frame(switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags, int stream_id)
+SWITCH_DECLARE(switch_status_t) switch_core_session_write_frame(switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags,
+																int stream_id)
 {
 
 	switch_status_t status = SWITCH_STATUS_FALSE;
@@ -569,7 +573,7 @@
 	if (need_codec) {
 		if (!switch_test_flag(session, SSF_WARN_TRANSCODE)) {
 			switch_core_session_message_t msg = { 0 };
-			
+
 			msg.message_id = SWITCH_MESSAGE_INDICATE_TRANSCODING_NECESSARY;
 			switch_core_session_receive_message(session, &msg);
 			switch_set_flag(session, SSF_WARN_TRANSCODE);
@@ -637,7 +641,7 @@
 
 		if (session->write_resampler) {
 			short *data = write_frame->data;
-			
+
 			switch_mutex_lock(session->resample_mutex);
 
 			session->write_resampler->from_len = write_frame->datalen / 2;
@@ -665,14 +669,14 @@
 					continue;
 				}
 				if (switch_test_flag(bp, SMBF_WRITE_STREAM)) {
-					
+
 					switch_mutex_lock(bp->write_mutex);
 					switch_buffer_write(bp->raw_write_buffer, write_frame->data, write_frame->datalen);
 					switch_mutex_unlock(bp->write_mutex);
 					if (bp->callback) {
 						ok = bp->callback(bp, bp->user_data, SWITCH_ABC_TYPE_WRITE);
 					}
-				} 
+				}
 
 				if (switch_test_flag(bp, SMBF_WRITE_REPLACE)) {
 					do_bugs = 0;
@@ -807,8 +811,8 @@
 								rate = frame->codec->implementation->actual_samples_per_second;
 							} else {
 								rate = session->write_codec->implementation->actual_samples_per_second;
-							} 
-							
+							}
+
 							status = switch_core_codec_encode(session->write_codec,
 															  frame->codec,
 															  enc_frame->data,
@@ -832,7 +836,7 @@
 																	session->write_codec->implementation->actual_samples_per_second,
 																	session->write_codec->implementation->bytes_per_frame, session->pool);
 									switch_mutex_unlock(session->resample_mutex);
-									
+
 									if (status != SWITCH_STATUS_SUCCESS) {
 										goto done;
 									}
@@ -871,7 +875,7 @@
 							if (session->read_resampler) {
 								short *data = write_frame->data;
 								switch_mutex_lock(session->resample_mutex);
-								
+
 								session->read_resampler->from_len =
 									switch_short_to_float(data, session->read_resampler->from, (int) write_frame->datalen / 2);
 								session->read_resampler->to_len = (uint32_t)
@@ -883,7 +887,7 @@
 								write_frame->datalen = session->read_resampler->to_len * 2;
 								write_frame->rate = session->read_resampler->to_rate;
 								switch_mutex_unlock(session->resample_mutex);
-								
+
 							}
 							if (flag & SFF_CNG) {
 								switch_set_flag(write_frame, SFF_CNG);
@@ -941,10 +945,10 @@
 
 SWITCH_DECLARE(switch_status_t) switch_core_session_recv_dtmf(switch_core_session_t *session, const switch_dtmf_t *dtmf)
 {
-	switch_io_event_hook_recv_dtmf_t *ptr;	
+	switch_io_event_hook_recv_dtmf_t *ptr;
 	switch_status_t status;
 	switch_dtmf_t new_dtmf;
-	
+
 	if (switch_channel_get_state(session->channel) >= CS_HANGUP) {
 		return SWITCH_STATUS_FALSE;
 	}
@@ -954,7 +958,7 @@
 	new_dtmf = *dtmf;
 
 	if (new_dtmf.duration > switch_core_max_dtmf_duration(0)) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "%s EXECSSIVE DTMF DIGIT [%c] LEN [%d]\n", 
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "%s EXECSSIVE DTMF DIGIT [%c] LEN [%d]\n",
 						  switch_channel_get_name(session->channel), new_dtmf.digit, new_dtmf.duration);
 		new_dtmf.duration = switch_core_max_dtmf_duration(0);
 	} else if (!new_dtmf.duration) {
@@ -974,7 +978,7 @@
 	switch_io_event_hook_send_dtmf_t *ptr;
 	switch_status_t status = SWITCH_STATUS_FALSE;
 	switch_dtmf_t new_dtmf;
-	
+
 	if (switch_channel_get_state(session->channel) >= CS_HANGUP) {
 		return SWITCH_STATUS_FALSE;
 	}
@@ -984,7 +988,7 @@
 	new_dtmf = *dtmf;
 
 	if (new_dtmf.duration > switch_core_max_dtmf_duration(0)) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "%s EXECSSIVE DTMF DIGIT [%c] LEN [%d]\n", 
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "%s EXECSSIVE DTMF DIGIT [%c] LEN [%d]\n",
 						  switch_channel_get_name(session->channel), new_dtmf.digit, new_dtmf.duration);
 		new_dtmf.duration = switch_core_max_dtmf_duration(0);
 	} else if (!new_dtmf.duration) {
@@ -997,7 +1001,7 @@
 			return SWITCH_STATUS_SUCCESS;
 		}
 	}
-	
+
 	if (session->endpoint_interface->io_routines->send_dtmf) {
 		if (dtmf->digit == 'w') {
 			switch_yield(500000);
@@ -1013,19 +1017,19 @@
 SWITCH_DECLARE(switch_status_t) switch_core_session_send_dtmf_string(switch_core_session_t *session, const char *dtmf_string)
 {
 	char *p;
-	switch_dtmf_t dtmf = {0, switch_core_default_dtmf_duration(0)};
+	switch_dtmf_t dtmf = { 0, switch_core_default_dtmf_duration(0) };
 	int sent = 0, dur;
 	char *string;
 	int i, argc;
 	char *argv[256];
-	
+
 	switch_assert(session != NULL);
 
 
 	if (switch_channel_get_state(session->channel) >= CS_HANGUP) {
 		return SWITCH_STATUS_FALSE;
 	}
-	
+
 	if (switch_strlen_zero(dtmf_string)) {
 		return SWITCH_STATUS_FALSE;
 	}
@@ -1037,12 +1041,12 @@
 
 	string = switch_core_session_strdup(session, dtmf_string);
 	argc = switch_separate_string(string, '+', argv, (sizeof(argv) / sizeof(argv[0])));
-	
+
 	if (argc) {
 		switch_channel_pre_answer(session->channel);
 	}
 
-	for(i = 0; i < argc; i++) {
+	for (i = 0; i < argc; i++) {
 		dtmf.duration = switch_core_default_dtmf_duration(0);
 		dur = switch_core_default_dtmf_duration(0) / 8;
 		if ((p = strchr(argv[i], '@'))) {
@@ -1054,7 +1058,7 @@
 
 
 		if (dtmf.duration > switch_core_max_dtmf_duration(0)) {
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "%s EXECSSIVE DTMF DIGIT [%c] LEN [%d]\n", 
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "%s EXECSSIVE DTMF DIGIT [%c] LEN [%d]\n",
 							  switch_channel_get_name(session->channel), dtmf.digit, dtmf.duration);
 			dtmf.duration = switch_core_max_dtmf_duration(0);
 		} else if (!dtmf.duration) {
@@ -1071,7 +1075,7 @@
 				}
 			}
 		}
-		
+
 	}
 	return sent ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_FALSE;
 }

Modified: freeswitch/trunk/src/switch_core_media_bug.c
==============================================================================
--- freeswitch/trunk/src/switch_core_media_bug.c	(original)
+++ freeswitch/trunk/src/switch_core_media_bug.c	Tue May 27 00:30:03 2008
@@ -100,7 +100,7 @@
 	if ((bug->raw_read_buffer && bug->raw_write_buffer) && (!rlen && !wlen)) {
 		return SWITCH_STATUS_FALSE;
 	}
-	
+
 	maxlen = SWITCH_RECOMMENDED_BUFFER_SIZE > frame->buflen ? frame->buflen : SWITCH_RECOMMENDED_BUFFER_SIZE;
 
 	if ((rdlen = rlen > wlen ? wlen : rlen) > maxlen) {
@@ -128,11 +128,11 @@
 
 
 	bytes = (datalen > frame->datalen) ? datalen : frame->datalen;
-	switch_assert( bytes <= maxlen );
-	
+	switch_assert(bytes <= maxlen);
+
 	if (bytes) {
 		int16_t *tp = bug->tmp;
-		
+
 		dp = (int16_t *) bug->data;
 		fp = (int16_t *) frame->data;
 		rlen = frame->datalen / 2;
@@ -171,10 +171,10 @@
 		frame->datalen = bytes;
 		frame->samples = bytes / sizeof(int16_t);
 		frame->rate = read_codec->implementation->actual_samples_per_second;
-		
+
 		return SWITCH_STATUS_SUCCESS;
 	}
-	
+
 	return SWITCH_STATUS_FALSE;
 }
 
@@ -183,7 +183,7 @@
 														  switch_media_bug_callback_t callback,
 														  void *user_data, time_t stop_time, switch_media_bug_flag_t flags, switch_media_bug_t **new_bug)
 {
-	switch_media_bug_t *bug;//, *bp;
+	switch_media_bug_t *bug;	//, *bp;
 	switch_size_t bytes;
 
 	if (flags & SMBF_WRITE_REPLACE) {
@@ -287,7 +287,7 @@
 		switch_thread_rwlock_unlock(session->bug_rwlock);
 		return SWITCH_STATUS_SUCCESS;
 	}
-	
+
 	if (session->bug_codec.implementation) {
 		switch_core_codec_destroy(&session->bug_codec);
 	}
@@ -313,7 +313,7 @@
 		*bug = NULL;
 		return SWITCH_STATUS_SUCCESS;
 	}
-	
+
 	return SWITCH_STATUS_FALSE;
 }
 
@@ -350,7 +350,7 @@
 	if (!session->bugs && session->bug_codec.implementation) {
 		switch_core_codec_destroy(&session->bug_codec);
 	}
-	
+
 	return status;
 }
 

Modified: freeswitch/trunk/src/switch_core_memory.c
==============================================================================
--- freeswitch/trunk/src/switch_core_memory.c	(original)
+++ freeswitch/trunk/src/switch_core_memory.c	Tue May 27 00:30:03 2008
@@ -43,7 +43,7 @@
 
 static struct {
 	switch_mutex_t *mem_lock;
-	switch_queue_t *pool_queue; /* 8 ball break */
+	switch_queue_t *pool_queue;	/* 8 ball break */
 	switch_queue_t *pool_recycle_queue;
 	switch_memory_pool_t *memory_pool;
 	int pool_thread_running;
@@ -58,7 +58,8 @@
 
 /* **ONLY** alloc things with this function that **WILL NOT** outlive
    the session itself or expect an earth shattering KABOOM!*/
-SWITCH_DECLARE(void *) switch_core_perform_session_alloc(switch_core_session_t *session, switch_size_t memory, const char *file, const char *func, int line)
+SWITCH_DECLARE(void *) switch_core_perform_session_alloc(switch_core_session_t *session, switch_size_t memory, const char *file, const char *func,
+														 int line)
 {
 	void *ptr = NULL;
 	switch_assert(session != NULL);
@@ -70,14 +71,14 @@
 
 #ifdef DEBUG_ALLOC
 	if (memory > 500)
-		switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_CONSOLE, "Session Allocate %d\n", (int)memory);
+		switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_CONSOLE, "Session Allocate %d\n", (int) memory);
 #endif
 
 	ptr = apr_palloc(session->pool, memory);
 	switch_assert(ptr != NULL);
 
 	memset(ptr, 0, memory);
-	
+
 #ifdef LOCK_MORE
 	switch_mutex_unlock(memory_manager.mem_lock);
 #endif
@@ -98,7 +99,7 @@
 #endif
 
 #ifdef DEBUG_ALLOC
-	switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_CONSOLE, "Perm Allocate %d\n", (int)memory);
+	switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_CONSOLE, "Perm Allocate %d\n", (int) memory);
 #endif
 
 	ptr = apr_palloc(memory_manager.memory_pool, memory);
@@ -131,7 +132,7 @@
 	switch_assert(duped != NULL);
 
 #ifdef DEBUG_ALLOC
-	switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_CONSOLE, "Perm Allocate %d\n", (int)len);
+	switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_CONSOLE, "Perm Allocate %d\n", (int) len);
 #endif
 
 #ifdef LOCK_MORE
@@ -153,7 +154,7 @@
 	switch_assert(session != NULL);
 	switch_assert(session->pool != NULL);
 	va_start(ap, fmt);
-	
+
 	result = apr_pvsprintf(session->pool, fmt, ap);
 	switch_assert(result != NULL);
 	va_end(ap);
@@ -199,7 +200,6 @@
 	if (!todup) {
 		return NULL;
 	}
-
 #ifdef LOCK_MORE
 	switch_mutex_lock(memory_manager.mem_lock);
 #endif
@@ -208,7 +208,7 @@
 
 #ifdef DEBUG_ALLOC
 	if (len > 500)
-		switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_CONSOLE, "Sess Strdup Allocate %d\n", (int)len);
+		switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_CONSOLE, "Sess Strdup Allocate %d\n", (int) len);
 #endif
 
 	duped = apr_pstrmemdup(session->pool, todup, len);
@@ -231,7 +231,6 @@
 	if (!todup) {
 		return NULL;
 	}
-
 #ifdef LOCK_MORE
 	switch_mutex_lock(memory_manager.mem_lock);
 #endif
@@ -240,7 +239,7 @@
 
 #ifdef DEBUG_ALLOC
 	if (len > 500)
-		switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_CONSOLE, "core strdup Allocate %d\n", (int)len);
+		switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_CONSOLE, "core strdup Allocate %d\n", (int) len);
 #endif
 
 	duped = apr_pstrmemdup(pool, todup, len);
@@ -262,10 +261,10 @@
 {
 	char *tmp;
 #ifdef PER_POOL_LOCK
-		apr_allocator_t *my_allocator = NULL;
-        apr_thread_mutex_t *my_mutex;
+	apr_allocator_t *my_allocator = NULL;
+	apr_thread_mutex_t *my_mutex;
 #else
-		void *pop = NULL;
+	void *pop = NULL;
 #endif
 
 	switch_mutex_lock(memory_manager.mem_lock);
@@ -322,7 +321,7 @@
 		apr_pool_destroy(*pool);
 	}
 	*pool = NULL;
-	
+
 	return SWITCH_STATUS_SUCCESS;
 }
 
@@ -338,8 +337,8 @@
 
 #ifdef DEBUG_ALLOC
 	if (memory > 500)
-		switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_CONSOLE, "Core Allocate %d\n", (int)memory);
-	/*switch_assert(memory < 20000);*/
+		switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_CONSOLE, "Core Allocate %d\n", (int) memory);
+	/*switch_assert(memory < 20000); */
 #endif
 
 	ptr = apr_palloc(pool, memory);
@@ -357,9 +356,9 @@
 {
 	switch_memory_pool_t *pool;
 	void *pop = NULL;
-	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Returning %d recycled memory pool(s)\n", 
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Returning %d recycled memory pool(s)\n",
 					  switch_queue_size(memory_manager.pool_recycle_queue) + switch_queue_size(memory_manager.pool_queue));
-	
+
 	while (switch_queue_trypop(memory_manager.pool_recycle_queue, &pop) == SWITCH_STATUS_SUCCESS) {
 		pool = (switch_memory_pool_t *) pop;
 		if (!pool) {
@@ -369,7 +368,7 @@
 	}
 }
 
-static void *SWITCH_THREAD_FUNC pool_thread(switch_thread_t * thread, void *obj)
+static void *SWITCH_THREAD_FUNC pool_thread(switch_thread_t *thread, void *obj)
 {
 	memory_manager.pool_thread_running = 1;
 
@@ -388,7 +387,6 @@
 					break;
 				}
 
-			
 #if defined(PER_POOL_LOCK) || defined(DESTROY_POOLS)
 				apr_pool_destroy(pop);
 #else
@@ -408,7 +406,7 @@
 		}
 	}
 
- done:
+  done:
 	switch_core_memory_reclaim();
 
 	{
@@ -428,7 +426,7 @@
 {
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Stopping memory pool queue.\n");
 	memory_manager.pool_thread_running = -1;
-	while(memory_manager.pool_thread_running) {
+	while (memory_manager.pool_thread_running) {
 		switch_yield(1000);
 	}
 }
@@ -436,7 +434,7 @@
 switch_memory_pool_t *switch_core_memory_init(void)
 {
 	switch_thread_t *thread;
-    switch_threadattr_t *thd_attr;
+	switch_threadattr_t *thd_attr;
 #ifdef PER_POOL_LOCK
 	apr_allocator_t *my_allocator = NULL;
 	apr_thread_mutex_t *my_mutex;
@@ -445,22 +443,22 @@
 	memset(&memory_manager, 0, sizeof(memory_manager));
 
 #ifdef PER_POOL_LOCK
-		if ((apr_allocator_create(&my_allocator)) != APR_SUCCESS) {
-			abort();
-		}
+	if ((apr_allocator_create(&my_allocator)) != APR_SUCCESS) {
+		abort();
+	}
 
-		if ((apr_pool_create_ex(&memory_manager.memory_pool, NULL, NULL, my_allocator)) != APR_SUCCESS) {
-			apr_allocator_destroy(my_allocator);
-			my_allocator = NULL;
-			abort();
-		}
+	if ((apr_pool_create_ex(&memory_manager.memory_pool, NULL, NULL, my_allocator)) != APR_SUCCESS) {
+		apr_allocator_destroy(my_allocator);
+		my_allocator = NULL;
+		abort();
+	}
 
-		if ((apr_thread_mutex_create(&my_mutex, APR_THREAD_MUTEX_DEFAULT, memory_manager.memory_pool)) != APR_SUCCESS) {
-			abort();
-		}
+	if ((apr_thread_mutex_create(&my_mutex, APR_THREAD_MUTEX_DEFAULT, memory_manager.memory_pool)) != APR_SUCCESS) {
+		abort();
+	}
 
-		apr_allocator_mutex_set(my_allocator, my_mutex);
-		apr_allocator_owner_set(my_allocator, memory_manager.memory_pool);
+	apr_allocator_mutex_set(my_allocator, my_mutex);
+	apr_allocator_owner_set(my_allocator, memory_manager.memory_pool);
 #else
 	apr_pool_create(&memory_manager.memory_pool, NULL);
 	switch_assert(memory_manager.memory_pool != NULL);
@@ -475,7 +473,7 @@
 
 	switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
 	switch_thread_create(&thread, thd_attr, pool_thread, NULL, memory_manager.memory_pool);
-	
+
 	while (!memory_manager.pool_thread_running) {
 		switch_yield(1000);
 	}

Modified: freeswitch/trunk/src/switch_core_port_allocator.c
==============================================================================
--- freeswitch/trunk/src/switch_core_port_allocator.c	(original)
+++ freeswitch/trunk/src/switch_core_port_allocator.c	Tue May 27 00:30:03 2008
@@ -54,7 +54,7 @@
 	switch_memory_pool_t *pool;
 	switch_core_port_allocator_t *alloc;
 	int even, odd;
-	
+
 	if ((status = switch_core_new_memory_pool(&pool)) != SWITCH_STATUS_SUCCESS) {
 		return status;
 	}
@@ -63,7 +63,7 @@
 		switch_core_destroy_memory_pool(&pool);
 		return SWITCH_STATUS_MEMERR;
 	}
-	
+
 	alloc->flags = flags;
 	even = switch_test_flag(alloc, SPF_EVEN);
 	odd = switch_test_flag(alloc, SPF_ODD);
@@ -90,14 +90,14 @@
 		}
 	}
 
-	alloc->track_len = (end - start) + 2;	
+	alloc->track_len = (end - start) + 2;
 
 	if (!(even && odd)) {
 		alloc->track_len /= 2;
 	}
-	
+
 	alloc->track = switch_core_alloc(pool, (alloc->track_len + 2) * sizeof(switch_byte_t));
-	
+
 	alloc->start = start;
 	alloc->next = start;
 	alloc->end = end;
@@ -118,20 +118,20 @@
 	int odd = switch_test_flag(alloc, SPF_ODD);
 
 	switch_mutex_lock(alloc->mutex);
-	srand(getpid() + (unsigned)switch_timestamp(NULL));
-	
-	while(alloc->track_used < alloc->track_len) {
+	srand(getpid() + (unsigned) switch_timestamp(NULL));
+
+	while (alloc->track_used < alloc->track_len) {
 		double r;
 		uint32_t index;
 		int tries = 0;
 
 		do {
-			r = ((double)rand() / ((double)(RAND_MAX)+(double)(1)));
+			r = ((double) rand() / ((double) (RAND_MAX) + (double) (1)));
 			index = (int) (r * alloc->track_len);
 			tries++;
-		} while((alloc->track[index] || index >= alloc->track_len) && tries < 10000);
-		
-		while(alloc->track[index]) {
+		} while ((alloc->track[index] || index >= alloc->track_len) && tries < 10000);
+
+		while (alloc->track[index]) {
 			if (++index >= alloc->track_len) {
 				index = 0;
 			}
@@ -143,29 +143,29 @@
 			status = SWITCH_STATUS_SUCCESS;
 
 			if ((even && odd)) {
-				port = (switch_port_t)(index + alloc->start);
+				port = (switch_port_t) (index + alloc->start);
 			} else {
-				port = (switch_port_t)(index + (alloc->start / 2));
+				port = (switch_port_t) (index + (alloc->start / 2));
 				port *= 2;
-			} 
+			}
 			goto end;
 		}
 	}
-	
-	
- end:
+
+
+  end:
 
 	switch_mutex_unlock(alloc->mutex);
-	
+
 	if (status == SWITCH_STATUS_SUCCESS) {
 		*port_ptr = port;
 	} else {
 		*port_ptr = 0;
 	}
 
-	
+
 	return status;
-	
+
 }
 
 SWITCH_DECLARE(switch_status_t) switch_core_port_allocator_free_port(switch_core_port_allocator_t *alloc, switch_port_t port)
@@ -174,7 +174,7 @@
 	int even = switch_test_flag(alloc, SPF_EVEN);
 	int odd = switch_test_flag(alloc, SPF_ODD);
 	int index = port - alloc->start;
-	
+
 	if (!(even && odd)) {
 		index /= 2;
 	}

Modified: freeswitch/trunk/src/switch_core_rwlock.c
==============================================================================
--- freeswitch/trunk/src/switch_core_rwlock.c	(original)
+++ freeswitch/trunk/src/switch_core_rwlock.c	Tue May 27 00:30:03 2008
@@ -57,7 +57,8 @@
 		if (switch_test_flag(session, SSF_DESTROYED)) {
 			status = SWITCH_STATUS_FALSE;
 #ifdef SWITCH_DEBUG_RWLOCKS
-			switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_ERROR, "%s Read lock FAIL\n", switch_channel_get_name(session->channel));
+			switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_ERROR, "%s Read lock FAIL\n",
+							  switch_channel_get_name(session->channel));
 #endif
 		} else {
 			status = (switch_status_t) switch_thread_rwlock_tryrdlock(session->rwlock);
@@ -75,7 +76,8 @@
 SWITCH_DECLARE(void) switch_core_session_perform_write_lock(switch_core_session_t *session, const char *file, const char *func, int line)
 {
 
-	switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_ERROR, "%s Write lock AQUIRED\n", switch_channel_get_name(session->channel));
+	switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_ERROR, "%s Write lock AQUIRED\n",
+					  switch_channel_get_name(session->channel));
 #else
 SWITCH_DECLARE(void) switch_core_session_write_lock(switch_core_session_t *session)
 {

Modified: freeswitch/trunk/src/switch_core_session.c
==============================================================================
--- freeswitch/trunk/src/switch_core_session.c	(original)
+++ freeswitch/trunk/src/switch_core_session.c	Tue May 27 00:30:03 2008
@@ -174,9 +174,7 @@
 }
 
 SWITCH_DECLARE(switch_call_cause_t) switch_core_session_resurrect_channel(const char *endpoint_name,
-																		  switch_core_session_t **new_session,
-																		  switch_memory_pool_t **pool,
-																		  void *data)
+																		  switch_core_session_t **new_session, switch_memory_pool_t **pool, void *data)
 {
 	const switch_endpoint_interface_t *endpoint_interface;
 
@@ -188,12 +186,11 @@
 	return endpoint_interface->io_routines->resurrect_session(new_session, pool, data);
 }
 
- SWITCH_DECLARE(switch_call_cause_t) switch_core_session_outgoing_channel(switch_core_session_t *session, switch_event_t *var_event,
-																		  const char *endpoint_name,
-																		  switch_caller_profile_t *caller_profile,
-																		  switch_core_session_t **new_session, 
-																		  switch_memory_pool_t **pool,
-																		  switch_originate_flag_t flags)
+SWITCH_DECLARE(switch_call_cause_t) switch_core_session_outgoing_channel(switch_core_session_t *session, switch_event_t *var_event,
+																		 const char *endpoint_name,
+																		 switch_caller_profile_t *caller_profile,
+																		 switch_core_session_t **new_session,
+																		 switch_memory_pool_t **pool, switch_originate_flag_t flags)
 {
 	switch_io_event_hook_outgoing_channel_t *ptr;
 	switch_status_t status = SWITCH_STATUS_FALSE;
@@ -218,10 +215,10 @@
 		channel = switch_core_session_get_channel(session);
 
 		switch_assert(channel != NULL);
-		
+
 		forwardvar = switch_channel_get_variable(channel, SWITCH_MAX_FORWARDS_VARIABLE);
 		if (!switch_strlen_zero(forwardvar)) {
-			forwardval =  atoi(forwardvar) - 1;
+			forwardval = atoi(forwardvar) - 1;
 		}
 		if (forwardval <= 0) {
 			return SWITCH_CAUSE_EXCHANGE_ROUTING_ERROR;
@@ -249,7 +246,8 @@
 		}
 	}
 
-	if ((cause = endpoint_interface->io_routines->outgoing_channel(session, var_event, outgoing_profile, new_session, pool, flags)) != SWITCH_CAUSE_SUCCESS) {
+	if ((cause =
+		 endpoint_interface->io_routines->outgoing_channel(session, var_event, outgoing_profile, new_session, pool, flags)) != SWITCH_CAUSE_SUCCESS) {
 		return cause;
 	}
 
@@ -262,16 +260,16 @@
 	}
 
 	if (!*new_session) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "outgoing method for endpoint: [%s] returned: [%s] but there is no new session!\n", 
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "outgoing method for endpoint: [%s] returned: [%s] but there is no new session!\n",
 						  endpoint_name, switch_channel_cause2str(cause));
 		return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
 	} else {
 		switch_caller_profile_t *profile = NULL, *peer_profile = NULL, *cloned_profile = NULL;
 		switch_event_t *event;
 		switch_channel_t *peer_channel = switch_core_session_get_channel(*new_session);
-		
+
 		switch_assert(peer_channel);
-		
+
 		peer_profile = switch_channel_get_caller_profile(peer_channel);
 
 		if (channel) {
@@ -339,7 +337,7 @@
 					switch_channel_set_originator_caller_profile(peer_channel, cloned_profile);
 				}
 			}
-			
+
 			if (peer_profile) {
 				if ((cloned_profile = switch_caller_profile_clone(session, peer_profile)) != 0) {
 					switch_channel_set_originatee_caller_profile(channel, cloned_profile);
@@ -370,9 +368,9 @@
 	if ((status = switch_core_session_read_lock(session)) != SWITCH_STATUS_SUCCESS) {
 		return status;
 	}
-	
+
 	switch_core_session_signal_lock(session);
-	
+
 	if (session->endpoint_interface->io_routines->receive_message) {
 		status = session->endpoint_interface->io_routines->receive_message(session, message);
 	}
@@ -396,7 +394,7 @@
 
 SWITCH_DECLARE(switch_status_t) switch_core_session_pass_indication(switch_core_session_t *session, switch_core_session_message_types_t indication)
 {
-	switch_core_session_message_t msg = {0};
+	switch_core_session_message_t msg = { 0 };
 	switch_core_session_t *other_session;
 	const char *uuid;
 	switch_channel_t *channel = switch_core_session_get_channel(session);
@@ -410,7 +408,7 @@
 	} else {
 		status = SWITCH_STATUS_FALSE;
 	}
-	
+
 	return status;
 }
 
@@ -426,7 +424,7 @@
 		switch_core_session_queue_message(session, msg);
 		return SWITCH_STATUS_SUCCESS;
 	}
-	
+
 	return SWITCH_STATUS_FALSE;
 }
 
@@ -441,7 +439,7 @@
 			status = SWITCH_STATUS_SUCCESS;
 		}
 	}
-	
+
 	return status;
 }
 
@@ -581,7 +579,7 @@
 	if (!switch_channel_test_flag(channel, CF_EVENT_LOCK) && session->private_event_queue) {
 		return switch_queue_size(session->private_event_queue);
 	}
-	
+
 	return 0;
 }
 
@@ -615,7 +613,7 @@
 			x++;
 		}
 	}
-	
+
 	return x;
 }
 
@@ -624,7 +622,7 @@
 	switch_channel_t *channel = switch_core_session_get_channel(session);
 	switch_size_t has;
 
-	/* clear resamplers*/
+	/* clear resamplers */
 	switch_resample_destroy(&session->read_resampler);
 	switch_resample_destroy(&session->write_resampler);
 
@@ -634,7 +632,7 @@
 	/* wipe theese, they will be recreated if need be */
 	switch_buffer_destroy(&session->raw_read_buffer);
 	switch_buffer_destroy(&session->raw_write_buffer);
-	
+
 	if (flush_dtmf) {
 		while ((has = switch_channel_has_dtmf(channel))) {
 			switch_channel_flush_dtmf(channel);
@@ -657,7 +655,7 @@
 {
 	switch_status_t status = SWITCH_STATUS_SUCCESS;
 	switch_io_event_hook_state_change_t *ptr;
-	
+
 	/* If trylock fails the signal is already awake so we needn't bother */
 	if (switch_mutex_trylock(session->mutex) == SWITCH_STATUS_SUCCESS) {
 		switch_thread_cond_signal(session->cond);
@@ -689,13 +687,12 @@
 	switch_memory_pool_t *pool;
 	switch_event_t *event;
 
-	switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_NOTICE, "Close Channel %s [%s]\n", 
-					  switch_channel_get_name((*session)->channel),
-					  switch_channel_state_name(switch_channel_get_state((*session)->channel)));
+	switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_NOTICE, "Close Channel %s [%s]\n",
+					  switch_channel_get_name((*session)->channel), switch_channel_state_name(switch_channel_get_state((*session)->channel)));
 
-	switch_core_media_bug_remove_all(*session);	
+	switch_core_media_bug_remove_all(*session);
 	switch_ivr_deactivate_unicast(*session);
-	
+
 	switch_scheduler_del_task_group((*session)->uuid_str);
 
 	switch_mutex_lock(runtime.throttle_mutex);
@@ -722,10 +719,10 @@
 	//#endif
 	*session = NULL;
 	switch_core_destroy_memory_pool(&pool);
-	
+
 }
 
-static void *SWITCH_THREAD_FUNC switch_core_session_thread(switch_thread_t * thread, void *obj)
+static void *SWITCH_THREAD_FUNC switch_core_session_thread(switch_thread_t *thread, void *obj)
 {
 	switch_core_session_t *session = obj;
 	switch_event_t *event;
@@ -735,7 +732,7 @@
 	session->thread = thread;
 
 	switch_core_session_run(session);
-	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Session %"SWITCH_SIZE_T_FMT" (%s) Locked, Waiting on external entities\n",
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Session %" SWITCH_SIZE_T_FMT " (%s) Locked, Waiting on external entities\n",
 					  session->id, switch_channel_get_name(session->channel));
 	switch_core_session_write_lock(session);
 	switch_set_flag(session, SSF_DESTROYED);
@@ -753,7 +750,7 @@
 
 	switch_core_session_rwunlock(session);
 
-	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Session %"SWITCH_SIZE_T_FMT" (%s) Ended\n",
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Session %" SWITCH_SIZE_T_FMT " (%s) Ended\n",
 					  session->id, switch_channel_get_name(session->channel));
 	switch_core_session_destroy(&session);
 	return NULL;
@@ -769,7 +766,7 @@
 	switch_threadattr_detach_set(thd_attr, 1);
 
 	switch_mutex_lock(session->mutex);
-	
+
 	if (!session->thread_running) {
 		session->thread_running = 1;
 		switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
@@ -818,7 +815,7 @@
 	count = session_manager.session_count;
 	sps = --runtime.sps;
 	switch_mutex_unlock(runtime.throttle_mutex);
-	
+
 	if (sps <= 0) {
 		//switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Throttle Error!\n");
 		return NULL;
@@ -838,7 +835,7 @@
 
 	session = switch_core_alloc(usepool, sizeof(*session));
 	session->pool = usepool;
-	
+
 	if (switch_channel_alloc(&session->channel, session->pool) != SWITCH_STATUS_SUCCESS) {
 		abort();
 	}
@@ -968,13 +965,13 @@
 		switch_channel_hangup(session->channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 		return SWITCH_STATUS_FALSE;
 	}
-		
+
 	if (!application_interface->application_function) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No Function for %s\n", app);
 		switch_channel_hangup(session->channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 		return SWITCH_STATUS_FALSE;
 	}
-		
+
 	if (switch_channel_test_flag(session->channel, CF_PROXY_MODE) && !switch_test_flag(application_interface, SAF_SUPPORT_NOMEDIA)) {
 		switch_ivr_media(session->uuid_str, SMF_NONE);
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Application %s Requires media on channel %s!\n",
@@ -1004,7 +1001,7 @@
 	}
 
 	switch_core_session_exec(session, application_interface, expanded);
-	
+
 	if (expanded != arg) {
 		switch_safe_free(expanded);
 	}
@@ -1013,7 +1010,8 @@
 }
 
 SWITCH_DECLARE(switch_status_t) switch_core_session_exec(switch_core_session_t *session,
-														 const switch_application_interface_t *application_interface, const char *arg) {
+														 const switch_application_interface_t *application_interface, const char *arg)
+{
 	switch_app_log_t *log, *lp;
 	switch_event_t *event;
 	const char *var;
@@ -1028,7 +1026,7 @@
 		log->app = switch_core_session_strdup(session, application_interface->interface_name);
 		log->arg = switch_core_session_strdup(session, arg);
 
-		for(lp = session->app_log; lp && lp->next; lp = lp->next);
+		for (lp = session->app_log; lp && lp->next; lp = lp->next);
 
 		if (lp) {
 			lp->next = log;
@@ -1036,7 +1034,7 @@
 			session->app_log = log;
 		}
 	}
-	
+
 	if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_EXECUTE) == SWITCH_STATUS_SUCCESS) {
 		switch_channel_event_set_data(session->channel, event);
 		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Application", "%s", application_interface->interface_name);
@@ -1049,7 +1047,7 @@
 	switch_assert(application_interface->application_function);
 
 	application_interface->application_function(session, arg);
-	
+
 	if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_EXECUTE_COMPLETE) == SWITCH_STATUS_SUCCESS) {
 		switch_channel_event_set_data(session->channel, event);
 		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Application", "%s", application_interface->interface_name);
@@ -1060,7 +1058,8 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-SWITCH_DECLARE(switch_status_t) switch_core_session_execute_exten(switch_core_session_t *session, const char *exten, const char *dialplan, const char *context)
+SWITCH_DECLARE(switch_status_t) switch_core_session_execute_exten(switch_core_session_t *session, const char *exten, const char *dialplan,
+																  const char *context)
 {
 	char *dp[25];
 	char *dpstr;
@@ -1074,21 +1073,21 @@
 	if (!(profile = switch_channel_get_caller_profile(channel))) {
 		return SWITCH_STATUS_FALSE;
 	}
-	
+
 	if (session->stack_count > SWITCH_MAX_STACKS) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error %s too many stacked extensions\n", switch_channel_get_name(session->channel));
 		return SWITCH_STATUS_FALSE;
 	}
 
 	session->stack_count++;
-	
+
 	new_profile = switch_caller_profile_clone(session, profile);
 	new_profile->destination_number = switch_core_session_strdup(session, exten);
-		
+
 	if (!switch_strlen_zero(dialplan)) {
 		new_profile->dialplan = switch_core_session_strdup(session, dialplan);
 	}
-	
+
 	if (!switch_strlen_zero(context)) {
 		new_profile->context = switch_core_session_strdup(session, context);
 	}
@@ -1101,7 +1100,7 @@
 	for (x = 0; x < argc; x++) {
 		char *dpname = dp[x];
 		char *dparg = NULL;
-			
+
 		if (dpname) {
 			if ((dparg = strchr(dpname, ':'))) {
 				*dparg++ = '\0';
@@ -1113,14 +1112,14 @@
 		if (!(dialplan_interface = switch_loadable_module_get_dialplan_interface(dpname))) {
 			continue;
 		}
-			
+
 		count++;
-		
+
 		if ((extension = dialplan_interface->hunt_function(session, dparg, new_profile)) != 0) {
 			break;
 		}
 	}
-	
+
 	if (!extension) {
 		status = SWITCH_STATUS_FALSE;
 		goto done;
@@ -1129,8 +1128,8 @@
 	new_profile->caller_extension = extension;
 
 	if (profile->caller_extension) {
-		for(pp = profile->caller_extension->children; pp && pp->next; pp = pp->next);
- 
+		for (pp = profile->caller_extension->children; pp && pp->next; pp = pp->next);
+
 		if (pp) {
 			pp->next = new_profile;
 		} else {
@@ -1141,19 +1140,19 @@
 	while (switch_channel_ready(channel) && extension->current_application) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Execute %s(%s)\n",
 						  extension->current_application->application_name, switch_str_nil(extension->current_application->application_data));
-		
+
 		if (switch_core_session_execute_application(session,
 													extension->current_application->application_name,
 													extension->current_application->application_data) != SWITCH_STATUS_SUCCESS) {
 			goto done;
 		}
-		
-		extension->current_application = extension->current_application->next;		
+
+		extension->current_application = extension->current_application->next;
 	}
 
- done:
+  done:
 	session->stack_count--;
-	return status;	
+	return status;
 }
 
 /* For Emacs:

Modified: freeswitch/trunk/src/switch_core_speech.c
==============================================================================
--- freeswitch/trunk/src/switch_core_speech.c	(original)
+++ freeswitch/trunk/src/switch_core_speech.c	Tue May 27 00:30:03 2008
@@ -37,11 +37,8 @@
 
 SWITCH_DECLARE(switch_status_t) switch_core_speech_open(switch_speech_handle_t *sh,
 														const char *module_name,
-														const char *voice_name, 
-														unsigned int rate,
-														unsigned int interval,
-														switch_speech_flag_t *flags, 
-														switch_memory_pool_t *pool)
+														const char *voice_name,
+														unsigned int rate, unsigned int interval, switch_speech_flag_t *flags, switch_memory_pool_t *pool)
 {
 	switch_status_t status;
 	char buf[256] = "";
@@ -130,7 +127,7 @@
 }
 
 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)
+															void *data, switch_size_t *datalen, uint32_t *rate, switch_speech_flag_t *flags)
 {
 	switch_assert(sh != NULL);
 

Modified: freeswitch/trunk/src/switch_core_state_machine.c
==============================================================================
--- freeswitch/trunk/src/switch_core_state_machine.c	(original)
+++ freeswitch/trunk/src/switch_core_state_machine.c	Tue May 27 00:30:03 2008
@@ -50,8 +50,7 @@
 static void switch_core_standard_on_reset(switch_core_session_t *session)
 {
 
-	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Standard RESET %s\n",
-					  switch_channel_get_name(session->channel));	
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Standard RESET %s\n", switch_channel_get_name(session->channel));
 }
 
 static void switch_core_standard_on_routing(switch_core_session_t *session)
@@ -71,7 +70,7 @@
 	} else {
 		char *dp[25];
 		int argc, x, count = 0;
-		
+
 		if (!switch_strlen_zero(caller_profile->dialplan)) {
 			if ((dpstr = switch_core_session_strdup(session, caller_profile->dialplan))) {
 				expanded = switch_channel_expand_variables(session->channel, dpstr);
@@ -79,7 +78,7 @@
 				for (x = 0; x < argc; x++) {
 					char *dpname = dp[x];
 					char *dparg = NULL;
-					
+
 					if (dpname) {
 						if ((dparg = strchr(dpname, ':'))) {
 							*dparg++ = '\0';
@@ -90,7 +89,7 @@
 					if (!(dialplan_interface = switch_loadable_module_get_dialplan_interface(dpname))) {
 						continue;
 					}
-					
+
 					count++;
 
 					if ((extension = dialplan_interface->hunt_function(session, dparg, NULL)) != 0) {
@@ -115,8 +114,8 @@
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "No Route, Aborting\n");
 		switch_channel_hangup(session->channel, SWITCH_CAUSE_NO_ROUTE_DESTINATION);
 	}
-	
- end:
+
+  end:
 
 	if (expanded && dpstr && expanded != dpstr) {
 		free(expanded);
@@ -129,7 +128,7 @@
 
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Standard EXECUTE\n");
 
- top:
+  top:
 	switch_channel_clear_flag(session->channel, CF_RESET);
 
 	if ((extension = switch_channel_get_caller_extension(session->channel)) == 0) {
@@ -141,12 +140,12 @@
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s Execute %s(%s)\n", switch_channel_get_name(session->channel),
 						  extension->current_application->application_name, switch_str_nil(extension->current_application->application_data));
 
-		if (switch_core_session_execute_application(session, 
+		if (switch_core_session_execute_application(session,
 													extension->current_application->application_name,
 													extension->current_application->application_data) != SWITCH_STATUS_SUCCESS) {
 			return;
 		}
-		
+
 		if (switch_channel_test_flag(session->channel, CF_RESET)) {
 			goto top;
 		}
@@ -249,7 +248,7 @@
 
 void switch_core_state_machine_init(switch_memory_pool_t *pool)
 {
-	
+
 	if (switch_test_flag((&runtime), SCF_CRASH_PROT)) {
 		sqlite3HashInit(&stack_table, SQLITE_HASH_BINARY, 0);
 	}
@@ -320,7 +319,7 @@
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Thread has crashed for channel %s\n", switch_channel_get_name(session->channel));
 			switch_channel_hangup(session->channel, SWITCH_CAUSE_CRASH);
 		} else {
-			sqlite3HashInsert(&stack_table, &thread_id, sizeof(thread_id), (void *)&env);
+			sqlite3HashInsert(&stack_table, &thread_id, sizeof(thread_id), (void *) &env);
 			//apr_hash_set(stack_table, &thread_id, sizeof(thread_id), &env);
 		}
 	}
@@ -361,7 +360,7 @@
 		if (state != switch_channel_get_running_state(session->channel) || state == CS_HANGUP || exception) {
 			int index = 0;
 			int proceed = 1;
-			int do_extra_handlers = 1;			
+			int do_extra_handlers = 1;
 
 			switch_channel_set_running_state(session->channel, state);
 
@@ -372,7 +371,7 @@
 			case CS_DONE:
 				goto done;
 				/* HANGUP INIT ROUTING and RESET are all short term so we signal lock during their callbacks */
-			case CS_HANGUP:	    /* Deactivate and end the thread */
+			case CS_HANGUP:	/* Deactivate and end the thread */
 				{
 					const char *var = switch_channel_get_variable(session->channel, SWITCH_PROCESS_CDR_VARIABLE);
 					const char *hook_var;
@@ -387,7 +386,7 @@
 								do_extra_handlers = 0;
 							}
 						} else if (!switch_true(var)) {
-                            do_extra_handlers = 0;
+							do_extra_handlers = 0;
 						}
 					}
 					switch_core_session_signal_lock(session);
@@ -405,50 +404,51 @@
 						}
 						SWITCH_STANDARD_STREAM(stream);
 						switch_api_execute(cmd, arg, NULL, &stream);
-						switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Hangup Command %s(%s):\n%s\n", cmd, arg, switch_str_nil((char *) stream.data));
+						switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Hangup Command %s(%s):\n%s\n", cmd, arg,
+										  switch_str_nil((char *) stream.data));
 						switch_safe_free(stream.data);
 					}
 				}
 				goto done;
-			case CS_INIT: /* Basic setup tasks */
+			case CS_INIT:		/* Basic setup tasks */
 				switch_core_session_signal_lock(session);
 				STATE_MACRO(init, "INIT");
 				switch_core_session_signal_unlock(session);
 				break;
-			case CS_ROUTING: /* Look for a dialplan and find something to do */
+			case CS_ROUTING:	/* Look for a dialplan and find something to do */
 				switch_core_session_signal_lock(session);
 				STATE_MACRO(routing, "ROUTING");
 				switch_core_session_signal_unlock(session);
 				break;
-			case CS_RESET: /* Reset */
+			case CS_RESET:		/* Reset */
 				switch_core_session_signal_lock(session);
 				STATE_MACRO(reset, "RESET");
 				switch_core_session_signal_unlock(session);
 				break;
 				/* These other states are intended for prolonged durations so we do not signal lock for them */
-			case CS_EXECUTE: /* Execute an Operation */
+			case CS_EXECUTE:	/* Execute an Operation */
 				STATE_MACRO(execute, "EXECUTE");
 				break;
-			case CS_EXCHANGE_MEDIA: /* loop all data back to source */
+			case CS_EXCHANGE_MEDIA:	/* loop all data back to source */
 				STATE_MACRO(exchange_media, "EXCHANGE_MEDIA");
 				break;
-			case CS_SOFT_EXECUTE: /* send/recieve data to/from another channel */
+			case CS_SOFT_EXECUTE:	/* send/recieve data to/from another channel */
 				STATE_MACRO(soft_execute, "SOFT_EXECUTE");
 				break;
-			case CS_PARK: /* wait in limbo */
+			case CS_PARK:		/* wait in limbo */
 				STATE_MACRO(park, "PARK");
 				break;
-			case CS_CONSUME_MEDIA: /* wait in limbo */
+			case CS_CONSUME_MEDIA:	/* wait in limbo */
 				STATE_MACRO(consume_media, "CONSUME_MEDIA");
 				break;
-			case CS_HIBERNATE: /* sleep */
+			case CS_HIBERNATE:	/* sleep */
 				STATE_MACRO(hibernate, "HIBERNATE");
 				break;
 			case CS_NONE:
 				abort();
 				break;
 			}
-			
+
 			if (midstate == CS_DONE) {
 				break;
 			}
@@ -456,7 +456,7 @@
 		}
 
 		endstate = switch_channel_get_state(session->channel);
-		
+
 		if (endstate == switch_channel_get_running_state(session->channel)) {
 			if (endstate == CS_NEW) {
 				switch_yield(1000);

Modified: freeswitch/trunk/src/switch_core_timer.c
==============================================================================
--- freeswitch/trunk/src/switch_core_timer.c	(original)
+++ freeswitch/trunk/src/switch_core_timer.c	Tue May 27 00:30:03 2008
@@ -35,7 +35,8 @@
 #include <switch.h>
 #include "private/switch_core_pvt.h"
 
-SWITCH_DECLARE(switch_status_t) switch_core_timer_init(switch_timer_t *timer, const 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, const char *timer_name, int interval, int samples,
+													   switch_memory_pool_t *pool)
 {
 	switch_timer_interface_t *timer_interface;
 	switch_status_t status;

Modified: freeswitch/trunk/src/switch_event.c
==============================================================================
--- freeswitch/trunk/src/switch_event.c	(original)
+++ freeswitch/trunk/src/switch_event.c	Tue May 27 00:30:03 2008
@@ -59,13 +59,13 @@
 static switch_queue_t *EVENT_HEADER_RECYCLE_QUEUE = NULL;
 static void launch_dispatch_threads(int max, int len, switch_memory_pool_t *pool);
 
-static char *my_dup (const char *s)
+static char *my_dup(const char *s)
 {
-    size_t len = strlen (s) + 1;
-    void *new = malloc (len);
+	size_t len = strlen(s) + 1;
+	void *new = malloc(len);
 	switch_assert(new);
 
-    return (char *) memcpy (new, s, len);
+	return (char *) memcpy(new, s, len);
 }
 
 #ifndef ALLOC
@@ -172,7 +172,7 @@
 	return match;
 }
 
-static void *SWITCH_THREAD_FUNC switch_event_dispatch_thread(switch_thread_t * thread, void *obj)
+static void *SWITCH_THREAD_FUNC switch_event_dispatch_thread(switch_thread_t *thread, void *obj)
 {
 	switch_queue_t *queue = (switch_queue_t *) obj;
 	int my_id = 0;
@@ -186,7 +186,7 @@
 		}
 	}
 
-	for(;;) {
+	for (;;) {
 		void *pop = NULL;
 		switch_event_t *event = NULL;
 
@@ -197,7 +197,7 @@
 		if (!pop) {
 			break;
 		}
-		
+
 		event = (switch_event_t *) pop;
 		switch_event_deliver(&event);
 	}
@@ -206,14 +206,14 @@
 	switch_mutex_lock(EVENT_QUEUE_MUTEX);
 	THREAD_COUNT--;
 	switch_mutex_unlock(EVENT_QUEUE_MUTEX);
-	
+
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Dispatch Thread %d Ended.\n", my_id);
 	return NULL;
-	
+
 }
 
 
-static void *SWITCH_THREAD_FUNC switch_event_thread(switch_thread_t * thread, void *obj)
+static void *SWITCH_THREAD_FUNC switch_event_thread(switch_thread_t *thread, void *obj)
 {
 	switch_queue_t *queue = (switch_queue_t *) obj;
 	int index = 0;
@@ -228,11 +228,11 @@
 			break;
 		}
 	}
-	
-	for(;;) {
+
+	for (;;) {
 		void *pop = NULL;
 		switch_event_t *event = NULL;
-		
+
 		if (switch_queue_pop(queue, &pop) != SWITCH_STATUS_SUCCESS) {
 			break;
 		}
@@ -243,18 +243,18 @@
 
 		event = (switch_event_t *) pop;
 
-		while(event) {
+		while (event) {
 			for (index = 0; index < SOFT_MAX_DISPATCH; index++) {
 				if (switch_queue_trypush(EVENT_DISPATCH_QUEUE[index], event) == SWITCH_STATUS_SUCCESS) {
 					event = NULL;
 					break;
 				}
 			}
-		
+
 			if (event) {
-				if (SOFT_MAX_DISPATCH+1 < MAX_DISPATCH) {				
-					switch_mutex_lock(EVENT_QUEUE_MUTEX);			
-					launch_dispatch_threads(SOFT_MAX_DISPATCH+1, DISPATCH_QUEUE_LEN, RUNTIME_POOL);
+				if (SOFT_MAX_DISPATCH + 1 < MAX_DISPATCH) {
+					switch_mutex_lock(EVENT_QUEUE_MUTEX);
+					launch_dispatch_threads(SOFT_MAX_DISPATCH + 1, DISPATCH_QUEUE_LEN, RUNTIME_POOL);
 					switch_mutex_unlock(EVENT_QUEUE_MUTEX);
 				}
 			}
@@ -264,10 +264,10 @@
 	switch_mutex_lock(EVENT_QUEUE_MUTEX);
 	THREAD_COUNT--;
 	switch_mutex_unlock(EVENT_QUEUE_MUTEX);
-	
+
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Event Thread %d Ended.\n", my_id);
 	return NULL;
-	
+
 }
 
 
@@ -352,7 +352,7 @@
 
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Returning %d recycled event(s) %d bytes\n", size, (int) sizeof(switch_event_t) * size);
 	size = switch_queue_size(EVENT_HEADER_RECYCLE_QUEUE);
-	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Returning %d recycled event header(s) %d bytes\n", 
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Returning %d recycled event header(s) %d bytes\n",
 					  size, (int) sizeof(switch_event_header_t) * size);
 
 	while (switch_queue_trypop(EVENT_HEADER_RECYCLE_QUEUE, &pop) == SWITCH_STATUS_SUCCESS) {
@@ -371,16 +371,16 @@
 	SYSTEM_RUNNING = 0;
 	switch_mutex_unlock(EVENT_QUEUE_MUTEX);
 
-	for(x = 0; x < 3; x++) {
+	for (x = 0; x < 3; x++) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Stopping event queue %d\n", x);
 		switch_queue_push(EVENT_QUEUE[x], NULL);
 	}
 
-	for(x = 0; x < SOFT_MAX_DISPATCH; x++) {
+	for (x = 0; x < SOFT_MAX_DISPATCH; x++) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Stopping dispatch queue %d\n", x);
 		switch_queue_push(EVENT_DISPATCH_QUEUE[x], NULL);
 	}
-		
+
 	while (x < 10000 && THREAD_COUNT) {
 		switch_yield(1000);
 		if (THREAD_COUNT == last) {
@@ -388,7 +388,7 @@
 		}
 		last = THREAD_COUNT;
 	}
-	
+
 
 	switch_core_hash_destroy(&CUSTOM_HASH);
 	switch_core_memory_reclaim_events();
@@ -399,17 +399,17 @@
 static void launch_dispatch_threads(int max, int len, switch_memory_pool_t *pool)
 {
 	switch_thread_t *thread;
-    switch_threadattr_t *thd_attr;
+	switch_threadattr_t *thd_attr;
 	int index = 0;
 
 	if (max > MAX_DISPATCH) {
 		return;
 	}
-	
+
 	if (max < SOFT_MAX_DISPATCH) {
 		return;
 	}
-	
+
 	for (index = SOFT_MAX_DISPATCH; index < max && index < MAX_DISPATCH; index++) {
 		if (EVENT_DISPATCH_QUEUE[index]) {
 			continue;
@@ -445,7 +445,7 @@
 	switch_queue_create(&EVENT_QUEUE[2], POOL_COUNT_MAX + 10, THRUNTIME_POOL);
 	switch_queue_create(&EVENT_RECYCLE_QUEUE, 250000, THRUNTIME_POOL);
 	switch_queue_create(&EVENT_HEADER_RECYCLE_QUEUE, 250000, THRUNTIME_POOL);
-	
+
 
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Activate Eventing Engine.\n");
 	switch_mutex_init(&BLOCK, SWITCH_MUTEX_NESTED, RUNTIME_POOL);
@@ -459,7 +459,7 @@
 	switch_thread_create(&thread, thd_attr, switch_event_thread, EVENT_QUEUE[0], RUNTIME_POOL);
 	switch_thread_create(&thread, thd_attr, switch_event_thread, EVENT_QUEUE[1], RUNTIME_POOL);
 	switch_thread_create(&thread, thd_attr, switch_event_thread, EVENT_QUEUE[2], RUNTIME_POOL);
-	
+
 	while (!THREAD_COUNT) {
 		switch_yield(1000);
 	}
@@ -475,11 +475,11 @@
 SWITCH_DECLARE(switch_status_t) switch_event_create_subclass(switch_event_t **event, switch_event_types_t event_id, const char *subclass_name)
 {
 	void *pop;
-	
+
 	if (event_id != SWITCH_EVENT_CUSTOM && subclass_name) {
 		return SWITCH_STATUS_GENERR;
 	}
-	
+
 	if (switch_queue_trypop(EVENT_RECYCLE_QUEUE, &pop) == SWITCH_STATUS_SUCCESS) {
 		*event = (switch_event_t *) pop;
 	} else {
@@ -493,7 +493,7 @@
 
 	if (subclass_name) {
 		if (!((*event)->subclass = switch_core_hash_find(CUSTOM_HASH, subclass_name))) {
-			switch_event_reserve_subclass((char *)subclass_name);
+			switch_event_reserve_subclass((char *) subclass_name);
 			(*event)->subclass = switch_core_hash_find(CUSTOM_HASH, subclass_name);
 		}
 		switch_event_add_header_string(*event, SWITCH_STACK_BOTTOM, "Event-Subclass", subclass_name);
@@ -513,7 +513,8 @@
 {
 	switch_event_header_t *hp;
 	switch_assert(event);
-	if (!header_name) return NULL;
+	if (!header_name)
+		return NULL;
 
 	for (hp = event->headers; hp; hp = hp->next) {
 		if (!strcasecmp(hp->name, header_name)) {
@@ -556,7 +557,7 @@
 		}
 		lp = hp;
 	}
-	
+
 	return status;
 }
 
@@ -685,7 +686,7 @@
 
 	for (hp = todup->headers; hp; hp = hp->next) {
 		void *pop;
-		
+
 		if (switch_queue_trypop(EVENT_HEADER_RECYCLE_QUEUE, &pop) == SWITCH_STATUS_SUCCESS) {
 			header = (switch_event_header_t *) pop;
 		} else {
@@ -844,7 +845,7 @@
 	return header;
 }
 
-SWITCH_DECLARE(switch_xml_t) switch_event_xmlize(switch_event_t *event, const char *fmt,...)
+SWITCH_DECLARE(switch_xml_t) switch_event_xmlize(switch_event_t *event, const char *fmt, ...)
 {
 	switch_event_header_t *hp;
 	char *data = NULL, *body = NULL;
@@ -863,7 +864,8 @@
 		ret = vasprintf(&data, fmt, ap);
 #else
 		data = (char *) malloc(2048);
-		if (!data) return NULL;
+		if (!data)
+			return NULL;
 		ret = vsnprintf(data, 2048, fmt, ap);
 #endif
 		va_end(ap);
@@ -935,7 +937,7 @@
 	switch_event_add_header_string(*event, SWITCH_STACK_BOTTOM, "Event-Date-Local", date);
 	switch_rfc822_date(date, ts);
 	switch_event_add_header_string(*event, SWITCH_STACK_BOTTOM, "Event-Date-GMT", date);
-	switch_event_add_header(*event, SWITCH_STACK_BOTTOM, "Event-Date-timestamp", "%"SWITCH_UINT64_T_FMT, (uint64_t)ts);
+	switch_event_add_header(*event, SWITCH_STACK_BOTTOM, "Event-Date-timestamp", "%" SWITCH_UINT64_T_FMT, (uint64_t) ts);
 	switch_event_add_header_string(*event, SWITCH_STACK_BOTTOM, "Event-Calling-File", switch_cut_path(file));
 	switch_event_add_header_string(*event, SWITCH_STACK_BOTTOM, "Event-Calling-Function", func);
 	switch_event_add_header(*event, SWITCH_STACK_BOTTOM, "Event-Calling-Line-Number", "%d", line);
@@ -948,7 +950,7 @@
 	if (user_data) {
 		(*event)->event_user_data = user_data;
 	}
-	
+
 
 	switch_queue_push(EVENT_QUEUE[(*event)->priority], *event);
 	*event = NULL;
@@ -998,15 +1000,15 @@
 	return SWITCH_STATUS_MEMERR;
 }
 
-SWITCH_DECLARE(switch_status_t) switch_event_create_pres_in_detailed(char *file, char *func, int line, 
+SWITCH_DECLARE(switch_status_t) switch_event_create_pres_in_detailed(char *file, char *func, int line,
 																	 const char *proto, const char *login,
 																	 const char *from, const char *from_domain,
-																	 const char *status, const char *event_type, 
+																	 const char *status, const char *event_type,
 																	 const char *alt_event_type, int event_count,
 																	 const char *unique_id, const char *channel_state,
 																	 const char *answer_state, const char *call_direction)
 {
-    switch_event_t *pres_event;
+	switch_event_t *pres_event;
 
 	if (switch_event_create_subclass(&pres_event, SWITCH_EVENT_PRESENCE_IN, SWITCH_EVENT_SUBCLASS_ANY) == SWITCH_STATUS_SUCCESS) {
 		switch_event_add_header_string(pres_event, SWITCH_STACK_TOP, "proto", proto);
@@ -1047,22 +1049,22 @@
 	int nv = 0;
 
 	q = in;
-	while(q && *q) {
+	while (q && *q) {
 		if (!(p = strchr(q, '$'))) {
 			break;
 		}
-		
-		if (*(p+1) != '{') {
+
+		if (*(p + 1) != '{') {
 			q = p + 1;
 			continue;
 		}
-		
+
 		nv = 1;
 		break;
 	}
-	
+
 	if (!nv) {
-		return (char *)in;
+		return (char *) in;
 	}
 
 	nv = 0;
@@ -1074,7 +1076,7 @@
 		c = data;
 		for (p = indup; p && *p; p++) {
 			vtype = 0;
-			
+
 			if (*p == '\\') {
 				if (*(p + 1) == '$') {
 					nv = 1;
@@ -1087,8 +1089,8 @@
 			}
 
 			if (*p == '$' && !nv) {
-				if (*(p+1)) {
-					if (*(p+1) == '{') {
+				if (*(p + 1)) {
+					if (*(p + 1) == '{') {
 						vtype = 1;
 					} else {
 						nv = 1;
@@ -1132,20 +1134,20 @@
 							br--;
 						}
 					}
-					
+
 					e++;
 				}
 				p = e;
-				
+
 				if ((vval = strchr(vname, '('))) {
 					e = vval - 1;
 					*vval++ = '\0';
-					while(*e == ' ') {
+					while (*e == ' ') {
 						*e-- = '\0';
 					}
 					e = vval;
 					br = 1;
-					while(e && *e) {
+					while (e && *e) {
 						if (*e == '(') {
 							br++;
 						} else if (br > 1 && *e == ')') {
@@ -1166,7 +1168,7 @@
 					int ooffset = 0;
 					char *ptr;
 
-					if ((expanded = switch_event_expand_headers(event, (char *)vname)) == vname) {
+					if ((expanded = switch_event_expand_headers(event, (char *) vname)) == vname) {
 						expanded = NULL;
 					} else {
 						vname = expanded;
@@ -1179,25 +1181,25 @@
 							ooffset = atoi(ptr);
 						}
 					}
-					
+
 					if (!(sub_val = switch_event_get_header(event, vname))) {
 						sub_val = switch_core_get_variable(vname);
 					}
 
 					if (offset || ooffset) {
 						cloned_sub_val = strdup(sub_val);
-                        switch_assert(cloned_sub_val);
+						switch_assert(cloned_sub_val);
 						sub_val = cloned_sub_val;
 					}
 
 					if (offset >= 0) {
 						sub_val += offset;
-					} else if ((size_t)abs(offset) <= strlen(sub_val)) {
+					} else if ((size_t) abs(offset) <= strlen(sub_val)) {
 						sub_val = cloned_sub_val + (strlen(cloned_sub_val) + offset);
 					}
 
-					if (ooffset > 0 && (size_t)ooffset < strlen(sub_val)) {
-						if ((ptr = (char *)sub_val + ooffset)) {
+					if (ooffset > 0 && (size_t) ooffset < strlen(sub_val)) {
+						if ((ptr = (char *) sub_val + ooffset)) {
 							*ptr = '\0';
 						}
 					}
@@ -1212,7 +1214,7 @@
 					if (stream.data) {
 						char *expanded_vname = NULL;
 
-						if ((expanded_vname = switch_event_expand_headers(event, (char *)vname)) == vname) {
+						if ((expanded_vname = switch_event_expand_headers(event, (char *) vname)) == vname) {
 							expanded_vname = NULL;
 						} else {
 							vname = expanded_vname;
@@ -1230,15 +1232,15 @@
 						} else {
 							free(stream.data);
 						}
-						
+
 						switch_safe_free(expanded);
 						switch_safe_free(expanded_vname);
-						
+
 					} else {
 						switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
 						free(data);
 						free(indup);
-						return (char *)in;
+						return (char *) in;
 					}
 				}
 				if ((nlen = sub_val ? strlen(sub_val) : 0)) {
@@ -1277,20 +1279,21 @@
 		}
 	}
 	free(indup);
-	
+
 	return data;
 }
 
-SWITCH_DECLARE(char *) switch_event_build_param_string(switch_event_t *event, const char *prefix, switch_hash_t* vars_map)
+SWITCH_DECLARE(char *) switch_event_build_param_string(switch_event_t *event, const char *prefix, switch_hash_t *vars_map)
 {
 	switch_stream_handle_t stream = { 0 };
 	switch_size_t encode_len = 1024, new_len = 0;
 	char *encode_buf = NULL;
-	const char *prof[12] = { 0 }, *prof_names[12] = {0};
+	const char *prof[12] = { 0 }, *prof_names[12] = {
+	0};
 	char *e = NULL;
 	switch_event_header_t *hi;
 	uint32_t x = 0;
-	void* data = NULL;
+	void *data = NULL;
 
 	SWITCH_STANDARD_STREAM(stream);
 
@@ -1325,24 +1328,23 @@
 
 	if (event) {
 		if ((hi = event->headers)) {
-		
+
 			for (; hi; hi = hi->next) {
 				char *var = hi->name;
 				char *val = hi->value;
-				
-				if (vars_map != NULL)
-				{
-				    if ((data = switch_core_hash_find(vars_map,var)) == NULL || strcasecmp(((char*)data),"enabled"))
-					continue;
-				    
+
+				if (vars_map != NULL) {
+					if ((data = switch_core_hash_find(vars_map, var)) == NULL || strcasecmp(((char *) data), "enabled"))
+						continue;
+
 				}
-				
+
 				new_len = (strlen((char *) var) * 3) + 1;
 				if (encode_len < new_len) {
 					char *tmp;
-				
+
 					encode_len = new_len;
-			
+
 					tmp = realloc(encode_buf, encode_len);
 					switch_assert(tmp);
 					encode_buf = tmp;
@@ -1354,7 +1356,7 @@
 			}
 		}
 	}
-	
+
 	e = (char *) stream.data + (strlen((char *) stream.data) - 1);
 
 	if (e && *e == '&') {

Modified: freeswitch/trunk/src/switch_ivr.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr.c	(original)
+++ freeswitch/trunk/src/switch_ivr.c	Tue May 27 00:30:03 2008
@@ -90,17 +90,17 @@
 	}
 
 	channel = switch_core_session_get_channel(conninfo->session);
-	
-	while(switch_test_flag(conninfo, SUF_READY) && switch_test_flag(conninfo, SUF_THREAD_RUNNING)) {
+
+	while (switch_test_flag(conninfo, SUF_READY) && switch_test_flag(conninfo, SUF_THREAD_RUNNING)) {
 		len = conninfo->write_frame.buflen;
 		if (switch_socket_recv(conninfo->socket, conninfo->write_frame.data, &len) != SWITCH_STATUS_SUCCESS || len == 0) {
 			break;
 		}
-		conninfo->write_frame.datalen = (uint32_t)len;
+		conninfo->write_frame.datalen = (uint32_t) len;
 		conninfo->write_frame.samples = conninfo->write_frame.datalen / 2;
 		switch_core_session_write_frame(conninfo->session, &conninfo->write_frame, SWITCH_IO_FLAG_NONE, conninfo->stream_id);
 	}
-	
+
 	switch_clear_flag_locked(conninfo, SUF_READY);
 	switch_clear_flag_locked(conninfo, SUF_THREAD_RUNNING);
 
@@ -126,14 +126,14 @@
 	int sanity = 0;
 
 	if (!switch_channel_test_flag(channel, CF_UNICAST)) {
-			return SWITCH_STATUS_FALSE;
+		return SWITCH_STATUS_FALSE;
 	}
 
 	if ((conninfo = switch_channel_get_private(channel, "unicast"))) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Shutting down unicast connection\n");
 		switch_clear_flag_locked(conninfo, SUF_READY);
 		switch_socket_shutdown(conninfo->socket, SWITCH_SHUTDOWN_READWRITE);
-		while(switch_test_flag(conninfo, SUF_THREAD_RUNNING)) {
+		while (switch_test_flag(conninfo, SUF_THREAD_RUNNING)) {
 			switch_yield(10000);
 			if (++sanity >= 10000) {
 				break;
@@ -148,13 +148,10 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-SWITCH_DECLARE(switch_status_t) switch_ivr_activate_unicast(switch_core_session_t *session, 
+SWITCH_DECLARE(switch_status_t) switch_ivr_activate_unicast(switch_core_session_t *session,
 															char *local_ip,
 															switch_port_t local_port,
-															char *remote_ip,
-															switch_port_t remote_port,
-															char *transport,
-															char *flags)
+															char *remote_ip, switch_port_t remote_port, char *transport, char *flags)
 {
 	switch_channel_t *channel = switch_core_session_get_channel(session);
 	switch_unicast_conninfo_t *conninfo = switch_core_session_alloc(session, sizeof(*conninfo));
@@ -168,7 +165,7 @@
 	conninfo->remote_ip = switch_core_session_strdup(session, remote_ip);
 	conninfo->remote_port = remote_port;
 	conninfo->session = session;
-	
+
 	if (!strcasecmp(transport, "udp")) {
 		conninfo->type = AF_INET;
 		conninfo->transport = SOCK_DGRAM;
@@ -187,9 +184,9 @@
 	}
 
 	switch_mutex_init(&conninfo->flag_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
-	
+
 	read_codec = switch_core_session_get_read_codec(session);
-	
+
 	if (!switch_test_flag(conninfo, SUF_NATIVE)) {
 		if (switch_core_codec_init(&conninfo->read_codec,
 								   "L16",
@@ -216,17 +213,17 @@
 					  conninfo->local_ip, conninfo->local_port, conninfo->remote_ip, conninfo->remote_port);
 
 	if (switch_sockaddr_info_get(&conninfo->local_addr,
-								 conninfo->local_ip, SWITCH_UNSPEC, conninfo->local_port, 0, 
+								 conninfo->local_ip, SWITCH_UNSPEC, conninfo->local_port, 0,
 								 switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
 		goto fail;
 	}
-	
-	if (switch_sockaddr_info_get(&conninfo->remote_addr, 
+
+	if (switch_sockaddr_info_get(&conninfo->remote_addr,
 								 conninfo->remote_ip, SWITCH_UNSPEC, conninfo->remote_port, 0,
 								 switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
 		goto fail;
 	}
-	
+
 	if (switch_socket_create(&conninfo->socket, AF_INET, SOCK_DGRAM, 0, switch_core_session_get_pool(session)) == SWITCH_STATUS_SUCCESS) {
 		if (switch_socket_bind(conninfo->socket, conninfo->local_addr) != SWITCH_STATUS_SUCCESS) {
 			goto fail;
@@ -242,11 +239,11 @@
 	switch_set_flag_locked(conninfo, SUF_READY);
 	return SWITCH_STATUS_SUCCESS;
 
- fail:
+  fail:
 
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Failure creating unicast connection %s:%d->%s:%d\n",
 					  conninfo->local_ip, conninfo->local_port, conninfo->remote_ip, conninfo->remote_port);
-	return SWITCH_STATUS_FALSE;	
+	return SWITCH_STATUS_FALSE;
 }
 
 SWITCH_DECLARE(switch_status_t) switch_ivr_parse_event(switch_core_session_t *session, switch_event_t *event)
@@ -280,8 +277,8 @@
 		switch_frame_t *read_frame;
 		int frame_count = atoi(lead_frames);
 		int max_frames = frame_count * 2;
-		
-		while(frame_count > 0 && --max_frames > 0) {
+
+		while (frame_count > 0 && --max_frames > 0) {
 			status = switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
 			if (!SWITCH_READ_ACCEPTABLE(status)) {
 				goto done;
@@ -310,7 +307,7 @@
 					int x;
 					const char *b_uuid = NULL;
 					switch_core_session_t *b_session = NULL;
-					
+
 					switch_channel_clear_flag(channel, CF_STOP_BROADCAST);
 					switch_channel_set_flag(channel, CF_BROADCAST);
 					if (hold_bleg && switch_true(hold_bleg)) {
@@ -336,8 +333,8 @@
 					}
 					for (x = 0; x < loops || loops < 0; x++) {
 						switch_time_t b4, aftr;
-						
-						switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s Command Execute %s(%s)\n", 
+
+						switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s Command Execute %s(%s)\n",
 										  switch_channel_get_name(channel), app_name, app_arg);
 						b4 = switch_timestamp_now();
 						switch_core_session_exec(session, application_interface, app_arg);
@@ -356,7 +353,7 @@
 						}
 					}
 
-					switch_channel_clear_flag(channel, CF_BROADCAST);					
+					switch_channel_clear_flag(channel, CF_BROADCAST);
 				}
 			}
 		}
@@ -384,7 +381,7 @@
 			transport = "udp";
 		}
 
-		switch_ivr_activate_unicast(session, local_ip, (switch_port_t)atoi(local_port), remote_ip, (switch_port_t)atoi(remote_port), transport, flags);
+		switch_ivr_activate_unicast(session, local_ip, (switch_port_t) atoi(local_port), remote_ip, (switch_port_t) atoi(remote_port), transport, flags);
 
 	} else if (cmd_hash == CMD_HANGUP) {
 		char *cause_name = switch_event_get_header(event, "hangup-cause");
@@ -402,7 +399,7 @@
 
 	status = SWITCH_STATUS_SUCCESS;
 
- done:
+  done:
 	switch_channel_clear_flag(channel, CF_EVENT_PARSE);
 	switch_channel_clear_flag(channel, CF_EVENT_LOCK);
 
@@ -473,18 +470,18 @@
 			if (!SWITCH_READ_ACCEPTABLE(status)) {
 				break;
 			}
-			
+
 			if (switch_channel_test_flag(channel, CF_UNICAST)) {
 				if (!conninfo) {
 					if (!(conninfo = switch_channel_get_private(channel, "unicast"))) {
 						switch_channel_clear_flag(channel, CF_UNICAST);
 					}
-					
+
 					if (conninfo) {
 						unicast_thread_launch(conninfo);
 					}
 				}
-				
+
 				if (conninfo) {
 					switch_size_t len = 0;
 					uint32_t flags = 0;
@@ -504,13 +501,11 @@
 						if (switch_test_flag(conninfo, SUF_NATIVE)) {
 							tstatus = SWITCH_STATUS_NOOP;
 						} else {
-							tstatus = switch_core_codec_decode(
-															  read_codec,
-															  &conninfo->read_codec,
-															  read_frame->data,
-															  read_frame->datalen,
-															  read_codec->implementation->actual_samples_per_second,
-															  decoded, &dlen, &rate, &flags);
+							tstatus = switch_core_codec_decode(read_codec,
+															   &conninfo->read_codec,
+															   read_frame->data,
+															   read_frame->datalen,
+															   read_codec->implementation->actual_samples_per_second, decoded, &dlen, &rate, &flags);
 						}
 						switch (tstatus) {
 						case SWITCH_STATUS_NOOP:
@@ -533,19 +528,19 @@
 
 					if (tstatus == SWITCH_STATUS_SUCCESS) {
 						len = sendlen;
-						if (switch_socket_sendto(conninfo->socket, conninfo->remote_addr, 0, (void *)sendbuf, &len) != SWITCH_STATUS_SUCCESS) {
+						if (switch_socket_sendto(conninfo->socket, conninfo->remote_addr, 0, (void *) sendbuf, &len) != SWITCH_STATUS_SUCCESS) {
 							switch_ivr_deactivate_unicast(session);
 						}
 					}
 				}
 			}
-			
+
 			if (switch_core_session_private_event_count(session)) {
 				switch_ivr_parse_all_events(session);
 			}
 
 			if (switch_channel_has_dtmf(channel)) {
-				switch_dtmf_t dtmf = {0};
+				switch_dtmf_t dtmf = { 0 };
 				switch_channel_dequeue_dtmf(channel, &dtmf);
 				if (args && args->input_callback) {
 					if ((status = args->input_callback(session, (void *) &dtmf, SWITCH_INPUT_TYPE_DTMF, args->buf, args->buflen)) != SWITCH_STATUS_SUCCESS) {
@@ -600,7 +595,7 @@
 	while (switch_channel_ready(channel)) {
 		switch_frame_t *read_frame = NULL;
 		switch_event_t *event;
-		switch_dtmf_t dtmf = {0};
+		switch_dtmf_t dtmf = { 0 };
 
 		if (switch_channel_test_flag(channel, CF_BREAK)) {
 			switch_channel_clear_flag(channel, CF_BREAK);
@@ -616,12 +611,12 @@
 		}
 
 		if (switch_core_session_private_event_count(session)) {
-            switch_ivr_parse_all_events(session);
-        }
+			switch_ivr_parse_all_events(session);
+		}
 
 		if (switch_channel_has_dtmf(channel)) {
 			switch_channel_dequeue_dtmf(channel, &dtmf);
-			status = args->input_callback(session, (void *)&dtmf, SWITCH_INPUT_TYPE_DTMF, args->buf, args->buflen);
+			status = args->input_callback(session, (void *) &dtmf, SWITCH_INPUT_TYPE_DTMF, args->buf, args->buflen);
 		}
 
 		if (switch_core_session_dequeue_event(session, &event) == SWITCH_STATUS_SUCCESS) {
@@ -656,11 +651,9 @@
 SWITCH_DECLARE(switch_status_t) switch_ivr_collect_digits_count(switch_core_session_t *session,
 																char *buf,
 																switch_size_t buflen,
-																switch_size_t maxdigits, 
-																const char *terminators, char *terminator, 
-																uint32_t first_timeout,
-																uint32_t digit_timeout,
-																uint32_t abs_timeout)
+																switch_size_t maxdigits,
+																const char *terminators, char *terminator,
+																uint32_t first_timeout, uint32_t digit_timeout, uint32_t abs_timeout)
 {
 	switch_size_t i = 0, x = strlen(buf);
 	switch_channel_t *channel = switch_core_session_get_channel(session);
@@ -693,7 +686,7 @@
 	} else if (first_timeout) {
 		digit_timeout = eff_timeout = first_timeout;
 	}
-	
+
 
 	if (eff_timeout) {
 		digit_started = switch_timestamp_now();
@@ -701,7 +694,7 @@
 
 	while (switch_channel_ready(channel)) {
 		switch_frame_t *read_frame;
-		
+
 		if (abs_timeout) {
 			abs_elapsed = (uint32_t) ((switch_timestamp_now() - started) / 1000);
 			if (abs_elapsed >= abs_timeout) {
@@ -709,9 +702,9 @@
 			}
 		}
 
-        if (switch_core_session_private_event_count(session)) {
-            switch_ivr_parse_all_events(session);
-        }
+		if (switch_core_session_private_event_count(session)) {
+			switch_ivr_parse_all_events(session);
+		}
 
 
 		if (eff_timeout) {
@@ -722,9 +715,9 @@
 		}
 
 		if (switch_channel_has_dtmf(channel)) {
-			switch_dtmf_t dtmf = {0};
+			switch_dtmf_t dtmf = { 0 };
 			switch_size_t y;
-			
+
 			if (eff_timeout) {
 				eff_timeout = digit_timeout;
 				digit_started = switch_timestamp_now();
@@ -739,8 +732,8 @@
 					*terminator = dtmf.digit;
 					return SWITCH_STATUS_SUCCESS;
 				}
-				
-				
+
+
 				buf[x++] = dtmf.digit;
 				buf[x] = '\0';
 				if (x >= buflen || x >= maxdigits) {
@@ -777,13 +770,13 @@
 	switch_channel_set_flag(channel, CF_SUSPEND);
 
 	switch_core_session_receive_message(session, &msg);
-	
+
 	if (moh && (stream = switch_channel_get_variable(channel, SWITCH_HOLD_MUSIC_VARIABLE))) {
 		if ((other_uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))) {
 			switch_ivr_broadcast(other_uuid, stream, SMF_ECHO_ALEG | SMF_LOOP);
 		}
 	}
-	
+
 
 	return SWITCH_STATUS_SUCCESS;
 }
@@ -848,7 +841,7 @@
 	switch_status_t status = SWITCH_STATUS_GENERR;
 	uint8_t swap = 0;
 	switch_frame_t *read_frame = NULL;
-	
+
 	msg.message_id = SWITCH_MESSAGE_INDICATE_MEDIA;
 	msg.from = __FILE__;
 
@@ -865,7 +858,7 @@
 
 			switch_channel_wait_for_flag(channel, CF_REQ_MEDIA, SWITCH_FALSE, 10000);
 			switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
-			
+
 			if ((flags & SMF_REBRIDGE)
 				&& (other_uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BRIDGE_VARIABLE))
 				&& (other_session = switch_core_session_locate(other_uuid))) {
@@ -881,7 +874,7 @@
 				switch_channel_clear_state_handler(channel, NULL);
 			}
 		}
-		
+
 		switch_core_session_rwunlock(session);
 
 		if (other_channel) {
@@ -906,7 +899,7 @@
 	switch_core_session_message_t msg = { 0 };
 	switch_status_t status = SWITCH_STATUS_GENERR;
 	uint8_t swap = 0;
-	
+
 	msg.message_id = SWITCH_MESSAGE_INDICATE_NOMEDIA;
 	msg.from = __FILE__;
 
@@ -920,7 +913,7 @@
 
 		if ((flags & SMF_FORCE) || !switch_channel_test_flag(channel, CF_PROXY_MODE)) {
 			switch_core_session_receive_message(session, &msg);
-			
+
 			if ((flags & SMF_REBRIDGE) && (other_uuid = switch_channel_get_variable(channel, SWITCH_BRIDGE_VARIABLE)) &&
 				(other_session = switch_core_session_locate(other_uuid))) {
 				other_channel = switch_core_session_get_channel(other_session);
@@ -947,7 +940,8 @@
 	return status;
 }
 
-SWITCH_DECLARE(switch_status_t) switch_ivr_session_transfer(switch_core_session_t *session, const char *extension, const char *dialplan, const char *context)
+SWITCH_DECLARE(switch_status_t) switch_ivr_session_transfer(switch_core_session_t *session, const char *extension, const char *dialplan,
+															const char *context)
 {
 	switch_channel_t *channel = switch_core_session_get_channel(session);
 	switch_caller_profile_t *profile, *new_profile;
@@ -960,7 +954,7 @@
 	int forwardval = 70;
 
 	if (!switch_strlen_zero(forwardvar)) {
-		forwardval =  atoi(forwardvar) - 1;
+		forwardval = atoi(forwardvar) - 1;
 	}
 	if (forwardval <= 0) {
 		switch_channel_hangup(channel, SWITCH_CAUSE_EXCHANGE_ROUTING_ERROR);
@@ -981,7 +975,7 @@
 		if (switch_strlen_zero(dialplan)) {
 			dialplan = profile->dialplan;
 		}
-	
+
 		if (switch_strlen_zero(context)) {
 			context = profile->context;
 		}
@@ -989,7 +983,7 @@
 		if (switch_strlen_zero(dialplan)) {
 			dialplan = "XML";
 		}
-	
+
 		if (switch_strlen_zero(context)) {
 			context = "default";
 		}
@@ -997,7 +991,7 @@
 		if (switch_strlen_zero(extension)) {
 			extension = "service";
 		}
-		
+
 		new_profile = switch_caller_profile_clone(session, profile);
 
 		new_profile->dialplan = switch_core_strdup(new_profile->pool, dialplan);
@@ -1015,7 +1009,7 @@
 		if (!uuid) {
 			uuid = switch_channel_get_variable(channel, SWITCH_BRIDGE_VARIABLE);
 		}
-		
+
 		if (uuid && (other_session = switch_core_session_locate(uuid))) {
 			other_channel = switch_core_session_get_channel(other_session);
 			switch_channel_set_variable(other_channel, SWITCH_SIGNAL_BOND_VARIABLE, NULL);
@@ -1028,7 +1022,7 @@
 
 			switch_channel_set_variable(channel, SWITCH_SIGNAL_BRIDGE_VARIABLE, NULL);
 			switch_channel_set_variable(other_channel, SWITCH_SIGNAL_BRIDGE_VARIABLE, NULL);
-			
+
 			switch_channel_set_variable(channel, SWITCH_BRIDGE_VARIABLE, NULL);
 			switch_channel_set_variable(other_channel, SWITCH_BRIDGE_VARIABLE, NULL);
 
@@ -1045,7 +1039,7 @@
 		switch_channel_set_flag(channel, CF_TRANSFER);
 
 		switch_channel_set_state(channel, CS_ROUTING);
-		
+
 		msg.message_id = SWITCH_MESSAGE_INDICATE_TRANSFER;
 		msg.from = __FILE__;
 		switch_core_session_receive_message(session, &msg);
@@ -1108,7 +1102,7 @@
 	switch_time_t last_digit_time;
 };
 
-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)
 {
 	switch_status_t status = SWITCH_STATUS_FALSE;
 
@@ -1148,7 +1142,7 @@
 	return status;
 }
 
-SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_parser_destroy(switch_ivr_digit_stream_parser_t * parser)
+SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_parser_destroy(switch_ivr_digit_stream_parser_t *parser)
 {
 	switch_status_t status = SWITCH_STATUS_FALSE;
 
@@ -1166,7 +1160,7 @@
 	return status;
 }
 
-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)
 {
 	switch_status_t status = SWITCH_STATUS_FALSE;
 
@@ -1182,7 +1176,7 @@
 	return status;
 }
 
-SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_destroy(switch_ivr_digit_stream_t * stream)
+SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_destroy(switch_ivr_digit_stream_t *stream)
 {
 	switch_status_t status = SWITCH_STATUS_FALSE;
 
@@ -1195,7 +1189,7 @@
 	return status;
 }
 
-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)
 {
 	switch_status_t status = SWITCH_STATUS_FALSE;
 
@@ -1231,7 +1225,7 @@
 	return status;
 }
 
-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)
 {
 	switch_status_t status = SWITCH_STATUS_FALSE;
 
@@ -1246,7 +1240,7 @@
 	return status;
 }
 
-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)
 {
 	void *result = NULL;
 
@@ -1297,7 +1291,7 @@
 	return result;
 }
 
-SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_reset(switch_ivr_digit_stream_t * stream)
+SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_reset(switch_ivr_digit_stream_t *stream)
 {
 	switch_status_t status = SWITCH_STATUS_FALSE;
 
@@ -1311,7 +1305,7 @@
 	return status;
 }
 
-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)
 {
 	switch_status_t status = SWITCH_STATUS_FALSE;
 
@@ -1403,13 +1397,14 @@
 	switch_xml_t variable;
 	switch_event_header_t *hi = switch_channel_variable_first(channel);
 
-	if (!hi) return off;
+	if (!hi)
+		return off;
 
 	for (; hi; hi = hi->next) {
 		if (!switch_strlen_zero(hi->name) && !switch_strlen_zero(hi->value) && ((variable = switch_xml_add_child_d(xml, hi->name, off++)))) {
 			char *data;
 			switch_size_t dlen = strlen(hi->value) * 3;
-			
+
 			if ((data = malloc(dlen))) {
 				memset(data, 0, dlen);
 				switch_url_encode(hi->value, data, dlen);
@@ -1423,11 +1418,11 @@
 	return off;
 }
 
-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)
 {
 	switch_channel_t *channel = switch_core_session_get_channel(session);
 	switch_caller_profile_t *caller_profile;
-	switch_xml_t variables, cdr, x_main_cp, x_caller_profile, x_caller_extension, x_times, time_tag, 
+	switch_xml_t variables, cdr, x_main_cp, x_caller_profile, x_caller_extension, x_times, time_tag,
 		x_application, x_callflow, x_inner_extension, x_apps, x_o;
 	switch_app_log_t *app_log;
 	char tmp[512];
@@ -1444,23 +1439,23 @@
 	if ((app_log = switch_core_session_get_app_log(session))) {
 		int app_off = 0;
 		switch_app_log_t *ap;
-		
+
 		if (!(x_apps = switch_xml_add_child_d(cdr, "app_log", cdr_off++))) {
 			goto error;
 		}
-		for(ap = app_log; ap; ap = ap->next) {
+		for (ap = app_log; ap; ap = ap->next) {
 
 			if (!(x_application = switch_xml_add_child_d(x_apps, "application", app_off++))) {
 				goto error;
 			}
-			
+
 			switch_xml_set_attr_d(x_application, "app_name", ap->app);
 			switch_xml_set_attr_d(x_application, "app_data", ap->arg);
 		}
 	}
 
 	switch_ivr_set_xml_chan_vars(variables, channel, v_off);
-	
+
 	caller_profile = switch_channel_get_caller_profile(channel);
 
 	while (caller_profile) {
@@ -1486,7 +1481,7 @@
 			if (!(x_caller_extension = switch_xml_add_child_d(x_callflow, "extension", cf_off++))) {
 				goto error;
 			}
-			
+
 			switch_xml_set_attr_d(x_caller_extension, "name", caller_profile->caller_extension->extension_name);
 			switch_xml_set_attr_d(x_caller_extension, "number", caller_profile->caller_extension->extension_number);
 			if (caller_profile->caller_extension->current_application) {
@@ -1509,13 +1504,13 @@
 				int i_off = 0;
 				for (cp = caller_profile->caller_extension->children; cp; cp = cp->next) {
 					app_off = 0;
-					
+
 					if (!cp->caller_extension) {
 						continue;
 					}
 					if (!(x_inner_extension = switch_xml_add_child_d(x_caller_extension, "sub_extensions", i_off++))) {
 						goto error;
-					}				
+					}
 
 					if (!(x_caller_extension = switch_xml_add_child_d(x_inner_extension, "extension", cf_off++))) {
 						goto error;
@@ -1526,7 +1521,7 @@
 					if (cp->caller_extension->current_application) {
 						switch_xml_set_attr_d(x_caller_extension, "current_app", cp->caller_extension->current_application->application_name);
 					}
-				
+
 					for (ap = cp->caller_extension->applications; ap; ap = ap->next) {
 						if (!(x_application = switch_xml_add_child_d(x_caller_extension, "application", app_off++))) {
 							goto error;
@@ -1675,7 +1670,7 @@
 
 	write_frame.codec = read_codec;
 
-	while(switch_channel_ready(channel)) {
+	while (switch_channel_ready(channel)) {
 		status = switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
 		if (!SWITCH_READ_ACCEPTABLE(status)) {
 			break;
@@ -1686,7 +1681,7 @@
 
 		if ((jb_frame = stfu_n_read_a_frame(jb))) {
 			write_frame.data = jb_frame->data;
-			write_frame.datalen = (uint32_t)jb_frame->dlen;
+			write_frame.datalen = (uint32_t) jb_frame->dlen;
 			status = switch_core_session_write_frame(session, &write_frame, SWITCH_IO_FLAG_NONE, 0);
 			if (!SWITCH_READ_ACCEPTABLE(status)) {
 				break;
@@ -1697,14 +1692,15 @@
 	stfu_n_destroy(&jb);
 }
 
-SWITCH_DECLARE(switch_status_t) switch_ivr_say(switch_core_session_t *session, const char *tosay, const char *module_name, const char *say_type, const char *say_method, switch_input_args_t *args)
+SWITCH_DECLARE(switch_status_t) switch_ivr_say(switch_core_session_t *session, const char *tosay, const char *module_name, const char *say_type,
+											   const char *say_method, switch_input_args_t *args)
 {
 	switch_say_interface_t *si;
 	switch_status_t status = SWITCH_STATUS_SUCCESS;
 
 	if ((si = switch_loadable_module_get_say_interface(module_name))) {
 		// should go back and proto all the say mods to const....
-		status = si->say_function(session, (char *)tosay, switch_ivr_get_say_type_by_name(say_type), switch_ivr_get_say_method_by_name(say_method), args);
+		status = si->say_function(session, (char *) tosay, switch_ivr_get_say_type_by_name(say_type), switch_ivr_get_say_method_by_name(say_method), args);
 	} else {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid SAY Interface [%s]!\n", module_name);
 		status = SWITCH_STATUS_FALSE;

Modified: freeswitch/trunk/src/switch_ivr_async.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr_async.c	(original)
+++ freeswitch/trunk/src/switch_ivr_async.c	Tue May 27 00:30:03 2008
@@ -47,20 +47,20 @@
 	switch_status_t status;
 	switch_frame_t *read_frame;
 
-	eh->up = 1;	
-	while(switch_channel_ready(channel)) {
+	eh->up = 1;
+	while (switch_channel_ready(channel)) {
 		status = switch_core_session_read_video_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
-        
+
 		if (!SWITCH_READ_ACCEPTABLE(status)) {
 			break;
 		}
-		
+
 		if (switch_test_flag(read_frame, SFF_CNG)) {
 			continue;
 		}
 
 		switch_core_session_write_video_frame(session, read_frame, SWITCH_IO_FLAG_NONE, 0);
-		
+
 	}
 	eh->up = 0;
 	return NULL;
@@ -73,13 +73,13 @@
 	switch_frame_t *read_frame;
 	switch_channel_t *channel = switch_core_session_get_channel(session);
 #ifdef SWITCH_VIDEO_IN_THREADS
-	struct echo_helper eh = {0};
+	struct echo_helper eh = { 0 };
 	switch_thread_t *thread;
 	switch_threadattr_t *thd_attr = NULL;
 #endif
 
 	switch_channel_pre_answer(channel);
-	
+
 #ifdef SWITCH_VIDEO_IN_THREADS
 	if (switch_channel_test_flag(channel, CF_VIDEO)) {
 		eh.session = session;
@@ -90,7 +90,7 @@
 	}
 #endif
 
-	while(switch_channel_ready(channel)) {
+	while (switch_channel_ready(channel)) {
 		status = switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
 		if (!SWITCH_READ_ACCEPTABLE(status)) {
 			break;
@@ -99,11 +99,11 @@
 
 #ifndef SWITCH_VIDEO_IN_THREADS
 		status = switch_core_session_read_video_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
-        
+
 		if (!SWITCH_READ_ACCEPTABLE(status)) {
 			break;
 		}
-		
+
 		if (switch_test_flag(read_frame, SFF_CNG)) {
 			continue;
 		}
@@ -115,7 +115,7 @@
 
 #ifdef SWITCH_VIDEO_IN_THREADS
 	if (eh.up) {
-		while(eh.up) {
+		while (eh.up) {
 			switch_yield(1000);
 		}
 	}
@@ -165,8 +165,8 @@
 				uint32_t x;
 
 				st = switch_core_file_read(&dh->fh, buf, &len);
-				
-				for(x = 0; x < (uint32_t) len; x++) {
+
+				for (x = 0; x < (uint32_t) len; x++) {
 					int32_t mixed = fp[x] + buf[x];
 					switch_normalize_to_16bit(mixed);
 					fp[x] = (int16_t) mixed;
@@ -232,8 +232,8 @@
 				uint32_t x;
 
 				st = switch_core_file_read(&dh->fh, buf, &len);
-				
-				for(x = 0; x < (uint32_t) len; x++) {
+
+				for (x = 0; x < (uint32_t) len; x++) {
 					int32_t mixed = fp[x] + buf[x];
 					switch_normalize_to_16bit(mixed);
 					fp[x] = (int16_t) mixed;
@@ -296,19 +296,18 @@
 		return SWITCH_STATUS_MEMERR;
 	}
 
-	
+
 	read_codec = switch_core_session_get_read_codec(session);
 	switch_assert(read_codec != NULL);
 
 	dh->fh.channels = read_codec->implementation->number_of_channels;
 	dh->fh.samplerate = read_codec->implementation->actual_samples_per_second;
-	
+
 	if (switch_core_file_open(&dh->fh,
 							  file,
 							  read_codec->implementation->number_of_channels,
 							  read_codec->implementation->actual_samples_per_second,
-							  SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT,
-							  NULL) != SWITCH_STATUS_SUCCESS) {
+							  SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL) != SWITCH_STATUS_SUCCESS) {
 		switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 		switch_core_session_reset(session, SWITCH_TRUE);
 		return SWITCH_STATUS_GENERR;
@@ -327,13 +326,13 @@
 	if (flags && strchr(flags, 'l')) {
 		dh->loop++;
 	}
-	
+
 	if (flags && strchr(flags, 'r')) {
 		status = switch_core_media_bug_add(session, read_displace_callback, dh, to, SMBF_WRITE_REPLACE | SMBF_READ_REPLACE, &bug);
 	} else {
 		status = switch_core_media_bug_add(session, write_displace_callback, dh, to, SMBF_WRITE_REPLACE | SMBF_READ_REPLACE, &bug);
 	}
-	
+
 	if (status != SWITCH_STATUS_SUCCESS) {
 		switch_core_file_close(&dh->fh);
 		return status;
@@ -416,7 +415,7 @@
 	struct eavesdrop_pvt *ep = (struct eavesdrop_pvt *) user_data;
 	uint8_t data[SWITCH_RECOMMENDED_BUFFER_SIZE];
 	switch_frame_t frame = { 0 };
-	
+
 	frame.data = data;
 	frame.buflen = SWITCH_RECOMMENDED_BUFFER_SIZE;
 
@@ -430,13 +429,13 @@
 	case SWITCH_ABC_TYPE_READ_PING:
 		if (ep->buffer) {
 			if (switch_core_media_bug_read(bug, &frame) == SWITCH_STATUS_SUCCESS) {
-                switch_buffer_lock(ep->buffer);
+				switch_buffer_lock(ep->buffer);
 				switch_buffer_zwrite(ep->buffer, frame.data, frame.datalen);
-                switch_buffer_unlock(ep->buffer);
+				switch_buffer_unlock(ep->buffer);
 			}
 		} else {
-            return SWITCH_FALSE;
-        }
+			return SWITCH_FALSE;
+		}
 		break;
 	case SWITCH_ABC_TYPE_READ:
 		break;
@@ -446,15 +445,15 @@
 
 			if (switch_test_flag(ep, ED_MUX_READ)) {
 				switch_frame_t *rframe = switch_core_media_bug_get_read_replace_frame(bug);
-			
+
 				if (switch_buffer_inuse(ep->r_buffer) >= rframe->datalen) {
 					uint32_t bytes;
 					switch_buffer_lock(ep->r_buffer);
 					bytes = (uint32_t) switch_buffer_read(ep->r_buffer, data, rframe->datalen);
-			
-					rframe->datalen = switch_merge_sln(rframe->data, rframe->samples, (int16_t *)data, bytes / 2) * 2;
+
+					rframe->datalen = switch_merge_sln(rframe->data, rframe->samples, (int16_t *) data, bytes / 2) * 2;
 					rframe->samples = rframe->datalen / 2;
-				
+
 					switch_buffer_unlock(ep->r_buffer);
 					switch_core_media_bug_set_read_replace_frame(bug, rframe);
 				}
@@ -466,15 +465,15 @@
 		{
 			if (switch_test_flag(ep, ED_MUX_WRITE)) {
 				switch_frame_t *rframe = switch_core_media_bug_get_write_replace_frame(bug);
-			
+
 				if (switch_buffer_inuse(ep->w_buffer) >= rframe->datalen) {
 					uint32_t bytes;
 					switch_buffer_lock(ep->w_buffer);
 					bytes = (uint32_t) switch_buffer_read(ep->w_buffer, data, rframe->datalen);
-			
-					rframe->datalen = switch_merge_sln(rframe->data, rframe->samples, (int16_t *)data, bytes / 2) * 2;
+
+					rframe->datalen = switch_merge_sln(rframe->data, rframe->samples, (int16_t *) data, bytes / 2) * 2;
 					rframe->samples = rframe->datalen / 2;
-				
+
 					switch_buffer_unlock(ep->w_buffer);
 					switch_core_media_bug_set_write_replace_frame(bug, rframe);
 				}
@@ -489,10 +488,8 @@
 	return SWITCH_TRUE;
 }
 
-SWITCH_DECLARE(switch_status_t) switch_ivr_eavesdrop_session(switch_core_session_t *session, 
-															 const char *uuid, 
-															 const char *require_group, 
-															 switch_eavesdrop_flag_t flags)
+SWITCH_DECLARE(switch_status_t) switch_ivr_eavesdrop_session(switch_core_session_t *session,
+															 const char *uuid, const char *require_group, switch_eavesdrop_flag_t flags)
 {
 	switch_core_session_t *tsession;
 	switch_status_t status = SWITCH_STATUS_FALSE;
@@ -504,8 +501,8 @@
 		switch_media_bug_t *bug = NULL;
 		switch_channel_t *tchannel = switch_core_session_get_channel(tsession);
 		switch_frame_t *read_frame, write_frame = { 0 };
-		switch_codec_t codec = {0};
-		int16_t buf[SWITCH_RECOMMENDED_BUFFER_SIZE/2];
+		switch_codec_t codec = { 0 };
+		int16_t buf[SWITCH_RECOMMENDED_BUFFER_SIZE / 2];
 		switch_codec_t *tread_codec = switch_core_session_get_read_codec(tsession);
 		uint32_t tlen;
 		const char *macro_name = "eavesdrop_announce";
@@ -530,39 +527,39 @@
 
 
 		if (!switch_strlen_zero(require_group)) {
-			const char *group_name = switch_channel_get_variable(tchannel, "eavesdrop_group");			
+			const char *group_name = switch_channel_get_variable(tchannel, "eavesdrop_group");
 			if (!group_name || strcmp(group_name, require_group)) {
 				status = SWITCH_STATUS_BREAK;
 				goto end;
 			}
 		}
 
-		
+
 		ep = switch_core_session_alloc(session, sizeof(*ep));
 
 		tlen = tread_codec->implementation->bytes_per_frame;
 
 		switch_channel_pre_answer(channel);
-		
+
 		if (switch_core_codec_init(&codec,
 								   "L16",
-								   NULL, 
+								   NULL,
 								   tread_codec->implementation->actual_samples_per_second,
 								   tread_codec->implementation->microseconds_per_frame / 1000,
-								   tread_codec->implementation->number_of_channels, 
-								   SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, 
+								   tread_codec->implementation->number_of_channels,
+								   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, "Cannot init codec\n");
 			switch_core_session_rwunlock(tsession);
 			goto end;
 		}
-		
+
 		switch_core_session_set_read_codec(session, &codec);
 		write_frame.codec = &codec;
 		write_frame.data = buf;
 		write_frame.buflen = sizeof(buf);
 		write_frame.rate = read_codec->implementation->actual_samples_per_second;
-		
+
 		ep->flags = flags;
 		switch_mutex_init(&ep->mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(tsession));
 		switch_buffer_create_dynamic(&ep->buffer, 2048, 2048, 8192);
@@ -576,22 +573,22 @@
 		switch_buffer_create_dynamic(&ep->r_buffer, 2048, 2048, 8192);
 		switch_buffer_add_mutex(ep->r_buffer, ep->r_mutex);
 
-		
-		if (switch_core_media_bug_add(tsession, eavesdrop_callback, ep, 0, 
+
+		if (switch_core_media_bug_add(tsession, eavesdrop_callback, ep, 0,
 									  SMBF_READ_STREAM | SMBF_WRITE_STREAM | SMBF_READ_REPLACE | SMBF_WRITE_REPLACE | SMBF_READ_PING | SMBF_THREAD_LOCK,
 									  &bug) != SWITCH_STATUS_SUCCESS) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot attach bug\n");
 			goto end;
 		}
-		
-        while(switch_channel_ready(tchannel) && switch_channel_ready(channel)) {
+
+		while (switch_channel_ready(tchannel) && switch_channel_ready(channel)) {
 			uint32_t len = sizeof(buf);
 			switch_event_t *event = NULL;
 			char *fcommand = NULL;
 			char db[2] = "";
 
 			status = switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
-			
+
 			if (!SWITCH_READ_ACCEPTABLE(status)) {
 				goto end;
 			}
@@ -605,7 +602,7 @@
 			}
 
 			if ((flags & ED_DTMF) && switch_channel_has_dtmf(channel)) {
-				switch_dtmf_t dtmf = {0};
+				switch_dtmf_t dtmf = { 0 };
 				switch_channel_dequeue_dtmf(channel, &dtmf);
 				db[0] = dtmf.digit;
 				fcommand = db;
@@ -613,9 +610,9 @@
 
 			if (fcommand) {
 				char *d;
-				for(d = fcommand; *d; d++) {
+				for (d = fcommand; *d; d++) {
 					int z = 1;
-					
+
 					switch (*d) {
 					case '1':
 						switch_set_flag(ep, ED_MUX_READ);
@@ -640,14 +637,14 @@
 						break;
 
 					}
-					
+
 					if (z) {
 						if (ep->r_buffer) {
 							switch_buffer_lock(ep->r_buffer);
 							switch_buffer_zero(ep->r_buffer);
 							switch_buffer_unlock(ep->r_buffer);
 						}
-						
+
 						if (ep->w_buffer) {
 							switch_buffer_lock(ep->w_buffer);
 							switch_buffer_zero(ep->w_buffer);
@@ -671,49 +668,49 @@
 				len = tlen;
 			}
 
-            if (switch_buffer_inuse(ep->buffer) >= len) {
-                switch_buffer_lock(ep->buffer);				
+			if (switch_buffer_inuse(ep->buffer) >= len) {
+				switch_buffer_lock(ep->buffer);
 				while (switch_buffer_inuse(ep->buffer) >= len) {
-					write_frame.datalen = (uint32_t)switch_buffer_read(ep->buffer, buf, len);
+					write_frame.datalen = (uint32_t) switch_buffer_read(ep->buffer, buf, len);
 					write_frame.samples = write_frame.datalen / 2;
 					if ((status = switch_core_session_write_frame(session, &write_frame, SWITCH_IO_FLAG_NONE, 0)) != SWITCH_STATUS_SUCCESS) {
 						break;
 					}
 				}
-                switch_buffer_unlock(ep->buffer);
-            }
-			
-        }
+				switch_buffer_unlock(ep->buffer);
+			}
+
+		}
 
-    end:
+	  end:
 
 		switch_core_codec_destroy(&codec);
 
-        if (bug) {
-            switch_core_media_bug_remove(tsession, &bug);
-        }
+		if (bug) {
+			switch_core_media_bug_remove(tsession, &bug);
+		}
 
 		if (ep) {
 			if (ep->buffer) {
 				switch_buffer_destroy(&ep->buffer);
 			}
-			
+
 			if (ep->r_buffer) {
 				switch_buffer_destroy(&ep->r_buffer);
 			}
-			
+
 			if (ep->w_buffer) {
 				switch_buffer_destroy(&ep->w_buffer);
 			}
 		}
 
-        switch_core_session_rwunlock(tsession);
+		switch_core_session_rwunlock(tsession);
 		status = SWITCH_STATUS_SUCCESS;
 
 		switch_core_session_set_read_codec(session, read_codec);
 		switch_core_session_reset(session, SWITCH_TRUE);
-    }
-	
+	}
+
 	return status;
 }
 
@@ -747,7 +744,7 @@
 	if ((p = switch_channel_get_variable(channel, "RECORD_ANSWER_REQ")) && switch_true(p)) {
 		flags |= SMBF_RECORD_ANSWER_REQ;
 	}
-	
+
 	fh->channels = channels;
 	fh->samplerate = read_codec->implementation->actual_samples_per_second;
 
@@ -803,7 +800,7 @@
 	if (limit) {
 		to = switch_timestamp(NULL) + limit;
 	}
-	
+
 	if ((status = switch_core_media_bug_add(session, record_callback, fh, to, flags, &bug)) != SWITCH_STATUS_SUCCESS) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error adding media bug for file %s\n", file);
 		switch_core_file_close(fh);
@@ -842,7 +839,7 @@
 			teletone_dtmf_get(&pvt->dtmf_detect, digit_str, sizeof(digit_str));
 			if (digit_str[0]) {
 				char *p = digit_str;
-				while(p && *p) {
+				while (p && *p) {
 					switch_dtmf_t dtmf;
 					dtmf.digit = *p;
 					dtmf.duration = switch_core_default_dtmf_duration(0);
@@ -907,37 +904,37 @@
 	switch_core_session_t *session;
 	teletone_generation_session_t ts;
 	switch_queue_t *digit_queue;
-    switch_buffer_t *audio_buffer;
+	switch_buffer_t *audio_buffer;
 	switch_mutex_t *mutex;
 	int read;
 	int ready;
 } switch_inband_dtmf_generate_t;
 
-static int teletone_dtmf_generate_handler(teletone_generation_session_t * ts, teletone_tone_map_t * map)
+static int teletone_dtmf_generate_handler(teletone_generation_session_t *ts, teletone_tone_map_t *map)
 {
-    switch_buffer_t *audio_buffer = ts->user_data;
-    int wrote;
+	switch_buffer_t *audio_buffer = ts->user_data;
+	int wrote;
 
-    if (!audio_buffer) {
-        return -1;
-    }
+	if (!audio_buffer) {
+		return -1;
+	}
 
-    wrote = teletone_mux_tones(ts, map);
-    switch_buffer_write(audio_buffer, ts->buffer, wrote * 2);
+	wrote = teletone_mux_tones(ts, map);
+	switch_buffer_write(audio_buffer, ts->buffer, wrote * 2);
 
-    return 0;
+	return 0;
 }
 
 static switch_status_t generate_on_dtmf(switch_core_session_t *session, const switch_dtmf_t *dtmf, switch_dtmf_direction_t direction)
 {
-    switch_channel_t *channel = switch_core_session_get_channel(session);
-    switch_media_bug_t *bug = switch_channel_get_private(channel, "dtmf_generate");
+	switch_channel_t *channel = switch_core_session_get_channel(session);
+	switch_media_bug_t *bug = switch_channel_get_private(channel, "dtmf_generate");
 	switch_status_t status = SWITCH_STATUS_SUCCESS;
 
-    if (bug) {
-        switch_inband_dtmf_generate_t *pvt = (switch_inband_dtmf_generate_t *) switch_core_media_bug_get_user_data(bug);
-        
-        if (pvt) {
+	if (bug) {
+		switch_inband_dtmf_generate_t *pvt = (switch_inband_dtmf_generate_t *) switch_core_media_bug_get_user_data(bug);
+
+		if (pvt) {
 			switch_mutex_lock(pvt->mutex);
 			if (pvt->ready) {
 				switch_dtmf_t *dt = NULL;
@@ -948,7 +945,7 @@
 					/* 
 					   SWITCH_STATUS_FALSE indicates pretend there never was a DTMF
 					   since we will be generating it inband now.
-					*/
+					 */
 					status = SWITCH_STATUS_FALSE;
 				} else {
 					free(dt);
@@ -1005,7 +1002,7 @@
 
 			if (!pvt->ready) {
 				switch_mutex_unlock(pvt->mutex);
-                return SWITCH_FALSE;
+				return SWITCH_FALSE;
 			}
 
 			if (pvt->read) {
@@ -1013,7 +1010,7 @@
 			} else {
 				frame = switch_core_media_bug_get_write_replace_frame(bug);
 			}
-			
+
 			while (switch_queue_trypop(pvt->digit_queue, &pop) == SWITCH_STATUS_SUCCESS) {
 				switch_dtmf_t *dtmf = (switch_dtmf_t *) pop;
 				char buf[2] = "";
@@ -1022,13 +1019,13 @@
 				buf[0] = dtmf->digit;
 				if (duration > 8000) {
 					duration = 4000;
-					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "%s Truncating ridiculous DTMF duration %d ms to 1/2 second.\n", 
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "%s Truncating ridiculous DTMF duration %d ms to 1/2 second.\n",
 									  switch_channel_get_name(switch_core_session_get_channel(pvt->session)), dtmf->duration / 8);
 				}
 				pvt->ts.duration = duration;
 				teletone_run(&pvt->ts, buf);
 			}
-			
+
 			if (switch_buffer_inuse(pvt->audio_buffer) && (bytes = switch_buffer_read(pvt->audio_buffer, frame->data, frame->datalen))) {
 				if (bytes < frame->datalen) {
 					switch_byte_t *dp = frame->data;
@@ -1087,7 +1084,7 @@
 	pvt->session = session;
 	pvt->read = !!read_stream;
 
-	if ((status = switch_core_media_bug_add(session, inband_dtmf_generate_callback, pvt, 0, 
+	if ((status = switch_core_media_bug_add(session, inband_dtmf_generate_callback, pvt, 0,
 											pvt->read ? SMBF_READ_REPLACE : SMBF_WRITE_REPLACE, &bug)) != SWITCH_STATUS_SUCCESS) {
 		return status;
 	}
@@ -1108,7 +1105,7 @@
 } switch_tone_detect_t;
 
 typedef struct {
-	switch_tone_detect_t list[MAX_TONES+1];
+	switch_tone_detect_t list[MAX_TONES + 1];
 	int index;
 	switch_media_bug_t *bug;
 	switch_core_session_t *session;
@@ -1133,11 +1130,11 @@
 			if (!frame) {
 				frame = switch_core_media_bug_get_write_replace_frame(bug);
 			}
-			
-			for (i = 0 ; i < cont->index; i++) {
+
+			for (i = 0; i < cont->index; i++) {
 				if (cont->list[i].up && teletone_multi_tone_detect(&cont->list[i].mt, frame->data, frame->samples)) {
 					switch_event_t *event;
-					
+
 					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "TONE %s DETECTED\n", cont->list[i].key);
 					cont->list[i].up = 0;
 
@@ -1154,11 +1151,11 @@
 					if (switch_event_create(&event, SWITCH_EVENT_DETECTED_TONE) == SWITCH_STATUS_SUCCESS) {
 						switch_event_t *dup;
 						switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Detected-Tone", "%s", cont->list[i].key);
-						
+
 						if (switch_event_dup(&dup, event) == SWITCH_STATUS_SUCCESS) {
 							switch_event_fire(&dup);
 						}
-	    
+
 						if (switch_core_session_queue_event(cont->session, &event) != SWITCH_STATUS_SUCCESS) {
 							switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Event queue failed!\n");
 							switch_event_add_header(event, SWITCH_STACK_BOTTOM, "delivery-failure", "true");
@@ -1180,7 +1177,7 @@
 {
 	switch_channel_t *channel = switch_core_session_get_channel(session);
 	switch_tone_container_t *cont = switch_channel_get_private(channel, "_tone_detect_");
-	
+
 	if (cont) {
 		switch_channel_set_private(channel, "_tone_detect_", NULL);
 		switch_core_media_bug_remove(session, &cont->bug);
@@ -1189,110 +1186,110 @@
 	return SWITCH_STATUS_FALSE;
 }
 
-SWITCH_DECLARE(switch_status_t) switch_ivr_tone_detect_session(switch_core_session_t *session, 
+SWITCH_DECLARE(switch_status_t) switch_ivr_tone_detect_session(switch_core_session_t *session,
 															   const char *key, const char *tone_spec,
-															   const char *flags, time_t timeout,
-															   const char *app, const char *data)
+															   const char *flags, time_t timeout, const char *app, const char *data)
 {
-  switch_channel_t *channel = switch_core_session_get_channel(session);
-  switch_codec_t *read_codec = switch_core_session_get_read_codec(session);
-  switch_status_t status;
-  switch_tone_container_t *cont = switch_channel_get_private(channel, "_tone_detect_");
-  char *p, *next;
-  int i = 0, ok = 0;
-  switch_media_bug_flag_t bflags = 0;
-
-  switch_assert(read_codec != NULL);
-  
-  if (switch_strlen_zero(key)) {
-	  switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No Key Specified!\n");
-	  return SWITCH_STATUS_FALSE;
-  }
-  
-  if (cont) {
-	  if (cont->index >= MAX_TONES) {
-		  switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Max Tones Reached!\n");
-		  return SWITCH_STATUS_FALSE;
-	  }
-
-	  for(i = 0; i < cont->index; i++) {
-		  if (!switch_strlen_zero(cont->list[cont->index].key) && !strcasecmp(key, cont->list[cont->index].key)) {
-			  switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Re-enabling %s\n", key);
-			  cont->list[cont->index].up = 1;
-			  teletone_multi_tone_init(&cont->list[i].mt, &cont->list[i].map);
-			  return SWITCH_STATUS_SUCCESS;
-		  }
-	  }
-  }
-
-  if (switch_strlen_zero(tone_spec)) {
-	  switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No Spec Specified!\n");
-	  return SWITCH_STATUS_FALSE;
-  }
-
-  if (!cont && !(cont = switch_core_session_alloc(session, sizeof(*cont)))) {
-	  return SWITCH_STATUS_MEMERR;
-  }
-
-  switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Adding tone spec %s index %d\n", tone_spec, cont->index);
-
-  i = 0;
-  p = (char *) tone_spec;
-
-  do {
-	  teletone_process_t this;
-	  next = strchr(p, ',');
-	  while(*p == ' ') p++;
-	  if ((this = (teletone_process_t) atof(p))) {
-		  ok++;
-		  cont->list[cont->index].map.freqs[i++] = this;
-	  }
-	  if (next) {
-		  p = next + 1;
-	  }
-  } while (next);
-  cont->list[cont->index].map.freqs[i++] = 0;
-
-  if (!ok) {
-	  switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid tone spec!\n");
-	  return SWITCH_STATUS_FALSE;
-  }
-
-  cont->list[cont->index].key = switch_core_session_strdup(session, key);
-
-  if (app) {
-	  cont->list[cont->index].app = switch_core_session_strdup(session, app);
-  }
-  
-  if (data) {
-	  cont->list[cont->index].data = switch_core_session_strdup(session, data);
-  }
-
-  cont->list[cont->index].up = 1;
-  cont->list[cont->index].mt.sample_rate = read_codec->implementation->actual_samples_per_second;
-  teletone_multi_tone_init(&cont->list[cont->index].mt, &cont->list[cont->index].map);
-  cont->session = session;
-  
-  switch_channel_pre_answer(channel);
-  
-  if (switch_strlen_zero(flags)) {
-	  bflags = SMBF_READ_REPLACE;
-  } else {
-	  if (strchr(flags, 'r')) {
-		  bflags |= SMBF_READ_REPLACE;
-	  } else if (strchr(flags, 'w')) {
-		  bflags |= SMBF_WRITE_REPLACE;
-	  }
-  }
-
-  if ((status = switch_core_media_bug_add(session, tone_detect_callback, cont, timeout, bflags, &cont->bug)) != SWITCH_STATUS_SUCCESS) {
-	  return status;
-  }
-
-  switch_channel_set_private(channel, "_tone_detect_", cont);
-  cont->index++;
-  
-  return SWITCH_STATUS_SUCCESS;
+	switch_channel_t *channel = switch_core_session_get_channel(session);
+	switch_codec_t *read_codec = switch_core_session_get_read_codec(session);
+	switch_status_t status;
+	switch_tone_container_t *cont = switch_channel_get_private(channel, "_tone_detect_");
+	char *p, *next;
+	int i = 0, ok = 0;
+	switch_media_bug_flag_t bflags = 0;
+
+	switch_assert(read_codec != NULL);
+
+	if (switch_strlen_zero(key)) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No Key Specified!\n");
+		return SWITCH_STATUS_FALSE;
+	}
+
+	if (cont) {
+		if (cont->index >= MAX_TONES) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Max Tones Reached!\n");
+			return SWITCH_STATUS_FALSE;
+		}
+
+		for (i = 0; i < cont->index; i++) {
+			if (!switch_strlen_zero(cont->list[cont->index].key) && !strcasecmp(key, cont->list[cont->index].key)) {
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Re-enabling %s\n", key);
+				cont->list[cont->index].up = 1;
+				teletone_multi_tone_init(&cont->list[i].mt, &cont->list[i].map);
+				return SWITCH_STATUS_SUCCESS;
+			}
+		}
+	}
+
+	if (switch_strlen_zero(tone_spec)) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No Spec Specified!\n");
+		return SWITCH_STATUS_FALSE;
+	}
+
+	if (!cont && !(cont = switch_core_session_alloc(session, sizeof(*cont)))) {
+		return SWITCH_STATUS_MEMERR;
+	}
+
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Adding tone spec %s index %d\n", tone_spec, cont->index);
+
+	i = 0;
+	p = (char *) tone_spec;
+
+	do {
+		teletone_process_t this;
+		next = strchr(p, ',');
+		while (*p == ' ')
+			p++;
+		if ((this = (teletone_process_t) atof(p))) {
+			ok++;
+			cont->list[cont->index].map.freqs[i++] = this;
+		}
+		if (next) {
+			p = next + 1;
+		}
+	} while (next);
+	cont->list[cont->index].map.freqs[i++] = 0;
+
+	if (!ok) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid tone spec!\n");
+		return SWITCH_STATUS_FALSE;
+	}
+
+	cont->list[cont->index].key = switch_core_session_strdup(session, key);
+
+	if (app) {
+		cont->list[cont->index].app = switch_core_session_strdup(session, app);
+	}
+
+	if (data) {
+		cont->list[cont->index].data = switch_core_session_strdup(session, data);
+	}
+
+	cont->list[cont->index].up = 1;
+	cont->list[cont->index].mt.sample_rate = read_codec->implementation->actual_samples_per_second;
+	teletone_multi_tone_init(&cont->list[cont->index].mt, &cont->list[cont->index].map);
+	cont->session = session;
+
+	switch_channel_pre_answer(channel);
+
+	if (switch_strlen_zero(flags)) {
+		bflags = SMBF_READ_REPLACE;
+	} else {
+		if (strchr(flags, 'r')) {
+			bflags |= SMBF_READ_REPLACE;
+		} else if (strchr(flags, 'w')) {
+			bflags |= SMBF_WRITE_REPLACE;
+		}
+	}
+
+	if ((status = switch_core_media_bug_add(session, tone_detect_callback, cont, timeout, bflags, &cont->bug)) != SWITCH_STATUS_SUCCESS) {
+		return status;
+	}
+
+	switch_channel_set_private(channel, "_tone_detect_", cont);
+	cont->index++;
+
+	return SWITCH_STATUS_SUCCESS;
 }
 
 typedef struct {
@@ -1304,7 +1301,7 @@
 typedef struct {
 	dtmf_meta_app_t map[10];
 	time_t last_digit;
-	switch_bool_t meta_on;	
+	switch_bool_t meta_on;
 	int up;
 } dtmf_meta_settings_t;
 
@@ -1321,19 +1318,19 @@
 	time_t now = switch_timestamp(NULL);
 	char digit[2] = "";
 	int dval;
-	
+
 	if (!md || switch_channel_test_flag(channel, CF_INNER_BRIDGE)) {
 		return SWITCH_STATUS_SUCCESS;
 	}
 
-	if (direction == SWITCH_DTMF_RECV && !md->sr[SWITCH_DTMF_RECV].up) { 
+	if (direction == SWITCH_DTMF_RECV && !md->sr[SWITCH_DTMF_RECV].up) {
 		return SWITCH_STATUS_SUCCESS;
 	}
 
-	if (direction == SWITCH_DTMF_SEND && !md->sr[SWITCH_DTMF_SEND].up) { 
+	if (direction == SWITCH_DTMF_SEND && !md->sr[SWITCH_DTMF_SEND].up) {
 		return SWITCH_STATUS_SUCCESS;
 	}
-	
+
 	if (md->sr[direction].meta_on && now - md->sr[direction].last_digit > 5) {
 		md->sr[direction].meta_on = SWITCH_FALSE;
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%s Meta digit timeout parsing %c\n", switch_channel_get_name(channel), dtmf->digit);
@@ -1358,9 +1355,9 @@
 			*digit = dtmf->digit;
 			dval = atoi(digit);
 
-			if (direction == SWITCH_DTMF_RECV && (md->sr[direction].map[dval].bind_flags & SBF_DIAL_ALEG)) { 
+			if (direction == SWITCH_DTMF_RECV && (md->sr[direction].map[dval].bind_flags & SBF_DIAL_ALEG)) {
 				ok = 1;
-			} else if (direction == SWITCH_DTMF_SEND && (md->sr[direction].map[dval].bind_flags & SBF_DIAL_BLEG)) { 
+			} else if (direction == SWITCH_DTMF_SEND && (md->sr[direction].map[dval].bind_flags & SBF_DIAL_BLEG)) {
 				ok = 1;
 			}
 
@@ -1387,41 +1384,41 @@
 					flags |= SMF_ECHO_ALEG;
 				}
 
-				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s Processing meta digit '%c' [%s]\n", 
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s Processing meta digit '%c' [%s]\n",
 								  switch_channel_get_name(channel), dtmf->digit, md->sr[direction].map[dval].app);
 				switch_ivr_broadcast(switch_core_session_get_uuid(session), md->sr[direction].map[dval].app, flags);
 			} else {
-				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "%s Ignoring meta digit '%c' not mapped\n", 
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "%s Ignoring meta digit '%c' not mapped\n",
 								  switch_channel_get_name(channel), dtmf->digit);
-								  
+
 			}
 		}
 		md->sr[direction].meta_on = SWITCH_FALSE;
 		return SWITCH_STATUS_FALSE;
 	}
 
-	return SWITCH_STATUS_SUCCESS;	
+	return SWITCH_STATUS_SUCCESS;
 }
 
 SWITCH_DECLARE(switch_status_t) switch_ivr_unbind_dtmf_meta_session(switch_core_session_t *session)
 {
 	switch_channel_t *channel = switch_core_session_get_channel(session);
-    switch_channel_set_private(channel, SWITCH_META_VAR_KEY, NULL);
+	switch_channel_set_private(channel, SWITCH_META_VAR_KEY, NULL);
 
 	return SWITCH_STATUS_SUCCESS;
 }
 
-SWITCH_DECLARE(switch_status_t) switch_ivr_bind_dtmf_meta_session(switch_core_session_t *session, uint32_t key, 
+SWITCH_DECLARE(switch_status_t) switch_ivr_bind_dtmf_meta_session(switch_core_session_t *session, uint32_t key,
 																  switch_bind_flag_t bind_flags, const char *app)
 {
 	switch_channel_t *channel = switch_core_session_get_channel(session);
 	dtmf_meta_data_t *md = switch_channel_get_private(channel, SWITCH_META_VAR_KEY);
-	
+
 	if (key > 9) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid key %u\n", key);
 		return SWITCH_STATUS_FALSE;
 	}
-	
+
 	if (!md) {
 		md = switch_core_session_alloc(session, sizeof(*md));
 		switch_channel_set_private(channel, SWITCH_META_VAR_KEY, md);
@@ -1435,7 +1432,7 @@
 			md->sr[SWITCH_DTMF_RECV].map[key].app = switch_core_session_strdup(session, app);
 			md->sr[SWITCH_DTMF_RECV].map[key].flags |= SMF_HOLD_BLEG;
 			md->sr[SWITCH_DTMF_RECV].map[key].bind_flags = bind_flags;
-		
+
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Bound A-Leg: %d %s\n", key, app);
 		}
 		if ((bind_flags & SBF_DIAL_BLEG)) {
@@ -1445,7 +1442,7 @@
 			md->sr[SWITCH_DTMF_SEND].map[key].bind_flags = bind_flags;
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Bound B-Leg: %d %s\n", key, app);
 		}
-		
+
 	} else {
 		if ((bind_flags & SBF_DIAL_ALEG)) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "UnBound A-Leg: %d\n", key);
@@ -1470,7 +1467,7 @@
 	switch_memory_pool_t *pool;
 };
 
-static void *SWITCH_THREAD_FUNC speech_thread(switch_thread_t * thread, void *obj)
+static void *SWITCH_THREAD_FUNC speech_thread(switch_thread_t *thread, void *obj)
 {
 	struct speech_thread_handle *sth = (struct speech_thread_handle *) obj;
 	switch_channel_t *channel = switch_core_session_get_channel(sth->session);
@@ -1659,10 +1656,7 @@
 
 SWITCH_DECLARE(switch_status_t) switch_ivr_detect_speech(switch_core_session_t *session,
 														 const char *mod_name,
-														 const char *grammar,
-														 const char *path,
-														 const char *dest,
-														 switch_asr_handle_t *ah)
+														 const char *grammar, const char *path, const char *dest, switch_asr_handle_t *ah)
 {
 	switch_channel_t *channel = switch_core_session_get_channel(session);
 	switch_codec_t *read_codec = switch_core_session_get_read_codec(session);
@@ -1816,7 +1810,7 @@
 	}
 
 	switch_zmalloc(cur, len);
-	helper = (struct transfer_helper *)cur;
+	helper = (struct transfer_helper *) cur;
 
 	switch_copy_string(helper->uuid_str, uuid, sizeof(helper->uuid_str));
 
@@ -1864,12 +1858,12 @@
 	char *cur = NULL;
 
 	switch_zmalloc(cur, len);
-	helper = (struct broadcast_helper *)cur;
-	
+	helper = (struct broadcast_helper *) cur;
+
 	cur += sizeof(*helper);
 	switch_copy_string(helper->uuid_str, uuid, sizeof(helper->uuid_str));
 	helper->flags = flags;
-	
+
 	switch_copy_string(cur, path, len - sizeof(helper));
 	helper->path = cur;
 
@@ -1898,7 +1892,7 @@
 	channel = switch_core_session_get_channel(session);
 
 	if ((switch_channel_test_flag(channel, CF_EVENT_PARSE))) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Channel [%s][%s] already broadcasting...broadcast aborted\n", 
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Channel [%s][%s] already broadcasting...broadcast aborted\n",
 						  switch_channel_get_name(channel), path);
 		switch_core_session_rwunlock(session);
 		return SWITCH_STATUS_FALSE;
@@ -1914,8 +1908,8 @@
 	if ((nomedia = switch_channel_test_flag(channel, CF_PROXY_MODE))) {
 		switch_ivr_media(uuid, SMF_REBRIDGE);
 	}
-		
-	if ((p = strchr(mypath, ':')) && *(p+1) == ':') {
+
+	if ((p = strchr(mypath, ':')) && *(p + 1) == ':') {
 		app = mypath;
 		*p++ = '\0';
 		*p++ = '\0';
@@ -1946,7 +1940,7 @@
 
 			switch_core_session_queue_private_event(other_session, &event);
 		}
-			
+
 		switch_core_session_rwunlock(other_session);
 		master = other_session;
 		other_session = NULL;

Modified: freeswitch/trunk/src/switch_ivr_bridge.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr_bridge.c	(original)
+++ freeswitch/trunk/src/switch_ivr_bridge.c	Tue May 27 00:30:03 2008
@@ -50,16 +50,16 @@
 	switch_status_t status;
 	switch_frame_t *read_frame;
 
-	vh->up = 1;	
-	while(switch_channel_ready(channel) && vh->up == 1) {
+	vh->up = 1;
+	while (switch_channel_ready(channel) && vh->up == 1) {
 		status = switch_core_session_read_video_frame(vh->session_a, &read_frame, SWITCH_IO_FLAG_NONE, 0);
-		
+
 		if (!SWITCH_READ_ACCEPTABLE(status)) {
 			break;
 		}
-		
+
 		switch_core_session_write_video_frame(vh->session_b, read_frame, SWITCH_IO_FLAG_NONE, 0);
-		
+
 	}
 	vh->up = 0;
 	return NULL;
@@ -70,10 +70,10 @@
 	switch_thread_t *thread;
 	switch_threadattr_t *thd_attr = NULL;
 
-    switch_threadattr_create(&thd_attr, switch_core_session_get_pool(vh->session_a));
-    switch_threadattr_detach_set(thd_attr, 1);
-    switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
-    switch_thread_create(&thread, thd_attr, video_bridge_thread, vh, switch_core_session_get_pool(vh->session_a));
+	switch_threadattr_create(&thd_attr, switch_core_session_get_pool(vh->session_a));
+	switch_threadattr_detach_set(thd_attr, 1);
+	switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
+	switch_thread_create(&thread, thd_attr, video_bridge_thread, vh, switch_core_session_get_pool(vh->session_a));
 }
 #endif
 
@@ -86,7 +86,7 @@
 };
 typedef struct switch_ivr_bridge_data switch_ivr_bridge_data_t;
 
-static void *audio_bridge_thread(switch_thread_t * thread, void *obj)
+static void *audio_bridge_thread(switch_thread_t *thread, void *obj)
 {
 	switch_ivr_bridge_data_t *data = obj;
 	int stream_id = 0, pre_b = 0, ans_a = 0, ans_b = 0, originator = 0;
@@ -99,9 +99,9 @@
 	uint32_t loop_count = 0;
 	const char *app_name = NULL, *app_arg = NULL;
 	const char *hook_var = NULL;
-	int inner_bridge  = 0;
+	int inner_bridge = 0;
 #ifdef SWITCH_VIDEO_IN_THREADS
-    struct vid_helper vh = { 0 };
+	struct vid_helper vh = { 0 };
 	uint32_t vid_launch = 0;
 #endif
 
@@ -109,7 +109,7 @@
 	if (!(session_b = switch_core_session_locate(data->b_uuid))) {
 		return NULL;
 	}
-	
+
 	input_callback = data->input_callback;
 	user_data = data->session_data;
 	stream_id = data->stream_id;
@@ -124,7 +124,7 @@
 	}
 
 	inner_bridge = switch_channel_test_flag(chan_a, CF_INNER_BRIDGE);
-	
+
 
 	switch_channel_set_flag(chan_a, CF_BRIDGED);
 
@@ -170,20 +170,19 @@
 
 		if (!inner_bridge && (switch_channel_test_flag(chan_a, CF_SUSPEND) || switch_channel_test_flag(chan_b, CF_SUSPEND))) {
 			status = switch_core_session_read_frame(session_a, &read_frame, SWITCH_IO_FLAG_NONE, stream_id);
-			
+
 			if (!SWITCH_READ_ACCEPTABLE(status)) {
 				goto end_of_bridge_loop;
 			}
 			continue;
 		}
-
 #ifdef SWITCH_VIDEO_IN_THREADS
-        if (switch_channel_test_flag(chan_a, CF_VIDEO) && switch_channel_test_flag(chan_b, CF_VIDEO) && !vid_launch) {
-            vid_launch++;
-            vh.session_a = session_a;
-            vh.session_b = session_b;
-            launch_video(&vh);
-        }
+		if (switch_channel_test_flag(chan_a, CF_VIDEO) && switch_channel_test_flag(chan_b, CF_VIDEO) && !vid_launch) {
+			vid_launch++;
+			vh.session_a = session_a;
+			vh.session_b = session_b;
+			launch_video(&vh);
+		}
 #endif
 
 		/* if 1 channel has DTMF pass it to the other */
@@ -193,8 +192,8 @@
 				int send_dtmf = 1;
 
 				if (input_callback) {
-					switch_status_t cb_status = input_callback(session_a, (void *)&dtmf, SWITCH_INPUT_TYPE_DTMF, user_data, 0);
-					
+					switch_status_t cb_status = input_callback(session_a, (void *) &dtmf, SWITCH_INPUT_TYPE_DTMF, user_data, 0);
+
 					if (cb_status == SWITCH_STATUS_IGNORE) {
 						send_dtmf = 0;
 					} else if (cb_status != SWITCH_STATUS_SUCCESS) {
@@ -203,7 +202,7 @@
 						goto end_of_bridge_loop;
 					}
 				}
-				
+
 				if (send_dtmf) {
 					switch_core_session_send_dtmf(session_b, &dtmf);
 				}
@@ -250,16 +249,15 @@
 				continue;
 			}
 		}
-
 #ifndef SWITCH_VIDEO_IN_THREADS
 		if (switch_channel_test_flag(chan_a, CF_VIDEO) && switch_channel_test_flag(chan_b, CF_VIDEO)) {
 			/* read video from 1 channel and write it to the other */
 			status = switch_core_session_read_video_frame(session_a, &read_frame, SWITCH_IO_FLAG_NONE, 0);
-		
+
 			if (!SWITCH_READ_ACCEPTABLE(status)) {
 				goto end_of_bridge_loop;
 			}
-		
+
 			switch_core_session_write_video_frame(session_b, read_frame, SWITCH_IO_FLAG_NONE, 0);
 		}
 #endif
@@ -285,17 +283,17 @@
 		}
 	}
 
- end_of_bridge_loop:
+  end_of_bridge_loop:
 
 
 #ifdef SWITCH_VIDEO_IN_THREADS
-    if (vh.up) {
-        vh.up = -1;
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Ending video thread.\n");
-        while(vh.up) {
-            switch_yield(100000);
-        }
-    }
+	if (vh.up) {
+		vh.up = -1;
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Ending video thread.\n");
+		while (vh.up) {
+			switch_yield(100000);
+		}
+	}
 #endif
 
 	if (!inner_bridge) {
@@ -314,9 +312,9 @@
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "\nPost-Bridge Command %s(%s):\n%s\n", cmd, arg, switch_str_nil((char *) stream.data));
 		switch_safe_free(stream.data);
 	}
-	
-	
-	if (switch_channel_get_state(chan_b) >= CS_HANGUP) {	
+
+
+	if (switch_channel_get_state(chan_b) >= CS_HANGUP) {
 		if (originator && switch_channel_ready(chan_a) && !switch_channel_test_flag(chan_a, CF_ANSWERED)) {
 			switch_channel_hangup(chan_a, switch_channel_get_cause(chan_b));
 		}
@@ -326,7 +324,7 @@
 	msg.message_id = SWITCH_MESSAGE_INDICATE_UNBRIDGE;
 	msg.from = __FILE__;
 	switch_core_session_receive_message(session_a, &msg);
-	
+
 	if (!inner_bridge && switch_channel_get_state(chan_a) < CS_HANGUP) {
 		if ((app_name = switch_channel_get_variable(chan_a, SWITCH_EXEC_AFTER_BRIDGE_APP_VARIABLE))) {
 			switch_caller_extension_t *extension = NULL;
@@ -347,7 +345,7 @@
 		}
 	}
 
- end:
+  end:
 
 	switch_core_session_kill_channel(session_b, SWITCH_SIG_BREAK);
 	switch_core_session_reset(session_a, SWITCH_TRUE);
@@ -379,7 +377,7 @@
 	switch_channel_clear_state_handler(channel, &audio_bridge_peer_state_handlers);
 
 	state = switch_channel_get_state(channel);
-	
+
 	if (!switch_channel_test_flag(channel, CF_TRANSFER) && state != CS_PARK && state != CS_ROUTING && !switch_channel_test_flag(channel, CF_INNER_BRIDGE)) {
 		switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
 	}
@@ -447,13 +445,12 @@
 	if (!switch_channel_test_flag(channel, CF_ORIGINATOR)) {
 		return SWITCH_STATUS_SUCCESS;
 	}
-	
-	if ((other_uuid = switch_channel_get_variable(channel, SWITCH_UUID_BRIDGE)) && 
-		(other_session = switch_core_session_locate(other_uuid))) {
+
+	if ((other_uuid = switch_channel_get_variable(channel, SWITCH_UUID_BRIDGE)) && (other_session = switch_core_session_locate(other_uuid))) {
 		switch_channel_t *other_channel = switch_core_session_get_channel(other_session);
 		switch_event_t *event;
 		uint8_t ready_a, ready_b;
-		
+
 		switch_channel_set_variable(channel, SWITCH_UUID_BRIDGE, NULL);
 
 		switch_channel_wait_for_state(channel, other_channel, CS_RESET);
@@ -474,7 +471,7 @@
 		switch_channel_clear_flag(other_channel, CF_TRANSFER);
 		switch_core_session_reset(session, SWITCH_TRUE);
 		switch_core_session_reset(other_session, SWITCH_TRUE);
-		
+
 		ready_a = switch_channel_ready(channel);
 		ready_b = switch_channel_ready(other_channel);
 
@@ -524,8 +521,8 @@
 	/*.on_exchange_media */ NULL,
 	/*.on_soft_execute */ uuid_bridge_on_soft_execute,
 	/*.on_consume_media */ NULL,
-	/*.on_hibernate*/ NULL,
-	/*.on_reset*/ uuid_bridge_on_reset
+	/*.on_hibernate */ NULL,
+	/*.on_reset */ uuid_bridge_on_reset
 };
 
 static switch_status_t signal_bridge_on_hibernate(switch_core_session_t *session)
@@ -548,7 +545,7 @@
 	switch_core_session_t *other_session;
 	switch_event_t *event;
 
-	if (switch_channel_test_flag(channel, CF_ORIGINATOR)) {		
+	if (switch_channel_test_flag(channel, CF_ORIGINATOR)) {
 		switch_channel_clear_flag(channel, CF_ORIGINATOR);
 		if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_UNBRIDGE) == SWITCH_STATUS_SUCCESS) {
 			switch_channel_event_set_data(channel, event);
@@ -636,7 +633,7 @@
 
 	switch_channel_set_state_flag(caller_channel, CF_TRANSFER);
 	switch_channel_set_state_flag(peer_channel, CF_TRANSFER);
-	
+
 
 	switch_channel_set_state(caller_channel, CS_HIBERNATE);
 	switch_channel_set_state(peer_channel, CS_HIBERNATE);
@@ -659,7 +656,7 @@
 	switch_event_t *event;
 	int br = 0;
 	int inner_bridge = switch_channel_test_flag(caller_channel, CF_INNER_BRIDGE);
-	
+
 	switch_channel_set_flag(caller_channel, CF_ORIGINATOR);
 	switch_channel_clear_flag(caller_channel, CF_TRANSFER);
 	switch_channel_clear_flag(peer_channel, CF_TRANSFER);
@@ -695,7 +692,7 @@
 			switch_event_fire(&event);
 			br = 1;
 		}
-		
+
 		if (switch_core_session_read_lock(peer_session) == SWITCH_STATUS_SUCCESS) {
 			switch_channel_set_variable(caller_channel, SWITCH_BRIDGE_VARIABLE, switch_core_session_get_uuid(peer_session));
 			switch_channel_set_variable(peer_channel, SWITCH_BRIDGE_VARIABLE, switch_core_session_get_uuid(session));
@@ -748,14 +745,14 @@
 			switch_channel_set_variable(peer_channel, SWITCH_BRIDGE_CHANNEL_VARIABLE, switch_channel_get_name(caller_channel));
 			switch_channel_set_variable(peer_channel, SWITCH_BRIDGE_UUID_VARIABLE, switch_core_session_get_uuid(session));
 			switch_channel_set_variable(peer_channel, SWITCH_SIGNAL_BOND_VARIABLE, switch_core_session_get_uuid(session));
-			
+
 			if ((app = switch_channel_get_variable(caller_channel, "bridge_pre_execute_aleg_app"))) {
 				data = switch_channel_get_variable(caller_channel, "bridge_pre_execute_aleg_data");
 				if ((application_interface = switch_loadable_module_get_application_interface(app))) {
 					switch_core_session_exec(session, application_interface, data);
 				}
 			}
-			
+
 			if ((app = switch_channel_get_variable(caller_channel, "bridge_pre_execute_bleg_app"))) {
 				data = switch_channel_get_variable(caller_channel, "bridge_pre_execute_bleg_data");
 				if ((application_interface = switch_loadable_module_get_application_interface(app))) {
@@ -768,7 +765,7 @@
 			audio_bridge_thread(NULL, (void *) a_leg);
 
 			switch_channel_clear_flag(caller_channel, CF_ORIGINATOR);
-			
+
 			if (!switch_channel_test_flag(peer_channel, CF_TRANSFER) && switch_channel_get_state(peer_channel) == CS_EXCHANGE_MEDIA) {
 				switch_channel_set_state(peer_channel, CS_RESET);
 			}
@@ -801,10 +798,10 @@
 	}
 
 	state = switch_channel_get_state(caller_channel);
-	
+
 	if (!switch_channel_test_flag(caller_channel, CF_TRANSFER) && !inner_bridge) {
-		if ((state != CS_EXECUTE && state != CS_PARK && state != CS_ROUTING) || 
-			(switch_channel_test_flag(peer_channel, CF_ANSWERED) && state < CS_HANGUP && 
+		if ((state != CS_EXECUTE && state != CS_PARK && state != CS_ROUTING) ||
+			(switch_channel_test_flag(peer_channel, CF_ANSWERED) && state < CS_HANGUP &&
 			 switch_true(switch_channel_get_variable(caller_channel, SWITCH_HANGUP_AFTER_BRIDGE_VARIABLE)))) {
 			switch_channel_hangup(caller_channel, switch_channel_get_cause(peer_channel));
 		}
@@ -837,7 +834,7 @@
 					swap_session = originator_session;
 					originator_session = originatee_session;
 					originatee_session = swap_session;
-					
+
 					swap_channel = originator_channel;
 					originator_channel = originatee_channel;
 					originatee_channel = swap_channel;
@@ -856,7 +853,7 @@
 			 * inturrupt anything they are already doing.
 			 * originatee_session will fall asleep and originator_session will bridge to it
 			 */
-			
+
 			switch_channel_clear_state_handler(originator_channel, NULL);
 			switch_channel_clear_state_handler(originatee_channel, NULL);
 			switch_channel_set_state_flag(originator_channel, CF_ORIGINATOR);
@@ -864,7 +861,7 @@
 			switch_channel_add_state_handler(originator_channel, &uuid_bridge_state_handlers);
 			switch_channel_add_state_handler(originatee_channel, &uuid_bridge_state_handlers);
 			switch_channel_set_variable(originator_channel, SWITCH_UUID_BRIDGE, switch_core_session_get_uuid(originatee_session));
-		
+
 			switch_channel_set_variable(originator_channel, SWITCH_BRIDGE_CHANNEL_VARIABLE, switch_channel_get_name(originatee_channel));
 			switch_channel_set_variable(originator_channel, SWITCH_BRIDGE_UUID_VARIABLE, switch_core_session_get_uuid(originatee_session));
 			switch_channel_set_variable(originator_channel, SWITCH_SIGNAL_BOND_VARIABLE, switch_core_session_get_uuid(originatee_session));
@@ -872,10 +869,10 @@
 			switch_channel_set_variable(originatee_channel, SWITCH_BRIDGE_UUID_VARIABLE, switch_core_session_get_uuid(originator_session));
 			switch_channel_set_variable(originatee_channel, SWITCH_SIGNAL_BOND_VARIABLE, switch_core_session_get_uuid(originator_session));
 
-			
+
 			originator_cp = switch_channel_get_caller_profile(originator_channel);
 			originatee_cp = switch_channel_get_caller_profile(originatee_channel);
-			
+
 
 			switch_channel_set_variable(originatee_channel, "original_destination_number", originatee_cp->destination_number);
 			switch_channel_set_variable(originatee_channel, "original_caller_id_name", originatee_cp->caller_id_name);
@@ -891,7 +888,7 @@
 			cp->caller_id_name = switch_core_strdup(cp->pool, originator_cp->caller_id_name);
 			switch_channel_set_caller_profile(originatee_channel, cp);
 			switch_channel_set_originator_caller_profile(originatee_channel, switch_caller_profile_clone(originatee_session, originator_cp));
-			
+
 			cp = switch_caller_profile_clone(originator_session, originator_cp);
 			cp->destination_number = switch_core_strdup(cp->pool, originatee_cp->caller_id_number);
 			cp->caller_id_number = switch_core_strdup(cp->pool, originatee_cp->caller_id_number);
@@ -907,7 +904,7 @@
 
 			switch_channel_clear_flag(originator_channel, CF_ORIGINATING);
 			switch_channel_clear_flag(originatee_channel, CF_ORIGINATING);
-			
+
 			/* change the states and let the chips fall where they may */
 			switch_channel_set_state(originator_channel, CS_RESET);
 			switch_channel_set_state(originatee_channel, CS_RESET);
@@ -935,7 +932,7 @@
 	switch_status_t status = SWITCH_STATUS_FALSE;
 
 	switch_assert(uuid);
-	
+
 	if ((rsession = switch_core_session_locate(uuid))) {
 		switch_channel_t *rchannel = switch_core_session_get_channel(rsession);
 		const char *brto;
@@ -946,7 +943,7 @@
 		}
 		switch_core_session_rwunlock(rsession);
 	}
-	
+
 	return status;
 
 }
@@ -972,7 +969,7 @@
 		return;
 	}
 
-	channel = switch_core_session_get_channel(session);	
+	channel = switch_core_session_get_channel(session);
 	rchannel = switch_core_session_get_channel(rsession);
 
 	switch_channel_pre_answer(channel);
@@ -983,7 +980,7 @@
 
 	if (!switch_channel_test_flag(rchannel, CF_ANSWERED)) {
 		switch_channel_answer(rchannel);
-	}	
+	}
 	//switch_ivr_park_session(rsession);
 	switch_channel_set_state_flag(rchannel, CF_TRANSFER);
 	switch_channel_set_state(rchannel, CS_RESET);

Modified: freeswitch/trunk/src/switch_ivr_originate.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr_originate.c	(original)
+++ freeswitch/trunk/src/switch_ivr_originate.c	Tue May 27 00:30:03 2008
@@ -37,13 +37,13 @@
 static switch_status_t originate_on_consume_media_transmit(switch_core_session_t *session)
 {
 	switch_channel_t *channel = switch_core_session_get_channel(session);
-	
+
 	if (!switch_channel_test_flag(channel, CF_PROXY_MODE)) {
-		while(switch_channel_get_state(channel) == CS_CONSUME_MEDIA && !switch_channel_test_flag(channel, CF_TAGGED)) {
+		while (switch_channel_get_state(channel) == CS_CONSUME_MEDIA && !switch_channel_test_flag(channel, CF_TAGGED)) {
 			switch_ivr_sleep(session, 10);
 		}
 	}
-	
+
 	switch_channel_clear_state_handler(channel, &originate_state_handlers);
 
 	return SWITCH_STATUS_FALSE;
@@ -81,7 +81,7 @@
 	switch_core_session_t *session;
 };
 
-static void *SWITCH_THREAD_FUNC collect_thread_run(switch_thread_t * thread, void *obj)
+static void *SWITCH_THREAD_FUNC collect_thread_run(switch_thread_t *thread, void *obj)
 {
 	struct key_collect *collect = (struct key_collect *) obj;
 	switch_channel_t *channel = switch_core_session_get_channel(collect->session);
@@ -117,7 +117,7 @@
 
 		switch_channel_set_state(channel, CS_SOFT_EXECUTE);
 		switch_core_session_exec(collect->session, application_interface, app_data);
-		
+
 		if (switch_channel_get_state(channel) < CS_HANGUP) {
 			switch_channel_set_flag(channel, CF_WINNER);
 		}
@@ -166,13 +166,14 @@
 
 static uint8_t check_channel_status(switch_channel_t **peer_channels,
 									switch_core_session_t **peer_sessions,
-									uint32_t len, int32_t *idx, uint32_t * hups, char *file, char *key, uint8_t early_ok, uint8_t *ring_ready, uint8_t return_ring_ready)
+									uint32_t len, int32_t *idx, uint32_t *hups, char *file, char *key, uint8_t early_ok, uint8_t *ring_ready,
+									uint8_t return_ring_ready)
 {
 
 	uint32_t i;
 	*hups = 0;
 	*idx = IDX_NADA;
-	
+
 	for (i = 0; i < len; i++) {
 		switch_channel_state_t state;
 		if (!peer_channels[i]) {
@@ -183,17 +184,16 @@
 		}
 
 		state = switch_channel_get_state(peer_channels[i]);
-		if (state >= CS_HANGUP || state == CS_RESET || switch_channel_test_flag(peer_channels[i], CF_TRANSFER) || 
-			switch_channel_test_flag(peer_channels[i], CF_BRIDGED) ||
-			!switch_channel_test_flag(peer_channels[i], CF_ORIGINATING)
+		if (state >= CS_HANGUP || state == CS_RESET || switch_channel_test_flag(peer_channels[i], CF_TRANSFER) ||
+			switch_channel_test_flag(peer_channels[i], CF_BRIDGED) || !switch_channel_test_flag(peer_channels[i], CF_ORIGINATING)
 			) {
 			(*hups)++;
 		} else if ((switch_channel_test_flag(peer_channels[i], CF_ANSWERED) ||
 					(early_ok && len == 1 && switch_channel_test_flag(peer_channels[i], CF_EARLY_MEDIA)) ||
 					(*ring_ready && return_ring_ready && len == 1 && switch_channel_test_flag(peer_channels[i], CF_RING_READY))
-					)
+				   )
 				   && !switch_channel_test_flag(peer_channels[i], CF_TAGGED)
-				   ) {
+			) {
 
 			if (!switch_strlen_zero(key)) {
 				struct key_collect *collect;
@@ -236,7 +236,7 @@
 
 typedef struct ringback ringback_t;
 
-static int teletone_handler(teletone_generation_session_t * ts, teletone_tone_map_t * map)
+static int teletone_handler(teletone_generation_session_t *ts, teletone_tone_map_t *map)
 {
 	ringback_t *tto = ts->user_data;
 	int wrote;
@@ -255,7 +255,7 @@
 {
 	switch_channel_t *caller_channel = switch_core_session_get_channel(session);
 	switch_channel_t *peer_channel = switch_core_session_get_channel(peer_session);
-	const char *ringback_data = NULL;	
+	const char *ringback_data = NULL;
 	switch_frame_t write_frame = { 0 };
 	switch_codec_t write_codec = { 0 };
 	switch_codec_t *read_codec = switch_core_session_get_read_codec(session);
@@ -267,7 +267,7 @@
 	int timelimit = 60;
 	const char *var = switch_channel_get_variable(caller_channel, "call_timeout");
 	switch_time_t start = 0;
-	
+
 	if ((switch_channel_test_flag(peer_channel, CF_ANSWERED) || switch_channel_test_flag(peer_channel, CF_EARLY_MEDIA))) {
 		return SWITCH_STATUS_SUCCESS;
 	}
@@ -287,14 +287,14 @@
 
 	if (switch_channel_test_flag(caller_channel, CF_ANSWERED)) {
 		ringback_data = switch_channel_get_variable(caller_channel, "transfer_ringback");
-	} 
-			
+	}
+
 	if (!ringback_data) {
 		ringback_data = switch_channel_get_variable(caller_channel, "ringback");
 	}
-		
-	
-	if (read_codec && (ringback_data || 
+
+
+	if (read_codec && (ringback_data ||
 					   (!(switch_channel_test_flag(caller_channel, CF_PROXY_MODE) && switch_channel_test_flag(caller_channel, CF_PROXY_MEDIA))))) {
 		if (!(pass = (uint8_t) switch_test_flag(read_codec, SWITCH_CODEC_FLAG_PASSTHROUGH))) {
 			if (switch_core_codec_init(&write_codec,
@@ -302,14 +302,14 @@
 									   NULL,
 									   read_codec->implementation->actual_samples_per_second,
 									   read_codec->implementation->microseconds_per_frame / 1000,
-									   1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, 
+									   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_DEBUG,
 								  "Raw Codec Activation Success L16@%uhz 1 channel %dms\n",
 								  read_codec->implementation->actual_samples_per_second, read_codec->implementation->microseconds_per_frame / 1000);
-				
+
 				write_frame.codec = &write_codec;
 				write_frame.datalen = read_codec->implementation->bytes_per_frame;
 				write_frame.samples = write_frame.datalen / 2;
@@ -317,13 +317,13 @@
 
 				if (ringback_data) {
 					char *tmp_data = NULL;
-					
+
 					switch_buffer_create_dynamic(&ringback.audio_buffer, 512, 1024, 0);
 					switch_buffer_set_loops(ringback.audio_buffer, -1);
-							
+
 					if (switch_is_file_path(ringback_data)) {
 						char *ext;
-								
+
 						if (strrchr(ringback_data, '.') || strstr(ringback_data, SWITCH_URL_SEPARATOR)) {
 							switch_core_session_set_read_codec(session, &write_codec);
 						} else {
@@ -342,8 +342,7 @@
 												  ringback_data,
 												  read_codec->implementation->number_of_channels,
 												  read_codec->implementation->actual_samples_per_second,
-												  SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT,
-												  NULL) != SWITCH_STATUS_SUCCESS) {
+												  SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL) != SWITCH_STATUS_SUCCESS) {
 							switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Playing File\n");
 							switch_safe_free(tmp_data);
 							goto done;
@@ -370,9 +369,10 @@
 		}
 	}
 
-	while (switch_channel_ready(peer_channel) && !(switch_channel_test_flag(peer_channel, CF_ANSWERED) || switch_channel_test_flag(peer_channel, CF_EARLY_MEDIA))) {
-		int diff = (int)(switch_timestamp_now() - start);
-		
+	while (switch_channel_ready(peer_channel)
+		   && !(switch_channel_test_flag(peer_channel, CF_ANSWERED) || switch_channel_test_flag(peer_channel, CF_EARLY_MEDIA))) {
+		int diff = (int) (switch_timestamp_now() - start);
+
 		if (diff > timelimit) {
 			status = SWITCH_STATUS_TIMEOUT;
 			goto done;
@@ -390,7 +390,7 @@
 			break;
 		}
 
-		
+
 		if (read_frame && !pass) {
 			if (ringback.fh) {
 				switch_size_t mlen, olen;
@@ -431,8 +431,8 @@
 		}
 	}
 
- done:
-	
+  done:
+
 	if (ringback.fh) {
 		switch_core_file_close(ringback.fh);
 		ringback.fh = NULL;
@@ -461,10 +461,9 @@
 													 const char *bridgeto,
 													 uint32_t timelimit_sec,
 													 const switch_state_handler_table_t *table,
-													 const char *cid_name_override, 
-													 const char *cid_num_override, 
-													 switch_caller_profile_t *caller_profile_override,
-													 switch_originate_flag_t flags)
+													 const char *cid_name_override,
+													 const char *cid_num_override,
+													 switch_caller_profile_t *caller_profile_override, switch_originate_flag_t flags)
 {
 	switch_originate_flag_t myflags = SOF_NONE;
 	char *pipe_names[MAX_PEERS] = { 0 };
@@ -516,10 +515,10 @@
 	while (data && *data && *data == ' ') {
 		data++;
 	}
-	
+
 	if (*data == '{') {
 		char *e = switch_find_end_paren(data, '{', '}');
-		
+
 		if (e) {
 			vars = data + 1;
 			*e++ = '\0';
@@ -558,47 +557,47 @@
 		if ((hi = switch_channel_variable_first(caller_channel))) {
 			for (; hi; hi = hi->next) {
 				int ok = 0;
-				if (!strcasecmp((char *)hi->name, "group_confirm_key")) {
+				if (!strcasecmp((char *) hi->name, "group_confirm_key")) {
 					ok = 1;
-				} else if (!strcasecmp((char *)hi->name, "group_confirm_file")) {
+				} else if (!strcasecmp((char *) hi->name, "group_confirm_file")) {
 					ok = 1;
-				} else if (!strcasecmp((char *)hi->name, "forked_dial")) {
+				} else if (!strcasecmp((char *) hi->name, "forked_dial")) {
 					ok = 1;
-				} else if (!strcasecmp((char *)hi->name, "fail_on_single_reject")) {
+				} else if (!strcasecmp((char *) hi->name, "fail_on_single_reject")) {
 					ok = 1;
-				} else if (!strcasecmp((char *)hi->name, "ignore_early_media")) {
+				} else if (!strcasecmp((char *) hi->name, "ignore_early_media")) {
 					ok = 1;
-				} else if (!strcasecmp((char *)hi->name, "return_ring_ready")) {
+				} else if (!strcasecmp((char *) hi->name, "return_ring_ready")) {
 					ok = 1;
-				} else if (!strcasecmp((char *)hi->name, "originate_retries")) {
+				} else if (!strcasecmp((char *) hi->name, "originate_retries")) {
 					ok = 1;
-				} else if (!strcasecmp((char *)hi->name, "originate_timeout")) {
+				} else if (!strcasecmp((char *) hi->name, "originate_timeout")) {
 					ok = 1;
-				} else if (!strcasecmp((char *)hi->name, "originate_retry_sleep_ms")) {
+				} else if (!strcasecmp((char *) hi->name, "originate_retry_sleep_ms")) {
 					ok = 1;
-				} else if (!strcasecmp((char *)hi->name, "origination_caller_id_name")) {
+				} else if (!strcasecmp((char *) hi->name, "origination_caller_id_name")) {
 					ok = 1;
-				} else if (!strcasecmp((char *)hi->name, "origination_caller_id_number")) {
+				} else if (!strcasecmp((char *) hi->name, "origination_caller_id_number")) {
 					ok = 1;
 				}
 
 				if (ok) {
-					switch_event_add_header(var_event, SWITCH_STACK_BOTTOM, (char *)hi->name, "%s", (char *) hi->value);
+					switch_event_add_header(var_event, SWITCH_STACK_BOTTOM, (char *) hi->name, "%s", (char *) hi->value);
 				}
 			}
 			switch_channel_variable_last(caller_channel);
 		}
 		/*
-		if ((hi = switch_channel_variable_first(caller_channel))) {
-			for (; hi; hi = switch_hash_next(hi)) {
-				switch_hash_this(hi, &vvar, NULL, &vval);
-				if (vvar && vval) {
-					switch_event_add_header(var_event, SWITCH_STACK_BOTTOM, (void *) vvar, "%s", (char *) vval);
-				}
-			}
-			switch_channel_variable_last(caller_channel);
-		}
-		*/
+		   if ((hi = switch_channel_variable_first(caller_channel))) {
+		   for (; hi; hi = switch_hash_next(hi)) {
+		   switch_hash_this(hi, &vvar, NULL, &vval);
+		   if (vvar && vval) {
+		   switch_event_add_header(var_event, SWITCH_STACK_BOTTOM, (void *) vvar, "%s", (char *) vval);
+		   }
+		   }
+		   switch_channel_variable_last(caller_channel);
+		   }
+		 */
 	}
 
 	if (vars) {					/* Parse parameters specified from the dialstring */
@@ -609,7 +608,7 @@
 			for (x = 0; x < var_count; x++) {
 				char *inner_var_array[2] = { 0 };
 				int inner_var_count;
-				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"variable string %d = [%s]\n", x, var_array[x]);				
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "variable string %d = [%s]\n", x, var_array[x]);
 				if ((inner_var_count =
 					 switch_separate_string(var_array[x], '=', inner_var_array, (sizeof(inner_var_array) / sizeof(inner_var_array[0])))) == 2) {
 
@@ -624,12 +623,12 @@
 
 		if (switch_channel_test_flag(caller_channel, CF_ANSWERED)) {
 			ringback_data = switch_channel_get_variable(caller_channel, "transfer_ringback");
-		} 
-			
+		}
+
 		if (!ringback_data) {
 			ringback_data = switch_channel_get_variable(caller_channel, "ringback");
 		}
-		
+
 		switch_channel_set_variable(caller_channel, "originate_disposition", "failure");
 	}
 
@@ -736,7 +735,7 @@
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Only calling the first element in the list in this mode.\n");
 				and_argc = 1;
 			}
-			
+
 			for (i = 0; i < and_argc; i++) {
 				char *vdata;
 				char *e = NULL;
@@ -748,7 +747,7 @@
 
 				vdata = chan_type;
 				e = switch_find_end_paren(vdata, '[', ']');
-				
+
 				if (e) {
 					vdata++;
 					*e++ = '\0';
@@ -756,7 +755,7 @@
 				} else {
 					vdata = NULL;
 				}
-				
+
 				if ((chan_data = strchr(chan_type, '/')) != 0) {
 					*chan_data = '\0';
 					chan_data++;
@@ -801,18 +800,15 @@
 						new_profile = switch_caller_profile_new(pool,
 																NULL,
 																NULL,
-																cid_name_override,
-																cid_num_override,
-																NULL, NULL, NULL, NULL, __FILE__, NULL,
-																chan_data);
+																cid_name_override, cid_num_override, NULL, NULL, NULL, NULL, __FILE__, NULL, chan_data);
 					}
 				}
-				
+
 				caller_profiles[i] = NULL;
 				peer_channels[i] = NULL;
 				peer_sessions[i] = NULL;
 				new_session = NULL;
-				
+
 				if (and_argc > 1 || or_argc > 1) {
 					myflags |= SOF_FORKED_DIAL;
 				} else if (var_event) {
@@ -821,9 +817,11 @@
 						myflags |= SOF_FORKED_DIAL;
 					}
 				}
-				if ((reason = switch_core_session_outgoing_channel(session, var_event, chan_type, new_profile, &new_session, &pool, myflags)) != SWITCH_CAUSE_SUCCESS) {
-					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot create outgoing channel of type [%s] cause: [%s]\n", 
-									  chan_type, switch_channel_cause2str(reason));
+				if ((reason =
+					 switch_core_session_outgoing_channel(session, var_event, chan_type, new_profile, &new_session, &pool,
+														  myflags)) != SWITCH_CAUSE_SUCCESS) {
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot create outgoing channel of type [%s] cause: [%s]\n", chan_type,
+									  switch_channel_cause2str(reason));
 					if (pool) {
 						switch_core_destroy_memory_pool(&pool);
 					}
@@ -837,7 +835,7 @@
 				peer_sessions[i] = new_session;
 				peer_channels[i] = switch_core_session_get_channel(new_session);
 				switch_channel_set_flag(peer_channels[i], CF_ORIGINATING);
-				
+
 				if (vdata) {
 					char *var_array[1024] = { 0 };
 					int var_count = 0;
@@ -847,15 +845,15 @@
 							char *inner_var_array[2] = { 0 };
 							int inner_var_count;
 							if ((inner_var_count =
-								 switch_separate_string(var_array[x], '=', 
+								 switch_separate_string(var_array[x], '=',
 														inner_var_array, (sizeof(inner_var_array) / sizeof(inner_var_array[0])))) == 2) {
-								
+
 								switch_channel_set_variable(peer_channels[i], inner_var_array[0], inner_var_array[1]);
 							}
 						}
 					}
 				}
-				
+
 				if (var_event) {
 					switch_event_t *event;
 					switch_event_header_t *header;
@@ -883,15 +881,15 @@
 					*cause = SWITCH_CAUSE_SUCCESS;
 					goto outer_for;
 				}
-				
+
 				if (!switch_core_session_running(peer_sessions[i])) {
 					//if (!(flags & SOF_NOBLOCK)) {
-                    //switch_channel_set_state(peer_channels[i], CS_ROUTING);
+					//switch_channel_set_state(peer_channels[i], CS_ROUTING);
 					//}
-                    //} else {
+					//} else {
 					switch_core_session_thread_launch(peer_sessions[i]);
 				}
-			}			
+			}
 
 			switch_timestamp(&start);
 
@@ -928,7 +926,7 @@
 
 					switch_yield(10000);
 				}
-				
+
 				if (valid_channels == 0) {
 					status = SWITCH_STATUS_GENERR;
 					goto done;
@@ -936,7 +934,7 @@
 
 			}
 
-		endfor1:
+		  endfor1:
 
 			if (ringback_data && !switch_channel_test_flag(caller_channel, CF_ANSWERED)
 				&& !switch_channel_test_flag(caller_channel, CF_EARLY_MEDIA)) {
@@ -947,7 +945,7 @@
 			}
 
 			if (session && (read_codec = switch_core_session_get_read_codec(session)) &&
-				(ringback_data || 
+				(ringback_data ||
 				 (!(switch_channel_test_flag(caller_channel, CF_PROXY_MODE) && switch_channel_test_flag(caller_channel, CF_PROXY_MEDIA))))) {
 
 				if (!(pass = (uint8_t) switch_test_flag(read_codec, SWITCH_CODEC_FLAG_PASSTHROUGH))) {
@@ -956,13 +954,14 @@
 											   NULL,
 											   read_codec->implementation->actual_samples_per_second,
 											   read_codec->implementation->microseconds_per_frame / 1000,
-											   1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, 
+											   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_DEBUG,
 										  "Raw Codec Activation Success L16@%uhz 1 channel %dms\n",
-										  read_codec->implementation->actual_samples_per_second, read_codec->implementation->microseconds_per_frame / 1000);
+										  read_codec->implementation->actual_samples_per_second,
+										  read_codec->implementation->microseconds_per_frame / 1000);
 						write_frame.codec = &write_codec;
 						write_frame.datalen = read_codec->implementation->bytes_per_frame;
 						write_frame.samples = write_frame.datalen / 2;
@@ -973,10 +972,10 @@
 
 							switch_buffer_create_dynamic(&ringback.audio_buffer, 512, 1024, 0);
 							switch_buffer_set_loops(ringback.audio_buffer, -1);
-							
+
 							if (switch_is_file_path(ringback_data)) {
 								char *ext;
-								
+
 								if (strrchr(ringback_data, '.') || strstr(ringback_data, SWITCH_URL_SEPARATOR)) {
 									switch_core_session_set_read_codec(session, &write_codec);
 								} else {
@@ -995,8 +994,7 @@
 														  ringback_data,
 														  read_codec->implementation->number_of_channels,
 														  read_codec->implementation->actual_samples_per_second,
-														  SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT,
-														  NULL) != SWITCH_STATUS_SUCCESS) {
+														  SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL) != SWITCH_STATUS_SUCCESS) {
 									switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Playing File\n");
 									switch_safe_free(tmp_data);
 									goto notready;
@@ -1038,7 +1036,6 @@
 					switch_channel_ring_ready(caller_channel);
 					sent_ring = 1;
 				}
-
 				// When the AND operator is being used, and fail_on_single_reject is set, a hangup indicates that the call should fail.
 				if ((to = (uint8_t) ((switch_timestamp(NULL) - start) >= (time_t) timelimit_sec))
 					|| (fail_on_single_reject && hups)) {
@@ -1059,23 +1056,24 @@
 					}
 				}
 
-				/* read from the channel while we wait if the audio is up on it */				
-				if (session && 
-					!switch_channel_test_flag(caller_channel, CF_PROXY_MODE) && 
-					!switch_channel_test_flag(caller_channel, CF_PROXY_MEDIA) && 
-					(ringback_data || (switch_channel_test_flag(caller_channel, CF_ANSWERED) || switch_channel_test_flag(caller_channel, CF_EARLY_MEDIA)))) {
-					 
+				/* read from the channel while we wait if the audio is up on it */
+				if (session &&
+					!switch_channel_test_flag(caller_channel, CF_PROXY_MODE) &&
+					!switch_channel_test_flag(caller_channel, CF_PROXY_MEDIA) &&
+					(ringback_data
+					 || (switch_channel_test_flag(caller_channel, CF_ANSWERED) || switch_channel_test_flag(caller_channel, CF_EARLY_MEDIA)))) {
+
 					switch_status_t tstatus = switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
-					
+
 					if (!SWITCH_READ_ACCEPTABLE(tstatus)) {
 						break;
 					}
-					
+
 					if (ring_ready && read_frame && !pass) {
 						if (ringback.fh) {
 							switch_size_t mlen, olen;
 							unsigned int pos = 0;
-							
+
 
 							if (ringback.asis) {
 								mlen = write_frame.codec->implementation->encoded_bytes_per_frame;
@@ -1103,7 +1101,7 @@
 								break;
 							}
 						}
-						
+
 						if (switch_core_session_write_frame(session, &write_frame, SWITCH_IO_FLAG_NONE, 0) != SWITCH_STATUS_SUCCESS) {
 							break;
 						}
@@ -1121,19 +1119,18 @@
 				idx = IDX_CANCEL;
 			}
 
-			if (session && (ringback_data || !(switch_channel_test_flag(caller_channel, CF_PROXY_MODE) && 
+			if (session && (ringback_data || !(switch_channel_test_flag(caller_channel, CF_PROXY_MODE) &&
 											   switch_channel_test_flag(caller_channel, CF_PROXY_MEDIA)))) {
 				switch_core_session_reset(session, SWITCH_FALSE);
 			}
-			
+
 			for (i = 0; i < and_argc; i++) {
 				if (!peer_channels[i]) {
 					continue;
 				}
-				
+
 				if (switch_channel_test_flag(peer_channels[i], CF_TRANSFER) || switch_channel_test_flag(peer_channels[i], CF_BRIDGED) ||
-					switch_channel_get_state(peer_channels[i]) == CS_RESET ||
-					!switch_channel_test_flag(peer_channels[i], CF_ORIGINATING)
+					switch_channel_get_state(peer_channels[i]) == CS_RESET || !switch_channel_test_flag(peer_channels[i], CF_ORIGINATING)
 					) {
 					continue;
 				}
@@ -1194,8 +1191,8 @@
 				}
 			}
 
-			if (switch_channel_test_flag(peer_channel, CF_ANSWERED) || 
-				(early_ok && switch_channel_test_flag(peer_channel, CF_EARLY_MEDIA)) || 
+			if (switch_channel_test_flag(peer_channel, CF_ANSWERED) ||
+				(early_ok && switch_channel_test_flag(peer_channel, CF_EARLY_MEDIA)) ||
 				(return_ring_ready && switch_channel_test_flag(peer_channel, CF_RING_READY))
 				) {
 				*bleg = peer_session;
@@ -1275,7 +1272,7 @@
 				}
 				switch_core_codec_destroy(&write_codec);
 			}
-			
+
 
 			for (i = 0; i < and_argc; i++) {
 				if (!peer_channels[i]) {
@@ -1287,7 +1284,7 @@
 				}
 				switch_core_session_rwunlock(peer_sessions[i]);
 			}
-			
+
 			if (status == SWITCH_STATUS_SUCCESS) {
 				goto outer_for;
 			}
@@ -1301,7 +1298,7 @@
 		*bleg = NULL;
 	}
 
-	
+
 	if (var_event) {
 		switch_event_destroy(&var_event);
 	}

Modified: freeswitch/trunk/src/switch_ivr_play_say.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr_play_say.c	(original)
+++ freeswitch/trunk/src/switch_ivr_play_say.c	Tue May 27 00:30:03 2008
@@ -121,14 +121,14 @@
 
 	switch_event_create(&hint_data, SWITCH_EVENT_MESSAGE);
 	switch_assert(hint_data);
-	
+
 	switch_event_add_header_string(hint_data, SWITCH_STACK_BOTTOM, "macro_name", macro_name);
 	switch_event_add_header_string(hint_data, SWITCH_STACK_BOTTOM, "lang", chan_lang);
 	if (data) {
 		switch_event_add_header_string(hint_data, SWITCH_STACK_BOTTOM, "data", data);
 	} else {
-        data = "";
-    }
+		data = "";
+	}
 	switch_channel_event_set_data(channel, hint_data);
 
 	if (switch_xml_locate("phrases", NULL, NULL, NULL, &xml, &cfg, hint_data) != SWITCH_STATUS_SUCCESS) {
@@ -170,7 +170,7 @@
 	if (!(tts_engine = (char *) switch_xml_attr(language, "tts-engine"))) {
 		tts_engine = (char *) switch_xml_attr(language, "tts_engine");
 	}
-	
+
 	if (!(tts_voice = (char *) switch_xml_attr(language, "tts-voice"))) {
 		tts_voice = (char *) switch_xml_attr(language, "tts_voice");
 	}
@@ -210,7 +210,7 @@
 	while (input && !done) {
 		char *pattern = (char *) switch_xml_attr(input, "pattern");
 		const char *do_break = switch_xml_attr_soft(input, "break_on_match");
-		
+
 		if (pattern) {
 			switch_regex_t *re = NULL;
 			int proceed = 0, ovector[30];
@@ -221,7 +221,7 @@
 			switch_xml_t match = NULL;
 
 			status = SWITCH_STATUS_SUCCESS;
-			
+
 			if ((proceed = switch_regex_perform(data, pattern, &re, ovector, sizeof(ovector) / sizeof(ovector[0])))) {
 				match = switch_xml_child(input, "match");
 			} else {
@@ -233,7 +233,7 @@
 				for (action = switch_xml_child(match, "action"); action && status == SWITCH_STATUS_SUCCESS; action = action->next) {
 					char *adata = (char *) switch_xml_attr_soft(action, "data");
 					char *func = (char *) switch_xml_attr_soft(action, "function");
-					
+
 					if (strchr(pattern, '(') && strchr(adata, '$')) {
 						len = (uint32_t) (strlen(data) + strlen(adata) + 10);
 						if (!(substituted = malloc(len))) {
@@ -278,7 +278,7 @@
 
 						cmd_args = switch_separate_paren_args(cmd);
 
-						if (!cmd_args ) {
+						if (!cmd_args) {
 							cmd_args = "";
 						}
 
@@ -293,14 +293,16 @@
 							char *say_type = (char *) switch_xml_attr_soft(action, "type");
 							char *say_method = (char *) switch_xml_attr_soft(action, "method");
 
-							status = si->say_function(session, odata, switch_ivr_get_say_type_by_name(say_type), switch_ivr_get_say_method_by_name(say_method), args);
+							status =
+								si->say_function(session, odata, switch_ivr_get_say_type_by_name(say_type), switch_ivr_get_say_method_by_name(say_method),
+												 args);
 						} else {
 							switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid SAY Interface [%s]!\n", module_name);
 						}
 					} else if (!strcasecmp(func, "speak-text")) {
 						const char *my_tts_engine = switch_xml_attr(action, "tts-engine");
 						const char *my_tts_voice = switch_xml_attr(action, "tts-voice");
-						
+
 						if (!my_tts_engine) {
 							my_tts_engine = tts_engine;
 						}
@@ -321,11 +323,11 @@
 			switch_safe_free(expanded);
 			switch_safe_free(substituted);
 
-			
+
 			if (match && do_break && switch_true(do_break)) {
 				break;
 			}
-			
+
 		}
 
 		if (status != SWITCH_STATUS_SUCCESS) {
@@ -337,7 +339,7 @@
 	}
 
   done:
-	
+
 	if (hint_data) {
 		switch_event_destroy(&hint_data);
 	}
@@ -360,7 +362,7 @@
 													   switch_file_handle_t *fh, const char *file, switch_input_args_t *args, uint32_t limit)
 {
 	switch_channel_t *channel = switch_core_session_get_channel(session);
-	switch_dtmf_t dtmf = {0};
+	switch_dtmf_t dtmf = { 0 };
 	switch_file_handle_t lfh = { 0 };
 	switch_frame_t *read_frame;
 	switch_codec_t codec, *read_codec = switch_core_session_get_read_codec(session);
@@ -463,9 +465,9 @@
 		org_silence_hits = fh->silence_hits;
 	}
 
-	for(;;) {
+	for (;;) {
 		switch_size_t len;
-		
+
 		if (!switch_channel_ready(channel)) {
 			status = SWITCH_STATUS_FALSE;
 			break;
@@ -476,7 +478,7 @@
 			status = SWITCH_STATUS_BREAK;
 			break;
 		}
-		
+
 		if (switch_core_session_private_event_count(session)) {
 			switch_ivr_parse_all_events(session);
 		}
@@ -497,9 +499,9 @@
 				}
 				switch_channel_dequeue_dtmf(channel, &dtmf);
 				if (args->input_callback) {
-					status = args->input_callback(session, (void *)&dtmf, SWITCH_INPUT_TYPE_DTMF, args->buf, args->buflen);
+					status = args->input_callback(session, (void *) &dtmf, SWITCH_INPUT_TYPE_DTMF, args->buf, args->buflen);
 				} else {
-					switch_copy_string((char *) args->buf, (void *)&dtmf, args->buflen);
+					switch_copy_string((char *) args->buf, (void *) &dtmf, args->buflen);
 					status = SWITCH_STATUS_BREAK;
 				}
 			}
@@ -535,7 +537,7 @@
 			uint32_t score, count = 0, j = 0;
 			double energy = 0;
 			int divisor = 0;
-			
+
 			for (count = 0; count < samples; count++) {
 				energy += abs(fdata[j]);
 				j += read_codec->implementation->number_of_channels;
@@ -544,7 +546,7 @@
 			if (!(divisor = read_codec->implementation->actual_samples_per_second / 8000)) {
 				divisor = 1;
 			}
-			
+
 			score = (uint32_t) (energy / (samples / divisor));
 			if (score < fh->thresh) {
 				if (!--fh->silence_hits) {
@@ -558,7 +560,7 @@
 		if (!switch_test_flag(fh, SWITCH_FILE_PAUSE) && !switch_test_flag(read_frame, SFF_CNG)) {
 			int16_t *data = read_frame->data;
 			len = (switch_size_t) read_frame->datalen / 2;
-			
+
 			if (switch_core_file_write(fh, data, &len) != SWITCH_STATUS_SUCCESS) {
 				break;
 			}
@@ -571,7 +573,7 @@
 	return status;
 }
 
-static int teletone_handler(teletone_generation_session_t * ts, teletone_tone_map_t * map)
+static int teletone_handler(teletone_generation_session_t *ts, teletone_tone_map_t *map)
 {
 	switch_buffer_t *audio_buffer = ts->user_data;
 	int wrote;
@@ -589,7 +591,7 @@
 SWITCH_DECLARE(switch_status_t) switch_ivr_gentones(switch_core_session_t *session, char *script, int32_t loops, switch_input_args_t *args)
 {
 	teletone_generation_session_t ts;
-	switch_dtmf_t dtmf = {0};
+	switch_dtmf_t dtmf = { 0 };
 	switch_buffer_t *audio_buffer;
 	switch_frame_t *read_frame = NULL;
 	switch_codec_t *read_codec = NULL, write_codec = { 0 };
@@ -599,13 +601,13 @@
 
 	switch_channel_pre_answer(channel);
 	read_codec = switch_core_session_get_read_codec(session);
-	
+
 	if (switch_core_codec_init(&write_codec,
 							   "L16",
 							   NULL,
 							   read_codec->implementation->actual_samples_per_second,
 							   read_codec->implementation->microseconds_per_frame / 1000,
-							   1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, 
+							   1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
 							   NULL, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
 
 		return SWITCH_STATUS_FALSE;
@@ -624,14 +626,14 @@
 		switch_buffer_set_loops(audio_buffer, loops);
 	}
 
-	for(;;) {
+	for (;;) {
 		int done = 0;
 		switch_status_t status;
-		
+
 		if (!switch_channel_ready(channel)) {
-            status = SWITCH_STATUS_FALSE;
-            break;
-        }
+			status = SWITCH_STATUS_FALSE;
+			break;
+		}
 
 		if (switch_channel_test_flag(channel, CF_BREAK)) {
 			switch_channel_clear_flag(channel, CF_BREAK);
@@ -658,9 +660,9 @@
 				}
 				switch_channel_dequeue_dtmf(channel, &dtmf);
 				if (args->input_callback) {
-					status = args->input_callback(session, (void *)&dtmf, SWITCH_INPUT_TYPE_DTMF, args->buf, args->buflen);
+					status = args->input_callback(session, (void *) &dtmf, SWITCH_INPUT_TYPE_DTMF, args->buf, args->buflen);
 				} else {
-					*((char *)args->buf) = dtmf.digit;
+					*((char *) args->buf) = dtmf.digit;
 					status = SWITCH_STATUS_BREAK;
 				}
 			}
@@ -680,13 +682,12 @@
 			}
 		}
 
-		if ((write_frame.datalen = (uint32_t) switch_buffer_read_loop(audio_buffer, write_frame.data,
-																	  read_codec->implementation->bytes_per_frame)) <= 0) {
+		if ((write_frame.datalen = (uint32_t) switch_buffer_read_loop(audio_buffer, write_frame.data, read_codec->implementation->bytes_per_frame)) <= 0) {
 			break;
 		}
 
 		write_frame.samples = write_frame.datalen / 2;
-		
+
 		if (switch_core_session_write_frame(session, &write_frame, SWITCH_IO_FLAG_NONE, 0) != SWITCH_STATUS_SUCCESS) {
 			break;
 		}
@@ -708,7 +709,7 @@
 {
 	switch_channel_t *channel = switch_core_session_get_channel(session);
 	int16_t *abuf = NULL;
-	switch_dtmf_t dtmf = {0};
+	switch_dtmf_t dtmf = { 0 };
 	uint32_t interval = 0, samples = 0, framelen, sample_start = 0;
 	uint32_t ilen = 0;
 	switch_size_t olen = 0, llen = 0;
@@ -750,7 +751,7 @@
 			const char *lang = switch_channel_get_variable(channel, "language");
 			alt = file + 7;
 			dup = switch_core_session_strdup(session, alt);
-			
+
 			if (dup) {
 				if ((arg = strchr(dup, ':'))) {
 					*arg++ = '\0';
@@ -763,7 +764,7 @@
 		} else if (!strncasecmp(file, "say:", 4)) {
 			char *engine = NULL, *voice = NULL, *text = NULL;
 			alt = file + 4;
-            dup = switch_core_session_strdup(session, alt);
+			dup = switch_core_session_strdup(session, alt);
 			engine = dup;
 
 			if (!switch_strlen_zero(engine)) {
@@ -779,8 +780,8 @@
 				return switch_ivr_speak_text(session, engine, voice, text, args);
 			} else if (!switch_strlen_zero(engine) && !(voice && text)) {
 				text = engine;
-				engine = (char *)switch_channel_get_variable(channel, "tts_engine");
-				voice = (char *)switch_channel_get_variable(channel, "tts_voice");
+				engine = (char *) switch_channel_get_variable(channel, "tts_engine");
+				voice = (char *) switch_channel_get_variable(channel, "tts_voice");
 				if (engine && text) {
 					return switch_ivr_speak_text(session, engine, voice, text, args);
 				}
@@ -789,7 +790,7 @@
 				return SWITCH_STATUS_FALSE;
 			}
 		}
-		
+
 	}
 
 	if (!prefix) {
@@ -946,15 +947,15 @@
 
 	ilen = samples;
 
-	for(;;) {
+	for (;;) {
 		int done = 0;
 		int do_speed = 1;
 		int last_speed = -1;
 
 		if (!switch_channel_ready(channel)) {
-            status = SWITCH_STATUS_FALSE;
-            break;
-        }
+			status = SWITCH_STATUS_FALSE;
+			break;
+		}
 
 		if (switch_channel_test_flag(channel, CF_BREAK)) {
 			switch_channel_clear_flag(channel, CF_BREAK);
@@ -979,9 +980,9 @@
 				}
 				switch_channel_dequeue_dtmf(channel, &dtmf);
 				if (args->input_callback) {
-					status = args->input_callback(session, (void *)&dtmf, SWITCH_INPUT_TYPE_DTMF, args->buf, args->buflen);
+					status = args->input_callback(session, (void *) &dtmf, SWITCH_INPUT_TYPE_DTMF, args->buf, args->buflen);
 				} else {
-					*((char *)args->buf) = dtmf.digit;
+					*((char *) args->buf) = dtmf.digit;
 					status = SWITCH_STATUS_BREAK;
 				}
 			}
@@ -1062,7 +1063,7 @@
 				supplement = 1;
 			}
 			newlen = (fh->speed > 0) ? olen - supplement : olen + supplement;
-			
+
 			step = (fh->speed > 0) ? (newlen / supplement) : (olen / supplement);
 
 			if (!fh->sp_audio_buffer) {
@@ -1099,10 +1100,10 @@
 			olen = llen;
 		}
 
-		write_frame.samples = (uint32_t)olen;
+		write_frame.samples = (uint32_t) olen;
 
 		if (asis) {
-			write_frame.datalen = (uint32_t)olen;
+			write_frame.datalen = (uint32_t) olen;
 		} else {
 			write_frame.datalen = write_frame.samples * 2;
 		}
@@ -1125,7 +1126,7 @@
 
 		fh->offset_pos += write_frame.samples / 2;
 		status = switch_core_session_write_frame(session, &write_frame, SWITCH_IO_FLAG_NONE, 0);
-		
+
 		if (status == SWITCH_STATUS_MORE_DATA) {
 			status = SWITCH_STATUS_SUCCESS;
 			continue;
@@ -1150,7 +1151,7 @@
 			}
 
 			tstatus = switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
-			
+
 			if (!SWITCH_READ_ACCEPTABLE(tstatus)) {
 				break;
 			}
@@ -1171,7 +1172,7 @@
 
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "done playing file\n");
 	switch_core_file_seek(fh, &fh->last_pos, 0, SEEK_CUR);
-	
+
 	switch_core_file_close(fh);
 	switch_buffer_destroy(&fh->audio_buffer);
 	switch_buffer_destroy(&fh->sp_audio_buffer);
@@ -1185,7 +1186,7 @@
 	}
 
 
- end:
+  end:
 	switch_safe_free(abuf);
 
 	switch_core_session_reset(session, SWITCH_TRUE);
@@ -1197,10 +1198,7 @@
 												uint32_t max_digits,
 												const char *prompt_audio_file,
 												const char *var_name,
-												char *digit_buffer, 
-												switch_size_t digit_buffer_length,
-												uint32_t timeout,
-												const char *valid_terminators)
+												char *digit_buffer, switch_size_t digit_buffer_length, uint32_t timeout, const char *valid_terminators)
 {
 	switch_channel_t *channel;
 	switch_input_args_t args = { 0 };
@@ -1221,34 +1219,34 @@
 
 	memset(digit_buffer, 0, digit_buffer_length);
 	args.buf = digit_buffer;
-	args.buflen = (uint32_t)digit_buffer_length;
+	args.buflen = (uint32_t) digit_buffer_length;
 
 	if (!switch_strlen_zero(prompt_audio_file) && strcasecmp(prompt_audio_file, "silence")) {
 		status = switch_ivr_play_file(session, NULL, prompt_audio_file, &args);
 	}
-	
+
 	if (status != SWITCH_STATUS_SUCCESS && status != SWITCH_STATUS_BREAK) {
 		goto end;
 	}
 
 	len = strlen(digit_buffer);
-	
+
 
 	if (len < min_digits && len < max_digits) {
 		args.buf = digit_buffer + len;
-		args.buflen = (uint32_t)(digit_buffer_length - len);
+		args.buflen = (uint32_t) (digit_buffer_length - len);
 		status = switch_ivr_collect_digits_count(session, digit_buffer, digit_buffer_length, max_digits, valid_terminators, &terminator, timeout, 0, 0);
 	}
 
-	
- end:
+
+  end:
 
 	if (var_name && !switch_strlen_zero(digit_buffer)) {
 		switch_channel_set_variable(channel, var_name, digit_buffer);
 	}
 
 	return status;
-	
+
 }
 
 
@@ -1357,7 +1355,7 @@
 		}
 	}
 
- done:
+  done:
 	//if we got here, we got no digits or lost the channel
 	digit_buffer = "\0";
 	return SWITCH_STATUS_FALSE;
@@ -1370,7 +1368,7 @@
 {
 	switch_channel_t *channel = switch_core_session_get_channel(session);
 	short abuf[960];
-	switch_dtmf_t dtmf = {0};
+	switch_dtmf_t dtmf = { 0 };
 	uint32_t len = 0;
 	switch_size_t ilen = 0;
 	switch_frame_t write_frame = { 0 };
@@ -1395,9 +1393,9 @@
 	write_frame.buflen = sizeof(abuf);
 
 	len = sh->samples * 2;
-	
+
 	flags = 0;
-	
+
 	if (!(star = switch_channel_get_variable(channel, "star_replace"))) {
 		star = "star";
 	}
@@ -1408,7 +1406,7 @@
 	poundlen = strlen(pound);
 
 
-	for(p = text; p && *p; p++) {
+	for (p = text; p && *p; p++) {
 		if (*p == '*') {
 			extra += starlen;
 		} else if (*p == '#') {
@@ -1429,14 +1427,14 @@
 			if (*p == '*') {
 				strncat(tp, star, starlen);
 				tp += starlen;
-			} else  if (*p == '#') {
+			} else if (*p == '#') {
 				strncat(tp, pound, poundlen);
 				tp += poundlen;
 			} else {
 				*tp++ = *p;
 			}
 		}
-		
+
 		text = tmp;
 	}
 
@@ -1466,13 +1464,13 @@
 	}
 
 	ilen = len;
-	for(;;) {
+	for (;;) {
 		switch_event_t *event;
 
 		if (!switch_channel_ready(channel)) {
-            status = SWITCH_STATUS_FALSE;
-            break;
-        }
+			status = SWITCH_STATUS_FALSE;
+			break;
+		}
 
 		if (switch_channel_test_flag(channel, CF_BREAK)) {
 			switch_channel_clear_flag(channel, CF_BREAK);
@@ -1628,7 +1626,7 @@
 };
 typedef struct cached_speech_handle cached_speech_handle_t;
 
-SWITCH_DECLARE(void) switch_ivr_clear_speech_cache(switch_core_session_t *session) 
+SWITCH_DECLARE(void) switch_ivr_clear_speech_cache(switch_core_session_t *session)
 {
 	cached_speech_handle_t *cache_obj = NULL;
 	switch_channel_t *channel = switch_core_session_get_channel(session);
@@ -1698,13 +1696,13 @@
 
 	switch_core_session_reset(session, SWITCH_TRUE);
 	read_codec = switch_core_session_get_read_codec(session);
-	
+
 	rate = read_codec->implementation->actual_samples_per_second;
 	interval = read_codec->implementation->microseconds_per_frame / 1000;
-	
+
 	if (need_create) {
 		memset(sh, 0, sizeof(*sh));
-		if (switch_core_speech_open(sh, tts_name, voice_name, (uint32_t) rate, interval, 
+		if (switch_core_speech_open(sh, tts_name, voice_name, (uint32_t) rate, interval,
 									&flags, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid TTS module!\n");
 			switch_core_session_reset(session, SWITCH_TRUE);
@@ -1727,7 +1725,8 @@
 	if (need_create) {
 		if (switch_core_codec_init(codec,
 								   codec_name,
-								   NULL, (int) rate, interval, 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, pool) == SWITCH_STATUS_SUCCESS) {
+								   NULL, (int) rate, interval, 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,
+								   pool) == 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 %s@%uhz 1 channel %dms\n", codec_name, rate, interval);
@@ -1740,7 +1739,7 @@
 			return SWITCH_STATUS_GENERR;
 		}
 	}
-	
+
 	write_frame.codec = codec;
 
 	if (timer_name) {
@@ -1762,7 +1761,7 @@
 		switch_core_service_session(session, &thread_session, 0);
 
 	}
-	
+
 	status = switch_ivr_speak_text_handle(session, sh, write_frame.codec, timer_name ? timer : NULL, text, args);
 	flags = 0;
 
@@ -1790,8 +1789,8 @@
 
 	switch (itype) {
 	case SWITCH_INPUT_TYPE_DTMF:
-        {
-            switch_dtmf_t *dtmf = (switch_dtmf_t *) input;
+		{
+			switch_dtmf_t *dtmf = (switch_dtmf_t *) input;
 			if (dtmf->digit == *stop_key) {
 				return SWITCH_STATUS_BREAK;
 			}
@@ -1813,8 +1812,8 @@
 	switch_input_args_t args = { 0 };
 	args.input_callback = hold_on_dtmf;
 	args.buf = (void *) unhold_key;
-	args.buflen = (uint32_t)strlen(unhold_key);
-	
+	args.buflen = (uint32_t) strlen(unhold_key);
+
 	switch_assert(session != NULL);
 	channel = switch_core_session_get_channel(session);
 	switch_assert(channel != NULL);
@@ -1825,7 +1824,7 @@
 			other_channel = switch_core_session_get_channel(other_session);
 
 			if (moh_b) {
-				moh = moh_b; 
+				moh = moh_b;
 			} else {
 				moh = switch_channel_get_variable(other_channel, "hold_music");
 			}
@@ -1834,18 +1833,18 @@
 				switch_ivr_broadcast(other_uuid, moh, SMF_ECHO_ALEG | SMF_LOOP);
 				moh_br++;
 			}
-			
+
 			if (moh_a) {
 				moh = moh_a;
 			} else {
 				moh = switch_channel_get_variable(channel, "hold_music");
 			}
-			
+
 			if (!switch_strlen_zero(moh) && strcasecmp(moh, "silence")) {
 				switch_ivr_play_file(session, NULL, moh, &args);
 			} else {
 				switch_ivr_collect_digits_callback(session, &args, 0);
-			}	
+			}
 
 			if (moh_br) {
 				switch_channel_stop_broadcast(other_channel);
@@ -1856,9 +1855,9 @@
 
 			return SWITCH_STATUS_SUCCESS;
 		}
-		
+
 	}
-	
+
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Channel %s is not in a bridge\n", switch_channel_get_name(channel));
 	return SWITCH_STATUS_FALSE;
 

Modified: freeswitch/trunk/src/switch_loadable_module.c
==============================================================================
--- freeswitch/trunk/src/switch_loadable_module.c	(original)
+++ freeswitch/trunk/src/switch_loadable_module.c	Tue May 27 00:30:03 2008
@@ -75,7 +75,7 @@
 static struct switch_loadable_module_container loadable_modules;
 static void do_shutdown(switch_loadable_module_t *module);
 
-static void *switch_loadable_module_exec(switch_thread_t * thread, void *obj)
+static void *switch_loadable_module_exec(switch_thread_t *thread, void *obj)
 {
 
 
@@ -126,7 +126,7 @@
 	switch_event_t *event;
 
 	new_module->key = switch_core_strdup(new_module->pool, key);
-	
+
 	switch_mutex_lock(loadable_modules.mutex);
 	switch_core_hash_insert(loadable_modules.module_hash, key, new_module);
 
@@ -155,13 +155,15 @@
 					if (!impl->iananame) {
 						load_interface = 0;
 						switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT,
-									  "Failed to load codec interface %s from %s due to no iana name in an implementation.\n", ptr->interface_name, key);
+										  "Failed to load codec interface %s from %s due to no iana name in an implementation.\n", ptr->interface_name,
+										  key);
 						break;
 					}
 					if (impl->bytes_per_frame > SWITCH_RECOMMENDED_BUFFER_SIZE) {
 						load_interface = 0;
 						switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT,
-									  "Failed to load codec interface %s from %s due to bytes per frame exceeding buffer size.\n", ptr->interface_name, key);
+										  "Failed to load codec interface %s from %s due to bytes per frame exceeding buffer size.\n", ptr->interface_name,
+										  key);
 						break;
 					}
 				}
@@ -590,7 +592,7 @@
 		const switch_chat_interface_t *ptr;
 
 		for (ptr = old_module->module_interface->chat_interface; ptr; ptr = ptr->next) {
-			if (ptr->interface_name) {				
+			if (ptr->interface_name) {
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Deleting Chat interface '%s'\n", ptr->interface_name);
 				if (switch_event_create(&event, SWITCH_EVENT_MODULE_UNLOAD) == SWITCH_STATUS_SUCCESS) {
 					switch_event_add_header(event, SWITCH_STACK_BOTTOM, "type", "%s", "chat");
@@ -718,12 +720,12 @@
 		}
 
 		if (status == SWITCH_STATUS_NOUNLOAD) {
-            module->perm++;
-        }
-		
+			module->perm++;
+		}
+
 		loading = 0;
 	}
-	
+
 
 	if (err) {
 		if (pool) {
@@ -778,7 +780,7 @@
 
 	if (switch_is_file_path(file)) {
 		path = switch_core_strdup(loadable_modules.pool, file);
-		file = (char *)switch_cut_path(file);
+		file = (char *) switch_cut_path(file);
 		if ((dot = strchr(file, '.'))) {
 			dot = '\0';
 		}
@@ -841,8 +843,7 @@
 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_bool_t runtime)
+																	 switch_module_shutdown_t switch_module_shutdown, switch_bool_t runtime)
 {
 	switch_loadable_module_t *module = NULL;
 	switch_module_load_t load_func_ptr = NULL;
@@ -851,7 +852,7 @@
 	switch_loadable_module_interface_t *module_interface = NULL;
 	switch_memory_pool_t *pool;
 
-	
+
 	if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "OH OH no pool\n");
 		abort();
@@ -1058,7 +1059,7 @@
 		}
 		apr_dir_close(module_dir_handle);
 	}
-	
+
 	switch_loadable_module_runtime();
 
 	return SWITCH_STATUS_SUCCESS;
@@ -1093,7 +1094,7 @@
 	switch_hash_index_t *hi;
 	void *val;
 	switch_loadable_module_t *module;
-	
+
 	for (hi = switch_hash_first(NULL, loadable_modules.module_hash); hi; hi = switch_hash_next(hi)) {
 		switch_hash_this(hi, NULL, NULL, &val);
 		module = (switch_loadable_module_t *) val;
@@ -1227,7 +1228,7 @@
 		/* oh well we will use what we have */
 		array[i++] = codec_interface->implementations;
 
-	found:
+	  found:
 
 		if (i > arraylen) {
 			break;
@@ -1235,7 +1236,7 @@
 	}
 
 	switch_mutex_unlock(loadable_modules.mutex);
-	
+
 	return i;
 
 }
@@ -1247,7 +1248,7 @@
 	const switch_codec_implementation_t *imp;
 
 	switch_mutex_lock(loadable_modules.mutex);
-	
+
 	for (x = 0; x < preflen; x++) {
 		char *cur, *last = NULL, *next = NULL, *name, *p, buf[256];
 		uint32_t interval = 0, rate = 8000;
@@ -1259,7 +1260,7 @@
 			if (!next) {
 				break;
 			}
-			
+
 			if ((p = strchr(next, '@'))) {
 				*p++ = '\0';
 			}
@@ -1318,7 +1319,7 @@
 				}
 			}
 
-		found:
+		  found:
 
 			if (i > arraylen) {
 				break;
@@ -1327,7 +1328,7 @@
 	}
 
 	switch_mutex_unlock(loadable_modules.mutex);
-	
+
 
 	return i;
 }
@@ -1383,7 +1384,7 @@
 	mod->pool = pool;
 
 	mod->module_name = switch_core_strdup(mod->pool, name);
-	
+
 	return mod;
 }
 
@@ -1404,46 +1405,46 @@
 SWITCH_DECLARE(void *) switch_loadable_module_create_interface(switch_loadable_module_interface_t *mod, switch_module_interface_name_t iname)
 {
 
-	switch(iname) {
+	switch (iname) {
 	case SWITCH_ENDPOINT_INTERFACE:
 		ALLOC_INTERFACE(endpoint)
 
 	case SWITCH_TIMER_INTERFACE:
 		ALLOC_INTERFACE(timer)
-		
+
 	case SWITCH_DIALPLAN_INTERFACE:
 		ALLOC_INTERFACE(dialplan)
-		
+
 	case SWITCH_CODEC_INTERFACE:
 		ALLOC_INTERFACE(codec)
-		
+
 	case SWITCH_APPLICATION_INTERFACE:
 		ALLOC_INTERFACE(application)
-		
+
 	case SWITCH_API_INTERFACE:
 		ALLOC_INTERFACE(api)
-		
+
 	case SWITCH_FILE_INTERFACE:
 		ALLOC_INTERFACE(file)
-		
+
 	case SWITCH_SPEECH_INTERFACE:
 		ALLOC_INTERFACE(speech)
-		
+
 	case SWITCH_DIRECTORY_INTERFACE:
 		ALLOC_INTERFACE(directory)
-		
+
 	case SWITCH_CHAT_INTERFACE:
 		ALLOC_INTERFACE(chat)
-		
+
 	case SWITCH_SAY_INTERFACE:
 		ALLOC_INTERFACE(say)
-		
+
 	case SWITCH_ASR_INTERFACE:
 		ALLOC_INTERFACE(asr)
-		
+
 	case SWITCH_MANAGEMENT_INTERFACE:
 		ALLOC_INTERFACE(management)
-		
+
 	default:
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid Module Type!\n");
 		return NULL;

Modified: freeswitch/trunk/src/switch_log.c
==============================================================================
--- freeswitch/trunk/src/switch_log.c	(original)
+++ freeswitch/trunk/src/switch_log.c	Tue May 27 00:30:03 2008
@@ -145,7 +145,7 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static void *SWITCH_THREAD_FUNC log_thread(switch_thread_t * thread, void *obj)
+static void *SWITCH_THREAD_FUNC log_thread(switch_thread_t *thread, void *obj)
 {
 
 	if (!obj) {
@@ -174,7 +174,7 @@
 			}
 		}
 		switch_mutex_unlock(BINDLOCK);
-		
+
 		switch_safe_free(node->data);
 		if (switch_queue_trypush(LOG_RECYCLE_QUEUE, node) != SWITCH_STATUS_SUCCESS) {
 			free(node);
@@ -263,13 +263,13 @@
 			fd_set can_write;
 			int fd;
 			struct timeval to;
-					
+
 			fd = fileno(handle);
 			memset(&to, 0, sizeof(to));
 			FD_SET(fd, &can_write);
 			to.tv_sec = 0;
 			to.tv_usec = 100000;
-			if (select(fd+1, NULL, &can_write, NULL, &to) > 0) {
+			if (select(fd + 1, NULL, &can_write, NULL, &to) > 0) {
 				aok = FD_ISSET(fd, &can_write);
 			} else {
 				aok = 0;
@@ -287,7 +287,7 @@
 			node = (switch_log_node_t *) pop;
 		} else {
 			node = malloc(sizeof(*node));
-			switch_assert(node);			
+			switch_assert(node);
 		}
 
 		node->data = data;
@@ -308,8 +308,8 @@
 			node = NULL;
 		}
 	}
-	
- end:
+
+  end:
 
 	switch_safe_free(data);
 	switch_safe_free(new_fmt);
@@ -347,7 +347,8 @@
 {
 	void *pop;
 	int size = switch_queue_size(LOG_RECYCLE_QUEUE);
-	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Returning %d recycled log node(s) %d bytes\n", size, (int)sizeof(switch_log_node_t) * size);
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Returning %d recycled log node(s) %d bytes\n", size,
+					  (int) sizeof(switch_log_node_t) * size);
 	while (switch_queue_trypop(LOG_RECYCLE_QUEUE, &pop) == SWITCH_STATUS_SUCCESS) {
 		free(pop);
 	}
@@ -362,7 +363,7 @@
 		switch_yield(1000);
 	}
 	switch_core_memory_reclaim_logger();
-	
+
 	return SWITCH_STATUS_SUCCESS;
 }
 

Modified: freeswitch/trunk/src/switch_odbc.c
==============================================================================
--- freeswitch/trunk/src/switch_odbc.c	(original)
+++ freeswitch/trunk/src/switch_odbc.c	Tue May 27 00:30:03 2008
@@ -50,7 +50,7 @@
 	if (!(new_handle = malloc(sizeof(*new_handle)))) {
 		goto err;
 	}
-	
+
 	memset(new_handle, 0, sizeof(*new_handle));
 
 	if (!(new_handle->dsn = strdup(dsn))) {
@@ -96,7 +96,7 @@
 		} else {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Disconnectiong [%s]\n", handle->dsn);
 		}
-	} 
+	}
 
 	handle->state = SWITCH_ODBC_STATE_DOWN;
 
@@ -143,19 +143,21 @@
 	}
 
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Connecting %s\n", handle->dsn);
-	
-	if(!strstr(handle->dsn, "DRIVER")) { 
-		result = SQLConnect(handle->con, (SQLCHAR *) handle->dsn, SQL_NTS, (SQLCHAR *) handle->username, SQL_NTS, (SQLCHAR *) handle->password, SQL_NTS); 
-	} else { 
-		SQLCHAR outstr[1024] = {0}; 
-		SQLSMALLINT outstrlen = 0; 
-		result = SQLDriverConnect(handle->con, NULL, (SQLCHAR *) handle->dsn, (SQLSMALLINT)strlen(handle->dsn), outstr, sizeof(outstr), &outstrlen, SQL_DRIVER_NOPROMPT); 
-	} 
+
+	if (!strstr(handle->dsn, "DRIVER")) {
+		result = SQLConnect(handle->con, (SQLCHAR *) handle->dsn, SQL_NTS, (SQLCHAR *) handle->username, SQL_NTS, (SQLCHAR *) handle->password, SQL_NTS);
+	} else {
+		SQLCHAR outstr[1024] = { 0 };
+		SQLSMALLINT outstrlen = 0;
+		result =
+			SQLDriverConnect(handle->con, NULL, (SQLCHAR *) handle->dsn, (SQLSMALLINT) strlen(handle->dsn), outstr, sizeof(outstr), &outstrlen,
+							 SQL_DRIVER_NOPROMPT);
+	}
 
 	if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) {
 		char *err_str;
 		if ((err_str = switch_odbc_handle_get_error(handle, NULL))) {
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%s\n",err_str);
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%s\n", err_str);
 			free(err_str);
 		} else {
 			SQLGetDiagRec(SQL_HANDLE_DBC, handle->con, 1, stat, &err, msg, 100, &mlen);
@@ -165,10 +167,10 @@
 		return SWITCH_ODBC_FAIL;
 	}
 
-	result = SQLGetInfo(handle->con, SQL_DRIVER_NAME, (SQLCHAR*)handle->odbc_driver, 255, &valueLength);
-	if ( result == SQL_SUCCESS || result == SQL_SUCCESS_WITH_INFO) {
+	result = SQLGetInfo(handle->con, SQL_DRIVER_NAME, (SQLCHAR *) handle->odbc_driver, 255, &valueLength);
+	if (result == SQL_SUCCESS || result == SQL_SUCCESS_WITH_INFO) {
 		for (i = 0; i < valueLength; ++i)
-			handle->odbc_driver[i] = (char)toupper(handle->odbc_driver[i]);
+			handle->odbc_driver[i] = (char) toupper(handle->odbc_driver[i]);
 	}
 
 	if (strstr(handle->odbc_driver, "FIREBIRD") != 0 || strstr(handle->odbc_driver, "FB32") != 0 || strstr(handle->odbc_driver, "FB64") != 0) {
@@ -194,28 +196,28 @@
 	SQLCHAR sql[255] = "";
 	int max_tries = 120;
 
- top:
-	
+  top:
+
 	if (!handle) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "No DB Handle\n");
 		goto done;
 	}
 
 	if (handle->is_firebird) {
-		strcpy((char*)sql, "select first 1 * from RDB$RELATIONS");
+		strcpy((char *) sql, "select first 1 * from RDB$RELATIONS");
 	} else {
-		strcpy((char*)sql, "select 1");
+		strcpy((char *) sql, "select 1");
 	}
 
-    if (SQLAllocHandle(SQL_HANDLE_STMT, handle->con, &stmt) != SQL_SUCCESS) {
-        goto error;
-    }
-	
-    if (SQLPrepare(stmt, sql, SQL_NTS) != SQL_SUCCESS) {
-        goto error;
-    }
-	
-    result = SQLExecute(stmt);
+	if (SQLAllocHandle(SQL_HANDLE_STMT, handle->con, &stmt) != SQL_SUCCESS) {
+		goto error;
+	}
+
+	if (SQLPrepare(stmt, sql, SQL_NTS) != SQL_SUCCESS) {
+		goto error;
+	}
+
+	result = SQLExecute(stmt);
 
 	SQLRowCount(stmt, &m);
 	ret = (int) m;
@@ -226,14 +228,14 @@
 
 	goto done;
 
- error:
+  error:
 	err_str = switch_odbc_handle_get_error(handle, stmt);
 	recon = switch_odbc_handle_connect(handle);
 
 	max_tries--;
 
 	if (switch_event_create(&event, SWITCH_EVENT_TRAP) == SWITCH_STATUS_SUCCESS) {
-		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Failure-Message", "The sql server is not responding for DSN %s [%s]", 
+		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Failure-Message", "The sql server is not responding for DSN %s [%s]",
 								switch_str_nil(handle->dsn), switch_str_nil(err_str));
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "The sql server is not responding for DSN %s [%s]\n",
 						  switch_str_nil(handle->dsn), switch_str_nil(err_str));
@@ -260,8 +262,8 @@
 	switch_safe_free(err_str);
 	switch_yield(1000000);
 	goto top;
-	
- done:
+
+  done:
 
 	switch_safe_free(err_str);
 
@@ -269,10 +271,10 @@
 		SQLFreeHandle(SQL_HANDLE_STMT, stmt);
 	}
 
-	return ret;	
+	return ret;
 }
 
-SWITCH_DECLARE(switch_odbc_status_t) switch_odbc_handle_exec(switch_odbc_handle_t *handle, char *sql, SQLHSTMT *rstmt)
+SWITCH_DECLARE(switch_odbc_status_t) switch_odbc_handle_exec(switch_odbc_handle_t *handle, char *sql, SQLHSTMT * rstmt)
 {
 	SQLHSTMT stmt = NULL;
 	int result;
@@ -280,7 +282,7 @@
 	if (!db_is_up(handle)) {
 		goto error;
 	}
-	
+
 	if (SQLAllocHandle(SQL_HANDLE_STMT, handle->con, &stmt) != SQL_SUCCESS) {
 		goto error;
 	}
@@ -303,13 +305,13 @@
 
 	return SWITCH_ODBC_SUCCESS;
 
- error:
+  error:
 	if (rstmt) {
-        *rstmt = stmt;
-    } else if (stmt) {
+		*rstmt = stmt;
+	} else if (stmt) {
 		SQLFreeHandle(SQL_HANDLE_STMT, stmt);
 	}
-	return SWITCH_ODBC_FAIL;	
+	return SWITCH_ODBC_FAIL;
 }
 
 SWITCH_DECLARE(switch_odbc_status_t) switch_odbc_handle_callback_exec(switch_odbc_handle_t *handle,
@@ -349,14 +351,14 @@
 			char **names;
 			char **vals;
 			int y = 0;
-		
+
 			if (!(result = SQLFetch(stmt)) == SQL_SUCCESS) {
 				goto error;
 			}
-		
+
 			names = calloc(c, sizeof(*names));
 			vals = calloc(c, sizeof(*vals));
-		
+
 			switch_assert(names && vals);
 
 			for (x = 1; x <= c; x++) {
@@ -365,7 +367,7 @@
 				names[y] = malloc(name_len);
 				memset(names[y], 0, name_len);
 
-				SQLDescribeCol(stmt, x, (SQLCHAR *) names[y], (SQLSMALLINT)name_len, &NameLength, &DataType, &ColumnSize, &DecimalDigits, &Nullable);
+				SQLDescribeCol(stmt, x, (SQLCHAR *) names[y], (SQLSMALLINT) name_len, &NameLength, &DataType, &ColumnSize, &DecimalDigits, &Nullable);
 				ColumnSize++;
 
 				vals[y] = malloc(ColumnSize);
@@ -373,7 +375,7 @@
 				SQLGetData(stmt, x, SQL_C_CHAR, (SQLCHAR *) vals[y], ColumnSize, NULL);
 				y++;
 			}
-		
+
 			if (callback(pdata, y, vals, names)) {
 				break;
 			}
@@ -435,8 +437,8 @@
 	SQLSMALLINT length;
 	char *ret = NULL;
 
-	if (SQLError(handle->env, handle->con, stmt, (SQLCHAR *)sqlstate, &sqlcode, (SQLCHAR *)buffer, sizeof(buffer), &length) == SQL_SUCCESS) {
-		ret = switch_mprintf("STATE: %s CODE %ld ERROR: %s\n", sqlstate,  sqlcode, buffer);
+	if (SQLError(handle->env, handle->con, stmt, (SQLCHAR *) sqlstate, &sqlcode, (SQLCHAR *) buffer, sizeof(buffer), &length) == SQL_SUCCESS) {
+		ret = switch_mprintf("STATE: %s CODE %ld ERROR: %s\n", sqlstate, sqlcode, buffer);
 	};
 
 	return ret;

Modified: freeswitch/trunk/src/switch_pcm.c
==============================================================================
--- freeswitch/trunk/src/switch_pcm.c	(original)
+++ freeswitch/trunk/src/switch_pcm.c	Tue May 27 00:30:03 2008
@@ -58,11 +58,10 @@
 										 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_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 && other_codec->implementation && 
+	if (codec && other_codec && codec->implementation && other_codec->implementation &&
 		codec->implementation->actual_samples_per_second != other_codec->implementation->actual_samples_per_second) {
 		memcpy(encoded_data, decoded_data, decoded_data_len);
 		*encoded_data_len = decoded_data_len;
@@ -75,8 +74,7 @@
 										 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_rate, void *decoded_data, uint32_t *decoded_data_len, uint32_t *decoded_rate, unsigned int *flag)
 {
 	if (codec && other_codec && codec->implementation && other_codec->implementation &&
 		codec->implementation->actual_samples_per_second != other_codec->implementation->actual_samples_per_second) {
@@ -100,21 +98,21 @@
 }
 
 static switch_status_t switch_proxy_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)
 {
 	return SWITCH_STATUS_FALSE;
 }
 
 static switch_status_t switch_proxy_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)
 {
 	return SWITCH_STATUS_FALSE;
 }
@@ -143,7 +141,7 @@
 										   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,
+										   uint32_t decoded_rate, void *encoded_data, uint32_t *encoded_data_len, uint32_t *encoded_rate,
 										   unsigned int *flag)
 {
 	short *dbuf;
@@ -166,7 +164,7 @@
 										   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,
+										   uint32_t encoded_rate, void *decoded_data, uint32_t *decoded_data_len, uint32_t *decoded_rate,
 										   unsigned int *flag)
 {
 	short *dbuf;
@@ -214,7 +212,7 @@
 										   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,
+										   uint32_t decoded_rate, void *encoded_data, uint32_t *encoded_data_len, uint32_t *encoded_rate,
 										   unsigned int *flag)
 {
 	short *dbuf;
@@ -237,7 +235,7 @@
 										   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,
+										   uint32_t encoded_rate, void *decoded_data, uint32_t *decoded_data_len, uint32_t *decoded_rate,
 										   unsigned int *flag)
 {
 	short *dbuf;
@@ -270,40 +268,39 @@
 static void mod_g711_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool)
 {
 	switch_codec_interface_t *codec_interface;
-    int mpf = 10000, spf = 80, bpf = 160, ebpf = 80, count;
+	int mpf = 10000, spf = 80, bpf = 160, ebpf = 80, count;
 
 	SWITCH_ADD_CODEC(codec_interface, "G.711 ulaw");
-    for (count = 12; count > 0; count--) {
-        switch_core_codec_add_implementation(pool, codec_interface,
-                                             SWITCH_CODEC_TYPE_AUDIO, 0, "PCMU", NULL, 8000, 8000, 64000,
-                                             mpf * count, spf * count, bpf * count, ebpf * count, 1, 1, 12,
-                                             switch_g711u_init, switch_g711u_encode, switch_g711u_decode, switch_g711u_destroy);
-    }
-    
+	for (count = 12; count > 0; count--) {
+		switch_core_codec_add_implementation(pool, codec_interface,
+											 SWITCH_CODEC_TYPE_AUDIO, 0, "PCMU", NULL, 8000, 8000, 64000,
+											 mpf * count, spf * count, bpf * count, ebpf * count, 1, 1, 12,
+											 switch_g711u_init, switch_g711u_encode, switch_g711u_decode, switch_g711u_destroy);
+	}
+
 	SWITCH_ADD_CODEC(codec_interface, "G.711 alaw");
-    for (count = 12; count > 0; count--) {
-        switch_core_codec_add_implementation(pool, codec_interface,
-                                             SWITCH_CODEC_TYPE_AUDIO, 8, "PCMA", NULL, 8000, 8000, 64000,
-                                             mpf * count, spf * count, bpf * count, ebpf * count, 1, 1, 12,
-                                             switch_g711a_init, switch_g711a_encode, switch_g711a_decode, switch_g711a_destroy);
-    }
+	for (count = 12; count > 0; count--) {
+		switch_core_codec_add_implementation(pool, codec_interface,
+											 SWITCH_CODEC_TYPE_AUDIO, 8, "PCMA", NULL, 8000, 8000, 64000,
+											 mpf * count, spf * count, bpf * count, ebpf * count, 1, 1, 12,
+											 switch_g711a_init, switch_g711a_encode, switch_g711a_decode, switch_g711a_destroy);
+	}
 
 }
 
 SWITCH_MODULE_LOAD_FUNCTION(core_pcm_load)
 {
 	switch_codec_interface_t *codec_interface;
-    int mpf = 10000, spf = 80, bpf = 160, ebpf = 160, bps = 128000, rate = 8000, counta = 1, countb = 12;
-    switch_payload_t ianacode[4] = { 0, 10, 117, 119 };
+	int mpf = 10000, spf = 80, bpf = 160, ebpf = 160, bps = 128000, rate = 8000, counta = 1, countb = 12;
+	switch_payload_t ianacode[4] = { 0, 10, 117, 119 };
 
 	/* connect my internal structure to the blank pointer passed to me */
 	*module_interface = switch_loadable_module_create_module_interface(pool, modname);
 
 	SWITCH_ADD_CODEC(codec_interface, "PROXY VIDEO PASS-THROUGH");
-    switch_core_codec_add_implementation(pool, codec_interface,
-                                         SWITCH_CODEC_TYPE_VIDEO, 31, "PROXY-VID", NULL, 90000, 90000, 0,
-                                         0, 0, 0, 0, 1, 1, 1,
-										 switch_proxy_init, switch_proxy_encode, switch_proxy_decode, switch_proxy_destroy);
+	switch_core_codec_add_implementation(pool, codec_interface,
+										 SWITCH_CODEC_TYPE_VIDEO, 31, "PROXY-VID", NULL, 90000, 90000, 0,
+										 0, 0, 0, 0, 1, 1, 1, switch_proxy_init, switch_proxy_encode, switch_proxy_decode, switch_proxy_destroy);
 
 
 	SWITCH_ADD_CODEC(codec_interface, "PROXY PASS-THROUGH");
@@ -311,34 +308,32 @@
 										 SWITCH_CODEC_TYPE_AUDIO, 0, "PROXY", NULL, 8000, 8000, 0,
 										 20000, 160, 320, 320, 1, 1, 12,
 										 switch_proxy_init, switch_proxy_encode, switch_proxy_decode, switch_proxy_destroy);
-	
+
 	SWITCH_ADD_CODEC(codec_interface, "RAW Signed Linear (16 bit)");
 
-    for (counta = 1; counta <= 3; counta++) {
-        for (countb = 12; countb > 0; countb--) {
-            switch_core_codec_add_implementation(pool, codec_interface,
-                                                 SWITCH_CODEC_TYPE_AUDIO, ianacode[counta], "L16", NULL, rate, rate, bps,
-                                                 mpf * countb, spf * countb, bpf * countb, ebpf * countb, 1, 1, 12,
-                                                 switch_raw_init, switch_raw_encode, switch_raw_decode, switch_raw_destroy);
-        }
-        rate = rate * 2;
-        bps = bps * 2;
-        spf = spf * 2;
-        bpf = bpf * 2;
-        ebpf = ebpf * 2;
-    }
+	for (counta = 1; counta <= 3; counta++) {
+		for (countb = 12; countb > 0; countb--) {
+			switch_core_codec_add_implementation(pool, codec_interface,
+												 SWITCH_CODEC_TYPE_AUDIO, ianacode[counta], "L16", NULL, rate, rate, bps,
+												 mpf * countb, spf * countb, bpf * countb, ebpf * countb, 1, 1, 12,
+												 switch_raw_init, switch_raw_encode, switch_raw_decode, switch_raw_destroy);
+		}
+		rate = rate * 2;
+		bps = bps * 2;
+		spf = spf * 2;
+		bpf = bpf * 2;
+		ebpf = ebpf * 2;
+	}
 	/* these formats below are for file playing. */
 
-    switch_core_codec_add_implementation(pool, codec_interface,
-                                         SWITCH_CODEC_TYPE_AUDIO, 118, "L16", NULL, 22050, 22050, 352800,
-                                         20000, 441, 882, 882, 1, 1, 1,
-                                         switch_raw_init, switch_raw_encode, switch_raw_decode, switch_raw_destroy);
-
-    switch_core_codec_add_implementation(pool, codec_interface,
-                                         SWITCH_CODEC_TYPE_AUDIO, 118, "L16", NULL, 11025, 11025, 176400,
-                                         40000, 441, 882, 882, 1, 1, 1,
-                                         switch_raw_init, switch_raw_encode, switch_raw_decode, switch_raw_destroy);
-    
+	switch_core_codec_add_implementation(pool, codec_interface,
+										 SWITCH_CODEC_TYPE_AUDIO, 118, "L16", NULL, 22050, 22050, 352800,
+										 20000, 441, 882, 882, 1, 1, 1, switch_raw_init, switch_raw_encode, switch_raw_decode, switch_raw_destroy);
+
+	switch_core_codec_add_implementation(pool, codec_interface,
+										 SWITCH_CODEC_TYPE_AUDIO, 118, "L16", NULL, 11025, 11025, 176400,
+										 40000, 441, 882, 882, 1, 1, 1, switch_raw_init, switch_raw_encode, switch_raw_decode, switch_raw_destroy);
+
 
 
 	/* indicate that the module should continue to be loaded */

Modified: freeswitch/trunk/src/switch_regex.c
==============================================================================
--- freeswitch/trunk/src/switch_regex.c	(original)
+++ freeswitch/trunk/src/switch_regex.c	Tue May 27 00:30:03 2008
@@ -34,11 +34,10 @@
 #include <pcre.h>
 
 SWITCH_DECLARE(switch_regex_t *) switch_regex_compile(const char *pattern,
-														 int options, const char **errorptr, int *erroroffset, 
-const unsigned char *tables) 
+													  int options, const char **errorptr, int *erroroffset, const unsigned char *tables)
 {
-	
-return pcre_compile(pattern, options, errorptr, erroroffset, tables);
+
+	return pcre_compile(pattern, options, errorptr, erroroffset, tables);
 
 }
 
@@ -51,7 +50,7 @@
 {
 	pcre_free(data);
 
-} 
+}
 
 SWITCH_DECLARE(int) switch_regex_perform(const char *field, const char *expression, switch_regex_t **new_re, int *ovector, uint32_t olen)
 {
@@ -87,7 +86,7 @@
 	}
 
 	re = pcre_compile(expression,	/* the pattern */
-					  flags,		/* default options */
+					  flags,	/* default options */
 					  &error,	/* for error message */
 					  &erroffset,	/* for error offset */
 					  NULL);	/* use default character tables */
@@ -114,7 +113,7 @@
 
 	*new_re = (switch_regex_t *) re;
 
- end:
+  end:
 	switch_safe_free(tmp);
 	return match_count;
 }

Modified: freeswitch/trunk/src/switch_resample.c
==============================================================================
--- freeswitch/trunk/src/switch_resample.c	(original)
+++ freeswitch/trunk/src/switch_resample.c	Tue May 27 00:30:03 2008
@@ -76,9 +76,9 @@
 	resampler->resampler = resample_open(QUALITY, resampler->factor, resampler->factor);
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Activate Resampler %d->%d %f\n", resampler->from_rate, resampler->to_rate,
 					  resampler->factor);
-	resampler->from_size = resample_buffer(to_rate, from_rate, (uint32_t)from_size);
+	resampler->from_size = resample_buffer(to_rate, from_rate, (uint32_t) from_size);
 	resampler->from = (float *) switch_core_alloc(pool, resampler->from_size * sizeof(float));
-	resampler->to_size = resample_buffer(to_rate, from_rate, (uint32_t)to_size); ;
+	resampler->to_size = resample_buffer(to_rate, from_rate, (uint32_t) to_size);;
 	resampler->to = (float *) switch_core_alloc(pool, resampler->to_size * sizeof(float));
 
 	*new_resampler = resampler;
@@ -231,7 +231,7 @@
 		x = samples;
 	}
 
-	for(i = 0; i < x; i++) {
+	for (i = 0; i < x; i++) {
 		z = data[i] + other_data[i];
 		switch_normalize_to_16bit(z);
 		data[i] = (int16_t) z;

Modified: freeswitch/trunk/src/switch_rtp.c
==============================================================================
--- freeswitch/trunk/src/switch_rtp.c	(original)
+++ freeswitch/trunk/src/switch_rtp.c	Tue May 27 00:30:03 2008
@@ -137,7 +137,7 @@
 	srtp_policy_t send_policy;
 	srtp_policy_t recv_policy;
 	uint32_t srtp_errs;
-	
+
 	uint16_t seq;
 	uint32_t ssrc;
 	uint8_t sending_dtmf;
@@ -185,13 +185,8 @@
 };
 
 static int global_init = 0;
-static int rtp_common_write(switch_rtp_t *rtp_session, 
-							rtp_msg_t *send_msg,
-							void *data, 
-							uint32_t datalen,
-							switch_payload_t payload,
-							uint32_t timestamp,
-							switch_frame_flag_t *flags);
+static int rtp_common_write(switch_rtp_t *rtp_session,
+							rtp_msg_t *send_msg, void *data, uint32_t datalen, switch_payload_t payload, uint32_t timestamp, switch_frame_flag_t *flags);
 
 
 static switch_status_t ice_out(switch_rtp_t *rtp_session)
@@ -201,7 +196,7 @@
 	unsigned int elapsed;
 	switch_size_t bytes;
 	switch_status_t status = SWITCH_STATUS_SUCCESS;
-	
+
 	switch_assert(rtp_session != NULL);
 	switch_assert(rtp_session->ice_user != NULL);
 
@@ -228,9 +223,9 @@
 	switch_socket_sendto(rtp_session->sock, rtp_session->remote_addr, 0, (void *) packet, &bytes);
 	rtp_session->stuncount = 25;
 
- end:
+  end:
 	WRITE_DEC(rtp_session);
-	
+
 	return SWITCH_STATUS_SUCCESS;
 }
 
@@ -249,7 +244,7 @@
 
 	READ_INC(rtp_session);
 	WRITE_INC(rtp_session);
-	
+
 	if (!switch_rtp_ready(rtp_session)) {
 		goto end;
 	}
@@ -299,12 +294,12 @@
 		rpacket = switch_stun_packet_build_header(SWITCH_STUN_BINDING_RESPONSE, packet->header.id, stunbuf);
 		switch_stun_packet_attribute_add_username(rpacket, username, 32);
 		remote_ip = switch_get_addr(ipbuf, sizeof(ipbuf), rtp_session->from_addr);
-		switch_stun_packet_attribute_add_binded_address(rpacket, (char *)remote_ip, switch_sockaddr_get_port(rtp_session->from_addr));
+		switch_stun_packet_attribute_add_binded_address(rpacket, (char *) remote_ip, switch_sockaddr_get_port(rtp_session->from_addr));
 		bytes = switch_stun_packet_length(rpacket);
 		switch_socket_sendto(rtp_session->sock, rtp_session->from_addr, 0, (void *) rpacket, &bytes);
 	}
 
- end:
+  end:
 
 	READ_DEC(rtp_session);
 	WRITE_DEC(rtp_session);
@@ -349,8 +344,8 @@
 		if (port_lock) {
 			switch_mutex_unlock(port_lock);
 		}
-        }
-        return START_PORT;
+	}
+	return START_PORT;
 }
 
 SWITCH_DECLARE(switch_port_t) switch_rtp_set_end_port(switch_port_t port)
@@ -366,8 +361,8 @@
 		if (port_lock) {
 			switch_mutex_unlock(port_lock);
 		}
-        }
-        return END_PORT;
+	}
+	return END_PORT;
 }
 
 SWITCH_DECLARE(void) switch_rtp_release_port(const char *ip, switch_port_t port)
@@ -378,8 +373,8 @@
 		return;
 	}
 
-    switch_mutex_lock(port_lock);
-    if ((alloc = switch_core_hash_find(alloc_hash, ip))) {
+	switch_mutex_lock(port_lock);
+	if ((alloc = switch_core_hash_find(alloc_hash, ip))) {
 		switch_core_port_allocator_free_port(alloc, port);
 	}
 	switch_mutex_unlock(port_lock);
@@ -390,7 +385,7 @@
 {
 	switch_port_t port = 0;
 	switch_core_port_allocator_t *alloc = NULL;
-	
+
 	switch_mutex_lock(port_lock);
 	alloc = switch_core_hash_find(alloc_hash, ip);
 	if (!alloc) {
@@ -400,7 +395,7 @@
 
 		switch_core_hash_insert(alloc_hash, ip, alloc);
 	}
-	
+
 	if (switch_core_port_allocator_request_port(alloc, &port) != SWITCH_STATUS_SUCCESS) {
 		port = 0;
 	}
@@ -463,7 +458,6 @@
 		*err = "Bind Error!";
 		goto done;
 	}
-
 #ifndef WIN32
 	len = sizeof(i);
 	switch_socket_opt_set(new_sock, SWITCH_SO_NONBLOCK, TRUE);
@@ -471,7 +465,7 @@
 	switch_socket_sendto(new_sock, rtp_session->local_addr, 0, (void *) o, &len);
 
 	x = 0;
-	while(!ilen) {
+	while (!ilen) {
 		switch_status_t status;
 		ilen = len;
 		status = switch_socket_recvfrom(rtp_session->from_addr, new_sock, 0, (void *) i, &ilen);
@@ -511,7 +505,7 @@
 	if (old_sock) {
 		switch_socket_close(old_sock);
 	}
-	
+
 	if (rtp_session->ready != 1) {
 		WRITE_DEC(rtp_session);
 		READ_DEC(rtp_session);
@@ -529,7 +523,7 @@
 {
 	switch_sockaddr_t *remote_addr;
 	*err = "Success";
-	
+
 	if (switch_sockaddr_info_get(&remote_addr, host, SWITCH_UNSPEC, port, 0, rtp_session->pool) != SWITCH_STATUS_SUCCESS || !remote_addr) {
 		*err = "Remote Address Error!";
 		return SWITCH_STATUS_FALSE;
@@ -545,10 +539,7 @@
 
 SWITCH_DECLARE(switch_status_t) switch_rtp_add_crypto_key(switch_rtp_t *rtp_session,
 														  switch_rtp_crypto_direction_t direction,
-														  uint32_t index,
-														  switch_rtp_crypto_key_type_t type,
-														  unsigned char *key,
-														  switch_size_t keylen) 
+														  uint32_t index, switch_rtp_crypto_key_type_t type, unsigned char *key, switch_size_t keylen)
 {
 	switch_rtp_crypto_key_t *crypto_key;
 	srtp_policy_t *policy;
@@ -557,10 +548,10 @@
 
 	if (direction >= SWITCH_RTP_CRYPTO_MAX || keylen > SWITCH_RTP_MAX_CRYPTO_LEN) {
 		return SWITCH_STATUS_FALSE;
-	} 
+	}
 
 	crypto_key = switch_core_alloc(rtp_session->pool, sizeof(*crypto_key));
-		
+
 	if (direction == SWITCH_RTP_CRYPTO_RECV) {
 		policy = &rtp_session->recv_policy;
 	} else {
@@ -575,7 +566,7 @@
 
 	memset(policy, 0, sizeof(*policy));
 
-	switch(crypto_key->type) {
+	switch (crypto_key->type) {
 	case AES_CM_128_HMAC_SHA1_80:
 		crypto_policy_set_aes_cm_128_hmac_sha1_80(&policy->rtp);
 		break;
@@ -586,13 +577,13 @@
 		break;
 	}
 
-	policy->next = NULL;	
+	policy->next = NULL;
 	policy->key = (uint8_t *) crypto_key->key;
 	crypto_policy_set_rtcp_default(&policy->rtcp);
 	policy->rtcp.sec_serv = sec_serv_none;
 
 	policy->rtp.sec_serv = sec_serv_conf_and_auth;
-	switch(direction) {
+	switch (direction) {
 	case SWITCH_RTP_CRYPTO_RECV:
 		policy->ssrc.type = ssrc_any_inbound;
 
@@ -645,10 +636,7 @@
 												  switch_payload_t payload,
 												  uint32_t samples_per_interval,
 												  uint32_t ms_per_packet,
-												  switch_rtp_flag_t flags, 
-												  char *timer_name, 
-												  const char **err,
-												  switch_memory_pool_t *pool)
+												  switch_rtp_flag_t flags, char *timer_name, const char **err, switch_memory_pool_t *pool)
 {
 	switch_rtp_t *rtp_session = NULL;
 	uint32_t ssrc = rand() & 0xffff;
@@ -718,9 +706,8 @@
 	}
 
 	if (!switch_strlen_zero(timer_name)) {
-		if (switch_core_timer_init(&rtp_session->timer, timer_name, ms_per_packet / 1000, samples_per_interval, pool) ==
-			SWITCH_STATUS_SUCCESS) {
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, 
+		if (switch_core_timer_init(&rtp_session->timer, timer_name, ms_per_packet / 1000, samples_per_interval, pool) == SWITCH_STATUS_SUCCESS) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
 							  "Starting timer [%s] %d bytes per %dms\n", timer_name, samples_per_interval, ms_per_packet);
 		} else {
 			memset(&rtp_session->timer, 0, sizeof(rtp_session->timer));
@@ -742,10 +729,7 @@
 											  switch_payload_t payload,
 											  uint32_t samples_per_interval,
 											  uint32_t ms_per_packet,
-											  switch_rtp_flag_t flags,
-											  char *timer_name, 
-											  const char **err, 
-											  switch_memory_pool_t *pool)
+											  switch_rtp_flag_t flags, char *timer_name, const char **err, switch_memory_pool_t *pool)
 {
 	switch_rtp_t *rtp_session = NULL;
 
@@ -768,26 +752,26 @@
 		*err = "Missing remote port";
 		goto end;
 	}
-	
+
 	if (switch_rtp_create(&rtp_session, payload, samples_per_interval, ms_per_packet, flags, timer_name, err, pool) != SWITCH_STATUS_SUCCESS) {
 		goto end;
 	}
 
-	switch_mutex_lock(rtp_session->flag_mutex);	
+	switch_mutex_lock(rtp_session->flag_mutex);
 
 	if (switch_rtp_set_local_address(rtp_session, rx_host, rx_port, err) != SWITCH_STATUS_SUCCESS) {
-		switch_mutex_unlock(rtp_session->flag_mutex);	
+		switch_mutex_unlock(rtp_session->flag_mutex);
 		rtp_session = NULL;
 		goto end;
 	}
 
 	if (switch_rtp_set_remote_address(rtp_session, tx_host, tx_port, err) != SWITCH_STATUS_SUCCESS) {
-		switch_mutex_unlock(rtp_session->flag_mutex);	
+		switch_mutex_unlock(rtp_session->flag_mutex);
 		rtp_session = NULL;
 		goto end;
 	}
-	
- end:
+
+  end:
 
 	if (rtp_session) {
 		switch_mutex_unlock(rtp_session->flag_mutex);
@@ -815,7 +799,7 @@
 
 SWITCH_DECLARE(switch_status_t) switch_rtp_activate_jitter_buffer(switch_rtp_t *rtp_session, uint32_t queue_frames)
 {
-	rtp_session->jb = stfu_n_init(queue_frames);	
+	rtp_session->jb = stfu_n_init(queue_frames);
 	return SWITCH_STATUS_SUCCESS;
 }
 
@@ -844,7 +828,7 @@
 	switch_size_t len = sizeof(o);
 
 	switch_assert(rtp_session != NULL);
-    switch_mutex_lock(rtp_session->flag_mutex);
+	switch_mutex_lock(rtp_session->flag_mutex);
 	if (rtp_session->sock) {
 		switch_set_flag_locked(rtp_session, SWITCH_RTP_FLAG_BREAK);
 		switch_socket_sendto(rtp_session->sock, rtp_session->local_addr, 0, (void *) &o, &len);
@@ -898,16 +882,16 @@
 
 	READ_DEC((*rtp_session));
 	WRITE_DEC((*rtp_session));
-	
+
 	switch_mutex_lock((*rtp_session)->flag_mutex);
 
 	switch_rtp_kill_socket(*rtp_session);
 
-	while(switch_queue_trypop((*rtp_session)->dtmf_data.dtmf_inqueue, &pop) == SWITCH_STATUS_SUCCESS) {
+	while (switch_queue_trypop((*rtp_session)->dtmf_data.dtmf_inqueue, &pop) == SWITCH_STATUS_SUCCESS) {
 		switch_safe_free(pop);
 	}
-	
-	while(switch_queue_trypop((*rtp_session)->dtmf_data.dtmf_queue, &pop) == SWITCH_STATUS_SUCCESS) {
+
+	while (switch_queue_trypop((*rtp_session)->dtmf_data.dtmf_queue, &pop) == SWITCH_STATUS_SUCCESS) {
 		switch_safe_free(pop);
 	}
 
@@ -1014,25 +998,18 @@
 			rtp_session->dtmf_data.out_digit_packet[1] |= 0x80;
 			loops = 3;
 		}
-			
+
 		rtp_session->dtmf_data.out_digit_packet[2] = (unsigned char) (rtp_session->dtmf_data.out_digit_sub_sofar >> 8);
 		rtp_session->dtmf_data.out_digit_packet[3] = (unsigned char) rtp_session->dtmf_data.out_digit_sub_sofar;
 
 		for (x = 0; x < loops; x++) {
 			switch_rtp_write_manual(rtp_session,
-									rtp_session->dtmf_data.out_digit_packet,
-									4,
-									0,
-									rtp_session->te,
-									rtp_session->dtmf_data.timestamp_dtmf, 
-									&flags);
+									rtp_session->dtmf_data.out_digit_packet, 4, 0, rtp_session->te, rtp_session->dtmf_data.timestamp_dtmf, &flags);
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Send %s packet for [%c] ts=%u dur=%d/%d/%d seq=%d\n",
-							  loops == 1 ? "middle" : "end", rtp_session->dtmf_data.out_digit, 
+							  loops == 1 ? "middle" : "end", rtp_session->dtmf_data.out_digit,
 							  rtp_session->dtmf_data.timestamp_dtmf,
-							  rtp_session->dtmf_data.out_digit_sofar, 
-							  rtp_session->dtmf_data.out_digit_sub_sofar,
-							  rtp_session->dtmf_data.out_digit_dur,
-							  rtp_session->seq);
+							  rtp_session->dtmf_data.out_digit_sofar,
+							  rtp_session->dtmf_data.out_digit_sub_sofar, rtp_session->dtmf_data.out_digit_dur, rtp_session->seq);
 		}
 
 		if (loops != 1) {
@@ -1054,7 +1031,7 @@
 				return;
 			}
 		}
-		
+
 		if (switch_queue_trypop(rtp_session->dtmf_data.dtmf_queue, &pop) == SWITCH_STATUS_SUCCESS) {
 			switch_dtmf_t *rdigit = pop;
 			int64_t offset;
@@ -1071,12 +1048,12 @@
 			rtp_session->dtmf_data.out_digit_packet[2] = (unsigned char) (rtp_session->dtmf_data.out_digit_sub_sofar >> 8);
 			rtp_session->dtmf_data.out_digit_packet[3] = (unsigned char) rtp_session->dtmf_data.out_digit_sub_sofar;
 
-			
+
 			rtp_session->dtmf_data.timestamp_dtmf = rtp_session->last_write_ts + samples;
 			if (rtp_session->timer.interval) {
 				offset = rtp_session->timer.samplecount - rtp_session->last_write_samplecount;
 				if (offset > 0) {
-					rtp_session->dtmf_data.timestamp_dtmf = (uint32_t)(rtp_session->dtmf_data.timestamp_dtmf + offset);
+					rtp_session->dtmf_data.timestamp_dtmf = (uint32_t) (rtp_session->dtmf_data.timestamp_dtmf + offset);
 				}
 			}
 
@@ -1084,17 +1061,13 @@
 									rtp_session->dtmf_data.out_digit_packet,
 									4,
 									switch_test_flag(rtp_session, SWITCH_RTP_FLAG_BUGGY_2833) ? 0 : 1,
-									rtp_session->te,
-									rtp_session->dtmf_data.timestamp_dtmf,
-									&flags);
+									rtp_session->te, rtp_session->dtmf_data.timestamp_dtmf, &flags);
 
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Send start packet for [%c] ts=%u dur=%d/%d/%d seq=%d\n",
-							  rtp_session->dtmf_data.out_digit, 
+							  rtp_session->dtmf_data.out_digit,
 							  rtp_session->dtmf_data.timestamp_dtmf,
-							  rtp_session->dtmf_data.out_digit_sofar, 
-							  rtp_session->dtmf_data.out_digit_sub_sofar,
-							  rtp_session->dtmf_data.out_digit_dur,
-							  rtp_session->seq);
+							  rtp_session->dtmf_data.out_digit_sofar,
+							  rtp_session->dtmf_data.out_digit_sub_sofar, rtp_session->dtmf_data.out_digit_dur, rtp_session->seq);
 
 			free(rdigit);
 		}
@@ -1108,7 +1081,7 @@
 	uint8_t check = 0;
 	stfu_frame_t *jb_frame;
 	int ret = -1;
-	
+
 	if (!switch_rtp_ready(rtp_session)) {
 		return -1;
 	}
@@ -1124,12 +1097,12 @@
 
 		bytes = sizeof(rtp_msg_t);
 		status = switch_socket_recvfrom(rtp_session->from_addr, rtp_session->sock, 0, (void *) &rtp_session->recv_msg, &bytes);
-		
+
 		if (bytes < 0) {
 			ret = (int) bytes;
 			goto end;
 		}
-		
+
 		if (bytes && switch_test_flag(rtp_session, SWITCH_RTP_FLAG_AUTOADJ) && switch_sockaddr_get_port(rtp_session->from_addr)) {
 			const char *tx_host;
 			const char *old_host;
@@ -1178,12 +1151,12 @@
 
 		if (!bytes && (io_flags & SWITCH_IO_FLAG_NOBLOCK)) {
 			do_cng = 1;
-            goto cng;
+			goto cng;
 		}
 
 
 		if (rtp_session->timer.interval) {
-			check = (uint8_t) (switch_core_timer_check(&rtp_session->timer, SWITCH_TRUE) == SWITCH_STATUS_SUCCESS);						
+			check = (uint8_t) (switch_core_timer_check(&rtp_session->timer, SWITCH_TRUE) == SWITCH_STATUS_SUCCESS);
 			if (bytes) {
 				switch_core_timer_sync(&rtp_session->timer);
 			} else {
@@ -1199,7 +1172,7 @@
 		} else if (bytes) {
 			check++;
 		}
-		
+
 		if (check || bytes) {
 			do_2833(rtp_session);
 		}
@@ -1213,25 +1186,25 @@
 			if (rtp_session->invalid_handler) {
 				rtp_session->invalid_handler(rtp_session, rtp_session->sock, (void *) &rtp_session->recv_msg, bytes, rtp_session->from_addr);
 			}
-			
+
 			memset(data, 0, 2);
 			data[0] = 65;
 
 			rtp_session->recv_msg.header.pt = (uint32_t) rtp_session->cng_pt ? rtp_session->cng_pt : SWITCH_RTP_CNG_PAYLOAD;
 			*flags |= SFF_CNG;
-			*payload_type = (switch_payload_t)rtp_session->recv_msg.header.pt;
+			*payload_type = (switch_payload_t) rtp_session->recv_msg.header.pt;
 			ret = 2 + rtp_header_len;
 			goto end;
 		}
 
 
-	
+
 		if (rtp_session->jb && ((bytes && rtp_session->recv_msg.header.pt == rtp_session->payload) || check)) {
 			if (bytes) {
 				if (rtp_session->recv_msg.header.m) {
 					stfu_n_reset(rtp_session->jb);
 				}
-			
+
 				stfu_n_eat(rtp_session->jb, ntohl(rtp_session->recv_msg.header.ts), rtp_session->recv_msg.body, bytes - rtp_header_len);
 				bytes = 0;
 			}
@@ -1248,7 +1221,7 @@
 				goto cng;
 			}
 		}
-		
+
 
 		if (bytes && switch_test_flag(rtp_session, SWITCH_RTP_FLAG_SECURE_RECV)) {
 			int sbytes = (int) bytes;
@@ -1274,7 +1247,8 @@
 				if (++rtp_session->srtp_errs >= MAX_SRTP_ERRS) {
 					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
 									  "error: srtp unprotection failed with code %d%s\n", stat,
-									  stat == err_status_replay_fail ? " (replay check failed)" : stat == err_status_auth_fail ? " (auth check failed)" : "");
+									  stat == err_status_replay_fail ? " (replay check failed)" : stat ==
+									  err_status_auth_fail ? " (auth check failed)" : "");
 					ret = -1;
 					goto end;
 				} else {
@@ -1300,13 +1274,13 @@
 			uint16_t duration = (packet[2] << 8) + packet[3];
 			char key = switch_rfc2833_to_char(packet[0]);
 			uint16_t in_digit_seq = ntohs((uint16_t) rtp_session->recv_msg.header.seq);
-			
+
 			if (in_digit_seq > rtp_session->dtmf_data.in_digit_seq) {
 				uint32_t ts = htonl(rtp_session->recv_msg.header.ts);
 				//int m = rtp_session->recv_msg.header.m;
 
 				rtp_session->dtmf_data.in_digit_seq = in_digit_seq;
-				
+
 				//printf("%c %u %u %u\n", key, in_digit_seq, ts, duration);
 
 				if (rtp_session->dtmf_data.last_duration > duration && ts == rtp_session->dtmf_data.in_digit_ts) {
@@ -1316,7 +1290,7 @@
 				if (end) {
 					if (rtp_session->dtmf_data.in_digit_ts) {
 						switch_dtmf_t dtmf = { key, duration };
-					
+
 						if (ts > rtp_session->dtmf_data.in_digit_ts) {
 							dtmf.duration += (ts - rtp_session->dtmf_data.in_digit_ts);
 						}
@@ -1325,7 +1299,6 @@
 							rtp_session->dtmf_data.flip = 0;
 							//printf("you're welcome!\n");
 						}
-
 						//printf("done digit=%c ts=%u start_ts=%u dur=%u ddur=%u\n", 
 						//dtmf.digit, ts, rtp_session->dtmf_data.in_digit_ts, duration, dtmf.duration);
 						switch_rtp_queue_rfc2833_in(rtp_session, &dtmf);
@@ -1336,8 +1309,8 @@
 				} else if (!rtp_session->dtmf_data.in_digit_ts) {
 					rtp_session->dtmf_data.in_digit_ts = ts;
 					rtp_session->dtmf_data.first_digit = key;
-				} 
-				
+				}
+
 				rtp_session->dtmf_data.last_duration = duration;
 
 			}
@@ -1345,7 +1318,7 @@
 			do_cng = 1;
 		}
 
-	cng:
+	  cng:
 		if (do_cng) {
 			memset(&rtp_session->recv_msg.body, 0, 2);
 			rtp_session->recv_msg.body[0] = 127;
@@ -1364,7 +1337,7 @@
 					goto end;
 				}
 			}
-			
+
 			if (rtp_session->jb && (jb_frame = stfu_n_read_a_frame(rtp_session->jb))) {
 				memcpy(rtp_session->recv_msg.body, jb_frame->data, jb_frame->dlen);
 				if (jb_frame->plc) {
@@ -1372,20 +1345,20 @@
 				}
 				bytes = jb_frame->dlen + rtp_header_len;
 				rtp_session->recv_msg.header.ts = htonl(jb_frame->ts);
-			} else if (!bytes && switch_test_flag(rtp_session, SWITCH_RTP_FLAG_USE_TIMER)) { /* We're late! We're Late! */
-				uint8_t *data = (uint8_t *) rtp_session->recv_msg.body;				
-				
+			} else if (!bytes && switch_test_flag(rtp_session, SWITCH_RTP_FLAG_USE_TIMER)) {	/* We're late! We're Late! */
+				uint8_t *data = (uint8_t *) rtp_session->recv_msg.body;
+
 				if (!switch_test_flag(rtp_session, SWITCH_RTP_FLAG_NOBLOCK) && status == SWITCH_STATUS_BREAK) {
 					switch_yield(1000);
 					continue;
 				}
-				
+
 				memset(data, 0, 2);
 				data[0] = 65;
-				
+
 				rtp_session->recv_msg.header.pt = (uint32_t) rtp_session->cng_pt ? rtp_session->cng_pt : SWITCH_RTP_CNG_PAYLOAD;
 				*flags |= SFF_CNG;
-				*payload_type = (switch_payload_t)rtp_session->recv_msg.header.pt;
+				*payload_type = (switch_payload_t) rtp_session->recv_msg.header.pt;
 				ret = 2 + rtp_header_len;
 				goto end;
 			}
@@ -1398,7 +1371,7 @@
 			ret = 0;
 			goto end;
 		}
-		
+
 		if (bytes && rtp_session->cng_pt && rtp_session->recv_msg.header.pt == rtp_session->cng_pt) {
 			goto do_continue;
 		}
@@ -1411,7 +1384,7 @@
 
 		break;
 
-	do_continue:
+	  do_continue:
 
 		switch_yield(1000);
 	}
@@ -1428,7 +1401,7 @@
 		ret = -1;
 	}
 
- end:
+  end:
 
 	READ_DEC(rtp_session);
 
@@ -1453,7 +1426,7 @@
 	switch_size_t bytes = 0;
 	switch_dtmf_t *_dtmf = NULL;
 	void *pop;
-	
+
 	if (!switch_rtp_ready(rtp_session)) {
 		return bytes;
 	}
@@ -1483,7 +1456,7 @@
 		if (rdigit->duration < switch_core_default_dtmf_duration(0)) {
 			rdigit->duration = switch_core_default_dtmf_duration(0);
 		}
-		
+
 		if ((switch_queue_trypush(rtp_session->dtmf_data.dtmf_queue, rdigit)) != SWITCH_STATUS_SUCCESS) {
 			free(rdigit);
 			return SWITCH_STATUS_FALSE;
@@ -1491,7 +1464,7 @@
 	} else {
 		abort();
 	}
-	
+
 	return SWITCH_STATUS_SUCCESS;
 }
 
@@ -1502,7 +1475,7 @@
 	if (!switch_rtp_ready(rtp_session)) {
 		return SWITCH_STATUS_FALSE;
 	}
-	
+
 	if ((rdigit = malloc(sizeof(*rdigit))) != 0) {
 		*rdigit = *dtmf;
 		if (rdigit->duration < switch_core_default_dtmf_duration(0)) {
@@ -1516,11 +1489,11 @@
 	} else {
 		abort();
 	}
-	
+
 	return SWITCH_STATUS_SUCCESS;
 }
 
-SWITCH_DECLARE(switch_status_t) switch_rtp_read(switch_rtp_t *rtp_session, void *data, uint32_t * datalen,
+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_io_flag_t io_flags)
 {
 	int bytes = 0;
@@ -1567,7 +1540,7 @@
 		frame->flags |= SFF_RFC2833;
 	}
 	frame->timestamp = ntohl(rtp_session->recv_msg.header.ts);
-	frame->seq = (uint16_t)ntohs((u_short)rtp_session->recv_msg.header.seq);
+	frame->seq = (uint16_t) ntohs((u_short) rtp_session->recv_msg.header.seq);
 	frame->ssrc = ntohl(rtp_session->recv_msg.header.ssrc);
 	frame->m = rtp_session->recv_msg.header.m ? SWITCH_TRUE : SWITCH_FALSE;
 
@@ -1580,14 +1553,15 @@
 	} else {
 		bytes -= rtp_header_len;
 	}
-	
+
 	frame->datalen = bytes;
 
 	return SWITCH_STATUS_SUCCESS;
 }
 
 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, switch_io_flag_t io_flags)
+														 void **data, uint32_t *datalen, switch_payload_t *payload_type, switch_frame_flag_t *flags,
+														 switch_io_flag_t io_flags)
 {
 	int bytes = 0;
 
@@ -1609,13 +1583,8 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static int rtp_common_write(switch_rtp_t *rtp_session, 
-							rtp_msg_t *send_msg,
-							void *data, 
-							uint32_t datalen,
-							switch_payload_t payload,
-							uint32_t timestamp,
-							switch_frame_flag_t *flags)
+static int rtp_common_write(switch_rtp_t *rtp_session,
+							rtp_msg_t *send_msg, void *data, uint32_t datalen, switch_payload_t payload, uint32_t timestamp, switch_frame_flag_t *flags)
 {
 	switch_size_t bytes;
 	uint8_t send = 1;
@@ -1633,11 +1602,11 @@
 		if (flags && *flags & SFF_RFC2833) {
 			send_msg->header.pt = rtp_session->te;
 		}
-        data = send_msg->body;
-        datalen -= rtp_header_len;
+		data = send_msg->body;
+		datalen -= rtp_header_len;
 	} else {
 		uint8_t m = 0;
-		
+
 		if (*flags & SFF_RFC2833) {
 			payload = rtp_session->te;
 		}
@@ -1655,10 +1624,10 @@
 		} else {
 			rtp_session->ts += rtp_session->samples_per_interval;
 		}
-		
+
 		rtp_session->send_msg.header.ts = htonl(rtp_session->ts);
 
-		if ((rtp_session->ts > (rtp_session->last_write_ts + (rtp_session->samples_per_interval * 10))) 
+		if ((rtp_session->ts > (rtp_session->last_write_ts + (rtp_session->samples_per_interval * 10)))
 			|| rtp_session->ts == rtp_session->samples_per_interval) {
 			m++;
 		}
@@ -1681,8 +1650,8 @@
 
 	if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_VAD) &&
 		rtp_session->recv_msg.header.pt == rtp_session->vad_data.read_codec->implementation->ianacode) {
-		
-		int16_t decoded[SWITCH_RECOMMENDED_BUFFER_SIZE / sizeof(int16_t)] = {0};
+
+		int16_t decoded[SWITCH_RECOMMENDED_BUFFER_SIZE / sizeof(int16_t)] = { 0 };
 		uint32_t rate = 0;
 		uint32_t codec_flags = 0;
 		uint32_t len = sizeof(decoded);
@@ -1706,7 +1675,7 @@
 			uint32_t score = 0;
 			int divisor = 0;
 			if (z) {
-				
+
 				if (!(divisor = rtp_session->vad_data.read_codec->implementation->actual_samples_per_second / 8000)) {
 					divisor = 1;
 				}
@@ -1715,7 +1684,7 @@
 					energy += abs(decoded[y]);
 					y += rtp_session->vad_data.read_codec->implementation->number_of_channels;
 				}
-				
+
 				if (++rtp_session->vad_data.start_count < rtp_session->vad_data.start) {
 					send = 1;
 				} else {
@@ -1770,7 +1739,7 @@
 
 				if (switch_test_flag(&rtp_session->vad_data, SWITCH_VAD_FLAG_TALKING)) {
 					send = 1;
-				} 
+				}
 			}
 		} else {
 			ret = -1;
@@ -1786,11 +1755,11 @@
 
 	if (send) {
 		send_msg->header.seq = htons(++rtp_session->seq);
-		
+
 		if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_SECURE_SEND)) {
 			int sbytes = (int) bytes;
 			err_status_t stat;
-			
+
 
 			if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_SECURE_SEND_RESET)) {
 				switch_clear_flag_locked(rtp_session, SWITCH_RTP_FLAG_SECURE_SEND_RESET);
@@ -1804,13 +1773,13 @@
 					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "RE-Activating Secure RTP SEND\n");
 				}
 			}
-			
+
 
 			stat = srtp_protect(rtp_session->send_ctx, &send_msg->header, &sbytes);
 			if (stat) {
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "error: srtp protection failed with code %d\n", stat);
 			}
-			
+
 			bytes = sbytes;
 		}
 
@@ -1819,7 +1788,7 @@
 			ret = -1;
 			goto end;
 		}
-		
+
 		if (rtp_session->timer.interval) {
 			rtp_session->last_write_samplecount = rtp_session->timer.samplecount;
 		}
@@ -1835,7 +1804,7 @@
 
 	ret = (int) bytes;
 
- end:
+  end:
 
 	WRITE_DEC(rtp_session);
 
@@ -1879,7 +1848,7 @@
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n");
 		return SWITCH_STATUS_FALSE;
 	}
-	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Activate VAD codec %s %dms\n", codec->implementation->iananame, 
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Activate VAD codec %s %dms\n", codec->implementation->iananame,
 					  codec->implementation->microseconds_per_frame / 1000);
 	rtp_session->vad_data.diff_level = 400;
 	rtp_session->vad_data.hangunder = 15;
@@ -1907,14 +1876,14 @@
 	uint32_t len, ts = 0;
 	switch_payload_t payload;
 	rtp_msg_t *send_msg = NULL;
-	
+
 	if (!switch_rtp_ready(rtp_session) || !rtp_session->remote_addr) {
 		return -1;
 	}
 
 	if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_PROXY_MEDIA)) {
 		switch_size_t bytes;
-		
+
 		/* Fast PASS! */
 		if (!switch_test_flag(frame, SFF_PROXY_PACKET)) {
 			return 0;
@@ -1938,8 +1907,7 @@
 	}
 
 	if (switch_test_flag(frame, SFF_RTP_HEADER)) {
-		return switch_rtp_write_manual(rtp_session, frame->data, frame->datalen, frame->m, frame->payload, 
-									   (uint32_t)(frame->timestamp), &frame->flags);
+		return switch_rtp_write_manual(rtp_session, frame->data, frame->datalen, frame->m, frame->payload, (uint32_t) (frame->timestamp), &frame->flags);
 	}
 
 	if (fwd) {
@@ -1949,16 +1917,14 @@
 	} else {
 		data = frame->data;
 		len = frame->datalen;
-		ts = (uint32_t)frame->timestamp;
+		ts = (uint32_t) frame->timestamp;
 	}
 
 	return rtp_common_write(rtp_session, send_msg, data, len, payload, ts, &frame->flags);
 }
 
 SWITCH_DECLARE(int) switch_rtp_write_manual(switch_rtp_t *rtp_session,
-											void *data,
-											uint32_t datalen,
-											uint8_t m, switch_payload_t payload, uint32_t ts, switch_frame_flag_t *flags)
+											void *data, uint32_t datalen, uint8_t m, switch_payload_t payload, uint32_t ts, switch_frame_flag_t *flags)
 {
 	switch_size_t bytes;
 	int ret = -1;
@@ -2011,8 +1977,8 @@
 	rtp_session->last_write_ts = ts;
 
 	ret = (int) bytes;
-	
- end:
+
+  end:
 
 	WRITE_DEC(rtp_session);
 

Modified: freeswitch/trunk/src/switch_scheduler.c
==============================================================================
--- freeswitch/trunk/src/switch_scheduler.c	(original)
+++ freeswitch/trunk/src/switch_scheduler.c	Tue May 27 00:30:03 2008
@@ -53,7 +53,7 @@
 	switch_memory_pool_t *memory_pool;
 } globals;
 
-static void switch_scheduler_execute(switch_scheduler_task_container_t * tp)
+static void switch_scheduler_execute(switch_scheduler_task_container_t *tp)
 {
 	switch_event_t *event;
 	//switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Executing task %u %s (%s)\n", tp->task.task_id, tp->desc, switch_str_nil(tp->task.group));
@@ -81,7 +81,7 @@
 	}
 }
 
-static void *SWITCH_THREAD_FUNC task_own_thread(switch_thread_t * thread, void *obj)
+static void *SWITCH_THREAD_FUNC task_own_thread(switch_thread_t *thread, void *obj)
 {
 	switch_scheduler_task_container_t *tp = (switch_scheduler_task_container_t *) obj;
 	switch_memory_pool_t *pool;
@@ -109,7 +109,7 @@
 		} else {
 			int64_t now = switch_timestamp(NULL);
 			if (now >= tp->task.runtime && !tp->in_thread) {
-				int32_t diff = (int32_t)(now - tp->task.runtime);
+				int32_t diff = (int32_t) (now - tp->task.runtime);
 				if (diff > 1) {
 					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Task was executed late by %d seconds %u %s (%s)\n",
 									  diff, tp->task.task_id, tp->desc, switch_str_nil(tp->task.group));
@@ -158,7 +158,7 @@
 	return done;
 }
 
-static void *SWITCH_THREAD_FUNC switch_scheduler_task_thread(switch_thread_t * thread, void *obj)
+static void *SWITCH_THREAD_FUNC switch_scheduler_task_thread(switch_thread_t *thread, void *obj)
 {
 
 	globals.task_thread_running = 1;
@@ -234,7 +234,7 @@
 	for (tp = globals.task_list; tp; tp = tp->next) {
 		if (tp->task.task_id == task_id) {
 			if (switch_test_flag(tp, SSHF_NO_DEL)) {
-				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Attempt made to delete undeleteable task #%u (group %s)\n", 
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Attempt made to delete undeleteable task #%u (group %s)\n",
 								  tp->task.task_id, tp->task.group);
 				break;
 			}

Modified: freeswitch/trunk/src/switch_stun.c
==============================================================================
--- freeswitch/trunk/src/switch_stun.c	(original)
+++ freeswitch/trunk/src/switch_stun.c	Tue May 27 00:30:03 2008
@@ -114,7 +114,7 @@
 }
 
 
-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)
 {
 	switch_stun_packet_t *packet;
 	switch_stun_packet_attribute_t *attr;
@@ -133,7 +133,7 @@
 	/*
 	 * Check packet type (RFC3489(bis?) values)
 	 */
-	switch(packet->header.type) {
+	switch (packet->header.type) {
 	case SWITCH_STUN_BINDING_REQUEST:
 	case SWITCH_STUN_BINDING_RESPONSE:
 	case SWITCH_STUN_BINDING_ERROR_RESPONSE:
@@ -180,7 +180,7 @@
 	do {
 		attr->length = ntohs(attr->length);
 		attr->type = ntohs(attr->type);
-		bytes_left -= 4;	/* attribute header consumed */
+		bytes_left -= 4;		/* attribute header consumed */
 
 		if (!attr->length || switch_stun_attribute_padded_length(attr) > bytes_left) {
 			/*
@@ -195,7 +195,7 @@
 		 * Handle STUN attributes
 		 */
 		switch (attr->type) {
-		case SWITCH_STUN_ATTR_MAPPED_ADDRESS:		/* Address, we only care about this one, but parse the others too */
+		case SWITCH_STUN_ATTR_MAPPED_ADDRESS:	/* Address, we only care about this one, but parse the others too */
 		case SWITCH_STUN_ATTR_RESPONSE_ADDRESS:
 		case SWITCH_STUN_ATTR_SOURCE_ADDRESS:
 		case SWITCH_STUN_ATTR_CHANGED_ADDRESS:
@@ -231,7 +231,7 @@
 			}
 			break;
 
-		case SWITCH_STUN_ATTR_CHANGE_REQUEST:		/* UInt32 */
+		case SWITCH_STUN_ATTR_CHANGE_REQUEST:	/* UInt32 */
 		case SWITCH_STUN_ATTR_LIFETIME:
 		case SWITCH_STUN_ATTR_BANDWIDTH:
 		case SWITCH_STUN_ATTR_OPTIONS:
@@ -247,16 +247,16 @@
 			}
 			break;
 
-		case SWITCH_STUN_ATTR_USERNAME:			/* ByteString, multiple of 4 bytes */
-		case SWITCH_STUN_ATTR_PASSWORD:			/* ByteString, multiple of 4 bytes */
+		case SWITCH_STUN_ATTR_USERNAME:	/* ByteString, multiple of 4 bytes */
+		case SWITCH_STUN_ATTR_PASSWORD:	/* ByteString, multiple of 4 bytes */
 			if (attr->length % 4 != 0) {
 				/* Invalid */
 				return NULL;
 			}
 			break;
 
-		case SWITCH_STUN_ATTR_DATA:			/* ByteString */
-		case SWITCH_STUN_ATTR_ERROR_CODE:		/* ErrorCode */
+		case SWITCH_STUN_ATTR_DATA:	/* ByteString */
+		case SWITCH_STUN_ATTR_ERROR_CODE:	/* ErrorCode */
 		case SWITCH_STUN_ATTR_TRANSPORT_PREFERENCES:	/* TransportPrefs */
 			/*
 			 * No length checking here, since we already checked against the padded length
@@ -271,7 +271,7 @@
 			}
 			break;
 
-		case SWITCH_STUN_ATTR_MAGIC_COOKIE:		/* ByteString, 4 bytes */
+		case SWITCH_STUN_ATTR_MAGIC_COOKIE:	/* ByteString, 4 bytes */
 			if (attr->length != 4) {
 				/* Invalid */
 				return NULL;
@@ -295,12 +295,12 @@
 
 	} while (bytes_left >= SWITCH_STUN_ATTRIBUTE_MIN_LEN && switch_stun_packet_next_attribute(attr, end_buf));
 
-	if ((uint32_t)(packet->header.length + 20) > (uint32_t)(len - bytes_left)) {
+	if ((uint32_t) (packet->header.length + 20) > (uint32_t) (len - bytes_left)) {
 		/*
 		 * the packet length is longer than the length of all attributes?
 		 * for now simply decrease the packet size
 		 */
-		packet->header.length = (uint16_t)((len - bytes_left) - 20);
+		packet->header.length = (uint16_t) ((len - bytes_left) - 20);
 	}
 
 	return packet;
@@ -336,14 +336,14 @@
 	return "INVALID";
 }
 
-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)
 {
 	switch_stun_ip_t *ip;
 	uint8_t x, *i;
 	char *p = ipstr;
 
 	ip = (switch_stun_ip_t *) attribute->value;
-	i = (uint8_t *) & ip->address;
+	i = (uint8_t *) &ip->address;
 	*ipstr = 0;
 	for (x = 0; x < 4; x++) {
 		sprintf(p, "%u%s", i[x], x == 3 ? "" : ".");
@@ -361,7 +361,7 @@
 	return memcpy(username, attribute->value, cpylen);
 }
 
-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)
 {
 	switch_stun_packet_header_t *header;
 
@@ -386,14 +386,14 @@
 	uint8_t *i, x;
 	char *p = ipstr;
 
-	attribute = (switch_stun_packet_attribute_t *) ((uint8_t *) & packet->first_attribute + ntohs(packet->header.length));
+	attribute = (switch_stun_packet_attribute_t *) ((uint8_t *) &packet->first_attribute + ntohs(packet->header.length));
 	attribute->type = htons(SWITCH_STUN_ATTR_MAPPED_ADDRESS);
 	attribute->length = htons(8);
 	ip = (switch_stun_ip_t *) attribute->value;
 
 	ip->port = htons(port);
 	ip->family = 1;
-	i = (uint8_t *) & ip->address;
+	i = (uint8_t *) &ip->address;
 
 	for (x = 0; x < 4; x++) {
 		i[x] = (uint8_t) atoi(p);
@@ -415,7 +415,7 @@
 	if (ulen % 4 != 0) {
 		return 0;
 	}
-	attribute = (switch_stun_packet_attribute_t *) ((uint8_t *) & packet->first_attribute + ntohs(packet->header.length));
+	attribute = (switch_stun_packet_attribute_t *) ((uint8_t *) &packet->first_attribute + ntohs(packet->header.length));
 	attribute->type = htons(SWITCH_STUN_ATTR_USERNAME);
 	attribute->length = htons(ulen);
 	if (username) {

Modified: freeswitch/trunk/src/switch_swig.c
==============================================================================
--- freeswitch/trunk/src/switch_swig.c	(original)
+++ freeswitch/trunk/src/switch_swig.c	Tue May 27 00:30:03 2008
@@ -243,7 +243,7 @@
 		return;
 	} else {
 		switch_ivr_multi_threaded_bridge(session, peer_session, NULL, NULL, NULL);
-        switch_core_session_rwunlock(peer_session);
+		switch_core_session_rwunlock(peer_session);
 	}
 }
 

Modified: freeswitch/trunk/src/switch_time.c
==============================================================================
--- freeswitch/trunk/src/switch_time.c	(original)
+++ freeswitch/trunk/src/switch_time.c	Tue May 27 00:30:03 2008
@@ -102,7 +102,7 @@
 #endif
 
 
-SWITCH_DECLARE(void) switch_time_set_monotonic(switch_bool_t enable) 
+SWITCH_DECLARE(void) switch_time_set_monotonic(switch_bool_t enable)
 {
 	MONO = enable ? 1 : 0;
 	switch_time_sync();
@@ -116,7 +116,7 @@
 	if (MONO) {
 		struct timespec ts;
 		clock_gettime(CLOCK_MONOTONIC, &ts);
-		now = ts.tv_sec * APR_USEC_PER_SEC + (ts.tv_nsec/1000) + offset;
+		now = ts.tv_sec * APR_USEC_PER_SEC + (ts.tv_nsec / 1000) + offset;
 	} else {
 #endif
 		now = switch_time_now();
@@ -138,13 +138,13 @@
 SWITCH_DECLARE(void) switch_sleep(switch_interval_time_t t)
 {
 
-#if defined(HAVE_CLOCK_NANOSLEEP) && defined(SWITCH_USE_CLOCK_FUNCS)	
+#if defined(HAVE_CLOCK_NANOSLEEP) && defined(SWITCH_USE_CLOCK_FUNCS)
 	struct timespec ts;
 	ts.tv_sec = t / APR_USEC_PER_SEC;
 	ts.tv_nsec = (t % APR_USEC_PER_SEC) * 1000;
-	
+
 	clock_nanosleep(CLOCK_REALTIME, 0, &ts, NULL);
-	
+
 #elif defined(HAVE_USLEEP)
 	usleep(t);
 #elif defined(WIN32)
@@ -161,7 +161,7 @@
 	timer_private_t *private_info;
 	int sanity = 0;
 
-	while(globals.STARTED == 0) {
+	while (globals.STARTED == 0) {
 		switch_yield(100000);
 		if (++sanity == 10) {
 			break;
@@ -193,8 +193,8 @@
 		private_info->roll++;											\
 		private_info->reference = private_info->start = TIMER_MATRIX[timer->interval].tick;	\
 	}																	\
-	
-	
+
+
 static switch_status_t timer_step(switch_timer_t *timer)
 {
 	timer_private_t *private_info = timer->private_info;
@@ -203,7 +203,7 @@
 	if (globals.RUNNING != 1 || private_info->ready == 0) {
 		return SWITCH_STATUS_FALSE;
 	}
-	
+
 	check_roll();
 	samples = timer->samples * (private_info->reference - private_info->start);
 
@@ -214,7 +214,7 @@
 
 	timer->samplecount = (uint32_t) samples;
 	private_info->reference++;
-	
+
 	return SWITCH_STATUS_SUCCESS;
 }
 
@@ -234,7 +234,7 @@
 		/* push the reference into the future 2 more intervals to prevent collision */
 		private_info->reference += 2;
 	}
-	
+
 	return SWITCH_STATUS_SUCCESS;
 }
 
@@ -249,7 +249,7 @@
 		check_roll();
 		switch_yield(1000);
 	}
-	
+
 	if (globals.RUNNING == 1) {
 		return SWITCH_STATUS_SUCCESS;
 	}
@@ -275,8 +275,8 @@
 	} else {
 		timer->diff = 0;
 	}
-	
-	if (timer->diff) {		
+
+	if (timer->diff) {
 		status = SWITCH_STATUS_FALSE;
 	} else if (step) {
 		timer_step(timer);
@@ -311,7 +311,7 @@
 
 	memset(&globals, 0, sizeof(globals));
 	switch_mutex_init(&globals.mutex, SWITCH_MUTEX_NESTED, module_pool);
-	
+
 	globals.STARTED = globals.RUNNING = 1;
 	switch_mutex_lock(runtime.throttle_mutex);
 	runtime.sps = runtime.sps_total;
@@ -319,9 +319,9 @@
 
 	if (MONO) {
 		int loops;
-		for(loops = 0; loops < 3; loops++) {
+		for (loops = 0; loops < 3; loops++) {
 			ts = time_now(0);
-			/* if it returns the same value every time it won't be of much use.*/
+			/* if it returns the same value every time it won't be of much use. */
 			if (ts == last) {
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Broken MONOTONIC Clock Detected!, Support Disabled.\n");
 				MONO = 0;
@@ -337,7 +337,7 @@
 	ts = 0;
 	last = 0;
 	fwd_errs = rev_errs = 0;
-	
+
 	while (globals.RUNNING == 1) {
 		runtime.reference += STEP_MIC;
 		while ((ts = time_now(runtime.offset)) < runtime.reference) {
@@ -346,7 +346,7 @@
 					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Virtual Migration Detected! Syncing Clock\n");
 					switch_time_sync();
 				} else {
-					int64_t diff = (int64_t)(ts - last);
+					int64_t diff = (int64_t) (ts - last);
 					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Reverse Clock Skew Detected!\n");
 					runtime.reference = switch_time_now();
 					current_ms = 0;
@@ -359,8 +359,8 @@
 			}
 			switch_yield(STEP_MIC);
 			last = ts;
-		} 
-		
+		}
+
 
 		if (ts > (runtime.reference + too_late)) {
 			if (MONO) {
@@ -378,7 +378,7 @@
 		} else {
 			fwd_errs = 0;
 		}
-		
+
 		if (fwd_errs > 9 || rev_errs > 9) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Auto Re-Syncing clock.\n");
 			switch_time_sync();
@@ -388,7 +388,7 @@
 		runtime.timestamp = ts;
 		current_ms += STEP_MS;
 		tick += STEP_MS;
-		
+
 		if (tick >= 1000) {
 			if (runtime.sps <= 0) {
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Over Session Rate of %d!\n", runtime.sps_total);
@@ -457,7 +457,6 @@
 			switch_yield(10000);
 		}
 	}
-
 #if defined(WIN32)
 	timeEndPeriod(1);
 #endif

Modified: freeswitch/trunk/src/switch_utils.c
==============================================================================
--- freeswitch/trunk/src/switch_utils.c	(original)
+++ freeswitch/trunk/src/switch_utils.c	Tue May 27 00:30:03 2008
@@ -63,7 +63,7 @@
 SWITCH_DECLARE(switch_status_t) switch_network_list_create(switch_network_list_t **list, switch_bool_t default_type, switch_memory_pool_t *pool)
 {
 	switch_network_list_t *new_list;
-	
+
 	if (!pool) {
 		switch_core_new_memory_pool(&pool);
 	}
@@ -82,7 +82,7 @@
 	switch_network_node_t *node;
 	switch_bool_t ok = list->default_type;
 	uint32_t bits = 0;
-	
+
 	for (node = list->node_head; node; node = node->next) {
 		if (node->bits > bits && switch_test_subnet(ip, node->ip, node->mask)) {
 			if (node->ok) {
@@ -93,7 +93,7 @@
 			bits = node->bits;
 		}
 	}
-	
+
 	return ok;
 }
 
@@ -102,11 +102,11 @@
 {
 	uint32_t ip, mask, bits;
 	switch_network_node_t *node;
-	
+
 	if (switch_parse_cidr(cidr_str, &ip, &mask, &bits)) {
 		return SWITCH_STATUS_GENERR;
 	}
-	
+
 	node = switch_core_alloc(list->pool, sizeof(*node));
 
 	node->ip = ip;
@@ -116,7 +116,7 @@
 
 	node->next = list->node_head;
 	list->node_head = node;
-	
+
 	return SWITCH_STATUS_SUCCESS;
 }
 
@@ -128,21 +128,21 @@
 
 	switch_inet_pton(AF_INET, host, &ip);
 	switch_inet_pton(AF_INET, mask_str, &mask);
-	
+
 	node = switch_core_alloc(list->pool, sizeof(*node));
-	
+
 	node->ip = ip;
 	node->mask = mask;
 	node->ok = ok;
 
 	/* http://graphics.stanford.edu/~seander/bithacks.html */
 	mask = mask - ((mask >> 1) & 0x55555555);
-    mask = (mask & 0x33333333) + ((mask >> 2) & 0x33333333);
+	mask = (mask & 0x33333333) + ((mask >> 2) & 0x33333333);
 	node->bits = (((mask + (mask >> 4)) & 0xF0F0F0F) * 0x1010101) >> 24;
-	
+
 	node->next = list->node_head;
 	list->node_head = node;
-	
+
 	return SWITCH_STATUS_SUCCESS;
 }
 
@@ -162,7 +162,7 @@
 
 	*bit_str++ = '\0';
 	bits = atoi(bit_str);
-	
+
 	if (bits < 0 || bits > 32) {
 		return -2;
 	}
@@ -180,7 +180,7 @@
 {
 	const char *e = NULL;
 	int depth = 0;
-	
+
 	while (s && *s && *s == ' ') {
 		s++;
 	}
@@ -199,7 +199,7 @@
 		}
 	}
 
-	return (char *)e;
+	return (char *) e;
 }
 
 SWITCH_DECLARE(switch_size_t) switch_fd_read_line(int fd, char *buf, switch_size_t len)
@@ -230,10 +230,10 @@
 
 	q = buf;
 
-	for(p = s; x < len; p++) {
-		switch(*p) {
+	for (p = s; x < len; p++) {
+		switch (*p) {
 		case '<':
-			if (x + 4 > len -1) {
+			if (x + 4 > len - 1) {
 				goto end;
 			}
 			*q++ = '&';
@@ -243,7 +243,7 @@
 			x += 4;
 			break;
 		case '>':
-			if (x + 4 > len -1) {
+			if (x + 4 > len - 1) {
 				goto end;
 			}
 			*q++ = '&';
@@ -253,7 +253,7 @@
 			x += 4;
 			break;
 		default:
-			if (x + 1 > len -1) {
+			if (x + 1 > len - 1) {
 				goto end;
 			}
 			*q++ = *p;
@@ -265,7 +265,7 @@
 		}
 	}
 
- end:
+  end:
 
 	return buf;
 }
@@ -274,33 +274,33 @@
 #define B64BUFFLEN 1024
 SWITCH_DECLARE(switch_status_t) switch_b64_encode(unsigned char *in, switch_size_t ilen, unsigned char *out, switch_size_t olen)
 {
-    int y = 0, bytes = 0;
-    size_t x = 0;
-    unsigned int b = 0,l = 0;
-
-    for(x = 0; x < ilen; x++) {
-        b = (b<<8) + in[x];
-        l += 8;
-        while (l >= 6) {
-            out[bytes++] = switch_b64_table[(b>>(l-=6))%64];
-            if (++y != 72) {
-                continue;
-            }
-            //out[bytes++] = '\n';
-            y=0;
-        }
-    }
-
-    if (l > 0) {
-        out[bytes++] = switch_b64_table[((b%16)<<(6-l))%64];
-    }
-    if (l != 0) {
+	int y = 0, bytes = 0;
+	size_t x = 0;
+	unsigned int b = 0, l = 0;
+
+	for (x = 0; x < ilen; x++) {
+		b = (b << 8) + in[x];
+		l += 8;
+		while (l >= 6) {
+			out[bytes++] = switch_b64_table[(b >> (l -= 6)) % 64];
+			if (++y != 72) {
+				continue;
+			}
+			//out[bytes++] = '\n';
+			y = 0;
+		}
+	}
+
+	if (l > 0) {
+		out[bytes++] = switch_b64_table[((b % 16) << (6 - l)) % 64];
+	}
+	if (l != 0) {
 		while (l < 6) {
 			out[bytes++] = '=', l += 2;
 		}
 	}
 
-    return SWITCH_STATUS_SUCCESS;
+	return SWITCH_STATUS_SUCCESS;
 }
 
 SWITCH_DECLARE(switch_size_t) switch_b64_decode(char *in, char *out, switch_size_t olen)
@@ -311,16 +311,16 @@
 	char *ip, *op = out;
 	size_t ol = 0;
 
-	for (i=0; i<256; i++) {
+	for (i = 0; i < 256; i++) {
 		l64[i] = -1;
 	}
 
-	for (i=0; i<64; i++) {
-		l64[(int)switch_b64_table[i]] = (char)i;
+	for (i = 0; i < 64; i++) {
+		l64[(int) switch_b64_table[i]] = (char) i;
 	}
 
 	for (ip = in; ip && *ip; ip++) {
-		c = l64[(int)*ip];
+		c = l64[(int) *ip];
 		if (c == -1) {
 			continue;
 		}
@@ -329,14 +329,14 @@
 		l += 6;
 
 		while (l >= 8) {
-			op[ol++] = (char)((b >> (l -= 8)) % 256);
-			if (ol >= olen -2) {
+			op[ol++] = (char) ((b >> (l -= 8)) % 256);
+			if (ol >= olen - 2) {
 				goto end;
 			}
 		}
 	}
 
- end:
+  end:
 
 	op[ol++] = '\0';
 
@@ -366,40 +366,40 @@
 	unsigned char in[B64BUFFLEN];
 	unsigned char out[B64BUFFLEN + 512];
 
-    switch_snprintf(filename, 80, "%smail.%d%04x", SWITCH_GLOBAL_dirs.temp_dir, (int)switch_timestamp(NULL), rand() & 0xffff);
-    
-    if ((fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0644))) {
-        if (file) {
-            if ((ifd = open(file, O_RDONLY)) < 1) {
-                return SWITCH_FALSE;
-            }
-        }
-        switch_snprintf(buf, B64BUFFLEN, "MIME-Version: 1.0\nContent-Type: multipart/mixed; boundary=\"%s\"\n", bound);
-        if (!write_buf(fd, buf)) {
-            return SWITCH_FALSE;
-        }
+	switch_snprintf(filename, 80, "%smail.%d%04x", SWITCH_GLOBAL_dirs.temp_dir, (int) switch_timestamp(NULL), rand() & 0xffff);
 
-        if (headers && !write_buf(fd, headers))
-            return SWITCH_FALSE;
+	if ((fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0644))) {
+		if (file) {
+			if ((ifd = open(file, O_RDONLY)) < 1) {
+				return SWITCH_FALSE;
+			}
+		}
+		switch_snprintf(buf, B64BUFFLEN, "MIME-Version: 1.0\nContent-Type: multipart/mixed; boundary=\"%s\"\n", bound);
+		if (!write_buf(fd, buf)) {
+			return SWITCH_FALSE;
+		}
 
-        if (!write_buf(fd, "\n\n"))
-            return SWITCH_FALSE;
+		if (headers && !write_buf(fd, headers))
+			return SWITCH_FALSE;
+
+		if (!write_buf(fd, "\n\n"))
+			return SWITCH_FALSE;
 
 		if (body && switch_stristr("content-type", body)) {
 			switch_snprintf(buf, B64BUFFLEN, "--%s\n", bound);
 		} else {
 			switch_snprintf(buf, B64BUFFLEN, "--%s\nContent-Type: text/plain\n\n", bound);
 		}
-        if (!write_buf(fd, buf))
-            return SWITCH_FALSE;
+		if (!write_buf(fd, buf))
+			return SWITCH_FALSE;
 
-        if (body) {
-            if (!write_buf(fd, body)) {
-                return SWITCH_FALSE;
-            }
-        }
+		if (body) {
+			if (!write_buf(fd, body)) {
+				return SWITCH_FALSE;
+			}
+		}
 
-        if (file) {
+		if (file) {
 			const char *stipped_file = switch_cut_path(file);
 			const char *new_type;
 			char *ext;
@@ -412,82 +412,81 @@
 			}
 
 			switch_snprintf(buf, B64BUFFLEN,
-					 "\n\n--%s\nContent-Type: %s; name=\"%s\"\n"
-					 "Content-ID: <ATTACHED at freeswitch.org>\n"
-					 "Content-Transfer-Encoding: base64\n"
-					 "Content-Description: Sound attachment.\n"
-					 "Content-Disposition: attachment; filename=\"%s\"\n\n",
-					 bound, mime_type, stipped_file, stipped_file);
-            if (!write_buf(fd, buf))
-                return SWITCH_FALSE;
-
-            while ((ilen = read(ifd, in, B64BUFFLEN))) {
-                for (x = 0; x < ilen; x++) {
-                    b = (b << 8) + in[x];
-                    l += 8;
-                    while (l >= 6) {
-                        out[bytes++] = switch_b64_table[(b >> (l -= 6)) % 64];
-                        if (++y != 72)
-                            continue;
-                        out[bytes++] = '\n';
-                        y = 0;
-                    }
-                }
-                if (write(fd, &out, bytes) != bytes) {
-                    return -1;
-                } else
-                    bytes = 0;
-
-            }
-
-            if (l > 0) {
-                out[bytes++] = switch_b64_table[((b % 16) << (6 - l)) % 64];
-            }
-            if (l != 0)
-                while (l < 6) {
-                    out[bytes++] = '=', l += 2;
-                }
-            if (write(fd, &out, bytes) != bytes) {
-                return -1;
-            }
-
-        }
-
-        switch_snprintf(buf, B64BUFFLEN, "\n\n--%s--\n.\n", bound);
-        if (!write_buf(fd, buf))
-            return SWITCH_FALSE;
-    }
-
-    if (fd) {
-        close(fd);
-    }
-    if (ifd) {
-        close(ifd);
-    }
-    switch_snprintf(buf, B64BUFFLEN, "/bin/cat %s | %s %s %s", filename, runtime.mailer_app, runtime.mailer_app_args, to);
-    if (system(buf)) {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to execute command: %s\n", buf);
-    }
+							"\n\n--%s\nContent-Type: %s; name=\"%s\"\n"
+							"Content-ID: <ATTACHED at freeswitch.org>\n"
+							"Content-Transfer-Encoding: base64\n"
+							"Content-Description: Sound attachment.\n"
+							"Content-Disposition: attachment; filename=\"%s\"\n\n", bound, mime_type, stipped_file, stipped_file);
+			if (!write_buf(fd, buf))
+				return SWITCH_FALSE;
+
+			while ((ilen = read(ifd, in, B64BUFFLEN))) {
+				for (x = 0; x < ilen; x++) {
+					b = (b << 8) + in[x];
+					l += 8;
+					while (l >= 6) {
+						out[bytes++] = switch_b64_table[(b >> (l -= 6)) % 64];
+						if (++y != 72)
+							continue;
+						out[bytes++] = '\n';
+						y = 0;
+					}
+				}
+				if (write(fd, &out, bytes) != bytes) {
+					return -1;
+				} else
+					bytes = 0;
+
+			}
+
+			if (l > 0) {
+				out[bytes++] = switch_b64_table[((b % 16) << (6 - l)) % 64];
+			}
+			if (l != 0)
+				while (l < 6) {
+					out[bytes++] = '=', l += 2;
+				}
+			if (write(fd, &out, bytes) != bytes) {
+				return -1;
+			}
+
+		}
+
+		switch_snprintf(buf, B64BUFFLEN, "\n\n--%s--\n.\n", bound);
+		if (!write_buf(fd, buf))
+			return SWITCH_FALSE;
+	}
+
+	if (fd) {
+		close(fd);
+	}
+	if (ifd) {
+		close(ifd);
+	}
+	switch_snprintf(buf, B64BUFFLEN, "/bin/cat %s | %s %s %s", filename, runtime.mailer_app, runtime.mailer_app_args, to);
+	if (system(buf)) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to execute command: %s\n", buf);
+	}
 
 	if (unlink(filename) != 0) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "failed to delete file [%s]\n", filename);
 	}
 
-    if (file) {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Emailed file [%s] to [%s]\n", filename, to);
-    } else {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Emailed data to [%s]\n", to);
-    }
+	if (file) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Emailed file [%s] to [%s]\n", filename, to);
+	} else {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Emailed data to [%s]\n", to);
+	}
 
-    return SWITCH_TRUE;
+	return SWITCH_TRUE;
 }
 
 SWITCH_DECLARE(switch_bool_t) switch_is_lan_addr(const char *ip)
 {
-	if (switch_strlen_zero(ip)) return SWITCH_FALSE;
+	if (switch_strlen_zero(ip))
+		return SWITCH_FALSE;
 
-	return (
-			strncmp(ip, "10.", 3) &&
+	return (strncmp(ip, "10.", 3) &&
 			strncmp(ip, "192.168.", 8) &&
 			strncmp(ip, "127.", 4) &&
 			strncmp(ip, "255.", 4) &&
@@ -498,12 +497,8 @@
 			strncmp(ip, "172.17.", 7) &&
 			strncmp(ip, "172.18.", 7) &&
 			strncmp(ip, "172.19.", 7) &&
-			strncmp(ip, "172.2", 5) &&
-			strncmp(ip, "172.30.", 7) &&
-			strncmp(ip, "172.31.", 7) &&
-			strncmp(ip, "192.0.2.", 8) &&
-			strncmp(ip, "169.254.", 8)
-			) ? SWITCH_FALSE : SWITCH_TRUE;	
+			strncmp(ip, "172.2", 5) && strncmp(ip, "172.30.", 7) && strncmp(ip, "172.31.", 7) && strncmp(ip, "192.0.2.", 8) && strncmp(ip, "169.254.", 8)
+		)? SWITCH_FALSE : SWITCH_TRUE;
 }
 
 SWITCH_DECLARE(switch_bool_t) switch_ast2regex(char *pat, char *rbuf, size_t len)
@@ -515,10 +510,10 @@
 	}
 
 	memset(rbuf, 0, len);
-	
+
 	*(rbuf + strlen(rbuf)) = '^';
 
-	while(p && *p) {
+	while (p && *p) {
 		if (*p == 'N') {
 			strncat(rbuf, "[2-9]", len - strlen(rbuf));
 		} else if (*p == 'X') {
@@ -534,7 +529,7 @@
 	}
 	*(rbuf + strlen(rbuf)) = '$';
 
-	return strcmp(pat,rbuf) ? SWITCH_TRUE : SWITCH_FALSE;
+	return strcmp(pat, rbuf) ? SWITCH_TRUE : SWITCH_FALSE;
 }
 
 SWITCH_DECLARE(char *) switch_replace_char(char *str, char from, char to, switch_bool_t dup)
@@ -548,7 +543,7 @@
 		p = str;
 	}
 
-	for(;p && *p; p++) {
+	for (; p && *p; p++) {
 		if (*p == from) {
 			*p = to;
 		}
@@ -561,23 +556,25 @@
 {
 	const char *sp = str;
 	char *p, *s = NULL;
-	
-	if (!sp) return NULL;
 
-	while(*sp == ' ') {
+	if (!sp)
+		return NULL;
+
+	while (*sp == ' ') {
 		sp++;
 	}
-	
+
 	s = strdup(sp);
 
-	if (!s) return NULL;
+	if (!s)
+		return NULL;
 
 	p = s + (strlen(s) - 1);
 
-	while(*p == ' ') {
+	while (*p == ' ') {
 		*p-- = '\0';
 	}
-	
+
 	return s;
 }
 
@@ -589,12 +586,12 @@
 	if ((args = strchr(str, '('))) {
 		e = args - 1;
 		*args++ = '\0';
-		while(*e == ' ') {
+		while (*e == ' ') {
 			*e-- = '\0';
 		}
 		e = args;
 		br = 1;
-		while(e && *e) {
+		while (e && *e) {
 			if (*e == '(') {
 				br++;
 			} else if (br > 1 && *e == ')') {
@@ -642,7 +639,7 @@
 
 	for (start = str; *start; start++) {
 		/* find start of pattern in string */
-		for ( ; ((*start) && (toupper(*start) != toupper(*instr))); start++);
+		for (; ((*start) && (toupper(*start) != toupper(*instr))); start++);
 
 		if (!*start)
 			return NULL;
@@ -709,8 +706,9 @@
 	getaddrinfo(base, NULL, NULL, &address_info);
 
 	if (!address_info || WSAIoctl(tmp_socket,
-				 SIO_ROUTING_INTERFACE_QUERY,
-				 address_info->ai_addr, (DWORD) address_info->ai_addrlen, &l_address, sizeof(l_address), (LPDWORD) & l_address_len, NULL, NULL)) {
+								  SIO_ROUTING_INTERFACE_QUERY,
+								  address_info->ai_addr, (DWORD) address_info->ai_addrlen, &l_address, sizeof(l_address), (LPDWORD) & l_address_len, NULL,
+								  NULL)) {
 
 		closesocket(tmp_socket);
 		if (address_info)
@@ -921,8 +919,7 @@
  * author:
  *	Paul Vixie, 1996.
  */
-const char *
-switch_inet_ntop(int af, void const *src, char *dst, size_t size)
+const char *switch_inet_ntop(int af, void const *src, char *dst, size_t size)
 {
 
 	switch (af) {
@@ -949,14 +946,12 @@
  * author:
  *	Paul Vixie, 1996.
  */
-static const char *
-switch_inet_ntop4(const unsigned char *src, char *dst, size_t size)
+static const char *switch_inet_ntop4(const unsigned char *src, char *dst, size_t size)
 {
 	static const char fmt[] = "%u.%u.%u.%u";
 	char tmp[sizeof "255.255.255.255"];
 
-	if (switch_snprintf(tmp, sizeof tmp, fmt,
-		     src[0], src[1], src[2], src[3]) >= (int)size) {
+	if (switch_snprintf(tmp, sizeof tmp, fmt, src[0], src[1], src[2], src[3]) >= (int) size) {
 		return NULL;
 	}
 
@@ -970,8 +965,7 @@
  * author:
  *	Paul Vixie, 1996.
  */
-static const char *
-switch_inet_ntop6(unsigned char const *src, char *dst, size_t size)
+static const char *switch_inet_ntop6(unsigned char const *src, char *dst, size_t size)
 {
 	/*
 	 * Note that int32_t and int16_t need only be "at least" large enough
@@ -981,14 +975,18 @@
 	 * to use pointer overlays.  All the world's not a VAX.
 	 */
 	char tmp[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"], *tp;
-	struct { int base, len; } best = { -1 , 0 }, cur = { -1, 0 };
+	struct {
+		int base, len;
+	} best = {
+	-1, 0}, cur = {
+	-1, 0};
 	unsigned int words[8];
 	int i;
 
 	/*
 	 * Preprocess:
-	 *	Copy the input (bytewise) array into a wordwise array.
-	 *	Find the longest run of 0x00's in src[] for :: shorthanding.
+	 *  Copy the input (bytewise) array into a wordwise array.
+	 *  Find the longest run of 0x00's in src[] for :: shorthanding.
 	 */
 	for (i = 0; i < 16; i += 2)
 		words[i / 2] = (src[i] << 8) | (src[i + 1]);
@@ -1021,8 +1019,7 @@
 	tp = tmp;
 	for (i = 0; i < 8; i++) {
 		/* Are we inside the best run of 0x00's? */
-		if (best.base != -1 && i >= best.base &&
-		    i < (best.base + best.len)) {
+		if (best.base != -1 && i >= best.base && i < (best.base + best.len)) {
 			if (i == best.base)
 				*tp++ = ':';
 			continue;
@@ -1031,9 +1028,8 @@
 		if (i != 0)
 			*tp++ = ':';
 		/* Is this address an encapsulated IPv4? */
-		if (i == 6 && best.base == 0 &&
-		    (best.len == 6 || (best.len == 5 && words[5] == 0xffff))) {
-			if (!inet_ntop4(src+12, tp, sizeof tmp - (tp - tmp)))
+		if (i == 6 && best.base == 0 && (best.len == 6 || (best.len == 5 && words[5] == 0xffff))) {
+			if (!inet_ntop4(src + 12, tp, sizeof tmp - (tp - tmp)))
 				return (NULL);
 			tp += strlen(tp);
 			break;
@@ -1048,7 +1044,7 @@
 	/*
 	 * Check for overflow, copy, and we're done.
 	 */
-	if ((size_t)(tp - tmp) >= size) {
+	if ((size_t) (tp - tmp) >= size) {
 		return NULL;
 	}
 
@@ -1144,20 +1140,20 @@
 	char unescaped;
 
 	switch (escaped) {
-		case 'n':
-			unescaped = '\n';
-			break;
-		case 'r':
-			unescaped = '\r';
-			break;
-		case 't':
-			unescaped = '\t';
-			break;
-		case 's':
-			unescaped = ' ';
-			break;
-		default:
-			unescaped = escaped;
+	case 'n':
+		unescaped = '\n';
+		break;
+	case 'r':
+		unescaped = '\r';
+		break;
+	case 't':
+		unescaped = '\t';
+		break;
+	case 's':
+		unescaped = ' ';
+		break;
+	default:
+		unescaped = escaped;
 	}
 	return unescaped;
 }
@@ -1181,8 +1177,8 @@
 		int esc = 0;
 
 		if (*ptr == ESCAPE_META) {
-			e = *(ptr+1);
-			if (e == '\'' || e == '"' || (delim && e == delim) || (e = unescape_char(*(ptr+1))) != *(ptr+1)) {
+			e = *(ptr + 1);
+			if (e == '\'' || e == '"' || (delim && e == delim) || (e = unescape_char(*(ptr + 1))) != *(ptr + 1)) {
 				++ptr;
 				*dest++ = e;
 				end = dest;
@@ -1216,28 +1212,28 @@
 
 	unsigned int count = 0;
 	char *ptr = buf;
-	int  inside_quotes = 0;
+	int inside_quotes = 0;
 	unsigned int i;
-	
+
 	while (*ptr && count < arraylen) {
 		switch (state) {
-			case START:
-				array[count++] = ptr;
-				state = FIND_DELIM;
-				break;
+		case START:
+			array[count++] = ptr;
+			state = FIND_DELIM;
+			break;
 
-			case FIND_DELIM:
-				/* escaped characters are copied verbatim to the destination string */
-				if (*ptr == ESCAPE_META) {
-					++ptr;
-				} else if (*ptr == '\'') {
-					inside_quotes = (1 - inside_quotes);
-				} else if (*ptr == delim && !inside_quotes) {
-					*ptr = '\0';
-					state = START;
-				}
+		case FIND_DELIM:
+			/* escaped characters are copied verbatim to the destination string */
+			if (*ptr == ESCAPE_META) {
 				++ptr;
-				break;
+			} else if (*ptr == '\'') {
+				inside_quotes = (1 - inside_quotes);
+			} else if (*ptr == delim && !inside_quotes) {
+				*ptr = '\0';
+				state = START;
+			}
+			++ptr;
+			break;
 		}
 	}
 	/* strip quotes, escaped chars and leading / trailing spaces */
@@ -1259,43 +1255,43 @@
 
 	unsigned int count = 0;
 	char *ptr = buf;
-	int  inside_quotes = 0;
+	int inside_quotes = 0;
 	unsigned int i;
 
 	while (*ptr && count < arraylen) {
 		switch (state) {
-			case START:
-				array[count++] = ptr;
-				state = SKIP_INITIAL_SPACE;
-				break;
+		case START:
+			array[count++] = ptr;
+			state = SKIP_INITIAL_SPACE;
+			break;
 
-			case SKIP_INITIAL_SPACE:
-				if (*ptr == ' ') {
-					++ptr;
-				} else {
-					state = FIND_DELIM;
-				}
-				break;
+		case SKIP_INITIAL_SPACE:
+			if (*ptr == ' ') {
+				++ptr;
+			} else {
+				state = FIND_DELIM;
+			}
+			break;
 
-			case FIND_DELIM:
-				if (*ptr == ESCAPE_META) {
-					++ptr;
-				} else if (*ptr == '\'') {
-					inside_quotes = (1 - inside_quotes);
-				} else if (*ptr == ' ' && !inside_quotes) {
-					*ptr = '\0';
-					state = SKIP_ENDING_SPACE;
-				}
+		case FIND_DELIM:
+			if (*ptr == ESCAPE_META) {
 				++ptr;
-				break;
+			} else if (*ptr == '\'') {
+				inside_quotes = (1 - inside_quotes);
+			} else if (*ptr == ' ' && !inside_quotes) {
+				*ptr = '\0';
+				state = SKIP_ENDING_SPACE;
+			}
+			++ptr;
+			break;
 
-			case SKIP_ENDING_SPACE:
-				if (*ptr == ' ') {
-					++ptr;
-				} else {
-					state = START;
-				}
-				break;
+		case SKIP_ENDING_SPACE:
+			if (*ptr == ' ') {
+				++ptr;
+			} else {
+				state = START;
+			}
+			break;
 		}
 	}
 	/* strip quotes, escaped chars and leading / trailing spaces */
@@ -1311,11 +1307,9 @@
 		return 0;
 	}
 
-	memset(array, 0, arraylen * sizeof (*array));
+	memset(array, 0, arraylen * sizeof(*array));
 
-	return (delim == ' ' ?
-			separate_string_blank_delim(buf, array, arraylen) :
-			separate_string_char_delim(buf, delim, array, arraylen));
+	return (delim == ' ' ? separate_string_blank_delim(buf, array, arraylen) : separate_string_char_delim(buf, delim, array, arraylen));
 }
 
 SWITCH_DECLARE(const char *) switch_cut_path(const char *in)
@@ -1389,7 +1383,7 @@
 	return dest;
 }
 
-SWITCH_DECLARE(int) switch_socket_waitfor(switch_pollfd_t * poll, int ms)
+SWITCH_DECLARE(int) switch_socket_waitfor(switch_pollfd_t *poll, int ms)
 {
 	int nsds = 0;
 



More information about the Freeswitch-svn mailing list