From f8180257e040e68b36ea87959598b55e46c15919 Mon Sep 17 00:00:00 2001 From: Tilghman Lesher Date: Fri, 24 Sep 2010 03:41:02 +0000 Subject: Merged revisions 288638 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.8 ................ r288638 | tilghman | 2010-09-23 22:39:29 -0500 (Thu, 23 Sep 2010) | 16 lines Merged revisions 288637 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.6.2 ................ r288637 | tilghman | 2010-09-23 22:36:01 -0500 (Thu, 23 Sep 2010) | 9 lines Merged revisions 288636 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r288636 | tilghman | 2010-09-23 22:20:24 -0500 (Thu, 23 Sep 2010) | 2 lines Solaris compatibility fixes ........ ................ ................ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@288639 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- cdr/cdr_pgsql.c | 8 ++++++ configure | 61 +++++++++++++++++++++++++++++++++++++++- configure.ac | 13 +++++++++ include/asterisk/autoconfig.h.in | 3 ++ include/asterisk/channel.h | 13 --------- include/asterisk/compat.h | 4 +++ main/strcompat.c | 13 +++++++++ 7 files changed, 101 insertions(+), 14 deletions(-) diff --git a/cdr/cdr_pgsql.c b/cdr/cdr_pgsql.c index ee5842d15..61bd4c8e5 100644 --- a/cdr/cdr_pgsql.c +++ b/cdr/cdr_pgsql.c @@ -111,7 +111,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); @@ -486,7 +490,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 72a740e1b..d51111d85 100755 --- a/configure +++ b/configure @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.ac Revision: 285163 . +# From configure.ac Revision: 285932 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.61 for asterisk trunk. # @@ -36517,6 +36517,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 +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 b1183031e..98fd5155a 100644 --- a/configure.ac +++ b/configure.ac @@ -1697,6 +1697,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 ], + [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 b715a89de..b438f4225 100644 --- a/include/asterisk/autoconfig.h.in +++ b/include/asterisk/autoconfig.h.in @@ -524,6 +524,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 ed842b6d7..d12d478d3 100644 --- a/include/asterisk/channel.h +++ b/include/asterisk/channel.h @@ -2242,19 +2242,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 22daeaef9..78c267105 100644 --- a/include/asterisk/compat.h +++ b/include/asterisk/compat.h @@ -133,6 +133,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 + #define strlcat __use__ast_str__functions_not__strlcat__ #define strlcpy __use__ast_copy_string__not__strlcpy__ diff --git a/main/strcompat.c b/main/strcompat.c index 923e935f7..831ab0ce9 100644 --- a/main/strcompat.c +++ b/main/strcompat.c @@ -169,6 +169,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. -- cgit v1.2.3