This function can be used to get the stored name for a given country code.
Signed-off-by: Stefan Schantl stefan.schantl@ipfire.org --- src/perl/Location.xs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
diff --git a/src/perl/Location.xs b/src/perl/Location.xs index 1cb2e21..dcf3f0d 100644 --- a/src/perl/Location.xs +++ b/src/perl/Location.xs @@ -243,6 +243,28 @@ lookup_asn(db, address) # # Get functions # +SV* +get_country_name(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 name for the given country code. + const char* country_name = loc_country_get_name(country); + RETVAL = newSVpv(country_name, strlen(country_name)); + + loc_country_unref(country); + } + + OUTPUT: + RETVAL + SV* get_continent_code(db, ccode) struct loc_database* db;