prstmidx.rb
#----------------------------------------------------------
# prstmidx.rb -  Print all the streams in the capture file
#  Alternate approach demostrating Ruby Classes
#
#  usage: prstmidx <capture-filename>
#
#---------------------------------------------------------
require 'win32ole'
 
USAGE = "prstmidx <capture-filename>"
endl  = "\n"
tab   = "\t"
 
 
class UStream
	def initialize(usnfstream)
		@stm = usnfstream
	end
 
	def to_s
		"#{@stm.ID}\t#{@stm.StartTimeStamp}\t#{@stm.SourceAddress}\t" +
		"#{@stm.DestinationAddress}\t#{@stm.InByteCount}\t#{@stm.OutByteCount}\t" +
		"#{@stm.Description}\n" 
	end
end
 
class StreamList
	def initialize(stmindex)
		@streamList = Array.new
 
		count = stmindex.Count
		(0..count-1).each { |idx| @streamList.push( UStream.new(stmindex.Item(idx)) ) }
	end
 
	def to_s
		s = "Number of streams in capture file = #{@streamList.length}\n"
		@streamList.each { |itm| s += itm.to_s }
		s
	end
end
 
 
if ARGV.length != 1
	puts USAGE
	exit 1
end
 
UnsniffDB = WIN32OLE.new("Unsniff.Database")
UnsniffDB.Open(ARGV[0])
 
slist = StreamList.new(UnsniffDB.StreamIndex)
print slist
 
UnsniffDB.Close()
unsniff/samples/prstmidx/ruby.txt · Last modified: 2014/09/11 23:23 (external edit)
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki