Reading struct with structs

Discussion in 'Python' started by Baillargeon, Sonny, Oct 12, 2004.

  1. 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>
    Baillargeon, Sonny, Oct 12, 2004
    #1
    1. Advertising

  2. Baillargeon, Sonny <> wrote:

    > 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
    Alex Martelli, Oct 16, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Patricia  Van Hise

    structs with fields that are structs

    Patricia Van Hise, Apr 5, 2004, in forum: C Programming
    Replies:
    5
    Views:
    633
    Al Bowers
    Apr 5, 2004
  2. Chris Hauxwell

    const structs in other structs

    Chris Hauxwell, Apr 23, 2004, in forum: C Programming
    Replies:
    6
    Views:
    555
    Chris Hauxwell
    Apr 27, 2004
  3. Paminu
    Replies:
    5
    Views:
    637
    Eric Sosman
    Oct 11, 2005
  4. Daniel Rudy
    Replies:
    15
    Views:
    1,386
    Keith Thompson
    Apr 10, 2006
  5. Tuan  Bui
    Replies:
    14
    Views:
    470
    it_says_BALLS_on_your forehead
    Jul 29, 2005
Loading...

Share This Page