diff options
Diffstat (limited to 'libgeome_netservices.c')
-rw-r--r-- | libgeome_netservices.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/libgeome_netservices.c b/libgeome_netservices.c new file mode 100644 index 0000000..7701e2f --- /dev/null +++ b/libgeome_netservices.c @@ -0,0 +1,34 @@ +/* See LICENSE file for copyright and license details. */ +#include "common.h" + + +#define GET(URL) {"curl", "-sL", URL, NULL} + +static const char *args0a[] = GET("http://ip-api.com/line?fields=lat,lon"); +static const char *args0b[] = GET("http://ip-api.com/csv?fields=lat,lon"); +static const char *args0c[] = GET("http://ip-api.com/json?fields=lat,lon"); +static const char *args0d[] = GET("http://ip-api.com/xml?fields=lat,lon"); +static const char *args1[] = GET("https://ipinfo.io/loc"); +static const char *args2[] = GET("http://ipwho.is"); +static const char *args3[] = GET("https://geolocation-db.com/json/"); + + +#define COMMON(SERVICE_ID, ARGS)\ + {\ + .can_fetch = (LIBGEOME_DATUM_LATITUDE | LIBGEOME_DATUM_LONGITUDE),\ + .service_id = (SERVICE_ID), .limit = 2048U, .alarm_seconds = 5U,\ + .path = "curl", .args = (ARGS)\ + } + +struct libgeome_netservice libgeome_netservices[] = { + COMMON(0, args0a), + COMMON(0, args0b), + COMMON(0, args0c), + COMMON(0, args0d), + COMMON(1, args1), + COMMON(2, args2), + COMMON(3, args3) +}; + + +const size_t libgeome_netservices_count = sizeof(libgeome_netservices) / sizeof(*libgeome_netservices); |