make style

This commit is contained in:
Philippe Teuwen 2020-05-21 15:06:17 +02:00
parent f52d04e0a7
commit 4525cd1c32
9 changed files with 455 additions and 470 deletions

View file

@ -138,8 +138,7 @@ int pcsc_transmit(struct nfc_device *pnd, const uint8_t *tx, const size_t tx_len
DWORD dw_rx_len = *rx_len; DWORD dw_rx_len = *rx_len;
//in libfreefare, tx_len = 1, and it leads to 0x80100008 error, with PC/SC reader, the input tx_len at least two bytes for the SW value //in libfreefare, tx_len = 1, and it leads to 0x80100008 error, with PC/SC reader, the input tx_len at least two bytes for the SW value
//so if found the reader is Feitian reader, we set to 2 //so if found the reader is Feitian reader, we set to 2
if (dw_rx_len == 1 && is_pcsc_reader_vendor_feitian(pnd)) if (dw_rx_len == 1 && is_pcsc_reader_vendor_feitian(pnd)) {
{
dw_rx_len = 2; dw_rx_len = 2;
} }
@ -204,8 +203,7 @@ uint8_t pcsc_get_icc_type(const struct nfc_device *pnd)
bool is_pcsc_reader_vendor(const struct nfc_device *pnd, const char *target_vendor_name) bool is_pcsc_reader_vendor(const struct nfc_device *pnd, const char *target_vendor_name)
{ {
bool isTarget = false; bool isTarget = false;
if (pnd == NULL || strlen(pnd->name) == 0) if (pnd == NULL || strlen(pnd->name) == 0) {
{
return isTarget; return isTarget;
} }
@ -340,8 +338,7 @@ int pcsc_props_to_target(struct nfc_device *pnd, uint8_t it, const uint8_t *patr
memcpy(pnt->nti.nai.abtUid, puid, szuid); memcpy(pnt->nti.nai.abtUid, puid, szuid);
pnt->nti.nai.szUidLen = szuid; pnt->nti.nai.szUidLen = szuid;
} }
if (is_pcsc_reader_vendor_feitian(pnd)) if (is_pcsc_reader_vendor_feitian(pnd)) {
{
uint8_t atqa[2]; uint8_t atqa[2];
pcsc_get_atqa(pnd, atqa, sizeof(atqa)); pcsc_get_atqa(pnd, atqa, sizeof(atqa));
//memcpy(pnt->nti.nai.abtAtqa,atqa,2); //memcpy(pnt->nti.nai.abtAtqa,atqa,2);
@ -974,27 +971,22 @@ pcsc_get_information_about(nfc_device *pnd, char **pbuf)
error: error:
#ifdef __APPLE__ #ifdef __APPLE__
if (pscc != NULL) if (pscc != NULL) {
{
SCardReleaseContext(*pscc); SCardReleaseContext(*pscc);
} }
if (name != NULL) if (name != NULL) {
{
free(name); free(name);
name = NULL; name = NULL;
} }
if (type != NULL) if (type != NULL) {
{
free(type); free(type);
type = NULL; type = NULL;
} }
if (version != NULL) if (version != NULL) {
{
free(version); free(version);
version = NULL; version = NULL;
} }
if (serial != NULL) if (serial != NULL) {
{
free(serial); free(serial);
serial = NULL; serial = NULL;
} }

View file

@ -169,77 +169,70 @@ static void BufferPrintBytes(char* buffer, unsigned int buflen, const uint8_t *d
static void PrintTagInfo(nfc_tag_info_t *TagInfo) static void PrintTagInfo(nfc_tag_info_t *TagInfo)
{ {
switch (TagInfo->technology) switch (TagInfo->technology) {
{ case TARGET_TYPE_UNKNOWN: {
case TARGET_TYPE_UNKNOWN:
{
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "'Type Unknown'"); log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "'Type Unknown'");
} break; }
case TARGET_TYPE_ISO14443_3A: break;
{ case TARGET_TYPE_ISO14443_3A: {
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "'Type 3A'"); log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "'Type 3A'");
} break; }
case TARGET_TYPE_ISO14443_3B: break;
{ case TARGET_TYPE_ISO14443_3B: {
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "'Type 3B'"); log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "'Type 3B'");
} break; }
case TARGET_TYPE_ISO14443_4: break;
{ case TARGET_TYPE_ISO14443_4: {
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "'Type 4A'"); log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "'Type 4A'");
} break; }
case TARGET_TYPE_FELICA: break;
{ case TARGET_TYPE_FELICA: {
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "'Type F'"); log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "'Type F'");
} break; }
case TARGET_TYPE_ISO15693: break;
{ case TARGET_TYPE_ISO15693: {
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "'Type V'"); log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "'Type V'");
} break; }
case TARGET_TYPE_NDEF: break;
{ case TARGET_TYPE_NDEF: {
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "'Type NDEF'"); log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "'Type NDEF'");
} break; }
case TARGET_TYPE_NDEF_FORMATABLE: break;
{ case TARGET_TYPE_NDEF_FORMATABLE: {
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "'Type Formatable'"); log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "'Type Formatable'");
} break; }
case TARGET_TYPE_MIFARE_CLASSIC: break;
{ case TARGET_TYPE_MIFARE_CLASSIC: {
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "'Type A - Mifare Classic'"); log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "'Type A - Mifare Classic'");
} break; }
case TARGET_TYPE_MIFARE_UL: break;
{ case TARGET_TYPE_MIFARE_UL: {
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "'Type A - Mifare Ul'"); log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "'Type A - Mifare Ul'");
} break; }
case TARGET_TYPE_KOVIO_BARCODE: break;
{ case TARGET_TYPE_KOVIO_BARCODE: {
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "'Type A - Kovio Barcode'"); log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "'Type A - Kovio Barcode'");
} break; }
case TARGET_TYPE_ISO14443_3A_3B: break;
{ case TARGET_TYPE_ISO14443_3A_3B: {
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "'Type A/B'"); log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "'Type A/B'");
} break; }
default: break;
{ default: {
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "'Type %d (Unknown or not supported)'\n", TagInfo->technology); log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "'Type %d (Unknown or not supported)'\n", TagInfo->technology);
} break; }
break;
} }
/*32 is max UID len (Kovio tags)*/ /*32 is max UID len (Kovio tags)*/
if((0x00 != TagInfo->uid_length) && (32 >= TagInfo->uid_length)) if ((0x00 != TagInfo->uid_length) && (32 >= TagInfo->uid_length)) {
{
char buffer [100]; char buffer [100];
int cx = 0; int cx = 0;
if(4 == TagInfo->uid_length || 7 == TagInfo->uid_length || 10 == TagInfo->uid_length) if (4 == TagInfo->uid_length || 7 == TagInfo->uid_length || 10 == TagInfo->uid_length) {
{
cx += snprintf(buffer + cx, sizeof(buffer) - cx, "NFCID1 : \t'"); cx += snprintf(buffer + cx, sizeof(buffer) - cx, "NFCID1 : \t'");
} } else if (8 == TagInfo->uid_length) {
else if(8 == TagInfo->uid_length)
{
cx += snprintf(buffer + cx, sizeof(buffer) - cx, "NFCID2 : \t'"); cx += snprintf(buffer + cx, sizeof(buffer) - cx, "NFCID2 : \t'");
} } else {
else
{
cx += snprintf(buffer + cx, sizeof(buffer) - cx, "UID : \t'"); cx += snprintf(buffer + cx, sizeof(buffer) - cx, "UID : \t'");
} }

View file

@ -206,8 +206,7 @@ nfc_device_validate_modulation(nfc_device *pnd, const nfc_mode mode, const nfc_m
int int
nfc_register_driver(const struct nfc_driver *ndr) nfc_register_driver(const struct nfc_driver *ndr)
{ {
if (!ndr) if (!ndr) {
{
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "nfc_register_driver returning NFC_EINVARG"); log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "nfc_register_driver returning NFC_EINVARG");
return NFC_EINVARG; return NFC_EINVARG;
} }

View file

@ -620,7 +620,8 @@ print_usage(const char *pcProgramName)
} }
bool is_directwrite(){ bool is_directwrite()
{
printf("Checking if Badge is DirectWrite...\n"); printf("Checking if Badge is DirectWrite...\n");
// Set default keys // Set default keys