- added card_detect_all

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@868 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
okir 2003-01-20 09:50:33 +00:00
parent 5b1eb43b93
commit 69f8588f47
3 changed files with 16 additions and 11 deletions

View File

@ -101,13 +101,8 @@ CK_RV C_GetSlotList(CK_BBOOL tokenPresent, /* only slots with token prese
int numMatches, i;
sc_pkcs11_slot_t *slot;
if (context == NULL_PTR)
return CKR_CRYPTOKI_NOT_INITIALIZED;
debug(context, "Getting slot listing\n");
for (i=0; i<context->reader_count; i++)
card_detect(i);
card_detect_all();
numMatches = 0;
for (i=0; i<SC_PKCS11_MAX_VIRTUAL_SLOTS; i++) {
@ -146,9 +141,9 @@ CK_RV C_GetSlotInfo(CK_SLOT_ID slotID, CK_SLOT_INFO_PTR pInfo)
return rv;
if (!slot->card) {
int i;
for (i=0; i<context->reader_count; i++)
card_detect(i);
rv = card_detect_all();
if (rv != CKR_OK)
return rv;
}
debug(context, "Getting info about slot %d\n", slotID);

View File

@ -287,7 +287,7 @@ void dump_template(const char *info, CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulCoun
/* Slot and card handling functions */
CK_RV card_initialize(int reader);
CK_RV card_detect(int reader);
CK_RV card_detect_all(void);
CK_RV card_removed(int reader);
CK_RV slot_initialize(int id, struct sc_pkcs11_slot *);
CK_RV slot_get_slot(int id, struct sc_pkcs11_slot **);

View File

@ -49,7 +49,7 @@ CK_RV card_initialize(int reader)
return CKR_OK;
}
CK_RV card_detect(int reader)
static CK_RV card_detect(int reader)
{
struct sc_pkcs11_card *card;
int rc, rv, i, retry = 1;
@ -127,6 +127,16 @@ again: rc = sc_detect_card_presence(context->reader[reader], 0);
return rv;
}
CK_RV card_detect_all(void)
{
int i;
if (context == NULL_PTR)
return CKR_CRYPTOKI_NOT_INITIALIZED;
for (i = 0; i < context->reader_count; i++)
card_detect(i);
}
CK_RV card_removed(int reader)
{
int i;