Welcome to the "trac"-ing site of openpgp4u!
[soap4r] [httpclient] [openpgp4u] [pkcs1] [logger] [csv] [vtr]

Changeset 32

Show
Ignore:
Timestamp:
11/06/04 13:44:34 (4 years ago)
Author:
nahi
Message:

* simplified Partial Body Lengths packet support algorithm.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/pgp/packet/packet.rb

    r29 r32  
    3030 
    3131  TAGS = { 
     32    -1 => "Partial", 
    3233    0 => "Reserved", 
    3334    1 => "Public-Key Encrypted Session Key Packet", 
     
    8889 
    8990  def self.load(port) 
    90     loadport = wrap_port(port) 
    9191    packets = [] 
    9292    continue = false 
     93    newheader = false 
     94    tag = nil 
     95    loadport = wrap_port(port) 
    9396    while !loadport.eof? 
    9497      if continue 
    95         lengthdefined, partial = load_length_new(loadport) 
    96       else 
    97         newheader, tag, lengthdefined, partial = load_header(loadport) 
    98       end 
    99       if partial and continue 
    100         raise "Partial Body Lengths packet not supported" 
    101       end 
    102       continue = partial 
     98        lengthdefined, continue = load_length_new(loadport) 
     99        packet = Partial.loader(loadport, lengthdefined) 
     100        packets << packet 
     101        next 
     102      end 
     103      newheader, tag, lengthdefined, continue = load_header(loadport) 
    103104      initpos = loadport.readlength 
    104105      unless TAG_LOADER.key?(tag) 
     
    122123    end 
    123124    continue = false 
     125    newheader = false 
     126    tag = nil 
    124127    loadport = wrap_port(port) 
    125128    while !loadport.eof? 
     
    127130      begin 
    128131        if continue 
    129           lengthdefined, partial = load_length_new(loadport) 
    130         else 
    131           newheader, tag, lengthdefined, partial = load_header(loadport) 
     132          lengthdefined, continue = load_length_new(loadport) 
     133          newtag = newheader ? "New" : "Old" 
     134          if continue 
     135            newtag += '(partial continue)' 
     136          else 
     137            newtag += '(partial end     )' 
     138          end 
     139          dumpport.puts "#{newtag}: - (tag #{tag})(#{lengthdefined} bytes)" 
     140          Partial.scanner(dumpport, loadport, lengthdefined) 
     141          next 
    132142        end 
     143        newheader, tag, lengthdefined, continue = load_header(loadport) 
    133144        newtag = newheader ? "New" : "Old" 
    134         if partial 
    135           if continue 
    136             dumpport.puts "#{newtag}(partial continue): - (tag #{tag})(#{lengthdefined} bytes)" 
    137             loadport.read(lengthdefined) 
    138             next 
    139           else 
    140             newtag += '(partial start)' 
    141           end 
    142         else 
    143           if continue 
    144             newtag += '(partial end)' 
    145           end 
     145        if continue 
     146          newtag += '(partial start   )' 
    146147        end 
    147         continue = partial 
    148         dumpport.puts "#{newtag}: #{taglabel(tag)}(tag #{tag})(#{lengthdefined} bytes)" 
     148        dumpport.puts "#{newtag}: #{taglabel(tag)}(tag #{tag})" + 
     149          "(#{lengthdefined} bytes)" 
    149150        initpos = loadport.readlength 
    150151        dumpport.indent(4) do