1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-29 10:59:02 +00:00

Reduce debugging further.

This is still too verbose for some use cases.
This commit is contained in:
batrick
2016-07-16 17:24:19 +00:00
parent 34af9d438e
commit 62c4985536

View File

@@ -42,8 +42,8 @@
-- @class module
-- @name bin
local debug2 = require "stdnse".debug2
local debug3 = require "stdnse".debug3
local debug4 = require "stdnse".debug4
local debug5 = require "stdnse".debug5
local assert = assert
local error = error
@@ -71,7 +71,7 @@ local function clamp (args, i, j, mask)
local o = assert(tointeger(args[i]))
local n = o & mask
if o ~= n then
debug2("bin.pack: clamping arg[%d]: 0x%x -> 0x%x", i, o, n)
debug4("bin.pack: clamping arg[%d]: 0x%x -> 0x%x", i, o, n)
end
args[i] = n
end
@@ -90,7 +90,7 @@ end
-- @param ... The values to pack.
-- @return String containing packed data.
function _ENV.pack (format, ...)
debug3("bin.pack: format = '%s'", format);
debug5("bin.pack: format = '%s'", format);
format = "!1="..format -- 1 byte alignment
local endianness = "="
local i, args = 1, pack(...)
@@ -176,7 +176,7 @@ function _ENV.pack (format, ...)
end
end
format = format:gsub("([%a=<>])(%d*)", translate)
debug3("bin.pack: string.pack(format = '%s', ...)", format)
debug5("bin.pack: string.pack(format = '%s', ...)", format)
return format.pack(format, unpack(args)) -- don't use method syntax for better error message
end
@@ -238,7 +238,7 @@ end
-- @return Position in the data string where unpacking stopped.
-- @return All unpacked values.
function _ENV.unpack (format, data, init)
debug3("bin.unpack: format = '%s'", format);
debug5("bin.unpack: format = '%s'", format);
format = "!1="..format -- 1 byte alignment
if type(init) == "number" and init <= 0 then init = 1 end
local endianness = "="
@@ -300,7 +300,7 @@ function _ENV.unpack (format, data, init)
end
end
format = format:gsub("([%a=<>])(%d*)", translate)
debug3("bin.unpack: string.unpack(format = '%s', ...)", format)
debug5("bin.unpack: string.unpack(format = '%s', ...)", format)
return unpacker(fixer, pcall(format.unpack, format, data, init))
end