Reading struct with structs

B

Baillargeon, Sonny

I am trying to read in a C struct file that contains sub-structs as part
as the data definition. For example:
int a /* 4 bytes */
int_t b /* custom struct */
blah_t c /* custom struct */
bing_t d /* custom struct */

The custom structs are arbitrary. The struct module only allows me to
have strict C datatypes. How can I read in a struct recursively given I
have to feed the struct.unpack?

Thanks,
Sonny


<FONT SIZE = 1>****************************************************************************
This e-mail and any attachments may contain confidential and privileged information. If you are not the intended recipient, please notify the sender immediately by return e-mail, delete this e-mail and destroy any copies. Any dissemination or use of this information by a person other than the intended recipient is unauthorized and may be illegal. Unless otherwise stated, opinions expressed in this e-mail are those of the author and are not endorsed by the author's employer.</FONT>
 
A

Alex Martelli

Baillargeon said:
I am trying to read in a C struct file that contains sub-structs as part
as the data definition. For example:
int a /* 4 bytes */
int_t b /* custom struct */
blah_t c /* custom struct */
bing_t d /* custom struct */

The custom structs are arbitrary. The struct module only allows me to
have strict C datatypes. How can I read in a struct recursively given I
have to feed the struct.unpack?

You need to know how the various "custom structs" are made, in detail --
if you don't it's impossible to read that file, of course. Now, just
insert the formatstring for the various fields of each "custom struct"
in place of the "custom struct" in the overall formatstring.


Alex
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top