Thanks.
As for explicit offsets; I mean, as a way to describe the format of the data in a file.
For exemple (hypothetical) a file with a header:
<type of the file> 4 bytes
<version> 4 bytes
<Language ID> 2 bytes
<offset to name section> 4 bytes
<offset to description section> 4 bytes
then an array of entry structures:
each entry:
<offset to its name relative to the name section> 4bytes
<offset to its description in the description section> 4 bytes
then the name section and description section.
for the moment I see only two "ways" of parsing the file, supposing it is mapped in memory:
Code:
typedef struct{
char type[4];
char version[4];
unsigned short lang_id;
unsigned long name_sec;
unsigned long desc_sec;
}*PHEADER;
typedef struct{
unsigned long name;
unsigned long desc;
}*PENTRY;
or:
Code:
#define HEADER_LENGTH 18
#define HE_TYPE 0
#define HE_VERSION 4
#define HE_LANGID 8
#define HE_NAMESEC 10
#define HE_DESCSEC 14
#define ENTRY_LENGTH 8
#define EN_NAME 0
#define EN_DESC 4
and the code gets rather unpleasant:
with things like:
Code:
*((unsigned long*)(pTemp + EN_DESC ))...
pTemp+= ENTRY_LENGTGH;
But wihout the pragma, because of the 2 bytes language ID member in this case, it is the only way out I see... This is all supposing I cannot modify the file format.