ftmod_libpri: Add configure check for pri_maintenance_service()

Said function has been added in libpri-1.4.11 and breaks
building with older libpri versions (i.e. the passive one for ftmod_pritap).

Check for pri_maintenance_service() in configure and disable
the "maintenance" subcommand if it is not available.

Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
This commit is contained in:
Stefan Knoblich 2013-01-08 14:30:59 +01:00
parent 1e5beafe97
commit 88e75bf9d7
2 changed files with 20 additions and 0 deletions

View File

@ -283,6 +283,19 @@ then
AC_MSG_NOTICE([You will need libpri-1.4.12_beta1 or newer for AOC event support])] AC_MSG_NOTICE([You will need libpri-1.4.12_beta1 or newer for AOC event support])]
) )
AC_MSG_CHECKING([whether libpri has pri_maintenance_service()])
AC_LINK_IFELSE(
[AC_LANG_PROGRAM(
[extern int pri_maintenance_service(void);],
[pri_maintenance_service();]
)],
[AC_DEFINE([HAVE_LIBPRI_MAINT_SERVICE], [1], [libpri has pri_maintenance_service()])
AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])
AC_MSG_NOTICE([You will need libpri-1.4.11 or newer for the ftdm libpri maintenance set of commands])]
)
# libpri is available, set variables for Makefile(.am) # libpri is available, set variables for Makefile(.am)
AC_SUBST([LIBPRI_LIBS], [-lpri]) AC_SUBST([LIBPRI_LIBS], [-lpri])
AC_SUBST([LIBPRI_LDFLAGS]) AC_SUBST([LIBPRI_LDFLAGS])

View File

@ -207,6 +207,7 @@ static int parse_debug(const char *in, uint32_t *flags)
return res; return res;
} }
#ifdef HAVE_LIBPRI_MAINT_SERVICE
/** /**
* \brief Parses a change status string to flags * \brief Parses a change status string to flags
* \param in change status string to parse for * \param in change status string to parse for
@ -232,6 +233,8 @@ static int parse_change_status(const char *in)
return flags; return flags;
} }
#endif
static int print_debug(uint32_t flags, char *tmp, const int size) static int print_debug(uint32_t flags, char *tmp, const int size)
{ {
@ -441,7 +444,9 @@ static const char *ftdm_libpri_usage =
"libpri kill <span>\n" "libpri kill <span>\n"
"libpri reset <span>\n" "libpri reset <span>\n"
"libpri restart <span> <channel/all>\n" "libpri restart <span> <channel/all>\n"
#ifdef HAVE_LIBPRI_MAINT_SERVICE
"libpri maintenance <span> <channel/all> <in/maint/out>\n" "libpri maintenance <span> <channel/all> <in/maint/out>\n"
#endif
"libpri debug <span> [all|none|flag,...flagN]\n" "libpri debug <span> [all|none|flag,...flagN]\n"
"libpri msn <span>\n" "libpri msn <span>\n"
"\n" "\n"
@ -650,6 +655,7 @@ static FIO_API_FUNCTION(ftdm_libpri_api)
goto done; goto done;
} }
} }
#ifdef HAVE_LIBPRI_MAINT_SERVICE
if (!strcasecmp(argv[0], "maintenance") && argc > 3) { if (!strcasecmp(argv[0], "maintenance") && argc > 3) {
ftdm_span_t *span = NULL; ftdm_span_t *span = NULL;
if (ftdm_span_find_by_name(argv[1], &span) == FTDM_SUCCESS) { if (ftdm_span_find_by_name(argv[1], &span) == FTDM_SUCCESS) {
@ -681,6 +687,7 @@ static FIO_API_FUNCTION(ftdm_libpri_api)
goto done; goto done;
} }
} }
#endif
} else { } else {
/* zero args print usage */ /* zero args print usage */
stream->write_function(stream, ftdm_libpri_usage); stream->write_function(stream, ftdm_libpri_usage);