aboutsummaryrefslogtreecommitdiff
path: root/lib/endian.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/endian.c')
-rw-r--r--lib/endian.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/endian.c b/lib/endian.c
index cc97adf5a..f95012905 100644
--- a/lib/endian.c
+++ b/lib/endian.c
@@ -23,3 +23,25 @@
#include "curl_setup.h"
#include "endian.h"
+
+/*
+ * This function converts from the little endian format used in the incoming
+ * package to whatever endian format we're using natively. Argument is a
+ * pointer to a 2 byte buffer.
+ */
+unsigned short readshort_le(unsigned char *buf)
+{
+ return (unsigned short)(((unsigned short)buf[0]) |
+ ((unsigned short)buf[1] << 8));
+}
+
+/*
+ * This function converts from the little endian format used in the
+ * incoming package to whatever endian format we're using natively.
+ * Argument is a pointer to a 4 byte buffer.
+ */
+unsigned int readint_le(unsigned char *buf)
+{
+ return ((unsigned int)buf[0]) | ((unsigned int)buf[1] << 8) |
+ ((unsigned int)buf[2] << 16) | ((unsigned int)buf[3] << 24);
+}