summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rwxr-xr-xsrc/common/endianness.c42
-rwxr-xr-xsrc/common/endianness.h9
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 */