Daniel Martin wrote:
> Daniel Martin <martind / martinhouse.internal> writes:
> 

require 'bit-struct'

class MRKHeader < BitStruct
    unsigned :version,            32, "Version",     :endian => :native
    unsigned :uid_Validity,       32, "UIDValidity", :endian => :native
    unsigned :uid_next,           32, "UIDNext",     :endian => :native
    unsigned :last_write_counter, 32, "LastWriteCounter", :endian => 
:native
    rest     :unused,                 "Unused"
    def MRKHeader.bit_length
      super
      36*8
    end
end

File.open("imap.mrk", "rb") {|f|
  head_string = f.read(MRKHeader.round_byte_length)
  raise "No header!" unless head_string
  mrk_header = MRKHeader.new(head_string)
  puts mrk_header.inspect
  while msg_string = f.read(MRKMessage.round_byte_length) do
    puts MRKMessage.new(msg_string).inspect
  end
}

Now an error is raised:
>ruby b.rb
#<MRKHeader version=1, uid_Validity=1106138982, uid_next=5825, 
last_write_counter=9872, unused="">
b.rb:19: uninitialized constant MRKMessage (NameError)
	from b.rb:14
>Exit code: 1

Also the problem is that there is to process the Message data structure: 
how can I accomplish this?
Thank you all very much for the help!

-- 
Posted via http://www.ruby-forum.com/.