Sha256: 985ce65260efa91f3290478f10c1db50bd6924089240f54ce0a6191949b32a4a
Contents?: true
Size: 1.24 KB
Versions: 3
Compression:
Stored size: 1.24 KB
Contents
module SetecAstronomy module KeePass class GroupField FIELD_TYPES = [ [0x0, 'ignored', :null], [0x1, 'groupid', :int], [0x2, 'group_name', :string], [0x3, 'creation_time', :date], [0x4, 'lastmod_time', :date], [0x5, 'lastacc_time', :date], [0x6, 'expire_time', :date], [0x7, 'imageid', :int], [0x8, 'level', :short], [0x9, 'flags', :int], [0xFFFF, 'terminator', :null] ] FIELD_TERMINATOR = 0xFFFF TYPE_CODE_FIELD_SIZE = 2 # unsigned short integer DATA_LENGTH_FIELD_SIZE = 4 # unsigned integer attr_reader :name, :data_type, :data def initialize(payload) type_code, @data_length = payload.read(TYPE_CODE_FIELD_SIZE + DATA_LENGTH_FIELD_SIZE).unpack('SI') @name, @data_type = _parse_type_code(type_code) @data = payload.read(@data_length) end def terminator? name == 'terminator' end def length TYPE_CODE_FIELD_SIZE + DATA_LENGTH_FIELD_SIZE + @data_length end def _parse_type_code(type_code) (_, name, data_type) = FIELD_TYPES.detect do |(code, *rest)| code == type_code end [name, data_type] end end end end
Version data entries
3 entries across 3 versions & 1 rubygems