From c80ebdca25bb6d9a47d1685df0dc74c5faf24430 Mon Sep 17 00:00:00 2001 From: Audrey Diacre Date: Thu, 5 Jan 2012 14:49:02 +0000 Subject: [PATCH] nfc_abort_command() function returns now 0 on success and libnfc error code on failure and fix some warnings. --- examples/nfc-poll.c | 2 +- include/nfc/nfc.h | 2 +- libnfc/drivers/arygon.c | 4 ++-- libnfc/drivers/pn532_uart.c | 4 ++-- libnfc/drivers/pn53x_usb.c | 4 ++-- libnfc/nfc-internal.h | 2 +- libnfc/nfc.c | 4 ++-- utils/mifare.c | 2 +- utils/nfc-list.c | 2 +- utils/nfc-mfclassic.c | 2 +- 10 files changed, 14 insertions(+), 14 deletions(-) diff --git a/examples/nfc-poll.c b/examples/nfc-poll.c index c9bd62b..2392f28 100644 --- a/examples/nfc-poll.c +++ b/examples/nfc-poll.c @@ -63,7 +63,7 @@ void stop_polling (int sig) } void -print_usage (char* progname) +print_usage (const char* progname) { printf ("usage: %s [-v]\n", progname); printf (" -v\t verbose display\n"); diff --git a/include/nfc/nfc.h b/include/nfc/nfc.h index 3b1bb4b..0f05a02 100644 --- a/include/nfc/nfc.h +++ b/include/nfc/nfc.h @@ -66,7 +66,7 @@ extern "C" { NFC_EXPORT bool nfc_get_default_device (nfc_connstring *connstring); NFC_EXPORT nfc_device *nfc_connect (const nfc_connstring connstring); NFC_EXPORT void nfc_disconnect (nfc_device *pnd); - NFC_EXPORT bool nfc_abort_command (nfc_device *pnd); + NFC_EXPORT int nfc_abort_command (nfc_device *pnd); NFC_EXPORT void nfc_list_devices (nfc_connstring connstrings[], size_t connstrings_len, size_t *pszDeviceFound); NFC_EXPORT int nfc_idle (nfc_device *pnd); diff --git a/libnfc/drivers/arygon.c b/libnfc/drivers/arygon.c index 2e2a9ee..40306eb 100644 --- a/libnfc/drivers/arygon.c +++ b/libnfc/drivers/arygon.c @@ -538,7 +538,7 @@ arygon_reset_tama (nfc_device *pnd) return NFC_SUCCESS; } -bool +int arygon_abort_command (nfc_device *pnd) { if (pnd) { @@ -549,7 +549,7 @@ arygon_abort_command (nfc_device *pnd) DRIVER_DATA (pnd)->abort_flag = true; #endif } - return true; + return NFC_SUCCESS; } diff --git a/libnfc/drivers/pn532_uart.c b/libnfc/drivers/pn532_uart.c index f47aeed..9bd7e89 100644 --- a/libnfc/drivers/pn532_uart.c +++ b/libnfc/drivers/pn532_uart.c @@ -481,7 +481,7 @@ pn532_uart_ack (nfc_device *pnd) return (uart_send (DRIVER_DATA(pnd)->port, pn53x_ack_frame, sizeof (pn53x_ack_frame), 0)); } -bool +int pn532_uart_abort_command (nfc_device *pnd) { if (pnd) { @@ -492,7 +492,7 @@ pn532_uart_abort_command (nfc_device *pnd) DRIVER_DATA (pnd)->abort_flag = true; #endif } - return true; + return NFC_SUCCESS; } const struct pn53x_io pn532_uart_io = { diff --git a/libnfc/drivers/pn53x_usb.c b/libnfc/drivers/pn53x_usb.c index a0a8f6a..1ab9ee7 100644 --- a/libnfc/drivers/pn53x_usb.c +++ b/libnfc/drivers/pn53x_usb.c @@ -781,11 +781,11 @@ pn53x_usb_set_property_bool (nfc_device *pnd, const nfc_property property, const return NFC_SUCCESS; } -bool +int pn53x_usb_abort_command (nfc_device *pnd) { DRIVER_DATA (pnd)->abort_flag = true; - return true; + return NFC_SUCCESS; } const struct pn53x_io pn53x_usb_io = { diff --git a/libnfc/nfc-internal.h b/libnfc/nfc-internal.h index f816ea6..fd15dba 100644 --- a/libnfc/nfc-internal.h +++ b/libnfc/nfc-internal.h @@ -151,7 +151,7 @@ struct nfc_driver_t { int (*device_set_property_bool) (struct nfc_device *pnd, const nfc_property property, const bool bEnable); int (*device_set_property_int) (struct nfc_device *pnd, const nfc_property property, const int value); - bool (*abort_command) (struct nfc_device *pnd); + int (*abort_command) (struct nfc_device *pnd); int (*idle) (struct nfc_device *pnd); }; diff --git a/libnfc/nfc.c b/libnfc/nfc.c index 8c61ea0..a042b05 100644 --- a/libnfc/nfc.c +++ b/libnfc/nfc.c @@ -676,7 +676,7 @@ nfc_idle (nfc_device *pnd) /** * @brief Abort current running command - * @return Returns \c true if action was successfully performed; otherwise returns \c false. + * @return Returns 0 on success, otherwise returns libnfc's error code. * * @param pnd \a nfc_device struct pointer that represent currently used device * @@ -685,7 +685,7 @@ nfc_idle (nfc_device *pnd) * * @note The blocking function (ie. nfc_target_init()) will failed with DEABORT error. */ -bool +int nfc_abort_command (nfc_device *pnd) { HAL (abort_command, pnd); diff --git a/utils/mifare.c b/utils/mifare.c index 4773e45..d9ea0b0 100644 --- a/utils/mifare.c +++ b/utils/mifare.c @@ -54,7 +54,7 @@ nfc_initiator_mifare_cmd (nfc_device *pnd, const mifare_cmd mc, const uint8_t ui size_t szRx = sizeof(abtRx); size_t szParamLen; uint8_t abtCmd[265]; - bool bEasyFraming; + //bool bEasyFraming; abtCmd[0] = mc; // The MIFARE Classic command abtCmd[1] = ui8Block; // The block address (1K=0x00..0x39, 4K=0x00..0xff) diff --git a/utils/nfc-list.c b/utils/nfc-list.c index 9fee2bb..5508d9c 100644 --- a/utils/nfc-list.c +++ b/utils/nfc-list.c @@ -60,7 +60,7 @@ static nfc_device *pnd; void -print_usage (char* progname) +print_usage (const char* progname) { printf ("usage: %s [-v]\n", progname); printf (" -v\t verbose display\n"); diff --git a/utils/nfc-mfclassic.c b/utils/nfc-mfclassic.c index e89a19b..94d939b 100644 --- a/utils/nfc-mfclassic.c +++ b/utils/nfc-mfclassic.c @@ -577,7 +577,7 @@ main (int argc, const char *argv[]) uint8_t fileUid[4]; memcpy (fileUid, mtKeys.amb[0].mbm.abtUID, 4); // Compare if key dump UID is the same as the current tag UID, at least for the first 4 bytes - if (memcmp (nt.nti.nai.abtUid, fileUid, 4) != 0) { + if (memcmp (pbtUID, fileUid, 4) != 0) { printf ("Expected MIFARE Classic card with UID starting as: %02x%02x%02x%02x\n", fileUid[0], fileUid[1], fileUid[2], fileUid[3]); }