From f34857487dc20ae7532d789f447256f6a89d7b46 Mon Sep 17 00:00:00 2001 From: Romuald Conty Date: Wed, 27 May 2009 12:18:21 +0000 Subject: [PATCH] Replace locally defined "null" to standard library defined "NULL" (stddef.h). Replace "ulong" usage by "size_t" from standard library (since ulong type was only used to store sizeof() result). --- configure.ac | 2 +- src/anticol.c | 3 +- src/defines.h | 7 +- src/dev_acr122.c | 36 ++++----- src/dev_pn531.c | 10 ++- src/emulate.c | 7 +- src/libnfc.c | 19 +++-- src/list.c | 191 ++++++++++++++++++++++++----------------------- src/mftool.c | 14 ++-- 9 files changed, 150 insertions(+), 139 deletions(-) diff --git a/configure.ac b/configure.ac index 47e3279..0e45289 100644 --- a/configure.ac +++ b/configure.ac @@ -13,7 +13,7 @@ AC_PATH_PROG(PKG_CONFIG, pkg-config) # Checks for header files. AC_HEADER_STDC -AC_CHECK_HEADERS([stdlib.h stdint.h]) +AC_CHECK_HEADERS([stdio.h stdlib.h stdint.h stddef.h]) # libusb diff --git a/src/anticol.c b/src/anticol.c index f05908f..1969dc3 100644 --- a/src/anticol.c +++ b/src/anticol.c @@ -20,6 +20,7 @@ along with this program. If not, see . #include #include +#include #include #include @@ -47,7 +48,7 @@ bool transmit_bits(const byte* pbtTx, const uint32_t uiTxBits) printf("R: "); print_hex_bits(pbtTx,uiTxBits); // Transmit the bit frame command, we don't use the arbitrary parity feature - if (!nfc_reader_transceive_bits(pdi,pbtTx,uiTxBits,null,abtRx,&uiRxBits,null)) return false; + if (!nfc_reader_transceive_bits(pdi,pbtTx,uiTxBits,NULL,abtRx,&uiRxBits,NULL)) return false; // Show received answer printf("T: "); print_hex_bits(abtRx,uiRxBits); diff --git a/src/defines.h b/src/defines.h index cddea0e..122ac25 100644 --- a/src/defines.h +++ b/src/defines.h @@ -21,15 +21,12 @@ along with this program. If not, see . #ifndef _LIBNFC_DEFINES_H_ #define _LIBNFC_DEFINES_H_ -// #define DEBUG +// #define DEBUG /* DEBUG flag can also be enabled using ./configure --enable-debug */ typedef unsigned char byte; -typedef unsigned long ulong; - -#define null 0 typedef void* dev_spec; // Device connection specification -#define INVALID_DEVICE_INFO null +#define INVALID_DEVICE_INFO 0 #define MAX_FRAME_LEN 264 #define DEVICE_NAME_LENGTH 256 diff --git a/src/dev_acr122.c b/src/dev_acr122.c index 18e6181..80b8363 100644 --- a/src/dev_acr122.c +++ b/src/dev_acr122.c @@ -17,14 +17,16 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +#include "dev_acr122.h" -#include "defines.h" +#include +#include +#include +#include #include -#include -#include -#include -#include "dev_acr122.h" + +#include "defines.h" #include "bitutils.h" // WINDOWS: #define IOCTL_CCID_ESCAPE_SCARD_CTL_CODE SCARD_CTL_CODE(3500) @@ -53,7 +55,7 @@ static byte abtTxBuf[ACR122_WRAP_LEN+ACR122_COMMAND_LEN] = { 0xFF, 0x00, 0x00, 0 static byte abtRxCmd[5] = { 0xFF,0xC0,0x00,0x00 }; static byte uiRxCmdLen = sizeof(abtRxCmd); static byte abtRxBuf[ACR122_RESPONSE_LEN]; -static ulong ulRxBufLen; +static size_t ulRxBufLen; static byte abtGetFw[5] = { 0xFF,0x00,0x48,0x00,0x00 }; static byte abtLed[9] = { 0xFF,0x00,0x40,0x05,0x04,0x00,0x00,0x00,0x00 }; @@ -61,7 +63,7 @@ dev_info* dev_acr122_connect(const uint32_t uiIndex) { char* pacReaders[MAX_READERS]; char acList[256+64*MAX_READERS]; - ulong ulListLen = sizeof(acList); + size_t ulListLen = sizeof(acList); uint32_t uiPos; uint32_t uiReaderCount; uint32_t uiReader; @@ -75,10 +77,10 @@ dev_info* dev_acr122_connect(const uint32_t uiIndex) memset(acList,0x00,ulListLen); // Test if context succeeded - if (SCardEstablishContext(SCARD_SCOPE_USER,null,null,&(dsa.hCtx)) != SCARD_S_SUCCESS) return INVALID_DEVICE_INFO; + if (SCardEstablishContext(SCARD_SCOPE_USER,NULL,NULL,&(dsa.hCtx)) != SCARD_S_SUCCESS) return INVALID_DEVICE_INFO; // Retrieve the string array of all available pcsc readers - if (SCardListReaders(dsa.hCtx,null,acList,(void*)&ulListLen) != SCARD_S_SUCCESS) return INVALID_DEVICE_INFO; + if (SCardListReaders(dsa.hCtx,NULL,acList,(void*)&ulListLen) != SCARD_S_SUCCESS) return INVALID_DEVICE_INFO; #ifdef DEBUG printf("Found the following PCSC device(s)\n"); @@ -132,7 +134,7 @@ dev_info* dev_acr122_connect(const uint32_t uiIndex) // Retrieve the current firmware version pcFirmware = dev_acr122_firmware((dev_info*)&dsa); - if (strstr(pcFirmware,FIRMWARE_TEXT) != null) + if (strstr(pcFirmware,FIRMWARE_TEXT) != NULL) { // We found a occurence, test if it has the right index if (uiDevIndex != 0) @@ -194,7 +196,7 @@ bool dev_acr122_transceive(const dev_spec ds, const byte* pbtTx, const uint32_t { if (SCardControl(pdsa->hCard,IOCTL_CCID_ESCAPE_SCARD_CTL_CODE,abtTxBuf,uiTxLen+5,abtRxBuf,ulRxBufLen,(void*)&ulRxBufLen) != SCARD_S_SUCCESS) return false; } else { - if (SCardTransmit(pdsa->hCard,&(pdsa->ioCard),abtTxBuf,uiTxLen+5,null,abtRxBuf,(void*)&ulRxBufLen) != SCARD_S_SUCCESS) return false; + if (SCardTransmit(pdsa->hCard,&(pdsa->ioCard),abtTxBuf,uiTxLen+5,NULL,abtRxBuf,(void*)&ulRxBufLen) != SCARD_S_SUCCESS) return false; } if (pdsa->ioCard.dwProtocol == SCARD_PROTOCOL_T0) @@ -208,7 +210,7 @@ bool dev_acr122_transceive(const dev_spec ds, const byte* pbtTx, const uint32_t // Retrieve the response bytes abtRxCmd[4] = abtRxBuf[1]; ulRxBufLen = sizeof(abtRxBuf); - if (SCardTransmit(pdsa->hCard,&(pdsa->ioCard),abtRxCmd,uiRxCmdLen,null,abtRxBuf,(void*)&ulRxBufLen) != SCARD_S_SUCCESS) return false; + if (SCardTransmit(pdsa->hCard,&(pdsa->ioCard),abtRxCmd,uiRxCmdLen,NULL,abtRxBuf,(void*)&ulRxBufLen) != SCARD_S_SUCCESS) return false; } #ifdef DEBUG @@ -217,7 +219,7 @@ bool dev_acr122_transceive(const dev_spec ds, const byte* pbtTx, const uint32_t #endif // When the answer should be ignored, just return a succesful result - if (pbtRx == null || puiRxLen == null) return true; + if (pbtRx == NULL || puiRxLen == NULL) return true; // Make sure we have an emulated answer that fits the return buffer if (ulRxBufLen < 4 || (ulRxBufLen-4) > *puiRxLen) return false; @@ -235,13 +237,13 @@ char* dev_acr122_firmware(const dev_spec ds) dev_spec_acr122* pdsa = (dev_spec_acr122*)ds; static char abtFw[11]; - ulong ulFwLen = sizeof(abtFw); + size_t ulFwLen = sizeof(abtFw); memset(abtFw,0x00,ulFwLen); if (pdsa->ioCard.dwProtocol == SCARD_PROTOCOL_UNDEFINED) { uiResult = SCardControl(pdsa->hCard,IOCTL_CCID_ESCAPE_SCARD_CTL_CODE,abtGetFw,sizeof(abtGetFw),abtFw,ulFwLen,(void*)&ulFwLen); } else { - uiResult = SCardTransmit(pdsa->hCard,&(pdsa->ioCard),abtGetFw,sizeof(abtGetFw),null,(byte*)abtFw,(void*)&ulFwLen); + uiResult = SCardTransmit(pdsa->hCard,&(pdsa->ioCard),abtGetFw,sizeof(abtGetFw),NULL,(byte*)abtFw,(void*)&ulFwLen); } #ifdef DEBUG @@ -258,12 +260,12 @@ bool dev_acr122_led_red(const dev_spec ds, bool bOn) { dev_spec_acr122* pdsa = (dev_spec_acr122*)ds; byte abtBuf[2]; - ulong ulBufLen = sizeof(abtBuf); + size_t ulBufLen = sizeof(abtBuf); if (pdsa->ioCard.dwProtocol == SCARD_PROTOCOL_UNDEFINED) { return (SCardControl(pdsa->hCard,IOCTL_CCID_ESCAPE_SCARD_CTL_CODE,abtLed,sizeof(abtLed),abtBuf,ulBufLen,(void*)&ulBufLen) == SCARD_S_SUCCESS); } else { - return (SCardTransmit(pdsa->hCard,&(pdsa->ioCard),abtLed,sizeof(abtLed),null,(byte*)abtBuf,(void*)&ulBufLen) == SCARD_S_SUCCESS); + return (SCardTransmit(pdsa->hCard,&(pdsa->ioCard),abtLed,sizeof(abtLed),NULL,(byte*)abtBuf,(void*)&ulBufLen) == SCARD_S_SUCCESS); } } diff --git a/src/dev_pn531.c b/src/dev_pn531.c index 67791e9..ba84cfd 100644 --- a/src/dev_pn531.c +++ b/src/dev_pn531.c @@ -20,11 +20,13 @@ Thanks to d18c7db and Okko for example code */ -#include "defines.h" +#include +#include #include -#include #include + +#include "defines.h" #include "dev_pn531.h" #include "bitutils.h" @@ -87,7 +89,7 @@ dev_info* dev_pn531_connect(const uint32_t uiIndex) dsp.uiEndPointIn = 0; dsp.uiEndPointOut = 0; - dsp.pudh = null; + dsp.pudh = NULL; usb_init(); if (usb_find_busses() < 0) return INVALID_DEVICE_INFO; @@ -234,7 +236,7 @@ bool dev_pn531_transceive(const dev_spec ds, const byte* pbtTx, const uint32_t u } // When the answer should be ignored, just return a succesful result - if(pbtRx == null || puiRxLen == null) return true; + if(pbtRx == NULL || puiRxLen == NULL) return true; // Only succeed when the result is at least 00 00 FF xx Fx Dx xx .. .. .. xx 00 (x = variable) if(ret < 9) return false; diff --git a/src/emulate.c b/src/emulate.c index 134912a..029ca8f 100644 --- a/src/emulate.c +++ b/src/emulate.c @@ -20,6 +20,7 @@ along with this program. If not, see . #include #include +#include #include #include @@ -36,7 +37,7 @@ byte abtSak [9] = { 0x08,0xb6,0xdd }; int main(int argc, const char* argv[]) { - byte* pbtTx = null; + byte* pbtTx = NULL; uint32_t uiTxBits; // Try to open the NFC reader @@ -68,7 +69,7 @@ int main(int argc, const char* argv[]) while(true) { // Test if we received a frame - if (nfc_target_receive_bits(pdi,abtRecv,&uiRecvBits,null)) + if (nfc_target_receive_bits(pdi,abtRecv,&uiRecvBits,NULL)) { // Prepare the command to send back for the anti-collision request switch(uiRecvBits) @@ -102,7 +103,7 @@ int main(int argc, const char* argv[]) if(uiTxBits) { // Send and print the command to the screen - nfc_target_send_bits(pdi,pbtTx,uiTxBits,null); + nfc_target_send_bits(pdi,pbtTx,uiTxBits,NULL); printf("T: "); print_hex_bits(pbtTx,uiTxBits); } diff --git a/src/libnfc.c b/src/libnfc.c index f83dcd6..c737449 100644 --- a/src/libnfc.c +++ b/src/libnfc.c @@ -19,10 +19,13 @@ along with this program. If not, see . */ #include "libnfc.h" -#include "bitutils.h" + #include +#include #include +#include "bitutils.h" + // Registers and symbols masks used to covers parts within a register #define REG_CIU_TX_MODE 0x6302 #define SYMBOL_TX_CRC_ENABLE 0x80 @@ -120,13 +123,13 @@ bool pn53x_set_reg(const dev_info* pdi, uint16_t ui16Reg, uint8_t ui8SybmolMask, pncmd_set_register[2] = ui16Reg >> 8; pncmd_set_register[3] = ui16Reg & 0xff; pncmd_set_register[4] = ui8Value | (pn53x_get_reg(pdi,ui16Reg) & (~ui8SybmolMask)); - return pdi->pdc->transceive(pdi->ds,pncmd_set_register,5,null,null); + return pdi->pdc->transceive(pdi->ds,pncmd_set_register,5,NULL,NULL); } bool pn53x_set_parameters(const dev_info* pdi, uint8_t ui8Value) { pncmd_set_parameters[2] = ui8Value; - return pdi->pdc->transceive(pdi->ds,pncmd_set_parameters,3,null,null); + return pdi->pdc->transceive(pdi->ds,pncmd_set_parameters,3,NULL,NULL); } bool pn53x_set_tx_bits(const dev_info* pdi, uint8_t ui8Bits) @@ -233,7 +236,7 @@ bool pn53x_unwrap_frame(const byte* pbtFrame, const uint32_t uiFrameBits, byte* btFrame = mirror(pbtFramePos[uiDataPos+1]); btData |= (btFrame >> (8-uiBitPos)); pbtRx[uiDataPos] = mirror(btData); - if(pbtRxPar != null) pbtRxPar[uiDataPos] = ((btFrame >> (7-uiBitPos)) & 0x01); + if(pbtRxPar != NULL) pbtRxPar[uiDataPos] = ((btFrame >> (7-uiBitPos)) & 0x01); // Increase the data (without parity bit) position uiDataPos++; // Test if we are done @@ -263,7 +266,7 @@ dev_info* nfc_connect() { // Great we have claimed a device pdi->pdc = &(dev_callbacks_list[uiDev]); - pdi->pdc->transceive(pdi->ds,pncmd_get_register,4,null,null); + pdi->pdc->transceive(pdi->ds,pncmd_get_register,4,NULL,NULL); // Try to retrieve PN53x chip revision if (!pdi->pdc->transceive(pdi->ds,pncmd_get_firmware_version,2,abtFw,&uiFwLen)) @@ -332,7 +335,7 @@ bool nfc_configure(dev_info* pdi, const dev_config_option dco, const bool bEnabl case DCO_ACTIVATE_FIELD: pncmd_rf_configure_field[3] = (bEnable) ? 1 : 0; - if (!pdi->pdc->transceive(pdi->ds,pncmd_rf_configure_field,4,null,null)) return false; + if (!pdi->pdc->transceive(pdi->ds,pncmd_rf_configure_field,4,NULL,NULL)) return false; break; case DCO_ACTIVATE_CRYPTO1: @@ -345,7 +348,7 @@ bool nfc_configure(dev_info* pdi, const dev_config_option dco, const bool bEnabl pncmd_rf_configure_retry_select[3] = (bEnable) ? 0xff : 0x00; // MxRtyATR, default: active = 0xff, passive = 0x02 pncmd_rf_configure_retry_select[4] = (bEnable) ? 0xff : 0x00; // MxRtyPSL, default: 0x01 pncmd_rf_configure_retry_select[5] = (bEnable) ? 0xff : 0x00; // MxRtyPassiveActivation, default: 0xff - if(!pdi->pdc->transceive(pdi->ds,pncmd_rf_configure_retry_select,6,null,null)) return false; + if(!pdi->pdc->transceive(pdi->ds,pncmd_rf_configure_retry_select,6,NULL,NULL)) return false; break; case DCO_ACCEPT_INVALID_FRAMES: @@ -477,7 +480,7 @@ bool nfc_reader_select(const dev_info* pdi, const init_modulation im, const byte bool nfc_reader_deselect(const dev_info* pdi) { - return (pdi->pdc->transceive(pdi->ds,pncmd_reader_deselect,3,null,null)); + return (pdi->pdc->transceive(pdi->ds,pncmd_reader_deselect,3,NULL,NULL)); } bool nfc_reader_transceive_bits(const dev_info* pdi, const byte* pbtTx, const uint32_t uiTxBits, const byte* pbtTxPar, byte* pbtRx, uint32_t* puiRxBits, byte* pbtRxPar) diff --git a/src/list.c b/src/list.c index be02e9b..742cdc7 100644 --- a/src/list.c +++ b/src/list.c @@ -1,96 +1,99 @@ -/* - -Public platform independent Near Field Communication (NFC) library -Copyright (C) 2009, Roel Verdult - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . - -*/ - -#include -#include -#include -#include "libnfc.h" - -static dev_info* pdi; -static byte abtFelica[5] = { 0x00, 0xff, 0xff, 0x00, 0x00 }; - -int main(int argc, const char* argv[]) -{ - tag_info ti; - - // Try to open the NFC reader - pdi = nfc_connect(); - - if (pdi == INVALID_DEVICE_INFO) - { - printf("Error connecting NFC reader\n"); - return 1; - } - nfc_reader_init(pdi); - +/* + +Public platform independent Near Field Communication (NFC) library +Copyright (C) 2009, Roel Verdult + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . + +*/ + +#include +#include +#include + +#include + +#include "libnfc.h" + +static dev_info* pdi; +static byte abtFelica[5] = { 0x00, 0xff, 0xff, 0x00, 0x00 }; + +int main(int argc, const char* argv[]) +{ + tag_info ti; + + // Try to open the NFC reader + pdi = nfc_connect(); + + if (pdi == INVALID_DEVICE_INFO) + { + printf("Error connecting NFC reader\n"); + return 1; + } + nfc_reader_init(pdi); + // Drop the field for a while nfc_configure(pdi,DCO_ACTIVATE_FIELD,false); - - // Let the reader only try once to find a tag - nfc_configure(pdi,DCO_INFINITE_SELECT,false); - - // Configure the CRC and Parity settings - nfc_configure(pdi,DCO_HANDLE_CRC,true); - nfc_configure(pdi,DCO_HANDLE_PARITY,true); - - // Enable field so more power consuming cards can power themselves up - nfc_configure(pdi,DCO_ACTIVATE_FIELD,true); - - printf("\nConnected to NFC reader: %s\n\n",pdi->acName); - - // Poll for a ISO14443A (MIFARE) tag - if (nfc_reader_select(pdi,IM_ISO14443A_106,null,null,&ti)) - { - printf("The following (NFC) ISO14443A tag was found:\n\n"); - printf(" ATQA (SENS_RES): "); print_hex(ti.tia.abtAtqa,2); - printf(" UID (NFCID%c): ",(ti.tia.abtUid[0]==0x08?'3':'1')); print_hex(ti.tia.abtUid,ti.tia.uiUidLen); - printf(" SAK (SEL_RES): "); print_hex(&ti.tia.btSak,1); - if (ti.tia.uiAtsLen) - { - printf(" ATS (ATR): "); - print_hex(ti.tia.abtAts,ti.tia.uiAtsLen); - } - } - - // Poll for a Felica tag - if (nfc_reader_select(pdi,IM_FELICA_212,abtFelica,5,&ti) || nfc_reader_select(pdi,IM_FELICA_424,abtFelica,5,&ti)) - { - printf("The following (NFC) Felica tag was found:\n\n"); - printf("%18s","ID (NFCID2): "); print_hex(ti.tif.abtId,8); - printf("%18s","Parameter (PAD): "); print_hex(ti.tif.abtPad,8); - } - - // Poll for a ISO14443B tag - if (nfc_reader_select(pdi,IM_ISO14443B_106,null,null,&ti)) - { - // No test results yet - printf("iso14443b\n"); - } - - // Poll for a Jewel tag - if (nfc_reader_select(pdi,IM_JEWEL_106,null,null,&ti)) - { - // No test results yet - printf("jewel\n"); - } - - nfc_disconnect(pdi); - return 1; -} + + // Let the reader only try once to find a tag + nfc_configure(pdi,DCO_INFINITE_SELECT,false); + + // Configure the CRC and Parity settings + nfc_configure(pdi,DCO_HANDLE_CRC,true); + nfc_configure(pdi,DCO_HANDLE_PARITY,true); + + // Enable field so more power consuming cards can power themselves up + nfc_configure(pdi,DCO_ACTIVATE_FIELD,true); + + printf("\nConnected to NFC reader: %s\n\n",pdi->acName); + + // Poll for a ISO14443A (MIFARE) tag + if (nfc_reader_select(pdi,IM_ISO14443A_106,NULL,NULL,&ti)) + { + printf("The following (NFC) ISO14443A tag was found:\n\n"); + printf(" ATQA (SENS_RES): "); print_hex(ti.tia.abtAtqa,2); + printf(" UID (NFCID%c): ",(ti.tia.abtUid[0]==0x08?'3':'1')); print_hex(ti.tia.abtUid,ti.tia.uiUidLen); + printf(" SAK (SEL_RES): "); print_hex(&ti.tia.btSak,1); + if (ti.tia.uiAtsLen) + { + printf(" ATS (ATR): "); + print_hex(ti.tia.abtAts,ti.tia.uiAtsLen); + } + } + + // Poll for a Felica tag + if (nfc_reader_select(pdi,IM_FELICA_212,abtFelica,5,&ti) || nfc_reader_select(pdi,IM_FELICA_424,abtFelica,5,&ti)) + { + printf("The following (NFC) Felica tag was found:\n\n"); + printf("%18s","ID (NFCID2): "); print_hex(ti.tif.abtId,8); + printf("%18s","Parameter (PAD): "); print_hex(ti.tif.abtPad,8); + } + + // Poll for a ISO14443B tag + if (nfc_reader_select(pdi,IM_ISO14443B_106,NULL,NULL,&ti)) + { + // No test results yet + printf("iso14443b\n"); + } + + // Poll for a Jewel tag + if (nfc_reader_select(pdi,IM_JEWEL_106,NULL,NULL,&ti)) + { + // No test results yet + printf("jewel\n"); + } + + nfc_disconnect(pdi); + return 1; +} diff --git a/src/mftool.c b/src/mftool.c index 39c2229..c52874d 100644 --- a/src/mftool.c +++ b/src/mftool.c @@ -21,6 +21,8 @@ along with this program. If not, see . #include #include #include +#include + #include #include @@ -72,7 +74,7 @@ bool read_card() { printf("x"); // When a failure occured we need to redo the anti-collision - if (!nfc_reader_select(pdi,IM_ISO14443A_106,null,null,&ti)) + if (!nfc_reader_select(pdi,IM_ISO14443A_106,NULL,NULL,&ti)) { printf("!\nError: tag was removed\n"); return 1; @@ -155,7 +157,7 @@ bool write_card() { printf("x"); // When a failure occured we need to redo the anti-collision - if (!nfc_reader_select(pdi,IM_ISO14443A_106,null,null,&ti)) + if (!nfc_reader_select(pdi,IM_ISO14443A_106,NULL,NULL,&ti)) { printf("!\nError: tag was removed\n"); return false; @@ -251,7 +253,7 @@ int main(int argc, const char* argv[]) bUseKeyA = (tolower(*(argv[2])) == 'a'); pfKeys = fopen(argv[3],"rb"); - if (pfKeys == null) + if (pfKeys == NULL) { printf("Could not open file: %s\n",argv[3]); return 1; @@ -270,7 +272,7 @@ int main(int argc, const char* argv[]) } else { pfDump = fopen(argv[4],"rb"); - if (pfDump == null) + if (pfDump == NULL) { printf("Could not open dump file: %s\n",argv[4]); return 1; @@ -310,7 +312,7 @@ int main(int argc, const char* argv[]) printf("Connected to NFC reader: %s\n",pdi->acName); // Try to find a MIFARE Classic tag - if (!nfc_reader_select(pdi,IM_ISO14443A_106,null,null,&ti)) + if (!nfc_reader_select(pdi,IM_ISO14443A_106,NULL,NULL,&ti)) { printf("Error: no tag was found\n"); nfc_disconnect(pdi); @@ -349,7 +351,7 @@ int main(int argc, const char* argv[]) printf("Writing data to file: %s\n",argv[4]); fflush(stdout); pfDump = fopen(argv[4],"wb"); - if (pfKeys == null) + if (pfKeys == NULL) { printf("Could not open file: %s\n",argv[4]); return 1;