diff --git a/client/lualibs/commands.lua b/client/lualibs/commands.lua index 4a7780ff9..244f3e6a1 100644 --- a/client/lualibs/commands.lua +++ b/client/lualibs/commands.lua @@ -92,13 +92,13 @@ Command = { end o.data = data return o - end, + end, parse = function (packet) local count, cmd, arg1, arg2, arg3, data = bin.unpack('LLLLH511', packet) return Command:new{cmd = cmd, arg1 = arg1, arg2 = arg2, arg3 = arg3, data = data} - end + end } --- commented out, not used. +-- commented out, not used. function Command:__tostring() local output = ("%s\r\nargs : (%s, %s, %s)\r\ndata:\r\n%s\r\n"):format( _commands.tostring(self.cmd), @@ -128,7 +128,7 @@ function Command:__responsetostring() tostring(self.resp_arg1), tostring(self.resp_arg2), tostring(self.resp_arg3))) - print('NG ::', self.resp_ng) + print('NG ::', self.resp_ng) print('package ::', self.resp_response) end @@ -144,10 +144,10 @@ function Command:sendMIX( ignore_response, timeout ) local data = self.data local cmd = self.cmd local arg1, arg2, arg3 = self.arg1, self.arg2, self.arg3 - + local err, msg = core.SendCommandMIX(cmd, arg1, arg2, arg3, data) if err == nil then return err, msg end - + if ignore_response then return true, nil end if timeout == nil then timeout = TIMEOUT end @@ -156,13 +156,13 @@ function Command:sendMIX( ignore_response, timeout ) if response == nil then return nil, 'Error, waiting for response timed out :: '..msg end - - -- lets digest + + -- lets digest local data local count, cmd, length, magic, status, crc, arg1, arg2, arg3 = bin.unpack('SSIsSLLL', response) count, data, ng = bin.unpack('H'..length..'C', response, count) - ---[[ uncomment if you want to debug + +--[[ uncomment if you want to debug self.resp_cmd = cmd self.resp_length = length self.resp_magic = magic @@ -181,20 +181,20 @@ function Command:sendMIX( ignore_response, timeout ) end function Command:sendNG( ignore_response, timeout ) local data = self.data - local cmd = self.cmd + local cmd = self.cmd local err, msg = core.SendCommandNG(cmd, data) if err == nil then return err, msg end - + if ignore_response then return true, nil end - + if timeout == nil then timeout = TIMEOUT end - + local response, msg = core.WaitForResponseTimeout(cmd, timeout) if response == nil then return nil, 'Error, waiting for response timed out :: '..msg end - - -- lets digest + + -- lets digest local data local count, cmd, length, magic, status, crc, arg1, arg2, arg3 = bin.unpack('SSIsSLLL', response) count, data, ng = bin.unpack('H'..length..'C', response, count) diff --git a/client/lualibs/read14a.lua b/client/lualibs/read14a.lua index 2f75fe81c..537f090b9 100644 --- a/client/lualibs/read14a.lua +++ b/client/lualibs/read14a.lua @@ -89,7 +89,7 @@ local function read14443a(dont_disconnect, no_rats) if no_rats then command.arg1 = command.arg1 + ISO14A_COMMAND.ISO14A_NO_RATS end - + local result,err = command:sendMIX() if result then local count,cmd,arg0,arg1,arg2 = bin.unpack('LLLL',result) diff --git a/client/proxmark3.c b/client/proxmark3.c index db8478d2e..bb6553a09 100644 --- a/client/proxmark3.c +++ b/client/proxmark3.c @@ -183,11 +183,11 @@ main_loop(char *script_cmds_file, char *script_cmd, bool pm3_present) { cmd[--l] = '\0'; } // ltrim - size_t off=0; + size_t off = 0; while ((cmd[off] != '\0') && isspace(cmd[off])) off++; - for (size_t i=0; i < strlen(cmd) - off; i++) - cmd[i] = cmd[i+off]; + for (size_t i = 0; i < strlen(cmd) - off; i++) + cmd[i] = cmd[i + off]; cmd[strlen(cmd) - off] = '\0'; if (cmd[0] != '\0') { diff --git a/client/scripting.c b/client/scripting.c index 309e5dc40..5aa76d33c 100644 --- a/client/scripting.c +++ b/client/scripting.c @@ -73,10 +73,10 @@ static int l_SendCommandOLD(lua_State *L) { } // parse input - cmd = luaL_checknumber(L, 1); + cmd = luaL_checknumber(L, 1); arg0 = luaL_checknumber(L, 2); arg1 = luaL_checknumber(L, 3); - arg2 = luaL_checknumber(L, 4); + arg2 = luaL_checknumber(L, 4); // data const char *p_data = luaL_checklstring(L, 5, &size); @@ -93,7 +93,7 @@ static int l_SendCommandOLD(lua_State *L) { } SendCommandOLD(cmd, arg0, arg1, arg2, data, len); - lua_pushboolean(L, true); + lua_pushboolean(L, true); return 1; } @@ -120,10 +120,10 @@ static int l_SendCommandMIX(lua_State *L) { return returnToLuaWithError(L, "You need to supply five parameters"); // parse input - cmd = luaL_checknumber(L, 1); + cmd = luaL_checknumber(L, 1); arg0 = luaL_checknumber(L, 2); arg1 = luaL_checknumber(L, 3); - arg2 = luaL_checknumber(L, 4); + arg2 = luaL_checknumber(L, 4); // data const char *p_data = luaL_checklstring(L, 5, &size); @@ -162,7 +162,7 @@ static int l_SendCommandNG(lua_State *L) { return returnToLuaWithError(L, "You need to supply two parameters"); // parse input - uint64_t cmd = luaL_checknumber(L, 1); + uint64_t cmd = luaL_checknumber(L, 1); // data const char *p_data = luaL_checklstring(L, 2, &size); diff --git a/client/scripts/ndef_dump.lua b/client/scripts/ndef_dump.lua index fee7af9fe..a89c4f32a 100644 --- a/client/scripts/ndef_dump.lua +++ b/client/scripts/ndef_dump.lua @@ -174,7 +174,7 @@ local function main( args) local blocks, err = getBlock(0) if err then close() - return oops(err) + return oops(err) end -- Block 3 contains number of blocks local b3chars = {string.byte(blocks[4], 1,4)} diff --git a/client/scripts/test_t55x7.lua b/client/scripts/test_t55x7.lua index 478336313..412f4acb8 100644 --- a/client/scripts/test_t55x7.lua +++ b/client/scripts/test_t55x7.lua @@ -80,7 +80,7 @@ local function help() print(desc) print("Example usage") print(example) - print(usage) + print(usage) end --- -- Exit message @@ -261,7 +261,7 @@ local function test(modulation) , arg2 = block } local response, err = wc:sendMIX(false) - if not response then return oops(err) end + if not response then return oops(err) end -- Detect local res, msg = core.t55xx_detect() @@ -323,7 +323,7 @@ local function main(args) end exitMsg('Tests finished') - core.console( + core.console( format('rem [SUMMARY] Success rate: %d/%d tests passed%s' , total_pass , total_tests diff --git a/client/scripts/tnp3clone.lua b/client/scripts/tnp3clone.lua index 0bb18375b..1e3545a1b 100644 --- a/client/scripts/tnp3clone.lua +++ b/client/scripts/tnp3clone.lua @@ -63,7 +63,7 @@ local function getblockdata(response) if not response then return nil, 'No response from device' end - + local count, cmd, arg0 = bin.unpack('LL', response) if arg0 == 1 then local count, arg1, arg2, data = bin.unpack('LLH511', response, count) @@ -81,7 +81,7 @@ local function readblock( blocknum, keyA ) return b end --- --- decode response and get the blockdata from backdoor magic command +-- decode response and get the blockdata from backdoor magic command local function readmagicblock( blocknum ) -- Read block N local CSETBLOCK_SINGLE_OPERATION = 0x1F diff --git a/client/scripts/tnp3dump.lua b/client/scripts/tnp3dump.lua index b0db89718..7da530f7d 100644 --- a/client/scripts/tnp3dump.lua +++ b/client/scripts/tnp3dump.lua @@ -91,7 +91,7 @@ local function getblockdata(response) if not response then return nil, 'No response from device' end - + local count, cmd, arg0 = bin.unpack('LL', response) if arg0 == 1 then local count, arg1, arg2, data = bin.unpack('LLH511', response, count) @@ -132,7 +132,7 @@ local function main(args) local cmdSetDbgOff = "hf mf dbg 0" core.console( cmdSetDbgOff) utils.Sleep(0.5) - + result, err = lib14a.read(false, true) if not result then return oops(err) end @@ -170,7 +170,7 @@ local function main(args) cmd = Command:newMIX{cmd = cmds.CMD_MIFARE_READBL, arg1 = 0, data = keyA} block0, err = getblockdata(cmd:sendMIX(false)) if not block0 then return oops(err) end - + core.clearCommandBuffer() -- Read block 1 diff --git a/client/scripts/tnp3sim.lua b/client/scripts/tnp3sim.lua index 8ba56238d..8e595363e 100644 --- a/client/scripts/tnp3sim.lua +++ b/client/scripts/tnp3sim.lua @@ -242,7 +242,7 @@ local function LoadEmulator(uid, blocks) blockdata = AddKey(keys, _, blockdata) end end - + io.write( _..',') io.flush() core.clearCommandBuffer() diff --git a/client/scripts/ufodump.lua b/client/scripts/ufodump.lua index 0270bafaa..d3d039741 100644 --- a/client/scripts/ufodump.lua +++ b/client/scripts/ufodump.lua @@ -15,7 +15,7 @@ xor: the first three block (0,1,2) is not XORED. The rest seems to be xored. example = [[ -- default script run ufodump - + -- stop at block 10 script run ufodump -b 10 ]] @@ -48,7 +48,7 @@ end local function oops(err) print('ERROR:', err) core.clearCommandBuffer() - return nil, err + return nil, err end --- -- Usage help @@ -59,7 +59,7 @@ local function help() print(desc) print('Example usage') print(example) - print(usage) + print(usage) end -- -- writes data to ascii textfile. @@ -122,7 +122,7 @@ function sendRaw(rawdata, options) -- of the ASCII-string rawdata arg2 = string.len(rawdata)/2, data = rawdata} - + return command:sendMIX(options.ignore_response) end -- diff --git a/client/scripts/ul_uid.lua b/client/scripts/ul_uid.lua index 7b806b1fe..9ac89c211 100644 --- a/client/scripts/ul_uid.lua +++ b/client/scripts/ul_uid.lua @@ -57,7 +57,7 @@ local function help() print(desc) print('Example usage') print(example) - print(usage) + print(usage) end -- --- Set UID on magic command enabled diff --git a/client/util.c b/client/util.c index ddb38fc27..50bbe0516 100644 --- a/client/util.c +++ b/client/util.c @@ -832,8 +832,7 @@ bool str_startswith(const char *s, const char *pre) { bool str_endswith(const char *s, const char *suffix) { size_t ls = strlen(s); size_t lsuffix = strlen(suffix); - if (ls >= lsuffix) - { + if (ls >= lsuffix) { return strncmp(suffix, s + (ls - lsuffix), lsuffix) == 0; } return false;