From: Michael Tremer Date: Sat, 12 Jan 2019 15:57:29 +0000 (+0000) Subject: Make package compile on Mac OS X X-Git-Tag: 0.9.0~26^2~5 X-Git-Url: http://git.ipfire.org/?p=people%2Fms%2Flibloc.git;a=commitdiff_plain;h=42f3ccd725ccc9d4479a3b20ea6338a431527684 Make package compile on Mac OS X Signed-off-by: Michael Tremer --- diff --git a/Makefile.am b/Makefile.am index 3dca0fe..be8d94c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 \ diff --git a/src/as.c b/src/as.c index 8be229a..947bfd2 100644 --- a/src/as.c +++ b/src/as.c @@ -15,14 +15,18 @@ */ #include -#include #include #include #include #include +#ifdef HAVE_ENDIAN_H +# include +#endif + #include #include +#include #include #include #include diff --git a/src/database.c b/src/database.c index d19bf7c..6d39ae1 100644 --- a/src/database.c +++ b/src/database.c @@ -16,7 +16,6 @@ #include #include -#include #include #include #include @@ -29,8 +28,13 @@ #include #include +#ifdef HAVE_ENDIAN_H +# include +#endif + #include #include +#include #include #include #include diff --git a/src/libloc.c b/src/libloc.c index fc05eb0..0f22279 100644 --- a/src/libloc.c +++ b/src/libloc.c @@ -26,6 +26,7 @@ #include #include +#include #include struct loc_ctx { diff --git a/src/loc/compat.h b/src/loc/compat.h new file mode 100644 index 0000000..8750976 --- /dev/null +++ b/src/loc/compat.h @@ -0,0 +1,40 @@ +/* + libloc - A library to determine the location of someone on the Internet + + Copyright (C) 2019 IPFire Development Team + + 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 +#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 diff --git a/src/network.c b/src/network.c index 0a22b76..09f225e 100644 --- a/src/network.c +++ b/src/network.c @@ -16,13 +16,17 @@ #include #include -#include #include #include #include #include +#ifdef HAVE_ENDIAN_H +# include +#endif + #include +#include #include #include #include diff --git a/src/writer.c b/src/writer.c index 60a129b..594df1a 100644 --- a/src/writer.c +++ b/src/writer.c @@ -14,7 +14,6 @@ Lesser General Public License for more details. */ -#include #include #include #include @@ -22,8 +21,13 @@ #include #include +#ifdef HAVE_ENDIAN_H +# include +#endif + #include #include +#include #include #include #include