diff options
author | Steve Holme <steve_holme@hotmail.com> | 2014-12-31 11:40:16 +0000 |
---|---|---|
committer | Steve Holme <steve_holme@hotmail.com> | 2014-12-31 12:05:36 +0000 |
commit | 920e684d4082e0ebed900e79d5523cf14fbf05b2 (patch) | |
tree | 1b1f96fefe6fdd2e80bcf255017e7c216ef81728 /lib/endian.c | |
parent | 81951d98748188fd57c07435fa74c505db6a0ba7 (diff) |
endian: Moved read functions to new module
Diffstat (limited to 'lib/endian.c')
-rw-r--r-- | lib/endian.c | 22 |
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); +} |