mirror of
https://github.com/moparisthebest/curl
synced 2024-12-21 15:48:49 -05:00
endian: Moved write functions to new module
This commit is contained in:
parent
920e684d40
commit
7873f9bdbd
@ -106,6 +106,7 @@
|
||||
#include "curl_md5.h"
|
||||
#include "curl_hmac.h"
|
||||
#include "warnless.h"
|
||||
#include "endian.h"
|
||||
|
||||
#define _MPRINTF_REPLACE /* use our functions only */
|
||||
#include <curl/mprintf.h>
|
||||
@ -464,26 +465,6 @@ static void ascii_uppercase_to_unicode_le(unsigned char *dest,
|
||||
}
|
||||
}
|
||||
|
||||
static void write32_le(const int value, unsigned char *buffer)
|
||||
{
|
||||
buffer[0] = (char)(value & 0x000000FF);
|
||||
buffer[1] = (char)((value & 0x0000FF00) >> 8);
|
||||
buffer[2] = (char)((value & 0x00FF0000) >> 16);
|
||||
buffer[3] = (char)((value & 0xFF000000) >> 24);
|
||||
}
|
||||
|
||||
#if (CURL_SIZEOF_CURL_OFF_T > 4)
|
||||
#if defined(HAVE_LONGLONG)
|
||||
static void write64_le(const long long value, unsigned char *buffer)
|
||||
#else
|
||||
static void write64_le(const __int64 value, unsigned char *buffer)
|
||||
#endif
|
||||
{
|
||||
write32_le((int)value, buffer);
|
||||
write32_le((int)(value >> 32), buffer + 4);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Set up nt hashed passwords
|
||||
*/
|
||||
|
20
lib/endian.c
20
lib/endian.c
@ -45,3 +45,23 @@ 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);
|
||||
}
|
||||
|
||||
void write32_le(const int value, unsigned char *buffer)
|
||||
{
|
||||
buffer[0] = (char)(value & 0x000000FF);
|
||||
buffer[1] = (char)((value & 0x0000FF00) >> 8);
|
||||
buffer[2] = (char)((value & 0x00FF0000) >> 16);
|
||||
buffer[3] = (char)((value & 0xFF000000) >> 24);
|
||||
}
|
||||
|
||||
#if (CURL_SIZEOF_CURL_OFF_T > 4)
|
||||
#if defined(HAVE_LONGLONG)
|
||||
void write64_le(const long long value, unsigned char *buffer)
|
||||
#else
|
||||
void write64_le(const __int64 value, unsigned char *buffer)
|
||||
#endif
|
||||
{
|
||||
write32_le((int)value, buffer);
|
||||
write32_le((int)(value >> 32), buffer + 4);
|
||||
}
|
||||
#endif
|
||||
|
10
lib/endian.h
10
lib/endian.h
@ -25,4 +25,14 @@
|
||||
unsigned short readshort_le(unsigned char *buf);
|
||||
unsigned int readint_le(unsigned char *buf);
|
||||
|
||||
void write32_le(const int value, unsigned char *buffer);
|
||||
|
||||
#if (CURL_SIZEOF_CURL_OFF_T > 4)
|
||||
#if defined(HAVE_LONGLONG)
|
||||
void write64_le(const long long value, unsigned char *buffer);
|
||||
#else
|
||||
void write64_le(const __int64 value, unsigned char *buffer);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif /* HEADER_CURL_ENDIAN_H */
|
||||
|
Loading…
Reference in New Issue
Block a user