summaryrefslogtreecommitdiff
path: root/2004/i/nono/src/utils
diff options
context:
space:
mode:
authorschodet2004-04-17 08:22:22 +0000
committerschodet2004-04-17 08:22:22 +0000
commit494d04e99b004567ea8949d4a094248ac714ece1 (patch)
treef4e6e8717f25d5947cf66b24cb86c3b2dfed0542 /2004/i/nono/src/utils
parent38309a2e4afecdd1546120019437a7093513944d (diff)
Déplacement des fonctions de décodage hexa.
Diffstat (limited to '2004/i/nono/src/utils')
-rw-r--r--2004/i/nono/src/utils/hexa.cc18
-rw-r--r--2004/i/nono/src/utils/hexa.h6
2 files changed, 24 insertions, 0 deletions
diff --git a/2004/i/nono/src/utils/hexa.cc b/2004/i/nono/src/utils/hexa.cc
index 247b44c..ab43f64 100644
--- a/2004/i/nono/src/utils/hexa.cc
+++ b/2004/i/nono/src/utils/hexa.cc
@@ -62,3 +62,21 @@ digit2hex (int d)
return digit2hexTbl_[d];
}
+/// Décode un mot signé (1 octets).
+int
+hexSignedChar2int (const char *s) const
+{
+ return (signed char) (hex2digit (s[0]) << 4
+ | hex2digit (s[1]) << 0);
+}
+
+/// Décode un mot signé (2 octets).
+int
+hexSignedShort2int (const char *s) const
+{
+ return (short) (hex2digit (s[0]) << 12
+ | hex2digit (s[1]) << 8
+ | hex2digit (s[2]) << 4
+ | hex2digit (s[3]));
+}
+
diff --git a/2004/i/nono/src/utils/hexa.h b/2004/i/nono/src/utils/hexa.h
index 2bcf81d..cdae943 100644
--- a/2004/i/nono/src/utils/hexa.h
+++ b/2004/i/nono/src/utils/hexa.h
@@ -31,4 +31,10 @@ int hex2digit (char c);
/// Converti un chiffre (0-15) en hexa (0-9a-f).
char digit2hex (int d);
+/// Décode un mot signé (1 octets).
+int hexSignedChar2int (const char *s) const;
+
+/// Décode un mot signé (2 octets).
+int hexSignedShort2int (const char *s) const;
+
#endif // hexa_h