1
0
mirror of https://github.com/dguglielmi/sunny-overlay.git synced 2025-12-06 11:42:40 +01:00
Files
sunny-overlay/net-misc/ipcalc-ng/files/ipcalc-ng-0.2.2-fix-geoip-linking.patch

65 lines
1.5 KiB
Diff

diff --git a/ipcalc-geoip.c b/ipcalc-geoip.c
index 6be38fe..17b6346 100644
--- a/ipcalc-geoip.c
+++ b/ipcalc-geoip.c
@@ -34,6 +34,22 @@
# include <GeoIP.h>
# include <GeoIPCity.h>
+static int __attribute__((__format__(printf, 2, 3)))
+safe_asprintf(char **strp, const char *fmt, ...)
+{
+ int ret;
+ va_list args;
+
+ va_start(args, fmt);
+ ret = vasprintf(&(*strp), fmt, args);
+ va_end(args);
+ if (ret < 0) {
+ fprintf(stderr, "Memory allocation failure\n");
+ exit(1);
+ }
+ return ret;
+}
+
# ifdef USE_DYN_GEOIP
# include <dlfcn.h>
@@ -59,22 +75,6 @@ static GeoIP_record_by_ipnum_v6_func pGeoIP_record_by_ipnum_v6;
#define LIBNAME LIBPATH"/libGeoIP.so.1"
-static int __attribute__((__format__(printf, 2, 3)))
-safe_asprintf(char **strp, const char *fmt, ...)
-{
- int ret;
- va_list args;
-
- va_start(args, fmt);
- ret = vasprintf(&(*strp), fmt, args);
- va_end(args);
- if (ret < 0) {
- fprintf(stderr, "Memory allocation failure\n");
- exit(1);
- }
- return ret;
-}
-
int geo_setup(void)
{
static void *ld = NULL;
diff --git a/ipcalc.h b/ipcalc.h
index a3f13bc..9af367a 100644
--- a/ipcalc.h
+++ b/ipcalc.h
@@ -24,6 +24,9 @@
void geo_ipv4_lookup(struct in_addr ip, char **country, char **ccode, char **city, char **coord);
void geo_ipv6_lookup(struct in6_addr *ip, char **country, char **ccode, char **city, char **coord);
int geo_setup(void);
+#ifndef USE_DYN_GEOIP
+# define geo_setup() 0
+#endif
#else
# define geo_ipv4_lookup(x,y,z,w,a)
# define geo_ipv6_lookup(x,y,z,w,a)