1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-06 12:41:29 +00:00

merge soc07 r4989 - applied mathew boyle's patch for print_debug

This commit is contained in:
fyodor
2007-08-11 04:39:17 +00:00
parent 7652ebeefb
commit e988f4878d
3 changed files with 18 additions and 8 deletions

View File

@@ -402,13 +402,14 @@ static int l_print_debug_unformatted(lua_State *l) {
int verbosity=1, stack_counter(1); int verbosity=1, stack_counter(1);
const char *out; const char *out;
if (lua_isnumber (l, 1) && (lua_gettop(l) > 1)) { if (lua_gettop(l) != 2) return luaL_error(l, "Incorrect number of arguments\n");
verbosity = lua_tointeger(l, 1);
verbosity = luaL_checkinteger(l, 1);
if (verbosity > o.verbose) return 0; if (verbosity > o.verbose) return 0;
stack_counter++; out = luaL_checkstring(l, 2);
}
out = luaL_checkstring(l, stack_counter); log_write(LOG_STDOUT, "%s DEBUG: %s\n", SCRIPT_ENGINE, out);
log_write(LOG_STDOUT, "%s NSE DEBUG: %s\n", SCRIPT_ENGINE, out);
return 0; return 0;
} }

9
nselib/stdnse.lua Normal file
View File

@@ -0,0 +1,9 @@
print_debug = function(...)
local verbosity = 1;
if ((#arg > 1) and (tonumber(arg[1]))) then
verbosity = table.remove(arg, 1);
end
nmap.print_debug_unformatted(verbosity, string.format(unpack(arg, start)));
end

View File

@@ -50,7 +50,7 @@ action = function(host, port)
if title ~= nil then if title ~= nil then
result = string.gsub(title , "[\n\r\t]", "") result = string.gsub(title , "[\n\r\t]", "")
if string.len(title) > 50 then if string.len(title) > 50 then
nmap.print_debug_unformatted("showHTMLTitle.nse: Title got truncated!"); nmap.print_debug("showHTMLTitle.nse: Title got truncated!");
result = string.sub(result, 1, 62) .. "..." result = string.sub(result, 1, 62) .. "..."
end end
else else