astyle --formatted --mode=c --indent=spaces=2 --indent-switches --indent-preprocessor --keep-one-line-blocks --max-instatement-indent=60
This commit is contained in:
parent
26569c2202
commit
a2cd236441
45 changed files with 1096 additions and 1082 deletions
|
|
@ -277,13 +277,13 @@ main (int argc, char *argv[])
|
|||
|
||||
// Request ATS, this only applies to tags that support ISO 14443A-4
|
||||
if (abtRx[0] & SAK_FLAG_ATS_SUPPORTED) {
|
||||
iso_ats_supported = true;
|
||||
iso_ats_supported = true;
|
||||
}
|
||||
if ((abtRx[0] & SAK_FLAG_ATS_SUPPORTED) || force_rats) {
|
||||
iso14443a_crc_append(abtRats, 2);
|
||||
if (transmit_bytes (abtRats, 4)) {
|
||||
memcpy (abtAts, abtRx, szRx);
|
||||
szAts = szRx;
|
||||
memcpy (abtAts, abtRx, szRx);
|
||||
szAts = szRx;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -295,25 +295,25 @@ main (int argc, char *argv[])
|
|||
switch (szCL) {
|
||||
case 1:
|
||||
printf ("%02x%02x%02x%02x", abtRawUid[0], abtRawUid[1], abtRawUid[2], abtRawUid[3]);
|
||||
break;
|
||||
break;
|
||||
case 2:
|
||||
printf ("%02x%02x%02x", abtRawUid[1], abtRawUid[2], abtRawUid[3]);
|
||||
printf ("%02x%02x%02x%02x", abtRawUid[4], abtRawUid[5], abtRawUid[6], abtRawUid[7]);
|
||||
break;
|
||||
break;
|
||||
case 3:
|
||||
printf ("%02x%02x%02x", abtRawUid[1], abtRawUid[2], abtRawUid[3]);
|
||||
printf ("%02x%02x%02x", abtRawUid[5], abtRawUid[6], abtRawUid[7]);
|
||||
printf ("%02x%02x%02x%02x", abtRawUid[8], abtRawUid[9], abtRawUid[10], abtRawUid[11]);
|
||||
break;
|
||||
break;
|
||||
}
|
||||
printf("\n");
|
||||
printf("ATQA: %02x%02x\n SAK: %02x\n", abtAtqa[1], abtAtqa[0], abtSak);
|
||||
if (szAts > 1) { // if = 1, it's not actual ATS but error code
|
||||
if (force_rats && ! iso_ats_supported) {
|
||||
printf(" RATS forced\n");
|
||||
}
|
||||
printf(" ATS: ");
|
||||
print_hex (abtAts, szAts);
|
||||
if (force_rats && ! iso_ats_supported) {
|
||||
printf(" RATS forced\n");
|
||||
}
|
||||
printf(" ATS: ");
|
||||
print_hex (abtAts, szAts);
|
||||
}
|
||||
|
||||
nfc_close (pnd);
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ main (int argc, const char *argv[])
|
|||
uint8_t abtRx[MAX_FRAME_LEN];
|
||||
int szRx;
|
||||
uint8_t abtTx[] = "Hello Mars!";
|
||||
#define MAX_DEVICE_COUNT 2
|
||||
#define MAX_DEVICE_COUNT 2
|
||||
nfc_connstring connstrings[MAX_DEVICE_COUNT];
|
||||
size_t szDeviceFound = nfc_list_devices (NULL, connstrings, MAX_DEVICE_COUNT);
|
||||
// Little hack to allow using nfc-dep-initiator & nfc-dep-target from
|
||||
|
|
@ -96,7 +96,7 @@ main (int argc, const char *argv[])
|
|||
.abtNFCID3 = { 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xff, 0x00, 0x00 },
|
||||
.szGB = 4,
|
||||
.abtGB = { 0x12, 0x34, 0x56, 0x78 },
|
||||
.ndm = NDM_UNDEFINED,
|
||||
.ndm = NDM_UNDEFINED,
|
||||
/* These bytes are not used by nfc_target_init: the chip will provide them automatically to the initiator */
|
||||
.btDID = 0x00,
|
||||
.btBS = 0x00,
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ stop_emulation (int sig)
|
|||
{
|
||||
(void)sig;
|
||||
if (pnd) {
|
||||
nfc_abort_command(pnd);
|
||||
nfc_abort_command(pnd);
|
||||
} else {
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -178,27 +178,27 @@ main (int argc, char *argv[])
|
|||
if ((szRecvBits = nfc_target_receive_bits (pnd, abtRecv, sizeof (abtRecv), 0)) > 0) {
|
||||
// Prepare the command to send back for the anti-collision request
|
||||
switch (szRecvBits) {
|
||||
case 7: // Request or Wakeup
|
||||
pbtTx = abtAtqa;
|
||||
szTxBits = 16;
|
||||
// New anti-collsion session started
|
||||
if (!quiet_output)
|
||||
printf ("\n");
|
||||
break;
|
||||
case 7: // Request or Wakeup
|
||||
pbtTx = abtAtqa;
|
||||
szTxBits = 16;
|
||||
// New anti-collsion session started
|
||||
if (!quiet_output)
|
||||
printf ("\n");
|
||||
break;
|
||||
|
||||
case 16: // Select All
|
||||
pbtTx = abtUidBcc;
|
||||
szTxBits = 40;
|
||||
break;
|
||||
case 16: // Select All
|
||||
pbtTx = abtUidBcc;
|
||||
szTxBits = 40;
|
||||
break;
|
||||
|
||||
case 72: // Select Tag
|
||||
pbtTx = abtSak;
|
||||
szTxBits = 24;
|
||||
break;
|
||||
case 72: // Select Tag
|
||||
pbtTx = abtSak;
|
||||
szTxBits = 24;
|
||||
break;
|
||||
|
||||
default: // unknown length?
|
||||
szTxBits = 0;
|
||||
break;
|
||||
default: // unknown length?
|
||||
szTxBits = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!quiet_output) {
|
||||
|
|
|
|||
|
|
@ -163,13 +163,13 @@ main (int argc, char *argv[])
|
|||
} else if (0 == strcmp (argv[arg], "-q")) {
|
||||
quiet_output = true;
|
||||
} else if (strlen(argv[arg]) == 8) {
|
||||
for(i= 0 ; i < 4 ; ++i) {
|
||||
memcpy(tmp, argv[arg]+i*2, 2);
|
||||
sscanf(tmp, "%02x", &c);
|
||||
abtData[i]= (char) c;
|
||||
}
|
||||
abtData[4]= abtData[0] ^ abtData[1] ^ abtData[2] ^ abtData[3];
|
||||
iso14443a_crc_append (abtData, 16);
|
||||
for(i= 0 ; i < 4 ; ++i) {
|
||||
memcpy(tmp, argv[arg]+i*2, 2);
|
||||
sscanf(tmp, "%02x", &c);
|
||||
abtData[i]= (char) c;
|
||||
}
|
||||
abtData[4]= abtData[0] ^ abtData[1] ^ abtData[2] ^ abtData[3];
|
||||
iso14443a_crc_append (abtData, 16);
|
||||
} else {
|
||||
ERR ("%s is not supported option.", argv[arg]);
|
||||
print_usage (argv);
|
||||
|
|
@ -305,29 +305,29 @@ main (int argc, char *argv[])
|
|||
|
||||
// Request ATS, this only applies to tags that support ISO 14443A-4
|
||||
if (abtRx[0] & SAK_FLAG_ATS_SUPPORTED) {
|
||||
iso_ats_supported = true;
|
||||
iso_ats_supported = true;
|
||||
}
|
||||
|
||||
printf ("\nFound tag with\n UID: ");
|
||||
switch (szCL) {
|
||||
case 1:
|
||||
printf ("%02x%02x%02x%02x", abtRawUid[0], abtRawUid[1], abtRawUid[2], abtRawUid[3]);
|
||||
break;
|
||||
break;
|
||||
case 2:
|
||||
printf ("%02x%02x%02x", abtRawUid[1], abtRawUid[2], abtRawUid[3]);
|
||||
printf ("%02x%02x%02x%02x", abtRawUid[4], abtRawUid[5], abtRawUid[6], abtRawUid[7]);
|
||||
break;
|
||||
break;
|
||||
case 3:
|
||||
printf ("%02x%02x%02x", abtRawUid[1], abtRawUid[2], abtRawUid[3]);
|
||||
printf ("%02x%02x%02x", abtRawUid[5], abtRawUid[6], abtRawUid[7]);
|
||||
printf ("%02x%02x%02x%02x", abtRawUid[8], abtRawUid[9], abtRawUid[10], abtRawUid[11]);
|
||||
break;
|
||||
break;
|
||||
}
|
||||
printf("\n");
|
||||
printf("ATQA: %02x%02x\n SAK: %02x\n", abtAtqa[1], abtAtqa[0], abtSak);
|
||||
if (szAts > 1) { // if = 1, it's not actual ATS but error code
|
||||
printf(" ATS: ");
|
||||
print_hex (abtAts, szAts);
|
||||
printf(" ATS: ");
|
||||
print_hex (abtAts, szAts);
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
|
|
|
|||
|
|
@ -205,7 +205,7 @@ main (int argc, char *argv[])
|
|||
}
|
||||
// Forward the frame to the original tag
|
||||
if ((szTagRxBits = nfc_initiator_transceive_bits
|
||||
(pndReader, abtReaderRx, (size_t) szReaderRxBits, abtReaderRxPar, abtTagRx, abtTagRxPar)) > 0) {
|
||||
(pndReader, abtReaderRx, (size_t) szReaderRxBits, abtReaderRxPar, abtTagRx, abtTagRxPar)) > 0) {
|
||||
// Redirect the answer back to the reader
|
||||
if (nfc_target_send_bits (pndTag, abtTagRx, szTagRxBits, abtTagRxPar) < 0) {
|
||||
nfc_perror (pndTag, "nfc_target_send_bits");
|
||||
|
|
|
|||
|
|
@ -125,14 +125,14 @@ main (int argc, const char *argv[])
|
|||
}
|
||||
|
||||
switch (mode) {
|
||||
case PSM_VIRTUAL_CARD:
|
||||
case PSM_VIRTUAL_CARD:
|
||||
{
|
||||
printf ("Now the SAM is readable for 1 minute from an external reader.\n");
|
||||
wait_one_minute ();
|
||||
}
|
||||
break;
|
||||
|
||||
case PSM_WIRED_CARD:
|
||||
case PSM_WIRED_CARD:
|
||||
{
|
||||
nfc_target nt;
|
||||
|
||||
|
|
@ -169,7 +169,7 @@ main (int argc, const char *argv[])
|
|||
}
|
||||
break;
|
||||
|
||||
case PSM_DUAL_CARD:
|
||||
case PSM_DUAL_CARD:
|
||||
{
|
||||
uint8_t abtRx[MAX_FRAME_LEN];
|
||||
|
||||
|
|
@ -197,8 +197,8 @@ main (int argc, const char *argv[])
|
|||
// wait_one_minute ();
|
||||
}
|
||||
break;
|
||||
case PSM_NORMAL:
|
||||
break;
|
||||
case PSM_NORMAL:
|
||||
break;
|
||||
}
|
||||
ret = EXIT_SUCCESS;
|
||||
|
||||
|
|
|
|||
|
|
@ -148,7 +148,7 @@ int main(int argc, const char* argv[])
|
|||
sscanf(cmd + offset, "%d", &s);
|
||||
printf("Pause for %i msecs\n", s);
|
||||
if (s>0) {
|
||||
sleep(s * SUSP_TIME);
|
||||
sleep(s * SUSP_TIME);
|
||||
}
|
||||
free(cmd);
|
||||
continue;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue