Skip to content

Commit

Permalink
better handling of PCSCLITE_STATIC_DRIVER as can be used on plateforms
Browse files Browse the repository at this point in the history
using µClinux (without dynamic loader)

Thanks to Guo Wenxue for a proto-patch


git-svn-id: svn:https://anonscm.debian.org/svn/pcsclite/trunk/PCSC@4629 0ce88b0d-b2fd-0310-8134-9614164e65ea
  • Loading branch information
LudovicRousseau committed Jan 1, 2010
1 parent f96a921 commit 56e07f8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
11 changes: 8 additions & 3 deletions src/dyn_unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,15 @@
INTERNAL int DYN_LoadLibrary(void **pvLHandle, char *pcLibrary)
{
*pvLHandle = NULL;
#ifndef PCSCLITE_STATIC_DRIVER
*pvLHandle = dlopen(pcLibrary, RTLD_LAZY);

if (*pvLHandle == NULL)
{
Log3(PCSC_LOG_CRITICAL, "%s: %s", pcLibrary, dlerror());
return SCARD_F_UNKNOWN_ERROR;
}
#endif

return SCARD_S_SUCCESS;
}
Expand All @@ -44,6 +46,7 @@ INTERNAL int DYN_CloseLibrary(void **pvLHandle)
{
int ret;

#ifndef PCSCLITE_STATIC_DRIVER
ret = dlclose(*pvLHandle);
*pvLHandle = NULL;

Expand All @@ -52,19 +55,21 @@ INTERNAL int DYN_CloseLibrary(void **pvLHandle)
Log2(PCSC_LOG_CRITICAL, "%s", dlerror());
return SCARD_F_UNKNOWN_ERROR;
}
#endif

return SCARD_S_SUCCESS;
}

INTERNAL int DYN_GetAddress(void *pvLHandle, void **pvFHandle, const char *pcFunction)
{
char pcFunctionName[256];
int rv;
int rv = SCARD_S_SUCCESS;

/* Some platforms might need a leading underscore for the symbol */
(void)snprintf(pcFunctionName, sizeof(pcFunctionName), "_%s", pcFunction);

*pvFHandle = NULL;
#ifndef PCSCLITE_STATIC_DRIVER
*pvFHandle = dlsym(pvLHandle, pcFunctionName);

/* Failed? Try again without the leading underscore */
Expand All @@ -75,8 +80,8 @@ INTERNAL int DYN_GetAddress(void *pvLHandle, void **pvFHandle, const char *pcFun
{
Log3(PCSC_LOG_CRITICAL, "%s: %s", pcFunction, dlerror());
rv = SCARD_F_UNKNOWN_ERROR;
} else
rv = SCARD_S_SUCCESS;
}
#endif

return rv;
}
Expand Down
2 changes: 0 additions & 2 deletions src/ifdwrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
#include "sys_generic.h"
#include "utils.h"

#undef PCSCLITE_STATIC_DRIVER

/**
* Set the protocol type selection (PTS).
* This function sets the appropriate protocol to be used on the card.
Expand Down
2 changes: 2 additions & 0 deletions src/pcscdaemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ static void SVCServiceRunLoop(int customMaxThreadCounter,
(void)signal(SIGHUP, SIG_IGN); /* needed for Solaris. The signal is sent
* when the shell is existed */

#ifndef PCSCLITE_STATIC_DRIVER
/*
* Set up the search for USB/PCMCIA devices
*/
Expand All @@ -126,6 +127,7 @@ static void SVCServiceRunLoop(int customMaxThreadCounter,
rsp = HPRegisterForHotplugEvents();
if (rsp)
return;
#endif

/*
* Set up the power management callback routine
Expand Down

0 comments on commit 56e07f8

Please sign in to comment.