summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/curl_endian.c17
-rw-r--r--lib/curl_endian.h3
2 files changed, 20 insertions, 0 deletions
diff --git a/lib/curl_endian.c b/lib/curl_endian.c
index 41202d73d..2d291c84c 100644
--- a/lib/curl_endian.c
+++ b/lib/curl_endian.c
@@ -63,6 +63,23 @@ unsigned int Curl_read32_le(unsigned char *buf)
}
/*
+ * 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()
*
* This function converts a 32-bit integer from the native endian format,
diff --git a/lib/curl_endian.h b/lib/curl_endian.h
index a8811c940..79eb3e8f6 100644
--- a/lib/curl_endian.h
+++ b/lib/curl_endian.h
@@ -28,6 +28,9 @@ unsigned short Curl_read16_le(unsigned char *buf);
/* Converts a 32-bit integer from little endian */
unsigned int Curl_read32_le(unsigned char *buf);
+/* 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);