]> git.ipfire.org Git - people/ms/libloc.git/commitdiff
Make package compile on Mac OS X
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 12 Jan 2019 15:57:29 +0000 (15:57 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 17 Oct 2019 13:25:37 +0000 (14:25 +0100)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Makefile.am
src/as.c
src/database.c
src/libloc.c
src/loc/compat.h [new file with mode: 0644]
src/network.c
src/writer.c

index 3dca0fee8207b7d006d487259ab4880f6bb08001..be8d94c08bf2172444aba54be90c83a58d47c9b5 100644 (file)
@@ -68,6 +68,7 @@ EXTRA_DIST += \
 pkginclude_HEADERS = \
        src/loc/libloc.h \
        src/loc/as.h \
+       src/loc/compat.h \
        src/loc/country.h \
        src/loc/database.h \
        src/loc/format.h \
index 8be229ad72596a4b41dc0daa0bf29d13f50c0f37..947bfd2872b662aa7fce571328e689fe72f1f8c3 100644 (file)
--- a/src/as.c
+++ b/src/as.c
 */
 
 #include <ctype.h>
-#include <endian.h>
 #include <errno.h>
 #include <stdint.h>
 #include <stdlib.h>
 #include <string.h>
 
+#ifdef HAVE_ENDIAN_H
+#  include <endian.h>
+#endif
+
 #include <loc/libloc.h>
 #include <loc/as.h>
+#include <loc/compat.h>
 #include <loc/format.h>
 #include <loc/private.h>
 #include <loc/stringpool.h>
index d19bf7c140bc3ded8b7fb51641b73dba3f66deaf..6d39ae16f977cb3dacf9c891a75fa2148c4b4c15 100644 (file)
@@ -16,7 +16,6 @@
 
 #include <arpa/inet.h>
 #include <ctype.h>
-#include <endian.h>
 #include <errno.h>
 #include <netinet/in.h>
 #include <stddef.h>
 #include <time.h>
 #include <unistd.h>
 
+#ifdef HAVE_ENDIAN_H
+#  include <endian.h>
+#endif
+
 #include <loc/libloc.h>
 #include <loc/as.h>
+#include <loc/compat.h>
 #include <loc/country.h>
 #include <loc/database.h>
 #include <loc/format.h>
index fc05eb0f976c81fdbbfee94b1f1deb3452bd678f..0f2227994284e9a3ce2b2a24d8559cdd905df8ff 100644 (file)
@@ -26,6 +26,7 @@
 #include <ctype.h>
 
 #include <loc/libloc.h>
+#include <loc/compat.h>
 #include <loc/private.h>
 
 struct loc_ctx {
diff --git a/src/loc/compat.h b/src/loc/compat.h
new file mode 100644 (file)
index 0000000..8750976
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+       libloc - A library to determine the location of someone on the Internet
+
+       Copyright (C) 2019 IPFire Development Team <info@ipfire.org>
+
+       This library is free software; you can redistribute it and/or
+       modify it under the terms of the GNU Lesser General Public
+       License as published by the Free Software Foundation; either
+       version 2.1 of the License, or (at your option) any later version.
+
+       This library is distributed in the hope that it will be useful,
+       but WITHOUT ANY WARRANTY; without even the implied warranty of
+       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+       Lesser General Public License for more details.
+*/
+
+#ifndef LIBLOC_COMPAT_H
+#define LIBLOC_COMPAT_H
+
+#ifdef __APPLE__
+/* Hacks to make this library compile on Mac OS X */
+
+#include <libkern/OSByteOrder.h>
+#define be16toh(x) OSSwapBigToHostInt16(x)
+#define htobe16(x) OSSwapHostToBigInt16(x)
+#define be32toh(x) OSSwapBigToHostInt32(x)
+#define htobe32(x) OSSwapHostToBigInt32(x)
+#define be64toh(x) OSSwapBigToHostInt64(x)
+#define htobe64(x) OSSwapHostToBigInt64(x)
+
+#ifndef s6_addr16
+#  define s6_addr16 __u6_addr.__u6_addr16
+#endif
+#ifndef s6_addr32
+#  define s6_addr32 __u6_addr.__u6_addr32
+#endif
+
+#endif
+
+#endif
index 0a22b7632b5f89a7841726a3543f60ed1e860924..09f225e7138073204b444414eedbe659d6ee5a2e 100644 (file)
 
 #include <arpa/inet.h>
 #include <assert.h>
-#include <endian.h>
 #include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
+#ifdef HAVE_ENDIAN_H
+#  include <endian.h>
+#endif
+
 #include <loc/libloc.h>
+#include <loc/compat.h>
 #include <loc/country.h>
 #include <loc/network.h>
 #include <loc/private.h>
index 60a129bd3a45770e0ab8c13e434fb8881d838876..594df1a0327672ce072e8099a213aa7a70a57d85 100644 (file)
@@ -14,7 +14,6 @@
        Lesser General Public License for more details.
 */
 
-#include <endian.h>
 #include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <sys/queue.h>
 #include <time.h>
 
+#ifdef HAVE_ENDIAN_H
+#  include <endian.h>
+#endif
+
 #include <loc/libloc.h>
 #include <loc/as.h>
+#include <loc/compat.h>
 #include <loc/country.h>
 #include <loc/format.h>
 #include <loc/network.h>