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
|
@ -139,7 +139,8 @@ main(int argc, char *argv[])
|
|||
// Mapping Version equal to 10h,MLe equal to 003Bh, MLc equal to 0034h, and NDEF File Control TLV
|
||||
// equal to T =04h, L=06h, V=E1 04 (NDEF ISO FID=E104h) 0E E0 (NDEF File size =3808 Bytes) 00 (free read access)
|
||||
// 00 free write access
|
||||
byte_t capability_container_file_content[15] = { 0x00, 0x0F, // CCLEN: Size of this capability container.CCLEN values are between 000Fh and FFFEh
|
||||
byte_t capability_container_file_content[15] = {
|
||||
0x00, 0x0F, // CCLEN: Size of this capability container.CCLEN values are between 000Fh and FFFEh
|
||||
0x10, // Mapping version
|
||||
0x00, 0x3B, // MLe: Maximum data size that can be read using a single ReadBinary command. MLe = 000Fh-FFFFh
|
||||
0x00, 0x34, // MLc: Maximum data size that can be sent using a single UpdateBinary command. MLc = 0001h-FFFFh
|
||||
|
|
|
@ -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,7 +121,7 @@ union mifare_classic_block {
|
|||
typedef unsigned char MifareClassicAccessBits;
|
||||
|
||||
unsigned char mifare_data_access_permissions[] = {
|
||||
/*
|
||||
/*
|
||||
* [ Key A ] [ Key B ]
|
||||
* | |
|
||||
* ,----------- r(ead) |
|
||||
|
@ -134,17 +135,17 @@ unsigned char mifare_data_access_permissions[] = {
|
|||
* ||,--- 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
|
||||
/* 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 | |
|
||||
|
@ -163,13 +164,13 @@ uint16_t mifare_trailer_access_permissions[] = {
|
|||
* ||,--- 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
|
||||
/* 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
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
||||
|
|
|
@ -57,10 +57,14 @@ test_mifare_classic_mad (void)
|
|||
|
||||
|
||||
// Check the empty MAD
|
||||
MifareClassicBlock ref_01 = { 0xce, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
MifareClassicBlock ref_02 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
MifareClassicBlock ref_01 = {
|
||||
0xce, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
MifareClassicBlock ref_02 = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
MifareClassicBlock data;
|
||||
|
||||
res = mifare_classic_authenticate (tag, 0x01, mad_public_key_a, MFC_KEY_A);
|
||||
|
@ -78,11 +82,11 @@ test_mifare_classic_mad (void)
|
|||
cut_assert_not_null (mad2, cut_message ("mad_read() failed"));
|
||||
cut_assert_equal_memory (mad, sizeof (mad), mad2, sizeof (mad2), cut_message ("Wrong MAD"));
|
||||
|
||||
const char application_data[] = "APPLICATION DATA >> APPLICATION DATA >> APPLICATION DATA >> "
|
||||
"APPLICATION DATA >> APPLICATION DATA >> APPLICATION DATA >> "
|
||||
"APPLICATION DATA >> APPLICATION DATA >> APPLICATION DATA >> "
|
||||
"APPLICATION DATA >> APPLICATION DATA >> APPLICATION DATA >> "
|
||||
"APPLICATION DATA >> APPLICATION DATA >> APPLICATION DATA >> "
|
||||
const char application_data[] = "APPLICATION DATA >> APPLICATION DATA >> APPLICATION DATA >> " \
|
||||
"APPLICATION DATA >> APPLICATION DATA >> APPLICATION DATA >> " \
|
||||
"APPLICATION DATA >> APPLICATION DATA >> APPLICATION DATA >> " \
|
||||
"APPLICATION DATA >> APPLICATION DATA >> APPLICATION DATA >> " \
|
||||
"APPLICATION DATA >> APPLICATION DATA >> APPLICATION DATA >> " \
|
||||
"APPLICATION DATA >> APPLICATION DATA >> APPLICATION DATA >> ";
|
||||
|
||||
MadAid aid = {
|
||||
|
@ -164,12 +168,18 @@ test_mifare_classic_mad (void)
|
|||
cut_assert_equal_int (0, res, cut_message ("mad_read() failed"));
|
||||
cut_assert_equal_memory (ref_02, sizeof (ref_02), data, sizeof (data), cut_message ("Wrong data"));
|
||||
|
||||
MifareClassicBlock ref_40 = { 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
MifareClassicBlock ref_41 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
MifareClassicBlock ref_42 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
MifareClassicBlock ref_40 = {
|
||||
0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
MifareClassicBlock ref_41 = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
MifareClassicBlock ref_42 = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
res = mifare_classic_authenticate (tag, 0x40, mad_public_key_a, MFC_KEY_A);
|
||||
cut_assert_equal_int (0, res, cut_message ("mifare_classic_authenticate() failed"));
|
||||
|
|
|
@ -24,40 +24,40 @@
|
|||
const uint8_t shortdata[8] = "elephant";
|
||||
const uint8_t eshortdata[11] = "\x03" "\x08" "elephant" "\xfe";
|
||||
|
||||
/*
|
||||
/*
|
||||
* Many thanks to Charles Baudelaire for helping me
|
||||
* test things and helping you realize your f**king
|
||||
* OS / compiler does not support UTF-8 ;-)
|
||||
*/
|
||||
const uint8_t longdata[660] = "Dans une terre grasse et pleine d'escargots\n"
|
||||
"Je veux creuser moi-même une fosse profonde,\n"
|
||||
"Où je puisse à loisir étaler mes vieux os\n"
|
||||
"Et dormir dans l'oubli comme un requin dans l'onde.\n"
|
||||
"Je hais les testaments et je hais les tombeaux;\n"
|
||||
"Plutôt que d'implorer une larme du monde,\n"
|
||||
"Vivant, j'aimerais mieux inviter les corbeaux\n"
|
||||
"À saigner tous les bouts de ma carcasse immonde.\n"
|
||||
"Ô vers! noirs compagnons sans oreille et sans yeux,\n"
|
||||
"Voyez venir à vous un mort libre et joyeux;\n"
|
||||
"Philosophes viveurs, fils de la pourriture,\n"
|
||||
"À travers ma ruine allez donc sans remords,\n"
|
||||
"Et dites-moi s'il est encor quelque torture\n"
|
||||
const uint8_t longdata[660] = "Dans une terre grasse et pleine d'escargots\n" \
|
||||
"Je veux creuser moi-même une fosse profonde,\n" \
|
||||
"Où je puisse à loisir étaler mes vieux os\n" \
|
||||
"Et dormir dans l'oubli comme un requin dans l'onde.\n" \
|
||||
"Je hais les testaments et je hais les tombeaux;\n" \
|
||||
"Plutôt que d'implorer une larme du monde,\n" \
|
||||
"Vivant, j'aimerais mieux inviter les corbeaux\n" \
|
||||
"À saigner tous les bouts de ma carcasse immonde.\n" \
|
||||
"Ô vers! noirs compagnons sans oreille et sans yeux,\n" \
|
||||
"Voyez venir à vous un mort libre et joyeux;\n" \
|
||||
"Philosophes viveurs, fils de la pourriture,\n" \
|
||||
"À travers ma ruine allez donc sans remords,\n" \
|
||||
"Et dites-moi s'il est encor quelque torture\n" \
|
||||
"Pour ce vieux corps sans âme et mort parmi les morts!\n";
|
||||
|
||||
const uint8_t elongdata[665] = "\x07" "\xff\x02\x94"
|
||||
"Dans une terre grasse et pleine d'escargots\n"
|
||||
"Je veux creuser moi-même une fosse profonde,\n"
|
||||
"Où je puisse à loisir étaler mes vieux os\n"
|
||||
"Et dormir dans l'oubli comme un requin dans l'onde.\n"
|
||||
"Je hais les testaments et je hais les tombeaux;\n"
|
||||
"Plutôt que d'implorer une larme du monde,\n"
|
||||
"Vivant, j'aimerais mieux inviter les corbeaux\n"
|
||||
"À saigner tous les bouts de ma carcasse immonde.\n"
|
||||
"Ô vers! noirs compagnons sans oreille et sans yeux,\n"
|
||||
"Voyez venir à vous un mort libre et joyeux;\n"
|
||||
"Philosophes viveurs, fils de la pourriture,\n"
|
||||
"À travers ma ruine allez donc sans remords,\n"
|
||||
"Et dites-moi s'il est encor quelque torture\n"
|
||||
const uint8_t elongdata[665] = "\x07" "\xff\x02\x94" \
|
||||
"Dans une terre grasse et pleine d'escargots\n" \
|
||||
"Je veux creuser moi-même une fosse profonde,\n" \
|
||||
"Où je puisse à loisir étaler mes vieux os\n" \
|
||||
"Et dormir dans l'oubli comme un requin dans l'onde.\n" \
|
||||
"Je hais les testaments et je hais les tombeaux;\n" \
|
||||
"Plutôt que d'implorer une larme du monde,\n" \
|
||||
"Vivant, j'aimerais mieux inviter les corbeaux\n" \
|
||||
"À saigner tous les bouts de ma carcasse immonde.\n" \
|
||||
"Ô vers! noirs compagnons sans oreille et sans yeux,\n" \
|
||||
"Voyez venir à vous un mort libre et joyeux;\n" \
|
||||
"Philosophes viveurs, fils de la pourriture,\n" \
|
||||
"À travers ma ruine allez donc sans remords,\n" \
|
||||
"Et dites-moi s'il est encor quelque torture\n" \
|
||||
"Pour ce vieux corps sans âme et mort parmi les morts!\n"
|
||||
"\xfe";
|
||||
|
||||
|
|
Loading…
Reference in a new issue