perl: Add get_continent_code()
Commit Message
This function allows to get the continent code by a given country code.
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
---
src/perl/Location.xs | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
@@ -166,6 +166,31 @@ lookup_asn(db, address)
OUTPUT:
RETVAL
+#
+# Get functions
+#
+SV*
+get_continent_code(db, ccode)
+ struct loc_database* db;
+ char* ccode;
+
+ CODE:
+ RETVAL = &PL_sv_undef;
+
+ // Lookup country code
+ struct loc_country *country;
+ int err = loc_database_get_country(db, &country, ccode);
+ if(!err) {
+ //Extract the continent code for the given country code.
+ const char* continent_code = loc_country_get_continent_code(country);
+ RETVAL = newSVpv(continent_code, strlen(continent_code));
+
+ loc_country_unref(country);
+ }
+
+ OUTPUT:
+ RETVAL
+
void
DESTROY(db)
struct loc_database* db;