From patchwork Wed Dec 11 10:38:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Schantl X-Patchwork-Id: 2638 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384 client-signature ECDSA (P-384) client-digest SHA384) (Client CN "mail01.haj.ipfire.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 47Xtgc0pkCz420M for ; Wed, 11 Dec 2019 10:38:20 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384 client-signature ECDSA (P-384) client-digest SHA384) (Client CN "mail02.haj.ipfire.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 47Xtgb6Qqdz2cD; Wed, 11 Dec 2019 10:38:19 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 47Xtgb4MHrz2yCr; Wed, 11 Dec 2019 10:38:19 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384 client-signature ECDSA (P-384) client-digest SHA384) (Client CN "mail01.haj.ipfire.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 47XtgY64lfz2yCL; Wed, 11 Dec 2019 10:38:17 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (Client did not present a certificate) by mail01.ipfire.org (Postfix) with ESMTPSA id 47XtgY1Mx0z2Cg; Wed, 11 Dec 2019 10:38:17 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=201909ed25519; t=1576060697; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=gXJXtTkqQXJpYgmiXoux5B4kcPxLHwXYHLDF/Zp9A4M=; b=Y9LCjdYqmF02yuJqrNL3ejX7Ae9DmPdEvawcCsosY4PZTKOZRKUTCjQZX65gk21XYASmT4 +3wF47wvrJedY8Cg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=201909rsa; t=1576060697; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=gXJXtTkqQXJpYgmiXoux5B4kcPxLHwXYHLDF/Zp9A4M=; b=YuY76be02KqCnHWAzobJgZVVM1703PNz2tRAqE6o8NwE6rzudNWjy1GKK5uRe4SKn7ew1s IA6ilPEs8ZtxaQ09ePc7+MrPPdqW+m9VcxVp/7vE5+iTpNVs6lOHg98Rl3K40RjUFU1Dc2 5r8ojFFhyTrIhWiKixz01ywBHz9y+eK9EWN5QOXf2AwxwWqzAUCt5++SdQvJfORbdw0xLc Cnz54w420FQuq0lNd8oeM/kVLdDSsVLyDWifx8fs/us/HZhJt+mAoMXIprtXnsS3JhME65 vbAjabML9oX23hi86JFBRCDFbNqTizPwfwOd1Fzs+JRLCRQiNX3H8LEu/k5nvA== From: Stefan Schantl To: location@lists.ipfire.org Subject: [PATCH] perl: Add get_continent_code() Date: Wed, 11 Dec 2019 11:38:14 +0100 Message-Id: <20191211103814.4130-1-stefan.schantl@ipfire.org> MIME-Version: 1.0 Authentication-Results: mail01.ipfire.org; auth=pass smtp.auth=stevee smtp.mailfrom=stefan.schantl@ipfire.org X-BeenThere: location@lists.ipfire.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: development@lists.ipfire.org Errors-To: location-bounces@lists.ipfire.org Sender: "Location" This function allows to get the continent code by a given country code. Signed-off-by: Stefan Schantl --- 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;