aboutsummaryrefslogtreecommitdiffstats
path: root/libgeome_netservices.c
blob: d1f335394d1b11b6eb2a5e4759c586a78f2a1f5e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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), .patterned = 0\
	}

const 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);