From patchwork Thu Sep 10 15:57:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Schantl X-Patchwork-Id: 3448 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 4BnNp32GSwz3x3R for ; Thu, 10 Sep 2020 15:58:03 +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 4BnNp23fhgzw9; Thu, 10 Sep 2020 15:58:02 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4BnNp21v9vz2xms; Thu, 10 Sep 2020 15:58:02 +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 4BnNp051t4z2xCd; Thu, 10 Sep 2020 15:58:00 +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 4BnNnz5gWGzQv; Thu, 10 Sep 2020 15:57:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1599753480; 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=p+bn4OmeNGqsQ3lCUNWoeAGmbSo6YYMMFBNJnMeNmq8=; b=Rea8W56zcvc7waHyElv8Qb9eBdHUm/gSCR+Nssvuq562EWe8LVhPOMU+JyB0S8QWJbvu+d M2NB76JX1ZF0DWrl03QxctRJaNwByR6r+SGJT9dtZcPi3RE4f7I7zmP0xGnbPTyiPrvmPu xLF1zyylRFqaesmwhqEmEjThH+87iv96kaORT+oleEddtJvNzen1WGcuqTsOfawQ51ABqe JshHZd7h3dUAI3GpDJLRM7PDud6xD9f1t6Xnz70k5YD+L/Tcspc/5pIqPWSBX+9GjIh3qy AVrLJ0qpRClg/R3cCmtcaa08PZVgloaONJymW4ZeJO2yyNO3piUY0mOZgEVpTA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1599753480; 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=p+bn4OmeNGqsQ3lCUNWoeAGmbSo6YYMMFBNJnMeNmq8=; b=8BcNWOtzlZhMokbLtF7vZp1CJgartnoa7DclImniH4MV/X31kPGm58t7ZDE00LGUQ10f/r DygRvAyPhEp0c3CA== From: Stefan Schantl To: location@lists.ipfire.org Subject: [PATCH 1/4] perl: Add get_country_name() function. Date: Thu, 10 Sep 2020 17:57:44 +0200 Message-Id: <20200910155747.12553-1-stefan.schantl@ipfire.org> MIME-Version: 1.0 Authentication-Results: mail01.ipfire.org; auth=pass 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 can be used to get the stored name for a given country code. Signed-off-by: Stefan Schantl --- 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;