Josep Monés Teixidor wrote:
On Tue, 2006-03-21 at 10:45 +0100, Josep Monés Teixidor wrote:
I promised an sc_reset patch, and I attach it to your consideration. The
patch is against yesterday's SVN code and only includes PC/SC backend
implementation.
Sorry!
I forgot the patch ;)
some first comments
Index: src/libopensc/card.c
===================================================================
--- src/libopensc/card.c (revision 2875)
+++ src/libopensc/card.c (working copy)
@@ -249,6 +249,26 @@
SC_FUNC_RETURN(ctx, 1, 0);
}
+int sc_reset(sc_card_t *card)
+{
+ int r = 0;
SC_SUCCESS is better than 0
+
+ if (card == NULL)
+ return SC_ERROR_INVALID_ARGUMENTS;
+
+ r = sc_mutex_lock(card->ctx, card->mutex);
+ if (r != SC_SUCCESS)
+ return r;
+
+ if(card->reader->ops->reset != NULL)
+ r = card->reader->ops->reset(card->reader, card->slot);
if the reader doesn't support this operation this function MUST
return a error like SC_ERROR_NOT_SUPPORTED (and of course applications
using this features must be able to handle this return value).
+
+ /* ignore return value of unlock to return reset value */
+ (void) sc_mutex_unlock(card->ctx, card->mutex);
actually one should _never_ ignore return values ;-)
+
+ return r;
+}
+
int sc_lock(sc_card_t *card)
{
int r = 0;
...
Index: src/libopensc/opensc.h
===================================================================
--- src/libopensc/opensc.h (revision 2875)
+++ src/libopensc/opensc.h (working copy)
@@ -394,6 +394,7 @@
int *reader_index,
unsigned int *event,
int timeout);
+ int (*reset)(struct sc_reader *, struct sc_slot_info *);
};
/*
@@ -806,6 +807,13 @@
int *reader, unsigned int *event, int timeout);
/**
+ * Resets the card.
It should be mentioned that this function is not always implemented
(depending on the used reader driver used).
+ * @param card The card to reset.
+ * @retval SC_SUCCESS on success
+ */
+int sc_reset(sc_card_t *card);
+
Cheers,
Nils
_______________________________________________
opensc-devel mailing list
[email protected]
http://www.opensc-project.org/mailman/listinfo/opensc-devel