diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2009-08-09 18:12:27 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2009-08-09 18:12:27 (GMT) |
commit | 5cd25c4adfe0426520a51a76de3f77c77cfa4b8e (patch) | |
tree | 396514971fb78e81b7bb55c9cd3331d87b45ca9a /src/common | |
parent | d02deb2425d6559c357bdd00e1c0fb05f35d5fc9 (diff) |
Reorganized the way formats are handled (Java and PE got disabled, Dwarf is empty).
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@105 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/common')
-rwxr-xr-x | src/common/endianness.c | 42 | ||||
-rwxr-xr-x | src/common/endianness.h | 9 |
2 files changed, 51 insertions, 0 deletions
diff --git a/src/common/endianness.c b/src/common/endianness.c index 059295d..32bb65a 100755 --- a/src/common/endianness.c +++ b/src/common/endianness.c @@ -80,6 +80,24 @@ bool read_u16(uint16_t *target, const bin_t *data, off_t *pos, off_t len, Source switch (endian) { + case SRE_LITTLE: + +#if __BYTE_ORDER == __LITTLE_ENDIAN + + *target = data[*pos] | (uint16_t)data[*pos + 1] << 8; + +#elif __BYTE_ORDER == __BIG_ENDIAN + + *target = data[*pos + 1] | (uint16_t)data[*pos] << 8; + +#else + +# error "TODO : PDP !" + +#endif + + break; + @@ -181,3 +199,27 @@ bool read_u32(uint32_t *target, const bin_t *data, off_t *pos, off_t len, Source return true; } + + +/****************************************************************************** +* * +* Paramètres : target = lieu d'enregistrement de la lecture. [OUT] * +* data = flux de données à analyser. * +* pos = position courante dans ce flux. [OUT] * +* len = taille totale des données à analyser. * +* endian = ordre des bits dans la source. * +* * +* Description : Lit un nombre non signé sur huit octets. * +* * +* Retour : Bilan de l'opération : true en cas de succès, false sinon. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool read_u64(uint64_t *target, const bin_t *data, off_t *pos, off_t len, SourceEndian endian) +{ + + return false; + +} diff --git a/src/common/endianness.h b/src/common/endianness.h index b4c3975..f9d421e 100755 --- a/src/common/endianness.h +++ b/src/common/endianness.h @@ -52,6 +52,15 @@ bool read_u16(uint16_t *, const bin_t *, off_t *, off_t, SourceEndian); /* Lit un nombre non signé sur quatre octets. */ bool read_u32(uint32_t *, const bin_t *, off_t *, off_t, SourceEndian); +/* Lit un nombre non signé sur huit octets. */ +bool read_u64(uint64_t *, const bin_t *, off_t *, off_t, SourceEndian); + + +#define read_s8(target, data, pos, len, endian) read_u8((uint8_t *)target, data, pos, len, endian) +#define read_s16(target, data, pos, len, endian) read_u16((uint16_t *)target, data, pos, len, endian) +#define read_s32(target, data, pos, len, endian) read_u32((uint32_t *)target, data, pos, len, endian) +#define read_s64(target, data, pos, len, endian) read_u64((uint64_t *)target, data, pos, len, endian) + #endif /* _COMMON_ENDIANNESS_H */ |