From 997550c5114e608852d33b0ab25fb32d75becf0b Mon Sep 17 00:00:00 2001
From: Stefan Knoblich <stkn@openisdn.net>
Date: Sat, 14 Apr 2012 01:39:25 +0200
Subject: [PATCH] ftmod_libpri: Check for required features in configure and
 remove old-style log callbacks

Non-PRI_NEW_SET_API logging callbacks were only available in libpri-1.0 and older,
which also lacks PRI_IO_FUNCS (required) and wouldn't work anyway.

Explicitly check for both PRI_* feature defines at configure time and reject libpri
versions that lack them.

Remove the non-PRI_NEW_SET_API logging callbacks in ftmod_libpri.c.

Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
---
 libs/freetdm/configure.ac                     | 15 ++++++++++++++
 .../src/ftmod/ftmod_libpri/ftmod_libpri.c     | 20 -------------------
 2 files changed, 15 insertions(+), 20 deletions(-)

diff --git a/libs/freetdm/configure.ac b/libs/freetdm/configure.ac
index d166233f00..a888d20ef4 100644
--- a/libs/freetdm/configure.ac
+++ b/libs/freetdm/configure.ac
@@ -236,6 +236,21 @@ then
 		 AC_MSG_ERROR([libpri not found or unusable (see config.log for details)])]
 	)
 
+	AC_MSG_CHECKING([whether libpri is too old])
+	AC_PREPROC_IFELSE(
+		[AC_LANG_PROGRAM(
+			[#include <libpri.h>],
+			[#if !defined(PRI_IO_FUNCS)
+			 #error "libpri is lacking PRI_IO_FUNCS"
+			 #elif !defined(PRI_NEW_SET_API)
+			 #error "libpri is lacking PRI_NEW_SET_API"
+			 #endif]
+		 )],
+		[AC_MSG_RESULT([no])],
+		[AC_MSG_RESULT([yes])
+		 AC_MSG_ERROR([Your version of libpri is too old (pre 1.2), please update!])]
+	)
+
 	AC_MSG_CHECKING([whether libpri has BRI support])
 	AC_LINK_IFELSE(
 		[AC_LANG_PROGRAM(
diff --git a/libs/freetdm/src/ftmod/ftmod_libpri/ftmod_libpri.c b/libs/freetdm/src/ftmod/ftmod_libpri/ftmod_libpri.c
index b8871cf70c..2e11f52f26 100644
--- a/libs/freetdm/src/ftmod/ftmod_libpri/ftmod_libpri.c
+++ b/libs/freetdm/src/ftmod/ftmod_libpri/ftmod_libpri.c
@@ -115,7 +115,6 @@ static FIO_CHANNEL_REQUEST_FUNCTION(isdn_channel_request)
 }
 
 
-#ifdef PRI_NEW_SET_API
 /**
  * \brief Logs a libpri message
  * \param pri	libpri structure
@@ -147,25 +146,6 @@ static void s_pri_error(struct pri *pri, char *s)
 		ftdm_log(FTDM_LOG_ERROR, "%s", s);
 	}
 }
-#else	/* !PRI_NEW_SET_API */
-/**
- * \brief Logs a libpri message
- * \param s	Message string
- */
-static void s_pri_message(char *s)
-{
-	ftdm_log(FTDM_LOG_DEBUG, "%s", s);
-}
-
-/**
- * \brief Logs a libpri error
- * \param s	Error string
- */
-static void s_pri_error(char *s)
-{
-	ftdm_log(FTDM_LOG_ERROR, "%s", s);
-}
-#endif
 
 
 #define PRI_DEBUG_Q921_ALL	(PRI_DEBUG_Q921_RAW | PRI_DEBUG_Q921_DUMP | PRI_DEBUG_Q921_STATE)