- Fixed a mac specific compiler warning

- Fixed libdl-specific code to work with Fink's dlcompat package


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@1335 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
aet 2003-08-06 08:45:57 +00:00
parent 6e29c9f599
commit c42a3bfc0f
1 changed files with 22 additions and 14 deletions

View File

@ -19,13 +19,12 @@
#define MAGIC 0xd00bed00 #define MAGIC 0xd00bed00
struct sc_pkcs11_module { struct sc_pkcs11_module {
unsigned int _magic; unsigned int _magic;
#if defined(HAVE_DLFCN_H) || defined(_WIN32) #if defined(HAVE_DLFCN_H) || defined(_WIN32)
void * _dl_handle; void *_dl_handle;
#endif #elif defined(__APPLE__)
#ifdef __APPLE__ const struct mach_header *_dl_handle;
struct mach_header *_dl_handle; CFBundleRef bundleRef;
CFBundleRef bundleRef;
#endif #endif
}; };
@ -133,18 +132,29 @@ sys_dlclose(struct sc_pkcs11_module *mod)
return 0; return 0;
} }
void * void *
sys_dlsym(sc_pkcs11_module_t *mod, const char *name) sys_dlsym(sc_pkcs11_module_t *mod, const char *name)
{ {
char sym_name[256];
void *address;
if (!mod->_dl_handle) if (!mod->_dl_handle)
return NULL; return NULL;
return dlsym(mod->_dl_handle, name);
/* Some platforms might need a leading underscore for the symbol */
sym_name[0] = '_';
strncpy(&sym_name[1], name, sizeof(sym_name) - 1);
address = dlsym(mod->_dl_handle, sym_name);
/* Failed? Try again without the leading underscore */
if (address == NULL)
address = dlsym(mod->_dl_handle, name);
return address;
} }
#endif #elif defined(_WIN32)
#ifdef _WIN32
#include <windows.h> #include <windows.h>
/* /*
@ -184,9 +194,7 @@ sys_dlsym(sc_pkcs11_module_t *mod, const char *name)
return GetProcAddress(mod->_dl_handle, name); return GetProcAddress(mod->_dl_handle, name);
} }
#endif #elif defined(__APPLE__)
#ifdef __APPLE__
#include <mach-o/dyld.h> #include <mach-o/dyld.h>
/* /*