From 9872a1b087d03ed15286a4d371f7ba9264c3b16f Mon Sep 17 00:00:00 2001 From: Romain Tartiere Date: Tue, 27 Jul 2010 08:44:12 +0000 Subject: [PATCH] Rename DESFIRE_4K to DESFIRE. The code can work with virtually any size of DESFire (since the operating system embedded in the card handle almost everything), so there is no need for us to distinguish cards of different sizes. --- examples/mifare-desfire-access.c | 8 ++------ examples/mifare-desfire-format.c | 8 ++------ examples/mifare-desfire-info.c | 8 ++------ libfreefare/freefare.c | 6 +++--- libfreefare/freefare.h | 4 +--- libfreefare/freefare_internal.h | 2 +- test/mifare_desfire_fixture.c | 2 +- 7 files changed, 12 insertions(+), 26 deletions(-) diff --git a/examples/mifare-desfire-access.c b/examples/mifare-desfire-access.c index 2ff0b64..ceb277a 100644 --- a/examples/mifare-desfire-access.c +++ b/examples/mifare-desfire-access.c @@ -61,12 +61,8 @@ main(int argc, char *argv[]) } for (int i = 0; (!error) && tags[i]; i++) { - switch (freefare_get_tag_type (tags[i])) { - case DESFIRE_4K: - break; - default: - continue; - } + if (DESFIRE != freefare_get_tag_type (tags[i])) + continue; int res; char *tag_uid = freefare_get_tag_uid (tags[i]); diff --git a/examples/mifare-desfire-format.c b/examples/mifare-desfire-format.c index 8b4ba5c..570dba1 100644 --- a/examples/mifare-desfire-format.c +++ b/examples/mifare-desfire-format.c @@ -92,12 +92,8 @@ main(int argc, char *argv[]) } for (int i = 0; (!error) && tags[i]; i++) { - switch (freefare_get_tag_type (tags[i])) { - case DESFIRE_4K: - break; - default: - continue; - } + if (DESFIRE != freefare_get_tag_type (tags[i])) + continue; char *tag_uid = freefare_get_tag_uid (tags[i]); char buffer[BUFSIZ]; diff --git a/examples/mifare-desfire-info.c b/examples/mifare-desfire-info.c index c5b52c2..8db6149 100644 --- a/examples/mifare-desfire-info.c +++ b/examples/mifare-desfire-info.c @@ -59,12 +59,8 @@ main(int argc, char *argv[]) } for (int i = 0; (!error) && tags[i]; i++) { - switch (freefare_get_tag_type (tags[i])) { - case DESFIRE_4K: - break; - default: - continue; - } + if (DESFIRE != freefare_get_tag_type (tags[i])) + continue; int res; char *tag_uid = freefare_get_tag_uid (tags[i]); diff --git a/libfreefare/freefare.c b/libfreefare/freefare.c index 5ee505f..f6f6ab2 100644 --- a/libfreefare/freefare.c +++ b/libfreefare/freefare.c @@ -27,7 +27,7 @@ struct supported_tag supported_tags[] = { { { 0x00, 0x04 }, 0x08, CLASSIC_1K, "Mifare Classic 1k" }, { { 0x00, 0x02 }, 0x18, CLASSIC_4K, "Mifare Classic 4k" }, { { 0x00, 0x02 }, 0x38, CLASSIC_4K, "Mifare Classic 4k (Emulated)" }, - { { 0x03, 0x44 }, 0x20, DESFIRE_4K, "Mifare DESFire 4k" }, + { { 0x03, 0x44 }, 0x20, DESFIRE, "Mifare DESFire 4k" }, { { 0x00, 0x44 }, 0x00, ULTRALIGHT, "Mifare UltraLight" }, }; @@ -107,7 +107,7 @@ freefare_get_tags (nfc_device_t *device) case CLASSIC_4K: tags[tag_count-1] = mifare_classic_tag_new (); break; - case DESFIRE_4K: + case DESFIRE: tags[tag_count-1] = mifare_desfire_tag_new (); break; case ULTRALIGHT: @@ -176,7 +176,7 @@ freefare_free_tag (MifareTag tag) case CLASSIC_4K: mifare_classic_tag_free (tag); break; - case DESFIRE_4K: + case DESFIRE: mifare_desfire_tag_free (tag); break; case ULTRALIGHT: diff --git a/libfreefare/freefare.h b/libfreefare/freefare.h index 3e22145..e516162 100644 --- a/libfreefare/freefare.h +++ b/libfreefare/freefare.h @@ -40,9 +40,7 @@ enum mifare_tag_type { // PLUS_S4K, // PLUS_X2K, // PLUS_X4K, -// DESFIRE_2K, - DESFIRE_4K, -// DESFIRE_8K + DESFIRE }; struct mifare_tag; diff --git a/libfreefare/freefare_internal.h b/libfreefare/freefare_internal.h index aefbaf0..35df59f 100644 --- a/libfreefare/freefare_internal.h +++ b/libfreefare/freefare_internal.h @@ -181,7 +181,7 @@ struct mifare_ultralight_tag { #define ASSERT_INACTIVE(tag) do { if (tag->active) return errno = ENXIO, -1; } while (0) #define ASSERT_MIFARE_CLASSIC(tag) do { if ((tag->tag_info->type != CLASSIC_1K) && (tag->tag_info->type != CLASSIC_4K)) return errno = ENODEV, -1; } while (0) -#define ASSERT_MIFARE_DESFIRE(tag) do { if (tag->tag_info->type != DESFIRE_4K) return errno = ENODEV, -1; } while (0) +#define ASSERT_MIFARE_DESFIRE(tag) do { if (tag->tag_info->type != DESFIRE) return errno = ENODEV, -1; } while (0) #define ASSERT_MIFARE_ULTRALIGHT(tag) do { if (tag->tag_info->type != ULTRALIGHT) return errno = ENODEV, -1; } while (0) /* diff --git a/test/mifare_desfire_fixture.c b/test/mifare_desfire_fixture.c index 7eaeb68..9070710 100644 --- a/test/mifare_desfire_fixture.c +++ b/test/mifare_desfire_fixture.c @@ -46,7 +46,7 @@ cut_setup () tag = NULL; for (int i=0; tags[i]; i++) { - if (freefare_get_tag_type(tags[i]) == DESFIRE_4K) { + if (freefare_get_tag_type(tags[i]) == DESFIRE) { tag = tags[i]; res = mifare_desfire_connect (tag); cut_assert_equal_int (0, res, cut_message ("mifare_desfire_connect() failed"));