EndProject\r
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Setup.CA.DownloadOpenH264", "w32\Setup\CustomActions\Setup.CA.DownloadOpenH264\Setup.CA.DownloadOpenH264.csproj", "{EBFDCFCA-8095-4ECC-98BE-B494BCB4E042}"\r
EndProject\r
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Databases", "Databases", "{31C2761D-20E0-4BF8-98B9-E32F0D8DD6E1}"\r
+EndProject\r
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_pgsql", "src\mod\databases\mod_pgsql\mod_pgsql.2017.vcxproj", "{1BA65811-5453-46F6-8190-9ECEEFEB7DF2}"\r
+EndProject\r
Global\r
GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
All|Win32 = All|Win32\r
{EBFDCFCA-8095-4ECC-98BE-B494BCB4E042}.Release|Win32.Build.0 = Release|x86\r
{EBFDCFCA-8095-4ECC-98BE-B494BCB4E042}.Release|x64.ActiveCfg = Release|x86\r
{EBFDCFCA-8095-4ECC-98BE-B494BCB4E042}.Release|x64.Build.0 = Release|x86\r
+ {1BA65811-5453-46F6-8190-9ECEEFEB7DF2}.All|Win32.ActiveCfg = Release|Win32\r
+ {1BA65811-5453-46F6-8190-9ECEEFEB7DF2}.All|Win32.Build.0 = Release|Win32\r
+ {1BA65811-5453-46F6-8190-9ECEEFEB7DF2}.All|x64.ActiveCfg = Release|x64\r
+ {1BA65811-5453-46F6-8190-9ECEEFEB7DF2}.All|x64.Build.0 = Release|x64\r
+ {1BA65811-5453-46F6-8190-9ECEEFEB7DF2}.Debug|Win32.ActiveCfg = Debug|Win32\r
+ {1BA65811-5453-46F6-8190-9ECEEFEB7DF2}.Debug|Win32.Build.0 = Debug|Win32\r
+ {1BA65811-5453-46F6-8190-9ECEEFEB7DF2}.Debug|x64.ActiveCfg = Debug|x64\r
+ {1BA65811-5453-46F6-8190-9ECEEFEB7DF2}.Debug|x64.Build.0 = Debug|x64\r
+ {1BA65811-5453-46F6-8190-9ECEEFEB7DF2}.Release|Win32.ActiveCfg = Release|Win32\r
+ {1BA65811-5453-46F6-8190-9ECEEFEB7DF2}.Release|Win32.Build.0 = Release|Win32\r
+ {1BA65811-5453-46F6-8190-9ECEEFEB7DF2}.Release|x64.ActiveCfg = Release|x64\r
+ {1BA65811-5453-46F6-8190-9ECEEFEB7DF2}.Release|x64.Build.0 = Release|x64\r
EndGlobalSection\r
GlobalSection(SolutionProperties) = preSolution\r
HideSolutionNode = FALSE\r
{EBD0B6B4-C5CA-46B0-BBC7-DBA71DF05D31} = {4F227C26-768F-46A3-8684-1D08A46FB374}\r
{B19AE6FC-BFFF-428D-B483-3BBEAECCC618} = {E72B5BCB-6462-4D23-B419-3AF1A4AC3D78}\r
{BC1FD72E-1CD5-4525-A7F5-17C5740BFDED} = {EB910B0D-F27D-4B62-B67B-DE834C99AC5B}\r
+ {1BA65811-5453-46F6-8190-9ECEEFEB7DF2} = {31C2761D-20E0-4BF8-98B9-E32F0D8DD6E1}\r
EndGlobalSection\r
GlobalSection(ExtensibilityGlobals) = postSolution\r
SolutionGuid = {09840DE7-9208-45AA-9667-1A71EE93BD1E}\r
libs/libteletone/src/libteletone.h \
src/include/switch_limit.h \
src/include/switch_odbc.h \
- src/include/switch_pgsql.h \
src/include/switch_hashtable.h \
src/include/switch_image.h
src/switch_config.c \
src/switch_time.c \
src/switch_odbc.c \
- src/switch_pgsql.c \
src/switch_limit.c \
src/g711.c \
src/switch_pcm.c \
#codecs/mod_silk
#codecs/mod_siren
#codecs/mod_theora
+databases/mod_pgsql
dialplans/mod_dialplan_asterisk
#dialplans/mod_dialplan_directory
dialplans/mod_dialplan_xml
codecs/mod_silk
codecs/mod_siren
codecs/mod_theora
+databases/mod_pgsql
dialplans/mod_dialplan_asterisk
dialplans/mod_dialplan_directory
dialplans/mod_dialplan_xml
--- /dev/null
+<configuration name="pre_load_modules.conf" description="Modules">\r
+ <modules>\r
+ <!-- Databases -->\r
+ <load module="mod_pgsql"/>\r
+ </modules>\r
+</configuration>\r
<param name="rtp-enable-zrtp" value="true"/>
+ <!--
+ Native PostgreSQL support was removed from the FreeSWITCH Core!
+ =================================
+ NOTICE: You MUST enable mod_pgsql
+ =================================
+ According to https://www.postgresql.org/docs/9.6/libpq-connect.html#LIBPQ-CONNSTRING
+ There are two accepted formats for connection strings supported by the libpq library:
+ * For plain keyword = value strings use pgsql://
+ pgsql://hostaddr=127.0.0.1 dbname=freeswitch user=freeswitch password='' options='-c client_min_messages=NOTICE' application_name='freeswitch'
+ * For RFC 3986 URIs use postgresql:// or postgres://
+ postgresql://
+ postgresql://localhost
+ postgresql://localhost:5433
+ postgresql://localhost/mydb
+ postgresql://user@localhost
+ postgresql://user:secret@localhost
+ postgresql://other@localhost/otherdb?connect_timeout=10&application_name=myapp
+ postgresql:///mydb?host=localhost&port=5433
+ -->
<!-- <param name="core-db-dsn" value="pgsql://hostaddr=127.0.0.1 dbname=freeswitch user=freeswitch password='' options='-c client_min_messages=NOTICE' application_name='freeswitch'" /> -->
+ <!-- <param name="core-db-dsn" value="postgresql://freeswitch:@127.0.0.1/freeswitch?options=-c%20client_min_messages%3DNOTICE&application_name=freeswitch" /> -->
<!-- <param name="core-db-dsn" value="dsn:username:password" /> -->
<!--
Allow to specify the sqlite db at a different location (In this example, move it to ramdrive for
--- /dev/null
+<configuration name="pre_load_modules.conf" description="Modules">\r
+ <modules>\r
+ <!-- Databases -->\r
+ <load module="mod_pgsql"/>\r
+ </modules>\r
+</configuration>\r
<param name="rtp-enable-zrtp" value="true"/>
+ <!--
+ Native PostgreSQL support was removed from the FreeSWITCH Core!
+ =================================
+ NOTICE: You MUST enable mod_pgsql
+ =================================
+ According to https://www.postgresql.org/docs/9.6/libpq-connect.html#LIBPQ-CONNSTRING
+ There are two accepted formats for connection strings supported by the libpq library:
+ * For plain keyword = value strings use pgsql://
+ pgsql://hostaddr=127.0.0.1 dbname=freeswitch user=freeswitch password='' options='-c client_min_messages=NOTICE'
+ * For RFC 3986 URIs use postgresql:// or postgres://
+ postgresql://
+ postgresql://localhost
+ postgresql://localhost:5433
+ postgresql://localhost/mydb
+ postgresql://user@localhost
+ postgresql://user:secret@localhost
+ postgresql://other@localhost/otherdb?connect_timeout=10&application_name=myapp
+ postgresql:///mydb?host=localhost&port=5433
+ -->
<!-- <param name="core-db-dsn" value="pgsql://hostaddr=127.0.0.1 dbname=freeswitch user=freeswitch password='' options='-c client_min_messages=NOTICE'" /> -->
+ <!-- <param name="core-db-dsn" value="postgresql://freeswitch:@127.0.0.1/freeswitch?options=-c%20client_min_messages%3DNOTICE" /> -->
<!-- <param name="core-db-dsn" value="dsn:username:password" /> -->
<!--
Allow to specify the sqlite db at a different location (In this example, move it to ramdrive for
--- /dev/null
+<configuration name="pre_load_modules.conf" description="Modules">\r
+ <modules>\r
+ <!-- Databases -->\r
+ <load module="mod_pgsql"/>\r
+ </modules>\r
+</configuration>\r
-->
<!-- <param name="rtp-retain-crypto-keys" value="true"/> -->
+ <!--
+ Native PostgreSQL support was removed from the FreeSWITCH Core!
+ =================================
+ NOTICE: You MUST enable mod_pgsql
+ =================================
+ According to https://www.postgresql.org/docs/9.6/libpq-connect.html#LIBPQ-CONNSTRING
+ There are two accepted formats for connection strings supported by the libpq library:
+ * For plain keyword = value strings use pgsql://
+ pgsql://hostaddr=127.0.0.1 dbname=freeswitch user=freeswitch password='' options='-c client_min_messages=NOTICE'
+ * For RFC 3986 URIs use postgresql:// or postgres://
+ postgresql://
+ postgresql://localhost
+ postgresql://localhost:5433
+ postgresql://localhost/mydb
+ postgresql://user@localhost
+ postgresql://user:secret@localhost
+ postgresql://other@localhost/otherdb?connect_timeout=10&application_name=myapp
+ postgresql:///mydb?host=localhost&port=5433
+ -->
<!-- <param name="core-db-dsn" value="pgsql://hostaddr=127.0.0.1 dbname=freeswitch user=freeswitch password='' options='-c client_min_messages=NOTICE'" /> -->
+ <!-- <param name="core-db-dsn" value="postgresql://freeswitch:@127.0.0.1/freeswitch?options=-c%20client_min_messages%3DNOTICE" /> -->
<!-- <param name="core-db-dsn" value="dsn:username:password" /> -->
<!--
Allow to specify the sqlite db at a different location (In this example, move it to ramdrive for
SWITCH_AM_LDFLAGS="$LIBUUID_LIBS $SWITCH_AM_LDFLAGS"
SWITCH_AM_CFLAGS="$LIBUUID_CFLAGS $SWITCH_AM_CFLAGS"
-AC_ARG_ENABLE(core-pgsql-support,
- [AS_HELP_STRING([--enable-core-pgsql-support], [Compile with PGSQL Support])],,[enable_core_pgsql_support="no"])
AC_ARG_ENABLE(core-pgsql-pkgconfig,
[AS_HELP_STRING([--disable-core-pgsql-pkgconfig], [Use pg_config to get PGQSL build options])],[enable_core_pgsql_pkgconfig="$enableval"],[enable_core_pgsql_pkgconfig="yes"])
-if test x"$enable_core_pgsql_support" = x"yes" ; then
- AC_PATH_PROG([PG_CONFIG], [pg_config], [no])
- AC_PATH_PROG([PKG_CONFIG], [pkg-config], [no])
- if test "$PKG_CONFIG" = "no" \
- || test x"$enable_core_pgsql_pkgconfig" = x"no" \
- || ! pkg-config libpq; then
+path_remove () {
+ echo "$1" | tr ':' '\n' | grep -Fxv "$2" | tr '\n' ':' | sed 's/:$//'
+}
+path_push_unique () {
+ x="$(eval echo \$$1)"
+ x="$(path_remove "$x" "$2")"
+ if test -z "$x"; then
+ eval export $1="$2"
+ else
+ eval export $1="$2:$x"
+ fi
+}
+
+AC_PATH_PROG([PG_CONFIG], [pg_config], [no])
+AC_PATH_PROG([PKG_CONFIG], [pkg-config], [no])
+
+case $host in
+ *-darwin*)
+ path_push_unique PKG_CONFIG_PATH /usr/local/opt/libpq/lib/pkgconfig
+ ;;
+esac
+
+if test "$PKG_CONFIG" = "no" \
+ || test x"$enable_core_pgsql_pkgconfig" = x"no" \
+ || ! pkg-config libpq; then
if test "$PG_CONFIG" != "no"; then
- AC_MSG_CHECKING([for PostgreSQL libraries via pg_config])
- POSTGRESQL_CFLAGS="-I`$PG_CONFIG --includedir`"
- POSTGRESQL_LIBDIR="-L`$PG_CONFIG --libdir`"
- POSTGRESQL_LDFLAGS="-L`$PG_CONFIG --libdir` -lpq"
- POSTGRESQL_VERSION=`$PG_CONFIG --version | awk '{ print $NF }'`
- POSTGRESQL_MAJOR_VERSION=`$PG_CONFIG --version | awk '{ print $NF }' | awk -F. '{ print $1 }'`
- POSTGRESQL_MINOR_VERSION=`$PG_CONFIG --version | awk '{ print $NF }' | awk -F. '{ print $2 }'`
- POSTGRESQL_PATCH_VERSION=`$PG_CONFIG --version | awk '{ print $NF }' | awk -F. '{ print $3 }'`
- else
- AC_MSG_ERROR([no usable pkg-config or pg_config; please install libpq devel package or equivalent])
- fi
- else
- AC_MSG_CHECKING([for PostgreSQL libraries via pkg_config])
- POSTGRESQL_CFLAGS="`$PKG_CONFIG --cflags libpq`"
- POSTGRESQL_LIBDIR="`$PKG_CONFIG libpq --libs-only-L`"
- POSTGRESQL_LDFLAGS="`$PKG_CONFIG --libs libpq`"
- POSTGRESQL_VERSION="`$PKG_CONFIG --modversion libpq`"
- POSTGRESQL_MAJOR_VERSION="`echo $POSTGRESQL_VERSION | cut -d. -f1 | sed 's/^\([[0-9]]*\)[[^0-9]].*/\1/'`"
- POSTGRESQL_MINOR_VERSION="`echo $POSTGRESQL_VERSION | cut -d. -f2 | sed 's/^\([[0-9]]*\)[[^0-9]].*/\1/'`"
- POSTGRESQL_PATCH_VERSION="`echo $POSTGRESQL_VERSION | cut -d. -f3 | sed 's/^\([[0-9]]*\)[[^0-9]].*/\1/'`"
- test -n "$POSTGRESQL_PATCH_VERSION" || POSTGRESQL_PATCH_VERSION=0
- fi
- save_LIBS="$LIBS"
- LIBS="$POSTGRESQL_LIBDIR $LIBS"
- AC_MSG_RESULT([$POSTGRESQL_LIBDIR])
-
- AC_DEFINE([SWITCH_HAVE_PGSQL], [1], [Define to 1 if PostgreSQL libraries are available])
- AM_CONDITIONAL([HAVE_PGSQL],[true])
- AC_DEFINE_UNQUOTED([POSTGRESQL_VERSION], "${POSTGRESQL_VERSION}", [Specifies the version of PostgreSQL we are linking against])
- AC_DEFINE_UNQUOTED([POSTGRESQL_MAJOR_VERSION], ${POSTGRESQL_MAJOR_VERSION}, [Specifies the version of PostgreSQL we are linking against])
- AC_DEFINE_UNQUOTED([POSTGRESQL_MINOR_VERSION], ${POSTGRESQL_MINOR_VERSION}, [Specifies the version of PostgreSQL we are linking against])
- AC_DEFINE_UNQUOTED([POSTGRESQL_PATCH_VERSION], ${POSTGRESQL_PATCH_VERSION}, [Specifies the version of PostgreSQL we are linking against])
-
- AC_CHECK_LIB([pq], [PQgetvalue],, AC_MSG_ERROR([no usable libpq; please install PostgreSQL devel package or equivalent]))
- AC_MSG_RESULT([yes])
- SWITCH_AM_CXXFLAGS="$POSTGRESQL_CFLAGS $SWITCH_AM_CXXFLAGS"
- SWITCH_AM_LDFLAGS="$POSTGRESQL_LDFLAGS $SWITCH_AM_LDFLAGS"
-
- LIBS="$save_LIBS"
+ AC_MSG_CHECKING([for PostgreSQL libraries via pg_config])
+ POSTGRESQL_CFLAGS="-I`$PG_CONFIG --includedir`"
+ POSTGRESQL_LIBDIR="-L`$PG_CONFIG --libdir`"
+ POSTGRESQL_LDFLAGS="-L`$PG_CONFIG --libdir` -lpq"
+ POSTGRESQL_VERSION=`$PG_CONFIG --version | awk '{ print $NF }'`
+ POSTGRESQL_MAJOR_VERSION=`$PG_CONFIG --version | awk '{ print $NF }' | awk -F. '{ print $1 }'`
+ POSTGRESQL_MINOR_VERSION=`$PG_CONFIG --version | awk '{ print $NF }' | awk -F. '{ print $2 }'`
+ POSTGRESQL_PATCH_VERSION=`$PG_CONFIG --version | awk '{ print $NF }' | awk -F. '{ print $3 }'`
+ fi
else
- AM_CONDITIONAL([HAVE_PGSQL],[false])
+
+ AC_MSG_CHECKING([for PostgreSQL libraries via pkg_config])
+ POSTGRESQL_CFLAGS="`$PKG_CONFIG --cflags libpq`"
+ POSTGRESQL_LIBDIR="`$PKG_CONFIG libpq --libs-only-L`"
+ POSTGRESQL_LDFLAGS="`$PKG_CONFIG --libs libpq`"
+ POSTGRESQL_VERSION="`$PKG_CONFIG --modversion libpq`"
+ POSTGRESQL_MAJOR_VERSION="`echo $POSTGRESQL_VERSION | cut -d. -f1 | sed 's/^\([[0-9]]*\)[[^0-9]].*/\1/'`"
+ POSTGRESQL_MINOR_VERSION="`echo $POSTGRESQL_VERSION | cut -d. -f2 | sed 's/^\([[0-9]]*\)[[^0-9]].*/\1/'`"
+ POSTGRESQL_PATCH_VERSION="`echo $POSTGRESQL_VERSION | cut -d. -f3 | sed 's/^\([[0-9]]*\)[[^0-9]].*/\1/'`"
+ test -n "$POSTGRESQL_PATCH_VERSION" || POSTGRESQL_PATCH_VERSION=0
fi
+AC_MSG_RESULT([$POSTGRESQL_LIBDIR])
+AC_DEFINE_UNQUOTED([POSTGRESQL_VERSION], "${POSTGRESQL_VERSION}", [Specifies the version of PostgreSQL we are linking against])
+AC_DEFINE_UNQUOTED([POSTGRESQL_MAJOR_VERSION], ${POSTGRESQL_MAJOR_VERSION}, [Specifies the version of PostgreSQL we are linking against])
+AC_DEFINE_UNQUOTED([POSTGRESQL_MINOR_VERSION], ${POSTGRESQL_MINOR_VERSION}, [Specifies the version of PostgreSQL we are linking against])
+AC_DEFINE_UNQUOTED([POSTGRESQL_PATCH_VERSION], ${POSTGRESQL_PATCH_VERSION}, [Specifies the version of PostgreSQL we are linking against])
+have_libpq=no
+AC_CHECK_LIB([pq], [PQgetvalue], [have_libpq="yes"])
+AM_CONDITIONAL([HAVE_PGSQL],[test "${have_libpq}" = "yes"])
+AC_SUBST([POSTGRESQL_CFLAGS], [$POSTGRESQL_CFLAGS])
+AC_SUBST([POSTGRESQL_LDFLAGS], [$POSTGRESQL_LDFLAGS])
+AC_SUBST([POSTGRESQL_LIBDIR], [$POSTGRESQL_LIBDIR])
AC_ARG_ENABLE(deprecated-core-db-events,
[AS_HELP_STRING([--enable-deprecated-core-db-events], [Keep deprecated core db events])],,[enable_deprecated_core_db_events="no"])
PLATFORM_CORE_LDFLAGS=
PLATFORM_CORE_LIBS=
-path_remove () {
- echo "$1" | tr ':' '\n' | grep -Fxv "$2" | tr '\n' ':' | sed 's/:$//'
-}
-path_push_unique () {
- x="$(eval echo \$$1)"
- x="$(path_remove "$x" "$2")"
- if test -z "$x"; then
- eval export $1="$2"
- else
- eval export $1="$2:$x"
- fi
-}
-
# tweak platform specific flags
case "$host" in
*darwin*)
src/mod/codecs/mod_siren/Makefile
src/mod/codecs/mod_skel_codec/Makefile
src/mod/codecs/mod_theora/Makefile
+ src/mod/databases/mod_pgsql/Makefile
src/mod/dialplans/mod_dialplan_asterisk/Makefile
src/mod/dialplans/mod_dialplan_directory/Makefile
src/mod/dialplans/mod_dialplan_xml/Makefile
freeswitch-mod-dptools (= \${binary:Version}),
freeswitch-mod-fifo (= \${binary:Version}),
freeswitch-mod-hash (= \${binary:Version}),
+ freeswitch-mod-pgsql (= \${binary:Version}),
freeswitch-mod-spandsp (= \${binary:Version}),
freeswitch-mod-voicemail (= \${binary:Version}),
freeswitch-mod-dialplan-xml (= \${binary:Version}),
freeswitch-mod-expr (= \${binary:Version}),
freeswitch-mod-fifo (= \${binary:Version}),
freeswitch-mod-hash (= \${binary:Version}),
+ freeswitch-mod-pgsql (= \${binary:Version}),
freeswitch-mod-voicemail (= \${binary:Version}),
freeswitch-mod-esf (= \${binary:Version}),
freeswitch-mod-fsv (= \${binary:Version}),
freeswitch-mod-lcr (= \${binary:Version}),
freeswitch-mod-nibblebill (= \${binary:Version}),
freeswitch-mod-oreka (= \${binary:Version}),
+ freeswitch-mod-pgsql (= \${binary:Version}),
freeswitch-mod-redis (= \${binary:Version}),
freeswitch-mod-rss (= \${binary:Version}),
freeswitch-mod-sms (= \${binary:Version}),
freeswitch-mod-memcache (= \${binary:Version}),
freeswitch-mod-nibblebill (= \${binary:Version}),
freeswitch-mod-oreka (= \${binary:Version}),
+ freeswitch-mod-pgsql (= \${binary:Version}),
freeswitch-mod-png (= \${binary:Version}),
freeswitch-mod-redis (= \${binary:Version}),
freeswitch-mod-rss (= \${binary:Version}),
freeswitch-mod-memcache-dbg (= \${binary:Version}),
freeswitch-mod-nibblebill-dbg (= \${binary:Version}),
freeswitch-mod-oreka-dbg (= \${binary:Version}),
+ freeswitch-mod-pgsql-dbg (= \${binary:Version}),
freeswitch-mod-png-dbg (= \${binary:Version}),
freeswitch-mod-redis-dbg (= \${binary:Version}),
freeswitch-mod-rss-dbg (= \${binary:Version}),
Description: Adds mod_yuv
Adds mod_yuv.
+## mod/databases
+
+Module: databases/mod_pgsql
+Description: Adds mod_pgsql
+ Adds mod_pgsql.
+Build-Depends: libpq-dev
+
## mod/dialplans
Module: dialplans/mod_dialplan_asterisk
--host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) \
--prefix=/usr --localstatedir=/var --sysconfdir=/etc \
--with-gnu-ld --with-python --with-erlang --with-openssl \
- --enable-core-odbc-support --enable-zrtp \
- --enable-core-pgsql-support
+ --enable-core-odbc-support --enable-zrtp
touch $@
override_dh_auto_configure: .stamp-configure
# spec file for package freeswitch
#
# includes module(s): freeswitch-devel freeswitch-codec-passthru-amr freeswitch-codec-passthru-amrwb freeswitch-codec-passthru-g729
-# freeswitch-codec-passthru-g7231 freeswitch-lua freeswitch-perl freeswitch-python freeswitch-v8 freeswitch-signalwire
+# freeswitch-codec-passthru-g7231 freeswitch-lua freeswitch-pgsql freeswitch-perl freeswitch-python freeswitch-v8 freeswitch-signalwire
# freeswitch-lan-de freeswitch-lang-en freeswitch-lang-fr freeswitch-lang-hu freeswitch-lang-ru freeswitch-freetdm
# and others
#
%description codec-theora
Theora Video Codec support for FreeSWITCH open source telephony platform.
+######################################################################################################################
+# FreeSWITCH Database Modules
+######################################################################################################################
+
+%package database-pgsql
+Summary: PostgreSQL native support for FreeSWITCH
+Group: System/Libraries
+Requires: %{name} = %{version}-%{release}
+Requires: postgresql-libs
+BuildRequires: postgresql-devel
+
+%description database-pgsql
+PostgreSQL native support for FreeSWITCH.
+
######################################################################################################################
# FreeSWITCH Directory Modules
######################################################################################################################
Requires: freeswitch-codec-h26x
Requires: freeswitch-codec-ilbc
Requires: freeswitch-codec-siren
+Requires: freeswitch-database-pgsql
Requires: freeswitch-format-local-stream
Requires: freeswitch-format-native-file
Requires: freeswitch-format-portaudio-stream
CODECS_MODULES+="codecs/mod_sangoma_codec"
%endif
+######################################################################################################################
+#
+# Database Modules
+#
+######################################################################################################################
+DATABASES_MODULES="databases/mod_pgsql"
+
######################################################################################################################
#
# Dialplan Modules
# Create one environment variable out of all the module defs
#
######################################################################################################################
-MYMODULES="$APPLICATIONS_MODULES $CODECS_MODULES $DIALPLANS_MODULES $DIRECTORIES_MODULES \
+MYMODULES="$APPLICATIONS_MODULES $CODECS_MODULES $DATABASES_MODULES $DIALPLANS_MODULES $DIRECTORIES_MODULES \
$ENDPOINTS_MODULES $ASR_TTS_MODULES $EVENT_HANDLERS_MODULES $FORMATS_MODULES $LANGUAGES_MODULES $LOGGERS_MODULES \
$SAY_MODULES $TIMERS_MODULES $XML_INT_MODULES"
--with-dbdir=%{DBDIR} \
--with-htdocsdir=%{HTDOCSDIR} \
--with-soundsdir=%{SOUNDSDIR} \
---enable-core-pgsql-support \
--enable-core-odbc-support \
--enable-core-libedit-support \
--with-grammardir=%{GRAMMARDIR} \
%config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/autoload_configs/pocketsphinx.conf.xml
%config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/autoload_configs/portaudio.conf.xml
%config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/autoload_configs/post_load_modules.conf.xml
+%config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/autoload_configs/pre_load_modules.conf.xml
%config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/autoload_configs/presence_map.conf.xml
%config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/autoload_configs/redis.conf.xml
%config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/autoload_configs/rss.conf.xml
%files codec-theora
%{MODINSTDIR}/mod_theora.so*
+######################################################################################################################
+#
+# FreeSWITCH Database Modules
+#
+######################################################################################################################
+
+%files database-pgsql
+%{MODINSTDIR}/mod_pgsql.so*
+
######################################################################################################################
#
# FreeSWITCH Directory Modules
#include "switch_config.h"
#include "switch_nat.h"
#include "switch_odbc.h"
-#include "switch_pgsql.h"
#include "switch_json.h"
#include "switch_limit.h"
#include "switch_core_media.h"
typedef enum {
SCDB_TYPE_CORE_DB,
SCDB_TYPE_ODBC,
- SCDB_TYPE_PGSQL,
SCDB_TYPE_DATABASE_INTERFACE
} switch_cache_db_handle_type_t;
typedef union {
switch_core_db_t *core_db_dbh;
switch_odbc_handle_t *odbc_dbh;
- switch_pgsql_handle_t *pgsql_dbh;
switch_database_interface_handle_t *database_interface_dbh;
} switch_cache_db_native_handle_t;
} switch_cache_db_odbc_options_t;
typedef struct {
- char *dsn;
-} switch_cache_db_pgsql_options_t;
-
-typedef struct {
- char *dsn;
+ const char *original_dsn;
+ char *connection_string;
char prefix[16];
switch_database_interface_t *database_interface;
switch_bool_t make_module_no_unloadable;
typedef union {
switch_cache_db_core_db_options_t core_db_options;
switch_cache_db_odbc_options_t odbc_options;
- switch_cache_db_pgsql_options_t pgsql_options;
switch_cache_db_database_interface_options_t database_interface_options;
} switch_cache_db_connection_options_t;
type_str = "DATABASE_INTERFACE";
}
break;
- case SCDB_TYPE_PGSQL:
- {
- type_str = "PGSQL";
- }
- break;
case SCDB_TYPE_ODBC:
{
type_str = "ODBC";
*/
SWITCH_DECLARE(switch_status_t) switch_core_check_core_db_dsn(void);
+/*!
+\brief Returns error if no suitable database interface found for a dsn.
+*/
+SWITCH_DECLARE(switch_status_t) switch_database_available(char* dsn);
+
SWITCH_DECLARE(void) switch_core_set_signal_handlers(void);
SWITCH_DECLARE(uint32_t) switch_core_debug_level(void);
SWITCH_DECLARE(int32_t) switch_core_sps(void);
const char *interface_name;
/*! flags indicating database specifics, see switch_database_flag_t */
uint32_t flags;
- switch_status_t(*handle_new)(char *dsn, switch_database_interface_handle_t **dih);
+ switch_status_t(*handle_new)(switch_cache_db_database_interface_options_t database_interface_options, switch_database_interface_handle_t **dih);
switch_status_t(*handle_destroy)(switch_database_interface_handle_t **dih);
switch_status_t(*flush)(switch_database_interface_handle_t *dih);
switch_status_t(*exec_detailed)(const char *file, const char *func, int line,
+++ /dev/null
-/*
- * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
- * Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
- *
- * Version: MPL 1.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
- *
- * The Initial Developer of the Original Code is
- * Anthony Minessale II <anthm@freeswitch.org>
- * Portions created by the Initial Developer are Copyright (C)
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Anthony Minessale II <anthm@freeswitch.org>
- * Eliot Gable <egable@gmail.com>
- *
- * switch_pgsql.h -- PGSQL Driver
- *
- */
-
-#ifndef SWITCH_PGSQL_H
-#define SWITCH_PGSQL_H
-
-#include <switch.h>
-
-#define DEFAULT_PGSQL_RETRIES 120
-
-SWITCH_BEGIN_EXTERN_C
-
-struct switch_pgsql_handle;
-struct switch_pgsql_result;
-
-
-typedef enum {
- SWITCH_PGSQL_STATE_INIT,
- SWITCH_PGSQL_STATE_DOWN,
- SWITCH_PGSQL_STATE_CONNECTED,
- SWITCH_PGSQL_STATE_ERROR
-} switch_pgsql_state_t;
-
-typedef enum {
- SWITCH_PGSQL_SUCCESS = 0,
- SWITCH_PGSQL_FAIL = -1
-} switch_pgsql_status_t;
-
-/*!
- \brief Create a new handle for the PGSQL connection.
- \param dsn The DSN of the database to connect to. See documentation for PQconnectdb() at
- http://www.postgresql.org/docs/9.0/static/libpq-connect.html. The DSN *MUST* be
- prefixed with 'pgsql;' to use the switch_cache_db* functionality. However, the DSN
- passed to this function directly *MUST NOT* be prefixed with 'pgsql;'.
- \return Returns a pointer to a newly allocated switch_pgsql_handle_t type or NULL on failure.
- */
-SWITCH_DECLARE(switch_pgsql_handle_t *) switch_pgsql_handle_new(const char *dsn);
-
-/*!
- \brief Sets the number of retries if the PGSQL connection fails.
- \param handle A fully allocated switch_pgsql_handle_t returned from a call to switch_pgsql_handle_new().
- \param num_retries How many times to retry connecting to the database if this connection fails.
- */
-SWITCH_DECLARE(void) switch_pgsql_set_num_retries(switch_pgsql_handle_t *handle, int num_retries);
-
-/*!
- \brief Disconnects a PGSQL connection from the database.
- \param handle The PGSQL database handle to disconnect.
- \return Returns SWITCH_PGSQL_SUCCESS or SWITCH_PGSQL_FAIL.
- */
-SWITCH_DECLARE(switch_pgsql_status_t ) switch_pgsql_handle_disconnect(switch_pgsql_handle_t *handle);
-#if 0
- ) /* Emacs formatting issue */
-#endif
-/*!
- \brief Connect to the database specified by the DSN passed to the switch_pgsql_handle_new() call which
- initialized this handle.
- \param The database handle to connect to the database.
- \return Returns SWITCH_PGSQL_SUCCESS or SWITCH_PGSQL_FAIL.
- */
-SWITCH_DECLARE(switch_pgsql_status_t) switch_pgsql_handle_connect(switch_pgsql_handle_t *handle);
-
-/*!
- */
-SWITCH_DECLARE(void) switch_pgsql_handle_destroy(switch_pgsql_handle_t **handlep);
-
-SWITCH_DECLARE(switch_pgsql_status_t) switch_pgsql_send_query(switch_pgsql_handle_t *handle, const char* sql);
-
-SWITCH_DECLARE(switch_pgsql_status_t) switch_pgsql_cancel_real(const char *file, const char *func, int line, switch_pgsql_handle_t *handle);
-#define switch_pgsql_cancel(handle) switch_pgsql_cancel_real(__FILE__, (char * )__SWITCH_FUNC__, __LINE__, handle)
-
-SWITCH_DECLARE(switch_pgsql_status_t) switch_pgsql_next_result_timed(switch_pgsql_handle_t *handle, switch_pgsql_result_t **result_out, int seconds);
-#define switch_pgsql_next_result(h, r) switch_pgsql_next_result_timed(h, r, 10000)
-
-SWITCH_DECLARE(void) switch_pgsql_free_result(switch_pgsql_result_t **result);
-
-SWITCH_DECLARE(switch_pgsql_status_t) switch_pgsql_finish_results_real(const char* file, const char *func, int line, switch_pgsql_handle_t *handle);
-#define switch_pgsql_finish_results(handle) switch_pgsql_finish_results_real(__FILE__, (char * )__SWITCH_FUNC__, __LINE__, handle)
-
-SWITCH_DECLARE(switch_pgsql_status_t) switch_pgsql_handle_exec_base_detailed(const char *file, const char *func, int line,
- switch_pgsql_handle_t *handle, const char *sql, char **err);
-#define switch_pgsql_handle_exec_base(handle, sql, err) switch_pgsql_handle_exec_base_detailed(__FILE__, (char * )__SWITCH_FUNC__, __LINE__, handle, sql, err)
-
-SWITCH_DECLARE(switch_pgsql_state_t) switch_pgsql_handle_get_state(switch_pgsql_handle_t *handle);
-
-SWITCH_DECLARE(switch_pgsql_status_t) switch_pgsql_handle_exec_detailed(const char *file, const char *func, int line,
- switch_pgsql_handle_t *handle, const char *sql, char **err);
-#define switch_pgsql_handle_exec(handle, sql, err) switch_pgsql_handle_exec_detailed(__FILE__, (char * )__SWITCH_FUNC__, __LINE__, handle, sql, err)
-
-SWITCH_DECLARE(switch_pgsql_status_t) switch_pgsql_handle_exec_string_detailed(const char *file, const char *func, int line,
- switch_pgsql_handle_t *handle, const char *sql, char *resbuf, size_t len, char **err);
-#define switch_pgsql_handle_exec_string(handle, sql, resbuf, len, err) switch_pgsql_handle_exec_string_detailed(__FILE__, (char * )__SWITCH_FUNC__, __LINE__, handle, sql, resbuf, len, err)
-
-SWITCH_DECLARE(switch_bool_t) switch_pgsql_available(void);
-SWITCH_DECLARE(switch_pgsql_status_t) switch_pgsql_SQLSetAutoCommitAttr(switch_pgsql_handle_t *handle, switch_bool_t on);
-SWITCH_DECLARE(switch_pgsql_status_t) switch_pgsql_SQLEndTran(switch_pgsql_handle_t *handle, switch_bool_t commit);
-
-/*!
- \brief Execute the sql query and issue a callback for each row returned
- \param file the file from which this function is called
- \param func the function from which this function is called
- \param line the line from which this function is called
- \param handle the PGSQL handle
- \param sql the sql string to execute
- \param callback the callback function to execute
- \param pdata the state data passed on each callback invocation
- \return SWITCH_STATUS_SUCCESS if the operation was successful
- \note none
-*/
-SWITCH_DECLARE(switch_pgsql_status_t) switch_pgsql_handle_callback_exec_detailed(const char *file, const char *func, int line, switch_pgsql_handle_t *handle,
- const char *sql, switch_core_db_callback_func_t callback, void *pdata,
- char **err);
-/*!
- \brief Execute the sql query and issue a callback for each row returned
- \param handle the PGSQL handle
- \param sql the sql string to execute
- \param callback the callback function to execute
- \param pdata the state data passed on each callback invocation
- \return SWITCH_STATUS_SUCCESS if the operation was successful
- \note none
-*/
-#define switch_pgsql_handle_callback_exec(handle, sql, callback, pdata, err) \
- switch_pgsql_handle_callback_exec_detailed(__FILE__, (char * )__SWITCH_FUNC__, __LINE__, \
- handle, sql, callback, pdata, err)
-
-
-SWITCH_DECLARE(char *) switch_pgsql_handle_get_error(switch_pgsql_handle_t *handle);
-
-SWITCH_DECLARE(int) switch_pgsql_handle_affected_rows(switch_pgsql_handle_t *handle);
-SWITCH_DECLARE(switch_pgsql_status_t) switch_pgsql_flush(switch_pgsql_handle_t *handle);
-
-
-SWITCH_END_EXTERN_C
-#endif
-/* For Emacs:
- * Local Variables:
- * mode:c
- * indent-tabs-mode:t
- * tab-width:4
- * c-basic-offset:4
- * End:
- * For VIM:
- * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet:
- */
typedef union switch_codec_settings switch_codec_settings_t;
typedef struct switch_codec_fmtp switch_codec_fmtp_t;
typedef struct switch_odbc_handle switch_odbc_handle_t;
-typedef struct switch_pgsql_handle switch_pgsql_handle_t;
-typedef struct switch_pgsql_result switch_pgsql_result_t;
typedef struct switch_database_interface_handle switch_database_interface_handle_t;
typedef struct switch_io_routines switch_io_routines_t;
char *val = (char *) switch_xml_attr_soft(param, "value");
if (!strcasecmp(var, "odbc-dsn") && !zstr(val)) {
- if (switch_odbc_available() || switch_pgsql_available()) {
+ if (switch_database_available(val)) {
switch_set_string(globals.odbc_dsn, val);
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ODBC IS NOT AVAILABLE!\n");
if (!strcasecmp(var, "outbound-strategy") && !zstr(val)) {
globals.default_strategy = parse_strategy(val);
} else if (!strcasecmp(var, "odbc-dsn") && !zstr(val)) {
- if (switch_odbc_available() || switch_pgsql_available()) {
+ if (switch_database_available(val)) {
switch_set_string(globals.odbc_dsn, val);
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ODBC IS NOT AVAILABLE!\n");
--- /dev/null
+include $(top_srcdir)/build/modmake.rulesam
+MODNAME=mod_pgsql
+
+if HAVE_PGSQL
+
+
+mod_LTLIBRARIES = mod_pgsql.la
+mod_pgsql_la_SOURCES = mod_pgsql.c
+mod_pgsql_la_CFLAGS = $(AM_CFLAGS) $(POSTGRESQL_CFLAGS)
+mod_pgsql_la_LIBADD = $(switch_builddir)/libfreeswitch.la
+mod_pgsql_la_LDFLAGS = -avoid-version -module -no-undefined -shared $(POSTGRESQL_LDFLAGS)
+
+else
+install: error
+all: error
+error:
+ $(error You must install libpq-dev to build mod_pgsql)
+endif
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectName>mod_pgsql</ProjectName>
+ <RootNamespace>mod_pgsql</RootNamespace>
+ <Keyword>Win32Proj</Keyword>
+ <ProjectGuid>{1BA65811-5453-46F6-8190-9ECEEFEB7DF2}</ProjectGuid>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v141</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v141</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v141</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v141</PlatformToolset>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <Import Project="..\..\..\..\w32\libpq.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ <Import Project="..\..\..\..\w32\module_release.props" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ <Import Project="..\..\..\..\w32\module_debug.props" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ <Import Project="..\..\..\..\w32\module_release.props" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ <Import Project="..\..\..\..\w32\module_debug.props" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <AdditionalIncludeDirectories>;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;MOD_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ </ClCompile>
+ <Link>
+ <AdditionalLibraryDirectories>;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <DataExecutionPrevention>
+ </DataExecutionPrevention>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <Midl>
+ <TargetEnvironment>X64</TargetEnvironment>
+ </Midl>
+ <ClCompile>
+ <AdditionalIncludeDirectories>;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;MOD_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ </ClCompile>
+ <Link>
+ <AdditionalLibraryDirectories>;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <DataExecutionPrevention>
+ </DataExecutionPrevention>
+ <TargetMachine>MachineX64</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <AdditionalIncludeDirectories>;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;MOD_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ </ClCompile>
+ <Link>
+ <AdditionalLibraryDirectories>;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <DataExecutionPrevention>
+ </DataExecutionPrevention>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <Midl>
+ <TargetEnvironment>X64</TargetEnvironment>
+ </Midl>
+ <ClCompile>
+ <AdditionalIncludeDirectories>;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;MOD_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ </ClCompile>
+ <Link>
+ <AdditionalLibraryDirectories>;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <DataExecutionPrevention>
+ </DataExecutionPrevention>
+ <TargetMachine>MachineX64</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="mod_pgsql.c" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\..\..\..\w32\Library\FreeSwitchCore.2017.vcxproj">
+ <Project>{202d7a4e-760d-4d0e-afa1-d7459ced30ff}</Project>
+ <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project>
/*
- * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
- * Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
- *
- * Version: MPL 1.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
- *
- * The Initial Developer of the Original Code is
- * Anthony Minessale II <anthm@freeswitch.org>
- * Portions created by the Initial Developer are Copyright (C)
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Anthony Minessale II <anthm@freeswitch.org>
- * Eliot Gable <egable@gmail.com>
- * Seven Du <dujinfang@gmail.com>
- *
- * switch_pgsql.c -- PGSQL Driver
- *
- */
+* mod_pgsql for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ * Copyright (C) 2005-2019, Anthony Minessale II <anthm@freeswitch.org>
+*
+* Version: MPL 1.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+* The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+*
+* The Initial Developer of the Original Code is
+* Anthony Minessale II <anthm@freeswitch.org>
+* Portions created by the Initial Developer are Copyright (C)
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Anthony Minessale II <anthm@freeswitch.org>
+* Eliot Gable <egable@gmail.com>
+* Seven Du <dujinfang@gmail.com>
+* Andrey Volk <andywolk@gmail.com>
+*
+* mod_pgsql.c -- PostgreSQL FreeSWITCH module
+*
+*/
-#include <switch.h>
+#define SWITCH_PGSQL_H
-#ifndef WIN32
-#include <switch_private.h>
-#endif
+#include <switch.h>
-#ifdef SWITCH_HAVE_PGSQL
#include <libpq-fe.h>
#ifndef _WIN32
#include <poll.h>
#else
-#include <winsock2.h>
+#include <WinSock2.h>
#endif
+switch_loadable_module_interface_t *MODULE_INTERFACE;
+static char *supported_prefixes[4] = { 0 };
+
+SWITCH_MODULE_LOAD_FUNCTION(mod_pgsql_load);
+SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_pgsql_shutdown);
+SWITCH_MODULE_DEFINITION(mod_pgsql, mod_pgsql_load, mod_pgsql_shutdown, NULL);
+
+#define DEFAULT_PGSQL_RETRIES 120
+
+typedef enum {
+ SWITCH_PGSQL_STATE_INIT,
+ SWITCH_PGSQL_STATE_DOWN,
+ SWITCH_PGSQL_STATE_CONNECTED,
+ SWITCH_PGSQL_STATE_ERROR
+} switch_pgsql_state_t;
struct switch_pgsql_handle {
char *dsn;
int rows;
int cols;
};
-#endif
-SWITCH_DECLARE(switch_pgsql_handle_t *) switch_pgsql_handle_new(const char *dsn)
-{
-#ifdef SWITCH_HAVE_PGSQL
- switch_pgsql_handle_t *new_handle;
+typedef struct switch_pgsql_handle switch_pgsql_handle_t;
+typedef struct switch_pgsql_result switch_pgsql_result_t;
- if (!(new_handle = malloc(sizeof(*new_handle)))) {
- goto err;
- }
+switch_status_t pgsql_handle_connect(switch_pgsql_handle_t *handle);
+switch_status_t pgsql_handle_destroy(switch_database_interface_handle_t **dih);
+switch_status_t pgsql_cancel_real(const char *file, const char *func, int line, switch_pgsql_handle_t *handle);
+switch_status_t pgsql_next_result_timed(switch_pgsql_handle_t *handle, switch_pgsql_result_t **result_out, int msec);
- memset(new_handle, 0, sizeof(*new_handle));
+#define pgsql_handle_exec_base(handle, sql, err) pgsql_handle_exec_base_detailed(__FILE__, (char * )__SWITCH_FUNC__, __LINE__, handle, sql, err)
+#define pgsql_next_result(h, r) pgsql_next_result_timed(h, r, 10000)
+#define pgsql_finish_results(handle) pgsql_finish_results_real(__FILE__, (char * )__SWITCH_FUNC__, __LINE__, handle)
+#define pgsql_cancel(handle) pgsql_cancel_real(__FILE__, (char * )__SWITCH_FUNC__, __LINE__, handle)
- if (!(new_handle->dsn = strdup(dsn))) {
- goto err;
- }
+char * pgsql_handle_get_error(switch_pgsql_handle_t *handle)
+{
+ char * err_str;
- new_handle->sock = 0;
- new_handle->state = SWITCH_PGSQL_STATE_INIT;
- new_handle->con = NULL;
- new_handle->affected_rows = 0;
- new_handle->num_retries = DEFAULT_PGSQL_RETRIES;
- new_handle->auto_commit = SWITCH_TRUE;
- new_handle->in_txn = SWITCH_FALSE;
+ if (!handle) {
+ return NULL;
+ }
- return new_handle;
+ switch_strdup(err_str, PQerrorMessage(handle->con));
- err:
- if (new_handle) {
- switch_safe_free(new_handle->dsn);
- switch_safe_free(new_handle);
- }
-#endif
- return NULL;
+ return err_str;
}
-
-#ifdef SWITCH_HAVE_PGSQL
static int db_is_up(switch_pgsql_handle_t *handle)
{
int ret = 0;
switch_event_t *event;
char *err_str = NULL;
int max_tries = DEFAULT_PGSQL_RETRIES;
- int code = 0, recon = 0;
+ int code = 0;
+ int recon = 0;
if (handle) {
max_tries = handle->num_retries;
max_tries = DEFAULT_PGSQL_RETRIES;
}
- top:
+top:
if (!handle) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "No DB Handle\n");
handle->sock = PQsocket(handle->con);
}
-/* if (!PQsendQuery(handle->con, "SELECT 1")) {
- code = __LINE__;
- goto error;
- }
-
- if(switch_pgsql_next_result(handle, &result) == SWITCH_PGSQL_FAIL) {
- code = __LINE__;
- goto error;
- }
-
- if (!result || result->status != PGRES_COMMAND_OK) {
- code = __LINE__;
- goto error;
- }
-
- switch_pgsql_free_result(&result);
- switch_pgsql_finish_results(handle);
-*/
ret = 1;
goto done;
- error:
- err_str = switch_pgsql_handle_get_error(handle);
+error:
+ err_str = pgsql_handle_get_error(handle);
if (PQstatus(handle->con) == CONNECTION_BAD) {
handle->state = SWITCH_PGSQL_STATE_ERROR;
PQreset(handle->con);
if (PQstatus(handle->con) == CONNECTION_OK) {
handle->state = SWITCH_PGSQL_STATE_CONNECTED;
- recon = SWITCH_PGSQL_SUCCESS;
+ recon = SWITCH_STATUS_SUCCESS;
handle->sock = PQsocket(handle->con);
}
}
if (switch_event_create(&event, SWITCH_EVENT_TRAP) == SWITCH_STATUS_SUCCESS) {
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Failure-Message", "The sql server is not responding for DSN %s [%s][%d]",
- switch_str_nil(handle->dsn), switch_str_nil(err_str), code);
+ switch_str_nil(handle->dsn), switch_str_nil(err_str), code);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "The sql server is not responding for DSN %s [%s][%d]\n",
- switch_str_nil(handle->dsn), switch_str_nil(err_str), code);
+ switch_str_nil(handle->dsn), switch_str_nil(err_str), code);
- if (recon == SWITCH_PGSQL_SUCCESS) {
+ if (recon == SWITCH_STATUS_SUCCESS) {
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Additional-Info", "The connection has been re-established");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "The connection has been re-established\n");
} else {
switch_yield(1000000);
goto top;
- done:
+done:
switch_safe_free(err_str);
return ret;
}
-#endif
+void pgsql_free_result(switch_pgsql_result_t **result)
+{
+ if (!*result) {
+ return;
+ }
+
+ if ((*result)->result) {
+ PQclear((*result)->result);
+ }
+ free(*result);
+ *result = NULL;
+}
-SWITCH_DECLARE(void) switch_pgsql_set_num_retries(switch_pgsql_handle_t *handle, int num_retries)
+switch_status_t pgsql_finish_results_real(const char* file, const char* func, int line, switch_pgsql_handle_t *handle)
{
-#ifdef SWITCH_HAVE_PGSQL
- if (handle) {
- handle->num_retries = num_retries;
+ switch_pgsql_result_t *res = NULL;
+ switch_status_t final_status = SWITCH_STATUS_SUCCESS;
+ int done = 0;
+
+ do {
+ pgsql_next_result(handle, &res);
+ if (res && res->err && !switch_stristr("already exists", res->err) && !switch_stristr("duplicate key name", res->err)) {
+ switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_ERROR, "Error executing query:\n%s\n", res->err);
+ final_status = SWITCH_STATUS_FALSE;
+ }
+
+ if (!res) {
+ done = 1;
+ } else if (res->result) {
+ char *affected_rows = PQcmdTuples(res->result);
+
+ if (!zstr(affected_rows)) {
+ handle->affected_rows = atoi(affected_rows);
+ }
+ }
+
+ pgsql_free_result(&res);
+ } while (!done);
+
+ return final_status;
+}
+
+switch_status_t pgsql_handle_affected_rows(switch_database_interface_handle_t *dih, int *affected_rows)
+{
+ switch_pgsql_handle_t *handle = NULL;
+
+ if (!dih) {
+ return SWITCH_STATUS_FALSE;
}
-#endif
+
+ handle = dih->handle;
+
+ if (!handle)
+ return SWITCH_STATUS_FALSE;
+
+ *affected_rows = handle->affected_rows;
+
+ return SWITCH_STATUS_SUCCESS;
}
-SWITCH_DECLARE(switch_pgsql_status_t) switch_pgsql_handle_disconnect(switch_pgsql_handle_t *handle)
+switch_status_t pgsql_handle_new(switch_cache_db_database_interface_options_t database_interface_options, switch_database_interface_handle_t **dih)
{
-#ifdef SWITCH_HAVE_PGSQL
+ switch_pgsql_handle_t *new_handle = NULL;
+
+ if (!(*dih = malloc(sizeof(**dih)))) {
+ goto err;
+ }
+
+ if (!(new_handle = malloc(sizeof(*new_handle)))) {
+ goto err;
+ }
+ memset(new_handle, 0, sizeof(*new_handle));
+
+ if (!strcasecmp(database_interface_options.prefix, "postgresql") || !strcasecmp(database_interface_options.prefix, "postgres")) {
+ new_handle->dsn = strdup(database_interface_options.original_dsn);
+ } else if (!strcasecmp(database_interface_options.prefix, "pgsql")) {
+ new_handle->dsn = strdup(database_interface_options.connection_string);
+ }
+
+ if (!new_handle->dsn) {
+ goto err;
+ }
+
+ new_handle->sock = 0;
+ new_handle->state = SWITCH_PGSQL_STATE_INIT;
+ new_handle->con = NULL;
+ new_handle->affected_rows = 0;
+ new_handle->num_retries = DEFAULT_PGSQL_RETRIES;
+ new_handle->auto_commit = SWITCH_TRUE;
+ new_handle->in_txn = SWITCH_FALSE;
+
+ (*dih)->handle = new_handle;
+
+ if (pgsql_handle_connect(new_handle) != SWITCH_STATUS_SUCCESS) {
+ if (pgsql_handle_destroy(dih) != SWITCH_STATUS_SUCCESS) {
+ goto err;
+ }
+ }
+
+ return SWITCH_STATUS_SUCCESS;
+
+err:
+ switch_safe_free(*dih);
+
+ if (new_handle) {
+ switch_safe_free(new_handle->dsn);
+ switch_safe_free(new_handle);
+ }
+
+ return SWITCH_STATUS_FALSE;
+}
+
+switch_status_t pgsql_handle_disconnect(switch_pgsql_handle_t *handle)
+{
if (!handle) {
- return SWITCH_PGSQL_FAIL;
+ return SWITCH_STATUS_FALSE;
}
if (handle->state == SWITCH_PGSQL_STATE_CONNECTED) {
switch_safe_free(handle->sql);
handle->state = SWITCH_PGSQL_STATE_DOWN;
- return SWITCH_PGSQL_SUCCESS;
-#else
- return SWITCH_PGSQL_FAIL;
-#endif
+ return SWITCH_STATUS_SUCCESS;
+}
+
+switch_status_t pgsql_handle_connect(switch_pgsql_handle_t *handle)
+{
+ if (!handle) {
+ return SWITCH_STATUS_FALSE;
+ }
+
+ if (handle->state == SWITCH_PGSQL_STATE_CONNECTED) {
+ pgsql_handle_disconnect(handle);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "Re-connecting %s\n", handle->dsn);
+ }
+
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "Connecting %s\n", handle->dsn);
+ PQinitSSL(0);
+
+ handle->con = PQconnectdb(handle->dsn);
+ if (PQstatus(handle->con) != CONNECTION_OK) {
+ char *err_str;
+
+ if ((err_str = pgsql_handle_get_error(handle))) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%s\n", err_str);
+ switch_safe_free(err_str);
+ } else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to connect to the database [%s]\n", handle->dsn);
+ pgsql_handle_disconnect(handle);
+ }
+
+ return SWITCH_STATUS_FALSE;
+ }
+
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "Connected to [%s]\n", handle->dsn);
+ handle->state = SWITCH_PGSQL_STATE_CONNECTED;
+ handle->sock = PQsocket(handle->con);
+
+ return SWITCH_STATUS_SUCCESS;
+}
+
+switch_status_t pgsql_handle_destroy(switch_database_interface_handle_t **dih)
+{
+ switch_pgsql_handle_t *handle = NULL;
+
+ if (!dih) {
+ return SWITCH_STATUS_FALSE;
+ }
+
+ handle = (*dih)->handle;
+
+ if (handle) {
+ pgsql_handle_disconnect(handle);
+
+ switch_safe_free(handle->dsn);
+ free(handle);
+ }
+
+ switch_safe_free(*dih);
+
+ return SWITCH_STATUS_SUCCESS;
+}
+
+switch_status_t pgsql_flush(switch_pgsql_handle_t *handle)
+{
+ PGresult *tmp = NULL;
+ int x = 0;
+
+ if (!handle) {
+ return SWITCH_STATUS_FALSE;
+ }
+
+ /* Make sure the query is fully cleared */
+ while ((tmp = PQgetResult(handle->con)) != NULL) {
+ PQclear(tmp);
+ x++;
+ }
+
+ if (x) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG10, "Flushing %d results\n", x);
+ }
+
+ return SWITCH_STATUS_SUCCESS;
+}
+
+switch_status_t database_flush(switch_database_interface_handle_t *dih)
+{
+ switch_pgsql_handle_t *handle;
+
+ if (!dih) {
+ return SWITCH_STATUS_FALSE;
+ }
+
+ handle = dih->handle;
+
+ return pgsql_flush(handle);
}
-SWITCH_DECLARE(switch_pgsql_status_t) switch_pgsql_send_query(switch_pgsql_handle_t *handle, const char* sql)
+switch_status_t pgsql_send_query(switch_pgsql_handle_t *handle, const char* sql)
{
-#ifdef SWITCH_HAVE_PGSQL
char *err_str;
switch_safe_free(handle->sql);
handle->sql = strdup(sql);
if (!PQsendQuery(handle->con, sql)) {
- err_str = switch_pgsql_handle_get_error(handle);
+ err_str = pgsql_handle_get_error(handle);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Failed to send query (%s) to database: %s\n", sql, err_str);
switch_safe_free(err_str);
- switch_pgsql_finish_results(handle);
+ pgsql_finish_results(handle);
goto error;
}
- return SWITCH_PGSQL_SUCCESS;
- error:
-#endif
- return SWITCH_PGSQL_FAIL;
+ return SWITCH_STATUS_SUCCESS;
+error:
+ return SWITCH_STATUS_FALSE;
}
-SWITCH_DECLARE(switch_pgsql_status_t) switch_pgsql_cancel_real(const char *file, const char *func, int line, switch_pgsql_handle_t *handle)
+switch_status_t pgsql_handle_exec_base_detailed(const char *file, const char *func, int line,
+ switch_pgsql_handle_t *handle, const char *sql, char **err)
{
- switch_pgsql_status_t ret = SWITCH_PGSQL_SUCCESS;
-#ifdef SWITCH_HAVE_PGSQL
- char err_buf[256];
- PGcancel *cancel = NULL;
+ char *err_str = NULL;
+ char *er = NULL;
- memset(err_buf, 0, 256);
- cancel = PQgetCancel(handle->con);
- if(!PQcancel(cancel, err_buf, 256)) {
- switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_CRIT, "Failed to cancel long-running query (%s): %s\n", handle->sql, err_buf);
- ret = SWITCH_PGSQL_FAIL;
- }
- PQfreeCancel(cancel);
- switch_pgsql_flush(handle);
+ pgsql_flush(handle);
+ handle->affected_rows = 0;
-#endif
- return ret;
-}
+ if (!db_is_up(handle)) {
+ er = strdup("Database is not up!");
+ goto error;
+ }
+ if (handle->auto_commit == SWITCH_FALSE && handle->in_txn == SWITCH_FALSE) {
+ if (pgsql_send_query(handle, "BEGIN") != SWITCH_STATUS_SUCCESS) {
+ er = strdup("Error sending BEGIN!");
+ if (pgsql_finish_results(handle) != SWITCH_STATUS_SUCCESS) {
+ db_is_up(handle); /* If finish_results failed, maybe the db went dead */
+ }
+ goto error;
+ }
-SWITCH_DECLARE(switch_pgsql_status_t) switch_pgsql_next_result_timed(switch_pgsql_handle_t *handle, switch_pgsql_result_t **result_out, int msec)
-{
-#ifdef SWITCH_HAVE_PGSQL
- switch_pgsql_result_t *res;
- switch_time_t start;
- switch_time_t ctime;
- unsigned int usec = msec * 1000;
- char *err_str;
-#ifndef _WIN32
- struct pollfd fds[2] = { { 0 } };
-#else
- fd_set rs, es;
-#endif
- int poll_res = 0;
+ if (pgsql_finish_results(handle) != SWITCH_STATUS_SUCCESS) {
+ db_is_up(handle);
+ er = strdup("Error sending BEGIN!");
+ goto error;
+ }
+ handle->in_txn = SWITCH_TRUE;
+ }
- if(!handle) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "**BUG** Null handle passed to switch_pgsql_next_result.\n");
- return SWITCH_PGSQL_FAIL;
+ if (pgsql_send_query(handle, sql) != SWITCH_STATUS_SUCCESS) {
+ er = strdup("Error sending query!");
+ if (pgsql_finish_results(handle) != SWITCH_STATUS_SUCCESS) {
+ db_is_up(handle);
+ }
+ goto error;
}
- /* Try to consume input that might be waiting right away */
- if (PQconsumeInput(handle->con)) {
- /* And check to see if we have a full result ready for reading */
- if (PQisBusy(handle->con)) {
+ return SWITCH_STATUS_SUCCESS;
- /* Wait for a result to become available, up to msec milliseconds */
- start = switch_micro_time_now();
- while((ctime = switch_micro_time_now()) - start <= usec) {
- int wait_time = (usec - (ctime - start)) / 1000;
- /* Wait for the PostgreSQL socket to be ready for data reads. */
-#ifndef _WIN32
- fds[0].fd = handle->sock;
- fds[0].events |= POLLIN;
- fds[0].events |= POLLERR;
- fds[0].events |= POLLNVAL;
- fds[0].events |= POLLHUP;
- fds[0].events |= POLLPRI;
- fds[0].events |= POLLRDNORM;
- fds[0].events |= POLLRDBAND;
+error:
+ err_str = pgsql_handle_get_error(handle);
- poll_res = poll(&fds[0], 1, wait_time);
+ if (zstr(err_str)) {
+ if (zstr(er)) {
+ err_str = strdup((char *)"SQL ERROR!");
+ } else {
+ err_str = er;
+ }
+ } else {
+ if (!zstr(er)) {
+ free(er);
+ }
+ }
+
+ if (err_str) {
+ if (!switch_stristr("already exists", err_str) && !switch_stristr("duplicate key name", err_str)) {
+ switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_ERROR, "ERR: [%s]\n[%s]\n", sql, switch_str_nil(err_str));
+ }
+
+ if (err) {
+ *err = err_str;
+ } else {
+ free(err_str);
+ }
+ }
+
+ return SWITCH_STATUS_FALSE;
+}
+
+
+switch_status_t pgsql_handle_exec_detailed(const char *file, const char *func, int line,
+ switch_pgsql_handle_t *handle, const char *sql, char **err)
+{
+ if (pgsql_handle_exec_base_detailed(file, func, line, handle, sql, err) == SWITCH_STATUS_FALSE) {
+ goto error;
+ }
+
+ return pgsql_finish_results(handle);
+error:
+ return SWITCH_STATUS_FALSE;
+}
+
+switch_status_t database_handle_exec_detailed(const char *file, const char *func, int line,
+ switch_database_interface_handle_t *dih, const char *sql, char **err)
+{
+ switch_pgsql_handle_t *handle;
+
+ if (!dih) {
+ return SWITCH_STATUS_FALSE;
+ }
+
+ handle = dih->handle;
+
+ return pgsql_handle_exec_detailed(file, func, line, handle, sql, err);
+}
+
+switch_status_t database_handle_exec_string(switch_database_interface_handle_t *dih, const char *sql, char *resbuf, size_t len, char **err)
+{
+ switch_pgsql_handle_t *handle;
+ switch_status_t sstatus = SWITCH_STATUS_SUCCESS;
+ char *val = NULL;
+ switch_pgsql_result_t *result = NULL;
+
+ if (!dih) {
+ return SWITCH_STATUS_FALSE;
+ }
+
+ handle = dih->handle;
+
+ if (!handle)
+ return SWITCH_STATUS_FALSE;
+
+ handle->affected_rows = 0;
+
+ if (pgsql_handle_exec_base(handle, sql, err) == SWITCH_STATUS_FALSE) {
+ goto error;
+ }
+
+ if (pgsql_next_result(handle, &result) == SWITCH_STATUS_FALSE) {
+ goto error;
+ }
+
+ if (result) {
+ switch (result->status) {
+#if POSTGRESQL_MAJOR_VERSION >= 9 && POSTGRESQL_MINOR_VERSION >= 2
+ case PGRES_SINGLE_TUPLE:
+ /* Added in PostgreSQL 9.2 */
+#endif
+ case PGRES_COMMAND_OK:
+ case PGRES_TUPLES_OK:
+ break;
+ default:
+ sstatus = SWITCH_STATUS_FALSE;
+ goto done;
+ }
+ }
+
+ if (handle->affected_rows <= 0) {
+ goto done;
+ }
+
+ val = PQgetvalue(result->result, 0, 0);
+ strncpy(resbuf, val, len);
+
+done:
+
+ pgsql_free_result(&result);
+ if (pgsql_finish_results(handle) != SWITCH_STATUS_SUCCESS) {
+ sstatus = SWITCH_STATUS_FALSE;
+ }
+
+ return sstatus;
+
+error:
+
+ return SWITCH_STATUS_FALSE;
+}
+
+switch_status_t pgsql_next_result_timed(switch_pgsql_handle_t *handle, switch_pgsql_result_t **result_out, int msec)
+{
+ switch_pgsql_result_t *res;
+ switch_time_t start;
+ switch_time_t ctime;
+ unsigned int usec = msec * 1000;
+ char *err_str;
+#ifndef _WIN32
+ struct pollfd fds[2] = { { 0 } };
+#else
+ fd_set rs, es;
+#endif
+ int poll_res = 0;
+
+ if (!handle) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "**BUG** Null handle passed to pgsql_next_result.\n");
+ return SWITCH_STATUS_FALSE;
+ }
+
+ /* Try to consume input that might be waiting right away */
+ if (PQconsumeInput(handle->con)) {
+ /* And check to see if we have a full result ready for reading */
+ if (PQisBusy(handle->con)) {
+
+ /* Wait for a result to become available, up to msec milliseconds */
+ start = switch_micro_time_now();
+ while ((ctime = switch_micro_time_now()) - start <= usec) {
+ switch_time_t wait_time = (usec - (ctime - start)) / 1000;
+ /* Wait for the PostgreSQL socket to be ready for data reads. */
+#ifndef _WIN32
+ fds[0].fd = handle->sock;
+ fds[0].events |= POLLIN;
+ fds[0].events |= POLLERR;
+ fds[0].events |= POLLNVAL;
+ fds[0].events |= POLLHUP;
+ fds[0].events |= POLLPRI;
+ fds[0].events |= POLLRDNORM;
+ fds[0].events |= POLLRDBAND;
+
+ poll_res = poll(&fds[0], 1, wait_time);
#else
- struct timeval wait = { wait_time * 1000, 0};
+ struct timeval wait = { (long)wait_time * 1000, 0 };
FD_ZERO(&rs);
FD_SET(handle->sock, &rs);
FD_ZERO(&es);
FD_SET(handle->sock, &es);
poll_res = select(0, &rs, 0, &es, &wait);
#endif
- if (poll_res > 0 ) {
+ if (poll_res > 0) {
#ifndef _WIN32
if (fds[0].revents & POLLHUP || fds[0].revents & POLLNVAL) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "PGSQL socket closed or invalid while waiting for result for query (%s)\n", handle->sql);
}
} else {
/* If we had an error trying to consume input, report it and cancel the query. */
- err_str = switch_pgsql_handle_get_error(handle);
+ err_str = pgsql_handle_get_error(handle);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "An error occurred trying to consume input for query (%s): %s\n", handle->sql, err_str);
switch_safe_free(err_str);
- switch_pgsql_cancel(handle);
+ pgsql_cancel(handle);
goto error;
}
}
/* If we broke the loop above because of a timeout, report that and cancel the query. */
if (ctime - start > usec) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Query (%s) took too long to complete or database not responding.\n", handle->sql);
- switch_pgsql_cancel(handle);
+ pgsql_cancel(handle);
goto error;
}
-
}
} else {
/* If we had an error trying to consume input, report it and cancel the query. */
- err_str = switch_pgsql_handle_get_error(handle);
+ err_str = pgsql_handle_get_error(handle);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "An error occurred trying to consume input for query (%s): %s\n", handle->sql, err_str);
switch_safe_free(err_str);
- /* switch_pgsql_cancel(handle); */
+ /* pgsql_cancel(handle); */
goto error;
}
-
/* At this point, we know we can read a full result without blocking. */
- if(!(res = malloc(sizeof(switch_pgsql_result_t)))) {
+ if (!(res = malloc(sizeof(switch_pgsql_result_t)))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Malloc failed!\n");
goto error;
}
- memset(res, 0, sizeof(switch_pgsql_result_t));
+ memset(res, 0, sizeof(switch_pgsql_result_t));
res->result = PQgetResult(handle->con);
if (res->result) {
*result_out = res;
res->status = PQresultStatus(res->result);
- switch(res->status) {
-#if (POSTGRESQL_MAJOR_VERSION == 9 && POSTGRESQL_MINOR_VERSION >= 2) || POSTGRESQL_MAJOR_VERSION > 9
+ switch (res->status) {
+//#if (POSTGRESQL_MAJOR_VERSION == 9 && POSTGRESQL_MINOR_VERSION >= 2) || POSTGRESQL_MAJOR_VERSION > 9
case PGRES_SINGLE_TUPLE:
/* Added in PostgreSQL 9.2 */
-#endif
+//#endif
case PGRES_TUPLES_OK:
- {
- res->rows = PQntuples(res->result);
- handle->affected_rows = res->rows;
- res->cols = PQnfields(res->result);
- }
- break;
-#if (POSTGRESQL_MAJOR_VERSION == 9 && POSTGRESQL_MINOR_VERSION >= 1) || POSTGRESQL_MAJOR_VERSION > 9
+ {
+ res->rows = PQntuples(res->result);
+ handle->affected_rows = res->rows;
+ res->cols = PQnfields(res->result);
+ }
+ break;
+//#if (POSTGRESQL_MAJOR_VERSION == 9 && POSTGRESQL_MINOR_VERSION >= 1) || POSTGRESQL_MAJOR_VERSION > 9
case PGRES_COPY_BOTH:
/* Added in PostgreSQL 9.1 */
-#endif
+//#endif
case PGRES_COPY_OUT:
case PGRES_COPY_IN:
case PGRES_COMMAND_OK:
*result_out = NULL;
}
- return SWITCH_PGSQL_SUCCESS;
- error:
+ return SWITCH_STATUS_SUCCESS;
+error:
/* Make sure the failed connection does not have any transactions marked as in progress */
- switch_pgsql_flush(handle);
+ pgsql_flush(handle);
/* Try to reconnect to the DB if we were dropped */
db_is_up(handle);
-#endif
- return SWITCH_PGSQL_FAIL;
+ return SWITCH_STATUS_FALSE;
}
-SWITCH_DECLARE(void) switch_pgsql_free_result(switch_pgsql_result_t **result)
+switch_status_t pgsql_cancel_real(const char *file, const char *func, int line, switch_pgsql_handle_t *handle)
{
-#ifdef SWITCH_HAVE_PGSQL
+ switch_status_t ret = SWITCH_STATUS_SUCCESS;
+ char err_buf[256];
+ PGcancel *cancel = NULL;
- if (!*result) {
- return;
- }
+ memset(err_buf, 0, 256);
+ cancel = PQgetCancel(handle->con);
- if ((*result)->result) {
- PQclear((*result)->result);
+ if (!PQcancel(cancel, err_buf, 256)) {
+ switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_CRIT, "Failed to cancel long-running query (%s): %s\n", handle->sql, err_buf);
+ ret = SWITCH_STATUS_FALSE;
}
- free(*result);
- *result = NULL;
-#else
- return;
-#endif
-}
-
-SWITCH_DECLARE(switch_pgsql_status_t) switch_pgsql_finish_results_real(const char* file, const char* func, int line, switch_pgsql_handle_t *handle)
-{
-#ifdef SWITCH_HAVE_PGSQL
- switch_pgsql_result_t *res = NULL;
- switch_pgsql_status_t final_status = SWITCH_PGSQL_SUCCESS;
- int done = 0;
- do {
- switch_pgsql_next_result(handle, &res);
- if (res && res->err && !switch_stristr("already exists", res->err) && !switch_stristr("duplicate key name", res->err)) {
- switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_ERROR, "Error executing query:\n%s\n", res->err);
- final_status = SWITCH_PGSQL_FAIL;
- }
-
- if (!res) {
- done = 1;
- } else if (res->result) {
- char *affected_rows = PQcmdTuples(res->result);
- if (!zstr(affected_rows)) {
- handle->affected_rows = atoi(affected_rows);
- }
- }
+ PQfreeCancel(cancel);
+ pgsql_flush(handle);
- switch_pgsql_free_result(&res);
- } while (!done);
- return final_status;
-#else
- return SWITCH_PGSQL_FAIL;
-#endif
+ return ret;
}
-
-SWITCH_DECLARE(switch_pgsql_status_t) switch_pgsql_handle_connect(switch_pgsql_handle_t *handle)
+switch_status_t pgsql_SQLSetAutoCommitAttr(switch_database_interface_handle_t *dih, switch_bool_t on)
{
-#ifdef SWITCH_HAVE_PGSQL
- if (handle->state == SWITCH_PGSQL_STATE_CONNECTED) {
- switch_pgsql_handle_disconnect(handle);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "Re-connecting %s\n", handle->dsn);
- }
+ switch_pgsql_handle_t *handle;
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "Connecting %s\n", handle->dsn);
- PQinitSSL(0);
- handle->con = PQconnectdb(handle->dsn);
- if (PQstatus(handle->con) != CONNECTION_OK) {
- char *err_str;
- if ((err_str = switch_pgsql_handle_get_error(handle))) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%s\n", err_str);
- switch_safe_free(err_str);
- } else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to connect to the database [%s]\n", handle->dsn);
- switch_pgsql_handle_disconnect(handle);
- }
- return SWITCH_PGSQL_FAIL;
+ if (!dih) {
+ return SWITCH_STATUS_FALSE;
}
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "Connected to [%s]\n", handle->dsn);
- handle->state = SWITCH_PGSQL_STATE_CONNECTED;
- handle->sock = PQsocket(handle->con);
- return SWITCH_PGSQL_SUCCESS;
-#else
- return SWITCH_PGSQL_FAIL;
-#endif
-}
-
-SWITCH_DECLARE(switch_pgsql_status_t) switch_pgsql_handle_exec_string_detailed(const char *file, const char *func, int line,
- switch_pgsql_handle_t *handle, const char *sql, char *resbuf, size_t len, char **err)
-{
-#ifdef SWITCH_HAVE_PGSQL
- switch_pgsql_status_t sstatus = SWITCH_PGSQL_SUCCESS;
- char *val = NULL;
- switch_pgsql_result_t *result = NULL;
+ handle = dih->handle;
- handle->affected_rows = 0;
+ if (!handle)
+ return SWITCH_STATUS_FALSE;
- if (switch_pgsql_handle_exec_base_detailed(file, func, line, handle, sql, err) == SWITCH_PGSQL_FAIL) {
- goto error;
+ if (on) {
+ handle->auto_commit = SWITCH_TRUE;
+ } else {
+ handle->auto_commit = SWITCH_FALSE;
}
- if(switch_pgsql_next_result(handle, &result) == SWITCH_PGSQL_FAIL) {
- goto error;
- }
+ return SWITCH_STATUS_SUCCESS;
+}
- if (result) {
- switch (result->status) {
-#if POSTGRESQL_MAJOR_VERSION >= 9 && POSTGRESQL_MINOR_VERSION >= 2
- case PGRES_SINGLE_TUPLE:
- /* Added in PostgreSQL 9.2 */
-#endif
- case PGRES_COMMAND_OK:
- case PGRES_TUPLES_OK:
- break;
- default:
- sstatus = SWITCH_PGSQL_FAIL;
- goto done;
- }
- }
+switch_status_t pgsql_SQLEndTran(switch_pgsql_handle_t *handle, switch_bool_t commit)
+{
+ char * err_str = NULL;
- if (handle->affected_rows <= 0) {
- goto done;
+ if (!handle) {
+ return SWITCH_STATUS_FALSE;
}
- val = PQgetvalue(result->result, 0, 0);
- strncpy(resbuf, val, len);
-
- done:
-
- switch_pgsql_free_result(&result);
- if (switch_pgsql_finish_results(handle) != SWITCH_PGSQL_SUCCESS) {
- sstatus = SWITCH_PGSQL_FAIL;
+ if (commit) {
+ if (!PQsendQuery(handle->con, "COMMIT")) {
+ err_str = pgsql_handle_get_error(handle);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Could not commit transaction: %s\n", err_str);
+ switch_safe_free(err_str);
+ return SWITCH_STATUS_FALSE;
+ }
+ } else {
+ if (!PQsendQuery(handle->con, "ROLLBACK")) {
+ err_str = pgsql_handle_get_error(handle);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Could not rollback transaction: %s\n", err_str);
+ switch_safe_free(err_str);
+ return SWITCH_STATUS_FALSE;
+ }
}
+ handle->in_txn = SWITCH_FALSE;
- return sstatus;
- error:
- return SWITCH_PGSQL_FAIL;
-#else
- return SWITCH_PGSQL_FAIL;
-#endif
+ return SWITCH_STATUS_SUCCESS;
}
-SWITCH_DECLARE(switch_pgsql_status_t) switch_pgsql_handle_exec_base_detailed(const char *file, const char *func, int line,
- switch_pgsql_handle_t *handle, const char *sql, char **err)
+switch_status_t database_commit(switch_database_interface_handle_t *dih)
{
-#ifdef SWITCH_HAVE_PGSQL
- char *err_str = NULL, *er = NULL;
-
-
+ switch_status_t result;
- switch_pgsql_flush(handle);
- handle->affected_rows = 0;
+ switch_pgsql_handle_t *handle;
- if (!db_is_up(handle)) {
- er = strdup("Database is not up!");
- goto error;
+ if (!dih) {
+ return SWITCH_STATUS_FALSE;
}
- if (handle->auto_commit == SWITCH_FALSE && handle->in_txn == SWITCH_FALSE) {
- if (switch_pgsql_send_query(handle, "BEGIN") != SWITCH_PGSQL_SUCCESS) {
- er = strdup("Error sending BEGIN!");
- if (switch_pgsql_finish_results(handle) != SWITCH_PGSQL_SUCCESS) {
- db_is_up(handle); /* If finish_results failed, maybe the db went dead */
- }
- goto error;
- }
+ handle = dih->handle;
- if (switch_pgsql_finish_results(handle) != SWITCH_PGSQL_SUCCESS) {
- db_is_up(handle);
- er = strdup("Error sending BEGIN!");
- goto error;
- }
- handle->in_txn = SWITCH_TRUE;
- }
+ if (!handle)
+ return SWITCH_STATUS_FALSE;
- if (switch_pgsql_send_query(handle, sql) != SWITCH_PGSQL_SUCCESS) {
- er = strdup("Error sending query!");
- if (switch_pgsql_finish_results(handle) != SWITCH_PGSQL_SUCCESS) {
- db_is_up(handle);
- }
- goto error;
- }
+ result = pgsql_SQLEndTran(handle, SWITCH_TRUE);
+ result = result && pgsql_SQLSetAutoCommitAttr(dih, SWITCH_TRUE);
+ result = result && pgsql_finish_results(handle);
- return SWITCH_PGSQL_SUCCESS;
+ return result;
+}
- error:
- err_str = switch_pgsql_handle_get_error(handle);
+switch_status_t database_rollback(switch_database_interface_handle_t *dih)
+{
+ switch_pgsql_handle_t *handle;
- if (zstr(err_str)) {
- if (zstr(er)) {
- err_str = strdup((char *)"SQL ERROR!");
- } else {
- err_str = er;
- }
- } else {
- if (!zstr(er)) {
- free(er);
- }
+ if (!dih) {
+ return SWITCH_STATUS_FALSE;
}
- if (err_str) {
- if (!switch_stristr("already exists", err_str) && !switch_stristr("duplicate key name", err_str)) {
- switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_ERROR, "ERR: [%s]\n[%s]\n", sql, switch_str_nil(err_str));
- }
- if (err) {
- *err = err_str;
- } else {
- free(err_str);
- }
- }
-#endif
- return SWITCH_PGSQL_FAIL;
-}
+ handle = dih->handle;
-SWITCH_DECLARE(switch_pgsql_status_t) switch_pgsql_handle_exec_detailed(const char *file, const char *func, int line,
- switch_pgsql_handle_t *handle, const char *sql, char **err)
-{
-#ifdef SWITCH_HAVE_PGSQL
- if (switch_pgsql_handle_exec_base_detailed(file, func, line, handle, sql, err) == SWITCH_PGSQL_FAIL) {
- goto error;
- }
+ if (!handle)
+ return SWITCH_STATUS_FALSE;
- return switch_pgsql_finish_results(handle);
- error:
-#endif
- return SWITCH_PGSQL_FAIL;
+ pgsql_SQLEndTran(handle, SWITCH_FALSE);
+ // Is that enought?
+
+ return SWITCH_STATUS_SUCCESS;
}
-SWITCH_DECLARE(switch_pgsql_status_t) switch_pgsql_handle_callback_exec_detailed(const char *file, const char *func, int line,
- switch_pgsql_handle_t *handle,
- const char *sql, switch_core_db_callback_func_t callback, void *pdata,
- char **err)
+switch_status_t pgsql_handle_callback_exec_detailed(const char *file, const char *func, int line,
+ switch_database_interface_handle_t *dih, const char *sql, switch_core_db_callback_func_t callback, void *pdata, char **err)
{
-#ifdef SWITCH_HAVE_PGSQL
char *err_str = NULL;
int row = 0, col = 0, err_cnt = 0;
switch_pgsql_result_t *result = NULL;
+ switch_pgsql_handle_t *handle;
+
+ if (!dih) {
+ return SWITCH_STATUS_FALSE;
+ }
+
+ handle = dih->handle;
+
+ if (!handle) {
+ return SWITCH_STATUS_FALSE;
+ }
+
handle->affected_rows = 0;
switch_assert(callback != NULL);
- if (switch_pgsql_handle_exec_base(handle, sql, err) == SWITCH_PGSQL_FAIL) {
+ if (pgsql_handle_exec_base(handle, sql, err) == SWITCH_STATUS_FALSE) {
goto error;
}
- if (switch_pgsql_next_result(handle, &result) == SWITCH_PGSQL_FAIL) {
+ if (pgsql_next_result(handle, &result) == SWITCH_STATUS_FALSE) {
err_cnt++;
- err_str = switch_pgsql_handle_get_error(handle);
+ err_str = pgsql_handle_get_error(handle);
+
if (result && !zstr(result->err)) {
switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_ERROR, "ERR: [%s]\n[%s]\n", sql, switch_str_nil(result->err));
}
+
if (!zstr(err_str)) {
switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_ERROR, "ERR: [%s]\n[%s]\n", sql, switch_str_nil(err_str));
}
+
switch_safe_free(err_str);
- err_str = NULL;
}
while (result != NULL) {
for (col = 0; col < result->cols; ++col) {
char * tmp;
- int len;
+ size_t len;
tmp = PQfname(result->result, col);
if (tmp) {
len = strlen(tmp);
- names[col] = malloc(len+1);
+ names[col] = malloc(len + 1);
names[col][len] = '\0';
strncpy(names[col], tmp, len);
len = PQgetlength(result->result, row, col);
- vals[col] = malloc(len+1);
+ vals[col] = malloc(len + 1);
vals[col][len] = '\0';
tmp = PQgetvalue(result->result, row, col);
strncpy(vals[col], tmp, len);
/*switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Executing callback for row %d...\n", row);*/
if (callback(pdata, result->cols, vals, names)) {
- switch_pgsql_finish_results(handle); /* Makes sure next call to switch_pgsql_next_result will return NULL */
+ pgsql_finish_results(handle); /* Makes sure next call to switch_pgsql_next_result will return NULL */
row = result->rows; /* Makes us exit the for loop */
}
free(names[col]);
free(vals[col]);
}
+
free(names);
free(vals);
}
- switch_pgsql_free_result(&result);
- if (switch_pgsql_next_result(handle, &result) == SWITCH_PGSQL_FAIL) {
+
+ pgsql_free_result(&result);
+
+ if (pgsql_next_result(handle, &result) == SWITCH_STATUS_FALSE) {
err_cnt++;
- err_str = switch_pgsql_handle_get_error(handle);
+ err_str = pgsql_handle_get_error(handle);
+
if (result && !zstr(result->err)) {
switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_ERROR, "ERR: [%s]\n[%s]\n", sql, switch_str_nil(result->err));
}
+
if (!zstr(err_str)) {
switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_ERROR, "ERR: [%s]\n[%s]\n", sql, switch_str_nil(err_str));
}
switch_safe_free(err_str);
- err_str = NULL;
}
}
+
if (err_cnt) {
goto error;
}
- return SWITCH_PGSQL_SUCCESS;
- error:
-#endif
- return SWITCH_PGSQL_FAIL;
-}
-
-SWITCH_DECLARE(void) switch_pgsql_handle_destroy(switch_pgsql_handle_t **handlep)
-{
-#ifdef SWITCH_HAVE_PGSQL
-
- switch_pgsql_handle_t *handle = NULL;
-
- if (!handlep) {
- return;
- }
- handle = *handlep;
-
- if (handle) {
- switch_pgsql_handle_disconnect(handle);
-
- switch_safe_free(handle->dsn);
- free(handle);
- }
- *handlep = NULL;
-#else
- return;
-#endif
-}
-
-SWITCH_DECLARE(switch_pgsql_state_t) switch_pgsql_handle_get_state(switch_pgsql_handle_t *handle)
-{
-#ifdef SWITCH_HAVE_PGSQL
- return handle ? handle->state : SWITCH_PGSQL_STATE_INIT;
-#else
- return SWITCH_PGSQL_STATE_ERROR;
-#endif
-}
-
-SWITCH_DECLARE(char *) switch_pgsql_handle_get_error(switch_pgsql_handle_t *handle)
-{
-#ifdef SWITCH_HAVE_PGSQL
- char * err_str;
- if (!handle) {
- return NULL;
- };
- switch_strdup(err_str, PQerrorMessage(handle->con));
- return err_str;
-#else
- return NULL;
-#endif
-}
-
-SWITCH_DECLARE(int) switch_pgsql_handle_affected_rows(switch_pgsql_handle_t *handle)
-{
-#ifdef SWITCH_HAVE_PGSQL
- return handle->affected_rows;
-#else
- return 0;
-#endif
-}
-
-SWITCH_DECLARE(switch_bool_t) switch_pgsql_available(void)
-{
-#ifdef SWITCH_HAVE_PGSQL
- return SWITCH_TRUE;
-#else
- return SWITCH_FALSE;
-#endif
-}
+ return SWITCH_STATUS_SUCCESS;
+error:
-SWITCH_DECLARE(switch_pgsql_status_t) switch_pgsql_SQLSetAutoCommitAttr(switch_pgsql_handle_t *handle, switch_bool_t on)
-{
-#ifdef SWITCH_HAVE_PGSQL
- if (on) {
- handle->auto_commit = SWITCH_TRUE;
- } else {
- handle->auto_commit = SWITCH_FALSE;
- }
- return SWITCH_PGSQL_SUCCESS;
-#else
- return (switch_pgsql_status_t) SWITCH_FALSE;
-#endif
+ return SWITCH_STATUS_FALSE;
}
-SWITCH_DECLARE(switch_pgsql_status_t) switch_pgsql_flush(switch_pgsql_handle_t *handle)
+SWITCH_MODULE_LOAD_FUNCTION(mod_pgsql_load)
{
-#ifdef SWITCH_HAVE_PGSQL
-
- PGresult *tmp = NULL;
- int x = 0;
-
- /* Make sure the query is fully cleared */
- while ((tmp = PQgetResult(handle->con)) != NULL) {
- PQclear(tmp);
- x++;
- }
-
- if (x) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG10, "Flushing %d results\n", x);
- }
-
- return SWITCH_PGSQL_SUCCESS;
-#else
- return (switch_pgsql_status_t) SWITCH_FALSE;
-#endif
+ switch_database_interface_t *database_interface;
+
+ supported_prefixes[0] = (char *)"pgsql";
+ supported_prefixes[1] = (char *)"postgres";
+ supported_prefixes[2] = (char *)"postgresql";
+
+ /* connect my internal structure to the blank pointer passed to me */
+ *module_interface = switch_loadable_module_create_module_interface(pool, modname);
+ MODULE_INTERFACE = *module_interface;
+
+ database_interface = (switch_database_interface_t *)switch_loadable_module_create_interface(*module_interface, SWITCH_DATABASE_INTERFACE);
+ database_interface->flags = 0;
+ database_interface->interface_name = modname;
+ database_interface->prefixes = supported_prefixes;
+ database_interface->handle_new = pgsql_handle_new;
+ database_interface->handle_destroy = pgsql_handle_destroy;
+ database_interface->flush = database_flush;
+ database_interface->exec_detailed = database_handle_exec_detailed;
+ database_interface->exec_string = database_handle_exec_string;
+ database_interface->affected_rows = pgsql_handle_affected_rows;
+ database_interface->sql_set_auto_commit_attr = pgsql_SQLSetAutoCommitAttr;
+ database_interface->commit = database_commit;
+ database_interface->rollback = database_rollback;
+ database_interface->callback_exec_detailed = pgsql_handle_callback_exec_detailed;
+
+ /* indicate that the module should continue to be loaded */
+ return SWITCH_STATUS_SUCCESS;
}
-SWITCH_DECLARE(switch_pgsql_status_t) switch_pgsql_SQLEndTran(switch_pgsql_handle_t *handle, switch_bool_t commit)
+SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_pgsql_shutdown)
{
-#ifdef SWITCH_HAVE_PGSQL
- char * err_str = NULL;
- if (commit) {
- if(!PQsendQuery(handle->con, "COMMIT")) {
- err_str = switch_pgsql_handle_get_error(handle);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Could not commit transaction: %s\n", err_str);
- switch_safe_free(err_str);
- return SWITCH_PGSQL_FAIL;
- }
- } else {
- if(!PQsendQuery(handle->con, "ROLLBACK")) {
- err_str = switch_pgsql_handle_get_error(handle);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Could not rollback transaction: %s\n", err_str);
- switch_safe_free(err_str);
- return SWITCH_PGSQL_FAIL;
- }
- }
- handle->in_txn = SWITCH_FALSE;
- return SWITCH_PGSQL_SUCCESS;
-#else
- return (switch_pgsql_status_t) SWITCH_FALSE;
-#endif
+ return SWITCH_STATUS_UNLOAD;
}
-
/* For Emacs:
* Local Variables:
* mode:c
mod_LTLIBRARIES = mod_cdr_pg_csv.la
mod_cdr_pg_csv_la_SOURCES = mod_cdr_pg_csv.c
-mod_cdr_pg_csv_la_CFLAGS = $(AM_CFLAGS) $(SWITCH_AM_CXXFLAGS)
+mod_cdr_pg_csv_la_CFLAGS = $(AM_CFLAGS) $(SWITCH_AM_CXXFLAGS) $(POSTGRESQL_CFLAGS)
mod_cdr_pg_csv_la_LIBADD = $(switch_builddir)/libfreeswitch.la
-mod_cdr_pg_csv_la_LDFLAGS = -avoid-version -module -no-undefined -shared -lpq $(SWITCH_AM_LDFLAGS)
+mod_cdr_pg_csv_la_LDFLAGS = -avoid-version -module -no-undefined -shared -lpq $(SWITCH_AM_LDFLAGS) $(POSTGRESQL_LDFLAGS)
else
install: error
}
-SWIGEXPORT void SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_cache_db_native_handle_t_pgsql_dbh_set___(void * jarg1, void * jarg2) {
- switch_cache_db_native_handle_t *arg1 = (switch_cache_db_native_handle_t *) 0 ;
- switch_pgsql_handle_t *arg2 = (switch_pgsql_handle_t *) 0 ;
-
- arg1 = (switch_cache_db_native_handle_t *)jarg1;
- arg2 = (switch_pgsql_handle_t *)jarg2;
- if (arg1) (arg1)->pgsql_dbh = arg2;
-}
-
-
-SWIGEXPORT void * SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_cache_db_native_handle_t_pgsql_dbh_get___(void * jarg1) {
- void * jresult ;
- switch_cache_db_native_handle_t *arg1 = (switch_cache_db_native_handle_t *) 0 ;
- switch_pgsql_handle_t *result = 0 ;
-
- arg1 = (switch_cache_db_native_handle_t *)jarg1;
- result = (switch_pgsql_handle_t *) ((arg1)->pgsql_dbh);
- jresult = (void *)result;
- return jresult;
-}
-
-
SWIGEXPORT void SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_cache_db_native_handle_t_database_interface_dbh_set___(void * jarg1, void * jarg2) {
switch_cache_db_native_handle_t *arg1 = (switch_cache_db_native_handle_t *) 0 ;
switch_database_interface_handle_t *arg2 = (switch_database_interface_handle_t *) 0 ;
}
-SWIGEXPORT void SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_cache_db_pgsql_options_t_dsn_set___(void * jarg1, char * jarg2) {
- switch_cache_db_pgsql_options_t *arg1 = (switch_cache_db_pgsql_options_t *) 0 ;
+SWIGEXPORT void SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_cache_db_database_interface_options_t_original_dsn_set___(void * jarg1, char * jarg2) {
+ switch_cache_db_database_interface_options_t *arg1 = (switch_cache_db_database_interface_options_t *) 0 ;
char *arg2 = (char *) 0 ;
- arg1 = (switch_cache_db_pgsql_options_t *)jarg1;
+ arg1 = (switch_cache_db_database_interface_options_t *)jarg1;
arg2 = (char *)jarg2;
{
- delete [] arg1->dsn;
if (arg2) {
- arg1->dsn = (char *) (new char[strlen((const char *)arg2)+1]);
- strcpy((char *)arg1->dsn, (const char *)arg2);
+ arg1->original_dsn = (char const *) (new char[strlen((const char *)arg2)+1]);
+ strcpy((char *)arg1->original_dsn, (const char *)arg2);
} else {
- arg1->dsn = 0;
+ arg1->original_dsn = 0;
}
}
}
-SWIGEXPORT char * SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_cache_db_pgsql_options_t_dsn_get___(void * jarg1) {
+SWIGEXPORT char * SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_cache_db_database_interface_options_t_original_dsn_get___(void * jarg1) {
char * jresult ;
- switch_cache_db_pgsql_options_t *arg1 = (switch_cache_db_pgsql_options_t *) 0 ;
+ switch_cache_db_database_interface_options_t *arg1 = (switch_cache_db_database_interface_options_t *) 0 ;
char *result = 0 ;
- arg1 = (switch_cache_db_pgsql_options_t *)jarg1;
- result = (char *) ((arg1)->dsn);
+ arg1 = (switch_cache_db_database_interface_options_t *)jarg1;
+ result = (char *) ((arg1)->original_dsn);
jresult = SWIG_csharp_string_callback((const char *)result);
return jresult;
}
-SWIGEXPORT void * SWIGSTDCALL CSharp_FreeSWITCHfNative_new_switch_cache_db_pgsql_options_t___() {
- void * jresult ;
- switch_cache_db_pgsql_options_t *result = 0 ;
-
- result = (switch_cache_db_pgsql_options_t *)new switch_cache_db_pgsql_options_t();
- jresult = (void *)result;
- return jresult;
-}
-
-
-SWIGEXPORT void SWIGSTDCALL CSharp_FreeSWITCHfNative_delete_switch_cache_db_pgsql_options_t___(void * jarg1) {
- switch_cache_db_pgsql_options_t *arg1 = (switch_cache_db_pgsql_options_t *) 0 ;
-
- arg1 = (switch_cache_db_pgsql_options_t *)jarg1;
- delete arg1;
-}
-
-
-SWIGEXPORT void SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_cache_db_database_interface_options_t_dsn_set___(void * jarg1, char * jarg2) {
+SWIGEXPORT void SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_cache_db_database_interface_options_t_connection_string_set___(void * jarg1, char * jarg2) {
switch_cache_db_database_interface_options_t *arg1 = (switch_cache_db_database_interface_options_t *) 0 ;
char *arg2 = (char *) 0 ;
arg1 = (switch_cache_db_database_interface_options_t *)jarg1;
arg2 = (char *)jarg2;
{
- delete [] arg1->dsn;
+ delete [] arg1->connection_string;
if (arg2) {
- arg1->dsn = (char *) (new char[strlen((const char *)arg2)+1]);
- strcpy((char *)arg1->dsn, (const char *)arg2);
+ arg1->connection_string = (char *) (new char[strlen((const char *)arg2)+1]);
+ strcpy((char *)arg1->connection_string, (const char *)arg2);
} else {
- arg1->dsn = 0;
+ arg1->connection_string = 0;
}
}
}
-SWIGEXPORT char * SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_cache_db_database_interface_options_t_dsn_get___(void * jarg1) {
+SWIGEXPORT char * SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_cache_db_database_interface_options_t_connection_string_get___(void * jarg1) {
char * jresult ;
switch_cache_db_database_interface_options_t *arg1 = (switch_cache_db_database_interface_options_t *) 0 ;
char *result = 0 ;
arg1 = (switch_cache_db_database_interface_options_t *)jarg1;
- result = (char *) ((arg1)->dsn);
+ result = (char *) ((arg1)->connection_string);
jresult = SWIG_csharp_string_callback((const char *)result);
return jresult;
}
}
-SWIGEXPORT void SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_cache_db_connection_options_t_pgsql_options_set___(void * jarg1, void * jarg2) {
- switch_cache_db_connection_options_t *arg1 = (switch_cache_db_connection_options_t *) 0 ;
- switch_cache_db_pgsql_options_t *arg2 = (switch_cache_db_pgsql_options_t *) 0 ;
-
- arg1 = (switch_cache_db_connection_options_t *)jarg1;
- arg2 = (switch_cache_db_pgsql_options_t *)jarg2;
- if (arg1) (arg1)->pgsql_options = *arg2;
-}
-
-
-SWIGEXPORT void * SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_cache_db_connection_options_t_pgsql_options_get___(void * jarg1) {
- void * jresult ;
- switch_cache_db_connection_options_t *arg1 = (switch_cache_db_connection_options_t *) 0 ;
- switch_cache_db_pgsql_options_t *result = 0 ;
-
- arg1 = (switch_cache_db_connection_options_t *)jarg1;
- result = (switch_cache_db_pgsql_options_t *)& ((arg1)->pgsql_options);
- jresult = (void *)result;
- return jresult;
-}
-
-
SWIGEXPORT void SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_cache_db_connection_options_t_database_interface_options_set___(void * jarg1, void * jarg2) {
switch_cache_db_connection_options_t *arg1 = (switch_cache_db_connection_options_t *) 0 ;
switch_cache_db_database_interface_options_t *arg2 = (switch_cache_db_database_interface_options_t *) 0 ;
}
+SWIGEXPORT int SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_database_available___(char * jarg1) {
+ int jresult ;
+ char *arg1 = (char *) 0 ;
+ switch_status_t result;
+
+ arg1 = (char *)jarg1;
+ result = (switch_status_t)switch_database_available(arg1);
+ jresult = (int)result;
+ return jresult;
+}
+
+
SWIGEXPORT void SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_core_set_signal_handlers___() {
switch_core_set_signal_handlers();
}
SWIGEXPORT void SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_database_interface_handle_new_set___(void * jarg1, void * jarg2) {
switch_database_interface *arg1 = (switch_database_interface *) 0 ;
- switch_status_t (*arg2)(char *,switch_database_interface_handle_t **) = (switch_status_t (*)(char *,switch_database_interface_handle_t **)) 0 ;
+ switch_status_t (*arg2)(switch_cache_db_database_interface_options_t,switch_database_interface_handle_t **) = (switch_status_t (*)(switch_cache_db_database_interface_options_t,switch_database_interface_handle_t **)) 0 ;
arg1 = (switch_database_interface *)jarg1;
- arg2 = (switch_status_t (*)(char *,switch_database_interface_handle_t **))jarg2;
+ arg2 = (switch_status_t (*)(switch_cache_db_database_interface_options_t,switch_database_interface_handle_t **))jarg2;
if (arg1) (arg1)->handle_new = arg2;
}
SWIGEXPORT void * SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_database_interface_handle_new_get___(void * jarg1) {
void * jresult ;
switch_database_interface *arg1 = (switch_database_interface *) 0 ;
- switch_status_t (*result)(char *,switch_database_interface_handle_t **) = 0 ;
+ switch_status_t (*result)(switch_cache_db_database_interface_options_t,switch_database_interface_handle_t **) = 0 ;
arg1 = (switch_database_interface *)jarg1;
- result = (switch_status_t (*)(char *,switch_database_interface_handle_t **)) ((arg1)->handle_new);
+ result = (switch_status_t (*)(switch_cache_db_database_interface_options_t,switch_database_interface_handle_t **)) ((arg1)->handle_new);
jresult = (void *)result;
return jresult;
}
}
-SWIGEXPORT unsigned long SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_event_channel_unbind___(char * jarg1, void * jarg2) {
+SWIGEXPORT int SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_event_channel_deliver___(char * jarg1, void * jarg2, char * jarg3, unsigned long jarg4) {
+ int jresult ;
+ char *arg1 = (char *) 0 ;
+ cJSON **arg2 = (cJSON **) 0 ;
+ char *arg3 = (char *) 0 ;
+ switch_event_channel_id_t arg4 ;
+ switch_status_t result;
+
+ arg1 = (char *)jarg1;
+ arg2 = (cJSON **)jarg2;
+ arg3 = (char *)jarg3;
+ arg4 = (switch_event_channel_id_t)jarg4;
+ result = (switch_status_t)switch_event_channel_deliver((char const *)arg1,arg2,(char const *)arg3,arg4);
+ jresult = (int)result;
+ return jresult;
+}
+
+
+SWIGEXPORT unsigned long SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_event_channel_unbind___(char * jarg1, void * jarg2, void * jarg3) {
unsigned long jresult ;
char *arg1 = (char *) 0 ;
switch_event_channel_func_t arg2 = (switch_event_channel_func_t) 0 ;
+ void *arg3 = (void *) 0 ;
uint32_t result;
arg1 = (char *)jarg1;
arg2 = (switch_event_channel_func_t)jarg2;
- result = (uint32_t)switch_event_channel_unbind((char const *)arg1,arg2);
+ arg3 = (void *)jarg3;
+ result = (uint32_t)switch_event_channel_unbind((char const *)arg1,arg2,arg3);
jresult = (unsigned long)result;
return jresult;
}
-SWIGEXPORT int SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_event_channel_bind___(char * jarg1, void * jarg2, void * jarg3) {
+SWIGEXPORT int SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_event_channel_bind___(char * jarg1, void * jarg2, void * jarg3, void * jarg4) {
int jresult ;
char *arg1 = (char *) 0 ;
switch_event_channel_func_t arg2 = (switch_event_channel_func_t) 0 ;
switch_event_channel_id_t *arg3 = (switch_event_channel_id_t *) 0 ;
+ void *arg4 = (void *) 0 ;
switch_status_t result;
arg1 = (char *)jarg1;
arg2 = (switch_event_channel_func_t)jarg2;
arg3 = (switch_event_channel_id_t *)jarg3;
- result = (switch_status_t)switch_event_channel_bind((char const *)arg1,arg2,arg3);
+ arg4 = (void *)jarg4;
+ result = (switch_status_t)switch_event_channel_bind((char const *)arg1,arg2,arg3,arg4);
jresult = (int)result;
return jresult;
}
}
+SWIGEXPORT int SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_dial_handle_create_json_obj___(void * jarg1, void * jarg2) {
+ int jresult ;
+ switch_dial_handle_t **arg1 = (switch_dial_handle_t **) 0 ;
+ cJSON *arg2 = (cJSON *) 0 ;
+ switch_status_t result;
+
+ arg1 = (switch_dial_handle_t **)jarg1;
+ arg2 = (cJSON *)jarg2;
+ result = (switch_status_t)switch_dial_handle_create_json_obj(arg1,arg2);
+ jresult = (int)result;
+ return jresult;
+}
+
+
+SWIGEXPORT int SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_dial_handle_create_json___(void * jarg1, char * jarg2) {
+ int jresult ;
+ switch_dial_handle_t **arg1 = (switch_dial_handle_t **) 0 ;
+ char *arg2 = (char *) 0 ;
+ switch_status_t result;
+
+ arg1 = (switch_dial_handle_t **)jarg1;
+ arg2 = (char *)jarg2;
+ result = (switch_status_t)switch_dial_handle_create_json(arg1,(char const *)arg2);
+ jresult = (int)result;
+ return jresult;
+}
+
+
SWIGEXPORT void SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_dial_handle_destroy___(void * jarg1) {
switch_dial_handle_t **arg1 = (switch_dial_handle_t **) 0 ;
}
+SWIGEXPORT int SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_dial_handle_serialize_json_obj___(void * jarg1, void * jarg2) {
+ int jresult ;
+ switch_dial_handle_t *arg1 = (switch_dial_handle_t *) 0 ;
+ cJSON **arg2 = (cJSON **) 0 ;
+ switch_status_t result;
+
+ arg1 = (switch_dial_handle_t *)jarg1;
+ arg2 = (cJSON **)jarg2;
+ result = (switch_status_t)switch_dial_handle_serialize_json_obj(arg1,arg2);
+ jresult = (int)result;
+ return jresult;
+}
+
+
+SWIGEXPORT int SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_dial_handle_serialize_json___(void * jarg1, void * jarg2) {
+ int jresult ;
+ switch_dial_handle_t *arg1 = (switch_dial_handle_t *) 0 ;
+ char **arg2 = (char **) 0 ;
+ switch_status_t result;
+
+ arg1 = (switch_dial_handle_t *)jarg1;
+ arg2 = (char **)jarg2;
+ result = (switch_status_t)switch_dial_handle_serialize_json(arg1,arg2);
+ jresult = (int)result;
+ return jresult;
+}
+
+
SWIGEXPORT void SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_dial_handle_add_leg_list___(void * jarg1, void * jarg2) {
switch_dial_handle_t *arg1 = (switch_dial_handle_t *) 0 ;
switch_dial_leg_list_t **arg2 = (switch_dial_leg_list_t **) 0 ;
}
+SWIGEXPORT void SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_log_json_format_item_t_name_set___(void * jarg1, char * jarg2) {
+ switch_log_json_format_item_t *arg1 = (switch_log_json_format_item_t *) 0 ;
+ char *arg2 = (char *) 0 ;
+
+ arg1 = (switch_log_json_format_item_t *)jarg1;
+ arg2 = (char *)jarg2;
+ {
+ if (arg2) {
+ arg1->name = (char const *) (new char[strlen((const char *)arg2)+1]);
+ strcpy((char *)arg1->name, (const char *)arg2);
+ } else {
+ arg1->name = 0;
+ }
+ }
+}
+
+
+SWIGEXPORT char * SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_log_json_format_item_t_name_get___(void * jarg1) {
+ char * jresult ;
+ switch_log_json_format_item_t *arg1 = (switch_log_json_format_item_t *) 0 ;
+ char *result = 0 ;
+
+ arg1 = (switch_log_json_format_item_t *)jarg1;
+ result = (char *) ((arg1)->name);
+ jresult = SWIG_csharp_string_callback((const char *)result);
+ return jresult;
+}
+
+
+SWIGEXPORT void SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_log_json_format_item_t_value_set___(void * jarg1, char * jarg2) {
+ switch_log_json_format_item_t *arg1 = (switch_log_json_format_item_t *) 0 ;
+ char *arg2 = (char *) 0 ;
+
+ arg1 = (switch_log_json_format_item_t *)jarg1;
+ arg2 = (char *)jarg2;
+ {
+ if (arg2) {
+ arg1->value = (char const *) (new char[strlen((const char *)arg2)+1]);
+ strcpy((char *)arg1->value, (const char *)arg2);
+ } else {
+ arg1->value = 0;
+ }
+ }
+}
+
+
+SWIGEXPORT char * SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_log_json_format_item_t_value_get___(void * jarg1) {
+ char * jresult ;
+ switch_log_json_format_item_t *arg1 = (switch_log_json_format_item_t *) 0 ;
+ char *result = 0 ;
+
+ arg1 = (switch_log_json_format_item_t *)jarg1;
+ result = (char *) ((arg1)->value);
+ jresult = SWIG_csharp_string_callback((const char *)result);
+ return jresult;
+}
+
+
+SWIGEXPORT void * SWIGSTDCALL CSharp_FreeSWITCHfNative_new_switch_log_json_format_item_t___() {
+ void * jresult ;
+ switch_log_json_format_item_t *result = 0 ;
+
+ result = (switch_log_json_format_item_t *)new switch_log_json_format_item_t();
+ jresult = (void *)result;
+ return jresult;
+}
+
+
+SWIGEXPORT void SWIGSTDCALL CSharp_FreeSWITCHfNative_delete_switch_log_json_format_item_t___(void * jarg1) {
+ switch_log_json_format_item_t *arg1 = (switch_log_json_format_item_t *) 0 ;
+
+ arg1 = (switch_log_json_format_item_t *)jarg1;
+ delete arg1;
+}
+
+
+SWIGEXPORT void SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_log_json_format_t_version_set___(void * jarg1, void * jarg2) {
+ switch_log_json_format_t *arg1 = (switch_log_json_format_t *) 0 ;
+ switch_log_json_format_item_t *arg2 = (switch_log_json_format_item_t *) 0 ;
+
+ arg1 = (switch_log_json_format_t *)jarg1;
+ arg2 = (switch_log_json_format_item_t *)jarg2;
+ if (arg1) (arg1)->version = *arg2;
+}
+
+
+SWIGEXPORT void * SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_log_json_format_t_version_get___(void * jarg1) {
+ void * jresult ;
+ switch_log_json_format_t *arg1 = (switch_log_json_format_t *) 0 ;
+ switch_log_json_format_item_t *result = 0 ;
+
+ arg1 = (switch_log_json_format_t *)jarg1;
+ result = (switch_log_json_format_item_t *)& ((arg1)->version);
+ jresult = (void *)result;
+ return jresult;
+}
+
+
+SWIGEXPORT void SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_log_json_format_t_host_set___(void * jarg1, void * jarg2) {
+ switch_log_json_format_t *arg1 = (switch_log_json_format_t *) 0 ;
+ switch_log_json_format_item_t *arg2 = (switch_log_json_format_item_t *) 0 ;
+
+ arg1 = (switch_log_json_format_t *)jarg1;
+ arg2 = (switch_log_json_format_item_t *)jarg2;
+ if (arg1) (arg1)->host = *arg2;
+}
+
+
+SWIGEXPORT void * SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_log_json_format_t_host_get___(void * jarg1) {
+ void * jresult ;
+ switch_log_json_format_t *arg1 = (switch_log_json_format_t *) 0 ;
+ switch_log_json_format_item_t *result = 0 ;
+
+ arg1 = (switch_log_json_format_t *)jarg1;
+ result = (switch_log_json_format_item_t *)& ((arg1)->host);
+ jresult = (void *)result;
+ return jresult;
+}
+
+
+SWIGEXPORT void SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_log_json_format_t_timestamp_set___(void * jarg1, void * jarg2) {
+ switch_log_json_format_t *arg1 = (switch_log_json_format_t *) 0 ;
+ switch_log_json_format_item_t *arg2 = (switch_log_json_format_item_t *) 0 ;
+
+ arg1 = (switch_log_json_format_t *)jarg1;
+ arg2 = (switch_log_json_format_item_t *)jarg2;
+ if (arg1) (arg1)->timestamp = *arg2;
+}
+
+
+SWIGEXPORT void * SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_log_json_format_t_timestamp_get___(void * jarg1) {
+ void * jresult ;
+ switch_log_json_format_t *arg1 = (switch_log_json_format_t *) 0 ;
+ switch_log_json_format_item_t *result = 0 ;
+
+ arg1 = (switch_log_json_format_t *)jarg1;
+ result = (switch_log_json_format_item_t *)& ((arg1)->timestamp);
+ jresult = (void *)result;
+ return jresult;
+}
+
+
+SWIGEXPORT void SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_log_json_format_t_level_set___(void * jarg1, void * jarg2) {
+ switch_log_json_format_t *arg1 = (switch_log_json_format_t *) 0 ;
+ switch_log_json_format_item_t *arg2 = (switch_log_json_format_item_t *) 0 ;
+
+ arg1 = (switch_log_json_format_t *)jarg1;
+ arg2 = (switch_log_json_format_item_t *)jarg2;
+ if (arg1) (arg1)->level = *arg2;
+}
+
+
+SWIGEXPORT void * SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_log_json_format_t_level_get___(void * jarg1) {
+ void * jresult ;
+ switch_log_json_format_t *arg1 = (switch_log_json_format_t *) 0 ;
+ switch_log_json_format_item_t *result = 0 ;
+
+ arg1 = (switch_log_json_format_t *)jarg1;
+ result = (switch_log_json_format_item_t *)& ((arg1)->level);
+ jresult = (void *)result;
+ return jresult;
+}
+
+
+SWIGEXPORT void SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_log_json_format_t_ident_set___(void * jarg1, void * jarg2) {
+ switch_log_json_format_t *arg1 = (switch_log_json_format_t *) 0 ;
+ switch_log_json_format_item_t *arg2 = (switch_log_json_format_item_t *) 0 ;
+
+ arg1 = (switch_log_json_format_t *)jarg1;
+ arg2 = (switch_log_json_format_item_t *)jarg2;
+ if (arg1) (arg1)->ident = *arg2;
+}
+
+
+SWIGEXPORT void * SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_log_json_format_t_ident_get___(void * jarg1) {
+ void * jresult ;
+ switch_log_json_format_t *arg1 = (switch_log_json_format_t *) 0 ;
+ switch_log_json_format_item_t *result = 0 ;
+
+ arg1 = (switch_log_json_format_t *)jarg1;
+ result = (switch_log_json_format_item_t *)& ((arg1)->ident);
+ jresult = (void *)result;
+ return jresult;
+}
+
+
+SWIGEXPORT void SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_log_json_format_t_pid_set___(void * jarg1, void * jarg2) {
+ switch_log_json_format_t *arg1 = (switch_log_json_format_t *) 0 ;
+ switch_log_json_format_item_t *arg2 = (switch_log_json_format_item_t *) 0 ;
+
+ arg1 = (switch_log_json_format_t *)jarg1;
+ arg2 = (switch_log_json_format_item_t *)jarg2;
+ if (arg1) (arg1)->pid = *arg2;
+}
+
+
+SWIGEXPORT void * SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_log_json_format_t_pid_get___(void * jarg1) {
+ void * jresult ;
+ switch_log_json_format_t *arg1 = (switch_log_json_format_t *) 0 ;
+ switch_log_json_format_item_t *result = 0 ;
+
+ arg1 = (switch_log_json_format_t *)jarg1;
+ result = (switch_log_json_format_item_t *)& ((arg1)->pid);
+ jresult = (void *)result;
+ return jresult;
+}
+
+
+SWIGEXPORT void SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_log_json_format_t_uuid_set___(void * jarg1, void * jarg2) {
+ switch_log_json_format_t *arg1 = (switch_log_json_format_t *) 0 ;
+ switch_log_json_format_item_t *arg2 = (switch_log_json_format_item_t *) 0 ;
+
+ arg1 = (switch_log_json_format_t *)jarg1;
+ arg2 = (switch_log_json_format_item_t *)jarg2;
+ if (arg1) (arg1)->uuid = *arg2;
+}
+
+
+SWIGEXPORT void * SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_log_json_format_t_uuid_get___(void * jarg1) {
+ void * jresult ;
+ switch_log_json_format_t *arg1 = (switch_log_json_format_t *) 0 ;
+ switch_log_json_format_item_t *result = 0 ;
+
+ arg1 = (switch_log_json_format_t *)jarg1;
+ result = (switch_log_json_format_item_t *)& ((arg1)->uuid);
+ jresult = (void *)result;
+ return jresult;
+}
+
+
+SWIGEXPORT void SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_log_json_format_t_file_set___(void * jarg1, void * jarg2) {
+ switch_log_json_format_t *arg1 = (switch_log_json_format_t *) 0 ;
+ switch_log_json_format_item_t *arg2 = (switch_log_json_format_item_t *) 0 ;
+
+ arg1 = (switch_log_json_format_t *)jarg1;
+ arg2 = (switch_log_json_format_item_t *)jarg2;
+ if (arg1) (arg1)->file = *arg2;
+}
+
+
+SWIGEXPORT void * SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_log_json_format_t_file_get___(void * jarg1) {
+ void * jresult ;
+ switch_log_json_format_t *arg1 = (switch_log_json_format_t *) 0 ;
+ switch_log_json_format_item_t *result = 0 ;
+
+ arg1 = (switch_log_json_format_t *)jarg1;
+ result = (switch_log_json_format_item_t *)& ((arg1)->file);
+ jresult = (void *)result;
+ return jresult;
+}
+
+
+SWIGEXPORT void SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_log_json_format_t_line_set___(void * jarg1, void * jarg2) {
+ switch_log_json_format_t *arg1 = (switch_log_json_format_t *) 0 ;
+ switch_log_json_format_item_t *arg2 = (switch_log_json_format_item_t *) 0 ;
+
+ arg1 = (switch_log_json_format_t *)jarg1;
+ arg2 = (switch_log_json_format_item_t *)jarg2;
+ if (arg1) (arg1)->line = *arg2;
+}
+
+
+SWIGEXPORT void * SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_log_json_format_t_line_get___(void * jarg1) {
+ void * jresult ;
+ switch_log_json_format_t *arg1 = (switch_log_json_format_t *) 0 ;
+ switch_log_json_format_item_t *result = 0 ;
+
+ arg1 = (switch_log_json_format_t *)jarg1;
+ result = (switch_log_json_format_item_t *)& ((arg1)->line);
+ jresult = (void *)result;
+ return jresult;
+}
+
+
+SWIGEXPORT void SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_log_json_format_t_function_set___(void * jarg1, void * jarg2) {
+ switch_log_json_format_t *arg1 = (switch_log_json_format_t *) 0 ;
+ switch_log_json_format_item_t *arg2 = (switch_log_json_format_item_t *) 0 ;
+
+ arg1 = (switch_log_json_format_t *)jarg1;
+ arg2 = (switch_log_json_format_item_t *)jarg2;
+ if (arg1) (arg1)->function = *arg2;
+}
+
+
+SWIGEXPORT void * SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_log_json_format_t_function_get___(void * jarg1) {
+ void * jresult ;
+ switch_log_json_format_t *arg1 = (switch_log_json_format_t *) 0 ;
+ switch_log_json_format_item_t *result = 0 ;
+
+ arg1 = (switch_log_json_format_t *)jarg1;
+ result = (switch_log_json_format_item_t *)& ((arg1)->function);
+ jresult = (void *)result;
+ return jresult;
+}
+
+
+SWIGEXPORT void SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_log_json_format_t_full_message_set___(void * jarg1, void * jarg2) {
+ switch_log_json_format_t *arg1 = (switch_log_json_format_t *) 0 ;
+ switch_log_json_format_item_t *arg2 = (switch_log_json_format_item_t *) 0 ;
+
+ arg1 = (switch_log_json_format_t *)jarg1;
+ arg2 = (switch_log_json_format_item_t *)jarg2;
+ if (arg1) (arg1)->full_message = *arg2;
+}
+
+
+SWIGEXPORT void * SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_log_json_format_t_full_message_get___(void * jarg1) {
+ void * jresult ;
+ switch_log_json_format_t *arg1 = (switch_log_json_format_t *) 0 ;
+ switch_log_json_format_item_t *result = 0 ;
+
+ arg1 = (switch_log_json_format_t *)jarg1;
+ result = (switch_log_json_format_item_t *)& ((arg1)->full_message);
+ jresult = (void *)result;
+ return jresult;
+}
+
+
+SWIGEXPORT void SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_log_json_format_t_short_message_set___(void * jarg1, void * jarg2) {
+ switch_log_json_format_t *arg1 = (switch_log_json_format_t *) 0 ;
+ switch_log_json_format_item_t *arg2 = (switch_log_json_format_item_t *) 0 ;
+
+ arg1 = (switch_log_json_format_t *)jarg1;
+ arg2 = (switch_log_json_format_item_t *)jarg2;
+ if (arg1) (arg1)->short_message = *arg2;
+}
+
+
+SWIGEXPORT void * SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_log_json_format_t_short_message_get___(void * jarg1) {
+ void * jresult ;
+ switch_log_json_format_t *arg1 = (switch_log_json_format_t *) 0 ;
+ switch_log_json_format_item_t *result = 0 ;
+
+ arg1 = (switch_log_json_format_t *)jarg1;
+ result = (switch_log_json_format_item_t *)& ((arg1)->short_message);
+ jresult = (void *)result;
+ return jresult;
+}
+
+
+SWIGEXPORT void SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_log_json_format_t_custom_field_prefix_set___(void * jarg1, char * jarg2) {
+ switch_log_json_format_t *arg1 = (switch_log_json_format_t *) 0 ;
+ char *arg2 = (char *) 0 ;
+
+ arg1 = (switch_log_json_format_t *)jarg1;
+ arg2 = (char *)jarg2;
+ {
+ if (arg2) {
+ arg1->custom_field_prefix = (char const *) (new char[strlen((const char *)arg2)+1]);
+ strcpy((char *)arg1->custom_field_prefix, (const char *)arg2);
+ } else {
+ arg1->custom_field_prefix = 0;
+ }
+ }
+}
+
+
+SWIGEXPORT char * SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_log_json_format_t_custom_field_prefix_get___(void * jarg1) {
+ char * jresult ;
+ switch_log_json_format_t *arg1 = (switch_log_json_format_t *) 0 ;
+ char *result = 0 ;
+
+ arg1 = (switch_log_json_format_t *)jarg1;
+ result = (char *) ((arg1)->custom_field_prefix);
+ jresult = SWIG_csharp_string_callback((const char *)result);
+ return jresult;
+}
+
+
+SWIGEXPORT void SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_log_json_format_t_timestamp_divisor_set___(void * jarg1, double jarg2) {
+ switch_log_json_format_t *arg1 = (switch_log_json_format_t *) 0 ;
+ double arg2 ;
+
+ arg1 = (switch_log_json_format_t *)jarg1;
+ arg2 = (double)jarg2;
+ if (arg1) (arg1)->timestamp_divisor = arg2;
+}
+
+
+SWIGEXPORT double SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_log_json_format_t_timestamp_divisor_get___(void * jarg1) {
+ double jresult ;
+ switch_log_json_format_t *arg1 = (switch_log_json_format_t *) 0 ;
+ double result;
+
+ arg1 = (switch_log_json_format_t *)jarg1;
+ result = (double) ((arg1)->timestamp_divisor);
+ jresult = result;
+ return jresult;
+}
+
+
+SWIGEXPORT void * SWIGSTDCALL CSharp_FreeSWITCHfNative_new_switch_log_json_format_t___() {
+ void * jresult ;
+ switch_log_json_format_t *result = 0 ;
+
+ result = (switch_log_json_format_t *)new switch_log_json_format_t();
+ jresult = (void *)result;
+ return jresult;
+}
+
+
+SWIGEXPORT void SWIGSTDCALL CSharp_FreeSWITCHfNative_delete_switch_log_json_format_t___(void * jarg1) {
+ switch_log_json_format_t *arg1 = (switch_log_json_format_t *) 0 ;
+
+ arg1 = (switch_log_json_format_t *)jarg1;
+ delete arg1;
+}
+
+
+SWIGEXPORT void * SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_log_node_to_json___(void * jarg1, int jarg2, void * jarg3, void * jarg4) {
+ void * jresult ;
+ switch_log_node_t *arg1 = (switch_log_node_t *) 0 ;
+ int arg2 ;
+ switch_log_json_format_t *arg3 = (switch_log_json_format_t *) 0 ;
+ switch_event_t *arg4 = (switch_event_t *) 0 ;
+ cJSON *result = 0 ;
+
+ arg1 = (switch_log_node_t *)jarg1;
+ arg2 = (int)jarg2;
+ arg3 = (switch_log_json_format_t *)jarg3;
+ arg4 = (switch_event_t *)jarg4;
+ result = (cJSON *)switch_log_node_to_json((switch_log_node_t const *)arg1,arg2,arg3,arg4);
+ jresult = (void *)result;
+ return jresult;
+}
+
+
SWIGEXPORT int SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_log_init___(void * jarg1, int jarg2) {
int jresult ;
switch_memory_pool_t *arg1 = (switch_memory_pool_t *) 0 ;
<ItemGroup>\r
<ProjectReference Include="..\..\FreeSWITCH.Managed.2017.csproj">\r
<Project>{834e2b2f-5483-4b80-8fe3-fe48ff76e5c0}</Project>\r
- <Name>FreeSWITCH.Managed.2015</Name>\r
+ <Name>FreeSWITCH.Managed.2017</Name>\r
</ProjectReference>\r
</ItemGroup>\r
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />\r
namespace FreeSWITCH.Native {
-public class SWIGTYPE_p_f_p_char_p_p_switch_database_interface_handle__switch_status_t {
- private global::System.Runtime.InteropServices.HandleRef swigCPtr;
-
- internal SWIGTYPE_p_f_p_char_p_p_switch_database_interface_handle__switch_status_t(global::System.IntPtr cPtr, bool futureUse) {
- swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
- }
-
- protected SWIGTYPE_p_f_p_char_p_p_switch_database_interface_handle__switch_status_t() {
- swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
- }
-
- internal static global::System.Runtime.InteropServices.HandleRef getCPtr(SWIGTYPE_p_f_p_char_p_p_switch_database_interface_handle__switch_status_t obj) {
- return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
- }
-}
-
-}
-//------------------------------------------------------------------------------
-// <auto-generated />
-//
-// This file was automatically generated by SWIG (http://www.swig.org).
-// Version 3.0.10
-//
-// Do not make changes to this file unless you know what you are doing--modify
-// the SWIG interface file instead.
-//------------------------------------------------------------------------------
-
-namespace FreeSWITCH.Native {
-
public class SWIGTYPE_p_f_p_p_switch_database_interface_handle__switch_status_t {
private global::System.Runtime.InteropServices.HandleRef swigCPtr;
namespace FreeSWITCH.Native {
-public class SWIGTYPE_p_f_p_q_const__char_p_cJSON_p_q_const__char_unsigned_long__void {
+public class SWIGTYPE_p_f_p_q_const__char_p_cJSON_p_q_const__char_unsigned_long_p_void__void {
private global::System.Runtime.InteropServices.HandleRef swigCPtr;
- internal SWIGTYPE_p_f_p_q_const__char_p_cJSON_p_q_const__char_unsigned_long__void(global::System.IntPtr cPtr, bool futureUse) {
+ internal SWIGTYPE_p_f_p_q_const__char_p_cJSON_p_q_const__char_unsigned_long_p_void__void(global::System.IntPtr cPtr, bool futureUse) {
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
}
- protected SWIGTYPE_p_f_p_q_const__char_p_cJSON_p_q_const__char_unsigned_long__void() {
+ protected SWIGTYPE_p_f_p_q_const__char_p_cJSON_p_q_const__char_unsigned_long_p_void__void() {
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
}
- internal static global::System.Runtime.InteropServices.HandleRef getCPtr(SWIGTYPE_p_f_p_q_const__char_p_cJSON_p_q_const__char_unsigned_long__void obj) {
+ internal static global::System.Runtime.InteropServices.HandleRef getCPtr(SWIGTYPE_p_f_p_q_const__char_p_cJSON_p_q_const__char_unsigned_long_p_void__void obj) {
return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
}
}
namespace FreeSWITCH.Native {
+public class SWIGTYPE_p_f_switch_cache_db_database_interface_options_t_p_p_switch_database_interface_handle__switch_status_t {
+ private global::System.Runtime.InteropServices.HandleRef swigCPtr;
+
+ internal SWIGTYPE_p_f_switch_cache_db_database_interface_options_t_p_p_switch_database_interface_handle__switch_status_t(global::System.IntPtr cPtr, bool futureUse) {
+ swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
+ }
+
+ protected SWIGTYPE_p_f_switch_cache_db_database_interface_options_t_p_p_switch_database_interface_handle__switch_status_t() {
+ swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
+ }
+
+ internal static global::System.Runtime.InteropServices.HandleRef getCPtr(SWIGTYPE_p_f_switch_cache_db_database_interface_options_t_p_p_switch_database_interface_handle__switch_status_t obj) {
+ return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
+ }
+}
+
+}
+//------------------------------------------------------------------------------
+// <auto-generated />
+//
+// This file was automatically generated by SWIG (http://www.swig.org).
+// Version 3.0.10
+//
+// Do not make changes to this file unless you know what you are doing--modify
+// the SWIG interface file instead.
+//------------------------------------------------------------------------------
+
+namespace FreeSWITCH.Native {
+
public class SWIGTYPE_p_f_uint8_t_p_p_q_const__char_p_void__p_switch_xml {
private global::System.Runtime.InteropServices.HandleRef swigCPtr;
namespace FreeSWITCH.Native {
-public class SWIGTYPE_p_switch_pgsql_handle {
- private global::System.Runtime.InteropServices.HandleRef swigCPtr;
-
- internal SWIGTYPE_p_switch_pgsql_handle(global::System.IntPtr cPtr, bool futureUse) {
- swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
- }
-
- protected SWIGTYPE_p_switch_pgsql_handle() {
- swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
- }
-
- internal static global::System.Runtime.InteropServices.HandleRef getCPtr(SWIGTYPE_p_switch_pgsql_handle obj) {
- return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
- }
-}
-
-}
-//------------------------------------------------------------------------------
-// <auto-generated />
-//
-// This file was automatically generated by SWIG (http://www.swig.org).
-// Version 3.0.10
-//
-// Do not make changes to this file unless you know what you are doing--modify
-// the SWIG interface file instead.
-//------------------------------------------------------------------------------
-
-namespace FreeSWITCH.Native {
-
public class SWIGTYPE_p_switch_pollfd_t {
private global::System.Runtime.InteropServices.HandleRef swigCPtr;
return ret;
}
+ public static switch_status_t switch_database_available(string dsn) {
+ switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_database_available(dsn);
+ return ret;
+ }
+
public static void switch_core_set_signal_handlers() {
freeswitchPINVOKE.switch_core_set_signal_handlers();
}
return ret;
}
- public static uint switch_event_channel_unbind(string event_channel, SWIGTYPE_p_f_p_q_const__char_p_cJSON_p_q_const__char_unsigned_long__void func) {
- uint ret = freeswitchPINVOKE.switch_event_channel_unbind(event_channel, SWIGTYPE_p_f_p_q_const__char_p_cJSON_p_q_const__char_unsigned_long__void.getCPtr(func));
+ public static switch_status_t switch_event_channel_deliver(string event_channel, SWIGTYPE_p_p_cJSON json, string key, uint id) {
+ switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_event_channel_deliver(event_channel, SWIGTYPE_p_p_cJSON.getCPtr(json), key, id);
return ret;
}
- public static switch_status_t switch_event_channel_bind(string event_channel, SWIGTYPE_p_f_p_q_const__char_p_cJSON_p_q_const__char_unsigned_long__void func, SWIGTYPE_p_unsigned_long id) {
- switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_event_channel_bind(event_channel, SWIGTYPE_p_f_p_q_const__char_p_cJSON_p_q_const__char_unsigned_long__void.getCPtr(func), SWIGTYPE_p_unsigned_long.getCPtr(id));
+ public static uint switch_event_channel_unbind(string event_channel, SWIGTYPE_p_f_p_q_const__char_p_cJSON_p_q_const__char_unsigned_long_p_void__void func, SWIGTYPE_p_void user_data) {
+ uint ret = freeswitchPINVOKE.switch_event_channel_unbind(event_channel, SWIGTYPE_p_f_p_q_const__char_p_cJSON_p_q_const__char_unsigned_long_p_void__void.getCPtr(func), SWIGTYPE_p_void.getCPtr(user_data));
+ return ret;
+ }
+
+ public static switch_status_t switch_event_channel_bind(string event_channel, SWIGTYPE_p_f_p_q_const__char_p_cJSON_p_q_const__char_unsigned_long_p_void__void func, SWIGTYPE_p_unsigned_long id, SWIGTYPE_p_void user_data) {
+ switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_event_channel_bind(event_channel, SWIGTYPE_p_f_p_q_const__char_p_cJSON_p_q_const__char_unsigned_long_p_void__void.getCPtr(func), SWIGTYPE_p_unsigned_long.getCPtr(id), SWIGTYPE_p_void.getCPtr(user_data));
return ret;
}
return ret;
}
+ public static switch_status_t switch_dial_handle_create_json_obj(SWIGTYPE_p_p_switch_dial_handle_s handle, SWIGTYPE_p_cJSON json) {
+ switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_dial_handle_create_json_obj(SWIGTYPE_p_p_switch_dial_handle_s.getCPtr(handle), SWIGTYPE_p_cJSON.getCPtr(json));
+ return ret;
+ }
+
+ public static switch_status_t switch_dial_handle_create_json(SWIGTYPE_p_p_switch_dial_handle_s handle, string handle_string) {
+ switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_dial_handle_create_json(SWIGTYPE_p_p_switch_dial_handle_s.getCPtr(handle), handle_string);
+ return ret;
+ }
+
public static void switch_dial_handle_destroy(SWIGTYPE_p_p_switch_dial_handle_s handle) {
freeswitchPINVOKE.switch_dial_handle_destroy(SWIGTYPE_p_p_switch_dial_handle_s.getCPtr(handle));
}
+ public static switch_status_t switch_dial_handle_serialize_json_obj(SWIGTYPE_p_switch_dial_handle_s handle, SWIGTYPE_p_p_cJSON json) {
+ switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_dial_handle_serialize_json_obj(SWIGTYPE_p_switch_dial_handle_s.getCPtr(handle), SWIGTYPE_p_p_cJSON.getCPtr(json));
+ return ret;
+ }
+
+ public static switch_status_t switch_dial_handle_serialize_json(SWIGTYPE_p_switch_dial_handle_s handle, ref string str) {
+ switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_dial_handle_serialize_json(SWIGTYPE_p_switch_dial_handle_s.getCPtr(handle), ref str);
+ return ret;
+ }
+
public static void switch_dial_handle_add_leg_list(SWIGTYPE_p_switch_dial_handle_s handle, SWIGTYPE_p_p_switch_dial_leg_list_s leg_listP) {
freeswitchPINVOKE.switch_dial_handle_add_leg_list(SWIGTYPE_p_switch_dial_handle_s.getCPtr(handle), SWIGTYPE_p_p_switch_dial_leg_list_s.getCPtr(leg_listP));
}
freeswitchPINVOKE.switch_rtp_video_loss(SWIGTYPE_p_switch_rtp.getCPtr(rtp_session));
}
+ public static SWIGTYPE_p_cJSON switch_log_node_to_json(switch_log_node_t node, int log_level, switch_log_json_format_t json_format, switch_event chan_vars) {
+ global::System.IntPtr cPtr = freeswitchPINVOKE.switch_log_node_to_json(switch_log_node_t.getCPtr(node), log_level, switch_log_json_format_t.getCPtr(json_format), switch_event.getCPtr(chan_vars));
+ SWIGTYPE_p_cJSON ret = (cPtr == global::System.IntPtr.Zero) ? null : new SWIGTYPE_p_cJSON(cPtr, false);
+ return ret;
+ }
+
public static switch_status_t switch_log_init(SWIGTYPE_p_apr_pool_t pool, switch_bool_t colorize) {
switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_log_init(SWIGTYPE_p_apr_pool_t.getCPtr(pool), (int)colorize);
return ret;
[global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_cache_db_native_handle_t_odbc_dbh_get___")]
public static extern global::System.IntPtr switch_cache_db_native_handle_t_odbc_dbh_get(global::System.Runtime.InteropServices.HandleRef jarg1);
- [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_cache_db_native_handle_t_pgsql_dbh_set___")]
- public static extern void switch_cache_db_native_handle_t_pgsql_dbh_set(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2);
-
- [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_cache_db_native_handle_t_pgsql_dbh_get___")]
- public static extern global::System.IntPtr switch_cache_db_native_handle_t_pgsql_dbh_get(global::System.Runtime.InteropServices.HandleRef jarg1);
-
[global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_cache_db_native_handle_t_database_interface_dbh_set___")]
public static extern void switch_cache_db_native_handle_t_database_interface_dbh_set(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2);
[global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_delete_switch_cache_db_odbc_options_t___")]
public static extern void delete_switch_cache_db_odbc_options_t(global::System.Runtime.InteropServices.HandleRef jarg1);
- [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_cache_db_pgsql_options_t_dsn_set___")]
- public static extern void switch_cache_db_pgsql_options_t_dsn_set(global::System.Runtime.InteropServices.HandleRef jarg1, string jarg2);
-
- [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_cache_db_pgsql_options_t_dsn_get___")]
- public static extern string switch_cache_db_pgsql_options_t_dsn_get(global::System.Runtime.InteropServices.HandleRef jarg1);
-
- [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_new_switch_cache_db_pgsql_options_t___")]
- public static extern global::System.IntPtr new_switch_cache_db_pgsql_options_t();
+ [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_cache_db_database_interface_options_t_original_dsn_set___")]
+ public static extern void switch_cache_db_database_interface_options_t_original_dsn_set(global::System.Runtime.InteropServices.HandleRef jarg1, string jarg2);
- [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_delete_switch_cache_db_pgsql_options_t___")]
- public static extern void delete_switch_cache_db_pgsql_options_t(global::System.Runtime.InteropServices.HandleRef jarg1);
+ [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_cache_db_database_interface_options_t_original_dsn_get___")]
+ public static extern string switch_cache_db_database_interface_options_t_original_dsn_get(global::System.Runtime.InteropServices.HandleRef jarg1);
- [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_cache_db_database_interface_options_t_dsn_set___")]
- public static extern void switch_cache_db_database_interface_options_t_dsn_set(global::System.Runtime.InteropServices.HandleRef jarg1, string jarg2);
+ [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_cache_db_database_interface_options_t_connection_string_set___")]
+ public static extern void switch_cache_db_database_interface_options_t_connection_string_set(global::System.Runtime.InteropServices.HandleRef jarg1, string jarg2);
- [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_cache_db_database_interface_options_t_dsn_get___")]
- public static extern string switch_cache_db_database_interface_options_t_dsn_get(global::System.Runtime.InteropServices.HandleRef jarg1);
+ [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_cache_db_database_interface_options_t_connection_string_get___")]
+ public static extern string switch_cache_db_database_interface_options_t_connection_string_get(global::System.Runtime.InteropServices.HandleRef jarg1);
[global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_cache_db_database_interface_options_t_prefix_set___")]
public static extern void switch_cache_db_database_interface_options_t_prefix_set(global::System.Runtime.InteropServices.HandleRef jarg1, string jarg2);
[global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_cache_db_connection_options_t_odbc_options_get___")]
public static extern global::System.IntPtr switch_cache_db_connection_options_t_odbc_options_get(global::System.Runtime.InteropServices.HandleRef jarg1);
- [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_cache_db_connection_options_t_pgsql_options_set___")]
- public static extern void switch_cache_db_connection_options_t_pgsql_options_set(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2);
-
- [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_cache_db_connection_options_t_pgsql_options_get___")]
- public static extern global::System.IntPtr switch_cache_db_connection_options_t_pgsql_options_get(global::System.Runtime.InteropServices.HandleRef jarg1);
-
[global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_cache_db_connection_options_t_database_interface_options_set___")]
public static extern void switch_cache_db_connection_options_t_database_interface_options_set(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2);
[global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_core_check_core_db_dsn___")]
public static extern int switch_core_check_core_db_dsn();
+ [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_database_available___")]
+ public static extern int switch_database_available(string jarg1);
+
[global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_core_set_signal_handlers___")]
public static extern void switch_core_set_signal_handlers();
[global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_event_channel_broadcast___")]
public static extern int switch_event_channel_broadcast(string jarg1, global::System.Runtime.InteropServices.HandleRef jarg2, string jarg3, uint jarg4);
+ [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_event_channel_deliver___")]
+ public static extern int switch_event_channel_deliver(string jarg1, global::System.Runtime.InteropServices.HandleRef jarg2, string jarg3, uint jarg4);
+
[global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_event_channel_unbind___")]
- public static extern uint switch_event_channel_unbind(string jarg1, global::System.Runtime.InteropServices.HandleRef jarg2);
+ public static extern uint switch_event_channel_unbind(string jarg1, global::System.Runtime.InteropServices.HandleRef jarg2, global::System.Runtime.InteropServices.HandleRef jarg3);
[global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_event_channel_bind___")]
- public static extern int switch_event_channel_bind(string jarg1, global::System.Runtime.InteropServices.HandleRef jarg2, global::System.Runtime.InteropServices.HandleRef jarg3);
+ public static extern int switch_event_channel_bind(string jarg1, global::System.Runtime.InteropServices.HandleRef jarg2, global::System.Runtime.InteropServices.HandleRef jarg3, global::System.Runtime.InteropServices.HandleRef jarg4);
[global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_NO_EVENT_CHANNEL_ID_get___")]
public static extern int NO_EVENT_CHANNEL_ID_get();
[global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_dial_handle_create___")]
public static extern int switch_dial_handle_create(global::System.Runtime.InteropServices.HandleRef jarg1);
+ [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_dial_handle_create_json_obj___")]
+ public static extern int switch_dial_handle_create_json_obj(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2);
+
+ [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_dial_handle_create_json___")]
+ public static extern int switch_dial_handle_create_json(global::System.Runtime.InteropServices.HandleRef jarg1, string jarg2);
+
[global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_dial_handle_destroy___")]
public static extern void switch_dial_handle_destroy(global::System.Runtime.InteropServices.HandleRef jarg1);
+ [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_dial_handle_serialize_json_obj___")]
+ public static extern int switch_dial_handle_serialize_json_obj(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2);
+
+ [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_dial_handle_serialize_json___")]
+ public static extern int switch_dial_handle_serialize_json(global::System.Runtime.InteropServices.HandleRef jarg1, ref string jarg2);
+
[global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_dial_handle_add_leg_list___")]
public static extern void switch_dial_handle_add_leg_list(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2);
[global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_delete_switch_log_node_t___")]
public static extern void delete_switch_log_node_t(global::System.Runtime.InteropServices.HandleRef jarg1);
+ [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_log_json_format_item_t_name_set___")]
+ public static extern void switch_log_json_format_item_t_name_set(global::System.Runtime.InteropServices.HandleRef jarg1, string jarg2);
+
+ [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_log_json_format_item_t_name_get___")]
+ public static extern string switch_log_json_format_item_t_name_get(global::System.Runtime.InteropServices.HandleRef jarg1);
+
+ [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_log_json_format_item_t_value_set___")]
+ public static extern void switch_log_json_format_item_t_value_set(global::System.Runtime.InteropServices.HandleRef jarg1, string jarg2);
+
+ [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_log_json_format_item_t_value_get___")]
+ public static extern string switch_log_json_format_item_t_value_get(global::System.Runtime.InteropServices.HandleRef jarg1);
+
+ [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_new_switch_log_json_format_item_t___")]
+ public static extern global::System.IntPtr new_switch_log_json_format_item_t();
+
+ [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_delete_switch_log_json_format_item_t___")]
+ public static extern void delete_switch_log_json_format_item_t(global::System.Runtime.InteropServices.HandleRef jarg1);
+
+ [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_log_json_format_t_version_set___")]
+ public static extern void switch_log_json_format_t_version_set(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2);
+
+ [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_log_json_format_t_version_get___")]
+ public static extern global::System.IntPtr switch_log_json_format_t_version_get(global::System.Runtime.InteropServices.HandleRef jarg1);
+
+ [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_log_json_format_t_host_set___")]
+ public static extern void switch_log_json_format_t_host_set(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2);
+
+ [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_log_json_format_t_host_get___")]
+ public static extern global::System.IntPtr switch_log_json_format_t_host_get(global::System.Runtime.InteropServices.HandleRef jarg1);
+
+ [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_log_json_format_t_timestamp_set___")]
+ public static extern void switch_log_json_format_t_timestamp_set(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2);
+
+ [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_log_json_format_t_timestamp_get___")]
+ public static extern global::System.IntPtr switch_log_json_format_t_timestamp_get(global::System.Runtime.InteropServices.HandleRef jarg1);
+
+ [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_log_json_format_t_level_set___")]
+ public static extern void switch_log_json_format_t_level_set(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2);
+
+ [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_log_json_format_t_level_get___")]
+ public static extern global::System.IntPtr switch_log_json_format_t_level_get(global::System.Runtime.InteropServices.HandleRef jarg1);
+
+ [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_log_json_format_t_ident_set___")]
+ public static extern void switch_log_json_format_t_ident_set(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2);
+
+ [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_log_json_format_t_ident_get___")]
+ public static extern global::System.IntPtr switch_log_json_format_t_ident_get(global::System.Runtime.InteropServices.HandleRef jarg1);
+
+ [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_log_json_format_t_pid_set___")]
+ public static extern void switch_log_json_format_t_pid_set(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2);
+
+ [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_log_json_format_t_pid_get___")]
+ public static extern global::System.IntPtr switch_log_json_format_t_pid_get(global::System.Runtime.InteropServices.HandleRef jarg1);
+
+ [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_log_json_format_t_uuid_set___")]
+ public static extern void switch_log_json_format_t_uuid_set(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2);
+
+ [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_log_json_format_t_uuid_get___")]
+ public static extern global::System.IntPtr switch_log_json_format_t_uuid_get(global::System.Runtime.InteropServices.HandleRef jarg1);
+
+ [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_log_json_format_t_file_set___")]
+ public static extern void switch_log_json_format_t_file_set(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2);
+
+ [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_log_json_format_t_file_get___")]
+ public static extern global::System.IntPtr switch_log_json_format_t_file_get(global::System.Runtime.InteropServices.HandleRef jarg1);
+
+ [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_log_json_format_t_line_set___")]
+ public static extern void switch_log_json_format_t_line_set(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2);
+
+ [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_log_json_format_t_line_get___")]
+ public static extern global::System.IntPtr switch_log_json_format_t_line_get(global::System.Runtime.InteropServices.HandleRef jarg1);
+
+ [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_log_json_format_t_function_set___")]
+ public static extern void switch_log_json_format_t_function_set(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2);
+
+ [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_log_json_format_t_function_get___")]
+ public static extern global::System.IntPtr switch_log_json_format_t_function_get(global::System.Runtime.InteropServices.HandleRef jarg1);
+
+ [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_log_json_format_t_full_message_set___")]
+ public static extern void switch_log_json_format_t_full_message_set(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2);
+
+ [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_log_json_format_t_full_message_get___")]
+ public static extern global::System.IntPtr switch_log_json_format_t_full_message_get(global::System.Runtime.InteropServices.HandleRef jarg1);
+
+ [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_log_json_format_t_short_message_set___")]
+ public static extern void switch_log_json_format_t_short_message_set(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2);
+
+ [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_log_json_format_t_short_message_get___")]
+ public static extern global::System.IntPtr switch_log_json_format_t_short_message_get(global::System.Runtime.InteropServices.HandleRef jarg1);
+
+ [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_log_json_format_t_custom_field_prefix_set___")]
+ public static extern void switch_log_json_format_t_custom_field_prefix_set(global::System.Runtime.InteropServices.HandleRef jarg1, string jarg2);
+
+ [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_log_json_format_t_custom_field_prefix_get___")]
+ public static extern string switch_log_json_format_t_custom_field_prefix_get(global::System.Runtime.InteropServices.HandleRef jarg1);
+
+ [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_log_json_format_t_timestamp_divisor_set___")]
+ public static extern void switch_log_json_format_t_timestamp_divisor_set(global::System.Runtime.InteropServices.HandleRef jarg1, double jarg2);
+
+ [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_log_json_format_t_timestamp_divisor_get___")]
+ public static extern double switch_log_json_format_t_timestamp_divisor_get(global::System.Runtime.InteropServices.HandleRef jarg1);
+
+ [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_new_switch_log_json_format_t___")]
+ public static extern global::System.IntPtr new_switch_log_json_format_t();
+
+ [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_delete_switch_log_json_format_t___")]
+ public static extern void delete_switch_log_json_format_t(global::System.Runtime.InteropServices.HandleRef jarg1);
+
+ [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_log_node_to_json___")]
+ public static extern global::System.IntPtr switch_log_node_to_json(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2, global::System.Runtime.InteropServices.HandleRef jarg3, global::System.Runtime.InteropServices.HandleRef jarg4);
+
[global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_log_init___")]
public static extern int switch_log_init(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2);
}
}
- public switch_cache_db_pgsql_options_t pgsql_options {
- set {
- freeswitchPINVOKE.switch_cache_db_connection_options_t_pgsql_options_set(swigCPtr, switch_cache_db_pgsql_options_t.getCPtr(value));
- }
- get {
- global::System.IntPtr cPtr = freeswitchPINVOKE.switch_cache_db_connection_options_t_pgsql_options_get(swigCPtr);
- switch_cache_db_pgsql_options_t ret = (cPtr == global::System.IntPtr.Zero) ? null : new switch_cache_db_pgsql_options_t(cPtr, false);
- return ret;
- }
- }
-
public switch_cache_db_database_interface_options_t database_interface_options {
set {
freeswitchPINVOKE.switch_cache_db_connection_options_t_database_interface_options_set(swigCPtr, switch_cache_db_database_interface_options_t.getCPtr(value));
}
}
- public string dsn {
+ public string original_dsn {
+ set {
+ freeswitchPINVOKE.switch_cache_db_database_interface_options_t_original_dsn_set(swigCPtr, value);
+ }
+ get {
+ string ret = freeswitchPINVOKE.switch_cache_db_database_interface_options_t_original_dsn_get(swigCPtr);
+ return ret;
+ }
+ }
+
+ public string connection_string {
set {
- freeswitchPINVOKE.switch_cache_db_database_interface_options_t_dsn_set(swigCPtr, value);
+ freeswitchPINVOKE.switch_cache_db_database_interface_options_t_connection_string_set(swigCPtr, value);
}
get {
- string ret = freeswitchPINVOKE.switch_cache_db_database_interface_options_t_dsn_get(swigCPtr);
+ string ret = freeswitchPINVOKE.switch_cache_db_database_interface_options_t_connection_string_get(swigCPtr);
return ret;
}
}
public enum switch_cache_db_handle_type_t {
SCDB_TYPE_CORE_DB,
SCDB_TYPE_ODBC,
- SCDB_TYPE_PGSQL,
SCDB_TYPE_DATABASE_INTERFACE
}
}
}
- public SWIGTYPE_p_switch_pgsql_handle pgsql_dbh {
- set {
- freeswitchPINVOKE.switch_cache_db_native_handle_t_pgsql_dbh_set(swigCPtr, SWIGTYPE_p_switch_pgsql_handle.getCPtr(value));
- }
- get {
- global::System.IntPtr cPtr = freeswitchPINVOKE.switch_cache_db_native_handle_t_pgsql_dbh_get(swigCPtr);
- SWIGTYPE_p_switch_pgsql_handle ret = (cPtr == global::System.IntPtr.Zero) ? null : new SWIGTYPE_p_switch_pgsql_handle(cPtr, false);
- return ret;
- }
- }
-
public switch_database_interface_handle database_interface_dbh {
set {
freeswitchPINVOKE.switch_cache_db_native_handle_t_database_interface_dbh_set(swigCPtr, switch_database_interface_handle.getCPtr(value));
namespace FreeSWITCH.Native {
-public class switch_cache_db_pgsql_options_t : global::System.IDisposable {
- private global::System.Runtime.InteropServices.HandleRef swigCPtr;
- protected bool swigCMemOwn;
-
- internal switch_cache_db_pgsql_options_t(global::System.IntPtr cPtr, bool cMemoryOwn) {
- swigCMemOwn = cMemoryOwn;
- swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
- }
-
- internal static global::System.Runtime.InteropServices.HandleRef getCPtr(switch_cache_db_pgsql_options_t obj) {
- return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
- }
-
- ~switch_cache_db_pgsql_options_t() {
- Dispose();
- }
-
- public virtual void Dispose() {
- lock(this) {
- if (swigCPtr.Handle != global::System.IntPtr.Zero) {
- if (swigCMemOwn) {
- swigCMemOwn = false;
- freeswitchPINVOKE.delete_switch_cache_db_pgsql_options_t(swigCPtr);
- }
- swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
- }
- global::System.GC.SuppressFinalize(this);
- }
- }
-
- public string dsn {
- set {
- freeswitchPINVOKE.switch_cache_db_pgsql_options_t_dsn_set(swigCPtr, value);
- }
- get {
- string ret = freeswitchPINVOKE.switch_cache_db_pgsql_options_t_dsn_get(swigCPtr);
- return ret;
- }
- }
-
- public switch_cache_db_pgsql_options_t() : this(freeswitchPINVOKE.new_switch_cache_db_pgsql_options_t(), true) {
- }
-
-}
-
-}
-//------------------------------------------------------------------------------
-// <auto-generated />
-//
-// This file was automatically generated by SWIG (http://www.swig.org).
-// Version 3.0.10
-//
-// Do not make changes to this file unless you know what you are doing--modify
-// the SWIG interface file instead.
-//------------------------------------------------------------------------------
-
-namespace FreeSWITCH.Native {
-
public enum switch_call_cause_t {
SWITCH_CAUSE_NONE = 0,
SWITCH_CAUSE_UNALLOCATED_NUMBER = 1,
}
}
- public SWIGTYPE_p_f_p_char_p_p_switch_database_interface_handle__switch_status_t handle_new {
+ public SWIGTYPE_p_f_switch_cache_db_database_interface_options_t_p_p_switch_database_interface_handle__switch_status_t handle_new {
set {
- freeswitchPINVOKE.switch_database_interface_handle_new_set(swigCPtr, SWIGTYPE_p_f_p_char_p_p_switch_database_interface_handle__switch_status_t.getCPtr(value));
+ freeswitchPINVOKE.switch_database_interface_handle_new_set(swigCPtr, SWIGTYPE_p_f_switch_cache_db_database_interface_options_t_p_p_switch_database_interface_handle__switch_status_t.getCPtr(value));
}
get {
global::System.IntPtr cPtr = freeswitchPINVOKE.switch_database_interface_handle_new_get(swigCPtr);
- SWIGTYPE_p_f_p_char_p_p_switch_database_interface_handle__switch_status_t ret = (cPtr == global::System.IntPtr.Zero) ? null : new SWIGTYPE_p_f_p_char_p_p_switch_database_interface_handle__switch_status_t(cPtr, false);
+ SWIGTYPE_p_f_switch_cache_db_database_interface_options_t_p_p_switch_database_interface_handle__switch_status_t ret = (cPtr == global::System.IntPtr.Zero) ? null : new SWIGTYPE_p_f_switch_cache_db_database_interface_options_t_p_p_switch_database_interface_handle__switch_status_t(cPtr, false);
return ret;
}
}
ED_DTMF = (1 << 2),
ED_COPY_DISPLAY = (1 << 3),
ED_BRIDGE_READ = (1 << 4),
- ED_BRIDGE_WRITE = (1 << 5)
+ ED_BRIDGE_WRITE = (1 << 5),
+ ED_TAP_READ = (1 << 6),
+ ED_TAP_WRITE = (1 << 7)
}
}
namespace FreeSWITCH.Native {
+public class switch_log_json_format_item_t : global::System.IDisposable {
+ private global::System.Runtime.InteropServices.HandleRef swigCPtr;
+ protected bool swigCMemOwn;
+
+ internal switch_log_json_format_item_t(global::System.IntPtr cPtr, bool cMemoryOwn) {
+ swigCMemOwn = cMemoryOwn;
+ swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
+ }
+
+ internal static global::System.Runtime.InteropServices.HandleRef getCPtr(switch_log_json_format_item_t obj) {
+ return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
+ }
+
+ ~switch_log_json_format_item_t() {
+ Dispose();
+ }
+
+ public virtual void Dispose() {
+ lock(this) {
+ if (swigCPtr.Handle != global::System.IntPtr.Zero) {
+ if (swigCMemOwn) {
+ swigCMemOwn = false;
+ freeswitchPINVOKE.delete_switch_log_json_format_item_t(swigCPtr);
+ }
+ swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
+ }
+ global::System.GC.SuppressFinalize(this);
+ }
+ }
+
+ public string name {
+ set {
+ freeswitchPINVOKE.switch_log_json_format_item_t_name_set(swigCPtr, value);
+ }
+ get {
+ string ret = freeswitchPINVOKE.switch_log_json_format_item_t_name_get(swigCPtr);
+ return ret;
+ }
+ }
+
+ public string value {
+ set {
+ freeswitchPINVOKE.switch_log_json_format_item_t_value_set(swigCPtr, value);
+ }
+ get {
+ string ret = freeswitchPINVOKE.switch_log_json_format_item_t_value_get(swigCPtr);
+ return ret;
+ }
+ }
+
+ public switch_log_json_format_item_t() : this(freeswitchPINVOKE.new_switch_log_json_format_item_t(), true) {
+ }
+
+}
+
+}
+//------------------------------------------------------------------------------
+// <auto-generated />
+//
+// This file was automatically generated by SWIG (http://www.swig.org).
+// Version 3.0.10
+//
+// Do not make changes to this file unless you know what you are doing--modify
+// the SWIG interface file instead.
+//------------------------------------------------------------------------------
+
+namespace FreeSWITCH.Native {
+
+public class switch_log_json_format_t : global::System.IDisposable {
+ private global::System.Runtime.InteropServices.HandleRef swigCPtr;
+ protected bool swigCMemOwn;
+
+ internal switch_log_json_format_t(global::System.IntPtr cPtr, bool cMemoryOwn) {
+ swigCMemOwn = cMemoryOwn;
+ swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
+ }
+
+ internal static global::System.Runtime.InteropServices.HandleRef getCPtr(switch_log_json_format_t obj) {
+ return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
+ }
+
+ ~switch_log_json_format_t() {
+ Dispose();
+ }
+
+ public virtual void Dispose() {
+ lock(this) {
+ if (swigCPtr.Handle != global::System.IntPtr.Zero) {
+ if (swigCMemOwn) {
+ swigCMemOwn = false;
+ freeswitchPINVOKE.delete_switch_log_json_format_t(swigCPtr);
+ }
+ swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
+ }
+ global::System.GC.SuppressFinalize(this);
+ }
+ }
+
+ public switch_log_json_format_item_t version {
+ set {
+ freeswitchPINVOKE.switch_log_json_format_t_version_set(swigCPtr, switch_log_json_format_item_t.getCPtr(value));
+ }
+ get {
+ global::System.IntPtr cPtr = freeswitchPINVOKE.switch_log_json_format_t_version_get(swigCPtr);
+ switch_log_json_format_item_t ret = (cPtr == global::System.IntPtr.Zero) ? null : new switch_log_json_format_item_t(cPtr, false);
+ return ret;
+ }
+ }
+
+ public switch_log_json_format_item_t host {
+ set {
+ freeswitchPINVOKE.switch_log_json_format_t_host_set(swigCPtr, switch_log_json_format_item_t.getCPtr(value));
+ }
+ get {
+ global::System.IntPtr cPtr = freeswitchPINVOKE.switch_log_json_format_t_host_get(swigCPtr);
+ switch_log_json_format_item_t ret = (cPtr == global::System.IntPtr.Zero) ? null : new switch_log_json_format_item_t(cPtr, false);
+ return ret;
+ }
+ }
+
+ public switch_log_json_format_item_t timestamp {
+ set {
+ freeswitchPINVOKE.switch_log_json_format_t_timestamp_set(swigCPtr, switch_log_json_format_item_t.getCPtr(value));
+ }
+ get {
+ global::System.IntPtr cPtr = freeswitchPINVOKE.switch_log_json_format_t_timestamp_get(swigCPtr);
+ switch_log_json_format_item_t ret = (cPtr == global::System.IntPtr.Zero) ? null : new switch_log_json_format_item_t(cPtr, false);
+ return ret;
+ }
+ }
+
+ public switch_log_json_format_item_t level {
+ set {
+ freeswitchPINVOKE.switch_log_json_format_t_level_set(swigCPtr, switch_log_json_format_item_t.getCPtr(value));
+ }
+ get {
+ global::System.IntPtr cPtr = freeswitchPINVOKE.switch_log_json_format_t_level_get(swigCPtr);
+ switch_log_json_format_item_t ret = (cPtr == global::System.IntPtr.Zero) ? null : new switch_log_json_format_item_t(cPtr, false);
+ return ret;
+ }
+ }
+
+ public switch_log_json_format_item_t ident {
+ set {
+ freeswitchPINVOKE.switch_log_json_format_t_ident_set(swigCPtr, switch_log_json_format_item_t.getCPtr(value));
+ }
+ get {
+ global::System.IntPtr cPtr = freeswitchPINVOKE.switch_log_json_format_t_ident_get(swigCPtr);
+ switch_log_json_format_item_t ret = (cPtr == global::System.IntPtr.Zero) ? null : new switch_log_json_format_item_t(cPtr, false);
+ return ret;
+ }
+ }
+
+ public switch_log_json_format_item_t pid {
+ set {
+ freeswitchPINVOKE.switch_log_json_format_t_pid_set(swigCPtr, switch_log_json_format_item_t.getCPtr(value));
+ }
+ get {
+ global::System.IntPtr cPtr = freeswitchPINVOKE.switch_log_json_format_t_pid_get(swigCPtr);
+ switch_log_json_format_item_t ret = (cPtr == global::System.IntPtr.Zero) ? null : new switch_log_json_format_item_t(cPtr, false);
+ return ret;
+ }
+ }
+
+ public switch_log_json_format_item_t uuid {
+ set {
+ freeswitchPINVOKE.switch_log_json_format_t_uuid_set(swigCPtr, switch_log_json_format_item_t.getCPtr(value));
+ }
+ get {
+ global::System.IntPtr cPtr = freeswitchPINVOKE.switch_log_json_format_t_uuid_get(swigCPtr);
+ switch_log_json_format_item_t ret = (cPtr == global::System.IntPtr.Zero) ? null : new switch_log_json_format_item_t(cPtr, false);
+ return ret;
+ }
+ }
+
+ public switch_log_json_format_item_t file {
+ set {
+ freeswitchPINVOKE.switch_log_json_format_t_file_set(swigCPtr, switch_log_json_format_item_t.getCPtr(value));
+ }
+ get {
+ global::System.IntPtr cPtr = freeswitchPINVOKE.switch_log_json_format_t_file_get(swigCPtr);
+ switch_log_json_format_item_t ret = (cPtr == global::System.IntPtr.Zero) ? null : new switch_log_json_format_item_t(cPtr, false);
+ return ret;
+ }
+ }
+
+ public switch_log_json_format_item_t line {
+ set {
+ freeswitchPINVOKE.switch_log_json_format_t_line_set(swigCPtr, switch_log_json_format_item_t.getCPtr(value));
+ }
+ get {
+ global::System.IntPtr cPtr = freeswitchPINVOKE.switch_log_json_format_t_line_get(swigCPtr);
+ switch_log_json_format_item_t ret = (cPtr == global::System.IntPtr.Zero) ? null : new switch_log_json_format_item_t(cPtr, false);
+ return ret;
+ }
+ }
+
+ public switch_log_json_format_item_t function {
+ set {
+ freeswitchPINVOKE.switch_log_json_format_t_function_set(swigCPtr, switch_log_json_format_item_t.getCPtr(value));
+ }
+ get {
+ global::System.IntPtr cPtr = freeswitchPINVOKE.switch_log_json_format_t_function_get(swigCPtr);
+ switch_log_json_format_item_t ret = (cPtr == global::System.IntPtr.Zero) ? null : new switch_log_json_format_item_t(cPtr, false);
+ return ret;
+ }
+ }
+
+ public switch_log_json_format_item_t full_message {
+ set {
+ freeswitchPINVOKE.switch_log_json_format_t_full_message_set(swigCPtr, switch_log_json_format_item_t.getCPtr(value));
+ }
+ get {
+ global::System.IntPtr cPtr = freeswitchPINVOKE.switch_log_json_format_t_full_message_get(swigCPtr);
+ switch_log_json_format_item_t ret = (cPtr == global::System.IntPtr.Zero) ? null : new switch_log_json_format_item_t(cPtr, false);
+ return ret;
+ }
+ }
+
+ public switch_log_json_format_item_t short_message {
+ set {
+ freeswitchPINVOKE.switch_log_json_format_t_short_message_set(swigCPtr, switch_log_json_format_item_t.getCPtr(value));
+ }
+ get {
+ global::System.IntPtr cPtr = freeswitchPINVOKE.switch_log_json_format_t_short_message_get(swigCPtr);
+ switch_log_json_format_item_t ret = (cPtr == global::System.IntPtr.Zero) ? null : new switch_log_json_format_item_t(cPtr, false);
+ return ret;
+ }
+ }
+
+ public string custom_field_prefix {
+ set {
+ freeswitchPINVOKE.switch_log_json_format_t_custom_field_prefix_set(swigCPtr, value);
+ }
+ get {
+ string ret = freeswitchPINVOKE.switch_log_json_format_t_custom_field_prefix_get(swigCPtr);
+ return ret;
+ }
+ }
+
+ public double timestamp_divisor {
+ set {
+ freeswitchPINVOKE.switch_log_json_format_t_timestamp_divisor_set(swigCPtr, value);
+ }
+ get {
+ double ret = freeswitchPINVOKE.switch_log_json_format_t_timestamp_divisor_get(swigCPtr);
+ return ret;
+ }
+ }
+
+ public switch_log_json_format_t() : this(freeswitchPINVOKE.new_switch_log_json_format_t(), true) {
+ }
+
+}
+
+}
+//------------------------------------------------------------------------------
+// <auto-generated />
+//
+// This file was automatically generated by SWIG (http://www.swig.org).
+// Version 3.0.10
+//
+// Do not make changes to this file unless you know what you are doing--modify
+// the SWIG interface file instead.
+//------------------------------------------------------------------------------
+
+namespace FreeSWITCH.Native {
+
public enum switch_log_level_t {
SWITCH_LOG_DEBUG10 = 110,
SWITCH_LOG_DEBUG9 = 109,
if (!r) {
for (dbh_ptr = sql_manager.handle_pool; dbh_ptr; dbh_ptr = dbh_ptr->next) {
- if (dbh_ptr->hash == hash && ((dbh_ptr->type != SCDB_TYPE_PGSQL && dbh_ptr->type != SCDB_TYPE_DATABASE_INTERFACE) || !dbh_ptr->use_count) && !switch_test_flag(dbh_ptr, CDF_PRUNE) &&
+ if (dbh_ptr->hash == hash && (dbh_ptr->type != SCDB_TYPE_DATABASE_INTERFACE || !dbh_ptr->use_count) && !switch_test_flag(dbh_ptr, CDF_PRUNE) &&
switch_mutex_trylock(dbh_ptr->mutex) == SWITCH_STATUS_SUCCESS) {
r = dbh_ptr;
break;
database_interface->handle_destroy(&dbh->native_handle.database_interface_dbh);
}
break;
- case SCDB_TYPE_PGSQL:
- {
- switch_pgsql_handle_destroy(&dbh->native_handle.pgsql_dbh);
- }
- break;
case SCDB_TYPE_ODBC:
{
switch_odbc_handle_destroy(&dbh->native_handle.odbc_dbh);
database_interface->flush((*dbh)->native_handle.database_interface_dbh);
}
break;
- case SCDB_TYPE_PGSQL:
- {
- switch_pgsql_flush((*dbh)->native_handle.pgsql_dbh);
- }
- break;
default:
break;
}
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#endif
-SWITCH_DECLARE(switch_status_t) switch_core_check_core_db_dsn(void)
+SWITCH_DECLARE(switch_status_t) switch_database_available(char* dsn)
{
switch_status_t status = SWITCH_STATUS_FALSE;
switch_database_interface_t *database_interface;
- if (!runtime.odbc_dsn) {
+ if (!dsn) {
status = SWITCH_STATUS_SUCCESS;
- } else {
+ }
+ else {
char *colon_slashes = NULL;
- if (NULL != (colon_slashes = strstr(runtime.odbc_dsn, "://")))
+ if (NULL != (colon_slashes = strstr(dsn, "://")))
{
char prefix[16] = "";
- strncpy(prefix, runtime.odbc_dsn, MIN(colon_slashes - runtime.odbc_dsn, 15));
+ strncpy(prefix, dsn, MIN(colon_slashes - dsn, 15));
if (!strncasecmp(prefix, "odbc", 4)) {
if (switch_odbc_available()) status = SWITCH_STATUS_SUCCESS;
else if (!strncasecmp(prefix, "sqlite", 6)) {
status = SWITCH_STATUS_SUCCESS;
}
- else if (!strncasecmp(prefix, "pgsql", 5)) {
- if (switch_pgsql_available()) status = SWITCH_STATUS_SUCCESS;
- }
else if ((database_interface = switch_loadable_module_get_database_interface(prefix, NULL))) {
status = SWITCH_STATUS_SUCCESS;
UNPROTECT_INTERFACE(database_interface);
}
}
- else if (strchr(runtime.odbc_dsn + 2, ':')) {
+ else if (strchr(dsn + 2, ':')) {
status = SWITCH_STATUS_SUCCESS;
}
}
return status;
}
+SWITCH_DECLARE(switch_status_t) switch_core_check_core_db_dsn(void)
+{
+ return switch_database_available(runtime.odbc_dsn);
+}
+
SWITCH_DECLARE(switch_status_t) _switch_cache_db_get_db_handle_dsn(switch_cache_db_handle_t **dbh, const char *dsn,
const char *file, const char *func, int line)
{
type = SCDB_TYPE_DATABASE_INTERFACE;
connection_options.database_interface_options.make_module_no_unloadable = make_module_no_unloadable;
connection_options.database_interface_options.database_interface = database_interface;
- connection_options.database_interface_options.dsn = colon_slashes + 3;
+ connection_options.database_interface_options.original_dsn = dsn;
+ connection_options.database_interface_options.connection_string = colon_slashes + 3;
strcpy(connection_options.database_interface_options.prefix, prefix);
UNPROTECT_INTERFACE(database_interface);
}
}
- if (!connection_options.database_interface_options.dsn)
- {
- if (!strncasecmp(dsn, "pgsql://", 8)) {
- type = SCDB_TYPE_PGSQL;
- connection_options.pgsql_options.dsn = (char *)(dsn + 8);
- }
- else if (!strncasecmp(dsn, "sqlite://", 9)) {
+ if (!connection_options.database_interface_options.connection_string)
+ {
+ if (!strncasecmp(dsn, "sqlite://", 9)) {
type = SCDB_TYPE_CORE_DB;
connection_options.core_db_options.db_path = (char *)(dsn + 9);
}
switch (type) {
case SCDB_TYPE_DATABASE_INTERFACE:
{
- db_name = connection_options->database_interface_options.dsn;
+ db_name = connection_options->database_interface_options.connection_string;
odbc_user = NULL;
odbc_pass = NULL;
db_type = "database_interface";
}
break;
- case SCDB_TYPE_PGSQL:
- {
- db_name = connection_options->pgsql_options.dsn;
- odbc_user = NULL;
- odbc_pass = NULL;
- db_type = "pgsql";
- }
- break;
case SCDB_TYPE_ODBC:
{
db_name = connection_options->odbc_options.dsn;
} else {
switch_core_db_t *db = NULL;
switch_odbc_handle_t *odbc_dbh = NULL;
- switch_pgsql_handle_t *pgsql_dbh = NULL;
switch_database_interface_handle_t *database_interface_dbh = NULL;
switch (type) {
{
switch_database_interface_t *database_interface = connection_options->database_interface_options.database_interface;
- if (SWITCH_STATUS_SUCCESS != database_interface->handle_new(connection_options->database_interface_options.dsn, &database_interface_dbh)) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Failure! Can't create new handle! Can't connect to DSN %s\n", connection_options->database_interface_options.dsn);
+ if (SWITCH_STATUS_SUCCESS != database_interface->handle_new(connection_options->database_interface_options, &database_interface_dbh)) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Failure! Can't create new handle! Can't connect to DSN %s\n", connection_options->database_interface_options.original_dsn);
goto end;
}
}
}
break;
- case SCDB_TYPE_PGSQL:
- {
- if (!switch_pgsql_available()) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Failure! PGSQL NOT AVAILABLE! Can't connect to DSN %s\n", connection_options->pgsql_options.dsn);
- goto end;
- }
-
- if ((pgsql_dbh = switch_pgsql_handle_new(connection_options->pgsql_options.dsn))) {
- if (switch_pgsql_handle_connect(pgsql_dbh) != SWITCH_PGSQL_SUCCESS) {
- switch_pgsql_handle_destroy(&pgsql_dbh);
- }
- }
- }
- break;
case SCDB_TYPE_ODBC:
{
if (!switch_odbc_available()) {
goto end;
}
- if (!db && !odbc_dbh && !pgsql_dbh && !database_interface_dbh) {
+ if (!db && !odbc_dbh && !database_interface_dbh) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Failure to connect to %s %s!\n", switch_cache_db_type_name(type), db_name);
goto end;
}
new_dbh->native_handle.core_db_dbh = db;
} else if (odbc_dbh) {
new_dbh->native_handle.odbc_dbh = odbc_dbh;
- } else {
- new_dbh->native_handle.pgsql_dbh = pgsql_dbh;
}
add_handle(new_dbh, db_str, db_callsite_str, thread_str);
status = database_interface_handle_exec(database_interface, dbh->native_handle.database_interface_dbh, sql, &errmsg);
}
break;
- case SCDB_TYPE_PGSQL:
- {
- type = "PGSQL";
- status = switch_pgsql_handle_exec(dbh->native_handle.pgsql_dbh, sql, &errmsg);
- }
- break;
case SCDB_TYPE_ODBC:
{
type = "ODBC";
database_interface->affected_rows(dbh->native_handle.database_interface_dbh, &affected_rows);
}
break;
- case SCDB_TYPE_PGSQL:
- {
- return switch_pgsql_handle_affected_rows(dbh->native_handle.pgsql_dbh);
- }
- break;
}
return 0;
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "load extension not supported by type DATABASE_INTERFACE!\n");
}
break;
- case SCDB_TYPE_PGSQL:
- {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "load extension not supported by type PGSQL!\n");
- }
- break;
}
return 0;
}
status = database_interface->exec_string(dbh->native_handle.database_interface_dbh, sql, str, len, err);
}
break;
- case SCDB_TYPE_PGSQL:
- {
- status = switch_pgsql_handle_exec_string(dbh->native_handle.pgsql_dbh, sql, str, len, err);
- }
- break;
}
end:
}
}
break;
- case SCDB_TYPE_PGSQL:
- {
- switch_pgsql_status_t result;
-
- if ((result = switch_pgsql_SQLSetAutoCommitAttr(dbh->native_handle.pgsql_dbh, 0)) != SWITCH_PGSQL_SUCCESS) {
- char tmp[100];
- switch_snprintfv(tmp, sizeof(tmp), "%q-%i", "Unable to Set AutoCommit Off", result);
- errmsg = strdup(tmp);
- }
- }
- break;
}
if (errmsg) {
}
}
break;
- case SCDB_TYPE_PGSQL:
- {
- switch_pgsql_SQLEndTran(dbh->native_handle.pgsql_dbh, 1);
- switch_pgsql_SQLSetAutoCommitAttr(dbh->native_handle.pgsql_dbh, 1);
- switch_pgsql_finish_results(dbh->native_handle.pgsql_dbh);
- }
- break;
}
goto again;
}
}
break;
- case SCDB_TYPE_PGSQL:
- {
- switch_pgsql_SQLEndTran(dbh->native_handle.pgsql_dbh, 1);
- switch_pgsql_SQLSetAutoCommitAttr(dbh->native_handle.pgsql_dbh, 1);
- switch_pgsql_finish_results(dbh->native_handle.pgsql_dbh);
- }
- break;
}
if (!zstr(post_trans_execute)) {
}
}
break;
- case SCDB_TYPE_PGSQL:
- {
- status = switch_pgsql_handle_callback_exec(dbh->native_handle.pgsql_dbh, sql, helper_callback, &h, err);
- }
- break;
case SCDB_TYPE_ODBC:
{
status = switch_odbc_handle_callback_exec(dbh->native_handle.odbc_dbh, sql, helper_callback, &h, err);
}
}
break;
- case SCDB_TYPE_PGSQL:
- {
- status = switch_pgsql_handle_callback_exec(dbh->native_handle.pgsql_dbh, sql, helper_callback, &h, err);
- if (err && *err) {
- (*err_callback)(pdata, (const char*)*err);
- }
- }
- break;
case SCDB_TYPE_ODBC:
{
status = switch_odbc_handle_callback_exec(dbh->native_handle.odbc_dbh, sql, helper_callback, &h, err);
}
}
break;
- case SCDB_TYPE_PGSQL:
- {
- status = switch_pgsql_handle_callback_exec(dbh->native_handle.pgsql_dbh, sql, callback, pdata, err);
- }
- break;
case SCDB_TYPE_ODBC:
{
status = switch_odbc_handle_callback_exec(dbh->native_handle.odbc_dbh, sql, callback, pdata, err);
}
}
break;
- case SCDB_TYPE_PGSQL:
- {
- status = switch_pgsql_handle_callback_exec(dbh->native_handle.pgsql_dbh, sql, callback, pdata, err);
- if (err && *err) {
- (*err_callback)(pdata, (const char*)*err);
- }
- }
- break;
case SCDB_TYPE_ODBC:
{
status = switch_odbc_handle_callback_exec(dbh->native_handle.odbc_dbh, sql, callback, pdata, err);
}
}
break;
- case SCDB_TYPE_PGSQL:
- {
- if (switch_pgsql_handle_exec(dbh->native_handle.pgsql_dbh, test_sql, NULL) != SWITCH_PGSQL_SUCCESS) {
- if (drop_sql) {
- switch_pgsql_handle_exec(dbh->native_handle.pgsql_dbh, drop_sql, NULL);
- }
- r = switch_pgsql_handle_exec(dbh->native_handle.pgsql_dbh, reactive_sql, NULL) == SWITCH_PGSQL_SUCCESS;
- }
- }
- break;
case SCDB_TYPE_ODBC:
{
if (switch_odbc_handle_exec(dbh->native_handle.odbc_dbh, test_sql, NULL, NULL) != SWITCH_ODBC_SUCCESS) {
}
}
break;
- case SCDB_TYPE_PGSQL:
- {
- switch_pgsql_status_t result;
-
- if ((result = switch_pgsql_SQLSetAutoCommitAttr(qm->event_db->native_handle.pgsql_dbh, 0)) != SWITCH_PGSQL_SUCCESS) {
- char tmp[100];
- switch_snprintfv(tmp, sizeof(tmp), "%q-%i", "Unable to Set AutoCommit Off", result);
- errmsg = strdup(tmp);
- }
- }
- break;
}
if (errmsg) {
}
}
break;
- case SCDB_TYPE_PGSQL:
- {
- switch_pgsql_SQLEndTran(qm->event_db->native_handle.pgsql_dbh, 1);
- switch_pgsql_SQLSetAutoCommitAttr(qm->event_db->native_handle.pgsql_dbh, 1);
- switch_pgsql_finish_results(qm->event_db->native_handle.pgsql_dbh);
- }
- break;
}
switch (qm->event_db->type) {
case SCDB_TYPE_DATABASE_INTERFACE:
break;
- case SCDB_TYPE_PGSQL:
- break;
case SCDB_TYPE_ODBC:
break;
case SCDB_TYPE_CORE_DB:
switch (sql_manager.dbh->type) {
case SCDB_TYPE_DATABASE_INTERFACE:
- case SCDB_TYPE_PGSQL:
case SCDB_TYPE_ODBC:
if (switch_test_flag((&runtime), SCF_CLEAR_SQL)) {
char sql[512] = "";
switch (sql_manager.dbh->type) {
case SCDB_TYPE_DATABASE_INTERFACE:
- case SCDB_TYPE_PGSQL:
case SCDB_TYPE_ODBC:
{
char *err;
}
}
break;
- case SCDB_TYPE_PGSQL:
- {
- switch_pgsql_status_t result;
-
- if ((result = switch_pgsql_SQLSetAutoCommitAttr(sql_manager.dbh->native_handle.pgsql_dbh, 0)) != SWITCH_PGSQL_SUCCESS) {
- char tmp[100];
- switch_snprintfv(tmp, sizeof(tmp), "%q-%i", "Unable to Set AutoCommit Off", result);
- err = strdup(tmp);
- }
- }
- break;
}
switch_cache_db_execute_sql(sql_manager.dbh, "delete from channels where hostname=''", &err);
}
}
break;
- case SCDB_TYPE_PGSQL:
- {
- if (switch_pgsql_SQLEndTran(sql_manager.dbh->native_handle.pgsql_dbh, 1) != SWITCH_PGSQL_SUCCESS ||
- switch_pgsql_SQLSetAutoCommitAttr(sql_manager.dbh->native_handle.pgsql_dbh, 1) != SWITCH_PGSQL_SUCCESS ||
- switch_pgsql_finish_results(sql_manager.dbh->native_handle.pgsql_dbh) != SWITCH_PGSQL_SUCCESS) {
- char tmp[100];
- switch_snprintfv(tmp, sizeof(tmp), "%q-%i", "Unable to commit transaction.", result);
- err = strdup(tmp);
- }
- }
- break;
}
}
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<Import Project="$(SolutionDir)\w32\switch_version.props" Condition=" '$(switch_versionPropsImported)' == '' " />
- <Import Project="$(SolutionDir)\w32\libpq.props" Condition=" '$(libpqPropsImported)' == '' " />
<Import Project="$(SolutionDir)\w32\openssl.props" Condition=" '$(OpensslPropsImported)' == '' " />
<Import Project="$(SolutionDir)\w32\curl.props" Condition=" '$(CurlPropsImported)' == '' " />
<Import Project="$(SolutionDir)\w32\pcre.props" Condition=" '$(pcrePropsImported)' == '' " />
<DisableSpecificWarnings Condition="'$(Configuration)|$(Platform)'=='Release|x64'">4389;4127;%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<ClCompile Include="..\..\src\switch_odbc.c" />
- <ClCompile Include="..\..\src\switch_pgsql.c" />
<ClCompile Include="..\..\src\switch_pcm.c" />
<ClCompile Include="..\..\src\switch_speex.c" />
<ClCompile Include="..\..\src\switch_profile.c" />
<ClInclude Include="..\..\src\include\switch_module_interfaces.h" />
<ClInclude Include="..\..\src\include\switch_mprintf.h" />
<ClInclude Include="..\..\src\include\switch_odbc.h" />
- <ClInclude Include="..\..\src\include\switch_pgsql.h" />
<ClInclude Include="..\..\src\include\switch_platform.h" />
<ClInclude Include="..\..\src\include\switch_regex.h" />
<ClInclude Include="..\..\src\include\switch_resample.h" />
<RefProjectOutputGroups>Binaries;Content;Satellites</RefProjectOutputGroups>\r
<RefTargetDir>INSTALLFOLDER</RefTargetDir>\r
</ProjectReference>\r
+ <ProjectReference Include="..\..\src\mod\databases\mod_pgsql\mod_pgsql.2017.vcxproj">\r
+ <Name>mod_pgsql</Name>\r
+ <Project>{1ba65811-5453-46f6-8190-9eceefeb7df2}</Project>\r
+ <Private>True</Private>\r
+ <DoNotHarvest>True</DoNotHarvest>\r
+ <RefProjectOutputGroups>Binaries;Content;Satellites</RefProjectOutputGroups>\r
+ <RefTargetDir>INSTALLFOLDER</RefTargetDir>\r
+ </ProjectReference>\r
<ProjectReference Include="..\..\src\mod\dialplans\mod_dialplan_asterisk\mod_dialplan_asterisk.2017.vcxproj">\r
<Name>mod_dialplan_asterisk</Name>\r
<Project>{e7bc026c-7cc5-45a3-bc7c-3b88eef01f24}</Project>\r