examples, test and utils use now nfc_exit() function.

This commit is contained in:
Audrey Diacre 2012-01-18 11:36:18 +00:00
parent 1d55b6f8c6
commit 207199dc34
25 changed files with 59 additions and 9 deletions

View file

@ -372,6 +372,7 @@ main (int argc, char *argv[])
err (EXIT_FAILURE, "Can't save NDEF file '%s'", argv[2]);
}
}
nfc_exit ();
exit (EXIT_SUCCESS);
}

View file

@ -251,6 +251,7 @@ main (int argc, const char *argv[])
}
nfc_close (pnd);
}
nfc_exit ();
return 0;
}

View file

@ -565,6 +565,7 @@ main (int argc, const char *argv[])
if (nfc_initiator_select_passive_target (pnd, nmMifare, NULL, 0, &nt) < 0) {
printf ("Error: no tag was found\n");
nfc_close (pnd);
nfc_exit ();
exit (EXIT_FAILURE);
}
// Test if we are dealing with a MIFARE compatible tag
@ -663,6 +664,7 @@ main (int argc, const char *argv[])
printf ("Done, all bytes have been extracted!\n");
}
};
nfc_exit ();
exit (EXIT_SUCCESS);
}

View file

@ -215,6 +215,7 @@ main (int argc, char *argv[])
if (!transmit_bits (abtReqa, 7)) {
printf ("Error: No tag available\n");
nfc_close (pnd);
nfc_exit ();
return 1;
}
memcpy (abtAtqa, abtRx, 2);
@ -353,5 +354,6 @@ main (int argc, char *argv[])
nfc_close (pnd);
nfc_exit ();
return 0;
}

View file

@ -230,6 +230,7 @@ main (int argc, const char *argv[])
if (nfc_initiator_select_passive_target (pnd, nmMifare, NULL, 0, &nt) < 0) {
ERR ("no tag was found\n");
nfc_close (pnd);
nfc_exit ();
return 1;
}
// Test if we are dealing with a MIFARE compatible tag
@ -237,6 +238,7 @@ main (int argc, const char *argv[])
if (nt.nti.nai.abtAtqa[1] != 0x44) {
ERR ("tag is not a MIFARE Ultralight card\n");
nfc_close (pnd);
nfc_exit ();
return EXIT_FAILURE;
}
// Get the info from the current tag
@ -268,6 +270,6 @@ main (int argc, const char *argv[])
}
nfc_close (pnd);
nfc_exit ();
return EXIT_SUCCESS;
}

View file

@ -317,5 +317,6 @@ error:
if (pnd) {
nfc_close (pnd);
}
nfc_exit ();
exit (error);
}

View file

