mirror of
https://github.com/nmap/nmap.git
synced 2025-12-15 12:19:02 +00:00
Merged Lpeg branch
This commit is contained in:
@@ -5,37 +5,16 @@
|
||||
-- <code>nmap.receive_buf</code> function in the Network I/O API (which see).
|
||||
-- @copyright Same as Nmap--See http://nmap.org/book/man-legal.html
|
||||
|
||||
local pcre = require "pcre"
|
||||
local stdnse = require "stdnse"
|
||||
_ENV = stdnse.module("match", stdnse.seeall)
|
||||
|
||||
--various functions for use with NSE's nsock:receive_buf - function
|
||||
|
||||
-- e.g.
|
||||
-- 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.
|
||||
--
|
||||
-- This function is a wrapper around <code>pcre.exec</code>. Its purpose is to
|
||||
-- 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"), true)
|
||||
-- @see nmap.receive_buf
|
||||
-- @see pcre.exec
|
||||
regex = function(pattern)
|
||||
local r = pcre.new(pattern, 0,"C")
|
||||
|
||||
return function(buf)
|
||||
local s,e = r:exec(buf, 0,0);
|
||||
return s,e
|
||||
end
|
||||
end
|
||||
|
||||
--- Return a function that allows delimiting at a certain number of bytes.
|
||||
--
|
||||
-- This function can be used to get a buffered version of
|
||||
|
||||
Reference in New Issue
Block a user