Forum: Ruby Re: Newbie question

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
87e9a89c53ccf984db792113471c2171?d=identicon&s=25 Kroeger, Simon (ext) (Guest)
on 2006-01-06 10:31
(Received via mailing list)
Welcome mac,

your code below should be more or less equal to:
(no chance of testing obviously)

def ae_6 session
  pdu, pduLen = session.read(5).unpack('cN')
  buffer = session.read(pduLen)

  calledAETitle, callingAETitle, itemType, itemLength =
buffer.unpack('x4A16A16x35Cxn')

  start = 72+itemLength
  contextName=buffer.slice(72...start)

  while start < pduLen
    start = getNextPresentationContext(start, pdu[start..-1]) + 1
    print "Finish = ",start-1,"  outside proc\n"
  end
end

def getNextPresentationContext(start, pdu)
  it, itemLength, presContextId, itemType, itemLength =
pdu.unpack('CxnCx3Cxn')

  start = 12 + itemLength
  abstractSyntax=pdu[12...start]
  itemType=pdu[start]

  while itemType == 64
    itemLength=pdu[start+2..start+1].unpack('n')[0]
    transferSyntax=pdu[start+2...start+2+itemLength]

    puts "id=#{presContextId}, AbstractSyntax =#{abstractSyntax},
TxSyntax=#{transferSyntax}"
    start=start+2+itemLength+1
    itemType=pdu[start]
  end
  return start-1
end


Hope you get the idea.

cheers

Simon
This topic is locked and can not be replied to.