Class: Mapi::Pst::Desc64

Inherits:
Struct
  • Object
show all
Includes:
RecursivelyEnumerable
Defined in:
lib/mapi/pst.rb

Overview

pst_desc

Constant Summary collapse

UNPACK_STR =
'T3VV'
SIZE =
32
BLOCK_SIZE =

descriptor blocks was 520 but bogus

512
COUNT_MAX =

guess as per Index64

15

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Desc64

Returns a new instance of Desc64.



479
480
481
482
# File 'lib/mapi/pst.rb', line 479

def initialize data
	super(*Pst.unpack(data, UNPACK_STR))
	@children = []
end

Instance Attribute Details

#childrenObject (readonly)

Returns the value of attribute children.



478
479
480
# File 'lib/mapi/pst.rb', line 478

def children
  @children
end

#desc_idObject

Returns the value of attribute desc_id

Returns:

  • (Object)

    the current value of desc_id



469
470
471
# File 'lib/mapi/pst.rb', line 469

def desc_id
  @desc_id
end

#idx2_idObject

Returns the value of attribute idx2_id

Returns:

  • (Object)

    the current value of idx2_id



469
470
471
# File 'lib/mapi/pst.rb', line 469

def idx2_id
  @idx2_id
end

#idx_idObject

Returns the value of attribute idx_id

Returns:

  • (Object)

    the current value of idx_id



469
470
471
# File 'lib/mapi/pst.rb', line 469

def idx_id
  @idx_id
end

#parent_desc_idObject

Returns the value of attribute parent_desc_id

Returns:

  • (Object)

    the current value of parent_desc_id



469
470
471
# File 'lib/mapi/pst.rb', line 469

def parent_desc_id
  @parent_desc_id
end

#pstObject

Returns the value of attribute pst.



477
478
479
# File 'lib/mapi/pst.rb', line 477

def pst
  @pst
end

#u2Object

Returns the value of attribute u2

Returns:

  • (Object)

    the current value of u2



469
470
471
# File 'lib/mapi/pst.rb', line 469

def u2
  @u2
end

Class Method Details

.load_chain(io, header) ⇒ Object



492
493
494
# File 'lib/mapi/pst.rb', line 492

def self.load_chain io, header
	load_desc_rec io, header.index2, 0, 0x21
end

.load_desc_rec(io, offset, linku1, start_val) ⇒ Object



496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
# File 'lib/mapi/pst.rb', line 496

def self.load_desc_rec io, offset, linku1, start_val
	io.seek offset
	buf = io.read BLOCK_SIZE
	descs = []
	item_count = buf[ITEM_COUNT_OFFSET_64]

	# not real desc
	#desc = Desc.new buf[BACKLINK_OFFSET, 4]
	#raise 'blah 1' unless desc.desc_id == linku1

	if buf[LEVEL_INDICATOR_OFFSET_64] == 0
		# leaf pointers
		raise "have too many active items in index (#{item_count})" if item_count > COUNT_MAX
		# split the data into item_count desc objects
		buf[0, SIZE * item_count].scan(/.{#{SIZE}}/mo).each_with_index do |data, i|
			desc = new data
			# first entry
			raise 'blah 3' if i == 0 and start_val != 0 and desc.desc_id != start_val
			break if desc.desc_id == 0
			descs << desc
		end
	else
		# node pointers
		raise "have too many active items in index (#{item_count})" if item_count > Index64::COUNT_MAX
		# split the data into item_count table pointers
		buf[0, Index64::SIZE * item_count].scan(/.{#{Index64::SIZE}}/mo).each_with_index do |data, i|
			start, u1, offset = Pst.unpack data, 'T3'
			# for the first value, we expect the start to be equal note that ids -1, so even for the
			# first we expect it to be equal. thats the 0x21 (dec 33) desc record. this means we assert
			# that the first desc record is always 33...
			# thats because 0x21 is the pst root itself...
			raise 'blah 3' if i == 0 and start_val != -1 and start != start_val
			# this shouldn't really happen i'd imagine
			break if start == 0
			descs += load_desc_rec io, offset, u1, start
		end
	end

	descs
end

Instance Method Details

#descObject



484
485
486
# File 'lib/mapi/pst.rb', line 484

def desc
	pst.idx_from_id idx_id
end

#each_child(&block) ⇒ Object



537
538
539
# File 'lib/mapi/pst.rb', line 537

def each_child(&block)
	@children.each(&block)
end

#list_indexObject



488
489
490
# File 'lib/mapi/pst.rb', line 488

def list_index
	pst.idx_from_id idx2_id
end