File capi20_fixes.diff of Package i4l-base
Index: isdn4k-utils/capi20/Makefile.am
===================================================================
--- isdn4k-utils.orig/capi20/Makefile.am
+++ isdn4k-utils/capi20/Makefile.am
@@ -10,7 +10,7 @@ lib_LTLIBRARIES = libcapi20.la
lib_LIBRARIES = libcapi20dyn.a
libcapi20_la_SOURCES = capi20.c capifunc.c convert.c
-libcapi20_la_LDFLAGS = -version-info ${LIBCAPI_VERSION}:${LIBCAPI_VERSION_RELEASE}:${LIBCAPI_VERSION_AGE} -lc -ldl
+libcapi20_la_LDFLAGS = -version-info ${LIBCAPI_VERSION}:${LIBCAPI_VERSION_RELEASE}:${LIBCAPI_VERSION_AGE} -lc -ldl -rdynamic
libcapi20_la_CFLAGS = -fno-strict-aliasing -DLIBDIR=\"$(libdir)/capi\"
modulesdir = $(libdir)/capi
Index: isdn4k-utils/capi20/capi20.c
===================================================================
--- isdn4k-utils.orig/capi20/capi20.c
+++ isdn4k-utils/capi20/capi20.c
@@ -140,6 +140,21 @@ unsigned char *put_word( unsigned char *
}
/**
+ * \brief Put dword to data buffer and increase buffer pointer
+ * \param ppnPtr data buffer pointer
+ * \param nVal dword number
+ * \return word from buffer
+ */
+unsigned char *put_dword( unsigned char **ppnPtr, _cdword nVal ) {
+ put_byte( ppnPtr, nVal & 0xFF );
+ put_byte( ppnPtr, ( nVal & 0xFF00 ) >> 8 );
+ put_byte( ppnPtr, ( nVal & 0xFF0000 ) >> 16 );
+ put_byte( ppnPtr, ( nVal & 0xFF000000 ) >> 24 );
+
+ return *ppnPtr;
+}
+
+/**
* \brief Put netword to data buffer and increase buffer pointer
* \param ppnPtr data buffer pointer
* \param nVal netword number
@@ -523,7 +538,7 @@ static int LoadModule( char *pnName ) {
InitModule initModule;
/* Try to open module */
- pHandle = dlopen( pnName, RTLD_LAZY );
+ pHandle = dlopen( pnName, RTLD_LAZY | RTLD_GLOBAL);
if ( pHandle == NULL ) {
Debug( 1, "Could not open module!\n" );
return -1;
@@ -636,32 +651,51 @@ unsigned capi20_isinstalled( void ) {
/* read configuration file */
read_config();
- /* no special driver requested, set default to 'standard' */
+ /* no special driver requested, auto-detect */
if ( strlen( driver ) <= 0 ) {
- snprintf( driver, sizeof( driver ), "standard" );
- }
-
- /* Find requested driver in list */
- psList = psModuleList;
- while ( psList != NULL ) {
- if ( !strcasecmp( psList -> psMod -> pnName, driver ) ) {
- psModule = psList -> psMod;
- break;
+ /* backwards-compatible: check standard interface fist */
+ psList = psModuleList;
+ while ( psList != NULL ) {
+
+ if ( !strcasecmp( psList -> psMod -> pnName, "standard" ) ) {
+ psModule = psList -> psMod;
+ capi_fd = psModule -> psOperations -> IsInstalled();
+ if ( capi_fd >= 0 ) {
+ /* no error */
+ return CapiNoError;
+ }
+ }
+ psList = psList -> psNext;
}
- psList = psList -> psNext;
- }
-
- /* if no module is selected, abort */
- if ( psModule == NULL ) {
- return CapiRegNotInstalled;
- }
-
- /* check if we have a capi interface and return file handle */
- capi_fd = psModule -> psOperations -> IsInstalled();
- if ( capi_fd >= 0 ) {
- /* no error */
- return CapiNoError;
+ /* no standard device detect, try the other modules */
+ psList = psModuleList;
+ while ( psList != NULL ) {
+ if ( strcasecmp( psList -> psMod -> pnName, "standard" ) ) {
+ psModule = psList -> psMod;
+ capi_fd = psModule -> psOperations -> IsInstalled();
+ if ( capi_fd >= 0 ) {
+ /* no error */
+ return CapiNoError;
+ }
+ }
+ psList = psList -> psNext;
+ }
+ } else {
+ /* Find requested driver in list */
+ psList = psModuleList;
+ while ( psList != NULL ) {
+ if ( !strcasecmp( psList -> psMod -> pnName, driver ) ) {
+ psModule = psList -> psMod;
+ capi_fd = psModule -> psOperations -> IsInstalled();
+ if ( capi_fd >= 0 ) {
+ /* no error */
+ return CapiNoError;
+ }
+ break;
+ }
+ psList = psList -> psNext;
+ }
}
/* uhh, not installed */
Index: isdn4k-utils/capi20/capi_mod.h
===================================================================
--- isdn4k-utils.orig/capi20/capi_mod.h
+++ isdn4k-utils/capi20/capi_mod.h
@@ -32,6 +32,7 @@ char *getHostName( void );
int getPort( void );
char *getTraceFile( void );
int getTraceLevel( void );
+unsigned char *get_buffer( unsigned applid, size_t *sizep, unsigned *handle );
#define MODULE_LOADER_VERSION 0x01
Index: isdn4k-utils/capi20/capi_mod_fritzbox.c
===================================================================
--- isdn4k-utils.orig/capi20/capi_mod_fritzbox.c
+++ isdn4k-utils/capi20/capi_mod_fritzbox.c
@@ -115,7 +115,7 @@ static int fritzboxOpenSocket( void ) {
/* no errors, return handle */
return nHandle;
}
- Debug( 1, "[%s]: Could not connect to port %d on '%s'", __FUNCTION__, getPort(), getHostName() );
+ Debug( 1, "[%s]: Could not connect to port %d on '%s'. CapiOverTCP enabled??", __FUNCTION__, getPort(), getHostName() );
} else {
Debug( 1, "[%s]: Could not resolve host '%s'", __FUNCTION__, getHostName() );
}
@@ -531,7 +531,7 @@ static unsigned fritzboxGetProfile( int
}
/** Module operations structure */
-struct sModuleOperations sFritzBox = {
+static struct sModuleOperations sFritzBox = {
fritzboxIsInstalled,
fritzboxRegister,
fritzboxRelease,
Index: isdn4k-utils/capi20/capi_mod_rcapi.c
===================================================================
--- isdn4k-utils.orig/capi20/capi_mod_rcapi.c
+++ isdn4k-utils/capi20/capi_mod_rcapi.c
@@ -479,7 +479,7 @@ static unsigned rcapiGetProfile( int nHa
}
/** Module operations structure */
-struct sModuleOperations sRemoteCapi = {
+static struct sModuleOperations sRemoteCapi = {
rcapiIsInstalled,
rcapiRegister,
NULL,
Index: isdn4k-utils/capi20/capi_mod_std.c
===================================================================
--- isdn4k-utils.orig/capi20/capi_mod_std.c
+++ isdn4k-utils/capi20/capi_mod_std.c
@@ -21,8 +21,9 @@
#include "capi20.h"
#include "capi_mod.h"
-static char capidevname[] = "/dev/capi20";
-static char capidevnamenew[] = "/dev/isdn/capi20";
+#define CAPI_DEVICE_NAME "/dev/capi20"
+#define CAPI_DEVICE_NAME_NEW "/dev/isdn/capi20"
+
static capi_ioctl_struct ioctl_data;
/**
@@ -32,8 +33,8 @@ static capi_ioctl_struct ioctl_data;
static unsigned standardIsInstalled( void ) {
int nHandle;
- if ( ( nHandle = open( capidevname, O_RDWR, 0666 ) ) < 0 && ( errno == ENOENT ) ) {
- nHandle = open( capidevnamenew, O_RDWR, 0666 );
+ if ( ( nHandle = open( CAPI_DEVICE_NAME, O_RDWR, 0666 ) ) < 0 && ( errno == ENOENT ) ) {
+ nHandle = open( CAPI_DEVICE_NAME_NEW, O_RDWR, 0666 );
}
if ( nHandle >= 0 ) {
@@ -59,8 +60,8 @@ static unsigned standardRegister( unsign
int nIndex;
int nHandle;
- if ( ( nHandle = open( capidevname, O_RDWR | O_NONBLOCK, 0666 ) ) < 0 && ( errno == ENOENT ) ) {
- nHandle = open( capidevnamenew, O_RDWR | O_NONBLOCK, 0666 );
+ if ( ( nHandle = open( CAPI_DEVICE_NAME, O_RDWR | O_NONBLOCK, 0666 ) ) < 0 && ( errno == ENOENT ) ) {
+ nHandle = open( CAPI_DEVICE_NAME_NEW, O_RDWR | O_NONBLOCK, 0666 );
}
if (nHandle < 0) {
@@ -435,7 +436,7 @@ static int standardGetNcciOpenCount( uns
}
/** Module operations structure */
-struct sModuleOperations sStandard = {
+static struct sModuleOperations sStandard = {
standardIsInstalled,
standardRegister,
NULL,