summaryrefslogtreecommitdiffstats
path: root/uint32_unpack.c
diff options
context:
space:
mode:
Diffstat (limited to 'uint32_unpack.c')
-rw-r--r--uint32_unpack.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/uint32_unpack.c b/uint32_unpack.c
new file mode 100644
index 0000000..f484644
--- /dev/null
+++ b/uint32_unpack.c
@@ -0,0 +1,31 @@
+#include "uint32.h"
+
+void uint32_unpack(char s[4],uint32 *u)
+{
+ uint32 result;
+
+ result = (unsigned char) s[3];
+ result <<= 8;
+ result += (unsigned char) s[2];
+ result <<= 8;
+ result += (unsigned char) s[1];
+ result <<= 8;
+ result += (unsigned char) s[0];
+
+ *u = result;
+}
+
+void uint32_unpack_big(char s[4],uint32 *u)
+{
+ uint32 result;
+
+ result = (unsigned char) s[0];
+ result <<= 8;
+ result += (unsigned char) s[1];
+ result <<= 8;
+ result += (unsigned char) s[2];
+ result <<= 8;
+ result += (unsigned char) s[3];
+
+ *u = result;
+}