nfc_initiator_transceive_bytes() now take a constant size for Rx buffer to have a cleaner API: no more in/out parameters

This commit is contained in:
Romuald Conty 2012-05-27 21:06:22 +00:00
parent f0e85c027a
commit 2c9275adde
13 changed files with 67 additions and 68 deletions

View file

@ -365,9 +365,8 @@ main (int argc, char *argv[])
}
printf ("NFC emulator device: %s opened\n", nfc_device_get_name (pndTarget));
szCapduLen = sizeof (abtCapdu);
if (nfc_target_init (pndTarget, &ntEmulatedTarget, abtCapdu, szCapduLen, 0) < 0) {
int res;
if ((res = nfc_target_init (pndTarget, &ntEmulatedTarget, abtCapdu, sizeof(abtCapdu), 0)) < 0) {
ERR ("%s", "Initialization of NFC emulator failed");
if (!target_only_mode) {
nfc_close (pndInitiator);
@ -379,7 +378,6 @@ main (int argc, char *argv[])
printf ("%s\n", "Done, relaying frames now!");
}
while (!quitting) {
bool ret;
int res = 0;
@ -419,8 +417,12 @@ main (int argc, char *argv[])
if (!target_only_mode) {
// Forward the frame to the original tag
ret = (nfc_initiator_transceive_bytes
(pndInitiator, abtCapdu, szCapduLen, abtRapdu, &szRapduLen, 0) < 0) ? 0 : 1;
if ((res = nfc_initiator_transceive_bytes (pndInitiator, abtCapdu, szCapduLen, abtRapdu, sizeof(abtRapdu), -1) < 0)) {
ret = false;
} else {
szCapduLen = (size_t) res;
ret = true;
}
} else {
if (scan_hex_fd3(abtRapdu, &szRapduLen, "R-APDU") != EXIT_SUCCESS) {
fprintf (stderr, "Error while scanning R-APDU from FD3\n");