Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
_CPIO_BINARY_LITTLE_ENDIAN_FILE_ENTRY_STRUCT = construct.Struct(
u'cpio_binary_little_endian_file_entry',
construct.ULInt16(u'signature'),
construct.ULInt16(u'device_number'),
construct.ULInt16(u'inode_number'),
construct.ULInt16(u'mode'),
construct.ULInt16(u'user_identifier'),
construct.ULInt16(u'group_identifier'),
construct.ULInt16(u'number_of_links'),
construct.ULInt16(u'special_device_number'),
construct.ULInt16(u'modification_time_upper'),
construct.ULInt16(u'modification_time_lower'),
construct.ULInt16(u'path_string_size'),
construct.ULInt16(u'file_size_upper'),
construct.ULInt16(u'file_size_lower'))
_CPIO_PORTABLE_ASCII_FILE_ENTRY_STRUCT = construct.Struct(
u'cpio_portable_ascii_file_entry',
construct.Bytes(u'signature', 6),
construct.Bytes(u'device_number', 6),
construct.Bytes(u'inode_number', 6),
construct.Bytes(u'mode', 6),
construct.Bytes(u'user_identifier', 6),
construct.Bytes(u'group_identifier', 6),
construct.Bytes(u'number_of_links', 6),
construct.Bytes(u'special_device_number', 6),
construct.Bytes(u'modification_time', 11),
construct.Bytes(u'path_string_size', 6),
construct.Bytes(u'file_size', 11))
_CPIO_NEW_ASCII_FILE_ENTRY_STRUCT = construct.Struct(
construct.ULInt32(u'unknown3'))
_DEST_LIST_STREAM_ENTRY_V1 = construct.Struct(
u'dest_list_stream_entry_v1',
construct.ULInt64(u'unknown1'),
construct.Bytes(u'droid_volume_identifier', 16),
construct.Bytes(u'droid_file_identifier', 16),
construct.Bytes(u'birth_droid_volume_identifier', 16),
construct.Bytes(u'birth_droid_file_identifier', 16),
construct.String(u'hostname', 16),
construct.ULInt32(u'entry_number'),
construct.ULInt32(u'unknown2'),
construct.LFloat32(u'unknown3'),
construct.ULInt64(u'last_modification_time'),
construct.ULInt32(u'pin_status'),
construct.ULInt16(u'path_size'))
_DEST_LIST_STREAM_ENTRY_V3 = construct.Struct(
u'dest_list_stream_entry_v3',
construct.ULInt64(u'unknown1'),
construct.Bytes(u'droid_volume_identifier', 16),
construct.Bytes(u'droid_file_identifier', 16),
construct.Bytes(u'birth_droid_volume_identifier', 16),
construct.Bytes(u'birth_droid_file_identifier', 16),
construct.String(u'hostname', 16),
construct.ULInt32(u'entry_number'),
construct.ULInt32(u'unknown2'),
construct.LFloat32(u'unknown3'),
construct.ULInt64(u'last_modification_time'),
construct.ULInt32(u'pin_status'),
construct.ULInt32(u'unknown4'),
construct.ULInt32(u'unknown5'),
def reel_header_le():
REEL = construct.Struct("REEL",
# Job identification number
construct.ULInt32("jobid"),
construct.ULInt32("lino"), # Line number
construct.ULInt32("reno"), # Reel number
construct.ULInt16("ntrpr"), # Traces per ensemble
# Aux traces per ensemble
construct.ULInt16("nart"),
# *** Sample interval us ***
construct.ULInt16("hdt"),
construct.ULInt16("dto"), # Field sample interval
# *** Number of samples per trace ***
construct.ULInt16("hns"),
# Field samples per trace
construct.ULInt16("nso"),
# *** Data format, 5 = 4-byte IEEE ***
construct.ULInt16("format"),
construct.ULInt16("fold"), # Ensemble fold
# Trace sorting code, 5 == shot gathers
construct.ULInt16("tsort"),
construct.ULInt16("vscode"), # Vertical sum code
# Starting sweep frequency
construct.ULInt16("hsfs"),
# Ending sweep frequency
construct.ULInt16("hsfe"),
construct.ULInt16("hslen"), # Sweep length us
construct.ULInt16("hstyp"), # Sweep type code
# Trace number of sweep channel
construct.ULInt16("schn"),
construct.UBInt16('error_code'),
construct.UBInt16('payload_size_cmd0')
)
s.header_cmd1 = construct.Struct('CMD1Header',
construct.Padding(48)
)
s.header_cmd2 = construct.Struct('CMD2Header',
construct.ULInt16('JDN_base'),
construct.Padding(2),
construct.ULInt32('seconds')
)
s.header = construct.Struct('CMDHeader',
construct.ULInt16('packet_type'),
construct.ULInt16('cmd_id'),
construct.ULInt16('payload_size'),
construct.ULInt16('seq_id'),
construct.Switch('cmd_hdr', lambda ctx: ctx.cmd_id,
{
0 : construct.If(lambda ctx: ctx.payload_size >= s.header_cmd0.sizeof(), construct.Embed(s.header_cmd0)),
1 : construct.If(lambda ctx: ctx.payload_size == s.header_cmd1.sizeof(), construct.Embed(s.header_cmd1)),
2 : construct.If(lambda ctx: ctx.payload_size == s.header_cmd2.sizeof(), construct.Embed(s.header_cmd2))
},
default = construct.Pass
)
)
s.cmd_handlers = {
0 : s.cmd0,
1 : s.cmd1,
2 : s.cmd2
}
s.cmd0_handlers = {
5 : { 6 : s.cmd0_5_6 },
construct.UBInt16(u'device_number'),
construct.UBInt16(u'inode_number'),
construct.UBInt16(u'mode'),
construct.UBInt16(u'user_identifier'),
construct.UBInt16(u'group_identifier'),
construct.UBInt16(u'number_of_links'),
construct.UBInt16(u'special_device_number'),
construct.UBInt16(u'modification_time_upper'),
construct.UBInt16(u'modification_time_lower'),
construct.UBInt16(u'path_string_size'),
construct.UBInt16(u'file_size_upper'),
construct.UBInt16(u'file_size_lower'))
_CPIO_BINARY_LITTLE_ENDIAN_FILE_ENTRY_STRUCT = construct.Struct(
u'cpio_binary_little_endian_file_entry',
construct.ULInt16(u'signature'),
construct.ULInt16(u'device_number'),
construct.ULInt16(u'inode_number'),
construct.ULInt16(u'mode'),
construct.ULInt16(u'user_identifier'),
construct.ULInt16(u'group_identifier'),
construct.ULInt16(u'number_of_links'),
construct.ULInt16(u'special_device_number'),
construct.ULInt16(u'modification_time_upper'),
construct.ULInt16(u'modification_time_lower'),
construct.ULInt16(u'path_string_size'),
construct.ULInt16(u'file_size_upper'),
construct.ULInt16(u'file_size_lower'))
_CPIO_PORTABLE_ASCII_FILE_ENTRY_STRUCT = construct.Struct(
u'cpio_portable_ascii_file_entry',
construct.Bytes(u'signature', 6),
construct.UBInt16('K'),
construct.UBInt16('L'),
construct.UBInt16('M'),
construct.UBInt16('N'),
construct.UBInt16('O'),
construct.UBInt16('P')
)
L = construct.Struct("BIN",
construct.ULInt16('A'),
construct.ULInt16('B'),
construct.ULInt16('C'),
construct.ULInt16('D'),
construct.ULInt16('E'),
construct.ULInt16('F'),
construct.ULInt16('G'),
construct.ULInt16('H'),
construct.ULInt16('I'),
construct.ULInt16('J'),
construct.ULInt16('K'),
construct.ULInt16('L'),
construct.ULInt16('M'),
construct.ULInt16('N'),
construct.ULInt16('O'),
construct.ULInt16('P')
)
return B, L
#
def MakeEventRow():
return construct.Struct('EventRow',
construct.ULInt16('EventFlags'),
MDTag.StringHeapRef.parse('Name'),
MDTag.TypeDefOrRef.parse('EventType')
)
construct.UBInt8('flags'),
construct.UBInt8('id_primary'),
construct.UBInt8('id_secondary'),
construct.UBInt16('error_code'),
construct.UBInt16('payload_size_cmd0')
)
s.header_cmd1 = construct.Struct('CMD1Header',
construct.Padding(48)
)
s.header_cmd2 = construct.Struct('CMD2Header',
construct.ULInt16('JDN_base'),
construct.Padding(2),
construct.ULInt32('seconds')
)
s.header = construct.Struct('CMDHeader',
construct.ULInt16('packet_type'),
construct.ULInt16('cmd_id'),
construct.ULInt16('payload_size'),
construct.ULInt16('seq_id'),
construct.Switch('cmd_hdr', lambda ctx: ctx.cmd_id,
{
0 : construct.If(lambda ctx: ctx.payload_size >= s.header_cmd0.sizeof(), construct.Embed(s.header_cmd0)),
1 : construct.If(lambda ctx: ctx.payload_size == s.header_cmd1.sizeof(), construct.Embed(s.header_cmd1)),
2 : construct.If(lambda ctx: ctx.payload_size == s.header_cmd2.sizeof(), construct.Embed(s.header_cmd2))
},
default = construct.Pass
)
)
s.cmd_handlers = {
0 : s.cmd0,
1 : s.cmd1,
2 : s.cmd2
def MakeAssemblyRow():
return construct.Struct('AssemblyRow',
construct.ULInt32('HashAlgId'),
construct.ULInt16('MajorVersion'),
construct.ULInt16('MinorVersion'),
construct.ULInt16('BuildNumber'),
construct.ULInt16('RevisionNumber'),
construct.ULInt32('Flags'),
MDTag.BlobHeapRef.parse('PublicKey'),
MDTag.StringHeapRef.parse('Name'),
MDTag.StringHeapRef.parse('Culture')
)
construct.ULInt16("vscode"), # Vertical sum code
# Starting sweep frequency
construct.ULInt16("hsfs"),
# Ending sweep frequency
construct.ULInt16("hsfe"),
construct.ULInt16("hslen"), # Sweep length us
construct.ULInt16("hstyp"), # Sweep type code
# Trace number of sweep channel
construct.ULInt16("schn"),
# Sweep taper length ms at start
construct.ULInt16("hstas"),
# Sweep taper length ms at end
construct.ULInt16("hstae"),
construct.ULInt16("htatyp"), # Taper type
# Correlated data traces
construct.ULInt16("hcorr"),
# Binary gain recovered
construct.ULInt16("bgrcv"),
# Amplitude recovery method
construct.ULInt16("rcvm"),
construct.ULInt16("mfeet"), # Measurement system
# Impulse signal polarity
construct.ULInt16("polyt"),
# Vibratory polarity code
construct.ULInt16("vpol"),
construct.BitField("unass1", 240), # Unassigned
# *** SEG-Y Revision number ***
construct.ULInt16("rev"),
construct.ULInt16("trlen"), # *** Trace length ***
# *** Number of extended text headers ***
construct.ULInt16("extxt"),
construct.BitField("unass2", 94)) # Unassigned