Change calling convention for sc_module_close()

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@474 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
aet 2002-04-05 18:10:17 +00:00
parent ddb49064d6
commit 11c937991b
3 changed files with 14 additions and 13 deletions

View File

@ -57,7 +57,7 @@ struct sc_algorithm_info * _sc_card_find_rsa_alg(struct sc_card *card,
unsigned int key_length);
int sc_module_open(struct sc_context *ctx, void **mod_handle, const char *filename);
int sc_module_close(struct sc_context *ctx, void **mod_handle);
int sc_module_close(struct sc_context *ctx, void *mod_handle);
int sc_module_get_address(struct sc_context *ctx, void *mod_handle, void **sym_address, const char *sym_name);
#endif

View File

@ -30,34 +30,34 @@
int sc_module_open(struct sc_context *ctx, void **mod_handle, const char *filename)
{
const char *error;
void *handle;
assert(ctx != NULL);
if (!filename)
return SC_ERROR_UNKNOWN;
*mod_handle = NULL;
*mod_handle = dlopen(filename, RTLD_LAZY);
handle = dlopen(filename, RTLD_LAZY);
if ((error = dlerror()) != NULL) {
if (ctx->debug)
debug(ctx, "sc_module_open: %s", error);
return SC_ERROR_UNKNOWN;
}
*mod_handle = handle;
return SC_SUCCESS;
}
int sc_module_close(struct sc_context *ctx, void **mod_handle)
int sc_module_close(struct sc_context *ctx, void *mod_handle)
{
const char *error;
assert(ctx != NULL);
if (!*mod_handle)
if (!mod_handle)
return SC_ERROR_UNKNOWN;
dlclose(*mod_handle);
*mod_handle = NULL;
dlclose(mod_handle);
if ((error = dlerror()) != NULL) {
if (ctx->debug)
@ -71,6 +71,7 @@ int sc_module_get_address(struct sc_context *ctx, void *mod_handle, void **sym_a
{
const char *error;
char name[256];
void *address;
assert(ctx != NULL);
@ -81,17 +82,17 @@ int sc_module_get_address(struct sc_context *ctx, void *mod_handle, void **sym_a
name[0] = '_';
strncpy(&name[1], sym_name, sizeof(name) - 1);
*sym_address = NULL;
*sym_address = dlsym(mod_handle, name);
address = dlsym(mod_handle, name);
/* Failed? Try again without the leading underscore */
if (*sym_address == NULL)
*sym_address = dlsym(mod_handle, sym_name);
if (address == NULL)
address = dlsym(mod_handle, sym_name);
if ((error = dlerror()) != NULL) {
if (ctx->debug)
debug(ctx, "sc_module_get_address: %s", error);
return SC_ERROR_UNKNOWN;
}
*sym_address = address;
return SC_SUCCESS;
}

View File

@ -309,7 +309,7 @@ static int ctapi_load_module(struct sc_context *ctx,
return 0;
symerr:
error(ctx, "Unable to resolve CT-API symbols.\n");
sc_module_close(ctx, &dlh);
sc_module_close(ctx, dlh);
return -1;
}
@ -354,7 +354,7 @@ static int ctapi_finish(struct sc_context *ctx, void *prv_data)
struct ctapi_module *mod = &priv->modules[i];
free(mod->name);
sc_module_close(ctx, &mod->dlhandle);
sc_module_close(ctx, mod->dlhandle);
}
if (priv->module_count)
free(priv->modules);