1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-22 15:39:03 +00:00

Update the usage examples in match.lua

The example uses of nmap.receive_buf() were missing the second
parameter, keeppattern. Also referenced the match library from
nmap.receive_buf's NSEdoc to avoid reimplementations of buffered
sockets.
This commit is contained in:
dmiller
2014-02-10 19:39:09 +00:00
parent 4e7e7c04f0
commit 298c42d3b4
2 changed files with 12 additions and 7 deletions

View File

@@ -12,11 +12,11 @@ _ENV = stdnse.module("match", stdnse.seeall)
--various functions for use with nse's nsock:receive_buf - function
-- e.g.
-- sock:receive_buf(regex("myregexpattern")) - does a match using pcre- regular-
-- - expressions
-- sock:receive_buf(numbytes(80)) - is the buffered version of
-- sock:receive_bytes(80) - i.e. it returns
-- exactly 80 bytes and no more
-- sock:receive_buf(regex("myregexpattern"), true) - does a match using pcre
-- regular expressions
-- sock:receive_buf(numbytes(80), true) - is the buffered version of
-- sock:receive_bytes(80) - i.e. it
-- returns exactly 80 bytes and no more
--- Return a function that allows delimiting with a regular expression.
--
@@ -24,7 +24,7 @@ _ENV = stdnse.module("match", stdnse.seeall)
-- give script developers the ability to use regular expressions for delimiting
-- instead of Lua's string patterns.
-- @param pattern The regex.
-- @usage sock:receive_buf(match.regex("myregexpattern"))
-- @usage sock:receive_buf(match.regex("myregexpattern"), true)
-- @see nmap.receive_buf
-- @see pcre.exec
regex = function(pattern)
@@ -42,8 +42,12 @@ end
-- <code>sock:receive_bytes(n)</code> in case a script requires more than one
-- fixed-size chunk, as the unbuffered version may return more bytes than
-- requested and thus would require you to do the parsing on your own.
--
-- The <code>keeppattern</code> parameter to receive_buf should be set to
-- <code>true</code>, otherwise the string returned will be 1 less than
-- <code>num</code>
-- @param num Number of bytes.
-- @usage sock:receive_buf(match.numbytes(80))
-- @usage sock:receive_buf(match.numbytes(80), true)
-- @see nmap.receive_buf
numbytes = function(num)
local n = num