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

This commit is contained in:
Philippe Teuwen 2012-05-29 15:53:43 +00:00
parent a2cd236441
commit 67522bae65
5 changed files with 42 additions and 37 deletions

View file

@ -125,15 +125,13 @@ main (int argc, const char *argv[])
} }
switch (mode) { switch (mode) {
case PSM_VIRTUAL_CARD: case PSM_VIRTUAL_CARD: {
{
printf ("Now the SAM is readable for 1 minute from an external reader.\n"); printf ("Now the SAM is readable for 1 minute from an external reader.\n");
wait_one_minute (); wait_one_minute ();
} }
break; break;
case PSM_WIRED_CARD: case PSM_WIRED_CARD: {
{
nfc_target nt; nfc_target nt;
// Set opened NFC device to initiator mode // Set opened NFC device to initiator mode
@ -169,8 +167,7 @@ main (int argc, const char *argv[])
} }
break; break;
case PSM_DUAL_CARD: case PSM_DUAL_CARD: {
{
uint8_t abtRx[MAX_FRAME_LEN]; uint8_t abtRx[MAX_FRAME_LEN];
nfc_target nt = { nfc_target nt = {

View file

@ -829,8 +829,7 @@ pn53x_set_property_bool (struct nfc_device *pnd, const nfc_property property, co
return NFC_SUCCESS; return NFC_SUCCESS;
break; break;
case NP_ACTIVATE_FIELD: case NP_ACTIVATE_FIELD: {
{
if (pn53x_RFConfiguration__RF_field (pnd, bEnable) == 0) if (pn53x_RFConfiguration__RF_field (pnd, bEnable) == 0)
return NFC_SUCCESS; return NFC_SUCCESS;
} }
@ -841,8 +840,7 @@ pn53x_set_property_bool (struct nfc_device *pnd, const nfc_property property, co
return pn53x_write_register (pnd, PN53X_REG_CIU_Status2, SYMBOL_MF_CRYPTO1_ON, btValue); return pn53x_write_register (pnd, PN53X_REG_CIU_Status2, SYMBOL_MF_CRYPTO1_ON, btValue);
break; break;
case NP_INFINITE_SELECT: case NP_INFINITE_SELECT: {
{
// TODO Made some research around this point: // TODO Made some research around this point:
// timings could be tweak better than this, and maybe we can tweak timings // timings could be tweak better than this, and maybe we can tweak timings
// to "gain" a sort-of hardware polling (ie. like PN532 does) // to "gain" a sort-of hardware polling (ie. like PN532 does)
@ -1045,8 +1043,7 @@ pn53x_initiator_select_passive_target_ext (struct nfc_device *pnd,
return res; return res;
} }
szTargetsData = (size_t)res; szTargetsData = (size_t)res;
} } else if (nm.nmt == NMT_ISO14443B2CT) {
else if (nm.nmt == NMT_ISO14443B2CT) {
// Some work to do before getting the UID... // Some work to do before getting the UID...
const uint8_t abtReqt[]= { 0x10 }; const uint8_t abtReqt[]= { 0x10 };
// Getting product code / fab code & store it in output buffer after the serial nr we'll obtain later // Getting product code / fab code & store it in output buffer after the serial nr we'll obtain later
@ -2860,8 +2857,7 @@ pn53x_get_supported_baud_rate (nfc_device *pnd, const nfc_modulation_type nmt, c
case NMT_ISO14443B: case NMT_ISO14443B:
case NMT_ISO14443BI: case NMT_ISO14443BI:
case NMT_ISO14443B2SR: case NMT_ISO14443B2SR:
case NMT_ISO14443B2CT: case NMT_ISO14443B2CT: {
{
if ((CHIP_DATA(pnd)->type != PN533)) { if ((CHIP_DATA(pnd)->type != PN533)) {
*supported_br = (nfc_baud_rate*)pn532_iso14443b_supported_baud_rates; *supported_br = (nfc_baud_rate*)pn532_iso14443b_supported_baud_rates;
} else { } else {

View file

@ -249,8 +249,8 @@ acr122s_send_frame(nfc_device *pnd, uint8_t *frame, int timeout)
static int static int
acr122s_recv_frame(nfc_device *pnd, uint8_t *frame, size_t frame_size, void *abort_p, int timeout) acr122s_recv_frame(nfc_device *pnd, uint8_t *frame, size_t frame_size, void *abort_p, int timeout)
{ {
if (frame_size < 13) if (frame_size < 13) {
{ pnd->last_error = NFC_EINVARG; pnd->last_error = NFC_EINVARG;
return pnd->last_error; return pnd->last_error;
} }
int ret; int ret;
@ -285,7 +285,8 @@ acr122s_recv_frame(nfc_device *pnd, uint8_t *frame, size_t frame_size, void *abo
* Convert host uint32 to litle endian uint32 * Convert host uint32 to litle endian uint32
*/ */
static uint32_t static uint32_t
le32(uint32_t val) { le32(uint32_t val)
{
uint32_t res; uint32_t res;
uint8_t *p = (uint8_t *) &res; uint8_t *p = (uint8_t *) &res;
p[0] = val; p[0] = val;

View file

@ -204,8 +204,7 @@ main (int argc, char *argv[])
} }
fd3 = fdopen(3, "r"); fd3 = fdopen(3, "r");
fd4 = fdopen(4, "w"); fd4 = fdopen(4, "w");
} } else {
else {
if (szFound < 2) { if (szFound < 2) {
ERR ("%zd device found but two opened devices are needed to relay NFC.", szFound); ERR ("%zd device found but two opened devices are needed to relay NFC.", szFound);
return EXIT_FAILURE; return EXIT_FAILURE;

View file

@ -36,8 +36,7 @@
#include "nfc-utils.h" #include "nfc-utils.h"
struct card_atqa struct card_atqa {
{
uint16_t atqa; uint16_t atqa;
uint16_t mask; uint16_t mask;
char type[128]; char type[128];
@ -45,54 +44,67 @@ struct card_atqa
int saklist[8]; int saklist[8];
}; };
struct card_sak struct card_sak {
{
uint8_t sak; uint8_t sak;
uint8_t mask; uint8_t mask;
char type[128]; char type[128];
}; };
struct card_atqa const_ca[] = { struct card_atqa const_ca[] = {
{ 0x0044, 0xffff, "MIFARE Ultralight", {
0x0044, 0xffff, "MIFARE Ultralight",
{0, -1} {0, -1}
}, },
{ 0x0044, 0xffff, "MIFARE Ultralight C", {
0x0044, 0xffff, "MIFARE Ultralight C",
{0, -1} {0, -1}
}, },
{ 0x0004, 0xff0f, "MIFARE Mini 0.3K", {
0x0004, 0xff0f, "MIFARE Mini 0.3K",
{1, -1} {1, -1}
}, },
{ 0x0004, 0xff0f, "MIFARE Classic 1K", {
0x0004, 0xff0f, "MIFARE Classic 1K",
{2, -1} {2, -1}
}, },
{ 0x0002, 0xff0f, "MIFARE Classic 4K", {
0x0002, 0xff0f, "MIFARE Classic 4K",
{3, -1} {3, -1}
}, },
{ 0x0004, 0xffff, "MIFARE Plus (4 Byte UID or 4 Byte RID)", {
0x0004, 0xffff, "MIFARE Plus (4 Byte UID or 4 Byte RID)",
{4, 5, 6, 7, 8, 9, -1} {4, 5, 6, 7, 8, 9, -1}
}, },
{ 0x0002, 0xffff, "MIFARE Plus (4 Byte UID or 4 Byte RID)", {
0x0002, 0xffff, "MIFARE Plus (4 Byte UID or 4 Byte RID)",
{4, 5, 6, 7, 8, 9, -1} {4, 5, 6, 7, 8, 9, -1}
}, },
{ 0x0044, 0xffff, "MIFARE Plus (7 Byte UID)", {
0x0044, 0xffff, "MIFARE Plus (7 Byte UID)",
{4, 5, 6, 7, 8, 9, -1} {4, 5, 6, 7, 8, 9, -1}
}, },
{ 0x0042, 0xffff, "MIFARE Plus (7 Byte UID)", {
0x0042, 0xffff, "MIFARE Plus (7 Byte UID)",
{4, 5, 6, 7, 8, 9, -1} {4, 5, 6, 7, 8, 9, -1}
}, },
{ 0x0344, 0xffff, "MIFARE DESFire", {
0x0344, 0xffff, "MIFARE DESFire",
{10, 11, -1} {10, 11, -1}
}, },
{ 0x0044, 0xffff, "P3SR008", {
0x0044, 0xffff, "P3SR008",
{-1} {-1}
}, // TODO we need SAK info }, // TODO we need SAK info
{ 0x0004, 0xf0ff, "SmartMX with MIFARE 1K emulation", {
0x0004, 0xf0ff, "SmartMX with MIFARE 1K emulation",
{12, -1} {12, -1}
}, },
{ 0x0002, 0xf0ff, "SmartMX with MIFARE 4K emulation", {
0x0002, 0xf0ff, "SmartMX with MIFARE 4K emulation",
{12, -1} {12, -1}
}, },
{ 0x0048, 0xf0ff, "SmartMX with 7 Byte UID", {
0x0048, 0xf0ff, "SmartMX with 7 Byte UID",
{12, -1} {12, -1}
} }
}; };