From: nobu@... Date: 2006-07-15T00:15:02+09:00 Subject: Re: How to pack/unpack nested structures? Hi, At Thu, 13 Jul 2006 00:31:37 +0900, Justin Bailey wrote in [ruby-talk:201532]: > version = 1 > numBuffers = 1 > > bufferSize = 100 > bufferType = 2 > buffer = "\0" * bufferSize I guess this buffer is the answer, unless the function returns another pointer. > struct = [version, numBuffers, [bufferSize, bufferType, > buffer].pack("LLP")].pack("LLP") or: nested_struct = [bufferSize, bufferType, buffer].pack("LLP") struct = [version, numBuffers, inner_struct].pack("LLP") nested_struct.unpack("LLP12") If the function alters buffer of struct SecurityBuffer, says it allocates new buffer and returns it, unpack can't deal with it. You need DL instead. -- Nobu Nakada