CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/lib/postgres/byteorder.rb
Views: 1904
1
# -*- coding: binary -*-
2
require 'postgres_msf'
3
4
# Namespace for Metasploit branch.
5
module Msf
6
module Db
7
8
module ByteOrder
9
Native = :Native
10
BigEndian = Big = Network = :BigEndian
11
LittleEndian = Little = :LittleEndian
12
13
# examines the byte order of the underlying machine
14
def byte_order
15
if [0x12345678].pack("L") == "\x12\x34\x56\x78"
16
BigEndian
17
else
18
LittleEndian
19
end
20
end
21
22
alias byteorder byte_order
23
24
def little_endian?
25
byte_order == LittleEndian
26
end
27
28
def big_endian?
29
byte_order == BigEndian
30
end
31
32
alias little? little_endian?
33
alias big? big_endian?
34
alias network? big_endian?
35
36
module_function :byte_order, :byteorder
37
module_function :little_endian?, :little?
38
module_function :big_endian?, :big?, :network?
39
end
40
41
end
42
end
43
44