astyle --formatted --mode=c --indent=spaces=2 --indent-switches --indent-preprocessor --keep-one-line-blocks --max-instatement-indent=60 --brackets=linux --pad-oper

This commit is contained in:
Philippe Teuwen 2012-05-29 15:54:00 +00:00
parent 67522bae65
commit 562205cc14
23 changed files with 196 additions and 196 deletions

View file

@ -274,11 +274,11 @@ static size_t
ndef_message_save (char *filename, struct nfcforum_tag4_ndef_data *tag_data)
{
FILE *F;
if (!(F= fopen (filename, "w")))
if (!(F = fopen (filename, "w")))
err (EXIT_FAILURE, "fopen (%s, w)", filename);
if (1 != fwrite (tag_data->ndef_file + 2, tag_data->ndef_file_len - 2, 1, F)) {
err (EXIT_FAILURE, "fwrite (%d)", (int) tag_data->ndef_file_len -2);
err (EXIT_FAILURE, "fwrite (%d)", (int) tag_data->ndef_file_len - 2);
}
fclose (F);

View file

@ -241,7 +241,7 @@ main (int argc, const char *argv[])
if ((res = nfc_initiator_list_passive_targets(pnd, nm, ant, MAX_TARGET_COUNT)) >= 0) {
int n;
if (verbose || (res > 0)) {
printf("%d Jewel passive target(s) found%s\n", res, (res == 0)?".\n":":");
printf("%d Jewel passive target(s) found%s\n", res, (res == 0) ? ".\n" : ":");
}
for(n = 0; n < res; n++) {
print_nfc_jewel_info (ant[n].nti.nji, verbose);

View file

@ -437,7 +437,7 @@ main (int argc, const char *argv[])
uint8_t *pbtUID;
FILE *pfKeys = NULL;
FILE *pfDump = NULL;
int unlock= 0;
int unlock = 0;
if (argc < 2) {
print_usage (argv[0]);
@ -452,8 +452,8 @@ main (int argc, const char *argv[])
}
atAction = ACTION_READ;
if (strcmp (command, "R") == 0)
unlock= 1;
bUseKeyA = tolower ((int) ((unsigned char) *(argv[2]))) == 'a';
unlock = 1;
bUseKeyA = tolower ((int) ((unsigned char) * (argv[2]))) == 'a';
bUseKeyFile = (argc > 4);
} else if (strcmp (command, "w") == 0 || strcmp (command, "W") == 0) {
if (argc < 4) {
@ -462,8 +462,8 @@ main (int argc, const char *argv[])
}
atAction = ACTION_WRITE;
if (strcmp (command, "W") == 0)
unlock= 1;
bUseKeyA = tolower ((int) ((unsigned char) *(argv[2]))) == 'a';
unlock = 1;
bUseKeyA = tolower ((int) ((unsigned char) * (argv[2]))) == 'a';
bUseKeyFile = (argc > 4);
}

View file

@ -129,12 +129,12 @@ write_card (void)
uiSkippedPages = 2;
for (int page = 0x2; page <= 0xF; page++) {
if ((page==0x2) && (!write_lock)) {
if ((page == 0x2) && (!write_lock)) {
printf ("s");
uiSkippedPages++;
continue;
}
if ((page==0x3) && (!write_otp)) {
if ((page == 0x3) && (!write_otp)) {
printf ("s");
uiSkippedPages++;
continue;
@ -183,7 +183,7 @@ main (int argc, const char *argv[])
DBG ("\nChecking arguments and settings\n");
bReadAction = tolower ((int) ((unsigned char) *(argv[1])) == 'r');
bReadAction = tolower ((int) ((unsigned char) * (argv[1])) == 'r');
if (bReadAction) {
memset (&mtDump, 0x00, sizeof (mtDump));

View file

@ -143,7 +143,7 @@ nfc_forum_tag_type3_check (nfc_device *dev, const nfc_target nt, const uint16_t
}
// const uint8_t res_block_count = res[12];
*data_len = res - res_overhead + 1; // +1 => block count is stored on 1 byte
memcpy (data, &rx[res_overhead+1], *data_len);
memcpy (data, &rx[res_overhead + 1], *data_len);
return *data_len;
}
@ -294,9 +294,9 @@ main(int argc, char *argv[])
const uint16_t block_count_to_check = (ndef_data_len / 16) + 1;
data_len = 0;
for (uint16_t b = 0; b < (block_count_to_check/block_max_per_check); b += block_max_per_check) {
for (uint16_t b = 0; b < (block_count_to_check / block_max_per_check); b += block_max_per_check) {
size_t size = sizeof(data) - data_len;
if(!nfc_forum_tag_type3_check (pnd, nt, 1+b, MIN(block_max_per_check, (block_count_to_check-(b*block_max_per_check))), data + data_len, &size)) {
if(!nfc_forum_tag_type3_check (pnd, nt, 1 + b, MIN(block_max_per_check, (block_count_to_check - (b * block_max_per_check))), data + data_len, &size)) {
nfc_perror (pnd, "nfc_forum_tag_type3_check");
error = EXIT_FAILURE;
goto error;

View file

@ -123,7 +123,7 @@ static bool scan_hex_fd3 (uint8_t *pbtData, size_t *pszBytes, const char *pchPre
char pchScan[256];
int c;
// Look for our next sync marker
while ( (c=fgetc(fd3)) != '#') {
while ( (c = fgetc(fd3)) != '#') {
if (c == EOF) {
return EXIT_FAILURE;
}
@ -133,7 +133,7 @@ static bool scan_hex_fd3 (uint8_t *pbtData, size_t *pszBytes, const char *pchPre
if (fscanf (fd3, pchScan, &uiBytes) < 1) {
return EXIT_FAILURE;
}
*pszBytes=uiBytes;
*pszBytes = uiBytes;
if (*pszBytes > MAX_FRAME_LEN) {
return EXIT_FAILURE;
}
@ -141,7 +141,7 @@ static bool scan_hex_fd3 (uint8_t *pbtData, size_t *pszBytes, const char *pchPre
if (fscanf (fd3, "%02x", &uiData) < 1) {
return EXIT_FAILURE;
}
pbtData[szPos]=uiData;
pbtData[szPos] = uiData;
}
return EXIT_SUCCESS;
}
@ -322,7 +322,7 @@ main (int argc, char *argv[])
}
// We can only emulate a short UID, so fix length & ATQA bit:
ntEmulatedTarget.nti.nai.szUidLen = 4;
ntEmulatedTarget.nti.nai.abtAtqa[1] &= (0xFF-0x40);
ntEmulatedTarget.nti.nai.abtAtqa[1] &= (0xFF - 0x40);
// First byte of UID is always automatically replaced by 0x08 in this mode anyway
ntEmulatedTarget.nti.nai.abtUid[0] = 0x08;
// ATS is always automatically replaced by PN532, we've no control on it:

View file

@ -93,7 +93,7 @@ struct card_atqa const_ca[] = {
},
{
0x0044, 0xffff, "P3SR008",
{-1}
{ -1}
}, // TODO we need SAK info
{
0x0004, 0xf0ff, "SmartMX with MIFARE 1K emulation",
@ -213,7 +213,7 @@ print_nfc_iso14443a_info (const nfc_iso14443a_info nai, bool verbose)
print_hex (nai.abtAtqa, 2);
if (verbose) {
printf("* UID size: ");
switch ((nai.abtAtqa[1] & 0xc0)>>6) {
switch ((nai.abtAtqa[1] & 0xc0) >> 6) {
case 0:
printf("single\n");
break;
@ -282,39 +282,39 @@ print_nfc_iso14443a_info (const nfc_iso14443a_info nai, bool verbose)
if (TA == 0) {
printf (" * PICC supports only 106 kbits/s in both directions\n");
}
if (TA & 1<<7) {
if (TA & 1 << 7) {
printf (" * Same bitrate in both directions mandatory\n");
}
if (TA & 1<<4) {
if (TA & 1 << 4) {
printf (" * PICC to PCD, DS=2, bitrate 212 kbits/s supported\n");
}
if (TA & 1<<5) {
if (TA & 1 << 5) {
printf (" * PICC to PCD, DS=4, bitrate 424 kbits/s supported\n");
}
if (TA & 1<<6) {
if (TA & 1 << 6) {
printf (" * PICC to PCD, DS=8, bitrate 847 kbits/s supported\n");
}
if (TA & 1<<0) {
if (TA & 1 << 0) {
printf (" * PCD to PICC, DR=2, bitrate 212 kbits/s supported\n");
}
if (TA & 1<<1) {
if (TA & 1 << 1) {
printf (" * PCD to PICC, DR=4, bitrate 424 kbits/s supported\n");
}
if (TA & 1<<2) {
if (TA & 1 << 2) {
printf (" * PCD to PICC, DR=8, bitrate 847 kbits/s supported\n");
}
if (TA & 1<<3) {
if (TA & 1 << 3) {
printf (" * ERROR unknown value\n");
}
}
if (nai.abtAts[0] & 0x20) { // TB(1) present
uint8_t TB= nai.abtAts[offset];
uint8_t TB = nai.abtAts[offset];
offset++;
printf ("* Frame Waiting Time: %.4g ms\n",256.0*16.0*(1<<((TB & 0xf0) >> 4))/13560.0);
printf ("* Frame Waiting Time: %.4g ms\n", 256.0 * 16.0 * (1 << ((TB & 0xf0) >> 4)) / 13560.0);
if ((TB & 0x0f) == 0) {
printf ("* No Start-up Frame Guard Time required\n");
} else {
printf ("* Start-up Frame Guard Time: %.4g ms\n",256.0*16.0*(1<<(TB & 0x0f))/13560.0);
printf ("* Start-up Frame Guard Time: %.4g ms\n", 256.0 * 16.0 * (1 << (TB & 0x0f)) / 13560.0);
}
}
if (nai.abtAts[0] & 0x40) { // TC(1) present
@ -473,11 +473,11 @@ print_nfc_iso14443a_info (const nfc_iso14443a_info nai, bool verbose)
uint8_t i, j;
bool found_possible_match = false;
atqa = (((uint16_t)nai.abtAtqa[0] & 0xff)<<8);
atqa = (((uint16_t)nai.abtAtqa[0] & 0xff) << 8);
atqa += (((uint16_t)nai.abtAtqa[1] & 0xff));
sak = ((uint8_t)nai.btSak & 0xff);
for (i = 0; i < sizeof(const_ca)/sizeof(const_ca[0]); i++) {
for (i = 0; i < sizeof(const_ca) / sizeof(const_ca[0]); i++) {
if ((atqa & const_ca[i].mask) == const_ca[i].atqa) {
for (j = 0; (j < sizeof(const_ca[i].saklist)) && (const_ca[i].saklist[j] >= 0); j++) {
int sakindex = const_ca[i].saklist[j];
@ -493,8 +493,8 @@ print_nfc_iso14443a_info (const nfc_iso14443a_info nai, bool verbose)
// but seen in the field:
printf("Other possible matches based on ATQA & SAK values:\n");
uint32_t atqasak = 0;
atqasak += (((uint32_t)nai.abtAtqa[0] & 0xff)<<16);
atqasak += (((uint32_t)nai.abtAtqa[1] & 0xff)<<8);
atqasak += (((uint32_t)nai.abtAtqa[0] & 0xff) << 16);
atqasak += (((uint32_t)nai.abtAtqa[1] & 0xff) << 8);
atqasak += ((uint32_t)nai.btSak & 0xff);
switch (atqasak) {
case 0x000488:
@ -581,28 +581,28 @@ print_nfc_iso14443b_info (const nfc_iso14443b_info nbi, bool verbose)
if (nbi.abtProtocolInfo[0] == 0) {
printf (" * PICC supports only 106 kbits/s in both directions\n");
}
if (nbi.abtProtocolInfo[0] & 1<<7) {
if (nbi.abtProtocolInfo[0] & 1 << 7) {
printf (" * Same bitrate in both directions mandatory\n");
}
if (nbi.abtProtocolInfo[0] & 1<<4) {
if (nbi.abtProtocolInfo[0] & 1 << 4) {
printf (" * PICC to PCD, 1etu=64/fc, bitrate 212 kbits/s supported\n");
}
if (nbi.abtProtocolInfo[0] & 1<<5) {
if (nbi.abtProtocolInfo[0] & 1 << 5) {
printf (" * PICC to PCD, 1etu=32/fc, bitrate 424 kbits/s supported\n");
}
if (nbi.abtProtocolInfo[0] & 1<<6) {
if (nbi.abtProtocolInfo[0] & 1 << 6) {
printf (" * PICC to PCD, 1etu=16/fc, bitrate 847 kbits/s supported\n");
}
if (nbi.abtProtocolInfo[0] & 1<<0) {
if (nbi.abtProtocolInfo[0] & 1 << 0) {
printf (" * PCD to PICC, 1etu=64/fc, bitrate 212 kbits/s supported\n");
}
if (nbi.abtProtocolInfo[0] & 1<<1) {
if (nbi.abtProtocolInfo[0] & 1 << 1) {
printf (" * PCD to PICC, 1etu=32/fc, bitrate 424 kbits/s supported\n");
}
if (nbi.abtProtocolInfo[0] & 1<<2) {
if (nbi.abtProtocolInfo[0] & 1 << 2) {
printf (" * PCD to PICC, 1etu=16/fc, bitrate 847 kbits/s supported\n");
}
if (nbi.abtProtocolInfo[0] & 1<<3) {
if (nbi.abtProtocolInfo[0] & 1 << 3) {
printf (" * ERROR unknown value\n");
}
if( (nbi.abtProtocolInfo[1] & 0xf0) <= 0x80 ) {
@ -611,8 +611,8 @@ print_nfc_iso14443b_info (const nfc_iso14443b_info nbi, bool verbose)
if((nbi.abtProtocolInfo[1] & 0x0f) == PI_ISO14443_4_SUPPORTED) {
printf ("* Protocol types supported: ISO/IEC 14443-4\n");
}
printf ("* Frame Waiting Time: %.4g ms\n",256.0*16.0*(1<<((nbi.abtProtocolInfo[2] & 0xf0) >> 4))/13560.0);
if((nbi.abtProtocolInfo[2] & (PI_NAD_SUPPORTED|PI_CID_SUPPORTED)) != 0) {
printf ("* Frame Waiting Time: %.4g ms\n", 256.0 * 16.0 * (1 << ((nbi.abtProtocolInfo[2] & 0xf0) >> 4)) / 13560.0);
if((nbi.abtProtocolInfo[2] & (PI_NAD_SUPPORTED | PI_CID_SUPPORTED)) != 0) {
printf ("* Frame options supported: ");
if ((nbi.abtProtocolInfo[2] & PI_NAD_SUPPORTED) != 0) printf ("NAD ");
if ((nbi.abtProtocolInfo[2] & PI_CID_SUPPORTED) != 0) printf ("CID ");
@ -627,7 +627,7 @@ print_nfc_iso14443bi_info (const nfc_iso14443bi_info nii, bool verbose)
printf (" DIV: ");
print_hex (nii.abtDIV, 4);
if (verbose) {
int version = (nii.btVerLog & 0x1e)>>1;
int version = (nii.btVerLog & 0x1e) >> 1;
printf (" Software Version: ");
if (version == 15) {
printf ("Undefined\n");
@ -685,7 +685,7 @@ print_nfc_dep_info (const nfc_dep_info ndi, bool verbose)
void
print_nfc_target (const nfc_target nt, bool verbose)
{
printf ("%s (%s%s) target:\n", str_nfc_modulation_type(nt.nm.nmt), str_nfc_baud_rate(nt.nm.nbr), (nt.nm.nmt!=NMT_DEP)?"":(nt.nti.ndi.ndm == NDM_ACTIVE)? "active mode" : "passive mode");
printf ("%s (%s%s) target:\n", str_nfc_modulation_type(nt.nm.nmt), str_nfc_baud_rate(nt.nm.nbr), (nt.nm.nmt != NMT_DEP) ? "" : (nt.nti.ndi.ndm == NDM_ACTIVE) ? "active mode" : "passive mode");
switch(nt.nm.nmt) {
case NMT_ISO14443A:
print_nfc_iso14443a_info (nt.nti.nai, verbose);