@ -233,6 +233,7 @@ main (int argc, char *argv[])
if (nfc_initiator_init (pndInitiator) < 0) {
printf ("Error: fail initializing initiator\n");
nfc_close (pndInitiator);
nfc_exit ();
exit (EXIT_FAILURE);
}
@ -244,6 +245,7 @@ main (int argc, char *argv[])
if (nfc_initiator_select_passive_target (pndInitiator, nm, NULL, 0, &ntRealTarget) < 0) {
printf ("Error: no tag was found\n");
nfc_close (pndInitiator);
nfc_exit ();
exit (EXIT_FAILURE);
}
@ -253,21 +255,25 @@ main (int argc, char *argv[])
if (print_hex_fd4(ntRealTarget.nti.nai.abtUid, ntRealTarget.nti.nai.szUidLen, "UID") != EXIT_SUCCESS) {
fprintf (stderr, "Error while printing UID to FD4\n");
nfc_close (pndInitiator);
nfc_exit ();
exit(EXIT_FAILURE);
}
if (print_hex_fd4(ntRealTarget.nti.nai.abtAtqa, 2, "ATQA") != EXIT_SUCCESS) {
fprintf (stderr, "Error while printing ATQA to FD4\n");
nfc_close (pndInitiator);
nfc_exit ();
exit(EXIT_FAILURE);
}
if (print_hex_fd4(&(ntRealTarget.nti.nai.btSak), 1, "SAK") != EXIT_SUCCESS) {
fprintf (stderr, "Error while printing SAK to FD4\n");
nfc_close (pndInitiator);
nfc_exit ();
exit(EXIT_FAILURE);
}
if (print_hex_fd4(ntRealTarget.nti.nai.abtAts, ntRealTarget.nti.nai.szAtsLen, "ATS") != EXIT_SUCCESS) {
fprintf (stderr, "Error while printing ATS to FD4\n");
nfc_close (pndInitiator);
nfc_exit ();
exit(EXIT_FAILURE);
}
}
@ -291,6 +297,7 @@ main (int argc, char *argv[])
if (scan_hex_fd3(ntEmulatedTarget.nti.nai.abtUid, &(ntEmulatedTarget.nti.nai.szUidLen), "UID") != EXIT_SUCCESS) {
fprintf (stderr, "Error while scanning UID from FD3\n");
nfc_close (pndInitiator);
nfc_exit ();
exit(EXIT_FAILURE);
}
if (scan_hex_fd3(ntEmulatedTarget.nti.nai.abtAtqa, &foo, "ATQA") != EXIT_SUCCESS) {
@ -301,11 +308,13 @@ main (int argc, char *argv[])
if (scan_hex_fd3(&(ntEmulatedTarget.nti.nai.btSak), &foo, "SAK") != EXIT_SUCCESS) {
fprintf (stderr, "Error while scanning SAK from FD3\n");
nfc_close (pndInitiator);
nfc_exit ();
exit(EXIT_FAILURE);
}
if (scan_hex_fd3(ntEmulatedTarget.nti.nai.abtAts, &(ntEmulatedTarget.nti.nai.szAtsLen), "ATS") != EXIT_SUCCESS) {
fprintf (stderr, "Error while scanning ATS from FD3\n");
nfc_close (pndInitiator);
nfc_exit ();
exit(EXIT_FAILURE);
}
} else {
@ -350,6 +359,7 @@ main (int argc, char *argv[])
if (!target_only_mode) {
nfc_close (pndInitiator);
}
nfc_exit ();
return EXIT_FAILURE;
}
@ -362,6 +372,7 @@ main (int argc, char *argv[])
nfc_close (pndInitiator);
}
nfc_close (pndTarget);
nfc_exit ();
exit(EXIT_FAILURE);
}
printf ("%s\n", "Done, relaying frames now!");
@ -379,6 +390,7 @@ main (int argc, char *argv[])
nfc_close (pndInitiator);
}
nfc_close (pndTarget);
nfc_exit ();
exit(EXIT_FAILURE);
}
szCapduLen = (size_t) res;
@ -386,6 +398,7 @@ main (int argc, char *argv[])
if (print_hex_fd4(abtCapdu, szCapduLen, "C-APDU") != EXIT_SUCCESS) {
fprintf (stderr, "Error while printing C-APDU to FD4\n");
nfc_close (pndTarget);
nfc_exit ();
exit(EXIT_FAILURE);
}
}
@ -393,6 +406,7 @@ main (int argc, char *argv[])
if (scan_hex_fd3(abtCapdu, &szCapduLen, "C-APDU") != EXIT_SUCCESS) {
fprintf (stderr, "Error while scanning C-APDU from FD3\n");
nfc_close (pndInitiator);
nfc_exit ();
exit(EXIT_FAILURE);
}
}
@ -410,6 +424,7 @@ main (int argc, char *argv[])
if (scan_hex_fd3(abtRapdu, &szRapduLen, "R-APDU") != EXIT_SUCCESS) {
fprintf (stderr, "Error while scanning R-APDU from FD3\n");
nfc_close (pndTarget);
nfc_exit ();
exit(EXIT_FAILURE);
}
ret = true;
@ -436,13 +451,16 @@ main (int argc, char *argv[])
}
if (!initiator_only_mode) {
nfc_close (pndTarget);
nfc_exit ();
}
nfc_exit ();
exit(EXIT_FAILURE);
}
} else {
if (print_hex_fd4(abtRapdu, szRapduLen, "R-APDU") != EXIT_SUCCESS) {
fprintf (stderr, "Error while printing R-APDU to FD4\n");
nfc_close (pndInitiator);
nfc_exit ();
exit(EXIT_FAILURE);
}
}
@ -455,6 +473,7 @@ main (int argc, char *argv[])
if (!initiator_only_mode) {
nfc_close (pndTarget);
}
nfc_exit ();
exit (EXIT_SUCCESS);
}