pn53x_usb: leave the device in cleaner state (Fixes Issue 123)

This commit is contained in:
Philippe Teuwen 2010-10-12 15:51:57 +00:00
parent 61b0df5fe9
commit 9d1e72a9f7
3 changed files with 52 additions and 6 deletions

View file

@ -35,6 +35,7 @@
#include <stddef.h>
#include <stdint.h>
#include <string.h>
#include <signal.h>
#include <nfc/nfc.h>
@ -49,6 +50,16 @@ static nfc_device_t *pnd;
static bool quiet_output = false;
static bool init_mfc_auth = false;
void
intr_hdlr (void)
{
printf ("\nQuitting...\n");
if (pnd != NULL) {
nfc_disconnect(pnd);
}
exit (EXIT_FAILURE);
}
bool
target_io( const nfc_target_t nt, const byte_t * pbtInput, const size_t szInput, byte_t * pbtOutput, size_t *pszOutput )
{
@ -139,6 +150,12 @@ main (int argc, char *argv[])
{
const char *acLibnfcVersion;
#ifdef WIN32
signal (SIGINT, (void (__cdecl *) (int)) intr_hdlr);
#else
signal (SIGINT, (void (*)()) intr_hdlr);
#endif
// Try to open the NFC reader
pnd = nfc_connect (NULL);