aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSteve Holme <steve_holme@hotmail.com>2014-12-31 15:58:07 +0000
committerSteve Holme <steve_holme@hotmail.com>2014-12-31 16:03:01 +0000
commit5eae12fc804c677bc413a49c7bddaff30d249c9e (patch)
treee63427032020976b8c608ab6bcf8fb950383b3cb /lib
parentb40e37f93ddbcce9db44e213e925d74d0df9858a (diff)
endian: Added 16-bit integer write function
Diffstat (limited to 'lib')
-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);