Don't hardcode initial debugging level and error/debug_file
pointers to the code, get the values from opensc.conf instead. git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@386 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
parent
441bbb5265
commit
ec6f8961b0
|
@ -33,9 +33,6 @@ CK_FUNCTION_LIST pkcs11_function_list;
|
|||
|
||||
CK_RV C_Initialize(CK_VOID_PTR pReserved)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
const char *envarg;
|
||||
#endif
|
||||
int i, rc;
|
||||
|
||||
if (context != NULL) {
|
||||
|
@ -45,22 +42,6 @@ CK_RV C_Initialize(CK_VOID_PTR pReserved)
|
|||
rc = sc_establish_context(&context, "opensc-pkcs11");
|
||||
if (rc != 0)
|
||||
return CKR_DEVICE_ERROR;
|
||||
#ifdef DEBUG
|
||||
/* We need to send the debug log to a file because of
|
||||
* netscape's stupid stderr capturing */
|
||||
if ((envarg = getenv("PKCS11_DEBUG")) != NULL
|
||||
&& (context->debug_file = fopen(envarg, "w")) != NULL) {
|
||||
context->error_file = context->debug_file;
|
||||
} else {
|
||||
context->debug_file = stdout;
|
||||
context->error_file = stderr;
|
||||
}
|
||||
if ((envarg = getenv("PKCS11_DEBUG_LEVEL")) != NULL)
|
||||
context->debug = atoi(envarg);
|
||||
#else
|
||||
context->debug_file = NULL;
|
||||
context->error_file = NULL;
|
||||
#endif
|
||||
|
||||
pool_initialize(&session_pool);
|
||||
for (i=0; i<SC_PKCS11_MAX_VIRTUAL_SLOTS; i++)
|
||||
|
|
|
@ -127,9 +127,6 @@ int p15_eid_init(int argc, const char **argv)
|
|||
scam_fw_p15_eid.printmsg("sc_establish_context: %s\n", sc_strerror(r));
|
||||
return SCAM_FAILED;
|
||||
}
|
||||
ctx->error_file = stderr;
|
||||
ctx->debug_file = stdout;
|
||||
ctx->debug = 0;
|
||||
|
||||
for (i = 0; i < argc; i++) {
|
||||
if (argv[i][0] == '-') {
|
||||
|
|
|
@ -127,9 +127,6 @@ int p15_ldap_init(int argc, const char **argv)
|
|||
scam_fw_p15_ldap.printmsg("sc_establish_context: %s\n", sc_strerror(r));
|
||||
return SCAM_FAILED;
|
||||
}
|
||||
ctx->error_file = stderr;
|
||||
ctx->debug_file = stdout;
|
||||
ctx->debug = 0;
|
||||
|
||||
for (i = 0; i < argc; i++) {
|
||||
if (argv[i][0] == '-') {
|
||||
|
|
|
@ -21,8 +21,6 @@ int sc_test_init(int *argc, char *argv[])
|
|||
printf("sc_establish_context() failed (%d)\n", i);
|
||||
return i;
|
||||
}
|
||||
ctx->error_file = stderr;
|
||||
ctx->debug_file = stdout;
|
||||
i = sc_detect_card_presence(ctx->reader[0], 0);
|
||||
printf("Card %s.\n", i == 1 ? "present" : "absent");
|
||||
if (i < 0) {
|
||||
|
|
|
@ -1170,9 +1170,8 @@ int main(int argc, char * const argv[])
|
|||
fprintf(stderr, "Failed to establish context: %s\n", sc_strerror(r));
|
||||
return 1;
|
||||
}
|
||||
ctx->error_file = stderr;
|
||||
ctx->debug_file = stdout;
|
||||
ctx->debug = opt_debug;
|
||||
if (opt_debug)
|
||||
ctx->debug = opt_debug;
|
||||
if (opt_reader >= ctx->reader_count || opt_reader < 0) {
|
||||
fprintf(stderr, "Illegal reader number. Only %d reader(s) configured.\n", ctx->reader_count);
|
||||
err = 1;
|
||||
|
|
|
@ -1175,11 +1175,8 @@ int main(int argc, char * const argv[])
|
|||
fprintf(stderr, "Failed to establish context: %s\n", sc_strerror(r));
|
||||
return 1;
|
||||
}
|
||||
if (opt_debug) {
|
||||
ctx->error_file = stderr;
|
||||
ctx->debug_file = stdout;
|
||||
if (opt_debug)
|
||||
ctx->debug = opt_debug;
|
||||
}
|
||||
if (opt_reader >= ctx->reader_count || opt_reader < 0) {
|
||||
fprintf(stderr, "Illegal reader number. Only %d reader(s) configured.\n", ctx->reader_count);
|
||||
err = 1;
|
||||
|
|
|
@ -408,9 +408,8 @@ int main(int argc, char * const argv[])
|
|||
fprintf(stderr, "Failed to establish context: %s\n", sc_strerror(r));
|
||||
return 1;
|
||||
}
|
||||
ctx->error_file = stderr;
|
||||
ctx->debug_file = stdout;
|
||||
ctx->debug = opt_debug;
|
||||
if (opt_debug)
|
||||
ctx->debug = opt_debug;
|
||||
if (do_list_rdrivers) {
|
||||
if ((err = list_reader_drivers()))
|
||||
goto end;
|
||||
|
|
|
@ -263,9 +263,8 @@ int main(int argc, char * const argv[])
|
|||
fprintf(stderr, "Failed to establish context: %s\n", sc_strerror(r));
|
||||
return 1;
|
||||
}
|
||||
ctx->error_file = stderr;
|
||||
ctx->debug_file = stdout;
|
||||
ctx->debug = opt_debug;
|
||||
if (opt_debug)
|
||||
ctx->debug = opt_debug;
|
||||
if (opt_reader >= ctx->reader_count || opt_reader < 0) {
|
||||
fprintf(stderr, "Illegal reader number. Only %d reader(s) configured.\n", ctx->reader_count);
|
||||
err = 1;
|
||||
|
|
|
@ -311,10 +311,8 @@ connect(int reader)
|
|||
error("Failed to establish context: %s\n", sc_strerror(r));
|
||||
return 0;
|
||||
}
|
||||
|
||||
ctx->error_file = stderr;
|
||||
ctx->debug_file = stdout;
|
||||
ctx->debug = opt_debug;
|
||||
if (opt_debug)
|
||||
ctx->debug = opt_debug;
|
||||
if (reader >= ctx->reader_count || reader < 0) {
|
||||
fprintf(stderr,
|
||||
"Illegal reader number. Only %d reader%s configured.\n",
|
||||
|
|
|
@ -703,9 +703,8 @@ int main(int argc, char * const argv[])
|
|||
fprintf(stderr, "Failed to establish context: %s\n", sc_strerror(r));
|
||||
return 1;
|
||||
}
|
||||
ctx->error_file = stderr;
|
||||
ctx->debug_file = stdout;
|
||||
ctx->debug = opt_debug;
|
||||
if (opt_debug)
|
||||
ctx->debug = opt_debug;
|
||||
if (ctx->reader_count == 0) {
|
||||
fprintf(stderr, "No readers configured.\n");
|
||||
err = 1;
|
||||
|
|
Loading…
Reference in New Issue