Commit 01303fab authored by Philippe Teuwen's avatar Philippe Teuwen

astyle --formatted --mode=c --indent=spaces=2 --indent-switches...

astyle --formatted --mode=c --indent=spaces=2 --indent-switches --indent-preprocessor --keep-one-line-blocks --max-instatement-indent=60 --brackets=linux --pad-oper --unpad-paren --pad-header
parent 562205cc
......@@ -14,52 +14,52 @@
#include "libnfc/chips/pn53x.h"
int
main (int argc, const char *argv[])
main(int argc, const char *argv[])
{
nfc_device *pnd;
nfc_target nt;
nfc_init (NULL);
nfc_init(NULL);
// Display libnfc version
const char *acLibnfcVersion = nfc_version ();
printf ("%s uses libnfc %s\n", argv[0], acLibnfcVersion);
const char *acLibnfcVersion = nfc_version();
printf("%s uses libnfc %s\n", argv[0], acLibnfcVersion);
// Open, using the first available NFC device
pnd = nfc_open (NULL, NULL);
pnd = nfc_open(NULL, NULL);
if (pnd == NULL) {
ERR ("%s", "Unable to open NFC device.");
ERR("%s", "Unable to open NFC device.");
return EXIT_FAILURE;
}
// Set opened NFC device to initiator mode
if (nfc_initiator_init (pnd) < 0) {
nfc_perror (pnd, "nfc_initiator_init");
exit (EXIT_FAILURE);
if (nfc_initiator_init(pnd) < 0) {
nfc_perror(pnd, "nfc_initiator_init");
exit(EXIT_FAILURE);
}
printf ("NFC reader: %s opened\n", nfc_device_get_name (pnd));
printf("NFC reader: %s opened\n", nfc_device_get_name(pnd));
// Poll for a ISO14443A (MIFARE) tag
const nfc_modulation nmMifare = {
.nmt = NMT_ISO14443A,
.nbr = NBR_106,
};
if (nfc_initiator_select_passive_target (pnd, nmMifare, NULL, 0, &nt) > 0) {
printf ("The following (NFC) ISO14443A tag was found:\n");
printf (" ATQA (SENS_RES): ");
print_hex (nt.nti.nai.abtAtqa, 2);
printf (" UID (NFCID%c): ", (nt.nti.nai.abtUid[0] == 0x08 ? '3' : '1'));
print_hex (nt.nti.nai.abtUid, nt.nti.nai.szUidLen);
printf (" SAK (SEL_RES): ");
print_hex (&nt.nti.nai.btSak, 1);
if (nfc_initiator_select_passive_target(pnd, nmMifare, NULL, 0, &nt) > 0) {
printf("The following (NFC) ISO14443A tag was found:\n");
printf(" ATQA (SENS_RES): ");
print_hex(nt.nti.nai.abtAtqa, 2);
printf(" UID (NFCID%c): ", (nt.nti.nai.abtUid[0] == 0x08 ? '3' : '1'));
print_hex(nt.nti.nai.abtUid, nt.nti.nai.szUidLen);
printf(" SAK (SEL_RES): ");
print_hex(&nt.nti.nai.btSak, 1);
if (nt.nti.nai.szAtsLen) {
printf (" ATS (ATR): ");
print_hex (nt.nti.nai.abtAts, nt.nti.nai.szAtsLen);
printf(" ATS (ATR): ");
print_hex(nt.nti.nai.abtAts, nt.nti.nai.szAtsLen);
}
}
// Close NFC device
nfc_close (pnd);
nfc_exit (NULL);
nfc_close(pnd);
nfc_exit(NULL);
return EXIT_SUCCESS;
}
......@@ -75,21 +75,21 @@ uint8_t abtHalt[4] = { 0x50, 0x00, 0x00, 0x00 };
#define CASCADE_BIT 0x04
static bool
transmit_bits (const uint8_t *pbtTx, const size_t szTxBits)
transmit_bits(const uint8_t *pbtTx, const size_t szTxBits)
{
// Show transmitted command
if (!quiet_output) {
printf ("Sent bits: ");
print_hex_bits (pbtTx, szTxBits);
printf("Sent bits: ");
print_hex_bits(pbtTx, szTxBits);
}
// Transmit the bit frame command, we don't use the arbitrary parity feature
if ((szRxBits = nfc_initiator_transceive_bits (pnd, pbtTx, szTxBits, NULL, abtRx, NULL)) < 0)
if ((szRxBits = nfc_initiator_transceive_bits(pnd, pbtTx, szTxBits, NULL, abtRx, NULL)) < 0)
return false;
// Show received answer
if (!quiet_output) {
printf ("Received bits: ");
print_hex_bits (abtRx, szRxBits);
printf("Received bits: ");
print_hex_bits(abtRx, szRxBits);
}
// Succesful transfer
return true;
......@@ -97,103 +97,103 @@ transmit_bits (const uint8_t *pbtTx, const size_t szTxBits)
static bool
transmit_bytes (const uint8_t *pbtTx, const size_t szTx)
transmit_bytes(const uint8_t *pbtTx, const size_t szTx)
{
// Show transmitted command
if (!quiet_output) {
printf ("Sent bits: ");
print_hex (pbtTx, szTx);
printf("Sent bits: ");
print_hex(pbtTx, szTx);
}
int res;
// Transmit the command bytes
if ((res = nfc_initiator_transceive_bytes (pnd, pbtTx, szTx, abtRx, sizeof(abtRx), 0)) < 0)
if ((res = nfc_initiator_transceive_bytes(pnd, pbtTx, szTx, abtRx, sizeof(abtRx), 0)) < 0)
return false;
// Show received answer
if (!quiet_output) {
printf ("Received bits: ");
print_hex (abtRx, res);
printf("Received bits: ");
print_hex(abtRx, res);
}
// Succesful transfer
return true;
}
static void
print_usage (char *argv[])
print_usage(char *argv[])
{
printf ("Usage: %s [OPTIONS]\n", argv[0]);
printf ("Options:\n");
printf ("\t-h\tHelp. Print this message.\n");
printf ("\t-q\tQuiet mode. Suppress output of READER and EMULATOR data (improves timing).\n");
printf ("\t-f\tForce RATS.\n");
printf("Usage: %s [OPTIONS]\n", argv[0]);
printf("Options:\n");
printf("\t-h\tHelp. Print this message.\n");
printf("\t-q\tQuiet mode. Suppress output of READER and EMULATOR data (improves timing).\n");
printf("\t-f\tForce RATS.\n");
}
int
main (int argc, char *argv[])
main(int argc, char *argv[])
{
int arg;
// Get commandline options
for (arg = 1; arg < argc; arg++) {
if (0 == strcmp (argv[arg], "-h")) {
print_usage (argv);
if (0 == strcmp(argv[arg], "-h")) {
print_usage(argv);
exit(EXIT_SUCCESS);
} else if (0 == strcmp (argv[arg], "-q")) {
} else if (0 == strcmp(argv[arg], "-q")) {
quiet_output = true;
} else if (0 == strcmp (argv[arg], "-f")) {
} else if (0 == strcmp(argv[arg], "-f")) {
force_rats = true;
} else {
ERR ("%s is not supported option.", argv[arg]);
print_usage (argv);
ERR("%s is not supported option.", argv[arg]);
print_usage(argv);
exit(EXIT_FAILURE);
}
}
nfc_init (NULL);
nfc_init(NULL);
// Try to open the NFC reader
pnd = nfc_open (NULL, NULL);
pnd = nfc_open(NULL, NULL);
if (!pnd) {
printf ("Error opening NFC reader\n");
printf("Error opening NFC reader\n");
exit(EXIT_FAILURE);
}
// Initialise NFC device as "initiator"
if (nfc_initiator_init (pnd) < 0) {
nfc_perror (pnd, "nfc_initiator_init");
exit (EXIT_FAILURE);
if (nfc_initiator_init(pnd) < 0) {
nfc_perror(pnd, "nfc_initiator_init");
exit(EXIT_FAILURE);
}
// Configure the CRC
if (nfc_device_set_property_bool (pnd, NP_HANDLE_CRC, false) < 0) {
nfc_perror (pnd, "nfc_device_set_property_bool");
exit (EXIT_FAILURE);
if (nfc_device_set_property_bool(pnd, NP_HANDLE_CRC, false) < 0) {
nfc_perror(pnd, "nfc_device_set_property_bool");
exit(EXIT_FAILURE);
}
// Use raw send/receive methods
if (nfc_device_set_property_bool (pnd, NP_EASY_FRAMING, false) < 0) {
nfc_perror (pnd, "nfc_device_set_property_bool");
exit (EXIT_FAILURE);
if (nfc_device_set_property_bool(pnd, NP_EASY_FRAMING, false) < 0) {
nfc_perror(pnd, "nfc_device_set_property_bool");
exit(EXIT_FAILURE);
}
// Disable 14443-4 autoswitching
if (nfc_device_set_property_bool (pnd, NP_AUTO_ISO14443_4, false) < 0) {
nfc_perror (pnd, "nfc_device_set_property_bool");
exit (EXIT_FAILURE);
if (nfc_device_set_property_bool(pnd, NP_AUTO_ISO14443_4, false) < 0) {
nfc_perror(pnd, "nfc_device_set_property_bool");
exit(EXIT_FAILURE);
}
printf ("NFC reader: %s opened\n\n", nfc_device_get_name (pnd));
printf("NFC reader: %s opened\n\n", nfc_device_get_name(pnd));
// Send the 7 bits request command specified in ISO 14443A (0x26)
if (!transmit_bits (abtReqa, 7)) {
printf ("Error: No tag available\n");
nfc_close (pnd);
nfc_exit (NULL);
if (!transmit_bits(abtReqa, 7)) {
printf("Error: No tag available\n");
nfc_close(pnd);
nfc_exit(NULL);
return 1;
}
memcpy (abtAtqa, abtRx, 2);
memcpy(abtAtqa, abtRx, 2);
// Anti-collision
transmit_bytes (abtSelectAll, 2);
transmit_bytes(abtSelectAll, 2);
// Check answer
if ((abtRx[0] ^ abtRx[1] ^ abtRx[2] ^ abtRx[3] ^ abtRx[4]) != 0) {
......@@ -201,12 +201,12 @@ main (int argc, char *argv[])
}
// Save the UID CL1
memcpy (abtRawUid, abtRx, 4);
memcpy(abtRawUid, abtRx, 4);
//Prepare and send CL1 Select-Command
memcpy (abtSelectTag + 2, abtRx, 5);
iso14443a_crc_append (abtSelectTag, 7);
transmit_bytes (abtSelectTag, 9);
memcpy(abtSelectTag + 2, abtRx, 5);
iso14443a_crc_append(abtSelectTag, 7);
transmit_bytes(abtSelectTag, 9);
abtSak = abtRx[0];
// Test if we are dealing with a CL2
......@@ -218,14 +218,14 @@ main (int argc, char *argv[])
}
}
if(szCL == 2) {
if (szCL == 2) {
// We have to do the anti-collision for cascade level 2
// Prepare CL2 commands
abtSelectAll[0] = 0x95;
// Anti-collision
transmit_bytes (abtSelectAll, 2);
transmit_bytes(abtSelectAll, 2);
// Check answer
if ((abtRx[0] ^ abtRx[1] ^ abtRx[2] ^ abtRx[3] ^ abtRx[4]) != 0) {
......@@ -233,13 +233,13 @@ main (int argc, char *argv[])
}
// Save UID CL2
memcpy (abtRawUid + 4, abtRx, 4);
memcpy(abtRawUid + 4, abtRx, 4);
// Selection
abtSelectTag[0] = 0x95;
memcpy (abtSelectTag + 2, abtRx, 5);
iso14443a_crc_append (abtSelectTag, 7);
transmit_bytes (abtSelectTag, 9);
memcpy(abtSelectTag + 2, abtRx, 5);
iso14443a_crc_append(abtSelectTag, 7);
transmit_bytes(abtSelectTag, 9);
abtSak = abtRx[0];
// Test if we are dealing with a CL3
......@@ -251,12 +251,12 @@ main (int argc, char *argv[])
}
}
if ( szCL == 3) {
if (szCL == 3) {
// We have to do the anti-collision for cascade level 3
// Prepare and send CL3 AC-Command
abtSelectAll[0] = 0x97;
transmit_bytes (abtSelectAll, 2);
transmit_bytes(abtSelectAll, 2);
// Check answer
if ((abtRx[0] ^ abtRx[1] ^ abtRx[2] ^ abtRx[3] ^ abtRx[4]) != 0) {
......@@ -264,13 +264,13 @@ main (int argc, char *argv[])
}
// Save UID CL3
memcpy (abtRawUid + 8, abtRx, 4);
memcpy(abtRawUid + 8, abtRx, 4);
// Prepare and send final Select-Command
abtSelectTag[0] = 0x97;
memcpy (abtSelectTag + 2, abtRx, 5);
iso14443a_crc_append (abtSelectTag, 7);
transmit_bytes (abtSelectTag, 9);
memcpy(abtSelectTag + 2, abtRx, 5);
iso14443a_crc_append(abtSelectTag, 7);
transmit_bytes(abtSelectTag, 9);
abtSak = abtRx[0];
}
}
......@@ -281,29 +281,29 @@ main (int argc, char *argv[])
}
if ((abtRx[0] & SAK_FLAG_ATS_SUPPORTED) || force_rats) {
iso14443a_crc_append(abtRats, 2);
if (transmit_bytes (abtRats, 4)) {
memcpy (abtAts, abtRx, szRx);
if (transmit_bytes(abtRats, 4)) {
memcpy(abtAts, abtRx, szRx);
szAts = szRx;
}
}
// Done, halt the tag now
iso14443a_crc_append(abtHalt, 2);
transmit_bytes (abtHalt, 4);
transmit_bytes(abtHalt, 4);
printf ("\nFound tag with\n UID: ");
printf("\nFound tag with\n UID: ");
switch (szCL) {
case 1:
printf ("%02x%02x%02x%02x", abtRawUid[0], abtRawUid[1], abtRawUid[2], abtRawUid[3]);
printf("%02x%02x%02x%02x", abtRawUid[0], abtRawUid[1], abtRawUid[2], abtRawUid[3]);
break;
case 2:
printf ("%02x%02x%02x", abtRawUid[1], abtRawUid[2], abtRawUid[3]);
printf ("%02x%02x%02x%02x", abtRawUid[4], abtRawUid[5], abtRawUid[6], abtRawUid[7]);
printf("%02x%02x%02x", abtRawUid[1], abtRawUid[2], abtRawUid[3]);
printf("%02x%02x%02x%02x", abtRawUid[4], abtRawUid[5], abtRawUid[6], abtRawUid[7]);
break;
case 3:
printf ("%02x%02x%02x", abtRawUid[1], abtRawUid[2], abtRawUid[3]);
printf ("%02x%02x%02x", abtRawUid[5], abtRawUid[6], abtRawUid[7]);
printf ("%02x%02x%02x%02x", abtRawUid[8], abtRawUid[9], abtRawUid[10], abtRawUid[11]);
printf("%02x%02x%02x", abtRawUid[1], abtRawUid[2], abtRawUid[3]);
printf("%02x%02x%02x", abtRawUid[5], abtRawUid[6], abtRawUid[7]);
printf("%02x%02x%02x%02x", abtRawUid[8], abtRawUid[9], abtRawUid[10], abtRawUid[11]);
break;
}
printf("\n");
......@@ -313,10 +313,10 @@ main (int argc, char *argv[])
printf(" RATS forced\n");
}
printf(" ATS: ");
print_hex (abtAts, szAts);
print_hex(abtAts, szAts);
}
nfc_close (pnd);
nfc_exit (NULL);
nfc_close(pnd);
nfc_exit(NULL);
return 0;
}
......@@ -50,66 +50,66 @@
static nfc_device *pnd;
static void stop_dep_communication (int sig)
static void stop_dep_communication(int sig)
{
(void) sig;
if (pnd)
nfc_abort_command (pnd);
nfc_abort_command(pnd);
else
exit (EXIT_FAILURE);
exit(EXIT_FAILURE);
}
int
main (int argc, const char *argv[])
main(int argc, const char *argv[])
{
nfc_target nt;
uint8_t abtRx[MAX_FRAME_LEN];
uint8_t abtTx[] = "Hello World!";
if (argc > 1) {
printf ("Usage: %s\n", argv[0]);
printf("Usage: %s\n", argv[0]);
return EXIT_FAILURE;
}
nfc_init (NULL);
nfc_init(NULL);
pnd = nfc_open (NULL, NULL);
pnd = nfc_open(NULL, NULL);
if (!pnd) {
printf("Unable to open NFC device.\n");
return EXIT_FAILURE;
}
printf ("NFC device: %s\n opened", nfc_device_get_name (pnd));
printf("NFC device: %s\n opened", nfc_device_get_name(pnd));
signal (SIGINT, stop_dep_communication);
signal(SIGINT, stop_dep_communication);
if (nfc_initiator_init (pnd) < 0) {
if (nfc_initiator_init(pnd) < 0) {
nfc_perror(pnd, "nfc_initiator_init");
goto error;
}
if(nfc_initiator_select_dep_target (pnd, NDM_PASSIVE, NBR_212, NULL, &nt, 1000) < 0) {
if (nfc_initiator_select_dep_target(pnd, NDM_PASSIVE, NBR_212, NULL, &nt, 1000) < 0) {
nfc_perror(pnd, "nfc_initiator_select_dep_target");
goto error;
}
print_nfc_target (nt, false);
print_nfc_target(nt, false);
printf ("Sending: %s\n", abtTx);
printf("Sending: %s\n", abtTx);
int res;
if ((res = nfc_initiator_transceive_bytes (pnd, abtTx, sizeof(abtTx), abtRx, sizeof(abtRx), 0)) < 0) {
if ((res = nfc_initiator_transceive_bytes(pnd, abtTx, sizeof(abtTx), abtRx, sizeof(abtRx), 0)) < 0) {
nfc_perror(pnd, "nfc_initiator_transceive_bytes");
goto error;
}
abtRx[res] = 0;
printf ("Received: %s\n", abtRx);
printf("Received: %s\n", abtRx);
if (nfc_initiator_deselect_target (pnd) < 0) {
if (nfc_initiator_deselect_target(pnd) < 0) {
nfc_perror(pnd, "nfc_initiator_deselect_target");
goto error;
}
error:
nfc_close (pnd);
nfc_exit (NULL);
nfc_close(pnd);
nfc_exit(NULL);
return EXIT_SUCCESS;
}
......@@ -49,40 +49,40 @@
static nfc_device *pnd;
static void stop_dep_communication (int sig)
static void stop_dep_communication(int sig)
{
(void) sig;
if (pnd)
nfc_abort_command (pnd);
nfc_abort_command(pnd);
else
exit (EXIT_FAILURE);
exit(EXIT_FAILURE);
}
int
main (int argc, const char *argv[])
main(int argc, const char *argv[])
{
uint8_t abtRx[MAX_FRAME_LEN];
int szRx;
uint8_t abtTx[] = "Hello Mars!";
#define MAX_DEVICE_COUNT 2
nfc_connstring connstrings[MAX_DEVICE_COUNT];
size_t szDeviceFound = nfc_list_devices (NULL, connstrings, MAX_DEVICE_COUNT);
size_t szDeviceFound = nfc_list_devices(NULL, connstrings, MAX_DEVICE_COUNT);
// Little hack to allow using nfc-dep-initiator & nfc-dep-target from
// the same machine: if there is more than one readers opened
// nfc-dep-target will open the second reader
// (we hope they're always detected in the same order)
nfc_init (NULL);
nfc_init(NULL);
if (szDeviceFound == 1) {
pnd = nfc_open (NULL, connstrings[0]);
pnd = nfc_open(NULL, connstrings[0]);
} else if (szDeviceFound > 1) {
pnd = nfc_open (NULL, connstrings[1]);
pnd = nfc_open(NULL, connstrings[1]);
} else {
printf("No device found.\n");
return EXIT_FAILURE;
}
if (argc > 1) {
printf ("Usage: %s\n", argv[0]);
printf("Usage: %s\n", argv[0]);
return EXIT_FAILURE;
}
......@@ -111,36 +111,36 @@ main (int argc, const char *argv[])
printf("Unable to open NFC device.\n");
return EXIT_FAILURE;
}
printf ("NFC device: %s opened\n", nfc_device_get_name (pnd));
printf("NFC device: %s opened\n", nfc_device_get_name(pnd));
signal (SIGINT, stop_dep_communication);
signal(SIGINT, stop_dep_communication);
printf ("NFC device will now act as: ");
print_nfc_target (nt, false);
printf("NFC device will now act as: ");
print_nfc_target(nt, false);
printf ("Waiting for initiator request...\n");
if ((szRx = nfc_target_init (pnd, &nt, abtRx, sizeof(abtRx), 0)) < 0) {
printf("Waiting for initiator request...\n");
if ((szRx = nfc_target_init(pnd, &nt, abtRx, sizeof(abtRx), 0)) < 0) {
nfc_perror(pnd, "nfc_target_init");
goto error;
}
printf("Initiator request received. Waiting for data...\n");
if ((szRx = nfc_target_receive_bytes (pnd, abtRx, sizeof (abtRx), 0)) < 0) {
if ((szRx = nfc_target_receive_bytes(pnd, abtRx, sizeof(abtRx), 0)) < 0) {
nfc_perror(pnd, "nfc_target_receive_bytes");
goto error;
}
abtRx[(size_t) szRx] = '\0';
printf ("Received: %s\n", abtRx);
printf("Received: %s\n", abtRx);
printf ("Sending: %s\n", abtTx);
if (nfc_target_send_bytes (pnd, abtTx, sizeof(abtTx), 0) < 0) {
printf("Sending: %s\n", abtTx);
if (nfc_target_send_bytes(pnd, abtTx, sizeof(abtTx), 0) < 0) {
nfc_perror(pnd, "nfc_target_send_bytes");
goto error;
}
printf("Data sent.\n");
error:
nfc_close (pnd);
nfc_exit (NULL);
nfc_close(pnd);
nfc_exit(NULL);
return EXIT_SUCCESS;
}
......@@ -74,13 +74,13 @@
static nfc_device *pnd;
static void
stop_emulation (int sig)
stop_emulation(int sig)
{
(void)sig;
if (pnd) {
nfc_abort_command(pnd);
} else {
exit (EXIT_FAILURE);
exit(EXIT_FAILURE);
}
}
......@@ -112,14 +112,14 @@ static uint8_t __nfcforum_tag2_memory_area[] = {
#define HALT 0x50
static int
nfcforum_tag2_io (struct nfc_emulator *emulator, const uint8_t *data_in, const size_t data_in_len, uint8_t *data_out, const size_t data_out_len)
nfcforum_tag2_io(struct nfc_emulator *emulator, const uint8_t *data_in, const size_t data_in_len, uint8_t *data_out, const size_t data_out_len)
{
int res = 0;
uint8_t *nfcforum_tag2_memory_area = (uint8_t *)(emulator->user_data);
printf (" In: ");
print_hex (data_in, data_in_len);
printf(" In: ");
print_hex(data_in, data_in_len);
switch (data_in[0]) {
case READ:
......@@ -131,19 +131,19 @@ nfcforum_tag2_io (struct nfc_emulator *emulator, const uint8_t *data_in, const s
}
break;
case HALT:
printf ("HALT sent\n");
printf("HALT sent\n");
res = -ECONNABORTED;
break;
default:
printf ("Unknown command: 0x%02x\n", data_in[0]);
printf("Unknown command: 0x%02x\n", data_in[0]);
res = -ENOTSUP;
}
if (res < 0) {
ERR ("%s (%d)", strerror (-res), -res);
ERR("%s (%d)", strerror(-res), -res);
} else {
printf (" Out: ");
print_hex (data_out, res);
printf(" Out: ");
print_hex(data_out, res);
}
return res;
......@@ -181,31 +181,31 @@ main(int argc, char *argv[])
.user_data = __nfcforum_tag2_memory_area,
};
signal (SIGINT, stop_emulation);
nfc_init (NULL);
pnd = nfc_open (NULL, NULL);
signal(SIGINT, stop_emulation);
nfc_init(NULL);
pnd = nfc_open(NULL, NULL);
if (pnd == NULL) {
ERR("Unable to open NFC device");
exit (EXIT_FAILURE);
exit(EXIT_FAILURE);
}
printf ("NFC device: %s opened\n", nfc_device_get_name (pnd));
printf ("Emulating NDEF tag now, please touch it with a second NFC device\n");
printf("NFC device: %s opened\n", nfc_device_get_name(pnd));
printf("Emulating NDEF tag now, please touch it with a second NFC device\n");
if (nfc_emulate_target (pnd, &emulator) < 0) {
if (nfc_emulate_target(pnd, &emulator) < 0) {
goto error;
}
nfc_close(pnd);
nfc_exit (NULL);
nfc_exit(NULL);
exit (EXIT_SUCCESS);
exit(EXIT_SUCCESS);
error:
if (pnd) {
nfc_perror (pnd, argv[0]);
nfc_close (pnd);
nfc_exit (NULL);
nfc_perror(pnd, argv[0]);
nfc_close(pnd);
nfc_exit(NULL);
}
}
......@@ -61,30 +61,30 @@ static bool quiet_output = false;
static bool init_mfc_auth = false;
static void
intr_hdlr (int sig)
intr_hdlr(int sig)
{
(void) sig;
printf ("\nQuitting...\n");
printf("\nQuitting...\n");
if (pnd != NULL) {
nfc_close(pnd);
}
nfc_exit (NULL);
exit (EXIT_FAILURE);
nfc_exit(NULL);
exit(EXIT_FAILURE);
}
static bool
target_io( nfc_target *pnt, const uint8_t *pbtInput, const size_t szInput, uint8_t *pbtOutput, size_t *pszOutput )
target_io(nfc_target *pnt, const uint8_t *pbtInput, const size_t szInput, uint8_t *pbtOutput, size_t *pszOutput)
{
bool loop = true;
*pszOutput = 0;
// Show transmitted command
if (!quiet_output) {
printf (" In: ");