From 74f6f87c65456256192285886659328b0efe5915 Mon Sep 17 00:00:00 2001 From: schodet Date: Wed, 19 May 2004 13:12:05 +0000 Subject: Ajout unsigned int --- 2004/i/nono/src/utils/hexa.cc | 13 +++++++++++++ 2004/i/nono/src/utils/hexa.h | 3 +++ 2 files changed, 16 insertions(+) (limited to '2004') diff --git a/2004/i/nono/src/utils/hexa.cc b/2004/i/nono/src/utils/hexa.cc index d5e4716..2368f09 100644 --- a/2004/i/nono/src/utils/hexa.cc +++ b/2004/i/nono/src/utils/hexa.cc @@ -98,3 +98,16 @@ hexSignedShort2int (const char *s) return (short) (h3 << 12 | h2 << 8 | h1 << 4 | h0); } +/// Décode un mot non-signé (2 octets). +int +hexUnsignedShort2int (const char *s) +{ + int h3 = hex2digit (s[0]); + int h2 = hex2digit (s[1]); + int h1 = hex2digit (s[2]); + int h0 = hex2digit (s[3]); + if (h3 == hexInvalid || h2 == hexInvalid || h1 == hexInvalid || h0 == hexInvalid) + return hexInvalid; + return (unsigned short) (h3 << 12 | h2 << 8 | h1 << 4 | h0); +} + diff --git a/2004/i/nono/src/utils/hexa.h b/2004/i/nono/src/utils/hexa.h index c2a0259..ee9e2ca 100644 --- a/2004/i/nono/src/utils/hexa.h +++ b/2004/i/nono/src/utils/hexa.h @@ -40,6 +40,9 @@ unsigned int hexUnsignedChar2int (const char *s); /// Décode un mot signé (1 octets). int hexSignedChar2int (const char *s); +/// Décode un mot non-signé (2 octets). +int hexUnsignedShort2int (const char *s); + /// Décode un mot signé (2 octets). int hexSignedShort2int (const char *s); -- cgit v1.2.3