add ykpiv_disconnect()

This commit is contained in:
Klas Lindfors
2014-06-17 10:55:46 +02:00
parent 9d0d163f62
commit f468146311
3 changed files with 17 additions and 0 deletions
+15
View File
@@ -57,10 +57,25 @@ ykpiv_rc ykpiv_init(ykpiv_state **state, int verbose) {
}
ykpiv_rc ykpiv_done(ykpiv_state *state) {
ykpiv_disconnect(state);
free(state);
return YKPIV_OK;
}
ykpiv_rc ykpiv_disconnect(ykpiv_state *state) {
if(state->card) {
SCardDisconnect(state->card, SCARD_RESET_CARD);
state->card = 0;
}
if(state->context) {
SCardReleaseContext(state->context);
state->context = 0;
}
return YKPIV_OK;
}
ykpiv_rc ykpiv_connect(ykpiv_state *state, const char *wanted) {
unsigned long num_readers = 0;
unsigned long active_protocol;