From cd022c5f35688e02e546fd64577b20312ce5f2ec Mon Sep 17 00:00:00 2001 From: Stefan Schantl Date: Wed, 11 Dec 2019 11:38:14 +0100 Subject: [PATCH] perl: Add get_continent_code() This function allows to get the continent code by a given country code. Signed-off-by: Stefan Schantl Signed-off-by: Michael Tremer --- src/perl/Location.xs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/perl/Location.xs b/src/perl/Location.xs index 02dff7d..5693744 100644 --- a/src/perl/Location.xs +++ b/src/perl/Location.xs @@ -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; -- 2.39.2