#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <chipcard/chipcard.h>
#include <chipcard/client.h>
const char *failedCommand)
{
const char *s;
switch (res) {
s="Ok.";
break;
s="Timeout.";
break;
s="IPC error.";
break;
s="Command error.";
break;
s="Data error.";
break;
s="Aborted.";
break;
s="Invalid argument to command.";
break;
s="Internal error.";
break;
s="Generic error.";
break;
default:
s="Unknown error.";
break;
}
fprintf(stderr, "Error in \"%s\": %s\n", failedCommand, s);
int sw1;
int sw2;
fprintf(stderr, " Last card command result:\n");
if (sw1!=-1 && sw2!=-1)
fprintf(stderr, " SW1=%02x, SW2=%02x\n", sw1, sw2);
if (s)
fprintf(stderr, " Result: %s\n", s);
if (s)
fprintf(stderr, " Text : %s\n", s);
}
}
int main(int argc, char **argv)
{
showError(card, res, "Init");
return 1;
}
fprintf(stderr, "INFO: Connecting to server.\n");
showError(card, res, "StartWait");
return 2;
}
fprintf(stderr, "Please insert a chip card.\n");
showError(card, res, "GetNextCard");
return 2;
}
fprintf(stderr, "INFO: Telling the server that we need no more cards.\n");
showError(card, res, "Stop");
return 2;
}
fprintf(stderr, "INFO: Opening card.\n");
showError(card, res, "CardOpen");
return 2;
}
fprintf(stderr, "INFO: I got this card:\n");
fprintf(stderr, "INFO: Closing card.\n");
showError(card, res, "CardClose");
return 2;
}
fprintf(stderr, "INFO: Card closed.\n");
showError(card, res, "CardRelease");
return 2;
}
return 0;
}
struct LC_CARD LC_CARD
Definition: card.h:25
CHIPCARD_API void LC_Card_Dump(const LC_CARD *cd, int indent)
CHIPCARD_API LC_CLIENT_RESULT LC_Card_Open(LC_CARD *card)
CHIPCARD_API const char * LC_Card_GetLastText(const LC_CARD *card)
CHIPCARD_API const char * LC_Card_GetLastResult(const LC_CARD *card)
CHIPCARD_API int LC_Card_GetLastSW2(const LC_CARD *card)
CHIPCARD_API LC_CLIENT_RESULT LC_Card_Close(LC_CARD *card)
CHIPCARD_API int LC_Card_GetLastSW1(const LC_CARD *card)
CHIPCARD_API void LC_Card_free(LC_CARD *cd)
CHIPCARD_API LC_CLIENT_RESULT LC_Client_Start(LC_CLIENT *cl)
CHIPCARD_API void LC_Client_free(LC_CLIENT *cl)
CHIPCARD_API LC_CLIENT_RESULT LC_Client_ReleaseCard(LC_CLIENT *cl, LC_CARD *card)
LC_CLIENT_RESULT
Definition: client.h:40
@ LC_Client_ResultAborted
Definition: client.h:46
@ LC_Client_ResultCmdError
Definition: client.h:44
@ LC_Client_ResultInvalid
Definition: client.h:47
@ LC_Client_ResultInternal
Definition: client.h:48
@ LC_Client_ResultDataError
Definition: client.h:45
@ LC_Client_ResultOk
Definition: client.h:41
@ LC_Client_ResultIpcError
Definition: client.h:43
@ LC_Client_ResultGeneric
Definition: client.h:49
@ LC_Client_ResultWait
Definition: client.h:42
CHIPCARD_API LC_CLIENT_RESULT LC_Client_GetNextCard(LC_CLIENT *cl, LC_CARD **pCard, int timeout)
CHIPCARD_API LC_CLIENT_RESULT LC_Client_Init(LC_CLIENT *cl)
CHIPCARD_API LC_CLIENT_RESULT LC_Client_Stop(LC_CLIENT *cl)
CHIPCARD_API LC_CLIENT * LC_Client_new(const char *programName, const char *programVersion)
struct LC_CLIENT LC_CLIENT
Definition: client.h:33