Don't bother exposing sc_pkcs11_module_t and scdl_context_t
to public headers, use void instead. git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@1424 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
parent
4f580598b0
commit
ba1a685c8e
@ -18,14 +18,15 @@
|
|||||||
|
|
||||||
struct sc_pkcs11_module {
|
struct sc_pkcs11_module {
|
||||||
unsigned int _magic;
|
unsigned int _magic;
|
||||||
scdl_context_t *handle;
|
void *handle;
|
||||||
};
|
};
|
||||||
|
typedef struct sc_pkcs11_module sc_pkcs11_module_t;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Load a module - this will load the shared object, call
|
* Load a module - this will load the shared object, call
|
||||||
* C_Initialize, and get the list of function pointers
|
* C_Initialize, and get the list of function pointers
|
||||||
*/
|
*/
|
||||||
sc_pkcs11_module_t *
|
void *
|
||||||
C_LoadModule(const char *mspec, CK_FUNCTION_LIST_PTR_PTR funcs)
|
C_LoadModule(const char *mspec, CK_FUNCTION_LIST_PTR_PTR funcs)
|
||||||
{
|
{
|
||||||
sc_pkcs11_module_t *mod;
|
sc_pkcs11_module_t *mod;
|
||||||
@ -48,9 +49,9 @@ C_LoadModule(const char *mspec, CK_FUNCTION_LIST_PTR_PTR funcs)
|
|||||||
goto failed;
|
goto failed;
|
||||||
rv = c_get_function_list(funcs);
|
rv = c_get_function_list(funcs);
|
||||||
if (rv == CKR_OK)
|
if (rv == CKR_OK)
|
||||||
return mod;
|
return (void *) mod;
|
||||||
|
|
||||||
failed: C_UnloadModule(mod);
|
failed: C_UnloadModule((void *) mod);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,8 +61,10 @@ failed: C_UnloadModule(mod);
|
|||||||
* and calling C_Finalize
|
* and calling C_Finalize
|
||||||
*/
|
*/
|
||||||
CK_RV
|
CK_RV
|
||||||
C_UnloadModule(sc_pkcs11_module_t *mod)
|
C_UnloadModule(void *module)
|
||||||
{
|
{
|
||||||
|
sc_pkcs11_module_t *mod = (sc_pkcs11_module_t *) module;
|
||||||
|
|
||||||
if (!mod || mod->_magic != MAGIC)
|
if (!mod || mod->_magic != MAGIC)
|
||||||
return CKR_ARGUMENTS_BAD;
|
return CKR_ARGUMENTS_BAD;
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ CK_FUNCTION_LIST_PTR pkcs11_spy = NULL;
|
|||||||
/* Real Module Function List */
|
/* Real Module Function List */
|
||||||
CK_FUNCTION_LIST_PTR po = NULL;
|
CK_FUNCTION_LIST_PTR po = NULL;
|
||||||
/* Dynamic Module Handle */
|
/* Dynamic Module Handle */
|
||||||
static sc_pkcs11_module_t *modhandle = NULL;
|
static void *modhandle = NULL;
|
||||||
/* Spy module output */
|
/* Spy module output */
|
||||||
FILE *spy_output = NULL;
|
FILE *spy_output = NULL;
|
||||||
|
|
||||||
|
@ -49,11 +49,8 @@ extern "C" {
|
|||||||
#define PKCS11_DEFAULT_MODULE_NAME "opensc-pkcs11.so";
|
#define PKCS11_DEFAULT_MODULE_NAME "opensc-pkcs11.so";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct sc_pkcs11_module sc_pkcs11_module_t;
|
extern void *C_LoadModule(const char *name, CK_FUNCTION_LIST_PTR_PTR);
|
||||||
|
extern CK_RV C_UnloadModule(void *module);
|
||||||
extern sc_pkcs11_module_t *C_LoadModule(const char *name,
|
|
||||||
CK_FUNCTION_LIST_PTR_PTR);
|
|
||||||
extern CK_RV C_UnloadModule(sc_pkcs11_module_t *);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
#include <Carbon/Carbon.h>
|
#include <Carbon/Carbon.h>
|
||||||
#endif
|
#endif
|
||||||
|
#include "scdl.h"
|
||||||
|
|
||||||
#define SCDL_MAGIC 0xbeefd00d
|
#define SCDL_MAGIC 0xbeefd00d
|
||||||
|
|
||||||
@ -207,7 +208,7 @@ mac_get_address(scdl_context_t *mod, const char *symbol)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
scdl_context_t *
|
void *
|
||||||
scdl_open(const char *name)
|
scdl_open(const char *name)
|
||||||
{
|
{
|
||||||
scdl_context_t *mod;
|
scdl_context_t *mod;
|
||||||
@ -237,12 +238,13 @@ scdl_open(const char *name)
|
|||||||
free(mod);
|
free(mod);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return mod;
|
return (void *) mod;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
scdl_close(scdl_context_t *mod)
|
scdl_close(void *module)
|
||||||
{
|
{
|
||||||
|
scdl_context_t *mod = (scdl_context_t *) module;
|
||||||
int rv;
|
int rv;
|
||||||
|
|
||||||
if (!mod || mod->magic != SCDL_MAGIC)
|
if (!mod || mod->magic != SCDL_MAGIC)
|
||||||
@ -269,8 +271,10 @@ scdl_close(scdl_context_t *mod)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void *
|
void *
|
||||||
scdl_get_address(scdl_context_t *mod, const char *symbol)
|
scdl_get_address(void *module, const char *symbol)
|
||||||
{
|
{
|
||||||
|
scdl_context_t *mod = (scdl_context_t *) module;
|
||||||
|
|
||||||
if (!mod || mod->magic != SCDL_MAGIC)
|
if (!mod || mod->magic != SCDL_MAGIC)
|
||||||
return NULL;
|
return NULL;
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
|
@ -17,11 +17,9 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef void scdl_context_t;
|
extern void *scdl_open(const char *name);
|
||||||
|
extern int scdl_close(void *module);
|
||||||
extern scdl_context_t *scdl_open(const char *name);
|
extern void *scdl_get_address(void *module, const char *symbol);
|
||||||
extern int scdl_close(scdl_context_t *mod);
|
|
||||||
extern void *scdl_get_address(scdl_context_t *mod, const char *symbol);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@
|
|||||||
* but is not anymore. The typical ``watch me walk over the edge
|
* but is not anymore. The typical ``watch me walk over the edge
|
||||||
* of that cliff there'' thing.
|
* of that cliff there'' thing.
|
||||||
*/
|
*/
|
||||||
static void * the_handler = NULL;
|
static void *handle = NULL;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create a new context
|
* Create a new context
|
||||||
@ -105,12 +105,12 @@ PKCS11_CTX_load(PKCS11_CTX *ctx, const char *name)
|
|||||||
PKCS11err(PKCS11_F_PKCS11_CTX_LOAD, PKCS11_MODULE_LOADED_ERROR);
|
PKCS11err(PKCS11_F_PKCS11_CTX_LOAD, PKCS11_MODULE_LOADED_ERROR);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
the_handler=C_LoadModule(name, &priv->method );
|
handle=C_LoadModule(name, &priv->method );
|
||||||
if (!the_handler) {
|
if (!handle) {
|
||||||
PKCS11err(PKCS11_F_PKCS11_CTX_LOAD, PKCS11_LOAD_MODULE_ERROR);
|
PKCS11err(PKCS11_F_PKCS11_CTX_LOAD, PKCS11_LOAD_MODULE_ERROR);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
/*
|
#if 0
|
||||||
priv->method = PKCS11_NEW(PKCS11_method);
|
priv->method = PKCS11_NEW(PKCS11_method);
|
||||||
base = (caddr_t) (priv->method);
|
base = (caddr_t) (priv->method);
|
||||||
for (sym = pkcs11_symbols; sym->name; sym++) {
|
for (sym = pkcs11_symbols; sym->name; sym++) {
|
||||||
@ -120,7 +120,7 @@ PKCS11_CTX_load(PKCS11_CTX *ctx, const char *name)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
#endif
|
||||||
|
|
||||||
/* Tell the PKCS11 to initialize itself */
|
/* Tell the PKCS11 to initialize itself */
|
||||||
rv = priv->method->C_Initialize(NULL);
|
rv = priv->method->C_Initialize(NULL);
|
||||||
@ -152,7 +152,7 @@ PKCS11_CTX_unload(PKCS11_CTX *ctx)
|
|||||||
priv->method->C_Finalize(NULL);
|
priv->method->C_Finalize(NULL);
|
||||||
|
|
||||||
/* Unload the module */
|
/* Unload the module */
|
||||||
C_UnloadModule(the_handler);
|
C_UnloadModule(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -120,7 +120,7 @@ static CK_BYTE opt_object_id[100], new_object_id[100];
|
|||||||
static int opt_object_id_len = 0, new_object_id_len = 0;
|
static int opt_object_id_len = 0, new_object_id_len = 0;
|
||||||
static char * opt_object_label = NULL;
|
static char * opt_object_label = NULL;
|
||||||
|
|
||||||
static sc_pkcs11_module_t *module = NULL;
|
static void *module = NULL;
|
||||||
static CK_FUNCTION_LIST_PTR p11 = NULL;
|
static CK_FUNCTION_LIST_PTR p11 = NULL;
|
||||||
static CK_SLOT_ID_PTR p11_slots = NULL;
|
static CK_SLOT_ID_PTR p11_slots = NULL;
|
||||||
static CK_ULONG p11_num_slots = 0;
|
static CK_ULONG p11_num_slots = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user