Parent

Included Modules

Nmap::XmlParsing::MyParser

Constants

IGNORED

We don't want to store anything we don't care about!

Attributes

hosts[R]
session[R]

Public Class Methods

new(callback) click to toggle source
# File lib/nmap/parser.rb, line 1833
def initialize(callback)
        @data = {}
        @loc = []

        @session = nil
        @hosts = []

        @callback = callback
end

Public Instance Methods

completed?() click to toggle source
# File lib/nmap/parser.rb, line 1812
def completed?
        # @session becomes non-nil when <nmaprun> closes, which means
        # we're done
        @session ? true : false
end
method_missing(sym, *args) click to toggle source
# File lib/nmap/parser.rb, line 1809
def method_missing(sym, *args)
end
tag_end(tag) click to toggle source
# File lib/nmap/parser.rb, line 1778
def tag_end(tag)
        name = tag.to_sym

        return if ignored(name)

        last = @loc.pop

        case name
        when :host
                @hosts << Parser::Host.new(last)
                @loc[@loc.size - 2][:kids].pop

                if @callback
                        Thread.new(@hosts.last) do |host|
                                Thread.current[:cb] = true
                                @callback.call(host)
                        end
                end
        when :nmaprun
                @session = Parser::Session.new(last)

                if @callback and Thread.list.size > 1
                        Thread.list.reject { |t|
                                not t[:cb]
                        }.each { |t|
                                t.join
                        }
                end
        end
end
tag_start(tag, attrs) click to toggle source
# File lib/nmap/parser.rb, line 1762
def tag_start(tag, attrs)
        name = tag.to_sym

        return if ignored(name)

        kv = XmlParsing::Tag.new(name, attrs)

        if @data.empty?
                @data[name] = kv
        else
                @loc.last[:kids].push(kv)
        end

        @loc.push(kv)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.