mirror of
https://github.com/moparisthebest/curl
synced 2024-12-21 07:38:49 -05:00
parent
9b2dfe88bb
commit
4ba20a5119
@ -5,7 +5,7 @@
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
@ -62,44 +62,6 @@ unsigned int Curl_read32_le(const unsigned char *buf)
|
||||
((unsigned int)buf[2] << 16) | ((unsigned int)buf[3] << 24);
|
||||
}
|
||||
|
||||
#if (CURL_SIZEOF_CURL_OFF_T > 4)
|
||||
/*
|
||||
* Curl_read64_le()
|
||||
*
|
||||
* This function converts a 64-bit integer from the little endian format, as
|
||||
* used in the incoming package to whatever endian format we're using
|
||||
* natively.
|
||||
*
|
||||
* Parameters:
|
||||
*
|
||||
* buf [in] - A pointer to a 8 byte buffer.
|
||||
*
|
||||
* Returns the integer.
|
||||
*/
|
||||
#if defined(HAVE_LONGLONG)
|
||||
unsigned long long Curl_read64_le(const unsigned char *buf)
|
||||
{
|
||||
return ((unsigned long long)buf[0]) |
|
||||
((unsigned long long)buf[1] << 8) |
|
||||
((unsigned long long)buf[2] << 16) |
|
||||
((unsigned long long)buf[3] << 24) |
|
||||
((unsigned long long)buf[4] << 32) |
|
||||
((unsigned long long)buf[5] << 40) |
|
||||
((unsigned long long)buf[6] << 48) |
|
||||
((unsigned long long)buf[7] << 56);
|
||||
}
|
||||
#else
|
||||
unsigned __int64 Curl_read64_le(const unsigned char *buf)
|
||||
{
|
||||
return ((unsigned __int64)buf[0]) | ((unsigned __int64)buf[1] << 8) |
|
||||
((unsigned __int64)buf[2] << 16) | ((unsigned __int64)buf[3] << 24) |
|
||||
((unsigned __int64)buf[4] << 32) | ((unsigned __int64)buf[5] << 40) |
|
||||
((unsigned __int64)buf[6] << 48) | ((unsigned __int64)buf[7] << 56);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* CURL_SIZEOF_CURL_OFF_T > 4 */
|
||||
|
||||
/*
|
||||
* Curl_read16_be()
|
||||
*
|
||||
@ -119,80 +81,6 @@ unsigned short Curl_read16_be(const unsigned char *buf)
|
||||
((unsigned short)buf[1]));
|
||||
}
|
||||
|
||||
/*
|
||||
* Curl_read32_be()
|
||||
*
|
||||
* This function converts a 32-bit integer from the big endian format, as
|
||||
* used in the incoming package to whatever endian format we're using
|
||||
* natively.
|
||||
*
|
||||
* Parameters:
|
||||
*
|
||||
* buf [in] - A pointer to a 4 byte buffer.
|
||||
*
|
||||
* Returns the integer.
|
||||
*/
|
||||
unsigned int Curl_read32_be(const unsigned char *buf)
|
||||
{
|
||||
return ((unsigned int)buf[0] << 24) | ((unsigned int)buf[1] << 16) |
|
||||
((unsigned int)buf[2] << 8) | ((unsigned int)buf[3]);
|
||||
}
|
||||
|
||||
#if (CURL_SIZEOF_CURL_OFF_T > 4)
|
||||
/*
|
||||
* Curl_read64_be()
|
||||
*
|
||||
* This function converts a 64-bit integer from the big endian format, as
|
||||
* used in the incoming package to whatever endian format we're using
|
||||
* natively.
|
||||
*
|
||||
* Parameters:
|
||||
*
|
||||
* buf [in] - A pointer to a 8 byte buffer.
|
||||
*
|
||||
* Returns the integer.
|
||||
*/
|
||||
#if defined(HAVE_LONGLONG)
|
||||
unsigned long long Curl_read64_be(const unsigned char *buf)
|
||||
{
|
||||
return ((unsigned long long)buf[0] << 56) |
|
||||
((unsigned long long)buf[1] << 48) |
|
||||
((unsigned long long)buf[2] << 40) |
|
||||
((unsigned long long)buf[3] << 32) |
|
||||
((unsigned long long)buf[4] << 24) |
|
||||
((unsigned long long)buf[5] << 16) |
|
||||
((unsigned long long)buf[6] << 8) |
|
||||
((unsigned long long)buf[7]);
|
||||
}
|
||||
#else
|
||||
unsigned __int64 Curl_read64_be(const unsigned char *buf)
|
||||
{
|
||||
return ((unsigned __int64)buf[0] << 56) | ((unsigned __int64)buf[1] << 48) |
|
||||
((unsigned __int64)buf[2] << 40) | ((unsigned __int64)buf[3] << 32) |
|
||||
((unsigned __int64)buf[4] << 24) | ((unsigned __int64)buf[5] << 16) |
|
||||
((unsigned __int64)buf[6] << 8) | ((unsigned __int64)buf[7]);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* CURL_SIZEOF_CURL_OFF_T > 4 */
|
||||
|
||||
/*
|
||||
* Curl_write16_le()
|
||||
*
|
||||
* This function converts a 16-bit integer from the native endian format,
|
||||
* to little endian format ready for sending down the wire.
|
||||
*
|
||||
* Parameters:
|
||||
*
|
||||
* value [in] - The 16-bit integer value.
|
||||
* buffer [in] - A pointer to the output buffer.
|
||||
*/
|
||||
void Curl_write16_le(const short value, unsigned char *buffer)
|
||||
{
|
||||
buffer[0] = (char)(value & 0x00FF);
|
||||
buffer[1] = (char)((value & 0xFF00) >> 8);
|
||||
}
|
||||
|
||||
/*
|
||||
* Curl_write32_le()
|
||||
*
|
||||
|
@ -7,7 +7,7 @@
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
@ -28,33 +28,9 @@ unsigned short Curl_read16_le(const unsigned char *buf);
|
||||
/* Converts a 32-bit integer from little endian */
|
||||
unsigned int Curl_read32_le(const unsigned char *buf);
|
||||
|
||||
#if (CURL_SIZEOF_CURL_OFF_T > 4)
|
||||
/* Converts a 64-bit integer from little endian */
|
||||
#if defined(HAVE_LONGLONG)
|
||||
unsigned long long Curl_read64_le(const unsigned char *buf);
|
||||
#else
|
||||
unsigned __int64 Curl_read64_le(const unsigned char *buf);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Converts a 16-bit integer from big endian */
|
||||
unsigned short Curl_read16_be(const unsigned char *buf);
|
||||
|
||||
/* Converts a 32-bit integer from big endian */
|
||||
unsigned int Curl_read32_be(const unsigned char *buf);
|
||||
|
||||
#if (CURL_SIZEOF_CURL_OFF_T > 4)
|
||||
/* Converts a 64-bit integer from big endian */
|
||||
#if defined(HAVE_LONGLONG)
|
||||
unsigned long long Curl_read64_be(const unsigned char *buf);
|
||||
#else
|
||||
unsigned __int64 Curl_read64_be(const unsigned char *buf);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Converts a 16-bit integer to little endian */
|
||||
void Curl_write16_le(const short value, unsigned char *buffer);
|
||||
|
||||
/* Converts a 32-bit integer to little endian */
|
||||
void Curl_write32_le(const int value, unsigned char *buffer);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user