How to unpack unusual binary structure?

Hello everyone

I try to read binary file and it has section in following format:
(I suspect this comes from .h file)


then the bars array (one-byte justification) follows

pragma pack(push,1)
//---- Standard representation of a quote in the base
struct RateInfo {
time_t ctm; // current time in seconds
double open;
double low;
double high;
double close;
double vol;
};
pragma pack(pop)

I don’t know what to do with pragma pack. I googled and found that this
is some weird bit-level alignment for records. But I can’t figure out,
how do I read and .unpack such records.

Can I just do .read(4 + 5 * 8) and get a record?
How do I decode it if its packed with this pragma pack?

Need help…

On 07/12/06, Leo – [email protected] wrote:

struct RateInfo {
I don’t know what to do with pragma pack. I googled and found that this

Have you looked at String#unpack ?

Farrel

On 07/12/06, Leo – [email protected] wrote:

This is just a guess and I’m not sure what time_t is but if we assuume
it’s an unsigned int then you could say:
ctm,open,low,high,close,vol = packedData.unpack(“Iddddd”)

Farrel

Farrel L. wrote:

Have you looked at String#unpack ?

Yes, but I do not know how to apply it in the case of packed data
structure. I’m not much into CS, so if this is possible with
String#unpack I will be very happy if you can help me with format string
to unpack this “pragma pack(1)” data structure.