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

Reformat and merge documentation for some NSE modules: comm, datafiles, dns,

http, ipOps, listop, and match. This is mainly merging the best documentation
from the module source and scripting.xml into the module, with the aim of
making the source code the canonical source for module documentation.
This commit is contained in:
david
2008-10-15 22:03:14 +00:00
parent 4b17b36913
commit 12e34eb5b0
8 changed files with 237 additions and 677 deletions

View File

@@ -1,5 +1,7 @@
--- Provides functions which can be used for delimiting data received
-- by receive_buf() function in the Network I/O API.
--- Buffered network I/O helper functions.
-- \n\n
-- The functions in this module can be used for delimiting data received
-- by the receive_buf function in the Network I/O API.
--@copyright See nmaps COPYING for licence
module(... or "match", package.seeall)
@@ -14,13 +16,13 @@ require "pcre"
-- 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")).
--- Return a function that allows delimiting with a regular expression.
-- \n\n
-- This function is a wrapper around the exec function of the pcre
-- library. It purpose is to give script developers the ability to use
-- regular expressions for delimiting instead of Lua's string patterns.
-- @param The regex.
-- @usage sock:receivebuf(regex("myregexpattern"))
regex = function(pattern)
local r = pcre.new(pattern, 0,"C")
@@ -30,12 +32,15 @@ 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.
--- Return a function that allows delimiting at a certain number of bytes.
-- \n\n
-- This function 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.
-- @usage sock:receivebuf(numbytes(80))
numbytes = function(num)
local n = num
return function(buf)