aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cdr/cdr_pgsql.c8
-rwxr-xr-xconfigure61
-rw-r--r--configure.ac13
-rw-r--r--include/asterisk/autoconfig.h.in3
-rw-r--r--include/asterisk/channel.h13
-rw-r--r--include/asterisk/compat.h4
-rw-r--r--main/strcompat.c13
7 files changed, 101 insertions, 14 deletions
diff --git a/cdr/cdr_pgsql.c b/cdr/cdr_pgsql.c
index 21370944f..f469bc520 100644
--- a/cdr/cdr_pgsql.c
+++ b/cdr/cdr_pgsql.c
@@ -113,7 +113,11 @@ static int pgsql_log(struct ast_cdr *cdr)
if (PQstatus(conn) != CONNECTION_BAD) {
connected = 1;
if (PQsetClientEncoding(conn, encoding)) {
+#ifdef HAVE_PGSQL_pg_encoding_to_char
ast_log(LOG_WARNING, "Failed to set encoding to '%s'. Encoding set to default '%s'\n", encoding, pg_encoding_to_char(PQclientEncoding(conn)));
+#else
+ ast_log(LOG_WARNING, "Failed to set encoding to '%s'. Encoding set to default.\n", encoding);
+#endif
}
} else {
pgerror = PQerrorMessage(conn);
@@ -489,7 +493,11 @@ static int config_module(int reload)
ast_debug(1, "Successfully connected to PostgreSQL database.\n");
connected = 1;
if (PQsetClientEncoding(conn, encoding)) {
+#ifdef HAVE_PGSQL_pg_encoding_to_char
ast_log(LOG_WARNING, "Failed to set encoding to '%s'. Encoding set to default '%s'\n", encoding, pg_encoding_to_char(PQclientEncoding(conn)));
+#else
+ ast_log(LOG_WARNING, "Failed to set encoding to '%s'. Encoding set to default.\n", encoding);
+#endif
}
version = PQserverVersion(conn);
diff --git a/configure b/configure
index 210efb4ce..8eb684886 100755
--- a/configure
+++ b/configure
@@ -1,5 +1,5 @@
#! /bin/sh
-# From configure.ac Revision: 284593 .
+# From configure.ac Revision: 285930 .
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.61 for asterisk 1.6.2.
#
@@ -32065,6 +32065,65 @@ _ACEOF
fi
+ { echo "$as_me:$LINENO: checking for pg_encoding_to_char within Postgres headers" >&5
+echo $ECHO_N "checking for pg_encoding_to_char within Postgres headers... $ECHO_C" >&6; }
+ old_CFLAGS=${CFLAGS}
+ CFLAGS="${CFLAGS} -I${PGSQL_includedir} -Werror"
+ old_LDFLAGS=${LDFLAGS}
+ LDFLAGS="${LDFLAGS} -L${PGSQL_libdir} -lpq -lz"
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <libpq-fe.h>
+int
+main ()
+{
+const char *foo = pg_encoding_to_char(1)
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_link") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest$ac_exeext &&
+ $as_test_x conftest$ac_exeext; then
+ { echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6; }
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_PGSQL_pg_encoding_to_char 1
+_ACEOF
+
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+ conftest$ac_exeext conftest.$ac_ext
+ CFLAGS=${old_CFLAGS}
+ LDFLAGS=${old_LDFLAGS}
+
if test "${ac_cv_lib_pq_PQescapeStringConn}" = "yes"; then
PGSQL_LIB="-L${PGSQL_libdir} -lpq -lz"
PGSQL_INCLUDE="-I${PGSQL_includedir}"
diff --git a/configure.ac b/configure.ac
index 0d18a4ac5..67ffe1ded 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1532,6 +1532,19 @@ if test "${PG_CONFIG}" != No; then
AC_CHECK_LIB([pq], [PQescapeStringConn], AC_DEFINE_UNQUOTED([HAVE_PGSQL], 1,
[Define to indicate the PostgreSQL library]), [], -L${PGSQL_libdir} -lz)
+ AC_MSG_CHECKING(for pg_encoding_to_char within Postgres headers)
+ old_CFLAGS=${CFLAGS}
+ CFLAGS="${CFLAGS} -I${PGSQL_includedir} -Werror"
+ old_LDFLAGS=${LDFLAGS}
+ LDFLAGS="${LDFLAGS} -L${PGSQL_libdir} -lpq -lz"
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <libpq-fe.h>],
+ [const char *foo = pg_encoding_to_char(1)])],
+ [AC_MSG_RESULT(yes)
+ AC_DEFINE_UNQUOTED([HAVE_PGSQL_pg_encoding_to_char], 1, [Define to indicate presence of the pg_encoding_to_char API.])],
+ [AC_MSG_RESULT(no)])
+ CFLAGS=${old_CFLAGS}
+ LDFLAGS=${old_LDFLAGS}
+
if test "${ac_cv_lib_pq_PQescapeStringConn}" = "yes"; then
PGSQL_LIB="-L${PGSQL_libdir} -lpq -lz"
PGSQL_INCLUDE="-I${PGSQL_includedir}"
diff --git a/include/asterisk/autoconfig.h.in b/include/asterisk/autoconfig.h.in
index c7252d34b..69dc48490 100644
--- a/include/asterisk/autoconfig.h.in
+++ b/include/asterisk/autoconfig.h.in
@@ -469,6 +469,9 @@
/* Define to indicate the PostgreSQL library */
#undef HAVE_PGSQL
+/* Define to indicate presence of the pg_encoding_to_char API. */
+#undef HAVE_PGSQL_pg_encoding_to_char
+
/* Define to 1 if your system defines IP_PKTINFO. */
#undef HAVE_PKTINFO
diff --git a/include/asterisk/channel.h b/include/asterisk/channel.h
index 9345a402d..88d1748c8 100644
--- a/include/asterisk/channel.h
+++ b/include/asterisk/channel.h
@@ -1747,19 +1747,6 @@ static inline int ast_fdisset(struct pollfd *pfds, int fd, int maximum, int *sta
return 0;
}
-#ifndef HAVE_TIMERSUB
-static inline void timersub(struct timeval *tvend, struct timeval *tvstart, struct timeval *tvdiff)
-{
- tvdiff->tv_sec = tvend->tv_sec - tvstart->tv_sec;
- tvdiff->tv_usec = tvend->tv_usec - tvstart->tv_usec;
- if (tvdiff->tv_usec < 0) {
- tvdiff->tv_sec --;
- tvdiff->tv_usec += 1000000;
- }
-
-}
-#endif
-
/*! \brief Retrieves the current T38 state of a channel */
static inline enum ast_t38_state ast_channel_get_t38_state(struct ast_channel *chan)
{
diff --git a/include/asterisk/compat.h b/include/asterisk/compat.h
index 519c71e68..365df66a1 100644
--- a/include/asterisk/compat.h
+++ b/include/asterisk/compat.h
@@ -113,6 +113,10 @@ int unsetenv(const char *name);
int __attribute__((format(printf, 2, 0))) vasprintf(char **strp, const char *fmt, va_list ap);
#endif
+#ifndef HAVE_TIMERSUB
+void timersub(struct timeval *tvend, struct timeval *tvstart, struct timeval *tvdiff);
+#endif
+
#ifndef HAVE_STRLCAT
size_t strlcat(char *dst, const char *src, size_t siz);
#endif
diff --git a/main/strcompat.c b/main/strcompat.c
index a3f0e1497..efd85c3bb 100644
--- a/main/strcompat.c
+++ b/main/strcompat.c
@@ -163,6 +163,19 @@ int vasprintf(char **strp, const char *fmt, va_list ap)
}
#endif /* !defined(HAVE_VASPRINTF) && !defined(__AST_DEBUG_MALLOC) */
+#ifndef HAVE_TIMERSUB
+void timersub(struct timeval *tvend, struct timeval *tvstart, struct timeval *tvdiff)
+{
+ tvdiff->tv_sec = tvend->tv_sec - tvstart->tv_sec;
+ tvdiff->tv_usec = tvend->tv_usec - tvstart->tv_usec;
+ if (tvdiff->tv_usec < 0) {
+ tvdiff->tv_sec --;
+ tvdiff->tv_usec += 1000000;
+ }
+
+}
+#endif
+
/*
* Based on Code from bsd-asprintf from OpenSSH
* Copyright (c) 2004 Darren Tucker.