mirror of
https://github.com/nmap/nmap.git
synced 2025-12-25 00:49:01 +00:00
Updated all libraries documentation.
packet and url both need more work.
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
-- See nmaps COPYING for licence
|
||||
--- Provides functions which can be used for delimiting data received
|
||||
-- by receive_buf() function in the Network I/O API.
|
||||
--@copyright See nmaps COPYING for licence
|
||||
|
||||
module(... or "match", package.seeall)
|
||||
require "pcre"
|
||||
|
||||
@@ -10,6 +13,14 @@ require "pcre"
|
||||
-- sock:receivebuf(numbytes(80)) - is the buffered version of
|
||||
-- sock:receive_bytes(80) - i.e. it returns
|
||||
-- exactly 80 bytes and no more
|
||||
|
||||
--- This is actually a wrapper around NSE's PCRE library exec function,
|
||||
-- thus giving script developers the possibility to use regular expressions
|
||||
-- for delimiting instead of Lua's string patterns. If you want to get the
|
||||
-- data in chunks separated by pattern (which has to be a valid regular
|
||||
-- expression), you would write:
|
||||
-- status, val = sockobj:receive_buf(match.regex("pattern")).
|
||||
-- @param The regex.
|
||||
regex = function(pattern)
|
||||
local r = pcre.new(pattern, 0,"C")
|
||||
|
||||
@@ -19,6 +30,12 @@ regex = function(pattern)
|
||||
end
|
||||
end
|
||||
|
||||
--- Takes a number as its argument and returns that many bytes. It can be
|
||||
-- used to get a buffered version of sockobj:receive_bytes(n) 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.
|
||||
-- @param num Number of bytes.
|
||||
numbytes = function(num)
|
||||
local n = num
|
||||
return function(buf)
|
||||
|
||||
Reference in New Issue
Block a user