summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2014-07-31 05:53:06 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2014-07-31 05:53:06 (GMT)
commita5d8e3fc30cda2e13d30f099e93ab1b182fdc0bd (patch)
treecf183906b2301cd3c726af820292fd0f2458bfa1 /src/common
parentdc436357ff29158dddd836d368d152d42d5b086b (diff)
Improved the way code is decoded by avoiding to propagate the base address everywhere.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@385 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/common')
-rwxr-xr-xsrc/common/endianness.c48
1 files changed, 24 insertions, 24 deletions
diff --git a/src/common/endianness.c b/src/common/endianness.c
index 2292620..5e48b02 100755
--- a/src/common/endianness.c
+++ b/src/common/endianness.c
@@ -34,7 +34,7 @@
* 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. *
+* end = limite des données à analyser. *
* low = position éventuelle des 4 bits visés. [OUT] *
* endian = ordre des bits dans la source. *
* *
@@ -46,10 +46,10 @@
* *
******************************************************************************/
-bool read_u4(uint8_t *target, const bin_t *data, off_t *pos, off_t len, bool *low, SourceEndian endian)
+bool read_u4(uint8_t *target, const bin_t *data, off_t *pos, off_t end, bool *low, SourceEndian endian)
{
if (*pos < 0) return false;
- if ((len - *pos) < 1) return false;
+ if ((end - *pos) < 1) return false;
if (*low)
{
@@ -73,7 +73,7 @@ bool read_u4(uint8_t *target, const bin_t *data, off_t *pos, off_t len, bool *lo
* 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. *
+* end = limite des données à analyser. *
* endian = ordre des bits dans la source. *
* *
* Description : Lit un nombre non signé sur un octet. *
@@ -84,10 +84,10 @@ bool read_u4(uint8_t *target, const bin_t *data, off_t *pos, off_t len, bool *lo
* *
******************************************************************************/
-bool read_u8(uint8_t *target, const bin_t *data, off_t *pos, off_t len, SourceEndian endian)
+bool read_u8(uint8_t *target, const bin_t *data, off_t *pos, off_t end, SourceEndian endian)
{
if (*pos < 0) return false;
- if ((len - *pos) < 1) return false;
+ if ((end - *pos) < 1) return false;
*target = data[*pos];
@@ -103,7 +103,7 @@ bool read_u8(uint8_t *target, const bin_t *data, off_t *pos, off_t len, SourceEn
* 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. *
+* end = limite des données à analyser. *
* endian = ordre des bits dans la source. *
* *
* Description : Lit un nombre non signé sur deux octets. *
@@ -114,10 +114,10 @@ bool read_u8(uint8_t *target, const bin_t *data, off_t *pos, off_t len, SourceEn
* *
******************************************************************************/
-bool read_u16(uint16_t *target, const bin_t *data, off_t *pos, off_t len, SourceEndian endian)
+bool read_u16(uint16_t *target, const bin_t *data, off_t *pos, off_t end, SourceEndian endian)
{
if (*pos < 0) return false;
- if ((len - *pos) < 2) return false;
+ if ((end - *pos) < 2) return false;
switch (endian)
{
@@ -176,7 +176,7 @@ bool read_u16(uint16_t *target, const bin_t *data, off_t *pos, off_t len, Source
* 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. *
+* end = limite des données à analyser. *
* endian = ordre des bits dans la source. *
* *
* Description : Lit un nombre non signé sur quatre octets. *
@@ -187,10 +187,10 @@ bool read_u16(uint16_t *target, const bin_t *data, off_t *pos, off_t len, Source
* *
******************************************************************************/
-bool read_u32(uint32_t *target, const bin_t *data, off_t *pos, off_t len, SourceEndian endian)
+bool read_u32(uint32_t *target, const bin_t *data, off_t *pos, off_t end, SourceEndian endian)
{
if (*pos < 0) return false;
- if ((len - *pos) < 4) return false;
+ if ((end - *pos) < 4) return false;
switch (endian)
{
@@ -253,7 +253,7 @@ bool read_u32(uint32_t *target, const bin_t *data, off_t *pos, off_t len, Source
* 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. *
+* end = limite des données à analyser. *
* endian = ordre des bits dans la source. *
* *
* Description : Lit un nombre non signé sur huit octets. *
@@ -264,10 +264,10 @@ bool read_u32(uint32_t *target, const bin_t *data, off_t *pos, off_t len, Source
* *
******************************************************************************/
-bool read_u64(uint64_t *target, const bin_t *data, off_t *pos, off_t len, SourceEndian endian)
+bool read_u64(uint64_t *target, const bin_t *data, off_t *pos, off_t end, SourceEndian endian)
{
if (*pos < 0) return false;
- if ((len - *pos) < 8) return false;
+ if ((end - *pos) < 8) return false;
switch (endian)
{
@@ -339,7 +339,7 @@ bool read_u64(uint64_t *target, const bin_t *data, off_t *pos, off_t len, Source
* size = taille de cette source de données. *
* data = flux de données à modifier. [OUT] *
* pos = position courante dans ce flux. [OUT] *
-* len = taille totale des données à analyser. *
+* end = limite des données à analyser. *
* endian = ordre des bits dans la source. *
* *
* Description : Ecrit un nombre non signé sur n octets. *
@@ -350,12 +350,12 @@ bool read_u64(uint64_t *target, const bin_t *data, off_t *pos, off_t len, Source
* *
******************************************************************************/
-bool _write_un(const bin_t *value, size_t size, bin_t *data, off_t *pos, off_t len, SourceEndian endian)
+bool _write_un(const bin_t *value, size_t size, bin_t *data, off_t *pos, off_t end, SourceEndian endian)
{
size_t i; /* Boucle de parcours */
if (*pos < 0) return false;
- if ((len - *pos) < size) return false;
+ if ((end - *pos) < size) return false;
switch (endian)
{
@@ -415,7 +415,7 @@ bool _write_un(const bin_t *value, size_t size, bin_t *data, off_t *pos, off_t l
* 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. *
+* end = limite des données à analyser. *
* endian = ordre des bits dans la source. *
* *
* Description : Lit un nombre hexadécimal non signé sur deux octets. *
@@ -426,12 +426,12 @@ bool _write_un(const bin_t *value, size_t size, bin_t *data, off_t *pos, off_t l
* *
******************************************************************************/
-bool strtou8(uint8_t *target, const char *data, size_t *pos, size_t len, SourceEndian endian)
+bool strtou8(uint8_t *target, const char *data, size_t *pos, size_t end, SourceEndian endian)
{
size_t i; /* Boucle de parcours */
if (*pos < 0) return false;
- if ((len - *pos) < 2) return false;
+ if ((end - *pos) < 2) return false;
*target = 0;
@@ -464,7 +464,7 @@ bool strtou8(uint8_t *target, const char *data, size_t *pos, size_t len, SourceE
* Paramètres : n = nombre d'octets constituant le nombre à lire. *
* data = flux de données à analyser. *
* pos = position courante dans ce flux. [OUT] *
-* len = taille totale des données à analyser. *
+* end = limite des données à analyser. *
* endian = ordre des bits dans la source. *
* ... = lieu d'enregistrement de la lecture. [OUT] *
* *
@@ -476,7 +476,7 @@ bool strtou8(uint8_t *target, const char *data, size_t *pos, size_t len, SourceE
* *
******************************************************************************/
-bool _strtoun(uint8_t n, const char *data, size_t *pos, size_t len, SourceEndian endian, ...)
+bool _strtoun(uint8_t n, const char *data, size_t *pos, size_t end, SourceEndian endian, ...)
{
bool result; /* Bilan à renvoyer */
va_list ap; /* Arguments variables */
@@ -489,7 +489,7 @@ bool _strtoun(uint8_t n, const char *data, size_t *pos, size_t len, SourceEndian
uint8_t tmp; /* Valeur temporaire de 8 bits */
if (*pos < 0) return false;
- if ((len - *pos) < (n * 2)) return false;
+ if ((end - *pos) < (n * 2)) return false;
/* Récupération de la destination */