From abbb66e037ff7565d2f4b196cf4d14fddbad02b2 Mon Sep 17 00:00:00 2001 From: Timo Schulz Date: Thu, 14 Aug 2003 12:20:08 +0000 Subject: [PATCH] * Always use 'dynload.h' instead of 'dlfcn.h'. --- scd/ChangeLog | 6 ++++++ scd/apdu.c | 57 ++++++++++++++++++++++++--------------------------- scd/app.c | 3 ++- scd/atr.c | 2 +- scd/iso7816.c | 2 +- 5 files changed, 37 insertions(+), 33 deletions(-) diff --git a/scd/ChangeLog b/scd/ChangeLog index ae2e6ce6e..d78c4aa16 100644 --- a/scd/ChangeLog +++ b/scd/ChangeLog @@ -1,3 +1,9 @@ +2003-08-14 Timo Schulz + + * apdu.c (ct_activate_card): Change the code a little to avoid + problems with other readers. + * Always use 'dynload.h' instead of 'dlfcn.h'. + 2003-08-05 Werner Koch * app-openpgp.c (dump_all_do): Don't analyze constructed DOs after diff --git a/scd/apdu.c b/scd/apdu.c index 60de5b953..6afcd6711 100644 --- a/scd/apdu.c +++ b/scd/apdu.c @@ -23,11 +23,11 @@ #include #include #include -#include #include #include "scdaemon.h" #include "apdu.h" +#include "dynload.h" #define MAX_READER 4 /* Number of readers we support concurrently. */ #define CARD_CONNECT_TIMEOUT 1 /* Number of seconds to wait for @@ -232,40 +232,37 @@ ct_activate_card (int reader) return -1; } - if (buf[0] == 0x05) - { /* Connected, now activate the card. */ - dad[0] = 1; /* Destination address: CT. */ - sad[0] = 2; /* Source address: Host. */ + /* Connected, now activate the card. */ + dad[0] = 1; /* Destination address: CT. */ + sad[0] = 2; /* Source address: Host. */ - cmd[0] = 0x20; /* Class byte. */ - cmd[1] = 0x12; /* Request ICC. */ - cmd[2] = 0x01; /* From first interface. */ - cmd[3] = 0x01; /* Return card's ATR. */ - cmd[4] = 0x00; + cmd[0] = 0x20; /* Class byte. */ + cmd[1] = 0x12; /* Request ICC. */ + cmd[2] = 0x01; /* From first interface. */ + cmd[3] = 0x01; /* Return card's ATR. */ + cmd[4] = 0x00; - buflen = DIM(buf); + buflen = DIM(buf); - rc = CT_data (reader, dad, sad, 5, cmd, &buflen, buf); - if (rc || buflen < 2 || buf[buflen-2] != 0x90) - { - log_error ("ct_activate_card(%d): activation failed: %s\n", - reader, ct_error_string (rc)); - return -1; - } - - /* Store the type and the ATR. */ - if (buflen - 2 > DIM (reader_table[0].atr)) - { - log_error ("ct_activate_card(%d): ATR too long\n", reader); - return -1; - } - - reader_table[reader].status = buf[buflen - 1]; - memcpy (reader_table[reader].atr, buf, buflen - 2); - reader_table[reader].atrlen = buflen - 2; - return 0; + rc = CT_data (reader, dad, sad, 5, cmd, &buflen, buf); + if (rc || buflen < 2 || buf[buflen-2] != 0x90) + { + log_error ("ct_activate_card(%d): activation failed: %s\n", + reader, ct_error_string (rc)); + return -1; } + /* Store the type and the ATR. */ + if (buflen - 2 > DIM (reader_table[0].atr)) + { + log_error ("ct_activate_card(%d): ATR too long\n", reader); + return -1; + } + + reader_table[reader].status = buf[buflen - 1]; + memcpy (reader_table[reader].atr, buf, buflen - 2); + reader_table[reader].atrlen = buflen - 2; + return 0; } log_info ("ct_activate_card(%d): timeout waiting for card\n", reader); diff --git a/scd/app.c b/scd/app.c index 04b421b55..fa5df8a72 100644 --- a/scd/app.c +++ b/scd/app.c @@ -23,12 +23,13 @@ #include #include #include -#include + #include "scdaemon.h" #include "app-common.h" #include "apdu.h" #include "iso7816.h" +#include "dynload.h" static char *default_reader_port; diff --git a/scd/atr.c b/scd/atr.c index 4e15aad50..6475e83f8 100644 --- a/scd/atr.c +++ b/scd/atr.c @@ -23,12 +23,12 @@ #include #include #include -#include #include #include "scdaemon.h" #include "apdu.h" #include "atr.h" +#include "dynload.h" static int const fi_table[16] = { 0, 372, 558, 744, 1116,1488, 1860, -1, -1, 512, 768, 1024, 1536, 2048, -1, -1 }; diff --git a/scd/iso7816.c b/scd/iso7816.c index 8903d8a5c..2b06103ef 100644 --- a/scd/iso7816.c +++ b/scd/iso7816.c @@ -23,11 +23,11 @@ #include #include #include -#include #include "scdaemon.h" #include "iso7816.h" #include "apdu.h" +#include "dynload.h" #define CMD_SELECT_FILE 0xA4 #define CMD_VERIFY 0x20