FORUM CLOSED, PLEASE REGISTER AT FORUM.SIO2INTERACTIVE.COM
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Basic C Question - Parsing Data

Go down

Basic C Question - Parsing Data Empty Basic C Question - Parsing Data

Post  uprise78 Sun Dec 28, 2008 10:42 pm

I am working on parsing CAF files to extract some information and ran into a small roadblock due to my limited C knowledge (still learning with a long way to go). I have the following structs that I am trying to read in:

Code:
typedef struct
{
    UInt32  mChunkType; // char mChunkType[4]
    SInt64  mChunkSize;   
} CAFChunkHeader;

typedef struct
{
    UInt32  mFileType; // char mFileType[4]
    UInt16  mFileVersion;
    UInt16  mFileFlags;   
} CAFFileHeader;
I am using an sio2Stream to parse the file data into the structs.

Code:
   CAFFileHeader *fileHeader = ( CAFFileHeader * )sio2StreamReadPtr( _SIO2stream, sizeof( CAFFileHeader ) );
   
   CAFChunkHeader *firstChunk = ( CAFChunkHeader* )sio2StreamReadPtr( _SIO2stream, sizeof( CAFChunkHeader ) );
The problem is that that all the fields appear to just be filled with random integer values instead of the expected values. If I replace the UInt32 fields with the commented out char arrays I can confirm that the structures are indeed lining up correctly because the char arrays are exactly as expected. Can someone with a bit more C knowledge than myself let me know why the int values are not correct?

uprise78

Posts : 228
Join date : 2008-10-31

Back to top Go down

Basic C Question - Parsing Data Empty Re: Basic C Question - Parsing Data

Post  uprise78 Tue Dec 30, 2008 10:38 am

I think I figured it out. The data was big endian and it just needed to be converted to little endian.

uprise78

Posts : 228
Join date : 2008-10-31

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum