Re: Utilty for parsing raw data into C structures

From: Måns Rullgård (mru_at_mru.ath.cx)
Date: 09/30/04


Date: Thu, 30 Sep 2004 10:41:51 +0200


"Nils O. Selåsdal" <NOS@Utel.no> writes:

> 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.

I wrote such a program once. What made it difficult was that it had
to be done in Java (choice of my employer, not mine).

> Depending what's the structure of the data is in
> }RefHeaderType __attribute__((__packed__));
> might be needed when mapping data directly to C structures.

If the file was created by dumping C structs, it should be sufficient
to use the same definition when reading it, if the code is compiled
for a machine with the same endianness and alignment constraints as
whatever generated the file. If the machines are different, things
start getting more difficult.

-- 
Måns Rullgård
mru@mru.ath.cx


Relevant Pages

  • Re: Is it always possible to write a COBOL program using only 1 sentence per paragraph?
    ... >> A few months ago I had an introductory class on Java programming. ... reading from console can be done via a call to ... just one character at a time). ... Stream reader, or an HTTP Input Stream reader, or an Audio Input Stream ...
    (comp.lang.cobol)
  • Event Driven Code and Thread Control
    ... One of the big changes I want to make is event-driven code (rather than the linear flow I had in Java). ... There is a GUI thread, a main processing thread (handles parsing, updating the objects, etc - this could also been on the GUI thread, but not sure if that is proper design. ... This would basically be the worker thread where all the data is actually manipulated), and 2 input threads (1 socket reading from another application, and 1 file also reading from that same other application). ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Arrrrrrrrrrrrggggg!!
    ... > decides to swap endianness in mid-execution. ... have _ONLY_ the choice of Java left, I think...because Java is the only ... "selfish" and "altruistic" are different sides of the same coin...you ... is no need for "portability" in this instance...hence, ...
    (alt.lang.asm)
  • Re: CLOS and databases
    ... No-one programs in Java if they ... I've experienced the frustration of loving Common Lisp but being forced ... Common Lisp macros) to hide all the mess. ... Reading PRIMES/0000000000000000001.transactionLog... ...
    (comp.lang.lisp)
  • Reading in chunks of data
    ... I'm reading up on the use of the RandomAccessFile (and other file I/O) ... classes in Java but I haven't found anything that can help me. ...
    (comp.lang.java.programmer)