mirror of
https://github.com/nmap/nmap.git
synced 2026-01-29 09:39:03 +00:00
Remove trailing whitespace in lua files
Whitespace is not significant, so this should not be a problem. https://secwiki.org/w/Nmap/Code_Standards
This commit is contained in:
@@ -13,27 +13,27 @@ _ENV = stdnse.module("gps", stdnse.seeall)
|
||||
--
|
||||
--
|
||||
|
||||
NMEA = {
|
||||
NMEA = {
|
||||
|
||||
-- Parser for the RMC sentence
|
||||
RMC = {
|
||||
|
||||
|
||||
parse = function(str)
|
||||
|
||||
|
||||
local time, status, latitude, ns_indicator, longitude,
|
||||
ew_indicator, speed, course, date, variation,
|
||||
ew_variation, checksum = str:match("^%$GPRMC,([^,]*),([^,]*),([^,]*),([^,]*),([^,]*),([^,]*),([^,]*),([^,]*),([^,]*),([^,]*),([^%*]*)(.*)$")
|
||||
|
||||
|
||||
if ( not(latitude) or not(longitude) ) then
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
local deg, min = latitude:match("^(..)(.*)$")
|
||||
if ( not(deg) or not(min) ) then
|
||||
return
|
||||
end
|
||||
latitude = tonumber(deg) + (tonumber(min)/60)
|
||||
|
||||
|
||||
deg, min = longitude:match("^(..)(.*)$")
|
||||
if ( not(deg) or not(min) ) then
|
||||
return
|
||||
@@ -46,15 +46,15 @@ NMEA = {
|
||||
if ( ns_indicator == 'S' ) then
|
||||
latitude = -latitude
|
||||
end
|
||||
|
||||
|
||||
return { time = time, status = status, latitude = latitude,
|
||||
longitude = longitude, speed = speed, course = course,
|
||||
date = date, variation = variation,
|
||||
date = date, variation = variation,
|
||||
ew_variation = ew_variation }
|
||||
end,
|
||||
|
||||
|
||||
},
|
||||
|
||||
|
||||
-- Calculates an verifies the message checksum
|
||||
--
|
||||
-- @param str containing the GPS sentence
|
||||
@@ -65,7 +65,7 @@ NMEA = {
|
||||
for c in str:sub(2,-4):gmatch(".") do
|
||||
val = bit.bxor(val, string.byte(c))
|
||||
end
|
||||
|
||||
|
||||
if ( str:sub(-2):upper() ~= stdnse.tohex(string.char(val)):upper() ) then
|
||||
return false, ("Failed to verify checksum (got: %s; expected: %s)"):format(stdnse.tohex(string.char(val)), str:sub(-2))
|
||||
end
|
||||
@@ -75,16 +75,16 @@ NMEA = {
|
||||
-- Parses a GPS sentence using the apropriate parser
|
||||
--
|
||||
-- @param str containing the GPS sentence
|
||||
-- @return entry table containing the parsed response or
|
||||
-- @return entry table containing the parsed response or
|
||||
-- err string if status is false
|
||||
-- @return status true on success, false on failure
|
||||
parse = function(str)
|
||||
|
||||
|
||||
local status, err = NMEA.checksum(str)
|
||||
if ( not(status) ) then
|
||||
return false, err
|
||||
end
|
||||
|
||||
|
||||
local prefix = str:match("^%$GP([^,]*)")
|
||||
if ( not(prefix) ) then
|
||||
return false, "Not a NMEA sentence"
|
||||
@@ -101,9 +101,9 @@ NMEA = {
|
||||
stdnse.print_debug(2, err)
|
||||
return false, err
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
}
|
||||
|
||||
Util = {
|
||||
@@ -111,7 +111,7 @@ Util = {
|
||||
convertTime = function(date, time)
|
||||
local d = {}
|
||||
d.hour, d.min, d.sec = time:match("(..)(..)(..)")
|
||||
d.day, d.month, d.year = date:match("(..)(..)(..)")
|
||||
d.day, d.month, d.year = date:match("(..)(..)(..)")
|
||||
d.year = d.year + 2000
|
||||
return os.time(d)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user