Utilty for parsing raw data into C structures

From: Karthik K R (shukart1_at_yahoo.com)
Date: 09/29/04


Date: 29 Sep 2004 07:06:04 -0700

Hi,

I need some help on parsing data into C structures and then printing
them.

To explain in detail I have a file which contains raw dump of some
data
for example: test.log contains
---------------------------------------------------------------
00000000: 00 00 00 BE 00 1C 00 00 00 00 A0 00 12 00 00 05
00000010: 10 02 00 0E 00 23 00 00 00 20 00 00 1A 00 03 06
00000020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00000030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
---------------------------------------------------------------

One of my C structures looks like this:

typedef struct StatusBlock
{
    uint8_t test;
    uint8_t valid;
    uint16_t low;
    uint16_t high;
    uint16_t errSeq;
    uint16_t stat;
    uint16_t reserved; // alignment
} SSB_t;

Now I need to read the above data from the file cast it to the form of
a C structure and print out individual members of this structure.

This is just a sample, I have different kind of structures for various
data files.
Any tool or parser that could help in this?

thanks,
Karthik.