summaryrefslogtreecommitdiff
path: root/src/charset/codecs/codec_utf16.c
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2009-07-02 17:53:52 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2009-07-02 17:53:52 +0000
commit040e428e08eedabed3994941a1b098a56827ca1d (patch)
tree4e1eae3df2dd261ac2e800355d4599e2141d3ffc /src/charset/codecs/codec_utf16.c
parent7f77907ab1f44a0d8b7c0fa14f2c9df69f42500b (diff)
downloadlibparserutils-040e428e08eedabed3994941a1b098a56827ca1d.tar.gz
libparserutils-040e428e08eedabed3994941a1b098a56827ca1d.tar.bz2
Remove dependency on a library providing ntohl/htonl.
svn path=/trunk/libparserutils/; revision=8267
Diffstat (limited to 'src/charset/codecs/codec_utf16.c')
-rw-r--r--src/charset/codecs/codec_utf16.c16
1 files changed, 4 insertions, 12 deletions
diff --git a/src/charset/codecs/codec_utf16.c b/src/charset/codecs/codec_utf16.c
index 6ec7878..8dbcae1 100644
--- a/src/charset/codecs/codec_utf16.c
+++ b/src/charset/codecs/codec_utf16.c
@@ -8,19 +8,11 @@
#include <stdlib.h>
#include <string.h>
-#ifdef BUILD_TARGET_windows
-#include <winsock.h>
-#else
-/* These three are for htonl / ntohl */
-#include <sys/types.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#endif
-
#include <parserutils/charset/mibenum.h>
#include <parserutils/charset/utf16.h>
#include "charset/codecs/codec_impl.h"
+#include "utils/endian.h"
#include "utils/utils.h"
/**
@@ -211,7 +203,7 @@ parserutils_error charset_utf16_codec_encode(parserutils_charset_codec *codec,
/* Now process the characters for this call */
while (*sourcelen > 0) {
- ucs4 = (uint32_t) ntohl(*((uint32_t *) (void *) *source));
+ ucs4 = endian_big_to_host(*((uint32_t *) (void *) *source));
towrite = &ucs4;
towritelen = 1;
@@ -315,7 +307,7 @@ parserutils_error charset_utf16_codec_decode(parserutils_charset_codec *codec,
while (c->read_len > 0 && *destlen >= c->read_len * 4) {
*((uint32_t *) (void *) *dest) =
- (uint32_t) htonl(pread[0]);
+ endian_host_to_big(pread[0]);
*dest += 4;
*destlen -= 4;
@@ -546,7 +538,7 @@ parserutils_error charset_utf16_codec_output_decoded_char(charset_utf16_codec *c
return PARSERUTILS_NOMEM;
}
- *((uint32_t *) (void *) *dest) = (uint32_t) htonl(ucs4);
+ *((uint32_t *) (void *) *dest) = endian_host_to_big(ucs4);
*dest += 4;
*destlen -= 4;