Re: Utilty for parsing raw data into C structures
From: QNils_O=2E_Sel=E5sdal=22?= (NOS_at_Utel.no)
Date: 09/30/04
- Next message: Måns Rullgård: "Re: Utilty for parsing raw data into C structures"
- Previous message: QNils_O=2E_Sel=E5sdal=22?=: "Re: How to set up handler"
- In reply to: Pat Ford: "Re: Utilty for parsing raw data into C structures"
- Next in thread: Måns Rullgård: "Re: Utilty for parsing raw data into C structures"
- Reply: Måns Rullgård: "Re: Utilty for parsing raw data into C structures"
- Reply: Pat Ford: "Re: Utilty for parsing raw data into C structures"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 30 Sep 2004 10:12:52 +0200
Pat Ford wrote:
> "Karthik K R" <shukart1@yahoo.com> wrote in message
> news:44bd5fac.0409290606.69a9d264@posting.google.com...
>
>>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.
>
>
>
> how about;
>
> //================== in the header file
> typedef struct {
> u_int16_t jmp_opcode; // this is always a 6
> u_int16_t Buffer; // the is the offset for the satrt of the main
> program
> u_int16_t Naddr; // number of addresses in the setup section
> u_int16_t CASES; // the number of cases in the program
> u_int16_t highChannelBitmap; // channel addresses in the range of E940
> to E95A
> u_int16_t lowChannelBitmap; // channel addresses in the range of E740
> to E75A
> u_int16_t subcases; // the number of subcases of option 0xD
> u_int16_t spare; // unused
> u_int16_t FUNCT[8]; // starting addresses of upto 8 functions this is
> an offset from tble
> HomeType home[20]; // this array hold the value and address for each
> "safe"
> // position. the number comes from refer.h AddressTableLimit
> u_int16_t poo[16];
> }RefHeaderType;
Depending what's the structure of the data is in
}RefHeaderType __attribute__((__packed__));
might be needed when mapping data directly to C structures.
- Next message: Måns Rullgård: "Re: Utilty for parsing raw data into C structures"
- Previous message: QNils_O=2E_Sel=E5sdal=22?=: "Re: How to set up handler"
- In reply to: Pat Ford: "Re: Utilty for parsing raw data into C structures"
- Next in thread: Måns Rullgård: "Re: Utilty for parsing raw data into C structures"
- Reply: Måns Rullgård: "Re: Utilty for parsing raw data into C structures"
- Reply: Pat Ford: "Re: Utilty for parsing raw data into C structures"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]