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:
Romain Tartiere 2010-09-03 18:01:02 +00:00
parent 036d2956f4
commit af061a3c1a
16 changed files with 632 additions and 615 deletions

View file

@ -44,7 +44,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]));
@ -54,81 +54,81 @@ 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]);
res = mifare_desfire_connect (tags[i]);
if (res < 0) {
warnx ("Can't connect to Mifare DESFire target.");
error = EXIT_FAILURE;
break;
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;
MifareDESFireKey key = mifare_desfire_des_key_new_with_version (key_data_null);
res = mifare_desfire_authenticate (tags[i], 0, key);
if (res < 0)
errx (EXIT_FAILURE, "Authentication on master application failed");
int res;
char *tag_uid = freefare_get_tag_uid (tags[i]);
MadAid mad_aid = { 0x12, 0x34 };
MifareDESFireAID aid = mifare_desfire_aid_new_with_mad_aid (mad_aid, 0x5);
res = mifare_desfire_create_application (tags[i], aid, 0xFF, 0x1);
if (res < 0)
errx (EXIT_FAILURE, "Application creation failed");
res = mifare_desfire_connect (tags[i]);
if (res < 0) {
warnx ("Can't connect to Mifare DESFire target.");
error = EXIT_FAILURE;
break;
}
res = mifare_desfire_select_application (tags[i], aid);
if (res < 0)
errx (EXIT_FAILURE, "Application selection failed");
res = mifare_desfire_authenticate (tags[i], 0, key);
if (res < 0)
errx (EXIT_FAILURE, "Authentication on application failed");
MifareDESFireKey key = mifare_desfire_des_key_new_with_version (key_data_null);
res = mifare_desfire_authenticate (tags[i], 0, key);
if (res < 0)
errx (EXIT_FAILURE, "Authentication on master application failed");
res = mifare_desfire_create_std_data_file (tags[i], 1, MDCM_FULLDES, 0x0000, 20);
if (res < 0)
errx (EXIT_FAILURE, "File creation failed");
MadAid mad_aid = { 0x12, 0x34 };
MifareDESFireAID aid = mifare_desfire_aid_new_with_mad_aid (mad_aid, 0x5);
res = mifare_desfire_create_application (tags[i], aid, 0xFF, 0x1);
if (res < 0)
errx (EXIT_FAILURE, "Application creation failed");
char *s= "Hello World";
res = mifare_desfire_write_data (tags[i], 1, 0, strlen (s), s);
if (res < 0)
errx (EXIT_FAILURE, "File write failed");
res = mifare_desfire_select_application (tags[i], aid);
if (res < 0)
errx (EXIT_FAILURE, "Application selection failed");
char buffer[20];
res = mifare_desfire_read_data (tags[i], 1, 0, 0, buffer);
if (res < 0)
errx (EXIT_FAILURE, "File read failed");
res = mifare_desfire_authenticate (tags[i], 0, key);
if (res < 0)
errx (EXIT_FAILURE, "Authentication on application failed");
res = mifare_desfire_select_application (tags[i], NULL);
if (res < 0)
errx (EXIT_FAILURE, "Master application selection failed");
res = mifare_desfire_create_std_data_file (tags[i], 1, MDCM_FULLDES, 0x0000, 20);
if (res < 0)
errx (EXIT_FAILURE, "File creation failed");
res = mifare_desfire_authenticate (tags[i], 0, key);
if (res < 0)
errx (EXIT_FAILURE, "Authentication on master application failed");
char *s= "Hello World";
res = mifare_desfire_write_data (tags[i], 1, 0, strlen (s), s);
if (res < 0)
errx (EXIT_FAILURE, "File write failed");
res = mifare_desfire_format_picc (tags[i]);
if (res < 0)
errx (EXIT_FAILURE, "PICC format failed");
char buffer[20];
res = mifare_desfire_read_data (tags[i], 1, 0, 0, buffer);
if (res < 0)
errx (EXIT_FAILURE, "File read failed");
mifare_desfire_key_free (key);
free (tag_uid);
free (aid);
res = mifare_desfire_select_application (tags[i], NULL);
if (res < 0)
errx (EXIT_FAILURE, "Master application selection failed");
mifare_desfire_disconnect (tags[i]);
}
res = mifare_desfire_authenticate (tags[i], 0, key);
if (res < 0)
errx (EXIT_FAILURE, "Authentication on master application failed");
freefare_free_tags (tags);
nfc_disconnect (device);
res = mifare_desfire_format_picc (tags[i]);
if (res < 0)
errx (EXIT_FAILURE, "PICC format failed");
mifare_desfire_key_free (key);
free (tag_uid);
free (aid);
mifare_desfire_disconnect (tags[i]);
}
freefare_free_tags (tags);
nfc_disconnect (device);
}
exit (error);