ids-functions.pl: Add get_subscription_code() function.

This function can be used to obtain the subscription code of a given
configured provider.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
This commit is contained in:
Stefan Schantl
2022-03-24 21:17:08 +01:00
parent 061391e776
commit 235e3e92a3

View File

@@ -1607,6 +1607,34 @@ END
close(FILE);
}
#
## Function to get the subscription code of a configured provider.
#
sub get_subscription_code($) {
my ($provider) = @_;
my %configured_providers = ();
# Read-in providers settings file.
&General::readhasharray($providers_settings_file, \%configured_providers);
# Loop through the hash of configured providers.
foreach my $id (keys %configured_providers) {
# Assign nice human-readable values to the data fields.
my $provider_handle = $configured_providers{$id}[0];
my $subscription_code = $configured_providers{$id}[1];
# Check if the current processed provider is the requested one.
if ($provider_handle eq $provider) {
# Return the obtained subscription code.
return $subscription_code;
}
}
# No subscription code found - return nothing.
return;
}
#
## Function to get the ruleset date for a given provider.
##