Reindent (1/2).
After trying to tweak gindent so that it does not mess-up my ASCII art, give and read the help of Vim to setup 'cinoptions' according to my needs (cino=t0(0). This changeset reindent some bits that where not indented as they should. A future commit will reindent the switch/case according to my (bad) taste now that I have setup cindent correctly on my system (cino=t0(0:0).
This commit is contained in:
parent
036d2956f4
commit
af061a3c1a
16 changed files with 632 additions and 615 deletions
|
|
@ -42,7 +42,7 @@ main(int argc, char *argv[])
|
|||
|
||||
nfc_list_devices (devices, 8, &device_count);
|
||||
if (!device_count)
|
||||
errx (EXIT_FAILURE, "No NFC device found.");
|
||||
errx (EXIT_FAILURE, "No NFC device found.");
|
||||
|
||||
for (size_t d = 0; d < device_count; d++) {
|
||||
device = nfc_connect (&(devices[d]));
|
||||
|
|
@ -52,76 +52,76 @@ main(int argc, char *argv[])
|
|||
continue;
|
||||
}
|
||||
|
||||
tags = freefare_get_tags (device);
|
||||
if (!tags) {
|
||||
nfc_disconnect (device);
|
||||
errx (EXIT_FAILURE, "Error listing tags.");
|
||||
}
|
||||
|
||||
for (int i = 0; (!error) && tags[i]; i++) {
|
||||
if (DESFIRE != freefare_get_tag_type (tags[i]))
|
||||
continue;
|
||||
|
||||
int res;
|
||||
char *tag_uid = freefare_get_tag_uid (tags[i]);
|
||||
|
||||
struct mifare_desfire_version_info info;
|
||||
|
||||
res = mifare_desfire_connect (tags[i]);
|
||||
if (res < 0) {
|
||||
warnx ("Can't connect to Mifare DESFire target.");
|
||||
error = 1;
|
||||
break;
|
||||
tags = freefare_get_tags (device);
|
||||
if (!tags) {
|
||||
nfc_disconnect (device);
|
||||
errx (EXIT_FAILURE, "Error listing tags.");
|
||||
}
|
||||
|
||||
res = mifare_desfire_get_version (tags[i], &info);
|
||||
if (res < 0) {
|
||||
warnx ("Can't get Mifare DESFire version information.");
|
||||
error = 1;
|
||||
break;
|
||||
for (int i = 0; (!error) && tags[i]; i++) {
|
||||
if (DESFIRE != freefare_get_tag_type (tags[i]))
|
||||
continue;
|
||||
|
||||
int res;
|
||||
char *tag_uid = freefare_get_tag_uid (tags[i]);
|
||||
|
||||
struct mifare_desfire_version_info info;
|
||||
|
||||
res = mifare_desfire_connect (tags[i]);
|
||||
if (res < 0) {
|
||||
warnx ("Can't connect to Mifare DESFire target.");
|
||||
error = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
res = mifare_desfire_get_version (tags[i], &info);
|
||||
if (res < 0) {
|
||||
warnx ("Can't get Mifare DESFire version information.");
|
||||
error = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
printf ("===> Version information for tag %s:\n", tag_uid);
|
||||
printf ("UID: 0x%02x%02x%02x%02x%02x%02x%02x\n", info.uid[0], info.uid[1], info.uid[2], info.uid[3], info.uid[4], info.uid[5], info.uid[6]);
|
||||
printf ("Batch number: 0x%02x%02x%02x%02x%02x\n", info.batch_number[0], info.batch_number[1], info.batch_number[2], info.batch_number[3], info.batch_number[4]);
|
||||
printf ("Production date: week %x, 20%02x\n", info.production_week, info.production_year);
|
||||
printf ("Hardware Information:\n");
|
||||
printf (" Vendor ID: 0x%02x\n", info.hardware.vendor_id);
|
||||
printf (" Type: 0x%02x\n", info.hardware.type);
|
||||
printf (" Subtype: 0x%02x\n", info.hardware.subtype);
|
||||
printf (" Version: %d.%d\n", info.hardware.version_major, info.hardware.version_minor);
|
||||
printf (" Storage size: 0x%02x (%s%d bytes)\n", info.hardware.storage_size, (info.hardware.storage_size & 1) ? ">" : "=", (int)pow (2, info.hardware.storage_size >> 1));
|
||||
printf (" Protocol: 0x%02x\n", info.hardware.protocol);
|
||||
printf ("Software Information:\n");
|
||||
printf (" Vendor ID: 0x%02x\n", info.software.vendor_id);
|
||||
printf (" Type: 0x%02x\n", info.software.type);
|
||||
printf (" Subtype: 0x%02x\n", info.software.subtype);
|
||||
printf (" Version: %d.%d\n", info.software.version_major, info.software.version_minor);
|
||||
printf (" Storage size: 0x%02x (%s%d bytes)\n", info.software.storage_size, (info.software.storage_size & 1) ? ">" : "=", (int)pow (2, info.software.storage_size >> 1));
|
||||
printf (" Protocol: 0x%02x\n", info.software.protocol);
|
||||
|
||||
uint8_t settings;
|
||||
uint8_t max_keys;
|
||||
res = mifare_desfire_get_key_settings (tags[i], &settings, &max_keys);
|
||||
if (res < 0) {
|
||||
warnx ("Cant' get Mifare DESFire Master Key settings: %s", mifare_desfire_error_lookup (mifare_desfire_get_last_error (tags[i])));
|
||||
error = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
printf ("Master Key settings (0x%02x):\n", settings);
|
||||
printf (" 0x%02x configuration changeable;\n", settings & 0x08);
|
||||
printf (" 0x%02x PICC Master Key not required for create / delete;\n", settings & 0x04);
|
||||
printf (" 0x%02x Free directory list access without PICC Master Key;\n", settings & 0x02);
|
||||
printf (" 0x%02x Allow changing the Master Key;\n", settings & 0x01);
|
||||
|
||||
free (tag_uid);
|
||||
|
||||
mifare_desfire_disconnect (tags[i]);
|
||||
}
|
||||
|
||||
printf ("===> Version information for tag %s:\n", tag_uid);
|
||||
printf ("UID: 0x%02x%02x%02x%02x%02x%02x%02x\n", info.uid[0], info.uid[1], info.uid[2], info.uid[3], info.uid[4], info.uid[5], info.uid[6]);
|
||||
printf ("Batch number: 0x%02x%02x%02x%02x%02x\n", info.batch_number[0], info.batch_number[1], info.batch_number[2], info.batch_number[3], info.batch_number[4]);
|
||||
printf ("Production date: week %x, 20%02x\n", info.production_week, info.production_year);
|
||||
printf ("Hardware Information:\n");
|
||||
printf (" Vendor ID: 0x%02x\n", info.hardware.vendor_id);
|
||||
printf (" Type: 0x%02x\n", info.hardware.type);
|
||||
printf (" Subtype: 0x%02x\n", info.hardware.subtype);
|
||||
printf (" Version: %d.%d\n", info.hardware.version_major, info.hardware.version_minor);
|
||||
printf (" Storage size: 0x%02x (%s%d bytes)\n", info.hardware.storage_size, (info.hardware.storage_size & 1) ? ">" : "=", (int)pow (2, info.hardware.storage_size >> 1));
|
||||
printf (" Protocol: 0x%02x\n", info.hardware.protocol);
|
||||
printf ("Software Information:\n");
|
||||
printf (" Vendor ID: 0x%02x\n", info.software.vendor_id);
|
||||
printf (" Type: 0x%02x\n", info.software.type);
|
||||
printf (" Subtype: 0x%02x\n", info.software.subtype);
|
||||
printf (" Version: %d.%d\n", info.software.version_major, info.software.version_minor);
|
||||
printf (" Storage size: 0x%02x (%s%d bytes)\n", info.software.storage_size, (info.software.storage_size & 1) ? ">" : "=", (int)pow (2, info.software.storage_size >> 1));
|
||||
printf (" Protocol: 0x%02x\n", info.software.protocol);
|
||||
|
||||
uint8_t settings;
|
||||
uint8_t max_keys;
|
||||
res = mifare_desfire_get_key_settings (tags[i], &settings, &max_keys);
|
||||
if (res < 0) {
|
||||
warnx ("Cant' get Mifare DESFire Master Key settings: %s", mifare_desfire_error_lookup (mifare_desfire_get_last_error (tags[i])));
|
||||
error = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
printf ("Master Key settings (0x%02x):\n", settings);
|
||||
printf (" 0x%02x configuration changeable;\n", settings & 0x08);
|
||||
printf (" 0x%02x PICC Master Key not required for create / delete;\n", settings & 0x04);
|
||||
printf (" 0x%02x Free directory list access without PICC Master Key;\n", settings & 0x02);
|
||||
printf (" 0x%02x Allow changing the Master Key;\n", settings & 0x01);
|
||||
|
||||
free (tag_uid);
|
||||
|
||||
mifare_desfire_disconnect (tags[i]);
|
||||
}
|
||||
|
||||
freefare_free_tags (tags);
|
||||
nfc_disconnect (device);
|
||||
freefare_free_tags (tags);
|
||||
nfc_disconnect (device);
|
||||
}
|
||||
|
||||
exit (error);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue