Files
metasploit-gs/lib/postgres/byteorder.rb
T
Tod Beardsley a65af9c8b3 See #730. Forking and adding Postgres-PR, with the following changes:
Namespaced everything under Msf::Db::PostgreSQL, renamed top-level include to postgres_msf to disambiguate.
Included recursive requires for all files.
Noted the IO monkeypatch -- should revisit.
Added a testcase for database connections.

The reason for the namespacing is to avoid stomping on any existing Postgres-PR installations, or any other requires named "postgres" or "postgresql" or even "pg," since these may or may not support the method's we're using here. The seperate namespace also allows for easier integration of custom commands later on.




git-svn-id: file:///home/svn/framework3/trunk@8342 4d416f70-5f16-0410-b530-b9f4589650da
2010-02-01 19:49:36 +00:00

42 lines
761 B
Ruby

require 'postgres_msf'
# Namespace for Metasploit branch.
module Msf
module Db
module ByteOrder
Native = :Native
BigEndian = Big = Network = :BigEndian
LittleEndian = Little = :LittleEndian
# examines the byte order of the underlying machine
def byte_order
if [0x12345678].pack("L") == "\x12\x34\x56\x78"
BigEndian
else
LittleEndian
end
end
alias byteorder byte_order
def little_endian?
byte_order == LittleEndian
end
def big_endian?
byte_order == BigEndian
end
alias little? little_endian?
alias big? big_endian?
alias network? big_endian?
module_function :byte_order, :byteorder
module_function :little_endian?, :little?
module_function :big_endian?, :big?, :network?
end
end
end