From ec6f8961b02f0afc28d4aefdb5987afedab4ef75 Mon Sep 17 00:00:00 2001 From: aet Date: Sun, 24 Mar 2002 21:56:13 +0000 Subject: [PATCH] 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 --- src/pkcs11/pkcs11-global.c | 19 ------------------- src/scam/p15_eid.c | 3 --- src/scam/p15_ldap.c | 3 --- src/tests/sc-test.c | 2 -- src/tools/cryptoflex-tool.c | 5 ++--- src/tools/opensc-explorer.c | 5 +---- src/tools/opensc-tool.c | 5 ++--- src/tools/pkcs15-crypt.c | 5 ++--- src/tools/pkcs15-init.c | 6 ++---- src/tools/pkcs15-tool.c | 5 ++--- 10 files changed, 11 insertions(+), 47 deletions(-) diff --git a/src/pkcs11/pkcs11-global.c b/src/pkcs11/pkcs11-global.c index 3dadfafb..ed1492f5 100644 --- a/src/pkcs11/pkcs11-global.c +++ b/src/pkcs11/pkcs11-global.c @@ -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; ierror_file = stderr; - ctx->debug_file = stdout; - ctx->debug = 0; for (i = 0; i < argc; i++) { if (argv[i][0] == '-') { diff --git a/src/scam/p15_ldap.c b/src/scam/p15_ldap.c index 3e5710a2..fb159798 100644 --- a/src/scam/p15_ldap.c +++ b/src/scam/p15_ldap.c @@ -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] == '-') { diff --git a/src/tests/sc-test.c b/src/tests/sc-test.c index b9ba6cbf..4ce3a90c 100644 --- a/src/tests/sc-test.c +++ b/src/tests/sc-test.c @@ -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) { diff --git a/src/tools/cryptoflex-tool.c b/src/tools/cryptoflex-tool.c index fca9a379..4c4ed86a 100644 --- a/src/tools/cryptoflex-tool.c +++ b/src/tools/cryptoflex-tool.c @@ -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; diff --git a/src/tools/opensc-explorer.c b/src/tools/opensc-explorer.c index 8316702e..7992751b 100644 --- a/src/tools/opensc-explorer.c +++ b/src/tools/opensc-explorer.c @@ -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; diff --git a/src/tools/opensc-tool.c b/src/tools/opensc-tool.c index e6455954..00ca3a8e 100644 --- a/src/tools/opensc-tool.c +++ b/src/tools/opensc-tool.c @@ -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; diff --git a/src/tools/pkcs15-crypt.c b/src/tools/pkcs15-crypt.c index 0fc54ae0..548d1d5a 100644 --- a/src/tools/pkcs15-crypt.c +++ b/src/tools/pkcs15-crypt.c @@ -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; diff --git a/src/tools/pkcs15-init.c b/src/tools/pkcs15-init.c index f9916e8d..eb14b49c 100644 --- a/src/tools/pkcs15-init.c +++ b/src/tools/pkcs15-init.c @@ -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", diff --git a/src/tools/pkcs15-tool.c b/src/tools/pkcs15-tool.c index d168b878..7e0a5df8 100644 --- a/src/tools/pkcs15-tool.c +++ b/src/tools/pkcs15-tool.c @@ -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;