indent pass 1

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@8686 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2008-05-27 04:30:03 +00:00
parent 49ff246b7c
commit 3c349c274e
66 changed files with 3258 additions and 3498 deletions

View File

@ -1,4 +1,5 @@
#!/bin/bash #!/bin/bash
echo -n "-brs -npsl -di0 -br -ce -d0 -cli0 -npcs -nfc1 -ut -i4 -ts4 -l155 -cs -T size_t " > ./.indent.pro 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 grep "} switch_" ./src/include/*.h | perl -ne '@l = split; $l[1] =~ s/;//g ; print " -T $l[1] "' >> ./.indent.pro

View File

@ -196,30 +196,32 @@ enum SG_Error {
#endif #endif
/*! @brief String manipulation functions. */ /*! @brief String manipulation functions. */
class SimpleGlobUtil class SimpleGlobUtil {
{ public:
public: static const char *strchr(const char *s, char c) {
static const char * strchr(const char *s, char c) { return (char *) sg_strchr((const SOCHAR_T *) s, 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 wchar_t * strchr(const wchar_t *s, wchar_t c) {
return ::wcschr(s, c);
} }
static const char * strrchr(const char *s, char c) { static const char *strrchr(const char *s, char c) {
return (char *) sg_strrchr((const SOCHAR_T *)s, c); return (char *) sg_strrchr((const SOCHAR_T *) s, c);
} }
static const wchar_t * strrchr(const wchar_t *s, wchar_t c) { static const wchar_t *strrchr(const wchar_t *s, wchar_t c) {
return ::wcsrchr(s, c); return::wcsrchr(s, c);
} }
// Note: char strlen returns number of bytes, not characters // Note: char strlen returns number of bytes, not characters
static size_t strlen(const char *s) { return ::strlen(s); } static size_t strlen(const char *s) {
static size_t strlen(const wchar_t *s) { return ::wcslen(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) { static void strcpy_s(char *dst, size_t n, const char *src) {
(void) n; (void) n;
sg_strcpy_s((SOCHAR_T *)dst, n, (const SOCHAR_T *)src); 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) { static void strcpy_s(wchar_t *dst, size_t n, const wchar_t *src) {
# if __STDC_WANT_SECURE_LIB__ # if __STDC_WANT_SECURE_LIB__
@ -231,18 +233,18 @@ public:
} }
static int strcmp(const char *s1, const char *s2) { static int strcmp(const char *s1, const char *s2) {
return sg_strcmp((const SOCHAR_T *)s1, (const SOCHAR_T *)s2); return sg_strcmp((const SOCHAR_T *) s1, (const SOCHAR_T *) s2);
} }
static int strcmp(const wchar_t *s1, const wchar_t *s2) { static int strcmp(const wchar_t *s1, const wchar_t *s2) {
return ::wcscmp(s1, s2); return::wcscmp(s1, s2);
} }
static int strcasecmp(const char *s1, const char *s2) { static int strcasecmp(const char *s1, const char *s2) {
return sg_strcasecmp((const SOCHAR_T *)s1, (const SOCHAR_T *)s2); return sg_strcasecmp((const SOCHAR_T *) s1, (const SOCHAR_T *) s2);
} }
#if _WIN32 #if _WIN32
static int strcasecmp(const wchar_t *s1, const wchar_t *s2) { static int strcasecmp(const wchar_t *s1, const wchar_t *s2) {
return ::_wcsicmp(s1, s2); return::_wcsicmp(s1, s2);
} }
#endif // _WIN32 #endif // _WIN32
}; };
@ -262,12 +264,9 @@ enum SG_FileType {
#define SG_PATH_CHAR '\\' #define SG_PATH_CHAR '\\'
/*! @brief Windows glob implementation. */ /*! @brief Windows glob implementation. */
template<class SOCHAR> template < class SOCHAR > struct SimpleGlobBase {
struct SimpleGlobBase SimpleGlobBase():m_hFind(INVALID_HANDLE_VALUE) {
{ } int FindFirstFileS(const char *a_pszFileSpec, unsigned int) {
SimpleGlobBase() : m_hFind(INVALID_HANDLE_VALUE) { }
int FindFirstFileS(const char * a_pszFileSpec, unsigned int) {
m_hFind = FindFirstFileA(a_pszFileSpec, &m_oFindDataA); m_hFind = FindFirstFileA(a_pszFileSpec, &m_oFindDataA);
if (m_hFind != INVALID_HANDLE_VALUE) { if (m_hFind != INVALID_HANDLE_VALUE) {
return SG_SUCCESS; return SG_SUCCESS;
@ -278,7 +277,7 @@ struct SimpleGlobBase
} }
return SG_ERR_FAILURE; return SG_ERR_FAILURE;
} }
int FindFirstFileS(const wchar_t * a_pszFileSpec, unsigned int) { int FindFirstFileS(const wchar_t *a_pszFileSpec, unsigned int) {
m_hFind = FindFirstFileW(a_pszFileSpec, &m_oFindDataW); m_hFind = FindFirstFileW(a_pszFileSpec, &m_oFindDataW);
if (m_hFind != INVALID_HANDLE_VALUE) { if (m_hFind != INVALID_HANDLE_VALUE) {
return SG_SUCCESS; return SG_SUCCESS;
@ -301,24 +300,18 @@ struct SimpleGlobBase
FindClose(m_hFind); FindClose(m_hFind);
} }
const char * GetFileNameS(char) const { const char *GetFileNameS(char) const {
return m_oFindDataA.cFileName; return m_oFindDataA.cFileName;
} } const wchar_t *GetFileNameS(wchar_t) const {
const wchar_t * GetFileNameS(wchar_t) const {
return m_oFindDataW.cFileName; return m_oFindDataW.cFileName;
} } bool IsDirS(char) const {
bool IsDirS(char) const {
return GetFileTypeS(m_oFindDataA.dwFileAttributes) == SG_FILETYPE_DIR; return GetFileTypeS(m_oFindDataA.dwFileAttributes) == SG_FILETYPE_DIR;
} } bool IsDirS(wchar_t) const {
bool IsDirS(wchar_t) const {
return GetFileTypeS(m_oFindDataW.dwFileAttributes) == SG_FILETYPE_DIR; return GetFileTypeS(m_oFindDataW.dwFileAttributes) == SG_FILETYPE_DIR;
} } SG_FileType GetFileTypeS(const char *a_pszPath) {
SG_FileType GetFileTypeS(const char * a_pszPath) {
return GetFileTypeS(GetFileAttributesA(a_pszPath)); return GetFileTypeS(GetFileAttributesA(a_pszPath));
} }
SG_FileType GetFileTypeS(const wchar_t * a_pszPath) { SG_FileType GetFileTypeS(const wchar_t *a_pszPath) {
return GetFileTypeS(GetFileAttributesW(a_pszPath)); return GetFileTypeS(GetFileAttributesW(a_pszPath));
} }
SG_FileType GetFileTypeS(DWORD a_dwAttribs) const { SG_FileType GetFileTypeS(DWORD a_dwAttribs) const {
@ -331,7 +324,7 @@ struct SimpleGlobBase
return SG_FILETYPE_FILE; return SG_FILETYPE_FILE;
} }
private: private:
HANDLE m_hFind; HANDLE m_hFind;
WIN32_FIND_DATAA m_oFindDataA; WIN32_FIND_DATAA m_oFindDataA;
WIN32_FIND_DATAW m_oFindDataW; WIN32_FIND_DATAW m_oFindDataW;
@ -342,44 +335,45 @@ private:
#define SG_PATH_CHAR '/' #define SG_PATH_CHAR '/'
/*! @brief Unix glob implementation. */ /*! @brief Unix glob implementation. */
template<class SOCHAR> template < class SOCHAR > struct SimpleGlobBase {
struct SimpleGlobBase
{
SimpleGlobBase() { SimpleGlobBase() {
memset(&m_glob, 0, sizeof(m_glob)); memset(&m_glob, 0, sizeof(m_glob));
m_uiCurr = (size_t)-1; m_uiCurr = (size_t) -1;
} } ~SimpleGlobBase() {
~SimpleGlobBase() {
globfree(&m_glob); globfree(&m_glob);
} }
void FilePrep() { void FilePrep() {
m_bIsDir = false; m_bIsDir = false;
size_t len = strlen(m_glob.gl_pathv[m_uiCurr]); size_t len = strlen(m_glob.gl_pathv[m_uiCurr]);
if (m_glob.gl_pathv[m_uiCurr][len-1] == '/') { if (m_glob.gl_pathv[m_uiCurr][len - 1] == '/') {
m_bIsDir = true; m_bIsDir = true;
m_glob.gl_pathv[m_uiCurr][len-1] = 0; m_glob.gl_pathv[m_uiCurr][len - 1] = 0;
} }
} }
int FindFirstFileS(const char * a_pszFileSpec, unsigned int a_uiFlags) { int FindFirstFileS(const char *a_pszFileSpec, unsigned int a_uiFlags) {
int nFlags = GLOB_MARK | GLOB_NOSORT; int nFlags = GLOB_MARK | GLOB_NOSORT;
if (a_uiFlags & SG_GLOB_ERR) nFlags |= GLOB_ERR; if (a_uiFlags & SG_GLOB_ERR)
nFlags |= GLOB_ERR;
#ifdef GLOB_TILDE #ifdef GLOB_TILDE
if (a_uiFlags & SG_GLOB_TILDE) nFlags |= GLOB_TILDE; if (a_uiFlags & SG_GLOB_TILDE)
nFlags |= GLOB_TILDE;
#endif #endif
int rc = glob(a_pszFileSpec, nFlags, NULL, &m_glob); int rc = glob(a_pszFileSpec, nFlags, NULL, &m_glob);
if (rc == GLOB_NOSPACE) return SG_ERR_MEMORY; if (rc == GLOB_NOSPACE)
if (rc == GLOB_ABORTED) return SG_ERR_FAILURE; return SG_ERR_MEMORY;
if (rc == GLOB_NOMATCH) return SG_ERR_NOMATCH; if (rc == GLOB_ABORTED)
return SG_ERR_FAILURE;
if (rc == GLOB_NOMATCH)
return SG_ERR_NOMATCH;
m_uiCurr = 0; m_uiCurr = 0;
FilePrep(); FilePrep();
return SG_SUCCESS; return SG_SUCCESS;
} }
bool FindNextFileS(char) { bool FindNextFileS(char) {
SG_ASSERT(m_uiCurr != (size_t)-1); SG_ASSERT(m_uiCurr != (size_t) -1);
if (++m_uiCurr >= m_glob.gl_pathc) { if (++m_uiCurr >= m_glob.gl_pathc) {
return false; return false;
} }
@ -390,20 +384,16 @@ struct SimpleGlobBase
void FindDone() { void FindDone() {
globfree(&m_glob); globfree(&m_glob);
memset(&m_glob, 0, sizeof(m_glob)); memset(&m_glob, 0, sizeof(m_glob));
m_uiCurr = (size_t)-1; m_uiCurr = (size_t) -1;
} }
const char * GetFileNameS(char) const { const char *GetFileNameS(char) const {
SG_ASSERT(m_uiCurr != (size_t)-1); SG_ASSERT(m_uiCurr != (size_t) -1);
return m_glob.gl_pathv[m_uiCurr]; return m_glob.gl_pathv[m_uiCurr];
} } bool IsDirS(char) const {
SG_ASSERT(m_uiCurr != (size_t) -1);
bool IsDirS(char) const {
SG_ASSERT(m_uiCurr != (size_t)-1);
return m_bIsDir; return m_bIsDir;
} } SG_FileType GetFileTypeS(const char *a_pszPath) const {
SG_FileType GetFileTypeS(const char * a_pszPath) const {
struct stat sb; struct stat sb;
if (0 != stat(a_pszPath, &sb)) { if (0 != stat(a_pszPath, &sb)) {
return SG_FILETYPE_INVALID; return SG_FILETYPE_INVALID;
@ -417,7 +407,7 @@ struct SimpleGlobBase
return SG_FILETYPE_INVALID; return SG_FILETYPE_INVALID;
} }
private: private:
glob_t m_glob; glob_t m_glob;
size_t m_uiCurr; size_t m_uiCurr;
bool m_bIsDir; bool m_bIsDir;
@ -432,10 +422,8 @@ private:
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
/*! @brief Implementation of the SimpleGlob class */ /*! @brief Implementation of the SimpleGlob class */
template<class SOCHAR> template < class SOCHAR > class CSimpleGlobTempl:private SimpleGlobBase < SOCHAR > {
class CSimpleGlobTempl : private SimpleGlobBase<SOCHAR> public:
{
public:
/*! @brief Initialize the class. /*! @brief Initialize the class.
@param a_uiFlags Combination of SG_GLOB flags. @param a_uiFlags Combination of SG_GLOB flags.
@ -476,7 +464,7 @@ public:
@return SG_ERR_MEMORY Out of memory failure. @return SG_ERR_MEMORY Out of memory failure.
@return SG_ERR_FAILURE General failure. @return SG_ERR_FAILURE General failure.
*/ */
int Add(const SOCHAR *a_pszFileSpec); int Add(const SOCHAR * a_pszFileSpec);
/*! @brief Add an array of filespec to the glob. /*! @brief Add an array of filespec to the glob.
@ -492,25 +480,25 @@ public:
@return SG_ERR_MEMORY Out of memory failure. @return SG_ERR_MEMORY Out of memory failure.
@return SG_ERR_FAILURE General failure. @return SG_ERR_FAILURE General failure.
*/ */
int Add(int a_nCount, const SOCHAR * const * a_rgpszFileSpec); int Add(int a_nCount, const SOCHAR * const *a_rgpszFileSpec);
/*! @brief Return the number of files in the argv array. /*! @brief Return the number of files in the argv array.
*/ */
inline int FileCount() const { return m_nArgsLen; } inline int FileCount() const {
return m_nArgsLen;
/*! @brief Return the full argv array. */ }
inline SOCHAR ** Files() { /*! @brief Return the full argv array. */ inline SOCHAR **Files() {
SetArgvArrayType(POINTERS); SetArgvArrayType(POINTERS);
return m_rgpArgs; return m_rgpArgs;
} }
/*! @brief Return the a single file. */ /*! @brief Return the a single file. */
inline SOCHAR * File(int n) { inline SOCHAR *File(int n) {
SG_ASSERT(n >= 0 && n < m_nArgsLen); SG_ASSERT(n >= 0 && n < m_nArgsLen);
return Files()[n]; return Files()[n];
} }
private: private:
/*! @brief The argv array has it's members stored as either an offset into /*! @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 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 are used because if the string buffer is dynamically resized, all pointers
@ -522,7 +510,7 @@ private:
void SetArgvArrayType(ARG_ARRAY_TYPE a_nNewType); void SetArgvArrayType(ARG_ARRAY_TYPE a_nNewType);
/*! @brief Add a filename to the array if it passes all requirements. */ /*! @brief Add a filename to the array if it passes all requirements. */
int AppendName(const SOCHAR *a_pszFileName, bool a_bIsDir); int AppendName(const SOCHAR * a_pszFileName, bool a_bIsDir);
/*! @brief Grow the argv array to the required size. */ /*! @brief Grow the argv array to the required size. */
bool GrowArgvArray(int a_nNewLen); bool GrowArgvArray(int a_nNewLen);
@ -533,14 +521,14 @@ private:
/*! @brief Compare two (possible NULL) strings */ /*! @brief Compare two (possible NULL) strings */
static int fileSortCompare(const void *a1, const void *a2); static int fileSortCompare(const void *a1, const void *a2);
private: private:
unsigned int m_uiFlags; unsigned int m_uiFlags;
ARG_ARRAY_TYPE m_nArgArrayType; //!< is the argv array storing indexes or pointers ARG_ARRAY_TYPE m_nArgArrayType; //!< is the argv array storing indexes or pointers
SOCHAR ** m_rgpArgs; //!< argv array SOCHAR **m_rgpArgs; //!< argv array
int m_nReservedSlots; //!< number of client reserved slots in the argv array int m_nReservedSlots; //!< number of client reserved slots in the argv array
int m_nArgsSize; //!< allocated size of array int m_nArgsSize; //!< allocated size of array
int m_nArgsLen; //!< used length int m_nArgsLen; //!< used length
SOCHAR * m_pBuffer; //!< argv string buffer SOCHAR *m_pBuffer; //!< argv string buffer
size_t m_uiBufferSize; //!< allocated size of buffer size_t m_uiBufferSize; //!< allocated size of buffer
size_t m_uiBufferLen; //!< used length of buffer size_t m_uiBufferLen; //!< used length of buffer
SOCHAR m_szPathPrefix[MAX_PATH]; //!< path prefix of any wildcard filenames SOCHAR m_szPathPrefix[MAX_PATH]; //!< path prefix of any wildcard filenames
@ -550,11 +538,7 @@ private:
// IMPLEMENTATION // IMPLEMENTATION
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
template<class SOCHAR> template < class SOCHAR > CSimpleGlobTempl < SOCHAR >::CSimpleGlobTempl(unsigned int a_uiFlags, int a_nReservedSlots)
CSimpleGlobTempl<SOCHAR>::CSimpleGlobTempl(
unsigned int a_uiFlags,
int a_nReservedSlots
)
{ {
m_rgpArgs = NULL; m_rgpArgs = NULL;
m_nArgsSize = 0; m_nArgsSize = 0;
@ -564,19 +548,15 @@ CSimpleGlobTempl<SOCHAR>::CSimpleGlobTempl(
Init(a_uiFlags, a_nReservedSlots); Init(a_uiFlags, a_nReservedSlots);
} }
template<class SOCHAR> template < class SOCHAR > CSimpleGlobTempl < SOCHAR >::~CSimpleGlobTempl()
CSimpleGlobTempl<SOCHAR>::~CSimpleGlobTempl()
{ {
if (m_rgpArgs) free(m_rgpArgs); if (m_rgpArgs)
if (m_pBuffer) free(m_pBuffer); free(m_rgpArgs);
if (m_pBuffer)
free(m_pBuffer);
} }
template<class SOCHAR> template < class SOCHAR > int CSimpleGlobTempl < SOCHAR >::Init(unsigned int a_uiFlags, int a_nReservedSlots)
int
CSimpleGlobTempl<SOCHAR>::Init(
unsigned int a_uiFlags,
int a_nReservedSlots
)
{ {
m_nArgArrayType = POINTERS; m_nArgArrayType = POINTERS;
m_uiFlags = a_uiFlags; m_uiFlags = a_uiFlags;
@ -596,11 +576,7 @@ CSimpleGlobTempl<SOCHAR>::Init(
return SG_SUCCESS; return SG_SUCCESS;
} }
template<class SOCHAR> template < class SOCHAR > int CSimpleGlobTempl < SOCHAR >::Add(const SOCHAR * a_pszFileSpec)
int
CSimpleGlobTempl<SOCHAR>::Add(
const SOCHAR *a_pszFileSpec
)
{ {
#ifdef _WIN32 #ifdef _WIN32
// Windows FindFirst/FindNext recognizes forward slash as the same as backward slash // Windows FindFirst/FindNext recognizes forward slash as the same as backward slash
@ -608,7 +584,7 @@ CSimpleGlobTempl<SOCHAR>::Add(
// and when we have no wildcards. // and when we have no wildcards.
SOCHAR szFileSpec[MAX_PATH]; SOCHAR szFileSpec[MAX_PATH];
SimpleGlobUtil::strcpy_s(szFileSpec, MAX_PATH, a_pszFileSpec); SimpleGlobUtil::strcpy_s(szFileSpec, MAX_PATH, a_pszFileSpec);
const SOCHAR * pszPath = SimpleGlobUtil::strchr(szFileSpec, '/'); const SOCHAR *pszPath = SimpleGlobUtil::strchr(szFileSpec, '/');
while (pszPath) { while (pszPath) {
szFileSpec[pszPath - szFileSpec] = SG_PATH_CHAR; szFileSpec[pszPath - szFileSpec] = SG_PATH_CHAR;
pszPath = SimpleGlobUtil::strchr(pszPath + 1, '/'); pszPath = SimpleGlobUtil::strchr(pszPath + 1, '/');
@ -618,9 +594,7 @@ CSimpleGlobTempl<SOCHAR>::Add(
// if this doesn't contain wildcards then we can just add it directly // if this doesn't contain wildcards then we can just add it directly
m_szPathPrefix[0] = 0; m_szPathPrefix[0] = 0;
if (!SimpleGlobUtil::strchr(a_pszFileSpec, '*') && if (!SimpleGlobUtil::strchr(a_pszFileSpec, '*') && !SimpleGlobUtil::strchr(a_pszFileSpec, '?')) {
!SimpleGlobUtil::strchr(a_pszFileSpec, '?'))
{
SG_FileType nType = GetFileTypeS(a_pszFileSpec); SG_FileType nType = GetFileTypeS(a_pszFileSpec);
if (nType == SG_FILETYPE_INVALID) { if (nType == SG_FILETYPE_INVALID) {
if (m_uiFlags & SG_GLOB_NOCHECK) { if (m_uiFlags & SG_GLOB_NOCHECK) {
@ -630,11 +604,10 @@ CSimpleGlobTempl<SOCHAR>::Add(
} }
return AppendName(a_pszFileSpec, nType == SG_FILETYPE_DIR); return AppendName(a_pszFileSpec, nType == SG_FILETYPE_DIR);
} }
#ifdef _WIN32 #ifdef _WIN32
// Windows doesn't return the directory with the filename, so we need to extract the // 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. // 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); const SOCHAR *pszFilename = SimpleGlobUtil::strrchr(a_pszFileSpec, SG_PATH_CHAR);
if (pszFilename) { if (pszFilename) {
SimpleGlobUtil::strcpy_s(m_szPathPrefix, MAX_PATH, a_pszFileSpec); SimpleGlobUtil::strcpy_s(m_szPathPrefix, MAX_PATH, a_pszFileSpec);
m_szPathPrefix[pszFilename - a_pszFileSpec + 1] = 0; m_szPathPrefix[pszFilename - a_pszFileSpec + 1] = 0;
@ -646,20 +619,20 @@ CSimpleGlobTempl<SOCHAR>::Add(
if (rc != SG_SUCCESS) { if (rc != SG_SUCCESS) {
if (rc == SG_ERR_NOMATCH && (m_uiFlags & SG_GLOB_NOCHECK)) { if (rc == SG_ERR_NOMATCH && (m_uiFlags & SG_GLOB_NOCHECK)) {
int ok = AppendName(a_pszFileSpec, false); int ok = AppendName(a_pszFileSpec, false);
if (ok != SG_SUCCESS) rc = ok; if (ok != SG_SUCCESS)
rc = ok;
} }
return rc; return rc;
} }
// add it and find all subsequent matches // add it and find all subsequent matches
int nError, nStartLen = m_nArgsLen; int nError, nStartLen = m_nArgsLen;
bool bSuccess; bool bSuccess;
do { do {
nError = AppendName(GetFileNameS((SOCHAR)0), IsDirS((SOCHAR)0)); nError = AppendName(GetFileNameS((SOCHAR) 0), IsDirS((SOCHAR) 0));
bSuccess = FindNextFileS((SOCHAR)0); bSuccess = FindNextFileS((SOCHAR) 0);
} }
while (nError == SG_SUCCESS && bSuccess); while (nError == SG_SUCCESS && bSuccess);
SimpleGlobBase<SOCHAR>::FindDone(); SimpleGlobBase < SOCHAR >::FindDone();
// sort these files if required // sort these files if required
if (m_nArgsLen > nStartLen && !(m_uiFlags & SG_GLOB_NOSORT)) { if (m_nArgsLen > nStartLen && !(m_uiFlags & SG_GLOB_NOSORT)) {
@ -667,21 +640,13 @@ CSimpleGlobTempl<SOCHAR>::Add(
nStartLen = m_nReservedSlots; nStartLen = m_nReservedSlots;
} }
SetArgvArrayType(POINTERS); SetArgvArrayType(POINTERS);
qsort( qsort(m_rgpArgs + nStartLen, m_nArgsLen - nStartLen, sizeof(m_rgpArgs[0]), fileSortCompare);
m_rgpArgs + nStartLen,
m_nArgsLen - nStartLen,
sizeof(m_rgpArgs[0]), fileSortCompare);
} }
return nError; return nError;
} }
template<class SOCHAR> template < class SOCHAR > int CSimpleGlobTempl < SOCHAR >::Add(int a_nCount, const SOCHAR * const *a_rgpszFileSpec)
int
CSimpleGlobTempl<SOCHAR>::Add(
int a_nCount,
const SOCHAR * const * a_rgpszFileSpec
)
{ {
int nResult; int nResult;
for (int n = 0; n < a_nCount; ++n) { for (int n = 0; n < a_nCount; ++n) {
@ -693,12 +658,7 @@ CSimpleGlobTempl<SOCHAR>::Add(
return SG_SUCCESS; return SG_SUCCESS;
} }
template<class SOCHAR> template < class SOCHAR > int CSimpleGlobTempl < SOCHAR >::AppendName(const SOCHAR * a_pszFileName, bool a_bIsDir)
int
CSimpleGlobTempl<SOCHAR>::AppendName(
const SOCHAR * a_pszFileName,
bool a_bIsDir
)
{ {
// we need the argv array as offsets in case we resize it // we need the argv array as offsets in case we resize it
SetArgvArrayType(OFFSETS); SetArgvArrayType(OFFSETS);
@ -720,12 +680,10 @@ CSimpleGlobTempl<SOCHAR>::AppendName(
} }
} }
} }
// ensure that we have enough room in the argv array // ensure that we have enough room in the argv array
if (!GrowArgvArray(m_nArgsLen + 1)) { if (!GrowArgvArray(m_nArgsLen + 1)) {
return SG_ERR_MEMORY; return SG_ERR_MEMORY;
} }
// ensure that we have enough room in the string buffer // ensure that we have enough room in the string buffer
size_t uiPrefixLen = SimpleGlobUtil::strlen(m_szPathPrefix); size_t uiPrefixLen = SimpleGlobUtil::strlen(m_szPathPrefix);
size_t uiLen = uiPrefixLen + SimpleGlobUtil::strlen(a_pszFileName) + 1; // + null character size_t uiLen = uiPrefixLen + SimpleGlobUtil::strlen(a_pszFileName) + 1; // + null character
@ -735,55 +693,41 @@ CSimpleGlobTempl<SOCHAR>::AppendName(
if (!GrowStringBuffer(m_uiBufferLen + uiLen)) { if (!GrowStringBuffer(m_uiBufferLen + uiLen)) {
return SG_ERR_MEMORY; return SG_ERR_MEMORY;
} }
// add this entry // add this entry
m_rgpArgs[m_nArgsLen++] = (SOCHAR*)m_uiBufferLen; // offset from beginning of buffer m_rgpArgs[m_nArgsLen++] = (SOCHAR *) m_uiBufferLen; // offset from beginning of buffer
SimpleGlobUtil::strcpy_s(m_pBuffer + m_uiBufferLen, SimpleGlobUtil::strcpy_s(m_pBuffer + m_uiBufferLen, m_uiBufferSize - m_uiBufferLen, m_szPathPrefix);
m_uiBufferSize - m_uiBufferLen, m_szPathPrefix); SimpleGlobUtil::strcpy_s(m_pBuffer + m_uiBufferLen + uiPrefixLen, m_uiBufferSize - m_uiBufferLen - uiPrefixLen, a_pszFileName);
SimpleGlobUtil::strcpy_s(m_pBuffer + m_uiBufferLen + uiPrefixLen,
m_uiBufferSize - m_uiBufferLen - uiPrefixLen, a_pszFileName);
m_uiBufferLen += uiLen; m_uiBufferLen += uiLen;
// add the directory slash if desired // add the directory slash if desired
if (a_bIsDir && (m_uiFlags & SG_GLOB_MARK) == SG_GLOB_MARK) { if (a_bIsDir && (m_uiFlags & SG_GLOB_MARK) == SG_GLOB_MARK) {
const static SOCHAR szDirSlash[] = { SG_PATH_CHAR, 0 }; const static SOCHAR szDirSlash[] = { SG_PATH_CHAR, 0 };
SimpleGlobUtil::strcpy_s(m_pBuffer + m_uiBufferLen - 2, SimpleGlobUtil::strcpy_s(m_pBuffer + m_uiBufferLen - 2, m_uiBufferSize - (m_uiBufferLen - 2), szDirSlash);
m_uiBufferSize - (m_uiBufferLen - 2), szDirSlash);
} }
return SG_SUCCESS; return SG_SUCCESS;
} }
template<class SOCHAR> template < class SOCHAR > void CSimpleGlobTempl < SOCHAR >::SetArgvArrayType(ARG_ARRAY_TYPE a_nNewType)
void
CSimpleGlobTempl<SOCHAR>::SetArgvArrayType(
ARG_ARRAY_TYPE a_nNewType
)
{ {
if (m_nArgArrayType == a_nNewType) return; if (m_nArgArrayType == a_nNewType)
return;
if (a_nNewType == POINTERS) { if (a_nNewType == POINTERS) {
SG_ASSERT(m_nArgArrayType == OFFSETS); SG_ASSERT(m_nArgArrayType == OFFSETS);
for (int n = 0; n < m_nArgsLen; ++n) { for (int n = 0; n < m_nArgsLen; ++n) {
m_rgpArgs[n] = (m_rgpArgs[n] == (SOCHAR*)-1) ? m_rgpArgs[n] = (m_rgpArgs[n] == (SOCHAR *) - 1) ? NULL : m_pBuffer + (size_t) m_rgpArgs[n];
NULL : m_pBuffer + (size_t) m_rgpArgs[n];
} }
} } else {
else {
SG_ASSERT(a_nNewType == OFFSETS); SG_ASSERT(a_nNewType == OFFSETS);
SG_ASSERT(m_nArgArrayType == POINTERS); SG_ASSERT(m_nArgArrayType == POINTERS);
for (int n = 0; n < m_nArgsLen; ++n) { for (int n = 0; n < m_nArgsLen; ++n) {
m_rgpArgs[n] = (m_rgpArgs[n] == NULL) ? m_rgpArgs[n] = (m_rgpArgs[n] == NULL) ? (SOCHAR *) - 1 : (SOCHAR *) (m_rgpArgs[n] - m_pBuffer);
(SOCHAR*) -1 : (SOCHAR*) (m_rgpArgs[n] - m_pBuffer);
} }
} }
m_nArgArrayType = a_nNewType; m_nArgArrayType = a_nNewType;
} }
template<class SOCHAR> template < class SOCHAR > bool CSimpleGlobTempl < SOCHAR >::GrowArgvArray(int a_nNewLen)
bool
CSimpleGlobTempl<SOCHAR>::GrowArgvArray(
int a_nNewLen
)
{ {
if (a_nNewLen >= m_nArgsSize) { if (a_nNewLen >= m_nArgsSize) {
static const int SG_ARGV_INITIAL_SIZE = 32; static const int SG_ARGV_INITIAL_SIZE = 32;
@ -791,19 +735,16 @@ CSimpleGlobTempl<SOCHAR>::GrowArgvArray(
while (a_nNewLen >= nNewSize) { while (a_nNewLen >= nNewSize) {
nNewSize *= 2; nNewSize *= 2;
} }
void * pNewBuffer = realloc(m_rgpArgs, nNewSize * sizeof(SOCHAR*)); void *pNewBuffer = realloc(m_rgpArgs, nNewSize * sizeof(SOCHAR *));
if (!pNewBuffer) return false; if (!pNewBuffer)
return false;
m_nArgsSize = nNewSize; m_nArgsSize = nNewSize;
m_rgpArgs = (SOCHAR**) pNewBuffer; m_rgpArgs = (SOCHAR **) pNewBuffer;
} }
return true; return true;
} }
template<class SOCHAR> template < class SOCHAR > bool CSimpleGlobTempl < SOCHAR >::GrowStringBuffer(size_t a_uiMinSize)
bool
CSimpleGlobTempl<SOCHAR>::GrowStringBuffer(
size_t a_uiMinSize
)
{ {
if (a_uiMinSize >= m_uiBufferSize) { if (a_uiMinSize >= m_uiBufferSize) {
static const int SG_BUFFER_INITIAL_SIZE = 1024; static const int SG_BUFFER_INITIAL_SIZE = 1024;
@ -811,23 +752,19 @@ CSimpleGlobTempl<SOCHAR>::GrowStringBuffer(
while (a_uiMinSize >= uiNewSize) { while (a_uiMinSize >= uiNewSize) {
uiNewSize *= 2; uiNewSize *= 2;
} }
void * pNewBuffer = realloc(m_pBuffer, uiNewSize * sizeof(SOCHAR)); void *pNewBuffer = realloc(m_pBuffer, uiNewSize * sizeof(SOCHAR));
if (!pNewBuffer) return false; if (!pNewBuffer)
return false;
m_uiBufferSize = uiNewSize; m_uiBufferSize = uiNewSize;
m_pBuffer = (SOCHAR*) pNewBuffer; m_pBuffer = (SOCHAR *) pNewBuffer;
} }
return true; return true;
} }
template<class SOCHAR> template < class SOCHAR > int CSimpleGlobTempl < SOCHAR >::fileSortCompare(const void *a1, const void *a2)
int
CSimpleGlobTempl<SOCHAR>::fileSortCompare(
const void *a1,
const void *a2
)
{ {
const SOCHAR * s1 = *(const SOCHAR **)a1; const SOCHAR *s1 = *(const SOCHAR **) a1;
const SOCHAR * s2 = *(const SOCHAR **)a2; const SOCHAR *s2 = *(const SOCHAR **) a2;
if (s1 && s2) { if (s1 && s2) {
return SimpleGlobUtil::strcasecmp(s1, s2); return SimpleGlobUtil::strcasecmp(s1, s2);
} }
@ -839,8 +776,8 @@ CSimpleGlobTempl<SOCHAR>::fileSortCompare(
// TYPE DEFINITIONS // TYPE DEFINITIONS
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
typedef CSimpleGlobTempl<char> CSimpleGlobA; /*!< @brief ASCII/MBCS version of CSimpleGlob */ typedef CSimpleGlobTempl < char >CSimpleGlobA; /*!< @brief ASCII/MBCS version of CSimpleGlob */
typedef CSimpleGlobTempl<wchar_t> CSimpleGlobW; /*!< @brief wchar_t version of CSimpleGlob */ typedef CSimpleGlobTempl < wchar_t >CSimpleGlobW; /*!< @brief wchar_t version of CSimpleGlob */
#if defined(_UNICODE) #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 #else

View File

@ -50,137 +50,108 @@ extern "C" {
#ifndef __inline__ #ifndef __inline__
#define __inline__ __inline #define __inline__ __inline
#endif #endif
typedef unsigned __int8 uint8_t; typedef unsigned __int8 uint8_t;
typedef __int16 int16_t; typedef __int16 int16_t;
typedef __int32 int32_t; typedef __int32 int32_t;
typedef unsigned __int16 uint16_t; typedef unsigned __int16 uint16_t;
#endif #endif
#if defined(__i386__) #if defined(__i386__)
/*! \brief Find the bit position of the highest set bit in a word /*! \brief Find the bit position of the highest set bit in a word
\param bits The word to be searched \param bits The word to be searched
\return The bit number of the highest set bit, or -1 if the word is zero. */ \return The bit number of the highest set bit, or -1 if the word is zero. */
static __inline__ int top_bit(unsigned int bits) static __inline__ int top_bit(unsigned int bits) {
{
int res; int res;
__asm__ __volatile__(" movl $-1,%%edx;\n" __asm__ __volatile__(" movl $-1,%%edx;\n" " bsrl %%eax,%%edx;\n":"=d"(res)
" bsrl %%eax,%%edx;\n" :"a" (bits));
: "=d" (res)
: "a" (bits));
return res; return res;
} }
/*- End of function --------------------------------------------------------*/ /*- End of function --------------------------------------------------------*//*! \brief Find the bit position of the lowest set bit in a word
/*! \brief Find the bit position of the lowest set bit in a word
\param bits The word to be searched \param bits The word to be searched
\return The bit number of the lowest set bit, or -1 if the word is zero. */ \return The bit number of the lowest set bit, or -1 if the word is zero. */ static __inline__ int bottom_bit(unsigned int bits) {
static __inline__ int bottom_bit(unsigned int bits)
{
int res; int res;
__asm__ __volatile__(" movl $-1,%%edx;\n" __asm__ __volatile__(" movl $-1,%%edx;\n" " bsfl %%eax,%%edx;\n":"=d"(res)
" bsfl %%eax,%%edx;\n" :"a" (bits));
: "=d" (res)
: "a" (bits));
return res; return res;
} }
/*- End of function --------------------------------------------------------*/ /*- End of function --------------------------------------------------------*/
#elif defined(__x86_64__) #elif defined(__x86_64__)
static __inline__ int top_bit(unsigned int bits) static __inline__ int top_bit(unsigned int bits) {
{
int res; int res;
__asm__ __volatile__(" movq $-1,%%rdx;\n" __asm__ __volatile__(" movq $-1,%%rdx;\n" " bsrq %%rax,%%rdx;\n":"=d"(res)
" bsrq %%rax,%%rdx;\n" :"a" (bits));
: "=d" (res)
: "a" (bits));
return res; return res;
} }
/*- End of function --------------------------------------------------------*/ /*- End of function --------------------------------------------------------*/ static __inline__ int bottom_bit(unsigned int bits) {
static __inline__ int bottom_bit(unsigned int bits)
{
int res; int res;
__asm__ __volatile__(" movq $-1,%%rdx;\n" __asm__ __volatile__(" movq $-1,%%rdx;\n" " bsfq %%rax,%%rdx;\n":"=d"(res)
" bsfq %%rax,%%rdx;\n" :"a" (bits));
: "=d" (res)
: "a" (bits));
return res; return res;
} }
/*- End of function --------------------------------------------------------*/ /*- End of function --------------------------------------------------------*/
#else #else
static __inline__ int top_bit(unsigned int bits) static __inline__ int top_bit(unsigned int bits) {
{
int i; int i;
if (bits == 0) if (bits == 0)
return -1; return -1;
i = 0; i = 0;
if (bits & 0xFFFF0000) if (bits & 0xFFFF0000) {
{
bits &= 0xFFFF0000; bits &= 0xFFFF0000;
i += 16; i += 16;
} }
if (bits & 0xFF00FF00) if (bits & 0xFF00FF00) {
{
bits &= 0xFF00FF00; bits &= 0xFF00FF00;
i += 8; i += 8;
} }
if (bits & 0xF0F0F0F0) if (bits & 0xF0F0F0F0) {
{
bits &= 0xF0F0F0F0; bits &= 0xF0F0F0F0;
i += 4; i += 4;
} }
if (bits & 0xCCCCCCCC) if (bits & 0xCCCCCCCC) {
{
bits &= 0xCCCCCCCC; bits &= 0xCCCCCCCC;
i += 2; i += 2;
} }
if (bits & 0xAAAAAAAA) if (bits & 0xAAAAAAAA) {
{
bits &= 0xAAAAAAAA; bits &= 0xAAAAAAAA;
i += 1; i += 1;
} }
return i; return i;
} }
/*- End of function --------------------------------------------------------*/ /*- End of function --------------------------------------------------------*/
static __inline__ int bottom_bit(unsigned int bits) static __inline__ int bottom_bit(unsigned int bits) {
{
int i; int i;
if (bits == 0) if (bits == 0)
return -1; return -1;
i = 32; i = 32;
if (bits & 0x0000FFFF) if (bits & 0x0000FFFF) {
{
bits &= 0x0000FFFF; bits &= 0x0000FFFF;
i -= 16; i -= 16;
} }
if (bits & 0x00FF00FF) if (bits & 0x00FF00FF) {
{
bits &= 0x00FF00FF; bits &= 0x00FF00FF;
i -= 8; i -= 8;
} }
if (bits & 0x0F0F0F0F) if (bits & 0x0F0F0F0F) {
{
bits &= 0x0F0F0F0F; bits &= 0x0F0F0F0F;
i -= 4; i -= 4;
} }
if (bits & 0x33333333) if (bits & 0x33333333) {
{
bits &= 0x33333333; bits &= 0x33333333;
i -= 2; i -= 2;
} }
if (bits & 0x55555555) if (bits & 0x55555555) {
{
bits &= 0x55555555; bits &= 0x55555555;
i -= 1; i -= 1;
} }
return i; return i;
} }
/*- End of function --------------------------------------------------------*/ /*- End of function --------------------------------------------------------*/
#endif #endif
@ -228,20 +199,16 @@ static __inline__ int bottom_bit(unsigned int bits)
\param linear The sample to encode. \param linear The sample to encode.
\return The u-law value. \return The u-law value.
*/ */
static __inline__ uint8_t linear_to_ulaw(int linear) static __inline__ uint8_t linear_to_ulaw(int linear) {
{
uint8_t u_val; uint8_t u_val;
int mask; int mask;
int seg; int seg;
/* Get the sign and the magnitude of the value. */ /* Get the sign and the magnitude of the value. */
if (linear < 0) if (linear < 0) {
{
linear = ULAW_BIAS - linear; linear = ULAW_BIAS - linear;
mask = 0x7F; mask = 0x7F;
} } else {
else
{
linear = ULAW_BIAS + linear; linear = ULAW_BIAS + linear;
mask = 0xFF; mask = 0xFF;
} }
@ -262,15 +229,14 @@ static __inline__ uint8_t linear_to_ulaw(int linear)
u_val = 0x02; u_val = 0x02;
#endif #endif
return u_val; return u_val;
} }
/*- End of function --------------------------------------------------------*/ /*- End of function --------------------------------------------------------*/
/*! \brief Decode an u-law sample to a linear value. /*! \brief Decode an u-law sample to a linear value.
\param ulaw The u-law sample to decode. \param ulaw The u-law sample to decode.
\return The linear value. \return The linear value.
*/ */
static __inline__ int16_t ulaw_to_linear(uint8_t ulaw) static __inline__ int16_t ulaw_to_linear(uint8_t ulaw) {
{
int t; int t;
/* Complement to obtain normal u-law value. */ /* Complement to obtain normal u-law value. */
@ -281,7 +247,7 @@ static __inline__ int16_t ulaw_to_linear(uint8_t ulaw)
*/ */
t = (((ulaw & 0x0F) << 3) + ULAW_BIAS) << (((int) ulaw & 0x70) >> 4); t = (((ulaw & 0x0F) << 3) + ULAW_BIAS) << (((int) ulaw & 0x70) >> 4);
return (int16_t) ((ulaw & 0x80) ? (ULAW_BIAS - t) : (t - ULAW_BIAS)); return (int16_t) ((ulaw & 0x80) ? (ULAW_BIAS - t) : (t - ULAW_BIAS));
} }
/*- End of function --------------------------------------------------------*/ /*- End of function --------------------------------------------------------*/
/* /*
@ -308,18 +274,14 @@ static __inline__ int16_t ulaw_to_linear(uint8_t ulaw)
\param linear The sample to encode. \param linear The sample to encode.
\return The A-law value. \return The A-law value.
*/ */
static __inline__ uint8_t linear_to_alaw(int linear) static __inline__ uint8_t linear_to_alaw(int linear) {
{
int mask; int mask;
int seg; int seg;
if (linear >= 0) if (linear >= 0) {
{
/* Sign (bit 7) bit = 1 */ /* Sign (bit 7) bit = 1 */
mask = ALAW_AMI_MASK | 0x80; mask = ALAW_AMI_MASK | 0x80;
} } else {
else
{
/* Sign (bit 7) bit = 0 */ /* Sign (bit 7) bit = 0 */
mask = ALAW_AMI_MASK; mask = ALAW_AMI_MASK;
linear = -linear - 8; linear = -linear - 8;
@ -327,10 +289,8 @@ static __inline__ uint8_t linear_to_alaw(int linear)
/* Convert the scaled magnitude to segment number. */ /* Convert the scaled magnitude to segment number. */
seg = top_bit(linear | 0xFF) - 7; seg = top_bit(linear | 0xFF) - 7;
if (seg >= 8) if (seg >= 8) {
{ if (linear >= 0) {
if (linear >= 0)
{
/* Out of range. Return maximum value. */ /* Out of range. Return maximum value. */
return (uint8_t) (0x7F ^ mask); return (uint8_t) (0x7F ^ mask);
} }
@ -339,15 +299,14 @@ static __inline__ uint8_t linear_to_alaw(int linear)
} }
/* Combine the sign, segment, and quantization bits. */ /* Combine the sign, segment, and quantization bits. */
return (uint8_t) (((seg << 4) | ((linear >> ((seg) ? (seg + 3) : 4)) & 0x0F)) ^ mask); return (uint8_t) (((seg << 4) | ((linear >> ((seg) ? (seg + 3) : 4)) & 0x0F)) ^ mask);
} }
/*- End of function --------------------------------------------------------*/ /*- End of function --------------------------------------------------------*/
/*! \brief Decode an A-law sample to a linear value. /*! \brief Decode an A-law sample to a linear value.
\param alaw The A-law sample to decode. \param alaw The A-law sample to decode.
\return The linear value. \return The linear value.
*/ */
static __inline__ int16_t alaw_to_linear(uint8_t alaw) static __inline__ int16_t alaw_to_linear(uint8_t alaw) {
{
int i; int i;
int seg; int seg;
@ -359,20 +318,20 @@ static __inline__ int16_t alaw_to_linear(uint8_t alaw)
else else
i += 8; i += 8;
return (int16_t) ((alaw & 0x80) ? i : -i); return (int16_t) ((alaw & 0x80) ? i : -i);
} }
/*- End of function --------------------------------------------------------*/ /*- End of function --------------------------------------------------------*/
/*! \brief Transcode from A-law to u-law, using the procedure defined in G.711. /*! \brief Transcode from A-law to u-law, using the procedure defined in G.711.
\param alaw The A-law sample to transcode. \param alaw The A-law sample to transcode.
\return The best matching u-law value. \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. /*! \brief Transcode from u-law to A-law, using the procedure defined in G.711.
\param ulaw The u-law sample to transcode. \param ulaw The u-law sample to transcode.
\return The best matching A-law value. \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 #ifdef __cplusplus
} }

View File

@ -56,8 +56,6 @@ SWITCH_BEGIN_EXTERN_C
*/ */
/** The fundamental pool type */ /** The fundamental pool type */
/* see switch types.h typedef struct apr_pool_t switch_memory_pool_t;*/ /* 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 * Clear all memory in the pool and run all the cleanups. This also destroys all
* subpools. * subpools.
@ -93,13 +91,13 @@ SWITCH_DECLARE(void) switch_pool_clear(switch_memory_pool_t *p);
* @bug We aught to provide an alternative to RTLD_GLOBAL, which * @bug We aught to provide an alternative to RTLD_GLOBAL, which
* is the only supported method of loading DSOs today. * 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. * Close a DSO library.
* @param handle handle to close. * @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. * Load a symbol from a DSO handle.
@ -107,7 +105,7 @@ SWITCH_DECLARE(switch_status_t) switch_dso_unload(switch_dso_handle_t * handle);
* @param handle handle to load the symbol from. * @param handle handle to load the symbol from.
* @param symname Name of the symbol to load. * @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. * Report more information when a DSO function fails.
@ -115,7 +113,7 @@ SWITCH_DECLARE(switch_status_t) switch_dso_sym(switch_dso_handle_sym_t * ressym,
* @param buf Location to store the dso error * @param buf Location to store the dso error
* @param bufsize The size of the provided buffer * @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(const char *) switch_dso_error(switch_dso_handle_t * dso, char *b
* @{ * @{
*/ */
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(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 @@ SWITCH_DECLARE(char *) switch_copy_string(_Out_z_cap_(dst_size) char *dst, _In_z
* progress at the same time. * 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. * Continue iterating over the entries in a hash table.
@ -172,7 +172,7 @@ SWITCH_DECLARE(switch_hash_index_t *) switch_hash_first(switch_memory_pool_t *p,
* @return a pointer to the updated iteration state. NULL if there are no more * @return a pointer to the updated iteration state. NULL if there are no more
* entries. * 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. * Get the current entry's details from the iteration state.
@ -183,11 +183,11 @@ SWITCH_DECLARE(switch_hash_index_t *) switch_hash_next(switch_hash_index_t * ht)
* @remark The return pointers should point to a variable that will be set to the * @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. * 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 @@ SWITCH_DECLARE(switch_time_t) switch_time_now(void);
* @param result the resulting imploded time * @param result the resulting imploded time
* @param input the input exploded 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 * formats the exploded time according to the format specified
@ -268,7 +268,7 @@ SWITCH_DECLARE(switch_status_t) switch_time_exp_gmt_get(switch_time_t * result,
* @param format The format for the time string * @param format The format for the time string
* @param tm The time to convert * @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 * switch_rfc822_date formats dates in the RFC822
@ -285,7 +285,7 @@ SWITCH_DECLARE(switch_status_t) switch_rfc822_date(char *date_str, switch_time_t
* @param result the exploded time * @param result the exploded time
* @param input the time to explode * @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 * Convert time value from human readable format to a numeric apr_time_t
@ -293,14 +293,14 @@ SWITCH_DECLARE(switch_status_t) switch_time_exp_gmt(switch_time_exp_t * result,
* @param result the resulting imploded time * @param result the resulting imploded time
* @param input the input exploded 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 * convert a time to its human readable components in local timezone
* @param result the exploded time * @param result the exploded time
* @param input the time to explode * @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. * Sleep for the specified number of micro-seconds.
@ -341,27 +341,27 @@ SWITCH_DECLARE(void) switch_sleep(switch_interval_time_t t);
* it will behave as either a nested or an unnested lock. * 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. * Destroy the mutex and free the memory associated with the lock.
* @param lock the mutex to destroy. * @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, * 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. * the current thread will be put to sleep until the lock becomes available.
* @param lock the mutex on which to acquire the lock. * @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. * Release the lock for the given mutex.
* @param lock the mutex from which to release the lock. * @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 * Attempt to acquire the lock for the given mutex. If the mutex has already
@ -370,7 +370,7 @@ SWITCH_DECLARE(switch_status_t) switch_mutex_unlock(switch_mutex_t * lock);
* if the return value was APR_EBUSY, for portability reasons. * if the return value was APR_EBUSY, for portability reasons.
* @param lock the mutex on which to attempt the lock acquiring. * @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 @@ SWITCH_DECLARE(switch_status_t) switch_mutex_trylock(switch_mutex_t * lock);
/** Opaque structure used for the rwlock */ /** Opaque structure used for the rwlock */
typedef struct apr_thread_rwlock_t switch_thread_rwlock_t; typedef struct apr_thread_rwlock_t switch_thread_rwlock_t;
SWITCH_DECLARE(switch_status_t) switch_thread_rwlock_create(switch_thread_rwlock_t ** rwlock, switch_memory_pool_t *pool); SWITCH_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_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_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_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_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_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_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_unlock(switch_thread_rwlock_t *rwlock);
/** @} */ /** @} */
@ -416,7 +416,7 @@ SWITCH_DECLARE(switch_status_t) switch_thread_rwlock_unlock(switch_thread_rwlock
* will be stored. * will be stored.
* @param pool the pool from which to allocate the mutex. * @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 * Put the active calling thread to sleep until signaled to wake up. Each
@ -430,7 +430,7 @@ SWITCH_DECLARE(switch_status_t) switch_thread_cond_create(switch_thread_cond_t *
* is released while the thread is asleep, and is again acquired before * is released while the thread is asleep, and is again acquired before
* returning from this function. * 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 * Put the active calling thread to sleep until signaled to wake up or
@ -448,7 +448,7 @@ SWITCH_DECLARE(switch_status_t) switch_thread_cond_wait(switch_thread_cond_t * c
* will wake up before this time, otherwise the error APR_TIMEUP * will wake up before this time, otherwise the error APR_TIMEUP
* is returned. * 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 * Signals a single thread, if one exists, that is blocking on the given
@ -457,7 +457,7 @@ SWITCH_DECLARE(switch_status_t) switch_thread_cond_timedwait(switch_thread_cond_
* is desired, that mutex must be locked while calling this function. * is desired, that mutex must be locked while calling this function.
* @param cond the condition variable on which to produce the signal. * @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. * Signals all threads blocking on the given condition variable.
@ -465,13 +465,13 @@ SWITCH_DECLARE(switch_status_t) switch_thread_cond_signal(switch_thread_cond_t *
* the associated mutex. This will happen in a serialized manner. * the associated mutex. This will happen in a serialized manner.
* @param cond the condition variable on which to produce the broadcast. * @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. * Destroy the condition variable and free the associated memory.
* @param cond the condition variable to destroy. * @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 @@ SWITCH_DECLARE(switch_status_t) switch_thread_cond_destroy(switch_thread_cond_t
* the formatted UUID and a null terminator * the formatted UUID and a null terminator
* @param uuid The UUID to format * @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 * Generate and return a (new) UUID
* @param uuid The resulting 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 * Parse a standard-format string into a UUID
* @param uuid The resulting UUID * @param uuid The resulting UUID
* @param uuid_str The formatted 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 @@ SWITCH_DECLARE(switch_status_t) switch_uuid_parse(switch_uuid_t * uuid, const ch
* @param queue_capacity maximum size of the queue * @param queue_capacity maximum size of the queue
* @param pool a pool to allocate queue from * @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 * pop/get an object from the queue, blocking if the queue is already empty
@ -541,7 +541,7 @@ SWITCH_DECLARE(switch_status_t) switch_queue_create(switch_queue_t ** queue, uns
* @returns APR_EOF if the queue has been terminated * @returns APR_EOF if the queue has been terminated
* @returns APR_SUCCESS on a successfull pop * @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 * push/add a object to the queue, blocking if the queue is already full
@ -552,7 +552,7 @@ SWITCH_DECLARE(switch_status_t) switch_queue_pop(switch_queue_t * queue, void **
* @returns APR_EOF the queue has been terminated * @returns APR_EOF the queue has been terminated
* @returns APR_SUCCESS on a successfull push * @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. * returns the size of the queue.
@ -562,7 +562,7 @@ SWITCH_DECLARE(switch_status_t) switch_queue_push(switch_queue_t * queue, void *
* @param queue the queue * @param queue the queue
* @returns the size of 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 * pop/get an object to the queue, returning immediatly if the queue is empty
@ -574,7 +574,7 @@ SWITCH_DECLARE(unsigned int) switch_queue_size(switch_queue_t * queue);
* @returns APR_EOF the queue has been terminated * @returns APR_EOF the queue has been terminated
* @returns APR_SUCCESS on a successfull push * @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 * push/add a object to the queue, returning immediatly if the queue is full
@ -586,7 +586,7 @@ SWITCH_DECLARE(switch_status_t) switch_queue_trypop(switch_queue_t * queue, void
* @returns APR_EOF the queue has been terminated * @returns APR_EOF the queue has been terminated
* @returns APR_SUCCESS on a successfull push * @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);
/** @} */ /** @} */
@ -722,19 +722,19 @@ SWITCH_DECLARE(switch_status_t) switch_queue_trypush(switch_queue_t * queue, voi
* @remark If perm is SWITCH_FPROT_OS_DEFAULT and the file is being created, * @remark If perm is SWITCH_FPROT_OS_DEFAULT and the file is being created,
* appropriate default permissions will be used. * 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_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. * Close the specified file.
* @param thefile The file descriptor to close. * @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. * Delete the specified file.
@ -764,7 +764,7 @@ SWITCH_DECLARE(switch_status_t) switch_file_rename(const char *from_path, const
* @remark It is not possible for both bytes to be read and an APR_EOF * @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. * 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. * Write data to the specified file.
@ -781,7 +781,7 @@ SWITCH_DECLARE(switch_status_t) switch_file_read(switch_file_t * thefile, void *
* @remark It is possible for both bytes to be written and an error to * @remark It is possible for both bytes to be written and an error to
* be returned. APR_EINTR is never returned. * 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(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); 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 @@ SWITCH_DECLARE(switch_status_t) switch_directory_exists(const char *dirname, swi
* @param perm Permissions for the new direcoty. * @param perm Permissions for the new direcoty.
* @param pool the pool to use. * @param pool the pool to use.
*/ */
SWITCH_DECLARE(switch_status_t) switch_dir_make(const char *path, switch_fileperms_t perm, SWITCH_DECLARE(switch_status_t) switch_dir_make(const char *path, switch_fileperms_t perm, switch_memory_pool_t *pool);
switch_memory_pool_t *pool);
/** Creates a new directory on the file system, but behaves like /** Creates a new directory on the file system, but behaves like
* 'mkdir -p'. Creates intermediate directories as required. No error * 'mkdir -p'. Creates intermediate directories as required. No error
@ -808,12 +807,11 @@ SWITCH_DECLARE(switch_status_t) switch_dir_make(const char *path, switch_fileper
* @param perm Permissions for the new direcoty. * @param perm Permissions for the new direcoty.
* @param pool the pool to use. * @param pool the pool to use.
*/ */
SWITCH_DECLARE(switch_status_t) switch_dir_make_recursive(const char *path, switch_fileperms_t perm, SWITCH_DECLARE(switch_status_t) switch_dir_make_recursive(const char *path, switch_fileperms_t perm, switch_memory_pool_t *pool);
switch_memory_pool_t *pool);
typedef struct switch_dir switch_dir_t; typedef struct switch_dir switch_dir_t;
struct switch_array_header_t { struct switch_array_header_t {
/** The pool the array is allocated out of */ /** The pool the array is allocated out of */
switch_memory_pool_t *pool; switch_memory_pool_t *pool;
/** The amount of memory allocated for each element of the array */ /** The amount of memory allocated for each element of the array */
@ -824,8 +822,8 @@ struct switch_array_header_t {
int nalloc; int nalloc;
/** The elements in the array */ /** The elements in the array */
char *elts; char *elts;
}; };
typedef struct switch_array_header_t switch_array_header_t; 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_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); SWITCH_DECLARE(switch_status_t) switch_dir_close(switch_dir_t *thedir);
@ -852,7 +850,7 @@ SWITCH_DECLARE(const char *) switch_dir_next_file(switch_dir_t *thedir, char *bu
typedef void *(SWITCH_THREAD_FUNC * switch_thread_start_t) (switch_thread_t *, void *); typedef void *(SWITCH_THREAD_FUNC * switch_thread_start_t) (switch_thread_t *, void *);
//APR_DECLARE(apr_status_t) apr_threadattr_stacksize_set(apr_threadattr_t *attr, switch_size_t stacksize) //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); SWITCH_DECLARE(switch_status_t) switch_threadattr_priority_increase(switch_threadattr_t *attr);
@ -862,14 +860,14 @@ SWITCH_DECLARE(switch_status_t) switch_threadattr_priority_increase(switch_threa
* @param new_attr The newly created threadattr. * @param new_attr The newly created threadattr.
* @param pool The pool to use * @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. * Set if newly created threads should be created in detached state.
* @param attr The threadattr to affect * @param attr The threadattr to affect
* @param on Non-zero if detached threads should be created. * @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 * Create a new thread of execution
@ -879,7 +877,7 @@ SWITCH_DECLARE(switch_status_t) switch_threadattr_detach_set(switch_threadattr_t
* @param data Any data to be passed to the starting function * @param data Any data to be passed to the starting function
* @param cont The pool to use * @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); switch_thread_start_t func, void *data, switch_memory_pool_t *cont);
/** @} */ /** @} */
@ -946,7 +944,7 @@ SWITCH_DECLARE(switch_status_t) switch_thread_create(switch_thread_t ** new_thre
* @param protocol The protocol of the socket (e.g., SWITCH_PROTO_TCP). * @param protocol The protocol of the socket (e.g., SWITCH_PROTO_TCP).
* @param pool The pool to use * @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. * Shutdown either reading, writing, or both sides of a socket.
@ -961,13 +959,13 @@ SWITCH_DECLARE(switch_status_t) switch_socket_create(switch_socket_t ** new_sock
* @remark This does not actually close the socket descriptor, it just * @remark This does not actually close the socket descriptor, it just
* controls which calls are still valid on the socket. * 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. * Close a socket.
* @param sock The socket to close * @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 * Bind the socket to its associated port
@ -976,7 +974,7 @@ SWITCH_DECLARE(switch_status_t) switch_socket_close(switch_socket_t * sock);
* @remark This may be where we will find out if there is any other process * @remark This may be where we will find out if there is any other process
* using the selected port. * 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. * Listen to a bound socket for connections.
@ -985,7 +983,7 @@ SWITCH_DECLARE(switch_status_t) switch_socket_bind(switch_socket_t * sock, switc
* listen queue. If this value is less than zero, the listen * listen queue. If this value is less than zero, the listen
* queue size is set to zero. * 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 * Accept a new connection request
@ -995,7 +993,7 @@ SWITCH_DECLARE(switch_status_t) switch_socket_listen(switch_socket_t * sock, int
* @param sock The socket we are listening on. * @param sock The socket we are listening on.
* @param pool The pool for the new socket. * @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 * Issue a connection request to a socket either on the same machine
@ -1003,12 +1001,12 @@ SWITCH_DECLARE(switch_status_t) switch_socket_accept(switch_socket_t ** new_sock
* @param sock The socket we wish to use for our side of the connection * @param 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. * @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(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(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(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(switch_status_t) switch_sockaddr_ip_get(char **addr, switch_sockaddr_t *sa);
/** /**
@ -1034,7 +1032,7 @@ SWITCH_DECLARE(switch_status_t) switch_sockaddr_ip_get(char **addr, switch_socka
* </PRE> * </PRE>
* @param pool The pool for the apr_sockaddr_t and associated storage. * @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); int32_t family, switch_port_t port, int32_t flags, switch_memory_pool_t *pool);
/** /**
@ -1054,7 +1052,7 @@ SWITCH_DECLARE(switch_status_t) switch_sockaddr_info_get(switch_sockaddr_t ** sa
* APR_EINTR is never returned. * APR_EINTR is never returned.
* </PRE> * </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 * @param sock The socket to send from
@ -1063,8 +1061,7 @@ SWITCH_DECLARE(switch_status_t) switch_socket_send(switch_socket_t * sock, const
* @param buf The data to send * @param buf The data to send
* @param len The length of 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_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_size_t *len);
/** /**
* @param from The apr_sockaddr_t to fill in the recipient info * @param from The apr_sockaddr_t to fill in the recipient info
@ -1074,7 +1071,7 @@ SWITCH_DECLARE(switch_status_t) switch_socket_sendto(switch_socket_t * sock, swi
* @param len The length of the available buffer * @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 @@ SWITCH_DECLARE(switch_status_t) switch_socket_recvfrom(switch_sockaddr_t * from,
* APR_EINTR is never returned. * APR_EINTR is never returned.
* </PRE> * </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 * Setup socket options for the specified socket
@ -1120,7 +1117,7 @@ SWITCH_DECLARE(switch_status_t) switch_socket_recv(switch_socket_t * sock, char
* </PRE> * </PRE>
* @param on Value for the option. * @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 * Setup socket timeout for the specified socket
@ -1133,7 +1130,7 @@ SWITCH_DECLARE(switch_status_t) switch_socket_opt_set(switch_socket_t * sock, in
* t < 0 -- read and write calls block * t < 0 -- read and write calls block
* </PRE> * </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 * Join a Multicast Group
@ -1144,7 +1141,7 @@ SWITCH_DECLARE(switch_status_t) switch_socket_timeout_set(switch_socket_t * sock
* @param source Source Address to accept transmissions from (non-NULL * @param source Source Address to accept transmissions from (non-NULL
* implies Source-Specific Multicast) * 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 @@ SWITCH_DECLARE(switch_status_t) switch_mcast_join(switch_socket_t * sock, switch
* platforms; the apr_pollset_create() call will fail with * platforms; the apr_pollset_create() call will fail with
* APR_ENOTIMPL on platforms where it is not supported. * 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 * Add a socket or file descriptor to a pollset
@ -1204,7 +1201,7 @@ SWITCH_DECLARE(switch_status_t) switch_pollset_create(switch_pollset_t ** pollse
* allowed for implementations where option (1) is impossible * allowed for implementations where option (1) is impossible
* or impractical. * 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 * Poll the sockets in the poll structure
@ -1219,7 +1216,7 @@ SWITCH_DECLARE(switch_status_t) switch_pollset_add(switch_pollset_t * pollset, c
* This is a blocking call, and it will not return until either a * This is a blocking call, and it will not return until either a
* socket has been signalled, or the timeout has expired. * 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 \brief Create a set of file descriptors to poll
@ -1229,7 +1226,7 @@ SWITCH_DECLARE(switch_status_t) switch_poll(switch_pollfd_t * aprset, int32_t nu
\param pool the memory pool to use \param pool the memory pool to use
\return SWITCH_STATUS_SUCCESS when successful \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_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); SWITCH_DECLARE(switch_status_t) switch_socket_addr_get(switch_sockaddr_t **sa, switch_bool_t remote, switch_socket_t *sock);

View File

@ -122,7 +122,8 @@ SWITCH_DECLARE(void) switch_buffer_set_loops(_In_ switch_buffer_t *buffer, _In_
* \param datalen amount of data to be written * \param datalen amount of data to be written
* \return int amount of buffer used after the write, or 0 if no space available * \return int amount of buffer used after the write, or 0 if no space available
*/ */
SWITCH_DECLARE(switch_size_t) switch_buffer_write(_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 /*! \brief Remove data from the buffer
* \param buffer any buffer of type switch_buffer_t * \param buffer any buffer of type switch_buffer_t
@ -142,7 +143,8 @@ SWITCH_DECLARE(void) switch_buffer_zero(_In_ switch_buffer_t *buffer);
*/ */
SWITCH_DECLARE(void) switch_buffer_destroy(switch_buffer_t **buffer); 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);
/** @} */ /** @} */

View File

@ -140,8 +140,7 @@ struct switch_caller_extension {
\return a new extension object allocated from the session's memory pool \return a new extension object allocated from the session's memory pool
*/ */
SWITCH_DECLARE(switch_caller_extension_t *) switch_caller_extension_new(_In_ switch_core_session_t *session, 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_name, _In_z_ const char *extension_number);
_In_z_ const char *extension_number);
/*! /*!
\brief Add an application (instruction) to the given extension \brief Add an application (instruction) to the given extension
@ -152,8 +151,7 @@ SWITCH_DECLARE(switch_caller_extension_t *) switch_caller_extension_new(_In_ swi
*/ */
SWITCH_DECLARE(void) switch_caller_extension_add_application(_In_ switch_core_session_t *session, SWITCH_DECLARE(void) switch_caller_extension_add_application(_In_ switch_core_session_t *session,
_In_ switch_caller_extension_t *caller_extension, _In_ switch_caller_extension_t *caller_extension,
_In_z_ const char *application_name, _In_z_ const char *application_name, _In_z_ const char *extra_data);
_In_z_ const char *extra_data);
/*! /*!
@ -162,7 +160,7 @@ SWITCH_DECLARE(void) switch_caller_extension_add_application(_In_ switch_core_se
\param name the name \param name the name
\note this function is meant for situations where the name paramater is the contents of the variable \note this function is meant for situations where the name paramater is the contents of the variable
*/ */
_Check_return_ _Ret_opt_z_ SWITCH_DECLARE(const char *) switch_caller_get_field_by_name(_In_ switch_caller_profile_t *caller_profile, _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); _In_z_ const char *name);
/*! /*!
@ -191,8 +189,7 @@ SWITCH_DECLARE(switch_caller_profile_t *) switch_caller_profile_new(_In_ switch_
_In_opt_z_ const char *aniii, _In_opt_z_ const char *aniii,
_In_opt_z_ const char *rdnis, _In_opt_z_ const char *rdnis,
_In_opt_z_ const char *source, _In_opt_z_ const char *source,
_In_opt_z_ const char *context, _In_opt_z_ const char *context, _In_opt_z_ const char *destination_number);
_In_opt_z_ const char *destination_number);
/*! /*!
\brief Clone an existing caller profile object \brief Clone an existing caller profile object
@ -216,8 +213,7 @@ SWITCH_DECLARE(switch_caller_profile_t *) switch_caller_profile_dup(_In_ switch_
*/ */
SWITCH_DECLARE(void) switch_caller_profile_event_set_data(_In_ switch_caller_profile_t *caller_profile, SWITCH_DECLARE(void) switch_caller_profile_event_set_data(_In_ switch_caller_profile_t *caller_profile,
_In_opt_z_ const char *prefix, _In_opt_z_ const char *prefix, _In_ switch_event_t *event);
_In_ switch_event_t *event);
SWITCH_END_EXTERN_C SWITCH_END_EXTERN_C
/** @} */ /** @} */

View File

@ -438,7 +438,8 @@ SWITCH_DECLARE(switch_status_t) switch_channel_queue_dtmf_string(_In_ switch_cha
*/ */
SWITCH_DECLARE(switch_status_t) switch_channel_dequeue_dtmf(_In_ switch_channel_t *channel, _In_ switch_dtmf_t *dtmf); 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(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 \brief Render the name of the provided state enum
@ -469,7 +470,8 @@ SWITCH_DECLARE(void) switch_channel_event_set_data(_In_ switch_channel_t *channe
\note it's necessary to test if the return val is the same as the input and free the string if it is not. \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_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); 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) #define switch_channel_stop_broadcast(_channel) if (switch_channel_test_flag(_channel, CF_BROADCAST)) switch_channel_set_flag(_channel, CF_BREAK | CF_STOP_BROADCAST)

View File

@ -88,13 +88,13 @@ struct switch_config {
\param file_path path to the file \param file_path path to the file
\return 1 (true) on success 0 (false) on failure \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 \brief Close a previously opened configuration file
\param cfg (switch_config_t *) config handle to use \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 \brief Retrieve next name/value pair from configuration file
@ -102,7 +102,7 @@ SWITCH_DECLARE(void) switch_config_close_file(switch_config_t * cfg);
\param var pointer to aim at the new variable name \param var pointer to aim at the new variable name
\param val pointer to aim at the new value \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 SWITCH_END_EXTERN_C
/** @} */ /** @} */

View File

@ -52,7 +52,6 @@ SWITCH_BEGIN_EXTERN_C
s.raw_write_function = switch_console_stream_raw_write; \ s.raw_write_function = switch_console_stream_raw_write; \
s.alloc_len = SWITCH_CMD_CHUNK_LEN; \ s.alloc_len = SWITCH_CMD_CHUNK_LEN; \
s.alloc_chunk = SWITCH_CMD_CHUNK_LEN s.alloc_chunk = SWITCH_CMD_CHUNK_LEN
/*! /*!
\brief A simple comand loop that reads input from the terminal \brief A simple comand loop that reads input from the terminal
*/ */

View File

@ -43,7 +43,7 @@
SWITCH_BEGIN_EXTERN_C SWITCH_BEGIN_EXTERN_C
#define SWITCH_MAX_CORE_THREAD_SESSION_OBJS 128 #define SWITCH_MAX_CORE_THREAD_SESSION_OBJS 128
#define SWITCH_MAX_STREAMS 128 #define SWITCH_MAX_STREAMS 128
struct switch_core_time_duration { struct switch_core_time_duration {
uint32_t mms; uint32_t mms;
uint32_t ms; uint32_t ms;
uint32_t sec; uint32_t sec;
@ -132,9 +132,7 @@ struct switch_core_port_allocator;
SWITCH_DECLARE(switch_status_t) switch_core_media_bug_add(_In_ switch_core_session_t *session, SWITCH_DECLARE(switch_status_t) switch_core_media_bug_add(_In_ switch_core_session_t *session,
_In_ switch_media_bug_callback_t callback, _In_ switch_media_bug_callback_t callback,
_In_opt_ void *user_data, _In_opt_ void *user_data,
_In_ time_t stop_time, _In_ time_t stop_time, _In_ switch_media_bug_flag_t flags, _Out_ switch_media_bug_t **new_bug);
_In_ switch_media_bug_flag_t flags,
_Out_ switch_media_bug_t **new_bug);
/*! /*!
\brief Obtain private data from a media bug \brief Obtain private data from a media bug
\param bug the bug to get the data from \param bug the bug to get the data from
@ -221,8 +219,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_bug_read(_In_ switch_media_bug
*/ */
SWITCH_DECLARE(switch_status_t) switch_core_port_allocator_new(_In_ switch_port_t start, SWITCH_DECLARE(switch_status_t) switch_core_port_allocator_new(_In_ switch_port_t start,
_In_ switch_port_t end, _In_ switch_port_t end,
_In_ switch_port_flag_t flags, _In_ switch_port_flag_t flags, _Out_ switch_core_port_allocator_t **new_allocator);
_Out_ switch_core_port_allocator_t **new_allocator);
/*! /*!
\brief Get a port from the port allocator \brief Get a port from the port allocator
@ -406,7 +403,8 @@ SWITCH_DECLARE(void *) switch_core_perform_permanent_alloc(_In_ switch_size_t me
#define switch_core_permanent_alloc(_memory) switch_core_perform_permanent_alloc(_memory, __FILE__, __SWITCH_FUNC__, __LINE__) #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 \brief Allocate memory directly from a memory pool
@ -416,7 +414,8 @@ SWITCH_DECLARE(void *) switch_core_perform_alloc(_In_ switch_memory_pool_t *pool
*/ */
#define switch_core_alloc(_pool, _mem) switch_core_perform_alloc(_pool, _mem, __FILE__, __SWITCH_FUNC__, __LINE__) #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 \brief Allocate memory from a session's pool
@ -439,7 +438,8 @@ SWITCH_DECLARE(char *) switch_core_perform_permanent_strdup(_In_z_ const char *t
#define switch_core_permanent_strdup(_todup) switch_core_perform_permanent_strdup(_todup, __FILE__, __SWITCH_FUNC__, __LINE__) #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 \brief Copy a string using memory allocation from a session's pool
@ -450,7 +450,8 @@ SWITCH_DECLARE(char *) switch_core_perform_session_strdup(_In_ switch_core_sessi
#define switch_core_session_strdup(_session, _todup) switch_core_perform_session_strdup(_session, _todup, __FILE__, __SWITCH_FUNC__, __LINE__) #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 \brief Copy a string using memory allocation from a given pool
@ -542,7 +543,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_thread_launch(_In_ switch_co
\param session the session to retrieve from \param session the session to retrieve from
\return a pointer to the channel object \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 \brief Signal a session's state machine thread that a state change has occured
@ -620,7 +621,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_queue_message(_In_ switch_co
\param indication the indication message to pass \param indication the indication message to pass
\return SWITCH_STATUS_SUCCESS if the message was passed \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 \brief Queue an indication message on a session
@ -628,7 +630,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_pass_indication(_In_ switch_
\param indication the indication message to queue \param indication the indication message to queue
\return SWITCH_STATUS_SUCCESS if the message was queued \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 \brief DE-Queue an message on a given session
@ -656,17 +659,14 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_event_send(_In_z_ const char
SWITCH_DECLARE(switch_app_log_t *) switch_core_session_get_app_log(_In_ switch_core_session_t *session); 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, SWITCH_DECLARE(switch_status_t) switch_core_session_exec(_In_ switch_core_session_t *session,
_In_ const switch_application_interface_t *application_interface, _In_ const switch_application_interface_t *application_interface, _In_opt_z_ const char *arg);
_In_opt_z_ const char *arg);
SWITCH_DECLARE(switch_status_t) switch_core_session_execute_application(_In_ switch_core_session_t *session, SWITCH_DECLARE(switch_status_t) switch_core_session_execute_application(_In_ switch_core_session_t *session,
_In_ const char *app, _In_ const char *app, _In_opt_z_ const char *arg);
_In_opt_z_ const char *arg);
SWITCH_DECLARE(switch_status_t) switch_core_session_execute_exten(_In_ switch_core_session_t *session, SWITCH_DECLARE(switch_status_t) switch_core_session_execute_exten(_In_ switch_core_session_t *session,
_In_z_ const char *exten, _In_z_ const char *exten,
_In_opt_z_ const char *dialplan, _In_opt_z_ const char *dialplan, _In_opt_z_ const char *context);
_In_opt_z_ const char *context);
/*! /*!
\brief Send an event to a session translating it to it's native message format \brief Send an event to a session translating it to it's native message format
@ -721,8 +721,7 @@ SWITCH_DECLARE(int) switch_core_session_get_stream_count(_In_ switch_core_sessio
\param obj an arguement \param obj an arguement
*/ */
SWITCH_DECLARE(void) switch_core_session_launch_thread(_In_ switch_core_session_t *session, SWITCH_DECLARE(void) switch_core_session_launch_thread(_In_ switch_core_session_t *session,
_In_ void *(*func) (switch_thread_t *, void *), _In_ void *(*func) (switch_thread_t *, void *), _In_opt_ void *obj);
_In_opt_ void *obj);
/*! /*!
\brief Signal a thread using a thread session to terminate \brief Signal a thread using a thread session to terminate
@ -737,8 +736,7 @@ SWITCH_DECLARE(void) switch_core_thread_session_end(_In_ switch_core_thread_sess
\param thread_session the thread_session to use \param thread_session the thread_session to use
*/ */
SWITCH_DECLARE(void) switch_core_service_session(_In_ switch_core_session_t *session, SWITCH_DECLARE(void) switch_core_service_session(_In_ switch_core_session_t *session,
_In_ switch_core_thread_session_t *thread_session, _In_ switch_core_thread_session_t *thread_session, _In_ int stream_id);
_In_ int stream_id);
/*! /*!
\brief Request an outgoing session spawned from an existing session using a desired endpoing module \brief Request an outgoing session spawned from an existing session using a desired endpoing module
@ -756,13 +754,11 @@ SWITCH_DECLARE(switch_call_cause_t) switch_core_session_outgoing_channel(_In_opt
_In_z_ const char *endpoint_name, _In_z_ const char *endpoint_name,
_In_ switch_caller_profile_t *caller_profile, _In_ switch_caller_profile_t *caller_profile,
_Inout_ switch_core_session_t **new_session, _Inout_ switch_core_session_t **new_session,
_Inout_ switch_memory_pool_t **pool, _Inout_ switch_memory_pool_t **pool, _In_ switch_originate_flag_t flags);
_In_ switch_originate_flag_t flags);
SWITCH_DECLARE(switch_call_cause_t) switch_core_session_resurrect_channel(_In_z_ const char *endpoint_name, 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_core_session_t **new_session,
_Inout_ switch_memory_pool_t **pool, _Inout_ switch_memory_pool_t **pool, _In_ void *data);
_In_ void *data);
/*! /*!
\brief Receive a message on a given session \brief Receive a message on a given session
@ -837,7 +833,8 @@ SWITCH_DECLARE(uint32_t) switch_core_session_flush_private_events(switch_core_se
\param stream_id which logical media channel to use \param stream_id which logical media channel to use
\return SWITCH_STATUS_SUCCESS a the frame was read \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 \brief Read a video frame from a session
@ -847,7 +844,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(_In_ switch_core_
\param stream_id which logical media channel to use \param stream_id which logical media channel to use
\return SWITCH_STATUS_SUCCESS a if the frame was read \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 \brief Write a video frame to a session
@ -857,7 +855,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_video_frame(_In_ switch
\param stream_id which logical media channel to use \param stream_id which logical media channel to use
\return SWITCH_STATUS_SUCCESS a if the frame was written \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 \brief Reset the buffers and resampler on a session
@ -874,7 +873,8 @@ SWITCH_DECLARE(void) switch_core_session_reset(_In_ switch_core_session_t *sessi
\param stream_id which logical media channel to use \param stream_id which logical media channel to use
\return SWITCH_STATUS_SUCCESS a the frame was written \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, SWITCH_DECLARE(switch_status_t) switch_core_session_perform_kill_channel(_In_ switch_core_session_t *session,
@ -916,7 +916,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_recv_dtmf(_In_ switch_core_s
\param pool the pool to use for the new hash \param pool the pool to use for the new hash
\return SWITCH_STATUS_SUCCESS if the hash is created \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 \brief Destroy an existing hash table
@ -933,7 +933,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_hash_destroy(_Inout_ switch_hash_t *
\return SWITCH_STATUS_SUCCESS if the data is added \return SWITCH_STATUS_SUCCESS if the data is added
\note the string key must be a constant or a dynamic string \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 \brief Insert data into a hash
@ -944,7 +944,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_hash_insert(_In_ switch_hash_t * has
\return SWITCH_STATUS_SUCCESS if the data is added \return SWITCH_STATUS_SUCCESS if the data is added
\note the string key must be a constant or a dynamic string \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 \brief Delete data from a hash based on desired key
@ -952,7 +953,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_hash_insert_locked(_In_ switch_hash_
\param key the key from which to delete the data \param key the key from which to delete the data
\return SWITCH_STATUS_SUCCESS if the data is deleted \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 \brief Delete data from a hash based on desired key
@ -961,7 +962,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_hash_delete(_In_ switch_hash_t * has
\param mutex optional mutex to lock \param mutex optional mutex to lock
\return SWITCH_STATUS_SUCCESS if the data is deleted \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 \brief Retrieve data from a given hash
@ -969,7 +970,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_hash_delete_locked(_In_ switch_hash_
\param key the key to retrieve \param key the key to retrieve
\return a pointer to the data held in the key \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 @@ SWITCH_DECLARE(void *) switch_core_hash_find(_In_ switch_hash_t * hash, _In_z_ c
\param mutex optional mutex to lock \param mutex optional mutex to lock
\return a pointer to the data held in the key \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_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(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 @@ SWITCH_DECLARE(void) switch_hash_this(_In_ switch_hash_index_t *hi, _Out_opt_ptr
\param pool the memory pool to use for allocation \param pool the memory pool to use for allocation
\return \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 \brief Wait for one cycle on an existing timer
@ -1078,7 +1081,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_codec_encode(switch_codec_t *codec,
void *decoded_data, void *decoded_data,
uint32_t decoded_data_len, uint32_t decoded_data_len,
uint32_t decoded_rate, 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 \brief Decode data using a codec handle
@ -1099,7 +1102,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_codec_decode(switch_codec_t *codec,
void *encoded_data, void *encoded_data,
uint32_t encoded_data_len, uint32_t encoded_data_len,
uint32_t encoded_rate, 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 \brief Destroy an initalized codec handle
@ -1214,9 +1217,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_perform_file_open(const char *file,
_In_ switch_file_handle_t *fh, _In_ switch_file_handle_t *fh,
_In_z_ const char *file_path, _In_z_ const char *file_path,
_In_ uint8_t channels, _In_ uint8_t channels,
_In_ uint32_t rate, _In_ uint32_t rate, _In_ unsigned int flags, _In_opt_ switch_memory_pool_t *pool);
_In_ unsigned int flags,
_In_opt_ switch_memory_pool_t *pool);
/*! /*!
\brief Open a media file using file format modules \brief Open a media file using file format modules
@ -1305,8 +1306,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_speech_open(_In_ switch_speech_handl
const char *module_name, const char *module_name,
const char *voice_name, const char *voice_name,
_In_ unsigned int rate, _In_ unsigned int rate,
_In_ unsigned int interval, _In_ unsigned int interval, switch_speech_flag_t *flags, _In_ switch_memory_pool_t *pool);
switch_speech_flag_t *flags, _In_ switch_memory_pool_t *pool);
/*! /*!
\brief Feed text to the TTS module \brief Feed text to the TTS module
\param sh the speech handle to feed \param sh the speech handle to feed
@ -1356,7 +1356,7 @@ SWITCH_DECLARE(void) switch_core_speech_float_param_tts(switch_speech_handle_t *
\return SWITCH_STATUS_SUCCESS with len adjusted to the bytes written if successful \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, 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 \brief Close an open speech handle
\param sh the speech handle to close \param sh the speech handle to close
@ -1379,11 +1379,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_speech_close(switch_speech_handle_t
*/ */
SWITCH_DECLARE(switch_status_t) switch_core_asr_open(switch_asr_handle_t *ah, SWITCH_DECLARE(switch_status_t) switch_core_asr_open(switch_asr_handle_t *ah,
const char *module_name, const char *module_name,
const char *codec, const char *codec, int rate, const char *dest, switch_asr_flag_t *flags, switch_memory_pool_t *pool);
int rate,
const char *dest,
switch_asr_flag_t *flags,
switch_memory_pool_t *pool);
/*! /*!
\brief Close an asr handle \brief Close an asr handle
@ -1587,7 +1583,7 @@ SWITCH_DECLARE(switch_time_t) switch_core_uptime(void);
\param val the command arguement (if needed) \param val the command arguement (if needed)
\return 0 on success nonzero on error \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 \brief Get the output console

View File

@ -32,8 +32,7 @@
#define SWITCH_EVENT_HOOKS_H #define SWITCH_EVENT_HOOKS_H
#include <switch.h> #include <switch.h>
SWITCH_BEGIN_EXTERN_C SWITCH_BEGIN_EXTERN_C typedef struct switch_io_event_hooks switch_io_event_hooks_t;
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_outgoing_channel switch_io_event_hook_outgoing_channel_t;
typedef struct switch_io_event_hook_receive_message switch_io_event_hook_receive_message_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_recv_dtmf switch_io_event_hook_recv_dtmf_t;
typedef struct switch_io_event_hook_state_change switch_io_event_hook_state_change_t; 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 struct switch_io_event_hook_resurrect_session switch_io_event_hook_resurrect_session_t;
typedef switch_status_t (*switch_outgoing_channel_hook_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_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_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); 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_kill_channel_hook_t) (switch_core_session_t *,
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_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_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_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 */ /*! \brief Node in which to store custom receive message callback hooks */
struct switch_io_event_hook_outgoing_channel { struct switch_io_event_hook_outgoing_channel {

View File

@ -8,36 +8,23 @@ extern "C" {
#ifdef DOH #ifdef DOH
} }
#endif #endif
#include <switch.h> #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(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 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(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 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) #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@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@cartissolutions.com>, (C) 2007
//
// Copyright: See COPYING file that comes with this distribution
//
#if 0 #if 0
#ifndef SWITCHTOMEMPOOL #ifndef SWITCHTOMEMPOOL
#define SWITCHTOMEMPOOL #define SWITCHTOMEMPOOL
class SwitchToMempool { class SwitchToMempool {
public: public:
SwitchToMempool() { } SwitchToMempool() {
SwitchToMempool(switch_memory_pool_t *mem) { memorypool = mem; } } SwitchToMempool(switch_memory_pool_t *mem) {
void *operator new(switch_size_t num_bytes, 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); void *ptr = switch_core_alloc(mem, (switch_size_t) num_bytes);
return ptr; return ptr;
} }
@ -66,14 +53,14 @@ Note that the first parameter to the new operator is implicitly handled by c++..
SWITCH_DECLARE(void) consoleLog(char *level_str, char *msg); SWITCH_DECLARE(void) consoleLog(char *level_str, char *msg);
SWITCH_DECLARE(void) consoleCleanLog(char *msg); SWITCH_DECLARE(void) consoleCleanLog(char *msg);
class CoreSession; class CoreSession;
class IVRMenu { class IVRMenu {
protected: protected:
switch_ivr_menu_t *menu; switch_ivr_menu_t *menu;
switch_memory_pool_t *pool; switch_memory_pool_t *pool;
public: public:
SWITCH_DECLARE_CONSTRUCTOR IVRMenu(IVRMenu *main, SWITCH_DECLARE_CONSTRUCTOR IVRMenu(IVRMenu * main,
const char *name, const char *name,
const char *greeting_sound, const char *greeting_sound,
const char *short_greeting_sound, const char *short_greeting_sound,
@ -81,45 +68,40 @@ class IVRMenu {
const char *exit_sound, const char *exit_sound,
const char *confirm_macro, const char *confirm_macro,
const char *confirm_key, const char *confirm_key,
int confirm_attempts, int confirm_attempts, int inter_timeout, int digit_len, int timeout, int max_failures);
int inter_timeout, virtual SWITCH_DECLARE_CONSTRUCTOR ~ IVRMenu();
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) bindAction(char *action, const char *arg, const char *bind);
SWITCH_DECLARE(void) execute(CoreSession *session, const char *name); SWITCH_DECLARE(void) execute(CoreSession * session, const char *name);
}; };
class API { class API {
protected: protected:
char *last_data; char *last_data;
public: public:
SWITCH_DECLARE_CONSTRUCTOR API(void); SWITCH_DECLARE_CONSTRUCTOR API(void);
virtual SWITCH_DECLARE_CONSTRUCTOR ~API(); virtual SWITCH_DECLARE_CONSTRUCTOR ~ API();
SWITCH_DECLARE(const char *) execute(const char *command, const char *data); SWITCH_DECLARE(const char *) execute(const char *command, const char *data);
SWITCH_DECLARE(const char *) executeString(const char *command); SWITCH_DECLARE(const char *) executeString(const char *command);
}; };
typedef struct input_callback_state { typedef struct input_callback_state {
void *function; // pointer to the language specific callback function void *function; // pointer to the language specific callback function
// eg, PyObject *pyfunc // eg, PyObject *pyfunc
void *threadState; // pointer to the language specific thread state void *threadState; // pointer to the language specific thread state
// eg, PyThreadState *threadState // eg, PyThreadState *threadState
void *extra; // currently used to store a switch_file_handle_t void *extra; // currently used to store a switch_file_handle_t
char *funcargs; // extra string that will be passed to callback function char *funcargs; // extra string that will be passed to callback function
} input_callback_state_t; } input_callback_state_t;
typedef enum { typedef enum {
S_HUP = (1 << 0), S_HUP = (1 << 0),
S_FREE = (1 << 1), S_FREE = (1 << 1),
S_RDLOCK = (1 << 2) S_RDLOCK = (1 << 2)
} session_flag_t; } session_flag_t;
class Stream { class Stream {
protected: protected:
switch_stream_handle_t mystream; switch_stream_handle_t mystream;
switch_stream_handle_t *stream_p; switch_stream_handle_t *stream_p;
@ -127,12 +109,12 @@ class Stream {
public: public:
SWITCH_DECLARE_CONSTRUCTOR Stream(void); SWITCH_DECLARE_CONSTRUCTOR Stream(void);
SWITCH_DECLARE_CONSTRUCTOR Stream(switch_stream_handle_t *); SWITCH_DECLARE_CONSTRUCTOR Stream(switch_stream_handle_t *);
virtual SWITCH_DECLARE_CONSTRUCTOR ~Stream(); virtual SWITCH_DECLARE_CONSTRUCTOR ~ Stream();
SWITCH_DECLARE(void) write(const char *data); SWITCH_DECLARE(void) write(const char *data);
SWITCH_DECLARE(const char *)get_data(void); SWITCH_DECLARE(const char *) get_data(void);
}; };
class Event { class Event {
protected: protected:
public: public:
switch_event_t *event; switch_event_t *event;
@ -140,22 +122,22 @@ class Event {
int mine; int mine;
SWITCH_DECLARE_CONSTRUCTOR Event(const char *type, const char *subclass_name = NULL); 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); SWITCH_DECLARE_CONSTRUCTOR Event(switch_event_t *wrap_me, int free_me = 0);
virtual SWITCH_DECLARE_CONSTRUCTOR ~Event(); virtual SWITCH_DECLARE_CONSTRUCTOR ~ Event();
SWITCH_DECLARE(const char *)serialize(const char *format=NULL); SWITCH_DECLARE(const char *) serialize(const char *format = NULL);
SWITCH_DECLARE(bool) setPriority(switch_priority_t priority = SWITCH_PRIORITY_NORMAL); SWITCH_DECLARE(bool) setPriority(switch_priority_t priority = SWITCH_PRIORITY_NORMAL);
SWITCH_DECLARE(const char *)getHeader(char *header_name); SWITCH_DECLARE(const char *) getHeader(char *header_name);
SWITCH_DECLARE(char *)getBody(void); SWITCH_DECLARE(char *) getBody(void);
SWITCH_DECLARE(const char *)getType(void); SWITCH_DECLARE(const char *) getType(void);
SWITCH_DECLARE(bool) addBody(const char *value); SWITCH_DECLARE(bool) addBody(const char *value);
SWITCH_DECLARE(bool) addHeader(const char *header_name, 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) delHeader(const char *header_name);
SWITCH_DECLARE(bool) fire(void); SWITCH_DECLARE(bool) fire(void);
}; };
class CoreSession { class CoreSession {
protected: protected:
switch_input_args_t args; // holds ptr to cb function and input_callback_state struct switch_input_args_t args; // holds ptr to cb function and input_callback_state struct
// which has a language specific callback function // which has a language specific callback function
@ -176,7 +158,7 @@ class CoreSession {
SWITCH_DECLARE_CONSTRUCTOR CoreSession(); SWITCH_DECLARE_CONSTRUCTOR CoreSession();
SWITCH_DECLARE_CONSTRUCTOR CoreSession(char *uuid); SWITCH_DECLARE_CONSTRUCTOR CoreSession(char *uuid);
SWITCH_DECLARE_CONSTRUCTOR CoreSession(switch_core_session_t *new_session); SWITCH_DECLARE_CONSTRUCTOR CoreSession(switch_core_session_t *new_session);
SWITCH_DECLARE_CONSTRUCTOR ~CoreSession(); SWITCH_DECLARE_CONSTRUCTOR ~ CoreSession();
switch_core_session_t *session; switch_core_session_t *session;
switch_channel_t *channel; switch_channel_t *channel;
unsigned int flags; unsigned int flags;
@ -190,8 +172,8 @@ class CoreSession {
SWITCH_DECLARE(void) hangup(char *cause = "normal_clearing"); SWITCH_DECLARE(void) hangup(char *cause = "normal_clearing");
SWITCH_DECLARE(void) setVariable(char *var, char *val); SWITCH_DECLARE(void) setVariable(char *var, char *val);
SWITCH_DECLARE(void) setPrivate(char *var, void *val); SWITCH_DECLARE(void) setPrivate(char *var, void *val);
SWITCH_DECLARE(void *)getPrivate(char *var); SWITCH_DECLARE(void *) getPrivate(char *var);
SWITCH_DECLARE(const char *)getVariable(char *var); SWITCH_DECLARE(const char *) getVariable(char *var);
SWITCH_DECLARE(switch_status_t) process_callback_result(char *result); 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) 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); SWITCH_DECLARE(void) sayPhrase(const char *phrase_name, const char *phrase_data = "", const char *phrase_lang = NULL);
@ -203,7 +185,7 @@ class CoreSession {
* to be considered silence (500 is a good starting point). * to be considered silence (500 is a good starting point).
* \param <[silence_secs]> seconds of silence to interrupt the record. * \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 /** \brief Set attributes of caller data for purposes of outgoing calls
@ -222,9 +204,7 @@ class CoreSession {
* \return an int status code indicating success or failure * \return an int status code indicating success or failure
* *
*/ */
SWITCH_DECLARE(int) originate(CoreSession *a_leg_session, SWITCH_DECLARE(int) originate(CoreSession * a_leg_session, char *dest, int timeout = 60);
char *dest,
int timeout=60);
/** \brief set a DTMF callback function /** \brief set a DTMF callback function
@ -253,19 +233,12 @@ class CoreSession {
* (see mod_python.i). This does NOT call any callbacks upon * (see mod_python.i). This does NOT call any callbacks upon
* receiving dtmf digits. For that, use collectDigits. * receiving dtmf digits. For that, use collectDigits.
*/ */
SWITCH_DECLARE(char *) getDigits( SWITCH_DECLARE(char *) getDigits(int maxdigits, char *terminators, int timeout);
int maxdigits,
char *terminators,
int timeout);
SWITCH_DECLARE(int) transfer(char *extensions, char *dialplan, char *context); SWITCH_DECLARE(int) transfer(char *extensions, char *dialplan, char *context);
SWITCH_DECLARE(char *) read(int min_digits, SWITCH_DECLARE(char *) read(int min_digits, int max_digits, const char *prompt_audio_file, int timeout, const char *valid_terminators);
int max_digits,
const char *prompt_audio_file,
int timeout,
const char *valid_terminators);
/** \brief Play a file into channel and collect dtmfs /** \brief Play a file into channel and collect dtmfs
* *
@ -278,11 +251,7 @@ class CoreSession {
SWITCH_DECLARE(char *) playAndGetDigits(int min_digits, SWITCH_DECLARE(char *) playAndGetDigits(int min_digits,
int max_digits, int max_digits,
int max_tries, int max_tries,
int timeout, int timeout, char *terminators, char *audio_files, char *bad_input_audio_files, char *digits_regex);
char *terminators,
char *audio_files,
char *bad_input_audio_files,
char *digits_regex);
/** \brief Play a file that resides on disk into the channel /** \brief Play a file that resides on disk into the channel
* *
@ -292,7 +261,7 @@ class CoreSession {
* \return an int status code indicating success or failure * \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 /** \brief flush any pending events
*/ */
@ -311,11 +280,11 @@ class CoreSession {
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(void) setEventData(Event * e);
SWITCH_DECLARE(char *) getXMLCDR(); SWITCH_DECLARE(char *) getXMLCDR();
virtual bool begin_allow_threads() = 0; virtual bool begin_allow_threads() = 0;
@ -324,21 +293,24 @@ class CoreSession {
/** \brief Get the uuid of this session /** \brief Get the uuid of this session
* \return 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 /** \brief Get the callback function arguments associated with this session
* \return a const reference to the callback function arguments * \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 /** \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, virtual switch_status_t run_dtmf_callback(void *input, switch_input_type_t itype) = 0;
switch_input_type_t itype) = 0;
}; };
/* ---- functions not bound to CoreSession instance ----- */ /* ---- functions not bound to CoreSession instance ----- */
@ -351,7 +323,7 @@ SWITCH_DECLARE(void) console_clean_log(char *msg);
* NOTE: the stuff regarding the dtmf callback might be completely * NOTE: the stuff regarding the dtmf callback might be completely
* wrong and has not been reviewed or tested * 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 /** \brief the actual hangup hook called back by freeswitch core
@ -361,10 +333,7 @@ SWITCH_DECLARE(void) bridge(CoreSession &session_a, CoreSession &session_b);
SWITCH_DECLARE_NONSTD(switch_status_t) hanguphook(switch_core_session_t *session); 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, SWITCH_DECLARE_NONSTD(switch_status_t) dtmf_callback(switch_core_session_t *session,
void *input, void *input, switch_input_type_t itype, void *buf, unsigned int buflen);
switch_input_type_t itype,
void *buf,
unsigned int buflen);
#ifdef __cplusplus #ifdef __cplusplus
@ -382,4 +351,3 @@ SWITCH_DECLARE_NONSTD(switch_status_t) dtmf_callback(switch_core_session_t *sess
* For VIM: * For VIM:
* vim:set softtabstop=4 shiftwidth=4 tabstop=4 expandtab: * vim:set softtabstop=4 shiftwidth=4 tabstop=4 expandtab:
*/ */

View File

@ -156,7 +156,7 @@ SWITCH_DECLARE(switch_status_t) switch_event_set_priority(switch_event_t *event,
\param header_name the name of the header to read \param header_name the name of the header to read
\return the value of the requested header \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)) #define switch_event_get_header_nil(e, h) switch_str_nil(switch_event_get_header(e,h))
@ -344,7 +344,7 @@ SWITCH_DECLARE(void) switch_event_deliver(switch_event_t **event);
*/ */
#define switch_event_fire_data(event, data) switch_event_fire_detailed(__FILE__, (char * )__SWITCH_FUNC__, __LINE__, event, data) #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);
///\} ///\}

View File

@ -40,7 +40,7 @@
SWITCH_BEGIN_EXTERN_C SWITCH_BEGIN_EXTERN_C
/*! \brief An abstraction of a data frame */ /*! \brief An abstraction of a data frame */
struct switch_frame { struct switch_frame {
/*! a pointer to the codec information */ /*! a pointer to the codec information */
switch_codec_t *codec; switch_codec_t *codec;
/*! the originating source of the frame */ /*! the originating source of the frame */

View File

@ -41,9 +41,7 @@
#include <switch.h> #include <switch.h>
SWITCH_BEGIN_EXTERN_C SWITCH_BEGIN_EXTERN_C struct switch_unicast_conninfo {
struct switch_unicast_conninfo {
switch_core_session_t *session; switch_core_session_t *session;
switch_codec_t read_codec; switch_codec_t read_codec;
switch_frame_t write_frame; switch_frame_t write_frame;
@ -76,10 +74,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_deactivate_unicast(switch_core_sessio
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, char *local_ip,
switch_port_t local_port, switch_port_t local_port,
char *remote_ip, char *remote_ip, switch_port_t remote_port, char *transport, char *flags);
switch_port_t remote_port,
char *transport,
char *flags);
/*! /*!
\brief Generate an XML CDR report. \brief Generate an XML CDR report.
@ -88,7 +83,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_activate_unicast(switch_core_session_
\return SWITCH_STATUS_SUCCESS if successful \return SWITCH_STATUS_SUCCESS if successful
\note on success the xml object must be freed \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_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); SWITCH_DECLARE(int) switch_ivr_set_xml_chan_vars(switch_xml_t xml, switch_channel_t *channel, int off);
@ -145,9 +140,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_collect_digits_count(switch_core_sess
switch_size_t buflen, switch_size_t buflen,
switch_size_t maxdigits, switch_size_t maxdigits,
const char *terminators, char *terminator, const char *terminators, char *terminator,
uint32_t first_timeout, uint32_t first_timeout, uint32_t digit_timeout, uint32_t abs_timeout);
uint32_t digit_timeout,
uint32_t abs_timeout);
/*! /*!
\brief Engage background Speech detection on a session \brief Engage background Speech detection on a session
@ -161,9 +154,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_collect_digits_count(switch_core_sess
*/ */
SWITCH_DECLARE(switch_status_t) switch_ivr_detect_speech(switch_core_session_t *session, SWITCH_DECLARE(switch_status_t) switch_ivr_detect_speech(switch_core_session_t *session,
const char *mod_name, const char *mod_name,
const char *grammar, const char *grammar, const char *path, const char *dest, switch_asr_handle_t *ah);
const char *path,
const char *dest, switch_asr_handle_t *ah);
/*! /*!
\brief Stop background Speech detection on a session \brief Stop background Speech detection on a session
@ -222,9 +213,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_record_session(switch_core_session_t
\return SWITCH_STATUS_SUCESS if all is well \return SWITCH_STATUS_SUCESS if all is well
*/ */
SWITCH_DECLARE(switch_status_t) switch_ivr_eavesdrop_session(switch_core_session_t *session, SWITCH_DECLARE(switch_status_t) switch_ivr_eavesdrop_session(switch_core_session_t *session,
const char *uuid, const char *uuid, const char *require_group, switch_eavesdrop_flag_t flags);
const char *require_group,
switch_eavesdrop_flag_t flags);
/*! /*!
\brief displace the media for a session with the audio from a file \brief displace the media for a session with the audio from a file
@ -309,8 +298,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_stop_tone_detect_session(switch_core_
*/ */
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 *key, const char *tone_spec,
const char *flags, time_t timeout, const char *flags, time_t timeout, const char *app, const char *data);
const char *app, const char *data);
@ -322,7 +310,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_tone_detect_session(switch_core_sessi
\param args arguements to pass for callbacks etc \param args arguements to pass for callbacks etc
\return SWITCH_STATUS_SUCCESS if all is well \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); 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_gentones(switch_core_session_t *sessi
*/ */
SWITCH_DECLARE(switch_status_t) switch_ivr_record_file(_In_ switch_core_session_t *session, SWITCH_DECLARE(switch_status_t) switch_ivr_record_file(_In_ switch_core_session_t *session,
_In_ switch_file_handle_t *fh, _In_ switch_file_handle_t *fh,
_In_z_ const char *file, _In_z_ const char *file, _In_opt_ switch_input_args_t *args, _In_ uint32_t limit);
_In_opt_ switch_input_args_t *args,
_In_ uint32_t limit);
/*! /*!
@ -407,8 +394,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
const switch_state_handler_table_t *table, const switch_state_handler_table_t *table,
const char *cid_name_override, const char *cid_name_override,
const char *cid_num_override, const char *cid_num_override,
switch_caller_profile_t *caller_profile_override, switch_caller_profile_t *caller_profile_override, switch_originate_flag_t flags);
switch_originate_flag_t flags);
/*! /*!
\brief Bridge Audio from one session to another \brief Bridge Audio from one session to another
@ -439,7 +425,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_signal_bridge(switch_core_session_t *
\param dialplan the new dialplan (OPTIONAL, may be NULL) \param dialplan the new dialplan (OPTIONAL, may be NULL)
\param context the new context (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 \brief Transfer an existing session to another location in the future
@ -560,14 +547,14 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_transfer_variable(switch_core_session
\param parser a pointer to the object pointer \param parser a pointer to the object pointer
\return SWITCH_STATUS_SUCCESS if all is well \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 \brief Destroy a digit stream parser object
\param parser a pointer to the parser object \param parser a pointer to the parser object
\return SWITCH_STATUS_SUCCESS if all is well \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 \brief Create a new digit stream object
@ -575,14 +562,14 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_parser_destroy(switch_iv
\param stream a pointer to the stream object pointer \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 \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 \brief Destroys a digit stream object
\param stream a pointer to the 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 \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 \brief Set a digit string to action mapping
@ -591,7 +578,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_destroy(switch_ivr_digit
\param data consumer data attached to this digit string \param data consumer data attached to this digit string
\return SWITCH_STATUS_SUCCESS if all is well \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 \brief Delete a string to action mapping
@ -599,7 +586,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_parser_set_event(switch_
\param digits the digit string to be removed from the map \param digits the digit string to be removed from the map
\return SWITCH_STATUS_SUCCESS if all is well \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 \brief Feed digits collected into the stream for event match testing
@ -608,14 +595,14 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_parser_del_event(switch_
\param digit a digit to collect and test against the map of digit strings \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 \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 \brief Reset the collected digit stream to nothing
\param stream a pointer to the parser stream object created by switch_ivr_digit_stream_new \param stream a pointer to the parser stream object created by switch_ivr_digit_stream_new
\return SWITCH_STATUS_SUCCESS if all is well \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 \brief Set a digit string terminator
@ -623,7 +610,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_reset(switch_ivr_digit_s
\param digit the terminator digit \param digit the terminator digit
\return SWITCH_STATUS_SUCCESS if all is well \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_DECLARE(switch_status_t) switch_ivr_digit_stream_parser_set_terminator(sw
SWITCH_IVR_ACTION_NOOP /* No operation */ SWITCH_IVR_ACTION_NOOP /* No operation */
} switch_ivr_action_t; } switch_ivr_action_t;
struct switch_ivr_menu; 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 switch_ivr_menu_t;
typedef struct switch_ivr_menu_action switch_ivr_menu_action_t; typedef struct switch_ivr_menu_action switch_ivr_menu_action_t;
/******************************************************************************************************/ /******************************************************************************************************/
@ -680,8 +667,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_parser_set_terminator(sw
*\return SWITCH_STATUS_SUCCESS if the menu was created. *\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_DECLARE(switch_status_t) switch_ivr_menu_init(switch_ivr_menu_t **new_menu,
switch_ivr_menu_t * main, switch_ivr_menu_t *main,
const char *name, const char *name,
const char *greeting_sound, const char *greeting_sound,
const char *short_greeting_sound, const char *short_greeting_sound,
@ -690,10 +677,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_menu_init(switch_ivr_menu_t ** new_me
const char *confirm_macro, const char *confirm_macro,
const char *confirm_key, const char *confirm_key,
int confirm_attempts, int confirm_attempts,
int inter_timeout, int inter_timeout, int digit_len, int timeout, int max_failures, switch_memory_pool_t *pool);
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. *\brief switch_ivr_menu_bind_action: Bind a keystroke to an action.
@ -703,7 +687,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_menu_init(switch_ivr_menu_t ** new_me
*\param bind KeyStrokes to bind the action to. *\param bind KeyStrokes to bind the action to.
*\return SWUTCH_STATUS_SUCCESS if the action was binded *\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 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_menu_bind_action(switch_ivr_menu_t *
*\note The function returns an switch_ivr_action_t enum of what you want to do. and looks to your buffer for args. *\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 *\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_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_ivr_menu_action_function_t *function, const char *arg, const char *bind);
/*! /*!
@ -729,14 +714,14 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_menu_bind_function(switch_ivr_menu_t
*\param obj A void pointer to an object you want to make avaliable to your callback functions that you may have binded with switch_ivr_menu_bind_function. *\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 *\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. *\brief free a stack of menu objects.
*\param stack The top level menu you wish to destroy. *\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 *\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; struct switch_ivr_menu_xml_ctx;
typedef struct switch_ivr_menu_xml_ctx switch_ivr_menu_xml_ctx_t; typedef struct switch_ivr_menu_xml_ctx switch_ivr_menu_xml_ctx_t;
@ -748,10 +733,10 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_menu_stack_free(switch_ivr_menu_t * s
*\param xml_menu The xml Menu source of the menu to be created *\param xml_menu The xml Menu source of the menu to be created
*\return SWITCH_STATUS_SUCCESS if all is well *\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_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_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 *\param xml_menu_ctx The XML menu parser context previously created by switch_ivr_menu_stack_xml_init
@ -759,46 +744,45 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_menu_str2action(const char *action_na
*\param function The menu function callback that will be executed when menu digits are bound to this name *\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 *\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, 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); 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 xml_menu_ctx A pointer of a XML menu parser context to be created
*\param pool memory pool (NULL to create one) *\param pool memory pool (NULL to create one)
*\return SWITCH_STATUS_SUCCESS if all is well *\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_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_input_args_t *args);
SWITCH_DECLARE(void) switch_ivr_delay_echo(switch_core_session_t *session, uint32_t delay_ms); 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(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_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(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_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, SWITCH_DECLARE(switch_status_t) switch_ivr_read(switch_core_session_t *session,
uint32_t min_digits, uint32_t min_digits,
uint32_t max_digits, uint32_t max_digits,
const char *prompt_audio_file, const char *prompt_audio_file,
const char *var_name, const char *var_name,
char *digit_buffer, char *digit_buffer,
switch_size_t digit_buffer_length, switch_size_t digit_buffer_length, uint32_t timeout, const char *valid_terminators);
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_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_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_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_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_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_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_type_t) switch_ivr_get_say_type_by_name(const char *name);
/** @} */ /** @} */
SWITCH_END_EXTERN_C SWITCH_END_EXTERN_C
#endif #endif
/* For Emacs: /* For Emacs:
* Local Variables: * Local Variables:

View File

@ -128,8 +128,7 @@ SWITCH_DECLARE(switch_dialplan_interface_t *) switch_loadable_module_get_dialpla
SWITCH_DECLARE(switch_status_t) switch_loadable_module_build_dynamic(char *filename, SWITCH_DECLARE(switch_status_t) switch_loadable_module_build_dynamic(char *filename,
switch_module_load_t switch_module_load, switch_module_load_t switch_module_load,
switch_module_runtime_t switch_module_runtime, switch_module_runtime_t switch_module_runtime,
switch_module_shutdown_t switch_module_shutdown, switch_module_shutdown_t switch_module_shutdown, switch_bool_t runtime);
switch_bool_t runtime);
/*! /*!
@ -259,7 +258,7 @@ SWITCH_DECLARE(switch_status_t) switch_loadable_module_unload_module(char *dir,
\param filename the path to the module's dll or so file \param filename the path to the module's dll or so file
\return SWITCH_STATUS_SUCCESS on a successful load \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); SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void);
/*! /*!
@ -317,8 +316,7 @@ SWITCH_DECLARE(uint32_t) switch_core_codec_next_id(void);
} }
static inline void switch_core_codec_add_implementation(switch_memory_pool_t *pool, static inline void switch_core_codec_add_implementation(switch_memory_pool_t *pool, switch_codec_interface_t *codec_interface,
switch_codec_interface_t *codec_interface,
/*! enumeration defining the type of the codec */ /*! enumeration defining the type of the codec */
const switch_codec_type_t codec_type, const switch_codec_type_t codec_type,
/*! the IANA code number */ /*! the IANA code number */
@ -329,7 +327,7 @@ static inline void switch_core_codec_add_implementation(switch_memory_pool_t *po
char *fmtp, char *fmtp,
/*! samples transferred per second */ /*! samples transferred per second */
uint32_t samples_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, uint32_t actual_samples_per_second,
/*! bits transferred per second */ /*! bits transferred per second */
int bits_per_second, int bits_per_second,

View File

@ -111,7 +111,7 @@ SWITCH_DECLARE(switch_status_t) switch_log_bind_logger(_In_ switch_log_function_
\param level the level \param level the level
\return the name of the log 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 \brief Return the level number of the specified log level name

View File

@ -45,8 +45,7 @@
SWITCH_BEGIN_EXTERN_C SWITCH_BEGIN_EXTERN_C
/*! \brief A table of functions to execute at various states /*! \brief A table of functions to execute at various states
*/ */
typedef enum {
typedef enum {
SWITCH_SHN_ON_INIT, SWITCH_SHN_ON_INIT,
SWITCH_SHN_ON_ROUTING, SWITCH_SHN_ON_ROUTING,
SWITCH_SHN_ON_EXECUTE, SWITCH_SHN_ON_EXECUTE,
@ -100,7 +99,31 @@ struct switch_io_event_hooks;
typedef switch_call_cause_t (*switch_io_outgoing_channel_t) 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_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_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); typedef switch_status_t (*switch_io_kill_channel_t) (switch_core_session_t *, int);
@ -110,7 +133,7 @@ typedef switch_status_t (*switch_io_receive_event_t) (switch_core_session_t *, s
typedef switch_status_t (*switch_io_state_change_t) (switch_core_session_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_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 { typedef enum {
SWITCH_IO_OUTGOING_CHANNEL, SWITCH_IO_OUTGOING_CHANNEL,
@ -192,7 +215,7 @@ struct switch_timer {
switch_memory_pool_t *memory_pool; switch_memory_pool_t *memory_pool;
/*! private data for loadable modules to store information */ /*! private data for loadable modules to store information */
void *private_info; void *private_info;
/*! remaining time from last call to _check()*/ /*! remaining time from last call to _check() */
switch_size_t diff; switch_size_t diff;
switch_size_t tick; switch_size_t tick;
}; };
@ -346,7 +369,7 @@ struct switch_asr_handle {
/*! The Rate */ /*! The Rate */
uint32_t rate; uint32_t rate;
char *grammar; char *grammar;
/*! module specific param*/ /*! module specific param */
char *param; char *param;
/*! the handle's memory pool */ /*! the handle's memory pool */
switch_memory_pool_t *memory_pool; switch_memory_pool_t *memory_pool;
@ -365,7 +388,7 @@ struct switch_speech_interface {
/*! function to feed audio to the ASR */ /*! 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); 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 */ /*! 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_flush_tts) (switch_speech_handle_t *sh);
void (*speech_text_param_tts) (switch_speech_handle_t *sh, char *param, const char *val); 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); void (*speech_numeric_param_tts) (switch_speech_handle_t *sh, char *param, int val);
@ -389,7 +412,7 @@ struct switch_speech_handle {
uint32_t samples; uint32_t samples;
char voice[80]; char voice[80];
char *engine; char *engine;
/*! module specific param*/ /*! module specific param */
char *param; char *param;
/*! the handle's memory pool */ /*! the handle's memory pool */
switch_memory_pool_t *memory_pool; switch_memory_pool_t *memory_pool;
@ -526,7 +549,7 @@ struct switch_codec_implementation {
char *fmtp; char *fmtp;
/*! samples transferred per second */ /*! samples transferred per second */
uint32_t samples_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; uint32_t actual_samples_per_second;
/*! bits transferred per second */ /*! bits transferred per second */
int bits_per_second; int bits_per_second;

View File

@ -44,9 +44,7 @@
#endif #endif
#include <sqltypes.h> #include <sqltypes.h>
SWITCH_BEGIN_EXTERN_C SWITCH_BEGIN_EXTERN_C struct switch_odbc_handle;
struct switch_odbc_handle;
typedef enum { typedef enum {
SWITCH_ODBC_STATE_INIT, SWITCH_ODBC_STATE_INIT,
@ -70,7 +68,6 @@ SWITCH_DECLARE(switch_odbc_status_t) switch_odbc_handle_callback_exec(switch_odb
char *sql, switch_core_db_callback_func_t callback, void *pdata); 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_DECLARE(char *) switch_odbc_handle_get_error(switch_odbc_handle_t *handle, SQLHSTMT stmt);
SWITCH_END_EXTERN_C SWITCH_END_EXTERN_C
#endif #endif
/* For Emacs: /* For Emacs:
* Local Variables: * Local Variables:

View File

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

View File

@ -45,9 +45,7 @@ SWITCH_BEGIN_EXTERN_C
#define SWITCH_RTP_KEY_LEN 30 #define SWITCH_RTP_KEY_LEN 30
#define SWITCH_RTP_CRYPTO_KEY_32 "AES_CM_128_HMAC_SHA1_32" #define SWITCH_RTP_CRYPTO_KEY_32 "AES_CM_128_HMAC_SHA1_32"
#define SWITCH_RTP_CRYPTO_KEY_80 "AES_CM_128_HMAC_SHA1_80" #define SWITCH_RTP_CRYPTO_KEY_80 "AES_CM_128_HMAC_SHA1_80"
typedef enum {
typedef enum {
SWITCH_RTP_CRYPTO_SEND, SWITCH_RTP_CRYPTO_SEND,
SWITCH_RTP_CRYPTO_RECV, SWITCH_RTP_CRYPTO_RECV,
SWITCH_RTP_CRYPTO_MAX SWITCH_RTP_CRYPTO_MAX
@ -72,16 +70,13 @@ typedef struct switch_rtp_crypto_key switch_rtp_crypto_key_t;
SWITCH_DECLARE(switch_status_t) switch_rtp_add_crypto_key(switch_rtp_t *rtp_session, SWITCH_DECLARE(switch_status_t) switch_rtp_add_crypto_key(switch_rtp_t *rtp_session,
switch_rtp_crypto_direction_t direction, switch_rtp_crypto_direction_t direction,
uint32_t index, uint32_t index, switch_rtp_crypto_key_type_t type, unsigned char *key, switch_size_t keylen);
switch_rtp_crypto_key_type_t type,
unsigned char *key,
switch_size_t keylen);
///\defgroup rtp RTP (RealTime Transport Protocol) ///\defgroup rtp RTP (RealTime Transport Protocol)
///\ingroup core1 ///\ingroup core1
///\{ ///\{
typedef void (*switch_rtp_invalid_handler_t) (switch_rtp_t *rtp_session, 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_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); SWITCH_DECLARE(void) switch_rtp_get_random(void *buf, uint32_t len);
@ -130,10 +125,7 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_create(switch_rtp_t **new_rtp_session
switch_payload_t payload, switch_payload_t payload,
uint32_t samples_per_interval, uint32_t samples_per_interval,
uint32_t ms_per_packet, uint32_t ms_per_packet,
switch_rtp_flag_t flags, switch_rtp_flag_t flags, char *timer_name, const char **err, switch_memory_pool_t *pool);
char *timer_name,
const char **err,
switch_memory_pool_t *pool);
/*! /*!
@ -158,10 +150,7 @@ SWITCH_DECLARE(switch_rtp_t *) switch_rtp_new(const char *rx_host,
switch_payload_t payload, switch_payload_t payload,
uint32_t samples_per_interval, uint32_t samples_per_interval,
uint32_t ms_per_packet, uint32_t ms_per_packet,
switch_rtp_flag_t flags, switch_rtp_flag_t flags, char *timer_name, const char **err, switch_memory_pool_t *pool);
char *timer_name,
const char **err,
switch_memory_pool_t *pool);
/*! /*!
@ -296,7 +285,7 @@ SWITCH_DECLARE(void) switch_rtp_set_invald_handler(switch_rtp_t *rtp_session, sw
\param io_flags i/o flags \param io_flags i/o flags
\return the number of bytes read \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); switch_payload_t *payload_type, switch_frame_flag_t *flags, switch_io_flag_t io_flags);
/*! /*!
@ -341,7 +330,8 @@ SWITCH_DECLARE(switch_size_t) switch_rtp_dequeue_dtmf(switch_rtp_t *rtp_session,
\return the number of bytes read \return the number of bytes read
*/ */
SWITCH_DECLARE(switch_status_t) switch_rtp_zerocopy_read(switch_rtp_t *rtp_session, SWITCH_DECLARE(switch_status_t) switch_rtp_zerocopy_read(switch_rtp_t *rtp_session,
void **data, uint32_t * datalen, switch_payload_t *payload_type, switch_frame_flag_t *flags, 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 \brief Read data from a given RTP session without copying
@ -390,9 +380,7 @@ SWITCH_DECLARE(int) switch_rtp_write_frame(switch_rtp_t *rtp_session, switch_fra
\return the number of bytes written \return the number of bytes written
*/ */
SWITCH_DECLARE(int) switch_rtp_write_manual(switch_rtp_t *rtp_session, SWITCH_DECLARE(int) switch_rtp_write_manual(switch_rtp_t *rtp_session,
void *data, void *data, uint32_t datalen, uint8_t m, switch_payload_t payload, uint32_t ts, switch_frame_flag_t *flags);
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 \brief Retrieve the SSRC from a given RTP session

View File

@ -137,7 +137,7 @@ SWITCH_DECLARE(void) switch_stun_random_string(char *buf, uint16_t len, char *se
\param len the length of the data \param len the length of the data
\return a stun packet pointer to buf to use as an access point \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 \brief Obtain a printable string form of a given value
@ -155,7 +155,7 @@ SWITCH_DECLARE(const char *) switch_stun_value_to_name(int32_t type, uint32_t va
\param port the port \param port the port
\return true or false \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 \brief Extract a username from a packet attribute
@ -174,7 +174,7 @@ SWITCH_DECLARE(char *) switch_stun_packet_attribute_get_username(switch_stun_pac
\param buf a pointer to data to use for the packet \param buf a pointer to data to use for the packet
\return a pointer to a ready-to-use stun 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 \brief Add a username packet attribute

View File

@ -91,11 +91,9 @@ SWITCH_BEGIN_EXTERN_C
#define SWITCH_SEQ_CLEARLINE SWITCH_SEQ_ESC SWITCH_SEQ_CLEARLINE_CHAR_STR #define SWITCH_SEQ_CLEARLINE SWITCH_SEQ_ESC SWITCH_SEQ_CLEARLINE_CHAR_STR
#define SWITCH_SEQ_CLEARLINEEND SWITCH_SEQ_ESC SWITCH_SEQ_CLEARLINEEND_CHAR #define SWITCH_SEQ_CLEARLINEEND SWITCH_SEQ_ESC SWITCH_SEQ_CLEARLINEEND_CHAR
#define SWITCH_SEQ_CLEARSCR SWITCH_SEQ_ESC SWITCH_SEQ_CLEARSCR_CHAR SWITCH_SEQ_HOME #define SWITCH_SEQ_CLEARSCR SWITCH_SEQ_ESC SWITCH_SEQ_CLEARSCR_CHAR SWITCH_SEQ_HOME
#define SWITCH_DEFAULT_DTMF_DURATION 2000 #define SWITCH_DEFAULT_DTMF_DURATION 2000
#define SWITCH_MAX_DTMF_DURATION 192000 #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 #define SWITCH_DEFAULT_DIR_PERMS SWITCH_FPROT_UREAD | SWITCH_FPROT_UWRITE | SWITCH_FPROT_UEXECUTE | SWITCH_FPROT_GREAD | SWITCH_FPROT_GEXECUTE
#ifdef WIN32 #ifdef WIN32
#define SWITCH_PATH_SEPARATOR "\\" #define SWITCH_PATH_SEPARATOR "\\"
#else #else
@ -144,7 +142,7 @@ SWITCH_BEGIN_EXTERN_C
#define SWITCH_SPEECH_KEY "speech" #define SWITCH_SPEECH_KEY "speech"
#define SWITCH_UUID_BRIDGE "uuid_bridge" #define SWITCH_UUID_BRIDGE "uuid_bridge"
#define SWITCH_BITS_PER_BYTE 8 #define SWITCH_BITS_PER_BYTE 8
typedef uint8_t switch_byte_t; typedef uint8_t switch_byte_t;
typedef struct { typedef struct {
char digit; char digit;
@ -185,7 +183,7 @@ typedef enum {
typedef enum { typedef enum {
SCF_NONE = 0, SCF_NONE = 0,
SCF_USE_SQL = ( 1 << 0), SCF_USE_SQL = (1 << 0),
SCF_NO_NEW_SESSIONS = (1 << 1), SCF_NO_NEW_SESSIONS = (1 << 1),
SCF_SHUTTING_DOWN = (1 << 2), SCF_SHUTTING_DOWN = (1 << 2),
SCF_CRASH_PROT = (1 << 3) SCF_CRASH_PROT = (1 << 3)
@ -1214,10 +1212,7 @@ typedef switch_status_t (*switch_core_codec_encode_func_t) (switch_codec_t *code
void *decoded_data, void *decoded_data,
uint32_t decoded_data_len, uint32_t decoded_data_len,
uint32_t decoded_rate, uint32_t decoded_rate,
void *encoded_data, void *encoded_data, uint32_t *encoded_data_len, uint32_t *encoded_rate, unsigned int *flag);
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, typedef switch_status_t (*switch_core_codec_decode_func_t) (switch_codec_t *codec,
@ -1225,10 +1220,7 @@ typedef switch_status_t (*switch_core_codec_decode_func_t) (switch_codec_t *code
void *encoded_data, void *encoded_data,
uint32_t encoded_data_len, uint32_t encoded_data_len,
uint32_t encoded_rate, uint32_t encoded_rate,
void *decoded_data, void *decoded_data, uint32_t *decoded_data_len, uint32_t *decoded_rate, unsigned int *flag);
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_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 *); typedef switch_status_t (*switch_core_codec_destroy_func_t) (switch_codec_t *);
@ -1255,7 +1247,8 @@ typedef struct switch_stream_handle switch_stream_handle_t;
typedef switch_status_t (*switch_stream_handle_write_function_t) (switch_stream_handle_t *handle, const char *fmt, ...); typedef switch_status_t (*switch_stream_handle_write_function_t) (switch_stream_handle_t *handle, const char *fmt, ...);
typedef switch_status_t (*switch_stream_handle_raw_write_function_t) (switch_stream_handle_t *handle, uint8_t *data, switch_size_t datalen); 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) #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,7 +1267,7 @@ typedef switch_status_t (*switch_say_callback_t) (switch_core_session_t *session
char *tosay, switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args); 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_xml *switch_xml_t;
typedef struct switch_core_time_duration switch_core_time_duration_t; typedef struct switch_core_time_duration switch_core_time_duration_t;
typedef switch_xml_t(*switch_xml_search_function_t) (const char *section, typedef switch_xml_t (*switch_xml_search_function_t) (const char *section,
const char *tag_name, const char *key_name, const char *key_value, switch_event_t *params, const char *tag_name, const char *key_name, const char *key_value, switch_event_t *params,
void *user_data); void *user_data);
@ -1290,9 +1283,9 @@ typedef struct switch_network_list switch_network_list_t;
#define SWITCH_MODULE_LOAD_ARGS (switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool) #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_RUNTIME_ARGS (void)
#define SWITCH_MODULE_SHUTDOWN_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_load_t) SWITCH_MODULE_LOAD_ARGS;
typedef switch_status_t (*switch_module_runtime_t) SWITCH_MODULE_RUNTIME_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_shutdown_t) SWITCH_MODULE_SHUTDOWN_ARGS;
#define SWITCH_MODULE_LOAD_FUNCTION(name) switch_status_t name SWITCH_MODULE_LOAD_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_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 #define SWITCH_MODULE_SHUTDOWN_FUNCTION(name) switch_status_t name SWITCH_MODULE_SHUTDOWN_ARGS

View File

@ -54,15 +54,12 @@ SWITCH_BEGIN_EXTERN_C
#else #else
#define switch_is_file_path(file) (file && ((*file == '/') || strstr(file, SWITCH_URL_SEPARATOR))) #define switch_is_file_path(file) (file && ((*file == '/') || strstr(file, SWITCH_URL_SEPARATOR)))
#endif #endif
/*! /*!
\brief Test for NULL or zero length string \brief Test for NULL or zero length string
\param s the string to test \param s the string to test
\return true value if the string is NULL or zero length \return true value if the string is NULL or zero length
*/ */
#define switch_strlen_zero(s) (!s || *s == '\0') #define switch_strlen_zero(s) (!s || *s == '\0')
static inline switch_bool_t switch_is_moh(const char *s) static inline switch_bool_t switch_is_moh(const char *s)
{ {
if (switch_strlen_zero(s) || !strcasecmp(s, "silence") || !strcasecmp(s, "indicate_hold")) { if (switch_strlen_zero(s) || !strcasecmp(s, "silence") || !strcasecmp(s, "indicate_hold")) {
@ -78,9 +75,10 @@ SWITCH_DECLARE(switch_status_t) switch_b64_encode(unsigned char *in, switch_size
SWITCH_DECLARE(switch_size_t) switch_b64_decode(char *in, char *out, switch_size_t olen); 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); 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) { if (*s < 48 || *s > 57) {
return SWITCH_FALSE; return SWITCH_FALSE;
} }
@ -113,7 +111,8 @@ atoi(expr))) ? SWITCH_TRUE : SWITCH_FALSE
\param family the address family to return (AF_INET or AF_INET6) \param family the address family to return (AF_INET or AF_INET6)
\return SWITCH_STATUS_SUCCESSS for success, otherwise failure \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 \brief find the char representation of an ip adress
@ -205,7 +204,7 @@ switch_mutex_unlock(obj->flag_mutex);
#define switch_set_string(_dst, _src) switch_copy_string(_dst, _src, sizeof(_dst)) #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; char *p;
for (p = s; p && *p; p++) { for (p = s; p && *p; p++) {
@ -251,7 +250,7 @@ static inline switch_bool_t switch_strstr(char *s, char *q)
assert(S != NULL); assert(S != NULL);
for (p = S; p && *p; p++) { for (p = S; p && *p; p++) {
*p = (char)toupper(*p); *p = (char) toupper(*p);
} }
if (strstr(S, q)) { if (strstr(S, q)) {
@ -263,7 +262,7 @@ static inline switch_bool_t switch_strstr(char *s, char *q)
assert(Q != NULL); assert(Q != NULL);
for (p = Q; p && *p; p++) { for (p = Q; p && *p; p++) {
*p = (char)toupper(*p); *p = (char) toupper(*p);
} }
if (strstr(s, Q)) { if (strstr(s, Q)) {
@ -345,7 +344,7 @@ SWITCH_DECLARE(char *) switch_escape_char(switch_memory_pool_t *pool, char *in,
\param ms the number of milliseconds to wait \param ms the number of milliseconds to wait
\return the requested condition \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 \brief Create a pointer to the file name in a given file path eliminating the directory name
@ -369,7 +368,7 @@ SWITCH_DECLARE(switch_status_t) switch_network_list_add_host_mask(switch_network
SWITCH_DECLARE(switch_bool_t) switch_network_list_validate_ip(switch_network_list_t *list, uint32_t ip); 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) #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 */ /* malloc or DIE macros */
#ifdef NDEBUG #ifdef NDEBUG

View File

@ -184,7 +184,7 @@ SWITCH_DECLARE(const char *) switch_xml_attr_soft(switch_xml_t xml, const char *
///\ Returns NULL if not found. ///\ Returns NULL if not found.
///\param xml the xml node ///\param xml the xml node
///\return an xml node or NULL ///\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 ///\brief Converts an switch_xml structure back to xml. Returns a string of xml data that
///\ must be freed. ///\ must be freed.
@ -234,7 +234,7 @@ SWITCH_DECLARE(switch_xml_t) switch_xml_new(const char *name);
///\param name the name of the tag ///\param name the name of the tag
///\param off the offset ///\param off the offset
///\return an xml node or NULL ///\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 ///\brief wrapper for switch_xml_add_child() that strdup()s name
///\param xml the xml node ///\param xml the xml node
@ -247,7 +247,7 @@ SWITCH_DECLARE(switch_xml_t) switch_xml_new(const char *name);
///\param xml the xml node ///\param xml the xml node
///\param txt the text ///\param txt the text
///\return an xml node or NULL ///\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 ///\brief wrapper for switch_xml_set_txt() that strdup()s txt
///\ sets the character content for the given tag and returns the tag ///\ sets the character content for the given tag and returns the tag
@ -324,7 +324,7 @@ SWITCH_DECLARE(switch_xml_t) switch_xml_root(void);
///\return SWITCH_STATUS_SUCCESS if successful root and node will be assigned ///\return SWITCH_STATUS_SUCCESS if successful root and node will be assigned
SWITCH_DECLARE(switch_status_t) switch_xml_locate(const char *section, SWITCH_DECLARE(switch_status_t) switch_xml_locate(const char *section,
const char *tag_name, 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_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_domain(const char *domain_name, switch_event_t *params, switch_xml_t *root, switch_xml_t *domain);
@ -332,17 +332,14 @@ SWITCH_DECLARE(switch_status_t) switch_xml_locate_user(const char *key,
const char *user_name, const char *user_name,
const char *domain_name, const char *domain_name,
const char *ip, const char *ip,
switch_xml_t *root, switch_xml_t *root, switch_xml_t *domain, switch_xml_t *user, switch_event_t *params);
switch_xml_t *domain,
switch_xml_t *user,
switch_event_t *params);
///\brief open a config in the core registry ///\brief open a config in the core registry
///\param file_path the name of the config section e.g. modules.conf ///\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 node a pointer to point to the node if it is found
///\param params optional URL formatted params to pass to external gateways ///\param params optional URL formatted params to pass to external gateways
///\return the root xml node associated with the current request or NULL ///\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 ///\brief bind a search function to an external gateway
///\param function the search function to bind ///\param function the search function to bind

View File

@ -80,29 +80,29 @@ SWITCH_DECLARE(unsigned int) switch_hashfunc_default(const char *key, switch_ssi
/* DSO functions */ /* 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); 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); 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); 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); return apr_dso_error(dso, buf, bufsize);
} }
/* string functions */ /* 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); return apr_strftime(s, retsize, max, format, (apr_time_exp_t *) tm);
} }
@ -124,7 +124,8 @@ SWITCH_DECLARE(int) switch_vsnprintf(char *buf, switch_size_t len, const char *f
SWITCH_DECLARE(char *) switch_copy_string(char *dst, const char *src, switch_size_t dst_size) 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) { if (!src) {
*dst = '\0'; *dst = '\0';
return dst; return dst;
@ -134,69 +135,69 @@ SWITCH_DECLARE(char *) switch_copy_string(char *dst, const char *src, switch_siz
/* thread read write lock functions */ /* 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); 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); 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); 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); 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); 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); 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); 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); return apr_thread_rwlock_unlock(rwlock);
} }
/* thread mutex functions */ /* 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); 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); 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); 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); 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); return apr_thread_mutex_trylock(lock);
} }
@ -207,29 +208,29 @@ SWITCH_DECLARE(switch_time_t) switch_time_now(void)
{ {
#if defined(HAVE_CLOCK_GETTIME) && defined(SWITCH_USE_CLOCK_FUNCS) #if defined(HAVE_CLOCK_GETTIME) && defined(SWITCH_USE_CLOCK_FUNCS)
struct timespec ts; struct timespec ts;
clock_gettime(CLOCK_REALTIME,&ts); clock_gettime(CLOCK_REALTIME, &ts);
return ts.tv_sec * APR_USEC_PER_SEC + (ts.tv_nsec/1000); return ts.tv_sec * APR_USEC_PER_SEC + (ts.tv_nsec / 1000);
#else #else
return (switch_time_t) apr_time_now(); return (switch_time_t) apr_time_now();
#endif #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); 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); 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); 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); return apr_time_exp_gmt((apr_time_exp_t *) result, input);
} }
@ -246,45 +247,45 @@ SWITCH_DECLARE(switch_time_t) switch_time_make(switch_time_t sec, int32_t usec)
/* Thread condition locks */ /* 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); 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); 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); 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); 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); 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); return apr_thread_cond_destroy(cond);
} }
/* file i/o stubs */ /* 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) switch_memory_pool_t *pool)
{ {
return apr_file_open(newf, fname, flag, perm, 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_status_t rv;
apr_off_t off = (apr_off_t) (*offset); apr_off_t off = (apr_off_t) (*offset);
@ -293,12 +294,12 @@ SWITCH_DECLARE(switch_status_t) switch_file_seek(switch_file_t * thefile, switch
return rv; 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); 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); return apr_file_lock(thefile, type);
} }
@ -313,12 +314,12 @@ SWITCH_DECLARE(switch_status_t) switch_file_remove(const char *path, switch_memo
return apr_file_remove(path, pool); 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); 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); return apr_file_write(thefile, buf, nbytes);
} }
@ -341,7 +342,7 @@ SWITCH_DECLARE(switch_status_t) switch_file_mktemp(switch_file_t **thefile, char
SWITCH_DECLARE(switch_size_t) switch_file_get_size(switch_file_t *thefile) SWITCH_DECLARE(switch_size_t) switch_file_get_size(switch_file_t *thefile)
{ {
struct apr_finfo_t finfo; 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) SWITCH_DECLARE(switch_status_t) switch_directory_exists(const char *dirname, switch_memory_pool_t *pool)
@ -391,15 +392,12 @@ SWITCH_DECLARE(switch_status_t) switch_file_exists(const char *filename, switch_
return status; return status;
} }
SWITCH_DECLARE(switch_status_t) switch_dir_make(const char *path, switch_fileperms_t perm, SWITCH_DECLARE(switch_status_t) switch_dir_make(const char *path, switch_fileperms_t perm, switch_memory_pool_t *pool)
switch_memory_pool_t *pool)
{ {
return apr_dir_make(path, perm, pool); return apr_dir_make(path, perm, pool);
} }
SWITCH_DECLARE(switch_status_t) switch_dir_make_recursive(const char *path, SWITCH_DECLARE(switch_status_t) switch_dir_make_recursive(const char *path, switch_fileperms_t perm, switch_memory_pool_t *pool)
switch_fileperms_t perm,
switch_memory_pool_t *pool)
{ {
return apr_dir_make_recursive(path, perm, pool); return apr_dir_make_recursive(path, perm, pool);
} }
@ -471,17 +469,17 @@ SWITCH_DECLARE(const char *) switch_dir_next_file(switch_dir_t *thedir, char *bu
/* thread stubs */ /* 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); 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); 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); return apr_threadattr_stacksize_set(attr, stacksize);
} }
@ -507,13 +505,12 @@ SWITCH_DECLARE(switch_status_t) switch_threadattr_priority_increase(switch_threa
if (stat == 0) { if (stat == 0) {
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
#endif #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) switch_thread_start_t func, void *data, switch_memory_pool_t *cont)
{ {
return apr_thread_create(new_thread, attr, func, data, cont); return apr_thread_create(new_thread, attr, func, data, cont);
@ -526,42 +523,42 @@ SWITCH_DECLARE(switch_status_t) switch_socket_addr_get(switch_sockaddr_t **sa, s
return apr_socket_addr_get(sa, remote, sock); 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); 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); 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); 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); 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); 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); 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_status_t status = SWITCH_STATUS_SUCCESS;
switch_size_t req = *len, wrote = 0, need = *len; switch_size_t req = *len, wrote = 0, need = *len;
@ -585,7 +582,7 @@ SWITCH_DECLARE(switch_status_t) switch_socket_send(switch_socket_t * sock, const
return status; 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) { if (!where || !buf || !len || !*len) {
return SWITCH_STATUS_GENERR; return SWITCH_STATUS_GENERR;
@ -593,33 +590,33 @@ SWITCH_DECLARE(switch_status_t) switch_socket_sendto(switch_socket_t * sock, swi
return apr_socket_sendto(sock, where, flags, buf, len); 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); 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) switch_port_t port, int32_t flags, switch_memory_pool_t *pool)
{ {
return apr_sockaddr_info_get(sa, hostname, family, port, flags, 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); 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); 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); 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); return apr_mcast_join(sock, join, iface, source);
} }
@ -627,7 +624,7 @@ SWITCH_DECLARE(switch_status_t) switch_mcast_join(switch_socket_t * sock, switch
/* socket functions */ /* 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) { if (!in) {
return ""; return "";
@ -635,17 +632,17 @@ SWITCH_DECLARE(const char *) switch_get_addr(char *buf, switch_size_t len, switc
return get_addr(buf, len, &in->sa.sin.sin_addr); 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; 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; 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; apr_status_t r;
@ -656,7 +653,7 @@ SWITCH_DECLARE(switch_status_t) switch_socket_recvfrom(switch_sockaddr_t * from,
*/ */
} }
if (r == 35 ) { if (r == 35) {
r = SWITCH_STATUS_BREAK; r = SWITCH_STATUS_BREAK;
} }
@ -665,22 +662,22 @@ SWITCH_DECLARE(switch_status_t) switch_socket_recvfrom(switch_sockaddr_t * from,
/* poll stubs */ /* 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); 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); 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); 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; switch_pollset_t *pollset;
@ -713,39 +710,39 @@ SWITCH_DECLARE(switch_status_t) switch_socket_create_pollfd(switch_pollfd_t ** p
/* UUID Handling (apr-util) */ /* 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); 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); 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); return apr_uuid_parse((apr_uuid_t *) uuid, uuid_str);
} }
/* FIFO queues (apr-util) */ /* 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); 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); 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); 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; apr_status_t s;
@ -756,12 +753,12 @@ SWITCH_DECLARE(switch_status_t) switch_queue_push(switch_queue_t * queue, void *
return s; 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); 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; apr_status_t s;
@ -810,7 +807,7 @@ SWITCH_DECLARE(int) switch_vasprintf(char **ret, const char *fmt, va_list ap)
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_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: /* For Emacs:

View File

@ -45,9 +45,7 @@ SWITCH_DECLARE(switch_caller_profile_t *) switch_caller_profile_new(switch_memor
const char *ani, const char *ani,
const char *aniii, const char *aniii,
const char *rdnis, const char *rdnis,
const char *source, const char *source, const char *context, const char *destination_number)
const char *context,
const char *destination_number)
{ {
switch_caller_profile_t *profile = NULL; switch_caller_profile_t *profile = NULL;
@ -276,7 +274,8 @@ SWITCH_DECLARE(void) switch_caller_profile_event_set_data(switch_caller_profile_
switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, switch_test_flag(caller_profile, SWITCH_CPF_HIDE_NUMBER) ? "yes" : "no"); 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; switch_caller_extension_t *caller_extension = NULL;
@ -290,7 +289,8 @@ SWITCH_DECLARE(switch_caller_extension_t *) switch_caller_extension_new(switch_c
} }
SWITCH_DECLARE(void) switch_caller_extension_add_application(switch_core_session_t *session, SWITCH_DECLARE(void) switch_caller_extension_add_application(switch_core_session_t *session,
switch_caller_extension_t *caller_extension, 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; switch_caller_application_t *caller_application = NULL;

View File

@ -130,7 +130,7 @@ SWITCH_DECLARE(const char *) switch_channel_cause2str(switch_call_cause_t cause)
uint8_t x; uint8_t x;
const char *str = "UNKNOWN"; 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) { if (CAUSE_CHART[x].cause == cause) {
str = CAUSE_CHART[x].name; str = CAUSE_CHART[x].name;
break; break;
@ -251,7 +251,7 @@ SWITCH_DECLARE(switch_status_t) switch_channel_queue_dtmf(switch_channel_t *chan
status = SWITCH_STATUS_SUCCESS; status = SWITCH_STATUS_SUCCESS;
done: done:
switch_mutex_unlock(channel->dtmf_mutex); switch_mutex_unlock(channel->dtmf_mutex);
@ -261,7 +261,7 @@ done:
SWITCH_DECLARE(switch_status_t) switch_channel_queue_dtmf_string(switch_channel_t *channel, const char *dtmf_string) SWITCH_DECLARE(switch_status_t) switch_channel_queue_dtmf_string(switch_channel_t *channel, const char *dtmf_string)
{ {
char *p; 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; int sent = 0, dur;
char *string; char *string;
int i, argc; int i, argc;
@ -274,7 +274,7 @@ SWITCH_DECLARE(switch_status_t) switch_channel_queue_dtmf_string(switch_channel_
string = switch_core_session_strdup(channel->session, dtmf_string); string = switch_core_session_strdup(channel->session, dtmf_string);
argc = switch_separate_string(string, '+', argv, (sizeof(argv) / sizeof(argv[0]))); 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); dtmf.duration = switch_core_default_dtmf_duration(0);
dur = switch_core_default_dtmf_duration(0) / 8; dur = switch_core_default_dtmf_duration(0) / 8;
if ((p = strchr(argv[i], '@'))) { if ((p = strchr(argv[i], '@'))) {
@ -347,11 +347,11 @@ SWITCH_DECLARE(switch_status_t) switch_channel_dequeue_dtmf(switch_channel_t *ch
SWITCH_DECLARE(switch_size_t) switch_channel_dequeue_dtmf_string(switch_channel_t *channel, char *dtmf_str, switch_size_t len) 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_size_t x = 0;
switch_dtmf_t dtmf = {0}; switch_dtmf_t dtmf = { 0 };
memset(dtmf_str, 0, len); 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; dtmf_str[x++] = dtmf.digit;
} }
@ -363,7 +363,7 @@ SWITCH_DECLARE(void) switch_channel_flush_dtmf(switch_channel_t *channel)
{ {
void *pop; void *pop;
switch_mutex_lock(channel->dtmf_mutex); 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_safe_free(pop);
} }
switch_mutex_unlock(channel->dtmf_mutex); switch_mutex_unlock(channel->dtmf_mutex);
@ -426,7 +426,7 @@ SWITCH_DECLARE(const char *) switch_channel_get_variable(switch_channel_t *chann
switch_assert(channel != NULL); switch_assert(channel != NULL);
switch_mutex_lock(channel->profile_mutex); 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; switch_caller_profile_t *cp = channel->caller_profile;
if (cp) { if (cp) {
@ -634,7 +634,7 @@ SWITCH_DECLARE(void) switch_channel_wait_for_state(switch_channel_t *channel, sw
switch_channel_state_t state, mystate, ostate; switch_channel_state_t state, mystate, ostate;
ostate = switch_channel_get_state(channel); ostate = switch_channel_get_state(channel);
for(;;) { for (;;) {
state = switch_channel_get_running_state(other_channel); state = switch_channel_get_running_state(other_channel);
mystate = switch_channel_get_running_state(channel); mystate = switch_channel_get_running_state(channel);
@ -652,7 +652,7 @@ SWITCH_DECLARE(switch_status_t) switch_channel_wait_for_flag(switch_channel_t *c
to++; to++;
} }
for(;;) { for (;;) {
if (pres) { if (pres) {
if (switch_test_flag(channel, want_flag)) { if (switch_test_flag(channel, want_flag)) {
break; break;
@ -769,8 +769,7 @@ SWITCH_DECLARE(switch_channel_state_t) switch_channel_perform_set_running_state(
const char *file, const char *func, int line) const char *file, const char *func, int line)
{ {
switch_mutex_lock(channel->flag_mutex); 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", 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->name, state_names[state]);
channel->running_state = state; channel->running_state = state;
if (channel->state_flags) { if (channel->state_flags) {
@ -797,7 +796,8 @@ SWITCH_DECLARE(switch_channel_state_t) switch_channel_perform_set_running_state(
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Channel-State-Number", "%s", (char *) state_num); 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, "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, "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)) { if (switch_channel_test_flag(channel, CF_ANSWERED)) {
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Answer-State", "answered"); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Answer-State", "answered");
} else if (switch_channel_test_flag(channel, CF_EARLY_MEDIA)) { } else if (switch_channel_test_flag(channel, CF_EARLY_MEDIA)) {
@ -856,146 +856,146 @@ SWITCH_DECLARE(switch_channel_state_t) switch_channel_perform_set_state(switch_c
*/ */
switch (last_state) { switch (last_state) {
case CS_NEW: case CS_NEW:
case CS_RESET: case CS_RESET:
switch (state) { switch (state) {
default: default:
ok++; ok++;
break; break;
} }
break; break;
case CS_INIT: case CS_INIT:
switch (state) { switch (state) {
case CS_EXCHANGE_MEDIA: case CS_EXCHANGE_MEDIA:
case CS_SOFT_EXECUTE: case CS_SOFT_EXECUTE:
case CS_ROUTING: case CS_ROUTING:
case CS_EXECUTE: case CS_EXECUTE:
case CS_PARK: case CS_PARK:
case CS_CONSUME_MEDIA: case CS_CONSUME_MEDIA:
case CS_HIBERNATE: case CS_HIBERNATE:
case CS_RESET: case CS_RESET:
ok++; ok++;
default: default:
break; break;
} }
break; break;
case CS_EXCHANGE_MEDIA: case CS_EXCHANGE_MEDIA:
switch (state) { switch (state) {
case CS_SOFT_EXECUTE: case CS_SOFT_EXECUTE:
case CS_ROUTING: case CS_ROUTING:
case CS_EXECUTE: case CS_EXECUTE:
case CS_PARK: case CS_PARK:
case CS_CONSUME_MEDIA: case CS_CONSUME_MEDIA:
case CS_HIBERNATE: case CS_HIBERNATE:
case CS_RESET: case CS_RESET:
ok++; ok++;
default: default:
break; break;
} }
break; break;
case CS_SOFT_EXECUTE: case CS_SOFT_EXECUTE:
switch (state) { switch (state) {
case CS_EXCHANGE_MEDIA: case CS_EXCHANGE_MEDIA:
case CS_ROUTING: case CS_ROUTING:
case CS_EXECUTE: case CS_EXECUTE:
case CS_PARK: case CS_PARK:
case CS_CONSUME_MEDIA: case CS_CONSUME_MEDIA:
case CS_HIBERNATE: case CS_HIBERNATE:
case CS_RESET: case CS_RESET:
ok++; ok++;
default: default:
break; break;
} }
break; break;
case CS_PARK: case CS_PARK:
switch (state) { switch (state) {
case CS_EXCHANGE_MEDIA: case CS_EXCHANGE_MEDIA:
case CS_ROUTING: case CS_ROUTING:
case CS_EXECUTE: case CS_EXECUTE:
case CS_SOFT_EXECUTE: case CS_SOFT_EXECUTE:
case CS_HIBERNATE: case CS_HIBERNATE:
case CS_RESET: case CS_RESET:
case CS_CONSUME_MEDIA: case CS_CONSUME_MEDIA:
ok++; ok++;
default: default:
break; break;
} }
break; break;
case CS_CONSUME_MEDIA: case CS_CONSUME_MEDIA:
switch (state) { switch (state) {
case CS_EXCHANGE_MEDIA: case CS_EXCHANGE_MEDIA:
case CS_ROUTING: case CS_ROUTING:
case CS_EXECUTE: case CS_EXECUTE:
case CS_SOFT_EXECUTE: case CS_SOFT_EXECUTE:
case CS_HIBERNATE: case CS_HIBERNATE:
case CS_RESET: case CS_RESET:
case CS_PARK: case CS_PARK:
ok++; ok++;
default: default:
break; break;
} }
break; break;
case CS_HIBERNATE: case CS_HIBERNATE:
switch (state) { switch (state) {
case CS_EXCHANGE_MEDIA: case CS_EXCHANGE_MEDIA:
case CS_INIT: case CS_INIT:
case CS_ROUTING: case CS_ROUTING:
case CS_EXECUTE: case CS_EXECUTE:
case CS_SOFT_EXECUTE: case CS_SOFT_EXECUTE:
case CS_PARK: case CS_PARK:
case CS_CONSUME_MEDIA: case CS_CONSUME_MEDIA:
case CS_RESET: case CS_RESET:
ok++; ok++;
default: default:
break; break;
} }
break; break;
case CS_ROUTING: case CS_ROUTING:
switch (state) { switch (state) {
case CS_EXCHANGE_MEDIA: case CS_EXCHANGE_MEDIA:
case CS_EXECUTE: case CS_EXECUTE:
case CS_SOFT_EXECUTE: case CS_SOFT_EXECUTE:
case CS_PARK: case CS_PARK:
case CS_CONSUME_MEDIA: case CS_CONSUME_MEDIA:
case CS_HIBERNATE: case CS_HIBERNATE:
case CS_RESET: case CS_RESET:
ok++; ok++;
default: default:
break; break;
} }
break; break;
case CS_EXECUTE: case CS_EXECUTE:
switch (state) { switch (state) {
case CS_EXCHANGE_MEDIA: case CS_EXCHANGE_MEDIA:
case CS_SOFT_EXECUTE: case CS_SOFT_EXECUTE:
case CS_ROUTING: case CS_ROUTING:
case CS_PARK: case CS_PARK:
case CS_CONSUME_MEDIA: case CS_CONSUME_MEDIA:
case CS_HIBERNATE: case CS_HIBERNATE:
case CS_RESET: case CS_RESET:
ok++; ok++;
default: default:
break; break;
} }
break; break;
case CS_HANGUP: case CS_HANGUP:
switch (state) { switch (state) {
case CS_DONE: case CS_DONE:
ok++; ok++;
default: default:
break; break;
} }
break; break;
default: default:
break; break;
} }
@ -1021,7 +1021,7 @@ default:
/* not cool lets crash this bad boy and figure out wtf is going on */ /* not cool lets crash this bad boy and figure out wtf is going on */
switch_assert(channel->state >= CS_HANGUP); switch_assert(channel->state >= CS_HANGUP);
} }
done: done:
switch_mutex_unlock(channel->flag_mutex); switch_mutex_unlock(channel->flag_mutex);
return channel->state; return channel->state;
@ -1249,7 +1249,7 @@ SWITCH_DECLARE(int) switch_channel_add_state_handler(switch_channel_t *channel,
channel->state_handlers[index] = state_handler; channel->state_handlers[index] = state_handler;
end: end:
switch_mutex_unlock(channel->flag_mutex); switch_mutex_unlock(channel->flag_mutex);
return index; return index;
} }
@ -1588,16 +1588,16 @@ SWITCH_DECLARE(char *) switch_channel_expand_variables(switch_channel_t *channel
int nv = 0; int nv = 0;
if (switch_strlen_zero(in)) { if (switch_strlen_zero(in)) {
return (char *)in; return (char *) in;
} }
q = in; q = in;
while(q && *q) { while (q && *q) {
if (!(p = strchr(q, '$'))) { if (!(p = strchr(q, '$'))) {
break; break;
} }
if (*(p+1) != '{') { if (*(p + 1) != '{') {
q = p + 1; q = p + 1;
continue; continue;
} }
@ -1607,7 +1607,7 @@ SWITCH_DECLARE(char *) switch_channel_expand_variables(switch_channel_t *channel
} }
if (!nv) { if (!nv) {
return (char *)in; return (char *) in;
} }
@ -1633,8 +1633,8 @@ SWITCH_DECLARE(char *) switch_channel_expand_variables(switch_channel_t *channel
} }
if (*p == '$' && !nv) { if (*p == '$' && !nv) {
if (*(p+1)) { if (*(p + 1)) {
if (*(p+1) == '{') { if (*(p + 1) == '{') {
vtype = 1; vtype = 1;
} else { } else {
nv = 1; nv = 1;
@ -1686,12 +1686,12 @@ SWITCH_DECLARE(char *) switch_channel_expand_variables(switch_channel_t *channel
if ((vval = strchr(vname, '('))) { if ((vval = strchr(vname, '('))) {
e = vval - 1; e = vval - 1;
*vval++ = '\0'; *vval++ = '\0';
while(*e == ' ') { while (*e == ' ') {
*e-- = '\0'; *e-- = '\0';
} }
e = vval; e = vval;
br = 1; br = 1;
while(e && *e) { while (e && *e) {
if (*e == '(') { if (*e == '(') {
br++; br++;
} else if (br > 1 && *e == ')') { } else if (br > 1 && *e == ')') {
@ -1712,7 +1712,7 @@ SWITCH_DECLARE(char *) switch_channel_expand_variables(switch_channel_t *channel
int ooffset = 0; int ooffset = 0;
char *ptr; char *ptr;
if ((expanded = switch_channel_expand_variables(channel, (char *)vname)) == vname) { if ((expanded = switch_channel_expand_variables(channel, (char *) vname)) == vname) {
expanded = NULL; expanded = NULL;
} else { } else {
vname = expanded; vname = expanded;
@ -1735,12 +1735,12 @@ SWITCH_DECLARE(char *) switch_channel_expand_variables(switch_channel_t *channel
if (offset >= 0) { if (offset >= 0) {
sub_val += offset; 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); sub_val = cloned_sub_val + (strlen(cloned_sub_val) + offset);
} }
if (ooffset > 0 && (size_t)ooffset < strlen(sub_val)) { if (ooffset > 0 && (size_t) ooffset < strlen(sub_val)) {
if ((ptr = (char *)sub_val + ooffset)) { if ((ptr = (char *) sub_val + ooffset)) {
*ptr = '\0'; *ptr = '\0';
} }
} }
@ -1756,7 +1756,7 @@ SWITCH_DECLARE(char *) switch_channel_expand_variables(switch_channel_t *channel
if (stream.data) { if (stream.data) {
char *expanded_vname = NULL; 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; expanded_vname = NULL;
} else { } else {
vname = expanded_vname; vname = expanded_vname;
@ -1782,7 +1782,7 @@ SWITCH_DECLARE(char *) switch_channel_expand_variables(switch_channel_t *channel
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
free(data); free(data);
free(indup); free(indup);
return (char *)in; return (char *) in;
} }
} }
if ((nlen = sub_val ? strlen(sub_val) : 0)) { if ((nlen = sub_val ? strlen(sub_val) : 0)) {
@ -1830,7 +1830,8 @@ SWITCH_DECLARE(char *) switch_channel_build_param_string(switch_channel_t *chann
switch_stream_handle_t stream = { 0 }; switch_stream_handle_t stream = { 0 };
switch_size_t encode_len = 1024, new_len = 0; switch_size_t encode_len = 1024, new_len = 0;
char *encode_buf = NULL; 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; char *e = NULL;
switch_event_header_t *hi; switch_event_header_t *hi;
uint32_t x = 0; uint32_t x = 0;
@ -1938,7 +1939,8 @@ SWITCH_DECLARE(switch_status_t) switch_channel_set_timestamps(switch_channel_t *
char start[80] = "", answer[80] = "", progress[80] = "", progress_media[80] = "", end[80] = "", tmp[80] = "", profile_start[80] = ""; 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; 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; 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) { if (!(caller_profile = switch_channel_get_caller_profile(channel)) || !channel->variables) {
return SWITCH_STATUS_FALSE; return SWITCH_STATUS_FALSE;
@ -2041,28 +2043,28 @@ SWITCH_DECLARE(switch_status_t) switch_channel_set_timestamps(switch_channel_t *
switch_channel_set_variable(channel, "end_uepoch", tmp); switch_channel_set_variable(channel, "end_uepoch", tmp);
uduration = caller_profile->times->hungup - caller_profile->times->created; uduration = caller_profile->times->hungup - caller_profile->times->created;
duration = (int32_t)(tt_hungup - tt_created); duration = (int32_t) (tt_hungup - tt_created);
mduration = (int32_t)(mtt_hungup - mtt_created); mduration = (int32_t) (mtt_hungup - mtt_created);
if (caller_profile->times->answered) { if (caller_profile->times->answered) {
billsec = (int32_t)(tt_hungup - tt_answered); billsec = (int32_t) (tt_hungup - tt_answered);
billmsec = (int32_t)(mtt_hungup - mtt_answered); billmsec = (int32_t) (mtt_hungup - mtt_answered);
billusec = caller_profile->times->hungup - caller_profile->times->answered; billusec = caller_profile->times->hungup - caller_profile->times->answered;
legbillsec = (int32_t)(tt_hungup - tt_prof_created); legbillsec = (int32_t) (tt_hungup - tt_prof_created);
legbillmsec = (int32_t)(mtt_hungup - mtt_prof_created); legbillmsec = (int32_t) (mtt_hungup - mtt_prof_created);
legbillusec = caller_profile->times->hungup - caller_profile->times->profile_created; legbillusec = caller_profile->times->hungup - caller_profile->times->profile_created;
} }
if (caller_profile->times->progress) { if (caller_profile->times->progress) {
progresssec = (int32_t)(tt_progress - tt_created); progresssec = (int32_t) (tt_progress - tt_created);
progressmsec = (int32_t)(mtt_progress - mtt_created); progressmsec = (int32_t) (mtt_progress - mtt_created);
progressusec = caller_profile->times->progress - caller_profile->times->created; progressusec = caller_profile->times->progress - caller_profile->times->created;
} }
if (caller_profile->times->progress_media) { if (caller_profile->times->progress_media) {
progress_mediasec = (int32_t)(tt_progress - tt_created); progress_mediasec = (int32_t) (tt_progress - tt_created);
progress_mediamsec = (int32_t)(mtt_progress - mtt_created); progress_mediamsec = (int32_t) (mtt_progress - mtt_created);
progress_mediausec = caller_profile->times->progress - caller_profile->times->created; progress_mediausec = caller_profile->times->progress - caller_profile->times->created;
} }

View File

@ -33,7 +33,7 @@
#include <switch.h> #include <switch.h>
#include <switch_config.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; FILE *f;
char *path = NULL; char *path = NULL;
@ -88,7 +88,7 @@ SWITCH_DECLARE(int) switch_config_open_file(switch_config_t * cfg, char *file_pa
} }
} }
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) { if (cfg->file) {
@ -98,7 +98,7 @@ SWITCH_DECLARE(void) switch_config_close_file(switch_config_t * cfg)
memset(cfg, 0, sizeof(*cfg)); 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; int ret = 0;
char *p, *end; char *p, *end;

View File

@ -286,8 +286,7 @@ SWITCH_DECLARE(void) switch_console_printf(switch_text_channel_t channel, const
} }
if (channel == SWITCH_CHANNEL_ID_EVENT && if (channel == SWITCH_CHANNEL_ID_EVENT &&
switch_event_running() == SWITCH_STATUS_SUCCESS && switch_event_running() == SWITCH_STATUS_SUCCESS && switch_event_create(&event, SWITCH_EVENT_LOG) == 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-Data", "%s", data);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Log-File", "%s", filep); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Log-File", "%s", filep);
@ -296,7 +295,7 @@ SWITCH_DECLARE(void) switch_console_printf(switch_text_channel_t channel, const
switch_event_fire(&event); switch_event_fire(&event);
} }
done: done:
if (data) { if (data) {
free(data); free(data);
} }
@ -313,15 +312,16 @@ static char prompt_str[512] = "";
/* /*
* If a fnkey is configured then process the command * 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; 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 // 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"); switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_CONSOLE, "\n");
if (c == NULL) { 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); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "FUNCTION KEY F%d IS NOT BOUND, please edit switch.conf XML file\n", i);
@ -335,45 +335,58 @@ static unsigned char console_fnkey_pressed(int i) {
return CC_REDISPLAY; return CC_REDISPLAY;
} }
static unsigned char console_f1key(EditLine *el, int ch) { static unsigned char console_f1key(EditLine * el, int ch)
{
return console_fnkey_pressed(1); return console_fnkey_pressed(1);
} }
static unsigned char console_f2key(EditLine *el, int ch) { static unsigned char console_f2key(EditLine * el, int ch)
{
return console_fnkey_pressed(2); return console_fnkey_pressed(2);
} }
static unsigned char console_f3key(EditLine *el, int ch) { static unsigned char console_f3key(EditLine * el, int ch)
{
return console_fnkey_pressed(3); return console_fnkey_pressed(3);
} }
static unsigned char console_f4key(EditLine *el, int ch) { static unsigned char console_f4key(EditLine * el, int ch)
{
return console_fnkey_pressed(4); return console_fnkey_pressed(4);
} }
static unsigned char console_f5key(EditLine *el, int ch) { static unsigned char console_f5key(EditLine * el, int ch)
{
return console_fnkey_pressed(5); return console_fnkey_pressed(5);
} }
static unsigned char console_f6key(EditLine *el, int ch) { static unsigned char console_f6key(EditLine * el, int ch)
{
return console_fnkey_pressed(6); return console_fnkey_pressed(6);
} }
static unsigned char console_f7key(EditLine *el, int ch) { static unsigned char console_f7key(EditLine * el, int ch)
{
return console_fnkey_pressed(7); return console_fnkey_pressed(7);
} }
static unsigned char console_f8key(EditLine *el, int ch) { static unsigned char console_f8key(EditLine * el, int ch)
{
return console_fnkey_pressed(8); return console_fnkey_pressed(8);
} }
static unsigned char console_f9key(EditLine *el, int ch) { static unsigned char console_f9key(EditLine * el, int ch)
{
return console_fnkey_pressed(9); return console_fnkey_pressed(9);
} }
static unsigned char console_f10key(EditLine *el, int ch) { static unsigned char console_f10key(EditLine * el, int ch)
{
return console_fnkey_pressed(10); return console_fnkey_pressed(10);
} }
static unsigned char console_f11key(EditLine *el, int ch) { static unsigned char console_f11key(EditLine * el, int ch)
{
return console_fnkey_pressed(11); return console_fnkey_pressed(11);
} }
static unsigned char console_f12key(EditLine *el, int ch) { static unsigned char console_f12key(EditLine * el, int ch)
{
return console_fnkey_pressed(12); return console_fnkey_pressed(12);
} }
char * prompt(EditLine *e) { char *prompt(EditLine * e)
{
if (*prompt_str == '\0') { if (*prompt_str == '\0') {
gethostname(hostname, sizeof(hostname)); gethostname(hostname, sizeof(hostname));
switch_snprintf(prompt_str, sizeof(prompt_str), "freeswitch@%s> ", hostname); switch_snprintf(prompt_str, sizeof(prompt_str), "freeswitch@%s> ", hostname);
@ -408,14 +421,14 @@ static void *SWITCH_THREAD_FUNC console_thread(switch_thread_t *thread, void *ob
char *cmd = strdup(line); char *cmd = strdup(line);
char *p; char *p;
const LineInfo *lf = el_line(el); 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'))) { if ((p = strrchr(cmd, '\r')) || (p = strrchr(cmd, '\n'))) {
*p = '\0'; *p = '\0';
} }
assert(cmd != NULL); assert(cmd != NULL);
history(myhistory, &ev, H_ENTER, line); history(myhistory, &ev, H_ENTER, line);
running = switch_console_process(cmd, 0); running = switch_console_process(cmd, 0);
el_deletestr(el, strlen(foo)+1); el_deletestr(el, strlen(foo) + 1);
memset(foo, 0, strlen(foo)); memset(foo, 0, strlen(foo));
free(cmd); free(cmd);
} }
@ -459,7 +472,7 @@ static int comp_callback(void *pArg, int argc, char **argv, char **columnNames)
return 0; 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(); switch_core_db_t *db = switch_core_db_handle();
char *sql; char *sql;
@ -477,11 +490,11 @@ static unsigned char complete(EditLine *el, int ch)
*p = '\0'; *p = '\0';
} }
while(*buf == ' ') { while (*buf == ' ') {
buf++; buf++;
} }
for(p = buf; p && *p; p++) { for (p = buf; p && *p; p++) {
if (*p == ' ') { if (*p == ' ') {
lp = p; lp = p;
h.words++; h.words++;
@ -515,7 +528,7 @@ static unsigned char complete(EditLine *el, int ch)
char *dupdup = strdup(dup); char *dupdup = strdup(dup);
switch_assert(dupdup); switch_assert(dupdup);
int x, argc = 0; int x, argc = 0;
char *argv[10] = {0}; char *argv[10] = { 0 };
switch_stream_handle_t stream = { 0 }; switch_stream_handle_t stream = { 0 };
SWITCH_STANDARD_STREAM(stream); SWITCH_STANDARD_STREAM(stream);
@ -523,17 +536,14 @@ static unsigned char complete(EditLine *el, int ch)
argc = switch_separate_string(dupdup, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); argc = switch_separate_string(dupdup, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
if (h.words == 0) { if (h.words == 0) {
stream.write_function(&stream, stream.write_function(&stream, "select distinct a1 from complete where " "a1 not in (select name from interfaces) %s ", argc ? "and" : "");
"select distinct a1 from complete where "
"a1 not in (select name from interfaces) %s ", argc ? "and" : "");
} else { } else {
stream.write_function(&stream, stream.write_function(&stream, "select distinct a%d from complete where ", h.words + 1);
"select distinct a%d from complete where ", h.words + 1);
} }
for(x = 0; x < argc; x++) { 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 "); 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);
@ -574,7 +584,7 @@ static unsigned char complete(EditLine *el, int ch)
SWITCH_DECLARE(switch_status_t) switch_console_set_complete(const char *string) 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; int argc, x;
switch_status_t status = SWITCH_STATUS_FALSE; switch_status_t status = SWITCH_STATUS_FALSE;
@ -587,15 +597,15 @@ SWITCH_DECLARE(switch_status_t) switch_console_set_complete(const char *string)
if (!strcasecmp(argv[0], "stickyadd")) { if (!strcasecmp(argv[0], "stickyadd")) {
mystream.write_function(&mystream, "insert into complete values (1,"); mystream.write_function(&mystream, "insert into complete values (1,");
for(x = 0; x < 10; x++) { for (x = 0; x < 10; x++) {
mystream.write_function(&mystream, "'%s'%s", switch_str_nil(argv[x+1]), x == 9 ? ")" : ", "); mystream.write_function(&mystream, "'%s'%s", switch_str_nil(argv[x + 1]), x == 9 ? ")" : ", ");
} }
switch_core_db_persistant_execute(db, mystream.data, 5); switch_core_db_persistant_execute(db, mystream.data, 5);
status = SWITCH_STATUS_SUCCESS; status = SWITCH_STATUS_SUCCESS;
} else if (!strcasecmp(argv[0], "add")) { } else if (!strcasecmp(argv[0], "add")) {
mystream.write_function(&mystream, "insert into complete values (0,"); mystream.write_function(&mystream, "insert into complete values (0,");
for(x = 0; x < 10; x++) { for (x = 0; x < 10; x++) {
mystream.write_function(&mystream, "'%s'%s", switch_str_nil(argv[x+1]), x == 9 ? ")" : ", "); mystream.write_function(&mystream, "'%s'%s", switch_str_nil(argv[x + 1]), x == 9 ? ")" : ", ");
} }
switch_core_db_persistant_execute(db, mystream.data, 5); switch_core_db_persistant_execute(db, mystream.data, 5);
status = SWITCH_STATUS_SUCCESS; status = SWITCH_STATUS_SUCCESS;
@ -605,8 +615,8 @@ SWITCH_DECLARE(switch_status_t) switch_console_set_complete(const char *string)
switch_core_db_persistant_execute(db, "delete from complete", 1); switch_core_db_persistant_execute(db, "delete from complete", 1);
} else { } else {
mystream.write_function(&mystream, "delete from complete where "); mystream.write_function(&mystream, "delete from complete where ");
for(x = 0; x < argc - 1; x++) { 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 "); 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); switch_core_db_persistant_execute(db, mystream.data, 1);
} }
@ -626,7 +636,7 @@ SWITCH_DECLARE(switch_status_t) switch_console_set_complete(const char *string)
SWITCH_DECLARE(switch_status_t) switch_console_set_alias(const char *string) 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; int argc;
switch_status_t status = SWITCH_STATUS_FALSE; switch_status_t status = SWITCH_STATUS_FALSE;
@ -693,18 +703,18 @@ SWITCH_DECLARE(void) switch_console_loop(void)
/* Load/Init the config first */ /* Load/Init the config first */
console_xml_config(); console_xml_config();
/* Bind the functions to the key */ /* Bind the functions to the key */
el_set(el, EL_ADDFN, "f1-key", "F1 KEY PRESS", console_f1key ); 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, "f2-key", "F2 KEY PRESS", console_f2key);
el_set(el, EL_ADDFN, "f3-key", "F3 KEY PRESS", console_f3key ); 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, "f4-key", "F4 KEY PRESS", console_f4key);
el_set(el, EL_ADDFN, "f5-key", "F5 KEY PRESS", console_f5key ); 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, "f6-key", "F6 KEY PRESS", console_f6key);
el_set(el, EL_ADDFN, "f7-key", "F7 KEY PRESS", console_f7key ); 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, "f8-key", "F8 KEY PRESS", console_f8key);
el_set(el, EL_ADDFN, "f9-key", "F9 KEY PRESS", console_f9key ); 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, "f10-key", "F10 KEY PRESS", console_f10key);
el_set(el, EL_ADDFN, "f11-key", "F11 KEY PRESS", console_f11key ); 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_ADDFN, "f12-key", "F12 KEY PRESS", console_f12key);
el_set(el, EL_BIND, "\033OP", "f1-key", NULL); el_set(el, EL_BIND, "\033OP", "f1-key", NULL);
el_set(el, EL_BIND, "\033OQ", "f2-key", NULL); el_set(el, EL_BIND, "\033OQ", "f2-key", NULL);

View File

@ -172,7 +172,7 @@ SWITCH_DECLARE(char *) switch_core_get_uuid(void)
} }
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_thread_session_t *data = obj;
switch_core_session_t *session = data->objs[0]; switch_core_session_t *session = data->objs[0];
@ -436,8 +436,7 @@ SWITCH_DECLARE(int32_t) set_high_priority(void)
* So let's try to remove the mlock limit here... * So let's try to remove the mlock limit here...
*/ */
if (setrlimit(RLIMIT_MEMLOCK, &lim) < 0) { if (setrlimit(RLIMIT_MEMLOCK, &lim) < 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Failed to disable memlock limit, application may crash if run as non-root user!\n");
"Failed to disable memlock limit, application may crash if run as non-root user!\n");
} }
#endif #endif
@ -463,7 +462,7 @@ SWITCH_DECLARE(int32_t) change_user_group(const char *user, const char *group)
/* /*
* Lookup user information in the system's db * Lookup user information in the system's db
*/ */
runas_pw = getpwnam( user ); runas_pw = getpwnam(user);
if (!runas_pw) { if (!runas_pw) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Unknown user \"%s\"\n", user); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Unknown user \"%s\"\n", user);
return -1; return -1;
@ -477,7 +476,7 @@ SWITCH_DECLARE(int32_t) change_user_group(const char *user, const char *group)
/* /*
* Lookup group information in the system's db * Lookup group information in the system's db
*/ */
gr = getgrnam( group ); gr = getgrnam(group);
if (!gr) { if (!gr) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Unknown group \"%s\"\n", group); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Unknown group \"%s\"\n", group);
return -1; return -1;
@ -514,7 +513,6 @@ SWITCH_DECLARE(int32_t) change_user_group(const char *user, const char *group)
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Failed to change gid!\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Failed to change gid!\n");
return -1; return -1;
} }
#ifdef HAVE_INITGROUPS #ifdef HAVE_INITGROUPS
/* /*
* Set all the other groups the user is a member of * Set all the other groups the user is a member of
@ -630,7 +628,7 @@ static void load_mime_types(void)
return; 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 *p;
char *type = line_buf; char *type = line_buf;
@ -645,7 +643,7 @@ static void load_mime_types(void)
if ((p = strchr(type, '\t')) || (p = strchr(type, ' '))) { if ((p = strchr(type, '\t')) || (p = strchr(type, ' '))) {
*p++ = '\0'; *p++ = '\0';
while(*p == ' ' || *p == '\t') { while (*p == ' ' || *p == '\t') {
p++; p++;
} }
@ -790,7 +788,8 @@ SWITCH_DECLARE(void) switch_load_network_lists(switch_bool_t reload)
if (reload) { if (reload) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Adding %s (%s) to list %s\n", cidr, ok ? "allow" : "deny", name); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Adding %s (%s) to list %s\n", cidr, ok ? "allow" : "deny", name);
} else { } 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 { } else {
if (reload) { if (reload) {
@ -855,8 +854,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_init(switch_core_flag_t flags, switc
memset(&runtime, 0, sizeof(runtime)); memset(&runtime, 0, sizeof(runtime));
runtime.dummy_cng_frame.data = runtime.dummy_data; runtime.dummy_cng_frame.data = runtime.dummy_data;
runtime.dummy_cng_frame.datalen= 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.buflen = sizeof(runtime.dummy_data);
runtime.dummy_cng_frame.flags = SFF_CNG; runtime.dummy_cng_frame.flags = SFF_CNG;
switch_set_flag((&runtime), SCF_NO_NEW_SESSIONS); switch_set_flag((&runtime), SCF_NO_NEW_SESSIONS);
@ -924,7 +923,6 @@ SWITCH_DECLARE(switch_status_t) switch_core_init(switch_core_flag_t flags, switc
if (level != SWITCH_LOG_INVALID) { if (level != SWITCH_LOG_INVALID) {
switch_core_session_ctl(SCSC_LOGLEVEL, &level); switch_core_session_ctl(SCSC_LOGLEVEL, &level);
} }
#ifdef HAVE_SETRLIMIT #ifdef HAVE_SETRLIMIT
} else if (!strcasecmp(var, "dump-cores")) { } else if (!strcasecmp(var, "dump-cores")) {
struct rlimit rlp; struct rlimit rlp;
@ -942,23 +940,21 @@ SWITCH_DECLARE(switch_status_t) switch_core_init(switch_core_flag_t flags, switc
} else if (!strcasecmp(var, "max_dtmf_duration")) { } else if (!strcasecmp(var, "max_dtmf_duration")) {
int tmp = atoi(val); int tmp = atoi(val);
if (tmp > 0) { 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")) { } else if (!strcasecmp(var, "default_dtmf_duration")) {
int tmp = atoi(val); int tmp = atoi(val);
if (tmp > 0) { 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")) { } else if (!strcasecmp(var, "disable-monotonic-timing")) {
switch_time_set_monotonic(SWITCH_FALSE); switch_time_set_monotonic(SWITCH_FALSE);
} else if (!strcasecmp(var, "max-sessions")) { } else if (!strcasecmp(var, "max-sessions")) {
switch_core_session_limit(atoi(val)); switch_core_session_limit(atoi(val));
} } else if (!strcasecmp(var, "rtp-start-port")) {
else if (!strcasecmp(var, "rtp-start-port")) { switch_rtp_set_start_port((switch_port_t) atoi(val));
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-end-port")) {
switch_rtp_set_end_port((switch_port_t)atoi(val));
} }
} }
} }
@ -1113,9 +1109,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_init_and_modload(switch_core_flag_t
"\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_test_flag((&runtime), SCF_CRASH_PROT) ? "Enabled" : "Disabled",
switch_core_session_limit(0), switch_core_session_limit(0),
switch_core_sessions_per_second(0), switch_core_sessions_per_second(0), switch_test_flag((&runtime), SCF_USE_SQL) ? "Enabled" : "Disabled");
switch_test_flag((&runtime), SCF_USE_SQL) ? "Enabled" : "Disabled"
);
switch_clear_flag((&runtime), SCF_NO_NEW_SESSIONS); switch_clear_flag((&runtime), SCF_NO_NEW_SESSIONS);
@ -1145,7 +1139,7 @@ SWITCH_DECLARE(switch_time_t) switch_core_uptime(void)
return switch_timestamp_now() - runtime.initiated; 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)) { if (switch_test_flag((&runtime), SCF_SHUTTING_DOWN)) {
return -1; return -1;

View File

@ -37,11 +37,7 @@
SWITCH_DECLARE(switch_status_t) switch_core_asr_open(switch_asr_handle_t *ah, SWITCH_DECLARE(switch_status_t) switch_core_asr_open(switch_asr_handle_t *ah,
const char *module_name, const char *module_name,
const char *codec, const char *codec, int rate, const char *dest, switch_asr_flag_t *flags, switch_memory_pool_t *pool)
int rate,
const char *dest,
switch_asr_flag_t *flags,
switch_memory_pool_t *pool)
{ {
switch_status_t status; switch_status_t status;
char buf[256] = ""; char buf[256] = "";

View File

@ -92,7 +92,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_set_write_codec(switch_core_
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-name", "%s", codec->implementation->iananame);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "channel-write-codec-rate", "%d", codec->implementation->actual_samples_per_second); 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) { 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); switch_event_fire(&event);
} }
@ -286,7 +287,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_codec_encode(switch_codec_t *codec,
void *decoded_data, void *decoded_data,
uint32_t decoded_data_len, uint32_t decoded_data_len,
uint32_t decoded_rate, 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(codec != NULL);
switch_assert(encoded_data != NULL); switch_assert(encoded_data != NULL);
@ -311,7 +312,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_codec_decode(switch_codec_t *codec,
void *encoded_data, void *encoded_data,
uint32_t encoded_data_len, uint32_t encoded_data_len,
uint32_t encoded_rate, 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(codec != NULL);
switch_assert(encoded_data != NULL); switch_assert(encoded_data != NULL);

View File

@ -81,7 +81,7 @@ SWITCH_DECLARE(int) switch_core_db_exec(switch_core_db_t *db, const char *sql, s
int sane = 100; int sane = 100;
char *err = NULL; char *err = NULL;
while(--sane > 0) { while (--sane > 0) {
ret = sqlite3_exec(db, sql, callback, data, &err); ret = sqlite3_exec(db, sql, callback, data, &err);
if (ret == SQLITE_BUSY || ret == SQLITE_LOCKED) { if (ret == SQLITE_BUSY || ret == SQLITE_LOCKED) {
if (sane > 1) { if (sane > 1) {
@ -165,7 +165,8 @@ SWITCH_DECLARE(void) switch_core_db_free(char *z)
sqlite3_free(z); sqlite3_free(z);
} }
SWITCH_DECLARE(int) switch_core_db_changes(switch_core_db_t *db) { SWITCH_DECLARE(int) switch_core_db_changes(switch_core_db_t *db)
{
return sqlite3_changes(db); return sqlite3_changes(db);
} }

View File

@ -32,17 +32,17 @@
#include "private/switch_core_pvt.h" #include "private/switch_core_pvt.h"
NEW_HOOK_DECL(outgoing_channel) NEW_HOOK_DECL(outgoing_channel)
NEW_HOOK_DECL(receive_message) NEW_HOOK_DECL(receive_message)
NEW_HOOK_DECL(receive_event) NEW_HOOK_DECL(receive_event)
NEW_HOOK_DECL(state_change) NEW_HOOK_DECL(state_change)
NEW_HOOK_DECL(read_frame) NEW_HOOK_DECL(read_frame)
NEW_HOOK_DECL(write_frame) NEW_HOOK_DECL(write_frame)
NEW_HOOK_DECL(video_read_frame) NEW_HOOK_DECL(video_read_frame)
NEW_HOOK_DECL(video_write_frame) NEW_HOOK_DECL(video_write_frame)
NEW_HOOK_DECL(kill_channel) NEW_HOOK_DECL(kill_channel)
NEW_HOOK_DECL(send_dtmf) NEW_HOOK_DECL(send_dtmf)
NEW_HOOK_DECL(recv_dtmf) NEW_HOOK_DECL(recv_dtmf)
NEW_HOOK_DECL(resurrect_session) NEW_HOOK_DECL(resurrect_session)
/* For Emacs: /* For Emacs:
* Local Variables: * Local Variables:

View File

@ -38,10 +38,7 @@
SWITCH_DECLARE(switch_status_t) switch_core_perform_file_open(const char *file, const char *func, int line, SWITCH_DECLARE(switch_status_t) switch_core_perform_file_open(const char *file, const char *func, int line,
switch_file_handle_t *fh, switch_file_handle_t *fh,
const char *file_path, const char *file_path,
uint8_t channels, uint8_t channels, uint32_t rate, unsigned int flags, switch_memory_pool_t *pool)
uint32_t rate,
unsigned int flags,
switch_memory_pool_t *pool)
{ {
char *ext; char *ext;
switch_status_t status; switch_status_t status;
@ -142,11 +139,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_file_read(switch_file_handle_t *fh,
if (!switch_test_flag(fh, SWITCH_FILE_NATIVE) && fh->native_rate != fh->samplerate) { if (!switch_test_flag(fh, SWITCH_FILE_NATIVE) && fh->native_rate != fh->samplerate) {
if (!fh->resampler) { if (!fh->resampler) {
if (switch_resample_create(&fh->resampler, if (switch_resample_create(&fh->resampler,
fh->native_rate, fh->native_rate, orig_len, fh->samplerate, (uint32_t) orig_len, fh->memory_pool) != SWITCH_STATUS_SUCCESS) {
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"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Unable to create resampler!\n");
return SWITCH_STATUS_GENERR; return SWITCH_STATUS_GENERR;
} }
@ -196,11 +189,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_file_write(switch_file_handle_t *fh,
if (!switch_test_flag(fh, SWITCH_FILE_NATIVE) && fh->native_rate != fh->samplerate) { if (!switch_test_flag(fh, SWITCH_FILE_NATIVE) && fh->native_rate != fh->samplerate) {
if (!fh->resampler) { if (!fh->resampler) {
if (switch_resample_create(&fh->resampler, if (switch_resample_create(&fh->resampler,
fh->native_rate, fh->native_rate, orig_len, fh->samplerate, (uint32_t) orig_len, fh->memory_pool) != SWITCH_STATUS_SUCCESS) {
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"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Unable to create resampler!\n");
return SWITCH_STATUS_GENERR; return SWITCH_STATUS_GENERR;
} }

View File

@ -41,7 +41,7 @@ struct switch_hash {
Hash table; 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; switch_hash_t *newhash;
@ -62,19 +62,19 @@ SWITCH_DECLARE(switch_status_t) switch_core_hash_destroy(switch_hash_t **hash)
return SWITCH_STATUS_SUCCESS; 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; 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) { 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) { if (mutex) {
switch_mutex_unlock(mutex); switch_mutex_unlock(mutex);
@ -83,19 +83,19 @@ SWITCH_DECLARE(switch_status_t) switch_core_hash_insert_locked(switch_hash_t * h
return SWITCH_STATUS_SUCCESS; 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; 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) { if (mutex) {
switch_mutex_lock(mutex); switch_mutex_lock(mutex);
} }
sqlite3HashInsert(&hash->table, key, (int)strlen(key)+1, NULL); sqlite3HashInsert(&hash->table, key, (int) strlen(key) + 1, NULL);
if (mutex) { if (mutex) {
switch_mutex_unlock(mutex); switch_mutex_unlock(mutex);
@ -104,12 +104,12 @@ SWITCH_DECLARE(switch_status_t) switch_core_hash_delete_locked(switch_hash_t * h
return SWITCH_STATUS_SUCCESS; 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; void *val;
@ -117,7 +117,7 @@ SWITCH_DECLARE(void *) switch_core_hash_find_locked(switch_hash_t * hash, const
switch_mutex_lock(mutex); switch_mutex_lock(mutex);
} }
val = sqlite3HashFind(&hash->table, key, (int)strlen(key)+1); val = sqlite3HashFind(&hash->table, key, (int) strlen(key) + 1);
if (mutex) { if (mutex) {
switch_mutex_unlock(mutex); switch_mutex_unlock(mutex);

View File

@ -35,7 +35,8 @@
#include <switch.h> #include <switch.h>
#include "private/switch_core_pvt.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_io_event_hook_video_write_frame_t *ptr;
switch_status_t status = SWITCH_STATUS_FALSE; switch_status_t status = SWITCH_STATUS_FALSE;
@ -56,7 +57,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_video_frame(switch_cor
return status; 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_status_t status = SWITCH_STATUS_FALSE;
switch_io_event_hook_video_read_frame_t *ptr; switch_io_event_hook_video_read_frame_t *ptr;
@ -68,8 +70,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_video_frame(switch_core
} }
if (session->endpoint_interface->io_routines->read_video_frame) { if (session->endpoint_interface->io_routines->read_video_frame) {
if ((status = if ((status = session->endpoint_interface->io_routines->read_video_frame(session, frame, flags, stream_id)) == SWITCH_STATUS_SUCCESS) {
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) { 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) { if ((status = ptr->video_read_frame(session, frame, flags, stream_id)) != SWITCH_STATUS_SUCCESS) {
break; break;
@ -98,7 +99,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_video_frame(switch_core
return status; 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_io_event_hook_read_frame_t *ptr;
switch_status_t status; switch_status_t status;
@ -107,7 +109,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_sessi
switch_assert(session != NULL); switch_assert(session != NULL);
top: top:
if (switch_channel_get_state(session->channel) >= CS_HANGUP) { if (switch_channel_get_state(session->channel) >= CS_HANGUP) {
*frame = NULL; *frame = NULL;
@ -126,8 +128,7 @@ top:
} }
if (session->endpoint_interface->io_routines->read_frame) { if (session->endpoint_interface->io_routines->read_frame) {
if ((status = if ((status = session->endpoint_interface->io_routines->read_frame(session, frame, flags, stream_id)) == SWITCH_STATUS_SUCCESS) {
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) { for (ptr = session->event_hooks.read_frame; ptr; ptr = ptr->next) {
if ((status = ptr->read_frame(session, frame, flags, stream_id)) != SWITCH_STATUS_SUCCESS) { if ((status = ptr->read_frame(session, frame, flags, stream_id)) != SWITCH_STATUS_SUCCESS) {
break; break;
@ -296,7 +297,8 @@ top:
switch_mutex_lock(bp->read_mutex); switch_mutex_lock(bp->read_mutex);
switch_buffer_write(bp->raw_read_buffer, read_frame->data, read_frame->datalen); switch_buffer_write(bp->raw_read_buffer, read_frame->data, read_frame->datalen);
if (bp->callback) { 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; ok = SWITCH_FALSE;
} }
} }
@ -448,7 +450,8 @@ top:
if (bp->ready && switch_test_flag(bp, SMBF_READ_PING)) { if (bp->ready && switch_test_flag(bp, SMBF_READ_PING)) {
switch_mutex_lock(bp->read_mutex); switch_mutex_lock(bp->read_mutex);
if (bp->callback) { 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; ok = SWITCH_FALSE;
} }
} }
@ -504,7 +507,8 @@ static switch_status_t perform_write(switch_core_session_t *session, switch_fram
return status; 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; switch_status_t status = SWITCH_STATUS_FALSE;
@ -1013,7 +1017,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_send_dtmf(switch_core_sessio
SWITCH_DECLARE(switch_status_t) switch_core_session_send_dtmf_string(switch_core_session_t *session, const char *dtmf_string) SWITCH_DECLARE(switch_status_t) switch_core_session_send_dtmf_string(switch_core_session_t *session, const char *dtmf_string)
{ {
char *p; 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; int sent = 0, dur;
char *string; char *string;
int i, argc; int i, argc;
@ -1042,7 +1046,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_send_dtmf_string(switch_core
switch_channel_pre_answer(session->channel); 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); dtmf.duration = switch_core_default_dtmf_duration(0);
dur = switch_core_default_dtmf_duration(0) / 8; dur = switch_core_default_dtmf_duration(0) / 8;
if ((p = strchr(argv[i], '@'))) { if ((p = strchr(argv[i], '@'))) {

View File

@ -128,7 +128,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_bug_read(switch_media_bug_t *b
bytes = (datalen > frame->datalen) ? datalen : frame->datalen; bytes = (datalen > frame->datalen) ? datalen : frame->datalen;
switch_assert( bytes <= maxlen ); switch_assert(bytes <= maxlen);
if (bytes) { if (bytes) {
int16_t *tp = bug->tmp; int16_t *tp = bug->tmp;
@ -183,7 +183,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_bug_add(switch_core_session_t
switch_media_bug_callback_t callback, 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) 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; switch_size_t bytes;
if (flags & SMBF_WRITE_REPLACE) { if (flags & SMBF_WRITE_REPLACE) {

View File

@ -58,7 +58,8 @@ SWITCH_DECLARE(switch_memory_pool_t *) switch_core_session_get_pool(switch_core_
/* **ONLY** alloc things with this function that **WILL NOT** outlive /* **ONLY** alloc things with this function that **WILL NOT** outlive
the session itself or expect an earth shattering KABOOM!*/ 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; void *ptr = NULL;
switch_assert(session != NULL); switch_assert(session != NULL);
@ -70,7 +71,7 @@ SWITCH_DECLARE(void *) switch_core_perform_session_alloc(switch_core_session_t *
#ifdef DEBUG_ALLOC #ifdef DEBUG_ALLOC
if (memory > 500) 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 #endif
ptr = apr_palloc(session->pool, memory); ptr = apr_palloc(session->pool, memory);
@ -98,7 +99,7 @@ SWITCH_DECLARE(void *) switch_core_perform_permanent_alloc(switch_size_t memory,
#endif #endif
#ifdef DEBUG_ALLOC #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 #endif
ptr = apr_palloc(memory_manager.memory_pool, memory); ptr = apr_palloc(memory_manager.memory_pool, memory);
@ -131,7 +132,7 @@ SWITCH_DECLARE(char *) switch_core_perform_permanent_strdup(const char *todup, c
switch_assert(duped != NULL); switch_assert(duped != NULL);
#ifdef DEBUG_ALLOC #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 #endif
#ifdef LOCK_MORE #ifdef LOCK_MORE
@ -199,7 +200,6 @@ SWITCH_DECLARE(char *) switch_core_perform_session_strdup(switch_core_session_t
if (!todup) { if (!todup) {
return NULL; return NULL;
} }
#ifdef LOCK_MORE #ifdef LOCK_MORE
switch_mutex_lock(memory_manager.mem_lock); switch_mutex_lock(memory_manager.mem_lock);
#endif #endif
@ -208,7 +208,7 @@ SWITCH_DECLARE(char *) switch_core_perform_session_strdup(switch_core_session_t
#ifdef DEBUG_ALLOC #ifdef DEBUG_ALLOC
if (len > 500) 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 #endif
duped = apr_pstrmemdup(session->pool, todup, len); duped = apr_pstrmemdup(session->pool, todup, len);
@ -231,7 +231,6 @@ SWITCH_DECLARE(char *) switch_core_perform_strdup(switch_memory_pool_t *pool, co
if (!todup) { if (!todup) {
return NULL; return NULL;
} }
#ifdef LOCK_MORE #ifdef LOCK_MORE
switch_mutex_lock(memory_manager.mem_lock); switch_mutex_lock(memory_manager.mem_lock);
#endif #endif
@ -240,7 +239,7 @@ SWITCH_DECLARE(char *) switch_core_perform_strdup(switch_memory_pool_t *pool, co
#ifdef DEBUG_ALLOC #ifdef DEBUG_ALLOC
if (len > 500) 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 #endif
duped = apr_pstrmemdup(pool, todup, len); duped = apr_pstrmemdup(pool, todup, len);
@ -338,8 +337,8 @@ SWITCH_DECLARE(void *) switch_core_perform_alloc(switch_memory_pool_t *pool, swi
#ifdef DEBUG_ALLOC #ifdef DEBUG_ALLOC
if (memory > 500) if (memory > 500)
switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_CONSOLE, "Core Allocate %d\n", (int)memory); 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_assert(memory < 20000); */
#endif #endif
ptr = apr_palloc(pool, memory); ptr = apr_palloc(pool, memory);
@ -369,7 +368,7 @@ SWITCH_DECLARE(void) switch_core_memory_reclaim(void)
} }
} }
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; memory_manager.pool_thread_running = 1;
@ -388,7 +387,6 @@ static void *SWITCH_THREAD_FUNC pool_thread(switch_thread_t * thread, void *obj)
break; break;
} }
#if defined(PER_POOL_LOCK) || defined(DESTROY_POOLS) #if defined(PER_POOL_LOCK) || defined(DESTROY_POOLS)
apr_pool_destroy(pop); apr_pool_destroy(pop);
#else #else
@ -428,7 +426,7 @@ void switch_core_memory_stop(void)
{ {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Stopping memory pool queue.\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Stopping memory pool queue.\n");
memory_manager.pool_thread_running = -1; memory_manager.pool_thread_running = -1;
while(memory_manager.pool_thread_running) { while (memory_manager.pool_thread_running) {
switch_yield(1000); switch_yield(1000);
} }
} }

View File

@ -118,20 +118,20 @@ SWITCH_DECLARE(switch_status_t) switch_core_port_allocator_request_port(switch_c
int odd = switch_test_flag(alloc, SPF_ODD); int odd = switch_test_flag(alloc, SPF_ODD);
switch_mutex_lock(alloc->mutex); switch_mutex_lock(alloc->mutex);
srand(getpid() + (unsigned)switch_timestamp(NULL)); srand(getpid() + (unsigned) switch_timestamp(NULL));
while(alloc->track_used < alloc->track_len) { while (alloc->track_used < alloc->track_len) {
double r; double r;
uint32_t index; uint32_t index;
int tries = 0; int tries = 0;
do { do {
r = ((double)rand() / ((double)(RAND_MAX)+(double)(1))); r = ((double) rand() / ((double) (RAND_MAX) + (double) (1)));
index = (int) (r * alloc->track_len); index = (int) (r * alloc->track_len);
tries++; tries++;
} while((alloc->track[index] || index >= alloc->track_len) && tries < 10000); } while ((alloc->track[index] || index >= alloc->track_len) && tries < 10000);
while(alloc->track[index]) { while (alloc->track[index]) {
if (++index >= alloc->track_len) { if (++index >= alloc->track_len) {
index = 0; index = 0;
} }
@ -143,9 +143,9 @@ SWITCH_DECLARE(switch_status_t) switch_core_port_allocator_request_port(switch_c
status = SWITCH_STATUS_SUCCESS; status = SWITCH_STATUS_SUCCESS;
if ((even && odd)) { if ((even && odd)) {
port = (switch_port_t)(index + alloc->start); port = (switch_port_t) (index + alloc->start);
} else { } else {
port = (switch_port_t)(index + (alloc->start / 2)); port = (switch_port_t) (index + (alloc->start / 2));
port *= 2; port *= 2;
} }
goto end; goto end;

View File

@ -57,7 +57,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_lock(switch_core_sessio
if (switch_test_flag(session, SSF_DESTROYED)) { if (switch_test_flag(session, SSF_DESTROYED)) {
status = SWITCH_STATUS_FALSE; status = SWITCH_STATUS_FALSE;
#ifdef SWITCH_DEBUG_RWLOCKS #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 #endif
} else { } else {
status = (switch_status_t) switch_thread_rwlock_tryrdlock(session->rwlock); status = (switch_status_t) switch_thread_rwlock_tryrdlock(session->rwlock);
@ -75,7 +76,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_lock(switch_core_sessio
SWITCH_DECLARE(void) switch_core_session_perform_write_lock(switch_core_session_t *session, const char *file, const char *func, int line) 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 #else
SWITCH_DECLARE(void) switch_core_session_write_lock(switch_core_session_t *session) SWITCH_DECLARE(void) switch_core_session_write_lock(switch_core_session_t *session)
{ {

View File

@ -174,9 +174,7 @@ SWITCH_DECLARE(int) switch_core_session_get_stream_count(switch_core_session_t *
} }
SWITCH_DECLARE(switch_call_cause_t) switch_core_session_resurrect_channel(const char *endpoint_name, SWITCH_DECLARE(switch_call_cause_t) switch_core_session_resurrect_channel(const char *endpoint_name,
switch_core_session_t **new_session, switch_core_session_t **new_session, switch_memory_pool_t **pool, void *data)
switch_memory_pool_t **pool,
void *data)
{ {
const switch_endpoint_interface_t *endpoint_interface; const switch_endpoint_interface_t *endpoint_interface;
@ -188,12 +186,11 @@ SWITCH_DECLARE(switch_call_cause_t) switch_core_session_resurrect_channel(const
return endpoint_interface->io_routines->resurrect_session(new_session, pool, data); 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, 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, const char *endpoint_name,
switch_caller_profile_t *caller_profile, switch_caller_profile_t *caller_profile,
switch_core_session_t **new_session, switch_core_session_t **new_session,
switch_memory_pool_t **pool, switch_memory_pool_t **pool, switch_originate_flag_t flags)
switch_originate_flag_t flags)
{ {
switch_io_event_hook_outgoing_channel_t *ptr; switch_io_event_hook_outgoing_channel_t *ptr;
switch_status_t status = SWITCH_STATUS_FALSE; switch_status_t status = SWITCH_STATUS_FALSE;
@ -249,7 +246,8 @@ SWITCH_DECLARE(switch_call_cause_t) switch_core_session_resurrect_channel(const
} }
} }
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; return cause;
} }
@ -396,7 +394,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_receive_message(switch_core_
SWITCH_DECLARE(switch_status_t) switch_core_session_pass_indication(switch_core_session_t *session, switch_core_session_message_types_t indication) 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; switch_core_session_t *other_session;
const char *uuid; const char *uuid;
switch_channel_t *channel = switch_core_session_get_channel(session); switch_channel_t *channel = switch_core_session_get_channel(session);
@ -624,7 +622,7 @@ SWITCH_DECLARE(void) switch_core_session_reset(switch_core_session_t *session, s
switch_channel_t *channel = switch_core_session_get_channel(session); switch_channel_t *channel = switch_core_session_get_channel(session);
switch_size_t has; switch_size_t has;
/* clear resamplers*/ /* clear resamplers */
switch_resample_destroy(&session->read_resampler); switch_resample_destroy(&session->read_resampler);
switch_resample_destroy(&session->write_resampler); switch_resample_destroy(&session->write_resampler);
@ -690,8 +688,7 @@ SWITCH_DECLARE(void) switch_core_session_perform_destroy(switch_core_session_t *
switch_event_t *event; switch_event_t *event;
switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_NOTICE, "Close Channel %s [%s]\n", 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_get_name((*session)->channel), switch_channel_state_name(switch_channel_get_state((*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_ivr_deactivate_unicast(*session);
@ -725,7 +722,7 @@ SWITCH_DECLARE(void) switch_core_session_perform_destroy(switch_core_session_t *
} }
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_core_session_t *session = obj;
switch_event_t *event; switch_event_t *event;
@ -735,7 +732,7 @@ static void *SWITCH_THREAD_FUNC switch_core_session_thread(switch_thread_t * thr
session->thread = thread; session->thread = thread;
switch_core_session_run(session); 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)); session->id, switch_channel_get_name(session->channel));
switch_core_session_write_lock(session); switch_core_session_write_lock(session);
switch_set_flag(session, SSF_DESTROYED); switch_set_flag(session, SSF_DESTROYED);
@ -753,7 +750,7 @@ static void *SWITCH_THREAD_FUNC switch_core_session_thread(switch_thread_t * thr
switch_core_session_rwunlock(session); 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)); session->id, switch_channel_get_name(session->channel));
switch_core_session_destroy(&session); switch_core_session_destroy(&session);
return NULL; return NULL;
@ -1013,7 +1010,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_execute_application(switch_c
} }
SWITCH_DECLARE(switch_status_t) switch_core_session_exec(switch_core_session_t *session, 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_app_log_t *log, *lp;
switch_event_t *event; switch_event_t *event;
const char *var; const char *var;
@ -1028,7 +1026,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_exec(switch_core_session_t *
log->app = switch_core_session_strdup(session, application_interface->interface_name); log->app = switch_core_session_strdup(session, application_interface->interface_name);
log->arg = switch_core_session_strdup(session, arg); 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) { if (lp) {
lp->next = log; lp->next = log;
@ -1060,7 +1058,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_exec(switch_core_session_t *
return SWITCH_STATUS_SUCCESS; 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 *dp[25];
char *dpstr; char *dpstr;
@ -1129,7 +1128,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_execute_exten(switch_core_se
new_profile->caller_extension = extension; new_profile->caller_extension = extension;
if (profile->caller_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) { if (pp) {
pp->next = new_profile; pp->next = new_profile;

View File

@ -38,10 +38,7 @@
SWITCH_DECLARE(switch_status_t) switch_core_speech_open(switch_speech_handle_t *sh, SWITCH_DECLARE(switch_status_t) switch_core_speech_open(switch_speech_handle_t *sh,
const char *module_name, const char *module_name,
const char *voice_name, const char *voice_name,
unsigned int rate, unsigned int rate, unsigned int interval, switch_speech_flag_t *flags, switch_memory_pool_t *pool)
unsigned int interval,
switch_speech_flag_t *flags,
switch_memory_pool_t *pool)
{ {
switch_status_t status; switch_status_t status;
char buf[256] = ""; char buf[256] = "";
@ -130,7 +127,7 @@ SWITCH_DECLARE(void) switch_core_speech_float_param_tts(switch_speech_handle_t *
} }
SWITCH_DECLARE(switch_status_t) switch_core_speech_read_tts(switch_speech_handle_t *sh, 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); switch_assert(sh != NULL);

View File

@ -50,8 +50,7 @@ static void switch_core_standard_on_hangup(switch_core_session_t *session)
static void switch_core_standard_on_reset(switch_core_session_t *session) 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_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Standard RESET %s\n", switch_channel_get_name(session->channel));
switch_channel_get_name(session->channel));
} }
static void switch_core_standard_on_routing(switch_core_session_t *session) static void switch_core_standard_on_routing(switch_core_session_t *session)
@ -320,7 +319,7 @@ SWITCH_DECLARE(void) switch_core_session_run(switch_core_session_t *session)
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Thread has crashed for channel %s\n", switch_channel_get_name(session->channel)); 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); switch_channel_hangup(session->channel, SWITCH_CAUSE_CRASH);
} else { } 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); //apr_hash_set(stack_table, &thread_id, sizeof(thread_id), &env);
} }
} }
@ -405,7 +404,8 @@ SWITCH_DECLARE(void) switch_core_session_run(switch_core_session_t *session)
} }
SWITCH_STANDARD_STREAM(stream); SWITCH_STANDARD_STREAM(stream);
switch_api_execute(cmd, arg, NULL, &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); switch_safe_free(stream.data);
} }
} }

View File

@ -35,7 +35,8 @@
#include <switch.h> #include <switch.h>
#include "private/switch_core_pvt.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_timer_interface_t *timer_interface;
switch_status_t status; switch_status_t status;

View File

@ -59,13 +59,13 @@ static switch_queue_t *EVENT_RECYCLE_QUEUE = NULL;
static switch_queue_t *EVENT_HEADER_RECYCLE_QUEUE = NULL; static switch_queue_t *EVENT_HEADER_RECYCLE_QUEUE = NULL;
static void launch_dispatch_threads(int max, int len, switch_memory_pool_t *pool); 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; size_t len = strlen(s) + 1;
void *new = malloc (len); void *new = malloc(len);
switch_assert(new); switch_assert(new);
return (char *) memcpy (new, s, len); return (char *) memcpy(new, s, len);
} }
#ifndef ALLOC #ifndef ALLOC
@ -172,7 +172,7 @@ static int switch_events_match(switch_event_t *event, switch_event_node_t *node)
return match; 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; switch_queue_t *queue = (switch_queue_t *) obj;
int my_id = 0; int my_id = 0;
@ -186,7 +186,7 @@ static void *SWITCH_THREAD_FUNC switch_event_dispatch_thread(switch_thread_t * t
} }
} }
for(;;) { for (;;) {
void *pop = NULL; void *pop = NULL;
switch_event_t *event = NULL; switch_event_t *event = NULL;
@ -213,7 +213,7 @@ static void *SWITCH_THREAD_FUNC switch_event_dispatch_thread(switch_thread_t * t
} }
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; switch_queue_t *queue = (switch_queue_t *) obj;
int index = 0; int index = 0;
@ -229,7 +229,7 @@ static void *SWITCH_THREAD_FUNC switch_event_thread(switch_thread_t * thread, vo
} }
} }
for(;;) { for (;;) {
void *pop = NULL; void *pop = NULL;
switch_event_t *event = NULL; switch_event_t *event = NULL;
@ -243,7 +243,7 @@ static void *SWITCH_THREAD_FUNC switch_event_thread(switch_thread_t * thread, vo
event = (switch_event_t *) pop; event = (switch_event_t *) pop;
while(event) { while (event) {
for (index = 0; index < SOFT_MAX_DISPATCH; index++) { for (index = 0; index < SOFT_MAX_DISPATCH; index++) {
if (switch_queue_trypush(EVENT_DISPATCH_QUEUE[index], event) == SWITCH_STATUS_SUCCESS) { if (switch_queue_trypush(EVENT_DISPATCH_QUEUE[index], event) == SWITCH_STATUS_SUCCESS) {
event = NULL; event = NULL;
@ -252,9 +252,9 @@ static void *SWITCH_THREAD_FUNC switch_event_thread(switch_thread_t * thread, vo
} }
if (event) { if (event) {
if (SOFT_MAX_DISPATCH+1 < MAX_DISPATCH) { if (SOFT_MAX_DISPATCH + 1 < MAX_DISPATCH) {
switch_mutex_lock(EVENT_QUEUE_MUTEX); switch_mutex_lock(EVENT_QUEUE_MUTEX);
launch_dispatch_threads(SOFT_MAX_DISPATCH+1, DISPATCH_QUEUE_LEN, RUNTIME_POOL); launch_dispatch_threads(SOFT_MAX_DISPATCH + 1, DISPATCH_QUEUE_LEN, RUNTIME_POOL);
switch_mutex_unlock(EVENT_QUEUE_MUTEX); switch_mutex_unlock(EVENT_QUEUE_MUTEX);
} }
} }
@ -371,12 +371,12 @@ SWITCH_DECLARE(switch_status_t) switch_event_shutdown(void)
SYSTEM_RUNNING = 0; SYSTEM_RUNNING = 0;
switch_mutex_unlock(EVENT_QUEUE_MUTEX); 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_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Stopping event queue %d\n", x);
switch_queue_push(EVENT_QUEUE[x], NULL); 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_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Stopping dispatch queue %d\n", x);
switch_queue_push(EVENT_DISPATCH_QUEUE[x], NULL); switch_queue_push(EVENT_DISPATCH_QUEUE[x], NULL);
} }
@ -493,7 +493,7 @@ SWITCH_DECLARE(switch_status_t) switch_event_create_subclass(switch_event_t **ev
if (subclass_name) { if (subclass_name) {
if (!((*event)->subclass = switch_core_hash_find(CUSTOM_HASH, 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); (*event)->subclass = switch_core_hash_find(CUSTOM_HASH, subclass_name);
} }
switch_event_add_header_string(*event, SWITCH_STACK_BOTTOM, "Event-Subclass", subclass_name); switch_event_add_header_string(*event, SWITCH_STACK_BOTTOM, "Event-Subclass", subclass_name);
@ -513,7 +513,8 @@ SWITCH_DECLARE(char *) switch_event_get_header(switch_event_t *event, char *head
{ {
switch_event_header_t *hp; switch_event_header_t *hp;
switch_assert(event); switch_assert(event);
if (!header_name) return NULL; if (!header_name)
return NULL;
for (hp = event->headers; hp; hp = hp->next) { for (hp = event->headers; hp; hp = hp->next) {
if (!strcasecmp(hp->name, header_name)) { if (!strcasecmp(hp->name, header_name)) {
@ -844,7 +845,7 @@ static switch_xml_t add_xml_header(switch_xml_t xml, char *name, char *value, in
return header; 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; switch_event_header_t *hp;
char *data = NULL, *body = NULL; char *data = NULL, *body = NULL;
@ -863,7 +864,8 @@ SWITCH_DECLARE(switch_xml_t) switch_event_xmlize(switch_event_t *event, const ch
ret = vasprintf(&data, fmt, ap); ret = vasprintf(&data, fmt, ap);
#else #else
data = (char *) malloc(2048); data = (char *) malloc(2048);
if (!data) return NULL; if (!data)
return NULL;
ret = vsnprintf(data, 2048, fmt, ap); ret = vsnprintf(data, 2048, fmt, ap);
#endif #endif
va_end(ap); va_end(ap);
@ -935,7 +937,7 @@ SWITCH_DECLARE(switch_status_t) switch_event_fire_detailed(const char *file, con
switch_event_add_header_string(*event, SWITCH_STACK_BOTTOM, "Event-Date-Local", date); switch_event_add_header_string(*event, SWITCH_STACK_BOTTOM, "Event-Date-Local", date);
switch_rfc822_date(date, ts); switch_rfc822_date(date, ts);
switch_event_add_header_string(*event, SWITCH_STACK_BOTTOM, "Event-Date-GMT", date); 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-File", switch_cut_path(file));
switch_event_add_header_string(*event, SWITCH_STACK_BOTTOM, "Event-Calling-Function", func); 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); switch_event_add_header(*event, SWITCH_STACK_BOTTOM, "Event-Calling-Line-Number", "%d", line);
@ -1047,12 +1049,12 @@ SWITCH_DECLARE(char *) switch_event_expand_headers(switch_event_t *event, const
int nv = 0; int nv = 0;
q = in; q = in;
while(q && *q) { while (q && *q) {
if (!(p = strchr(q, '$'))) { if (!(p = strchr(q, '$'))) {
break; break;
} }
if (*(p+1) != '{') { if (*(p + 1) != '{') {
q = p + 1; q = p + 1;
continue; continue;
} }
@ -1062,7 +1064,7 @@ SWITCH_DECLARE(char *) switch_event_expand_headers(switch_event_t *event, const
} }
if (!nv) { if (!nv) {
return (char *)in; return (char *) in;
} }
nv = 0; nv = 0;
@ -1087,8 +1089,8 @@ SWITCH_DECLARE(char *) switch_event_expand_headers(switch_event_t *event, const
} }
if (*p == '$' && !nv) { if (*p == '$' && !nv) {
if (*(p+1)) { if (*(p + 1)) {
if (*(p+1) == '{') { if (*(p + 1) == '{') {
vtype = 1; vtype = 1;
} else { } else {
nv = 1; nv = 1;
@ -1140,12 +1142,12 @@ SWITCH_DECLARE(char *) switch_event_expand_headers(switch_event_t *event, const
if ((vval = strchr(vname, '('))) { if ((vval = strchr(vname, '('))) {
e = vval - 1; e = vval - 1;
*vval++ = '\0'; *vval++ = '\0';
while(*e == ' ') { while (*e == ' ') {
*e-- = '\0'; *e-- = '\0';
} }
e = vval; e = vval;
br = 1; br = 1;
while(e && *e) { while (e && *e) {
if (*e == '(') { if (*e == '(') {
br++; br++;
} else if (br > 1 && *e == ')') { } else if (br > 1 && *e == ')') {
@ -1166,7 +1168,7 @@ SWITCH_DECLARE(char *) switch_event_expand_headers(switch_event_t *event, const
int ooffset = 0; int ooffset = 0;
char *ptr; char *ptr;
if ((expanded = switch_event_expand_headers(event, (char *)vname)) == vname) { if ((expanded = switch_event_expand_headers(event, (char *) vname)) == vname) {
expanded = NULL; expanded = NULL;
} else { } else {
vname = expanded; vname = expanded;
@ -1192,12 +1194,12 @@ SWITCH_DECLARE(char *) switch_event_expand_headers(switch_event_t *event, const
if (offset >= 0) { if (offset >= 0) {
sub_val += offset; 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); sub_val = cloned_sub_val + (strlen(cloned_sub_val) + offset);
} }
if (ooffset > 0 && (size_t)ooffset < strlen(sub_val)) { if (ooffset > 0 && (size_t) ooffset < strlen(sub_val)) {
if ((ptr = (char *)sub_val + ooffset)) { if ((ptr = (char *) sub_val + ooffset)) {
*ptr = '\0'; *ptr = '\0';
} }
} }
@ -1212,7 +1214,7 @@ SWITCH_DECLARE(char *) switch_event_expand_headers(switch_event_t *event, const
if (stream.data) { if (stream.data) {
char *expanded_vname = NULL; 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; expanded_vname = NULL;
} else { } else {
vname = expanded_vname; vname = expanded_vname;
@ -1238,7 +1240,7 @@ SWITCH_DECLARE(char *) switch_event_expand_headers(switch_event_t *event, const
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
free(data); free(data);
free(indup); free(indup);
return (char *)in; return (char *) in;
} }
} }
if ((nlen = sub_val ? strlen(sub_val) : 0)) { if ((nlen = sub_val ? strlen(sub_val) : 0)) {
@ -1281,16 +1283,17 @@ SWITCH_DECLARE(char *) switch_event_expand_headers(switch_event_t *event, const
return data; 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_stream_handle_t stream = { 0 };
switch_size_t encode_len = 1024, new_len = 0; switch_size_t encode_len = 1024, new_len = 0;
char *encode_buf = NULL; 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; char *e = NULL;
switch_event_header_t *hi; switch_event_header_t *hi;
uint32_t x = 0; uint32_t x = 0;
void* data = NULL; void *data = NULL;
SWITCH_STANDARD_STREAM(stream); SWITCH_STANDARD_STREAM(stream);
@ -1330,9 +1333,8 @@ SWITCH_DECLARE(char *) switch_event_build_param_string(switch_event_t *event, co
char *var = hi->name; char *var = hi->name;
char *val = hi->value; char *val = hi->value;
if (vars_map != NULL) if (vars_map != NULL) {
{ if ((data = switch_core_hash_find(vars_map, var)) == NULL || strcasecmp(((char *) data), "enabled"))
if ((data = switch_core_hash_find(vars_map,var)) == NULL || strcasecmp(((char*)data),"enabled"))
continue; continue;
} }

View File

@ -91,12 +91,12 @@ static void *SWITCH_THREAD_FUNC unicast_thread_run(switch_thread_t *thread, void
channel = switch_core_session_get_channel(conninfo->session); 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; len = conninfo->write_frame.buflen;
if (switch_socket_recv(conninfo->socket, conninfo->write_frame.data, &len) != SWITCH_STATUS_SUCCESS || len == 0) { if (switch_socket_recv(conninfo->socket, conninfo->write_frame.data, &len) != SWITCH_STATUS_SUCCESS || len == 0) {
break; break;
} }
conninfo->write_frame.datalen = (uint32_t)len; conninfo->write_frame.datalen = (uint32_t) len;
conninfo->write_frame.samples = conninfo->write_frame.datalen / 2; 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_core_session_write_frame(conninfo->session, &conninfo->write_frame, SWITCH_IO_FLAG_NONE, conninfo->stream_id);
} }
@ -133,7 +133,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_deactivate_unicast(switch_core_sessio
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Shutting down unicast connection\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Shutting down unicast connection\n");
switch_clear_flag_locked(conninfo, SUF_READY); switch_clear_flag_locked(conninfo, SUF_READY);
switch_socket_shutdown(conninfo->socket, SWITCH_SHUTDOWN_READWRITE); 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); switch_yield(10000);
if (++sanity >= 10000) { if (++sanity >= 10000) {
break; break;
@ -151,10 +151,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_deactivate_unicast(switch_core_sessio
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, char *local_ip,
switch_port_t local_port, switch_port_t local_port,
char *remote_ip, char *remote_ip, switch_port_t remote_port, char *transport, char *flags)
switch_port_t remote_port,
char *transport,
char *flags)
{ {
switch_channel_t *channel = switch_core_session_get_channel(session); switch_channel_t *channel = switch_core_session_get_channel(session);
switch_unicast_conninfo_t *conninfo = switch_core_session_alloc(session, sizeof(*conninfo)); switch_unicast_conninfo_t *conninfo = switch_core_session_alloc(session, sizeof(*conninfo));
@ -281,7 +278,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_parse_event(switch_core_session_t *se
int frame_count = atoi(lead_frames); int frame_count = atoi(lead_frames);
int max_frames = frame_count * 2; 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); status = switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
if (!SWITCH_READ_ACCEPTABLE(status)) { if (!SWITCH_READ_ACCEPTABLE(status)) {
goto done; goto done;
@ -384,7 +381,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_parse_event(switch_core_session_t *se
transport = "udp"; 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) { } else if (cmd_hash == CMD_HANGUP) {
char *cause_name = switch_event_get_header(event, "hangup-cause"); char *cause_name = switch_event_get_header(event, "hangup-cause");
@ -504,13 +501,11 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_park(switch_core_session_t *session,
if (switch_test_flag(conninfo, SUF_NATIVE)) { if (switch_test_flag(conninfo, SUF_NATIVE)) {
tstatus = SWITCH_STATUS_NOOP; tstatus = SWITCH_STATUS_NOOP;
} else { } else {
tstatus = switch_core_codec_decode( tstatus = switch_core_codec_decode(read_codec,
read_codec,
&conninfo->read_codec, &conninfo->read_codec,
read_frame->data, read_frame->data,
read_frame->datalen, read_frame->datalen,
read_codec->implementation->actual_samples_per_second, read_codec->implementation->actual_samples_per_second, decoded, &dlen, &rate, &flags);
decoded, &dlen, &rate, &flags);
} }
switch (tstatus) { switch (tstatus) {
case SWITCH_STATUS_NOOP: case SWITCH_STATUS_NOOP:
@ -533,7 +528,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_park(switch_core_session_t *session,
if (tstatus == SWITCH_STATUS_SUCCESS) { if (tstatus == SWITCH_STATUS_SUCCESS) {
len = sendlen; 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); switch_ivr_deactivate_unicast(session);
} }
} }
@ -545,7 +540,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_park(switch_core_session_t *session,
} }
if (switch_channel_has_dtmf(channel)) { if (switch_channel_has_dtmf(channel)) {
switch_dtmf_t dtmf = {0}; switch_dtmf_t dtmf = { 0 };
switch_channel_dequeue_dtmf(channel, &dtmf); switch_channel_dequeue_dtmf(channel, &dtmf);
if (args && args->input_callback) { if (args && args->input_callback) {
if ((status = args->input_callback(session, (void *) &dtmf, SWITCH_INPUT_TYPE_DTMF, args->buf, args->buflen)) != SWITCH_STATUS_SUCCESS) { if ((status = args->input_callback(session, (void *) &dtmf, SWITCH_INPUT_TYPE_DTMF, args->buf, args->buflen)) != SWITCH_STATUS_SUCCESS) {
@ -600,7 +595,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_collect_digits_callback(switch_core_s
while (switch_channel_ready(channel)) { while (switch_channel_ready(channel)) {
switch_frame_t *read_frame = NULL; switch_frame_t *read_frame = NULL;
switch_event_t *event; switch_event_t *event;
switch_dtmf_t dtmf = {0}; switch_dtmf_t dtmf = { 0 };
if (switch_channel_test_flag(channel, CF_BREAK)) { if (switch_channel_test_flag(channel, CF_BREAK)) {
switch_channel_clear_flag(channel, CF_BREAK); switch_channel_clear_flag(channel, CF_BREAK);
@ -621,7 +616,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_collect_digits_callback(switch_core_s
if (switch_channel_has_dtmf(channel)) { if (switch_channel_has_dtmf(channel)) {
switch_channel_dequeue_dtmf(channel, &dtmf); 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) { if (switch_core_session_dequeue_event(session, &event) == SWITCH_STATUS_SUCCESS) {
@ -658,9 +653,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_collect_digits_count(switch_core_sess
switch_size_t buflen, switch_size_t buflen,
switch_size_t maxdigits, switch_size_t maxdigits,
const char *terminators, char *terminator, const char *terminators, char *terminator,
uint32_t first_timeout, uint32_t first_timeout, uint32_t digit_timeout, uint32_t abs_timeout)
uint32_t digit_timeout,
uint32_t abs_timeout)
{ {
switch_size_t i = 0, x = strlen(buf); switch_size_t i = 0, x = strlen(buf);
switch_channel_t *channel = switch_core_session_get_channel(session); switch_channel_t *channel = switch_core_session_get_channel(session);
@ -722,7 +715,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_collect_digits_count(switch_core_sess
} }
if (switch_channel_has_dtmf(channel)) { if (switch_channel_has_dtmf(channel)) {
switch_dtmf_t dtmf = {0}; switch_dtmf_t dtmf = { 0 };
switch_size_t y; switch_size_t y;
if (eff_timeout) { if (eff_timeout) {
@ -947,7 +940,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_nomedia(const char *uuid, switch_medi
return status; 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_channel_t *channel = switch_core_session_get_channel(session);
switch_caller_profile_t *profile, *new_profile; switch_caller_profile_t *profile, *new_profile;
@ -1108,7 +1102,7 @@ struct switch_ivr_digit_stream {
switch_time_t last_digit_time; 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; switch_status_t status = SWITCH_STATUS_FALSE;
@ -1148,7 +1142,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_parser_new(switch_memory
return status; 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; switch_status_t status = SWITCH_STATUS_FALSE;
@ -1166,7 +1160,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_parser_destroy(switch_iv
return status; 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; switch_status_t status = SWITCH_STATUS_FALSE;
@ -1182,7 +1176,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_new(switch_ivr_digit_str
return status; 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; switch_status_t status = SWITCH_STATUS_FALSE;
@ -1195,7 +1189,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_destroy(switch_ivr_digit
return status; 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; switch_status_t status = SWITCH_STATUS_FALSE;
@ -1231,7 +1225,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_parser_set_event(switch_
return status; 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; switch_status_t status = SWITCH_STATUS_FALSE;
@ -1246,7 +1240,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_parser_del_event(switch_
return status; 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; void *result = NULL;
@ -1297,7 +1291,7 @@ SWITCH_DECLARE(void *) switch_ivr_digit_stream_parser_feed(switch_ivr_digit_stre
return result; 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; switch_status_t status = SWITCH_STATUS_FALSE;
@ -1311,7 +1305,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_reset(switch_ivr_digit_s
return status; 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; switch_status_t status = SWITCH_STATUS_FALSE;
@ -1403,7 +1397,8 @@ SWITCH_DECLARE(int) switch_ivr_set_xml_chan_vars(switch_xml_t xml, switch_channe
switch_xml_t variable; switch_xml_t variable;
switch_event_header_t *hi = switch_channel_variable_first(channel); switch_event_header_t *hi = switch_channel_variable_first(channel);
if (!hi) return off; if (!hi)
return off;
for (; hi; hi = hi->next) { 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++)))) { if (!switch_strlen_zero(hi->name) && !switch_strlen_zero(hi->value) && ((variable = switch_xml_add_child_d(xml, hi->name, off++)))) {
@ -1423,7 +1418,7 @@ SWITCH_DECLARE(int) switch_ivr_set_xml_chan_vars(switch_xml_t xml, switch_channe
return off; 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_channel_t *channel = switch_core_session_get_channel(session);
switch_caller_profile_t *caller_profile; switch_caller_profile_t *caller_profile;
@ -1448,7 +1443,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_generate_xml_cdr(switch_core_session_
if (!(x_apps = switch_xml_add_child_d(cdr, "app_log", cdr_off++))) { if (!(x_apps = switch_xml_add_child_d(cdr, "app_log", cdr_off++))) {
goto error; 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++))) { if (!(x_application = switch_xml_add_child_d(x_apps, "application", app_off++))) {
goto error; goto error;
@ -1675,7 +1670,7 @@ SWITCH_DECLARE(void) switch_ivr_delay_echo(switch_core_session_t *session, uint3
write_frame.codec = read_codec; 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); status = switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
if (!SWITCH_READ_ACCEPTABLE(status)) { if (!SWITCH_READ_ACCEPTABLE(status)) {
break; break;
@ -1686,7 +1681,7 @@ SWITCH_DECLARE(void) switch_ivr_delay_echo(switch_core_session_t *session, uint3
if ((jb_frame = stfu_n_read_a_frame(jb))) { if ((jb_frame = stfu_n_read_a_frame(jb))) {
write_frame.data = jb_frame->data; 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); status = switch_core_session_write_frame(session, &write_frame, SWITCH_IO_FLAG_NONE, 0);
if (!SWITCH_READ_ACCEPTABLE(status)) { if (!SWITCH_READ_ACCEPTABLE(status)) {
break; break;
@ -1697,14 +1692,15 @@ SWITCH_DECLARE(void) switch_ivr_delay_echo(switch_core_session_t *session, uint3
stfu_n_destroy(&jb); 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_say_interface_t *si;
switch_status_t status = SWITCH_STATUS_SUCCESS; switch_status_t status = SWITCH_STATUS_SUCCESS;
if ((si = switch_loadable_module_get_say_interface(module_name))) { if ((si = switch_loadable_module_get_say_interface(module_name))) {
// should go back and proto all the say mods to const.... // 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 { } else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid SAY Interface [%s]!\n", module_name); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid SAY Interface [%s]!\n", module_name);
status = SWITCH_STATUS_FALSE; status = SWITCH_STATUS_FALSE;

View File

@ -48,7 +48,7 @@ static void *SWITCH_THREAD_FUNC echo_video_thread(switch_thread_t *thread, void
switch_frame_t *read_frame; switch_frame_t *read_frame;
eh->up = 1; eh->up = 1;
while(switch_channel_ready(channel)) { while (switch_channel_ready(channel)) {
status = switch_core_session_read_video_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0); status = switch_core_session_read_video_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
if (!SWITCH_READ_ACCEPTABLE(status)) { if (!SWITCH_READ_ACCEPTABLE(status)) {
@ -73,7 +73,7 @@ SWITCH_DECLARE(void) switch_ivr_session_echo(switch_core_session_t *session)
switch_frame_t *read_frame; switch_frame_t *read_frame;
switch_channel_t *channel = switch_core_session_get_channel(session); switch_channel_t *channel = switch_core_session_get_channel(session);
#ifdef SWITCH_VIDEO_IN_THREADS #ifdef SWITCH_VIDEO_IN_THREADS
struct echo_helper eh = {0}; struct echo_helper eh = { 0 };
switch_thread_t *thread; switch_thread_t *thread;
switch_threadattr_t *thd_attr = NULL; switch_threadattr_t *thd_attr = NULL;
#endif #endif
@ -90,7 +90,7 @@ SWITCH_DECLARE(void) switch_ivr_session_echo(switch_core_session_t *session)
} }
#endif #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); status = switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
if (!SWITCH_READ_ACCEPTABLE(status)) { if (!SWITCH_READ_ACCEPTABLE(status)) {
break; break;
@ -115,7 +115,7 @@ SWITCH_DECLARE(void) switch_ivr_session_echo(switch_core_session_t *session)
#ifdef SWITCH_VIDEO_IN_THREADS #ifdef SWITCH_VIDEO_IN_THREADS
if (eh.up) { if (eh.up) {
while(eh.up) { while (eh.up) {
switch_yield(1000); switch_yield(1000);
} }
} }
@ -166,7 +166,7 @@ static switch_bool_t write_displace_callback(switch_media_bug_t *bug, void *user
st = switch_core_file_read(&dh->fh, buf, &len); 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]; int32_t mixed = fp[x] + buf[x];
switch_normalize_to_16bit(mixed); switch_normalize_to_16bit(mixed);
fp[x] = (int16_t) mixed; fp[x] = (int16_t) mixed;
@ -233,7 +233,7 @@ static switch_bool_t read_displace_callback(switch_media_bug_t *bug, void *user_
st = switch_core_file_read(&dh->fh, buf, &len); 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]; int32_t mixed = fp[x] + buf[x];
switch_normalize_to_16bit(mixed); switch_normalize_to_16bit(mixed);
fp[x] = (int16_t) mixed; fp[x] = (int16_t) mixed;
@ -307,8 +307,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_displace_session(switch_core_session_
file, file,
read_codec->implementation->number_of_channels, read_codec->implementation->number_of_channels,
read_codec->implementation->actual_samples_per_second, read_codec->implementation->actual_samples_per_second,
SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL) != SWITCH_STATUS_SUCCESS) {
NULL) != SWITCH_STATUS_SUCCESS) {
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
switch_core_session_reset(session, SWITCH_TRUE); switch_core_session_reset(session, SWITCH_TRUE);
return SWITCH_STATUS_GENERR; return SWITCH_STATUS_GENERR;
@ -452,7 +451,7 @@ static switch_bool_t eavesdrop_callback(switch_media_bug_t *bug, void *user_data
switch_buffer_lock(ep->r_buffer); switch_buffer_lock(ep->r_buffer);
bytes = (uint32_t) switch_buffer_read(ep->r_buffer, data, rframe->datalen); 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; rframe->samples = rframe->datalen / 2;
switch_buffer_unlock(ep->r_buffer); switch_buffer_unlock(ep->r_buffer);
@ -472,7 +471,7 @@ static switch_bool_t eavesdrop_callback(switch_media_bug_t *bug, void *user_data
switch_buffer_lock(ep->w_buffer); switch_buffer_lock(ep->w_buffer);
bytes = (uint32_t) switch_buffer_read(ep->w_buffer, data, rframe->datalen); 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; rframe->samples = rframe->datalen / 2;
switch_buffer_unlock(ep->w_buffer); switch_buffer_unlock(ep->w_buffer);
@ -490,9 +489,7 @@ static switch_bool_t eavesdrop_callback(switch_media_bug_t *bug, void *user_data
} }
SWITCH_DECLARE(switch_status_t) switch_ivr_eavesdrop_session(switch_core_session_t *session, SWITCH_DECLARE(switch_status_t) switch_ivr_eavesdrop_session(switch_core_session_t *session,
const char *uuid, const char *uuid, const char *require_group, switch_eavesdrop_flag_t flags)
const char *require_group,
switch_eavesdrop_flag_t flags)
{ {
switch_core_session_t *tsession; switch_core_session_t *tsession;
switch_status_t status = SWITCH_STATUS_FALSE; switch_status_t status = SWITCH_STATUS_FALSE;
@ -504,8 +501,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_eavesdrop_session(switch_core_session
switch_media_bug_t *bug = NULL; switch_media_bug_t *bug = NULL;
switch_channel_t *tchannel = switch_core_session_get_channel(tsession); switch_channel_t *tchannel = switch_core_session_get_channel(tsession);
switch_frame_t *read_frame, write_frame = { 0 }; switch_frame_t *read_frame, write_frame = { 0 };
switch_codec_t codec = {0}; switch_codec_t codec = { 0 };
int16_t buf[SWITCH_RECOMMENDED_BUFFER_SIZE/2]; int16_t buf[SWITCH_RECOMMENDED_BUFFER_SIZE / 2];
switch_codec_t *tread_codec = switch_core_session_get_read_codec(tsession); switch_codec_t *tread_codec = switch_core_session_get_read_codec(tsession);
uint32_t tlen; uint32_t tlen;
const char *macro_name = "eavesdrop_announce"; const char *macro_name = "eavesdrop_announce";
@ -584,7 +581,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_eavesdrop_session(switch_core_session
goto end; 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); uint32_t len = sizeof(buf);
switch_event_t *event = NULL; switch_event_t *event = NULL;
char *fcommand = NULL; char *fcommand = NULL;
@ -605,7 +602,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_eavesdrop_session(switch_core_session
} }
if ((flags & ED_DTMF) && switch_channel_has_dtmf(channel)) { 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); switch_channel_dequeue_dtmf(channel, &dtmf);
db[0] = dtmf.digit; db[0] = dtmf.digit;
fcommand = db; fcommand = db;
@ -613,7 +610,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_eavesdrop_session(switch_core_session
if (fcommand) { if (fcommand) {
char *d; char *d;
for(d = fcommand; *d; d++) { for (d = fcommand; *d; d++) {
int z = 1; int z = 1;
switch (*d) { switch (*d) {
@ -674,7 +671,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_eavesdrop_session(switch_core_session
if (switch_buffer_inuse(ep->buffer) >= len) { if (switch_buffer_inuse(ep->buffer) >= len) {
switch_buffer_lock(ep->buffer); switch_buffer_lock(ep->buffer);
while (switch_buffer_inuse(ep->buffer) >= len) { 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; 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) { if ((status = switch_core_session_write_frame(session, &write_frame, SWITCH_IO_FLAG_NONE, 0)) != SWITCH_STATUS_SUCCESS) {
break; break;
@ -842,7 +839,7 @@ static switch_bool_t inband_dtmf_callback(switch_media_bug_t *bug, void *user_da
teletone_dtmf_get(&pvt->dtmf_detect, digit_str, sizeof(digit_str)); teletone_dtmf_get(&pvt->dtmf_detect, digit_str, sizeof(digit_str));
if (digit_str[0]) { if (digit_str[0]) {
char *p = digit_str; char *p = digit_str;
while(p && *p) { while (p && *p) {
switch_dtmf_t dtmf; switch_dtmf_t dtmf;
dtmf.digit = *p; dtmf.digit = *p;
dtmf.duration = switch_core_default_dtmf_duration(0); dtmf.duration = switch_core_default_dtmf_duration(0);
@ -913,7 +910,7 @@ typedef struct {
int ready; int ready;
} switch_inband_dtmf_generate_t; } 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; switch_buffer_t *audio_buffer = ts->user_data;
int wrote; int wrote;
@ -1108,7 +1105,7 @@ typedef struct {
} switch_tone_detect_t; } switch_tone_detect_t;
typedef struct { typedef struct {
switch_tone_detect_t list[MAX_TONES+1]; switch_tone_detect_t list[MAX_TONES + 1];
int index; int index;
switch_media_bug_t *bug; switch_media_bug_t *bug;
switch_core_session_t *session; switch_core_session_t *session;
@ -1134,7 +1131,7 @@ static switch_bool_t tone_detect_callback(switch_media_bug_t *bug, void *user_da
frame = switch_core_media_bug_get_write_replace_frame(bug); 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)) { if (cont->list[i].up && teletone_multi_tone_detect(&cont->list[i].mt, frame->data, frame->samples)) {
switch_event_t *event; switch_event_t *event;
@ -1191,8 +1188,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_stop_tone_detect_session(switch_core_
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 *key, const char *tone_spec,
const char *flags, time_t timeout, const char *flags, time_t timeout, const char *app, const char *data)
const char *app, const char *data)
{ {
switch_channel_t *channel = switch_core_session_get_channel(session); switch_channel_t *channel = switch_core_session_get_channel(session);
switch_codec_t *read_codec = switch_core_session_get_read_codec(session); switch_codec_t *read_codec = switch_core_session_get_read_codec(session);
@ -1215,7 +1211,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_tone_detect_session(switch_core_sessi
return SWITCH_STATUS_FALSE; return SWITCH_STATUS_FALSE;
} }
for(i = 0; i < cont->index; i++) { for (i = 0; i < cont->index; i++) {
if (!switch_strlen_zero(cont->list[cont->index].key) && !strcasecmp(key, cont->list[cont->index].key)) { 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); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Re-enabling %s\n", key);
cont->list[cont->index].up = 1; cont->list[cont->index].up = 1;
@ -1242,7 +1238,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_tone_detect_session(switch_core_sessi
do { do {
teletone_process_t this; teletone_process_t this;
next = strchr(p, ','); next = strchr(p, ',');
while(*p == ' ') p++; while (*p == ' ')
p++;
if ((this = (teletone_process_t) atof(p))) { if ((this = (teletone_process_t) atof(p))) {
ok++; ok++;
cont->list[cont->index].map.freqs[i++] = this; cont->list[cont->index].map.freqs[i++] = this;
@ -1470,7 +1467,7 @@ struct speech_thread_handle {
switch_memory_pool_t *pool; 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; struct speech_thread_handle *sth = (struct speech_thread_handle *) obj;
switch_channel_t *channel = switch_core_session_get_channel(sth->session); switch_channel_t *channel = switch_core_session_get_channel(sth->session);
@ -1659,10 +1656,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_detect_speech_unload_grammar(switch_c
SWITCH_DECLARE(switch_status_t) switch_ivr_detect_speech(switch_core_session_t *session, SWITCH_DECLARE(switch_status_t) switch_ivr_detect_speech(switch_core_session_t *session,
const char *mod_name, const char *mod_name,
const char *grammar, const char *grammar, const char *path, const char *dest, switch_asr_handle_t *ah)
const char *path,
const char *dest,
switch_asr_handle_t *ah)
{ {
switch_channel_t *channel = switch_core_session_get_channel(session); switch_channel_t *channel = switch_core_session_get_channel(session);
switch_codec_t *read_codec = switch_core_session_get_read_codec(session); switch_codec_t *read_codec = switch_core_session_get_read_codec(session);
@ -1816,7 +1810,7 @@ SWITCH_DECLARE(uint32_t) switch_ivr_schedule_transfer(time_t runtime, const char
} }
switch_zmalloc(cur, len); 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)); switch_copy_string(helper->uuid_str, uuid, sizeof(helper->uuid_str));
@ -1864,7 +1858,7 @@ SWITCH_DECLARE(uint32_t) switch_ivr_schedule_broadcast(time_t runtime, char *uui
char *cur = NULL; char *cur = NULL;
switch_zmalloc(cur, len); switch_zmalloc(cur, len);
helper = (struct broadcast_helper *)cur; helper = (struct broadcast_helper *) cur;
cur += sizeof(*helper); cur += sizeof(*helper);
switch_copy_string(helper->uuid_str, uuid, sizeof(helper->uuid_str)); switch_copy_string(helper->uuid_str, uuid, sizeof(helper->uuid_str));
@ -1915,7 +1909,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_broadcast(const char *uuid, const cha
switch_ivr_media(uuid, SMF_REBRIDGE); switch_ivr_media(uuid, SMF_REBRIDGE);
} }
if ((p = strchr(mypath, ':')) && *(p+1) == ':') { if ((p = strchr(mypath, ':')) && *(p + 1) == ':') {
app = mypath; app = mypath;
*p++ = '\0'; *p++ = '\0';
*p++ = '\0'; *p++ = '\0';

View File

@ -51,7 +51,7 @@ static void *SWITCH_THREAD_FUNC video_bridge_thread(switch_thread_t *thread, voi
switch_frame_t *read_frame; switch_frame_t *read_frame;
vh->up = 1; vh->up = 1;
while(switch_channel_ready(channel) && 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); status = switch_core_session_read_video_frame(vh->session_a, &read_frame, SWITCH_IO_FLAG_NONE, 0);
if (!SWITCH_READ_ACCEPTABLE(status)) { if (!SWITCH_READ_ACCEPTABLE(status)) {
@ -86,7 +86,7 @@ struct switch_ivr_bridge_data {
}; };
typedef struct switch_ivr_bridge_data switch_ivr_bridge_data_t; 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; switch_ivr_bridge_data_t *data = obj;
int stream_id = 0, pre_b = 0, ans_a = 0, ans_b = 0, originator = 0; int stream_id = 0, pre_b = 0, ans_a = 0, ans_b = 0, originator = 0;
@ -176,7 +176,6 @@ static void *audio_bridge_thread(switch_thread_t * thread, void *obj)
} }
continue; continue;
} }
#ifdef SWITCH_VIDEO_IN_THREADS #ifdef SWITCH_VIDEO_IN_THREADS
if (switch_channel_test_flag(chan_a, CF_VIDEO) && switch_channel_test_flag(chan_b, CF_VIDEO) && !vid_launch) { if (switch_channel_test_flag(chan_a, CF_VIDEO) && switch_channel_test_flag(chan_b, CF_VIDEO) && !vid_launch) {
vid_launch++; vid_launch++;
@ -193,7 +192,7 @@ static void *audio_bridge_thread(switch_thread_t * thread, void *obj)
int send_dtmf = 1; int send_dtmf = 1;
if (input_callback) { 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) { if (cb_status == SWITCH_STATUS_IGNORE) {
send_dtmf = 0; send_dtmf = 0;
@ -250,7 +249,6 @@ static void *audio_bridge_thread(switch_thread_t * thread, void *obj)
continue; continue;
} }
} }
#ifndef SWITCH_VIDEO_IN_THREADS #ifndef SWITCH_VIDEO_IN_THREADS
if (switch_channel_test_flag(chan_a, CF_VIDEO) && switch_channel_test_flag(chan_b, CF_VIDEO)) { 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 */ /* read video from 1 channel and write it to the other */
@ -292,7 +290,7 @@ static void *audio_bridge_thread(switch_thread_t * thread, void *obj)
if (vh.up) { if (vh.up) {
vh.up = -1; vh.up = -1;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Ending video thread.\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Ending video thread.\n");
while(vh.up) { while (vh.up) {
switch_yield(100000); switch_yield(100000);
} }
} }
@ -448,8 +446,7 @@ static switch_status_t uuid_bridge_on_soft_execute(switch_core_session_t *sessio
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
if ((other_uuid = switch_channel_get_variable(channel, SWITCH_UUID_BRIDGE)) && if ((other_uuid = switch_channel_get_variable(channel, SWITCH_UUID_BRIDGE)) && (other_session = switch_core_session_locate(other_uuid))) {
(other_session = switch_core_session_locate(other_uuid))) {
switch_channel_t *other_channel = switch_core_session_get_channel(other_session); switch_channel_t *other_channel = switch_core_session_get_channel(other_session);
switch_event_t *event; switch_event_t *event;
uint8_t ready_a, ready_b; uint8_t ready_a, ready_b;
@ -524,8 +521,8 @@ static const switch_state_handler_table_t uuid_bridge_state_handlers = {
/*.on_exchange_media */ NULL, /*.on_exchange_media */ NULL,
/*.on_soft_execute */ uuid_bridge_on_soft_execute, /*.on_soft_execute */ uuid_bridge_on_soft_execute,
/*.on_consume_media */ NULL, /*.on_consume_media */ NULL,
/*.on_hibernate*/ NULL, /*.on_hibernate */ NULL,
/*.on_reset*/ uuid_bridge_on_reset /*.on_reset */ uuid_bridge_on_reset
}; };
static switch_status_t signal_bridge_on_hibernate(switch_core_session_t *session) static switch_status_t signal_bridge_on_hibernate(switch_core_session_t *session)

View File

@ -39,7 +39,7 @@ static switch_status_t originate_on_consume_media_transmit(switch_core_session_t
switch_channel_t *channel = switch_core_session_get_channel(session); switch_channel_t *channel = switch_core_session_get_channel(session);
if (!switch_channel_test_flag(channel, CF_PROXY_MODE)) { 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_ivr_sleep(session, 10);
} }
} }
@ -81,7 +81,7 @@ struct key_collect {
switch_core_session_t *session; 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; struct key_collect *collect = (struct key_collect *) obj;
switch_channel_t *channel = switch_core_session_get_channel(collect->session); switch_channel_t *channel = switch_core_session_get_channel(collect->session);
@ -166,7 +166,8 @@ static void launch_collect_thread(struct key_collect *collect)
static uint8_t check_channel_status(switch_channel_t **peer_channels, static uint8_t check_channel_status(switch_channel_t **peer_channels,
switch_core_session_t **peer_sessions, 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; uint32_t i;
@ -184,8 +185,7 @@ static uint8_t check_channel_status(switch_channel_t **peer_channels,
state = switch_channel_get_state(peer_channels[i]); state = switch_channel_get_state(peer_channels[i]);
if (state >= CS_HANGUP || state == CS_RESET || switch_channel_test_flag(peer_channels[i], CF_TRANSFER) || 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_BRIDGED) || !switch_channel_test_flag(peer_channels[i], CF_ORIGINATING)
!switch_channel_test_flag(peer_channels[i], CF_ORIGINATING)
) { ) {
(*hups)++; (*hups)++;
} else if ((switch_channel_test_flag(peer_channels[i], CF_ANSWERED) || } else if ((switch_channel_test_flag(peer_channels[i], CF_ANSWERED) ||
@ -236,7 +236,7 @@ struct ringback {
typedef struct ringback ringback_t; 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; ringback_t *tto = ts->user_data;
int wrote; int wrote;
@ -342,8 +342,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_wait_for_answer(switch_core_session_t
ringback_data, ringback_data,
read_codec->implementation->number_of_channels, read_codec->implementation->number_of_channels,
read_codec->implementation->actual_samples_per_second, read_codec->implementation->actual_samples_per_second,
SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL) != SWITCH_STATUS_SUCCESS) {
NULL) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Playing File\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Playing File\n");
switch_safe_free(tmp_data); switch_safe_free(tmp_data);
goto done; goto done;
@ -370,8 +369,9 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_wait_for_answer(switch_core_session_t
} }
} }
while (switch_channel_ready(peer_channel) && !(switch_channel_test_flag(peer_channel, CF_ANSWERED) || switch_channel_test_flag(peer_channel, CF_EARLY_MEDIA))) { while (switch_channel_ready(peer_channel)
int diff = (int)(switch_timestamp_now() - start); && !(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) { if (diff > timelimit) {
status = SWITCH_STATUS_TIMEOUT; status = SWITCH_STATUS_TIMEOUT;
@ -463,8 +463,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
const switch_state_handler_table_t *table, const switch_state_handler_table_t *table,
const char *cid_name_override, const char *cid_name_override,
const char *cid_num_override, const char *cid_num_override,
switch_caller_profile_t *caller_profile_override, switch_caller_profile_t *caller_profile_override, switch_originate_flag_t flags)
switch_originate_flag_t flags)
{ {
switch_originate_flag_t myflags = SOF_NONE; switch_originate_flag_t myflags = SOF_NONE;
char *pipe_names[MAX_PEERS] = { 0 }; char *pipe_names[MAX_PEERS] = { 0 };
@ -558,32 +557,32 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
if ((hi = switch_channel_variable_first(caller_channel))) { if ((hi = switch_channel_variable_first(caller_channel))) {
for (; hi; hi = hi->next) { for (; hi; hi = hi->next) {
int ok = 0; int ok = 0;
if (!strcasecmp((char *)hi->name, "group_confirm_key")) { if (!strcasecmp((char *) hi->name, "group_confirm_key")) {
ok = 1; ok = 1;
} else if (!strcasecmp((char *)hi->name, "group_confirm_file")) { } else if (!strcasecmp((char *) hi->name, "group_confirm_file")) {
ok = 1; ok = 1;
} else if (!strcasecmp((char *)hi->name, "forked_dial")) { } else if (!strcasecmp((char *) hi->name, "forked_dial")) {
ok = 1; ok = 1;
} else if (!strcasecmp((char *)hi->name, "fail_on_single_reject")) { } else if (!strcasecmp((char *) hi->name, "fail_on_single_reject")) {
ok = 1; ok = 1;
} else if (!strcasecmp((char *)hi->name, "ignore_early_media")) { } else if (!strcasecmp((char *) hi->name, "ignore_early_media")) {
ok = 1; ok = 1;
} else if (!strcasecmp((char *)hi->name, "return_ring_ready")) { } else if (!strcasecmp((char *) hi->name, "return_ring_ready")) {
ok = 1; ok = 1;
} else if (!strcasecmp((char *)hi->name, "originate_retries")) { } else if (!strcasecmp((char *) hi->name, "originate_retries")) {
ok = 1; ok = 1;
} else if (!strcasecmp((char *)hi->name, "originate_timeout")) { } else if (!strcasecmp((char *) hi->name, "originate_timeout")) {
ok = 1; ok = 1;
} else if (!strcasecmp((char *)hi->name, "originate_retry_sleep_ms")) { } else if (!strcasecmp((char *) hi->name, "originate_retry_sleep_ms")) {
ok = 1; ok = 1;
} else if (!strcasecmp((char *)hi->name, "origination_caller_id_name")) { } else if (!strcasecmp((char *) hi->name, "origination_caller_id_name")) {
ok = 1; ok = 1;
} else if (!strcasecmp((char *)hi->name, "origination_caller_id_number")) { } else if (!strcasecmp((char *) hi->name, "origination_caller_id_number")) {
ok = 1; ok = 1;
} }
if (ok) { 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); switch_channel_variable_last(caller_channel);
@ -609,7 +608,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
for (x = 0; x < var_count; x++) { for (x = 0; x < var_count; x++) {
char *inner_var_array[2] = { 0 }; char *inner_var_array[2] = { 0 };
int inner_var_count; 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 = if ((inner_var_count =
switch_separate_string(var_array[x], '=', inner_var_array, (sizeof(inner_var_array) / sizeof(inner_var_array[0])))) == 2) { switch_separate_string(var_array[x], '=', inner_var_array, (sizeof(inner_var_array) / sizeof(inner_var_array[0])))) == 2) {
@ -801,10 +800,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
new_profile = switch_caller_profile_new(pool, new_profile = switch_caller_profile_new(pool,
NULL, NULL,
NULL, NULL,
cid_name_override, cid_name_override, cid_num_override, NULL, NULL, NULL, NULL, __FILE__, NULL, chan_data);
cid_num_override,
NULL, NULL, NULL, NULL, __FILE__, NULL,
chan_data);
} }
} }
@ -821,9 +817,11 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
myflags |= SOF_FORKED_DIAL; 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) { if ((reason =
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot create outgoing channel of type [%s] cause: [%s]\n", switch_core_session_outgoing_channel(session, var_event, chan_type, new_profile, &new_session, &pool,
chan_type, switch_channel_cause2str(reason)); 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) { if (pool) {
switch_core_destroy_memory_pool(&pool); switch_core_destroy_memory_pool(&pool);
} }
@ -962,7 +960,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
"Raw Codec Activation Success L16@%uhz 1 channel %dms\n", "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.codec = &write_codec;
write_frame.datalen = read_codec->implementation->bytes_per_frame; write_frame.datalen = read_codec->implementation->bytes_per_frame;
write_frame.samples = write_frame.datalen / 2; write_frame.samples = write_frame.datalen / 2;
@ -995,8 +994,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
ringback_data, ringback_data,
read_codec->implementation->number_of_channels, read_codec->implementation->number_of_channels,
read_codec->implementation->actual_samples_per_second, read_codec->implementation->actual_samples_per_second,
SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL) != SWITCH_STATUS_SUCCESS) {
NULL) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Playing File\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Playing File\n");
switch_safe_free(tmp_data); switch_safe_free(tmp_data);
goto notready; goto notready;
@ -1038,7 +1036,6 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
switch_channel_ring_ready(caller_channel); switch_channel_ring_ready(caller_channel);
sent_ring = 1; 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. // 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)) if ((to = (uint8_t) ((switch_timestamp(NULL) - start) >= (time_t) timelimit_sec))
|| (fail_on_single_reject && hups)) { || (fail_on_single_reject && hups)) {
@ -1063,7 +1060,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
if (session && if (session &&
!switch_channel_test_flag(caller_channel, CF_PROXY_MODE) && !switch_channel_test_flag(caller_channel, CF_PROXY_MODE) &&
!switch_channel_test_flag(caller_channel, CF_PROXY_MEDIA) && !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)))) { (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); switch_status_t tstatus = switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
@ -1132,8 +1130,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
} }
if (switch_channel_test_flag(peer_channels[i], CF_TRANSFER) || switch_channel_test_flag(peer_channels[i], CF_BRIDGED) || 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_get_state(peer_channels[i]) == CS_RESET || !switch_channel_test_flag(peer_channels[i], CF_ORIGINATING)
!switch_channel_test_flag(peer_channels[i], CF_ORIGINATING)
) { ) {
continue; continue;
} }

View File

@ -278,7 +278,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_phrase_macro(switch_core_session_t *s
cmd_args = switch_separate_paren_args(cmd); cmd_args = switch_separate_paren_args(cmd);
if (!cmd_args ) { if (!cmd_args) {
cmd_args = ""; cmd_args = "";
} }
@ -293,7 +293,9 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_phrase_macro(switch_core_session_t *s
char *say_type = (char *) switch_xml_attr_soft(action, "type"); char *say_type = (char *) switch_xml_attr_soft(action, "type");
char *say_method = (char *) switch_xml_attr_soft(action, "method"); 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 { } else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid SAY Interface [%s]!\n", module_name); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid SAY Interface [%s]!\n", module_name);
} }
@ -360,7 +362,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_record_file(switch_core_session_t *se
switch_file_handle_t *fh, const char *file, switch_input_args_t *args, uint32_t limit) 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_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_file_handle_t lfh = { 0 };
switch_frame_t *read_frame; switch_frame_t *read_frame;
switch_codec_t codec, *read_codec = switch_core_session_get_read_codec(session); switch_codec_t codec, *read_codec = switch_core_session_get_read_codec(session);
@ -463,7 +465,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_record_file(switch_core_session_t *se
org_silence_hits = fh->silence_hits; org_silence_hits = fh->silence_hits;
} }
for(;;) { for (;;) {
switch_size_t len; switch_size_t len;
if (!switch_channel_ready(channel)) { if (!switch_channel_ready(channel)) {
@ -497,9 +499,9 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_record_file(switch_core_session_t *se
} }
switch_channel_dequeue_dtmf(channel, &dtmf); switch_channel_dequeue_dtmf(channel, &dtmf);
if (args->input_callback) { 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 { } 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; status = SWITCH_STATUS_BREAK;
} }
} }
@ -571,7 +573,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_record_file(switch_core_session_t *se
return status; 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; switch_buffer_t *audio_buffer = ts->user_data;
int wrote; int wrote;
@ -589,7 +591,7 @@ static int teletone_handler(teletone_generation_session_t * ts, teletone_tone_ma
SWITCH_DECLARE(switch_status_t) switch_ivr_gentones(switch_core_session_t *session, char *script, int32_t loops, 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)
{ {
teletone_generation_session_t ts; teletone_generation_session_t ts;
switch_dtmf_t dtmf = {0}; switch_dtmf_t dtmf = { 0 };
switch_buffer_t *audio_buffer; switch_buffer_t *audio_buffer;
switch_frame_t *read_frame = NULL; switch_frame_t *read_frame = NULL;
switch_codec_t *read_codec = NULL, write_codec = { 0 }; switch_codec_t *read_codec = NULL, write_codec = { 0 };
@ -624,7 +626,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_gentones(switch_core_session_t *sessi
switch_buffer_set_loops(audio_buffer, loops); switch_buffer_set_loops(audio_buffer, loops);
} }
for(;;) { for (;;) {
int done = 0; int done = 0;
switch_status_t status; switch_status_t status;
@ -658,9 +660,9 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_gentones(switch_core_session_t *sessi
} }
switch_channel_dequeue_dtmf(channel, &dtmf); switch_channel_dequeue_dtmf(channel, &dtmf);
if (args->input_callback) { 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 { } else {
*((char *)args->buf) = dtmf.digit; *((char *) args->buf) = dtmf.digit;
status = SWITCH_STATUS_BREAK; status = SWITCH_STATUS_BREAK;
} }
} }
@ -680,8 +682,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_gentones(switch_core_session_t *sessi
} }
} }
if ((write_frame.datalen = (uint32_t) switch_buffer_read_loop(audio_buffer, write_frame.data, if ((write_frame.datalen = (uint32_t) switch_buffer_read_loop(audio_buffer, write_frame.data, read_codec->implementation->bytes_per_frame)) <= 0) {
read_codec->implementation->bytes_per_frame)) <= 0) {
break; break;
} }
@ -708,7 +709,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess
{ {
switch_channel_t *channel = switch_core_session_get_channel(session); switch_channel_t *channel = switch_core_session_get_channel(session);
int16_t *abuf = NULL; 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 interval = 0, samples = 0, framelen, sample_start = 0;
uint32_t ilen = 0; uint32_t ilen = 0;
switch_size_t olen = 0, llen = 0; switch_size_t olen = 0, llen = 0;
@ -779,8 +780,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess
return switch_ivr_speak_text(session, engine, voice, text, args); return switch_ivr_speak_text(session, engine, voice, text, args);
} else if (!switch_strlen_zero(engine) && !(voice && text)) { } else if (!switch_strlen_zero(engine) && !(voice && text)) {
text = engine; text = engine;
engine = (char *)switch_channel_get_variable(channel, "tts_engine"); engine = (char *) switch_channel_get_variable(channel, "tts_engine");
voice = (char *)switch_channel_get_variable(channel, "tts_voice"); voice = (char *) switch_channel_get_variable(channel, "tts_voice");
if (engine && text) { if (engine && text) {
return switch_ivr_speak_text(session, engine, voice, text, args); return switch_ivr_speak_text(session, engine, voice, text, args);
} }
@ -946,7 +947,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess
ilen = samples; ilen = samples;
for(;;) { for (;;) {
int done = 0; int done = 0;
int do_speed = 1; int do_speed = 1;
int last_speed = -1; int last_speed = -1;
@ -979,9 +980,9 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess
} }
switch_channel_dequeue_dtmf(channel, &dtmf); switch_channel_dequeue_dtmf(channel, &dtmf);
if (args->input_callback) { 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 { } else {
*((char *)args->buf) = dtmf.digit; *((char *) args->buf) = dtmf.digit;
status = SWITCH_STATUS_BREAK; status = SWITCH_STATUS_BREAK;
} }
} }
@ -1099,10 +1100,10 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess
olen = llen; olen = llen;
} }
write_frame.samples = (uint32_t)olen; write_frame.samples = (uint32_t) olen;
if (asis) { if (asis) {
write_frame.datalen = (uint32_t)olen; write_frame.datalen = (uint32_t) olen;
} else { } else {
write_frame.datalen = write_frame.samples * 2; write_frame.datalen = write_frame.samples * 2;
} }
@ -1197,10 +1198,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_read(switch_core_session_t *session,
uint32_t max_digits, uint32_t max_digits,
const char *prompt_audio_file, const char *prompt_audio_file,
const char *var_name, const char *var_name,
char *digit_buffer, char *digit_buffer, switch_size_t digit_buffer_length, uint32_t timeout, const char *valid_terminators)
switch_size_t digit_buffer_length,
uint32_t timeout,
const char *valid_terminators)
{ {
switch_channel_t *channel; switch_channel_t *channel;
switch_input_args_t args = { 0 }; switch_input_args_t args = { 0 };
@ -1221,7 +1219,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_read(switch_core_session_t *session,
memset(digit_buffer, 0, digit_buffer_length); memset(digit_buffer, 0, digit_buffer_length);
args.buf = digit_buffer; 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")) { if (!switch_strlen_zero(prompt_audio_file) && strcasecmp(prompt_audio_file, "silence")) {
status = switch_ivr_play_file(session, NULL, prompt_audio_file, &args); status = switch_ivr_play_file(session, NULL, prompt_audio_file, &args);
@ -1236,7 +1234,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_read(switch_core_session_t *session,
if (len < min_digits && len < max_digits) { if (len < min_digits && len < max_digits) {
args.buf = digit_buffer + len; 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); status = switch_ivr_collect_digits_count(session, digit_buffer, digit_buffer_length, max_digits, valid_terminators, &terminator, timeout, 0, 0);
} }
@ -1370,7 +1368,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_speak_text_handle(switch_core_session
{ {
switch_channel_t *channel = switch_core_session_get_channel(session); switch_channel_t *channel = switch_core_session_get_channel(session);
short abuf[960]; short abuf[960];
switch_dtmf_t dtmf = {0}; switch_dtmf_t dtmf = { 0 };
uint32_t len = 0; uint32_t len = 0;
switch_size_t ilen = 0; switch_size_t ilen = 0;
switch_frame_t write_frame = { 0 }; switch_frame_t write_frame = { 0 };
@ -1408,7 +1406,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_speak_text_handle(switch_core_session
poundlen = strlen(pound); poundlen = strlen(pound);
for(p = text; p && *p; p++) { for (p = text; p && *p; p++) {
if (*p == '*') { if (*p == '*') {
extra += starlen; extra += starlen;
} else if (*p == '#') { } else if (*p == '#') {
@ -1466,7 +1464,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_speak_text_handle(switch_core_session
} }
ilen = len; ilen = len;
for(;;) { for (;;) {
switch_event_t *event; switch_event_t *event;
if (!switch_channel_ready(channel)) { if (!switch_channel_ready(channel)) {
@ -1727,7 +1725,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_speak_text(switch_core_session_t *ses
if (need_create) { if (need_create) {
if (switch_core_codec_init(codec, if (switch_core_codec_init(codec,
codec_name, 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"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Raw Codec Activated\n");
} else { } else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Raw Codec Activation Failed %s@%uhz 1 channel %dms\n", codec_name, rate, interval); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Raw Codec Activation Failed %s@%uhz 1 channel %dms\n", codec_name, rate, interval);
@ -1813,7 +1812,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_soft_hold(switch_core_session_t *sess
switch_input_args_t args = { 0 }; switch_input_args_t args = { 0 };
args.input_callback = hold_on_dtmf; args.input_callback = hold_on_dtmf;
args.buf = (void *) unhold_key; args.buf = (void *) unhold_key;
args.buflen = (uint32_t)strlen(unhold_key); args.buflen = (uint32_t) strlen(unhold_key);
switch_assert(session != NULL); switch_assert(session != NULL);
channel = switch_core_session_get_channel(session); channel = switch_core_session_get_channel(session);

View File

@ -75,7 +75,7 @@ struct switch_loadable_module_container {
static struct switch_loadable_module_container loadable_modules; static struct switch_loadable_module_container loadable_modules;
static void do_shutdown(switch_loadable_module_t *module); 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)
{ {
@ -155,13 +155,15 @@ static switch_status_t switch_loadable_module_process(char *key, switch_loadable
if (!impl->iananame) { if (!impl->iananame) {
load_interface = 0; load_interface = 0;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, 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; break;
} }
if (impl->bytes_per_frame > SWITCH_RECOMMENDED_BUFFER_SIZE) { if (impl->bytes_per_frame > SWITCH_RECOMMENDED_BUFFER_SIZE) {
load_interface = 0; load_interface = 0;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, 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; break;
} }
} }
@ -778,7 +780,7 @@ SWITCH_DECLARE(switch_status_t) switch_loadable_module_load_module(char *dir, ch
if (switch_is_file_path(file)) { if (switch_is_file_path(file)) {
path = switch_core_strdup(loadable_modules.pool, 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, '.'))) { if ((dot = strchr(file, '.'))) {
dot = '\0'; dot = '\0';
} }
@ -841,8 +843,7 @@ SWITCH_DECLARE(switch_status_t) switch_loadable_module_unload_module(char *dir,
SWITCH_DECLARE(switch_status_t) switch_loadable_module_build_dynamic(char *filename, SWITCH_DECLARE(switch_status_t) switch_loadable_module_build_dynamic(char *filename,
switch_module_load_t switch_module_load, switch_module_load_t switch_module_load,
switch_module_runtime_t switch_module_runtime, switch_module_runtime_t switch_module_runtime,
switch_module_shutdown_t switch_module_shutdown, switch_module_shutdown_t switch_module_shutdown, switch_bool_t runtime)
switch_bool_t runtime)
{ {
switch_loadable_module_t *module = NULL; switch_loadable_module_t *module = NULL;
switch_module_load_t load_func_ptr = NULL; switch_module_load_t load_func_ptr = NULL;
@ -1404,7 +1405,7 @@ SWITCH_DECLARE(switch_loadable_module_interface_t *) switch_loadable_module_crea
SWITCH_DECLARE(void *) switch_loadable_module_create_interface(switch_loadable_module_interface_t *mod, switch_module_interface_name_t iname) 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: case SWITCH_ENDPOINT_INTERFACE:
ALLOC_INTERFACE(endpoint) ALLOC_INTERFACE(endpoint)

View File

@ -145,7 +145,7 @@ SWITCH_DECLARE(switch_status_t) switch_log_bind_logger(switch_log_function_t fun
return SWITCH_STATUS_SUCCESS; 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) { if (!obj) {
@ -269,7 +269,7 @@ SWITCH_DECLARE(void) switch_log_printf(switch_text_channel_t channel, const char
FD_SET(fd, &can_write); FD_SET(fd, &can_write);
to.tv_sec = 0; to.tv_sec = 0;
to.tv_usec = 100000; 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); aok = FD_ISSET(fd, &can_write);
} else { } else {
aok = 0; aok = 0;
@ -347,7 +347,8 @@ SWITCH_DECLARE(void) switch_core_memory_reclaim_logger(void)
{ {
void *pop; void *pop;
int size = switch_queue_size(LOG_RECYCLE_QUEUE); 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) { while (switch_queue_trypop(LOG_RECYCLE_QUEUE, &pop) == SWITCH_STATUS_SUCCESS) {
free(pop); free(pop);
} }

View File

@ -144,18 +144,20 @@ SWITCH_DECLARE(switch_odbc_status_t) switch_odbc_handle_connect(switch_odbc_hand
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Connecting %s\n", handle->dsn); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Connecting %s\n", handle->dsn);
if(!strstr(handle->dsn, "DRIVER")) { if (!strstr(handle->dsn, "DRIVER")) {
result = SQLConnect(handle->con, (SQLCHAR *) handle->dsn, SQL_NTS, (SQLCHAR *) handle->username, SQL_NTS, (SQLCHAR *) handle->password, SQL_NTS); result = SQLConnect(handle->con, (SQLCHAR *) handle->dsn, SQL_NTS, (SQLCHAR *) handle->username, SQL_NTS, (SQLCHAR *) handle->password, SQL_NTS);
} else { } else {
SQLCHAR outstr[1024] = {0}; SQLCHAR outstr[1024] = { 0 };
SQLSMALLINT outstrlen = 0; SQLSMALLINT outstrlen = 0;
result = SQLDriverConnect(handle->con, NULL, (SQLCHAR *) handle->dsn, (SQLSMALLINT)strlen(handle->dsn), outstr, sizeof(outstr), &outstrlen, SQL_DRIVER_NOPROMPT); 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)) { if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) {
char *err_str; char *err_str;
if ((err_str = switch_odbc_handle_get_error(handle, NULL))) { 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); free(err_str);
} else { } else {
SQLGetDiagRec(SQL_HANDLE_DBC, handle->con, 1, stat, &err, msg, 100, &mlen); SQLGetDiagRec(SQL_HANDLE_DBC, handle->con, 1, stat, &err, msg, 100, &mlen);
@ -165,10 +167,10 @@ SWITCH_DECLARE(switch_odbc_status_t) switch_odbc_handle_connect(switch_odbc_hand
return SWITCH_ODBC_FAIL; return SWITCH_ODBC_FAIL;
} }
result = SQLGetInfo(handle->con, SQL_DRIVER_NAME, (SQLCHAR*)handle->odbc_driver, 255, &valueLength); result = SQLGetInfo(handle->con, SQL_DRIVER_NAME, (SQLCHAR *) handle->odbc_driver, 255, &valueLength);
if ( result == SQL_SUCCESS || result == SQL_SUCCESS_WITH_INFO) { if (result == SQL_SUCCESS || result == SQL_SUCCESS_WITH_INFO) {
for (i = 0; i < valueLength; ++i) 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) { if (strstr(handle->odbc_driver, "FIREBIRD") != 0 || strstr(handle->odbc_driver, "FB32") != 0 || strstr(handle->odbc_driver, "FB64") != 0) {
@ -202,9 +204,9 @@ static int db_is_up(switch_odbc_handle_t *handle)
} }
if (handle->is_firebird) { if (handle->is_firebird) {
strcpy((char*)sql, "select first 1 * from RDB$RELATIONS"); strcpy((char *) sql, "select first 1 * from RDB$RELATIONS");
} else { } else {
strcpy((char*)sql, "select 1"); strcpy((char *) sql, "select 1");
} }
if (SQLAllocHandle(SQL_HANDLE_STMT, handle->con, &stmt) != SQL_SUCCESS) { if (SQLAllocHandle(SQL_HANDLE_STMT, handle->con, &stmt) != SQL_SUCCESS) {
@ -272,7 +274,7 @@ static int db_is_up(switch_odbc_handle_t *handle)
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; SQLHSTMT stmt = NULL;
int result; int result;
@ -365,7 +367,7 @@ SWITCH_DECLARE(switch_odbc_status_t) switch_odbc_handle_callback_exec(switch_odb
names[y] = malloc(name_len); names[y] = malloc(name_len);
memset(names[y], 0, 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++; ColumnSize++;
vals[y] = malloc(ColumnSize); vals[y] = malloc(ColumnSize);
@ -435,7 +437,7 @@ SWITCH_DECLARE(char *) switch_odbc_handle_get_error(switch_odbc_handle_t *handle
SQLSMALLINT length; SQLSMALLINT length;
char *ret = NULL; char *ret = NULL;
if (SQLError(handle->env, handle->con, stmt, (SQLCHAR *)sqlstate, &sqlcode, (SQLCHAR *)buffer, sizeof(buffer), &length) == SQL_SUCCESS) { 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); ret = switch_mprintf("STATE: %s CODE %ld ERROR: %s\n", sqlstate, sqlcode, buffer);
}; };

View File

@ -58,8 +58,7 @@ static switch_status_t switch_raw_encode(switch_codec_t *codec,
switch_codec_t *other_codec, switch_codec_t *other_codec,
void *decoded_data, void *decoded_data,
uint32_t decoded_data_len, 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)
unsigned int *flag)
{ {
/* NOOP indicates that the audio in is already the same as the audio out, so no conversion was necessary. */ /* 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 &&
@ -75,8 +74,7 @@ static switch_status_t switch_raw_decode(switch_codec_t *codec,
switch_codec_t *other_codec, switch_codec_t *other_codec,
void *encoded_data, void *encoded_data,
uint32_t encoded_data_len, 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)
unsigned int *flag)
{ {
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) { codec->implementation->actual_samples_per_second != other_codec->implementation->actual_samples_per_second) {
@ -103,7 +101,7 @@ static switch_status_t switch_proxy_encode(switch_codec_t *codec,
switch_codec_t *other_codec, switch_codec_t *other_codec,
void *decoded_data, void *decoded_data,
uint32_t decoded_data_len, 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) unsigned int *flag)
{ {
return SWITCH_STATUS_FALSE; return SWITCH_STATUS_FALSE;
@ -113,7 +111,7 @@ static switch_status_t switch_proxy_decode(switch_codec_t *codec,
switch_codec_t *other_codec, switch_codec_t *other_codec,
void *encoded_data, void *encoded_data,
uint32_t encoded_data_len, 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) unsigned int *flag)
{ {
return SWITCH_STATUS_FALSE; return SWITCH_STATUS_FALSE;
@ -143,7 +141,7 @@ static switch_status_t switch_g711u_encode(switch_codec_t *codec,
switch_codec_t *other_codec, switch_codec_t *other_codec,
void *decoded_data, void *decoded_data,
uint32_t decoded_data_len, 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) unsigned int *flag)
{ {
short *dbuf; short *dbuf;
@ -166,7 +164,7 @@ static switch_status_t switch_g711u_decode(switch_codec_t *codec,
switch_codec_t *other_codec, switch_codec_t *other_codec,
void *encoded_data, void *encoded_data,
uint32_t encoded_data_len, 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) unsigned int *flag)
{ {
short *dbuf; short *dbuf;
@ -214,7 +212,7 @@ static switch_status_t switch_g711a_encode(switch_codec_t *codec,
switch_codec_t *other_codec, switch_codec_t *other_codec,
void *decoded_data, void *decoded_data,
uint32_t decoded_data_len, 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) unsigned int *flag)
{ {
short *dbuf; short *dbuf;
@ -237,7 +235,7 @@ static switch_status_t switch_g711a_decode(switch_codec_t *codec,
switch_codec_t *other_codec, switch_codec_t *other_codec,
void *encoded_data, void *encoded_data,
uint32_t encoded_data_len, 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) unsigned int *flag)
{ {
short *dbuf; short *dbuf;
@ -302,8 +300,7 @@ SWITCH_MODULE_LOAD_FUNCTION(core_pcm_load)
SWITCH_ADD_CODEC(codec_interface, "PROXY VIDEO PASS-THROUGH"); SWITCH_ADD_CODEC(codec_interface, "PROXY VIDEO PASS-THROUGH");
switch_core_codec_add_implementation(pool, codec_interface, switch_core_codec_add_implementation(pool, codec_interface,
SWITCH_CODEC_TYPE_VIDEO, 31, "PROXY-VID", NULL, 90000, 90000, 0, SWITCH_CODEC_TYPE_VIDEO, 31, "PROXY-VID", NULL, 90000, 90000, 0,
0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, switch_proxy_init, switch_proxy_encode, switch_proxy_decode, switch_proxy_destroy);
switch_proxy_init, switch_proxy_encode, switch_proxy_decode, switch_proxy_destroy);
SWITCH_ADD_CODEC(codec_interface, "PROXY PASS-THROUGH"); SWITCH_ADD_CODEC(codec_interface, "PROXY PASS-THROUGH");
@ -331,13 +328,11 @@ SWITCH_MODULE_LOAD_FUNCTION(core_pcm_load)
switch_core_codec_add_implementation(pool, codec_interface, switch_core_codec_add_implementation(pool, codec_interface,
SWITCH_CODEC_TYPE_AUDIO, 118, "L16", NULL, 22050, 22050, 352800, SWITCH_CODEC_TYPE_AUDIO, 118, "L16", NULL, 22050, 22050, 352800,
20000, 441, 882, 882, 1, 1, 1, 20000, 441, 882, 882, 1, 1, 1, switch_raw_init, switch_raw_encode, switch_raw_decode, switch_raw_destroy);
switch_raw_init, switch_raw_encode, switch_raw_decode, switch_raw_destroy);
switch_core_codec_add_implementation(pool, codec_interface, switch_core_codec_add_implementation(pool, codec_interface,
SWITCH_CODEC_TYPE_AUDIO, 118, "L16", NULL, 11025, 11025, 176400, SWITCH_CODEC_TYPE_AUDIO, 118, "L16", NULL, 11025, 11025, 176400,
40000, 441, 882, 882, 1, 1, 1, 40000, 441, 882, 882, 1, 1, 1, switch_raw_init, switch_raw_encode, switch_raw_decode, switch_raw_destroy);
switch_raw_init, switch_raw_encode, switch_raw_decode, switch_raw_destroy);

View File

@ -34,11 +34,10 @@
#include <pcre.h> #include <pcre.h>
SWITCH_DECLARE(switch_regex_t *) switch_regex_compile(const char *pattern, SWITCH_DECLARE(switch_regex_t *) switch_regex_compile(const char *pattern,
int options, const char **errorptr, int *erroroffset, int options, const char **errorptr, int *erroroffset, const unsigned char *tables)
const unsigned char *tables)
{ {
return pcre_compile(pattern, options, errorptr, erroroffset, tables); return pcre_compile(pattern, options, errorptr, erroroffset, tables);
} }

View File

@ -76,9 +76,9 @@ SWITCH_DECLARE(switch_status_t) switch_resample_create(switch_audio_resampler_t
resampler->resampler = resample_open(QUALITY, resampler->factor, resampler->factor); 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, switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Activate Resampler %d->%d %f\n", resampler->from_rate, resampler->to_rate,
resampler->factor); 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->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)); resampler->to = (float *) switch_core_alloc(pool, resampler->to_size * sizeof(float));
*new_resampler = resampler; *new_resampler = resampler;
@ -231,7 +231,7 @@ SWITCH_DECLARE(uint32_t) switch_merge_sln(int16_t *data, uint32_t samples, int16
x = samples; x = samples;
} }
for(i = 0; i < x; i++) { for (i = 0; i < x; i++) {
z = data[i] + other_data[i]; z = data[i] + other_data[i];
switch_normalize_to_16bit(z); switch_normalize_to_16bit(z);
data[i] = (int16_t) z; data[i] = (int16_t) z;

View File

@ -186,12 +186,7 @@ struct switch_rtp {
static int global_init = 0; static int global_init = 0;
static int rtp_common_write(switch_rtp_t *rtp_session, static int rtp_common_write(switch_rtp_t *rtp_session,
rtp_msg_t *send_msg, rtp_msg_t *send_msg, void *data, uint32_t datalen, switch_payload_t payload, uint32_t timestamp, switch_frame_flag_t *flags);
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) static switch_status_t ice_out(switch_rtp_t *rtp_session)
@ -299,7 +294,7 @@ static void handle_ice(switch_rtp_t *rtp_session, void *data, switch_size_t len)
rpacket = switch_stun_packet_build_header(SWITCH_STUN_BINDING_RESPONSE, packet->header.id, stunbuf); rpacket = switch_stun_packet_build_header(SWITCH_STUN_BINDING_RESPONSE, packet->header.id, stunbuf);
switch_stun_packet_attribute_add_username(rpacket, username, 32); switch_stun_packet_attribute_add_username(rpacket, username, 32);
remote_ip = switch_get_addr(ipbuf, sizeof(ipbuf), rtp_session->from_addr); 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); bytes = switch_stun_packet_length(rpacket);
switch_socket_sendto(rtp_session->sock, rtp_session->from_addr, 0, (void *) rpacket, &bytes); switch_socket_sendto(rtp_session->sock, rtp_session->from_addr, 0, (void *) rpacket, &bytes);
} }
@ -463,7 +458,6 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_set_local_address(switch_rtp_t *rtp_s
*err = "Bind Error!"; *err = "Bind Error!";
goto done; goto done;
} }
#ifndef WIN32 #ifndef WIN32
len = sizeof(i); len = sizeof(i);
switch_socket_opt_set(new_sock, SWITCH_SO_NONBLOCK, TRUE); switch_socket_opt_set(new_sock, SWITCH_SO_NONBLOCK, TRUE);
@ -471,7 +465,7 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_set_local_address(switch_rtp_t *rtp_s
switch_socket_sendto(new_sock, rtp_session->local_addr, 0, (void *) o, &len); switch_socket_sendto(new_sock, rtp_session->local_addr, 0, (void *) o, &len);
x = 0; x = 0;
while(!ilen) { while (!ilen) {
switch_status_t status; switch_status_t status;
ilen = len; ilen = len;
status = switch_socket_recvfrom(rtp_session->from_addr, new_sock, 0, (void *) i, &ilen); status = switch_socket_recvfrom(rtp_session->from_addr, new_sock, 0, (void *) i, &ilen);
@ -545,10 +539,7 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_set_remote_address(switch_rtp_t *rtp_
SWITCH_DECLARE(switch_status_t) switch_rtp_add_crypto_key(switch_rtp_t *rtp_session, SWITCH_DECLARE(switch_status_t) switch_rtp_add_crypto_key(switch_rtp_t *rtp_session,
switch_rtp_crypto_direction_t direction, switch_rtp_crypto_direction_t direction,
uint32_t index, uint32_t index, switch_rtp_crypto_key_type_t type, unsigned char *key, switch_size_t keylen)
switch_rtp_crypto_key_type_t type,
unsigned char *key,
switch_size_t keylen)
{ {
switch_rtp_crypto_key_t *crypto_key; switch_rtp_crypto_key_t *crypto_key;
srtp_policy_t *policy; srtp_policy_t *policy;
@ -575,7 +566,7 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_add_crypto_key(switch_rtp_t *rtp_sess
memset(policy, 0, sizeof(*policy)); memset(policy, 0, sizeof(*policy));
switch(crypto_key->type) { switch (crypto_key->type) {
case AES_CM_128_HMAC_SHA1_80: case AES_CM_128_HMAC_SHA1_80:
crypto_policy_set_aes_cm_128_hmac_sha1_80(&policy->rtp); crypto_policy_set_aes_cm_128_hmac_sha1_80(&policy->rtp);
break; break;
@ -592,7 +583,7 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_add_crypto_key(switch_rtp_t *rtp_sess
policy->rtcp.sec_serv = sec_serv_none; policy->rtcp.sec_serv = sec_serv_none;
policy->rtp.sec_serv = sec_serv_conf_and_auth; policy->rtp.sec_serv = sec_serv_conf_and_auth;
switch(direction) { switch (direction) {
case SWITCH_RTP_CRYPTO_RECV: case SWITCH_RTP_CRYPTO_RECV:
policy->ssrc.type = ssrc_any_inbound; policy->ssrc.type = ssrc_any_inbound;
@ -645,10 +636,7 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_create(switch_rtp_t **new_rtp_session
switch_payload_t payload, switch_payload_t payload,
uint32_t samples_per_interval, uint32_t samples_per_interval,
uint32_t ms_per_packet, uint32_t ms_per_packet,
switch_rtp_flag_t flags, switch_rtp_flag_t flags, char *timer_name, const char **err, switch_memory_pool_t *pool)
char *timer_name,
const char **err,
switch_memory_pool_t *pool)
{ {
switch_rtp_t *rtp_session = NULL; switch_rtp_t *rtp_session = NULL;
uint32_t ssrc = rand() & 0xffff; uint32_t ssrc = rand() & 0xffff;
@ -718,8 +706,7 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_create(switch_rtp_t **new_rtp_session
} }
if (!switch_strlen_zero(timer_name)) { if (!switch_strlen_zero(timer_name)) {
if (switch_core_timer_init(&rtp_session->timer, timer_name, ms_per_packet / 1000, samples_per_interval, pool) == if (switch_core_timer_init(&rtp_session->timer, timer_name, ms_per_packet / 1000, samples_per_interval, pool) == SWITCH_STATUS_SUCCESS) {
SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, 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); "Starting timer [%s] %d bytes per %dms\n", timer_name, samples_per_interval, ms_per_packet);
} else { } else {
@ -742,10 +729,7 @@ SWITCH_DECLARE(switch_rtp_t *) switch_rtp_new(const char *rx_host,
switch_payload_t payload, switch_payload_t payload,
uint32_t samples_per_interval, uint32_t samples_per_interval,
uint32_t ms_per_packet, uint32_t ms_per_packet,
switch_rtp_flag_t flags, switch_rtp_flag_t flags, char *timer_name, const char **err, switch_memory_pool_t *pool)
char *timer_name,
const char **err,
switch_memory_pool_t *pool)
{ {
switch_rtp_t *rtp_session = NULL; switch_rtp_t *rtp_session = NULL;
@ -903,11 +887,11 @@ SWITCH_DECLARE(void) switch_rtp_destroy(switch_rtp_t **rtp_session)
switch_rtp_kill_socket(*rtp_session); 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); 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); switch_safe_free(pop);
} }
@ -1020,19 +1004,12 @@ static void do_2833(switch_rtp_t *rtp_session)
for (x = 0; x < loops; x++) { for (x = 0; x < loops; x++) {
switch_rtp_write_manual(rtp_session, switch_rtp_write_manual(rtp_session,
rtp_session->dtmf_data.out_digit_packet, rtp_session->dtmf_data.out_digit_packet, 4, 0, rtp_session->te, rtp_session->dtmf_data.timestamp_dtmf, &flags);
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", 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.timestamp_dtmf,
rtp_session->dtmf_data.out_digit_sofar, rtp_session->dtmf_data.out_digit_sofar,
rtp_session->dtmf_data.out_digit_sub_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_dur,
rtp_session->seq);
} }
if (loops != 1) { if (loops != 1) {
@ -1076,7 +1053,7 @@ static void do_2833(switch_rtp_t *rtp_session)
if (rtp_session->timer.interval) { if (rtp_session->timer.interval) {
offset = rtp_session->timer.samplecount - rtp_session->last_write_samplecount; offset = rtp_session->timer.samplecount - rtp_session->last_write_samplecount;
if (offset > 0) { 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 @@ static void do_2833(switch_rtp_t *rtp_session)
rtp_session->dtmf_data.out_digit_packet, rtp_session->dtmf_data.out_digit_packet,
4, 4,
switch_test_flag(rtp_session, SWITCH_RTP_FLAG_BUGGY_2833) ? 0 : 1, switch_test_flag(rtp_session, SWITCH_RTP_FLAG_BUGGY_2833) ? 0 : 1,
rtp_session->te, rtp_session->te, rtp_session->dtmf_data.timestamp_dtmf, &flags);
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", 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.timestamp_dtmf,
rtp_session->dtmf_data.out_digit_sofar, rtp_session->dtmf_data.out_digit_sofar,
rtp_session->dtmf_data.out_digit_sub_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_dur,
rtp_session->seq);
free(rdigit); free(rdigit);
} }
@ -1219,7 +1192,7 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_
rtp_session->recv_msg.header.pt = (uint32_t) rtp_session->cng_pt ? rtp_session->cng_pt : SWITCH_RTP_CNG_PAYLOAD; rtp_session->recv_msg.header.pt = (uint32_t) rtp_session->cng_pt ? rtp_session->cng_pt : SWITCH_RTP_CNG_PAYLOAD;
*flags |= SFF_CNG; *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; ret = 2 + rtp_header_len;
goto end; goto end;
} }
@ -1274,7 +1247,8 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_
if (++rtp_session->srtp_errs >= MAX_SRTP_ERRS) { if (++rtp_session->srtp_errs >= MAX_SRTP_ERRS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
"error: srtp unprotection failed with code %d%s\n", stat, "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; ret = -1;
goto end; goto end;
} else { } else {
@ -1325,7 +1299,6 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_
rtp_session->dtmf_data.flip = 0; rtp_session->dtmf_data.flip = 0;
//printf("you're welcome!\n"); //printf("you're welcome!\n");
} }
//printf("done digit=%c ts=%u start_ts=%u dur=%u ddur=%u\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); //dtmf.digit, ts, rtp_session->dtmf_data.in_digit_ts, duration, dtmf.duration);
switch_rtp_queue_rfc2833_in(rtp_session, &dtmf); switch_rtp_queue_rfc2833_in(rtp_session, &dtmf);
@ -1385,7 +1358,7 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_
rtp_session->recv_msg.header.pt = (uint32_t) rtp_session->cng_pt ? rtp_session->cng_pt : SWITCH_RTP_CNG_PAYLOAD; rtp_session->recv_msg.header.pt = (uint32_t) rtp_session->cng_pt ? rtp_session->cng_pt : SWITCH_RTP_CNG_PAYLOAD;
*flags |= SFF_CNG; *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; ret = 2 + rtp_header_len;
goto end; goto end;
} }
@ -1520,7 +1493,7 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_queue_rfc2833_in(switch_rtp_t *rtp_se
return SWITCH_STATUS_SUCCESS; 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) switch_payload_t *payload_type, switch_frame_flag_t *flags, switch_io_flag_t io_flags)
{ {
int bytes = 0; int bytes = 0;
@ -1567,7 +1540,7 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_zerocopy_read_frame(switch_rtp_t *rtp
frame->flags |= SFF_RFC2833; frame->flags |= SFF_RFC2833;
} }
frame->timestamp = ntohl(rtp_session->recv_msg.header.ts); 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->ssrc = ntohl(rtp_session->recv_msg.header.ssrc);
frame->m = rtp_session->recv_msg.header.m ? SWITCH_TRUE : SWITCH_FALSE; frame->m = rtp_session->recv_msg.header.m ? SWITCH_TRUE : SWITCH_FALSE;
@ -1587,7 +1560,8 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_zerocopy_read_frame(switch_rtp_t *rtp
} }
SWITCH_DECLARE(switch_status_t) switch_rtp_zerocopy_read(switch_rtp_t *rtp_session, SWITCH_DECLARE(switch_status_t) switch_rtp_zerocopy_read(switch_rtp_t *rtp_session,
void **data, uint32_t * datalen, switch_payload_t *payload_type, switch_frame_flag_t *flags, 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; int bytes = 0;
@ -1610,12 +1584,7 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_zerocopy_read(switch_rtp_t *rtp_sessi
} }
static int rtp_common_write(switch_rtp_t *rtp_session, static int rtp_common_write(switch_rtp_t *rtp_session,
rtp_msg_t *send_msg, rtp_msg_t *send_msg, void *data, uint32_t datalen, switch_payload_t payload, uint32_t timestamp, switch_frame_flag_t *flags)
void *data,
uint32_t datalen,
switch_payload_t payload,
uint32_t timestamp,
switch_frame_flag_t *flags)
{ {
switch_size_t bytes; switch_size_t bytes;
uint8_t send = 1; uint8_t send = 1;
@ -1682,7 +1651,7 @@ static int rtp_common_write(switch_rtp_t *rtp_session,
if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_VAD) && if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_VAD) &&
rtp_session->recv_msg.header.pt == rtp_session->vad_data.read_codec->implementation->ianacode) { 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 rate = 0;
uint32_t codec_flags = 0; uint32_t codec_flags = 0;
uint32_t len = sizeof(decoded); uint32_t len = sizeof(decoded);
@ -1938,8 +1907,7 @@ SWITCH_DECLARE(int) switch_rtp_write_frame(switch_rtp_t *rtp_session, switch_fra
} }
if (switch_test_flag(frame, SFF_RTP_HEADER)) { if (switch_test_flag(frame, SFF_RTP_HEADER)) {
return switch_rtp_write_manual(rtp_session, frame->data, frame->datalen, frame->m, frame->payload, return switch_rtp_write_manual(rtp_session, frame->data, frame->datalen, frame->m, frame->payload, (uint32_t) (frame->timestamp), &frame->flags);
(uint32_t)(frame->timestamp), &frame->flags);
} }
if (fwd) { if (fwd) {
@ -1949,16 +1917,14 @@ SWITCH_DECLARE(int) switch_rtp_write_frame(switch_rtp_t *rtp_session, switch_fra
} else { } else {
data = frame->data; data = frame->data;
len = frame->datalen; 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); 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, SWITCH_DECLARE(int) switch_rtp_write_manual(switch_rtp_t *rtp_session,
void *data, void *data, uint32_t datalen, uint8_t m, switch_payload_t payload, uint32_t ts, switch_frame_flag_t *flags)
uint32_t datalen,
uint8_t m, switch_payload_t payload, uint32_t ts, switch_frame_flag_t *flags)
{ {
switch_size_t bytes; switch_size_t bytes;
int ret = -1; int ret = -1;

View File

@ -53,7 +53,7 @@ static struct {
switch_memory_pool_t *memory_pool; switch_memory_pool_t *memory_pool;
} globals; } 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_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)); //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_scheduler_execute(switch_scheduler_task_container_t * tp)
} }
} }
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_scheduler_task_container_t *tp = (switch_scheduler_task_container_t *) obj;
switch_memory_pool_t *pool; switch_memory_pool_t *pool;
@ -109,7 +109,7 @@ static int task_thread_loop(int done)
} else { } else {
int64_t now = switch_timestamp(NULL); int64_t now = switch_timestamp(NULL);
if (now >= tp->task.runtime && !tp->in_thread) { 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) { if (diff > 1) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Task was executed late by %d seconds %u %s (%s)\n", 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)); diff, tp->task.task_id, tp->desc, switch_str_nil(tp->task.group));
@ -158,7 +158,7 @@ static int task_thread_loop(int done)
return done; 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; globals.task_thread_running = 1;

View File

@ -114,7 +114,7 @@ SWITCH_DECLARE(void) switch_stun_random_string(char *buf, uint16_t len, char *se
} }
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_t *packet;
switch_stun_packet_attribute_t *attr; switch_stun_packet_attribute_t *attr;
@ -133,7 +133,7 @@ SWITCH_DECLARE(switch_stun_packet_t *) switch_stun_packet_parse(uint8_t * buf, u
/* /*
* Check packet type (RFC3489(bis?) values) * Check packet type (RFC3489(bis?) values)
*/ */
switch(packet->header.type) { switch (packet->header.type) {
case SWITCH_STUN_BINDING_REQUEST: case SWITCH_STUN_BINDING_REQUEST:
case SWITCH_STUN_BINDING_RESPONSE: case SWITCH_STUN_BINDING_RESPONSE:
case SWITCH_STUN_BINDING_ERROR_RESPONSE: case SWITCH_STUN_BINDING_ERROR_RESPONSE:
@ -295,12 +295,12 @@ SWITCH_DECLARE(switch_stun_packet_t *) switch_stun_packet_parse(uint8_t * buf, u
} while (bytes_left >= SWITCH_STUN_ATTRIBUTE_MIN_LEN && switch_stun_packet_next_attribute(attr, end_buf)); } 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? * the packet length is longer than the length of all attributes?
* for now simply decrease the packet size * 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; return packet;
@ -336,14 +336,14 @@ SWITCH_DECLARE(const char *) switch_stun_value_to_name(int32_t type, uint32_t va
return "INVALID"; 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; switch_stun_ip_t *ip;
uint8_t x, *i; uint8_t x, *i;
char *p = ipstr; char *p = ipstr;
ip = (switch_stun_ip_t *) attribute->value; ip = (switch_stun_ip_t *) attribute->value;
i = (uint8_t *) & ip->address; i = (uint8_t *) &ip->address;
*ipstr = 0; *ipstr = 0;
for (x = 0; x < 4; x++) { for (x = 0; x < 4; x++) {
sprintf(p, "%u%s", i[x], x == 3 ? "" : "."); sprintf(p, "%u%s", i[x], x == 3 ? "" : ".");
@ -361,7 +361,7 @@ SWITCH_DECLARE(char *) switch_stun_packet_attribute_get_username(switch_stun_pac
return memcpy(username, attribute->value, cpylen); 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; switch_stun_packet_header_t *header;
@ -386,14 +386,14 @@ SWITCH_DECLARE(uint8_t) switch_stun_packet_attribute_add_binded_address(switch_s
uint8_t *i, x; uint8_t *i, x;
char *p = ipstr; 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->type = htons(SWITCH_STUN_ATTR_MAPPED_ADDRESS);
attribute->length = htons(8); attribute->length = htons(8);
ip = (switch_stun_ip_t *) attribute->value; ip = (switch_stun_ip_t *) attribute->value;
ip->port = htons(port); ip->port = htons(port);
ip->family = 1; ip->family = 1;
i = (uint8_t *) & ip->address; i = (uint8_t *) &ip->address;
for (x = 0; x < 4; x++) { for (x = 0; x < 4; x++) {
i[x] = (uint8_t) atoi(p); i[x] = (uint8_t) atoi(p);
@ -415,7 +415,7 @@ SWITCH_DECLARE(uint8_t) switch_stun_packet_attribute_add_username(switch_stun_pa
if (ulen % 4 != 0) { if (ulen % 4 != 0) {
return 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->type = htons(SWITCH_STUN_ATTR_USERNAME);
attribute->length = htons(ulen); attribute->length = htons(ulen);
if (username) { if (username) {

View File

@ -116,7 +116,7 @@ static switch_time_t time_now(int64_t offset)
if (MONO) { if (MONO) {
struct timespec ts; struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &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 { } else {
#endif #endif
now = switch_time_now(); now = switch_time_now();
@ -161,7 +161,7 @@ static switch_status_t timer_init(switch_timer_t *timer)
timer_private_t *private_info; timer_private_t *private_info;
int sanity = 0; int sanity = 0;
while(globals.STARTED == 0) { while (globals.STARTED == 0) {
switch_yield(100000); switch_yield(100000);
if (++sanity == 10) { if (++sanity == 10) {
break; break;
@ -319,9 +319,9 @@ SWITCH_MODULE_RUNTIME_FUNCTION(softtimer_runtime)
if (MONO) { if (MONO) {
int loops; int loops;
for(loops = 0; loops < 3; loops++) { for (loops = 0; loops < 3; loops++) {
ts = time_now(0); 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) { if (ts == last) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Broken MONOTONIC Clock Detected!, Support Disabled.\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Broken MONOTONIC Clock Detected!, Support Disabled.\n");
MONO = 0; MONO = 0;
@ -346,7 +346,7 @@ SWITCH_MODULE_RUNTIME_FUNCTION(softtimer_runtime)
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Virtual Migration Detected! Syncing Clock\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Virtual Migration Detected! Syncing Clock\n");
switch_time_sync(); switch_time_sync();
} else { } 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"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Reverse Clock Skew Detected!\n");
runtime.reference = switch_time_now(); runtime.reference = switch_time_now();
current_ms = 0; current_ms = 0;
@ -457,7 +457,6 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(softtimer_shutdown)
switch_yield(10000); switch_yield(10000);
} }
} }
#if defined(WIN32) #if defined(WIN32)
timeEndPeriod(1); timeEndPeriod(1);
#endif #endif

View File

@ -199,7 +199,7 @@ SWITCH_DECLARE(char *) switch_find_end_paren(const char *s, char open, char clos
} }
} }
return (char *)e; return (char *) e;
} }
SWITCH_DECLARE(switch_size_t) switch_fd_read_line(int fd, char *buf, switch_size_t len) SWITCH_DECLARE(switch_size_t) switch_fd_read_line(int fd, char *buf, switch_size_t len)
@ -230,10 +230,10 @@ SWITCH_DECLARE(char *) switch_amp_encode(char *s, char *buf, switch_size_t len)
q = buf; q = buf;
for(p = s; x < len; p++) { for (p = s; x < len; p++) {
switch(*p) { switch (*p) {
case '<': case '<':
if (x + 4 > len -1) { if (x + 4 > len - 1) {
goto end; goto end;
} }
*q++ = '&'; *q++ = '&';
@ -243,7 +243,7 @@ SWITCH_DECLARE(char *) switch_amp_encode(char *s, char *buf, switch_size_t len)
x += 4; x += 4;
break; break;
case '>': case '>':
if (x + 4 > len -1) { if (x + 4 > len - 1) {
goto end; goto end;
} }
*q++ = '&'; *q++ = '&';
@ -253,7 +253,7 @@ SWITCH_DECLARE(char *) switch_amp_encode(char *s, char *buf, switch_size_t len)
x += 4; x += 4;
break; break;
default: default:
if (x + 1 > len -1) { if (x + 1 > len - 1) {
goto end; goto end;
} }
*q++ = *p; *q++ = *p;
@ -276,23 +276,23 @@ SWITCH_DECLARE(switch_status_t) switch_b64_encode(unsigned char *in, switch_size
{ {
int y = 0, bytes = 0; int y = 0, bytes = 0;
size_t x = 0; size_t x = 0;
unsigned int b = 0,l = 0; unsigned int b = 0, l = 0;
for(x = 0; x < ilen; x++) { for (x = 0; x < ilen; x++) {
b = (b<<8) + in[x]; b = (b << 8) + in[x];
l += 8; l += 8;
while (l >= 6) { while (l >= 6) {
out[bytes++] = switch_b64_table[(b>>(l-=6))%64]; out[bytes++] = switch_b64_table[(b >> (l -= 6)) % 64];
if (++y != 72) { if (++y != 72) {
continue; continue;
} }
//out[bytes++] = '\n'; //out[bytes++] = '\n';
y=0; y = 0;
} }
} }
if (l > 0) { if (l > 0) {
out[bytes++] = switch_b64_table[((b%16)<<(6-l))%64]; out[bytes++] = switch_b64_table[((b % 16) << (6 - l)) % 64];
} }
if (l != 0) { if (l != 0) {
while (l < 6) { while (l < 6) {
@ -311,16 +311,16 @@ SWITCH_DECLARE(switch_size_t) switch_b64_decode(char *in, char *out, switch_size
char *ip, *op = out; char *ip, *op = out;
size_t ol = 0; size_t ol = 0;
for (i=0; i<256; i++) { for (i = 0; i < 256; i++) {
l64[i] = -1; l64[i] = -1;
} }
for (i=0; i<64; i++) { for (i = 0; i < 64; i++) {
l64[(int)switch_b64_table[i]] = (char)i; l64[(int) switch_b64_table[i]] = (char) i;
} }
for (ip = in; ip && *ip; ip++) { for (ip = in; ip && *ip; ip++) {
c = l64[(int)*ip]; c = l64[(int) *ip];
if (c == -1) { if (c == -1) {
continue; continue;
} }
@ -329,8 +329,8 @@ SWITCH_DECLARE(switch_size_t) switch_b64_decode(char *in, char *out, switch_size
l += 6; l += 6;
while (l >= 8) { while (l >= 8) {
op[ol++] = (char)((b >> (l -= 8)) % 256); op[ol++] = (char) ((b >> (l -= 8)) % 256);
if (ol >= olen -2) { if (ol >= olen - 2) {
goto end; goto end;
} }
} }
@ -366,7 +366,7 @@ SWITCH_DECLARE(switch_bool_t) switch_simple_email(const char *to, const char *fr
unsigned char in[B64BUFFLEN]; unsigned char in[B64BUFFLEN];
unsigned char out[B64BUFFLEN + 512]; unsigned char out[B64BUFFLEN + 512];
switch_snprintf(filename, 80, "%smail.%d%04x", SWITCH_GLOBAL_dirs.temp_dir, (int)switch_timestamp(NULL), rand() & 0xffff); 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 ((fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0644))) {
if (file) { if (file) {
@ -416,8 +416,7 @@ SWITCH_DECLARE(switch_bool_t) switch_simple_email(const char *to, const char *fr
"Content-ID: <ATTACHED@freeswitch.org>\n" "Content-ID: <ATTACHED@freeswitch.org>\n"
"Content-Transfer-Encoding: base64\n" "Content-Transfer-Encoding: base64\n"
"Content-Description: Sound attachment.\n" "Content-Description: Sound attachment.\n"
"Content-Disposition: attachment; filename=\"%s\"\n\n", "Content-Disposition: attachment; filename=\"%s\"\n\n", bound, mime_type, stipped_file, stipped_file);
bound, mime_type, stipped_file, stipped_file);
if (!write_buf(fd, buf)) if (!write_buf(fd, buf))
return SWITCH_FALSE; return SWITCH_FALSE;
@ -484,10 +483,10 @@ SWITCH_DECLARE(switch_bool_t) switch_simple_email(const char *to, const char *fr
SWITCH_DECLARE(switch_bool_t) switch_is_lan_addr(const char *ip) 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 ( return (strncmp(ip, "10.", 3) &&
strncmp(ip, "10.", 3) &&
strncmp(ip, "192.168.", 8) && strncmp(ip, "192.168.", 8) &&
strncmp(ip, "127.", 4) && strncmp(ip, "127.", 4) &&
strncmp(ip, "255.", 4) && strncmp(ip, "255.", 4) &&
@ -498,12 +497,8 @@ SWITCH_DECLARE(switch_bool_t) switch_is_lan_addr(const char *ip)
strncmp(ip, "172.17.", 7) && strncmp(ip, "172.17.", 7) &&
strncmp(ip, "172.18.", 7) && strncmp(ip, "172.18.", 7) &&
strncmp(ip, "172.19.", 7) && strncmp(ip, "172.19.", 7) &&
strncmp(ip, "172.2", 5) && 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)
strncmp(ip, "172.30.", 7) && )? SWITCH_FALSE : SWITCH_TRUE;
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) SWITCH_DECLARE(switch_bool_t) switch_ast2regex(char *pat, char *rbuf, size_t len)
@ -518,7 +513,7 @@ SWITCH_DECLARE(switch_bool_t) switch_ast2regex(char *pat, char *rbuf, size_t len
*(rbuf + strlen(rbuf)) = '^'; *(rbuf + strlen(rbuf)) = '^';
while(p && *p) { while (p && *p) {
if (*p == 'N') { if (*p == 'N') {
strncat(rbuf, "[2-9]", len - strlen(rbuf)); strncat(rbuf, "[2-9]", len - strlen(rbuf));
} else if (*p == 'X') { } else if (*p == 'X') {
@ -534,7 +529,7 @@ SWITCH_DECLARE(switch_bool_t) switch_ast2regex(char *pat, char *rbuf, size_t len
} }
*(rbuf + strlen(rbuf)) = '$'; *(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) SWITCH_DECLARE(char *) switch_replace_char(char *str, char from, char to, switch_bool_t dup)
@ -548,7 +543,7 @@ SWITCH_DECLARE(char *) switch_replace_char(char *str, char from, char to, switch
p = str; p = str;
} }
for(;p && *p; p++) { for (; p && *p; p++) {
if (*p == from) { if (*p == from) {
*p = to; *p = to;
} }
@ -562,19 +557,21 @@ SWITCH_DECLARE(char *) switch_strip_spaces(const char *str)
const char *sp = str; const char *sp = str;
char *p, *s = NULL; char *p, *s = NULL;
if (!sp) return NULL; if (!sp)
return NULL;
while(*sp == ' ') { while (*sp == ' ') {
sp++; sp++;
} }
s = strdup(sp); s = strdup(sp);
if (!s) return NULL; if (!s)
return NULL;
p = s + (strlen(s) - 1); p = s + (strlen(s) - 1);
while(*p == ' ') { while (*p == ' ') {
*p-- = '\0'; *p-- = '\0';
} }
@ -589,12 +586,12 @@ SWITCH_DECLARE(char *) switch_separate_paren_args(char *str)
if ((args = strchr(str, '('))) { if ((args = strchr(str, '('))) {
e = args - 1; e = args - 1;
*args++ = '\0'; *args++ = '\0';
while(*e == ' ') { while (*e == ' ') {
*e-- = '\0'; *e-- = '\0';
} }
e = args; e = args;
br = 1; br = 1;
while(e && *e) { while (e && *e) {
if (*e == '(') { if (*e == '(') {
br++; br++;
} else if (br > 1 && *e == ')') { } else if (br > 1 && *e == ')') {
@ -642,7 +639,7 @@ SWITCH_DECLARE(const char *) switch_stristr(const char *instr, const char *str)
for (start = str; *start; start++) { for (start = str; *start; start++) {
/* find start of pattern in string */ /* find start of pattern in string */
for ( ; ((*start) && (toupper(*start) != toupper(*instr))); start++); for (; ((*start) && (toupper(*start) != toupper(*instr))); start++);
if (!*start) if (!*start)
return NULL; return NULL;
@ -710,7 +707,8 @@ SWITCH_DECLARE(switch_status_t) switch_find_local_ip(char *buf, int len, int fam
if (!address_info || WSAIoctl(tmp_socket, if (!address_info || WSAIoctl(tmp_socket,
SIO_ROUTING_INTERFACE_QUERY, SIO_ROUTING_INTERFACE_QUERY,
address_info->ai_addr, (DWORD) address_info->ai_addrlen, &l_address, sizeof(l_address), (LPDWORD) & l_address_len, NULL, NULL)) { address_info->ai_addr, (DWORD) address_info->ai_addrlen, &l_address, sizeof(l_address), (LPDWORD) & l_address_len, NULL,
NULL)) {
closesocket(tmp_socket); closesocket(tmp_socket);
if (address_info) if (address_info)
@ -921,8 +919,7 @@ static const char *switch_inet_ntop6(const unsigned char *src, char *dst, size_t
* author: * author:
* Paul Vixie, 1996. * Paul Vixie, 1996.
*/ */
const char * const char *switch_inet_ntop(int af, void const *src, char *dst, size_t size)
switch_inet_ntop(int af, void const *src, char *dst, size_t size)
{ {
switch (af) { switch (af) {
@ -949,14 +946,12 @@ switch_inet_ntop(int af, void const *src, char *dst, size_t size)
* author: * author:
* Paul Vixie, 1996. * Paul Vixie, 1996.
*/ */
static const char * static const char *switch_inet_ntop4(const unsigned char *src, char *dst, size_t size)
switch_inet_ntop4(const unsigned char *src, char *dst, size_t size)
{ {
static const char fmt[] = "%u.%u.%u.%u"; static const char fmt[] = "%u.%u.%u.%u";
char tmp[sizeof "255.255.255.255"]; char tmp[sizeof "255.255.255.255"];
if (switch_snprintf(tmp, sizeof tmp, fmt, if (switch_snprintf(tmp, sizeof tmp, fmt, src[0], src[1], src[2], src[3]) >= (int) size) {
src[0], src[1], src[2], src[3]) >= (int)size) {
return NULL; return NULL;
} }
@ -970,8 +965,7 @@ switch_inet_ntop4(const unsigned char *src, char *dst, size_t size)
* author: * author:
* Paul Vixie, 1996. * Paul Vixie, 1996.
*/ */
static const char * static const char *switch_inet_ntop6(unsigned char const *src, char *dst, size_t size)
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 * Note that int32_t and int16_t need only be "at least" large enough
@ -981,7 +975,11 @@ switch_inet_ntop6(unsigned char const *src, char *dst, size_t size)
* to use pointer overlays. All the world's not a VAX. * 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; 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]; unsigned int words[8];
int i; int i;
@ -1021,8 +1019,7 @@ switch_inet_ntop6(unsigned char const *src, char *dst, size_t size)
tp = tmp; tp = tmp;
for (i = 0; i < 8; i++) { for (i = 0; i < 8; i++) {
/* Are we inside the best run of 0x00's? */ /* Are we inside the best run of 0x00's? */
if (best.base != -1 && i >= best.base && if (best.base != -1 && i >= best.base && i < (best.base + best.len)) {
i < (best.base + best.len)) {
if (i == best.base) if (i == best.base)
*tp++ = ':'; *tp++ = ':';
continue; continue;
@ -1031,9 +1028,8 @@ switch_inet_ntop6(unsigned char const *src, char *dst, size_t size)
if (i != 0) if (i != 0)
*tp++ = ':'; *tp++ = ':';
/* Is this address an encapsulated IPv4? */ /* Is this address an encapsulated IPv4? */
if (i == 6 && best.base == 0 && if (i == 6 && best.base == 0 && (best.len == 6 || (best.len == 5 && words[5] == 0xffff))) {
(best.len == 6 || (best.len == 5 && words[5] == 0xffff))) { if (!inet_ntop4(src + 12, tp, sizeof tmp - (tp - tmp)))
if (!inet_ntop4(src+12, tp, sizeof tmp - (tp - tmp)))
return (NULL); return (NULL);
tp += strlen(tp); tp += strlen(tp);
break; break;
@ -1048,7 +1044,7 @@ switch_inet_ntop6(unsigned char const *src, char *dst, size_t size)
/* /*
* Check for overflow, copy, and we're done. * Check for overflow, copy, and we're done.
*/ */
if ((size_t)(tp - tmp) >= size) { if ((size_t) (tp - tmp) >= size) {
return NULL; return NULL;
} }
@ -1181,8 +1177,8 @@ static char *cleanup_separated_string(char *str, char delim)
int esc = 0; int esc = 0;
if (*ptr == ESCAPE_META) { if (*ptr == ESCAPE_META) {
e = *(ptr+1); e = *(ptr + 1);
if (e == '\'' || e == '"' || (delim && e == delim) || (e = unescape_char(*(ptr+1))) != *(ptr+1)) { if (e == '\'' || e == '"' || (delim && e == delim) || (e = unescape_char(*(ptr + 1))) != *(ptr + 1)) {
++ptr; ++ptr;
*dest++ = e; *dest++ = e;
end = dest; end = dest;
@ -1311,11 +1307,9 @@ SWITCH_DECLARE(unsigned int) switch_separate_string(char *buf, char delim, char
return 0; return 0;
} }
memset(array, 0, arraylen * sizeof (*array)); memset(array, 0, arraylen * sizeof(*array));
return (delim == ' ' ? return (delim == ' ' ? separate_string_blank_delim(buf, array, arraylen) : separate_string_char_delim(buf, delim, array, arraylen));
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) SWITCH_DECLARE(const char *) switch_cut_path(const char *in)
@ -1389,7 +1383,7 @@ SWITCH_DECLARE(char *) switch_string_replace(const char *string, const char *sea
return dest; 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; int nsds = 0;