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

@ -49,9 +49,9 @@ freefare_tag_new (nfc_device_t *device, nfc_iso14443a_info_t nai)
/* Ensure the target is supported */
for (size_t i = 0; i < sizeof (supported_tags) / sizeof (struct supported_tag); i++) {
if (((nai.szUidLen == 4) || (nai.abtUid[0] == NXP_MANUFACTURER_CODE)) &&
(nai.btSak == supported_tags[i].SAK) &&
(nai.szAtsLen == supported_tags[i].ATS_length) &&
(0 == memcmp (nai.abtAts, supported_tags[i].ATS, supported_tags[i].ATS_length))) {
(nai.btSak == supported_tags[i].SAK) &&
(nai.szAtsLen == supported_tags[i].ATS_length) &&
(0 == memcmp (nai.abtAts, supported_tags[i].ATS, supported_tags[i].ATS_length))) {
tag_info = &(supported_tags[i]);
found = true;

View file

@ -85,8 +85,9 @@
DEBUG_XFER (msg, __##msg##_n, "===> "); \
if (!(nfc_initiator_transceive_bytes (tag->device, msg, __##msg##_n, res, &__##res##_n))) { \
nfc_perror (tag->device, __FUNCTION__); \
if (disconnect) \
if (disconnect) { \
tag->active = false; \
} \
return errno = EIO, -1; \
} \
DEBUG_XFER (res, __##res##_n, "<=== "); \
@ -120,56 +121,56 @@ union mifare_classic_block {
typedef unsigned char MifareClassicAccessBits;
unsigned char mifare_data_access_permissions[] = {
/*
* [ Key A ] [ Key B ]
* | |
* ,----------- r(ead) |
* |,---------- w(rite) |
* ||,--------- d(ecrement) |
* |||,-------- i(ncrement) |
* |||| |
* |||| ,------------------------ r
* ,----- C3 |||| |,----------------------- w
* |,---- C2 |||| ||,---------------------- d
* ||,--- C1 |||| |||,--------------------- i
* ||| |||| ||||
* 0b000 0b 1111 1111 */ 0xff, /* Default (blank card) */
/* 0b001 0b 1000 1100 */ 0x8c,
/* 0b010 0b 1000 1000 */ 0x88,
/* 0b011 0b 1010 1111 */ 0xaf,
/* 0b100 0b 1010 1010 */ 0xaa,
/* 0b101 0b 0000 1000 */ 0x08,
/* 0b110 0b 0000 1100 */ 0x0c,
/* 0b111 0b 0000 0000 */ 0x00
/*
* [ Key A ] [ Key B ]
* | |
* ,----------- r(ead) |
* |,---------- w(rite) |
* ||,--------- d(ecrement) |
* |||,-------- i(ncrement) |
* |||| |
* |||| ,------------------------ r
* ,----- C3 |||| |,----------------------- w
* |,---- C2 |||| ||,---------------------- d
* ||,--- C1 |||| |||,--------------------- i
* ||| |||| ||||
* 0b000 0b 1111 1111 */ 0xff, /* Default (blank card) */
/* 0b001 0b 1000 1100 */ 0x8c,
/* 0b010 0b 1000 1000 */ 0x88,
/* 0b011 0b 1010 1111 */ 0xaf,
/* 0b100 0b 1010 1010 */ 0xaa,
/* 0b101 0b 0000 1000 */ 0x08,
/* 0b110 0b 0000 1100 */ 0x0c,
/* 0b111 0b 0000 0000 */ 0x00
};
uint16_t mifare_trailer_access_permissions[] = {
/*
* [ Key A ] [ Access bits ] [ Key B ]
* | | |
* ,----------- read A | |
* |,---------- read B | |
* ||,--------- write A | |
* |||,-------- write B | |
* |||| | |
* |||| ,----------------------- read A |
* |||| |,---------------------- read B |
* |||| ||,--------------------- write A |
* |||| |||,-------------------- write B |
* |||| |||| |
* |||| |||| ,----------------------------------- read A
* ,----- C3 |||| |||| |,---------------------------------- read B
* |,---- C2 |||| |||| ||,--------------------------------- write A
* ||,--- C1 |||| |||| |||,-------------------------------- write B
* ||| |||| |||| ||||
* 0b000 0b 0010 1000 1010*/ 0x28a,
/* 0b001 0b 0001 1100 0001*/ 0x1c1,
/* 0b010 0b 0000 1000 1000*/ 0x088,
/* 0b011 0b 0000 1100 0000*/ 0x0c0,
/* 0b100 0b 0010 1010 1010*/ 0x2aa, /* Default (blank card) */
/* 0b101 0b 0000 1101 0000*/ 0x0d0,
/* 0b110 0b 0001 1101 0001*/ 0x1d1,
/* 0b111 0b 0000 1100 0000*/ 0x0c0
/*
* [ Key A ] [ Access bits ] [ Key B ]
* | | |
* ,----------- read A | |
* |,---------- read B | |
* ||,--------- write A | |
* |||,-------- write B | |
* |||| | |
* |||| ,----------------------- read A |
* |||| |,---------------------- read B |
* |||| ||,--------------------- write A |
* |||| |||,-------------------- write B |
* |||| |||| |
* |||| |||| ,----------------------------------- read A
* ,----- C3 |||| |||| |,---------------------------------- read B
* |,---- C2 |||| |||| ||,--------------------------------- write A
* ||,--- C1 |||| |||| |||,-------------------------------- write B
* ||| |||| |||| ||||
* 0b000 0b 0010 1000 1010*/ 0x28a,
/* 0b001 0b 0001 1100 0001*/ 0x1c1,
/* 0b010 0b 0000 1000 1000*/ 0x088,
/* 0b011 0b 0000 1100 0000*/ 0x0c0,
/* 0b100 0b 0010 1010 1010*/ 0x2aa, /* Default (blank card) */
/* 0b101 0b 0000 1101 0000*/ 0x0d0,
/* 0b110 0b 0001 1101 0001*/ 0x1d1,
/* 0b111 0b 0000 1100 0000*/ 0x0c0
};
@ -543,7 +544,7 @@ get_block_access_bits (MifareTag tag, const MifareClassicBlockNumber block, Mifa
*/
if (MIFARE_CLASSIC(tag)->cached_access_bits.sector_trailer_block_number == trailer) {
/* cache hit! */
sector_access_bits = MIFARE_CLASSIC(tag)->cached_access_bits.sector_access_bits;
sector_access_bits = MIFARE_CLASSIC(tag)->cached_access_bits.sector_access_bits;
} else {
MifareClassicBlock trailer_data;
@ -561,7 +562,7 @@ get_block_access_bits (MifareTag tag, const MifareClassicBlockNumber block, Mifa
}
MIFARE_CLASSIC(tag)->cached_access_bits.sector_trailer_block_number = trailer;
MIFARE_CLASSIC(tag)->cached_access_bits.block_number = -1;
MIFARE_CLASSIC(tag)->cached_access_bits.sector_access_bits = sector_access_bits;
MIFARE_CLASSIC(tag)->cached_access_bits.sector_access_bits = sector_access_bits;
}
/*
@ -730,7 +731,7 @@ MifareClassicBlockNumber
mifare_classic_sector_last_block (MifareClassicSectorNumber sector)
{
return mifare_classic_sector_first_block (sector) +
mifare_classic_sector_block_count (sector) - 1;
mifare_classic_sector_block_count (sector) - 1;
}
/*

View file

@ -93,8 +93,9 @@ static ssize_t read_data (MifareTag tag, uint8_t command, uint8_t file_no, off_
#define ASSERT_AUTHENTICATED(tag) \
do { \
if (MIFARE_DESFIRE (tag)->authenticated_key_no == NOT_YET_AUTHENTICATED) \
if (MIFARE_DESFIRE (tag)->authenticated_key_no == NOT_YET_AUTHENTICATED) { \
return errno = EINVAL, -1;\
} \
} while (0)
/*
@ -103,18 +104,20 @@ static ssize_t read_data (MifareTag tag, uint8_t command, uint8_t file_no, off_
*/
#define ASSERT_CS(cs) \
do { \
if (cs < 0) \
if (cs < 0) { \
return errno = EINVAL, -1; \
if (cs == 0x02) \
} else if (cs == 0x02) { \
return errno = EINVAL, -1; \
if (cs > 0x03) \
} else if (cs > 0x03) { \
return errno = EINVAL, -1; \
} \
} while (0)
#define ASSERT_NOT_NULL(argument) \
do { \
if (!argument) \
if (!argument) { \
return errno = EINVAL, -1; \
} \
} while (0)
@ -144,8 +147,9 @@ static ssize_t read_data (MifareTag tag, uint8_t command, uint8_t file_no, off_
errno = 0; \
MIFARE_DESFIRE (tag)->last_picc_error = OPERATION_OK; \
DEBUG_XFER (__##msg, __##msg##_n+1, "===> "); \
if (!(nfc_initiator_transceive_bytes (tag->device, __##msg, __##msg##_n+1, __##res, &__##res##_n))) \
if (!(nfc_initiator_transceive_bytes (tag->device, __##msg, __##msg##_n+1, __##res, &__##res##_n))) { \
return errno = EIO, -1; \
} \
DEBUG_XFER (__##res, __##res##_n, "<=== "); \
__##res##_n -= 1; \
while (__##res[0] == 0xf2) { \
@ -157,8 +161,9 @@ static ssize_t read_data (MifareTag tag, uint8_t command, uint8_t file_no, off_
DEBUG_XFER (__##res, __##res##_n, "<=== "); \
__##res##_n -= 1; \
} \
if ((1 == __##res##_n) && (OPERATION_OK != res[0]) && (ADDITIONAL_FRAME != res[0])) \
if ((1 == __##res##_n) && (OPERATION_OK != res[0]) && (ADDITIONAL_FRAME != res[0])) { \
return MIFARE_DESFIRE (tag)->last_picc_error = res[0], -1; \
} \
} while (0)
@ -717,7 +722,7 @@ mifare_desfire_get_file_settings (MifareTag tag, uint8_t file_no, struct mifare_
settings->file_type = raw_settings.file_type;
settings->communication_settings = raw_settings.communication_settings;
settings->access_rights = le16toh (raw_settings.access_rights);
switch (settings->file_type) {
case MDFT_STANDARD_DATA_FILE:
case MDFT_BACKUP_DATA_FILE:
@ -757,15 +762,15 @@ mifare_desfire_change_file_settings (MifareTag tag, uint8_t file_no, uint8_t com
cached_file_settings_current[file_no] = false;
if (MDAR_CHANGE_AR(settings.access_rights) == MDAR_FREE) {
BUFFER_INIT (cmd, 5);
BUFFER_INIT (res, 1);
BUFFER_INIT (cmd, 5);
BUFFER_INIT (res, 1);
BUFFER_APPEND (cmd, 0x5F);
BUFFER_APPEND (cmd, file_no);
BUFFER_APPEND (cmd, communication_settings);
BUFFER_APPEND_LE (cmd, access_rights, 2, sizeof (uint16_t));
BUFFER_APPEND (cmd, 0x5F);
BUFFER_APPEND (cmd, file_no);
BUFFER_APPEND (cmd, communication_settings);
BUFFER_APPEND_LE (cmd, access_rights, 2, sizeof (uint16_t));
DESFIRE_TRANSCEIVE (tag, cmd, res);
DESFIRE_TRANSCEIVE (tag, cmd, res);
} else {
BUFFER_INIT (cmd, 10);
BUFFER_INIT (res, 1);
@ -946,8 +951,8 @@ read_data (MifareTag tag, uint8_t command, uint8_t file_no, off_t offset, size_t
return -1;
}
BUFFER_CLEAR (cmd);
BUFFER_APPEND (cmd, 0xAF);
BUFFER_CLEAR (cmd);
BUFFER_APPEND (cmd, 0xAF);
}
} while (res[0] != 0x00);

View file

@ -56,7 +56,7 @@ mifare_desfire_aid_new (uint32_t aid)
uint32_t aid_le = htole32 (aid);
if ((res = malloc (sizeof (*res)))) {
memcpy(res->data, ((uint8_t*)&aid_le), 3);
memcpy(res->data, ((uint8_t*)&aid_le), 3);
}
return res;

View file

@ -256,7 +256,7 @@ mifare_des (MifareDESFireKey key, uint8_t *data, uint8_t *ivect, MifareDirection
if (mac) {
DES_ecb_encrypt ((DES_cblock *) data, (DES_cblock *) edata, &(key->ks1), DES_ENCRYPT);
} else {
DES_ecb_encrypt ((DES_cblock *) data, (DES_cblock *) edata, &(key->ks1), DES_DECRYPT);
DES_ecb_encrypt ((DES_cblock *) data, (DES_cblock *) edata, &(key->ks1), DES_DECRYPT);
}
memcpy (data, edata, 8);
break;
@ -266,9 +266,9 @@ mifare_des (MifareDESFireKey key, uint8_t *data, uint8_t *ivect, MifareDirection
DES_ecb_encrypt ((DES_cblock *) edata, (DES_cblock *) data, &(key->ks2), DES_DECRYPT);
DES_ecb_encrypt ((DES_cblock *) data, (DES_cblock *) edata, &(key->ks1), DES_ENCRYPT);
} else {
DES_ecb_encrypt ((DES_cblock *) data, (DES_cblock *) edata, &(key->ks1), DES_DECRYPT);
DES_ecb_encrypt ((DES_cblock *) edata, (DES_cblock *) data, &(key->ks2), DES_ENCRYPT);
DES_ecb_encrypt ((DES_cblock *) data, (DES_cblock *) edata, &(key->ks1), DES_DECRYPT);
DES_ecb_encrypt ((DES_cblock *) data, (DES_cblock *) edata, &(key->ks1), DES_DECRYPT);
DES_ecb_encrypt ((DES_cblock *) edata, (DES_cblock *) data, &(key->ks2), DES_ENCRYPT);
DES_ecb_encrypt ((DES_cblock *) data, (DES_cblock *) edata, &(key->ks1), DES_DECRYPT);
}
memcpy (data, edata, 8);
break;

View file

@ -73,7 +73,7 @@ tlv_encode (const uint8_t type, const uint8_t *istream, uint16_t isize, size_t *
return NULL;
if ((res = malloc (1 + ((isize > 254) ? 3 : 1) + isize + 1))) {
/* type + size + payload + terminator */
/* type + size + payload + terminator */
res[n++] = type;
if (isize > 254) {