return;
}
+#
+## The load_blocklists function.
+#
+## This function is responsible for loading all enabled blocklists.
+##
+## It will gain all enabled blocklists and perform a de-duplication of
+## the blocked addresses/networks on the single blocklists while reading the
+## cached files before calling the load_blocklist() function.
+#
+sub load_blocklists () {
+ # Hash to store the single elements of all blocklists,
+ # to de-duplicate them.
+ my %addresses = ();
+
+ # Story any errors.
+ my @errors;
+
+ # Get all enabled blocklists.
+ my @enabled_blocklists = &get_enabled_blocklists();
+
+ # Loop through the array of enabled blocklists.
+ foreach my $list (@enabled_blocklists) {
+ # Temporary array to store the uniqe blocklist
+ # elements.
+ my @data = ();
+
+ # Get the file name of the cached blocklist.
+ my $file = &get_cached_blocklist_file($list);
+
+ # Open the file for reading.
+ open(FILE, $file) if (-e $file);
+
+ # Read-in the file content.
+ my @file_content = <FILE>;
+
+ # Close file handle.
+ close(FILE);
+
+ # Skip list if the file does not contain any content.
+ next unless(@file_content);
+
+ # Loop through the file content.
+ foreach my $line (@file_content) {
+ # Remove newline.
+ chomp($line);
+
+ # Skip element if the address / network allready has
+ # been seen. In this case an entry in the addresses
+ # hash exists.
+ next if($addresses{$line});
+
+ # Add the element to the addresses hash.
+ $addresses{$line} = $list;
+
+ # Add the line to the temporary blocklist array.
+ push(@data, $line);
+ }
+
+ # Skip the blocklist if there are no elements to add.
+ next unless(@data);
+
+ # Call function to load the blocklist.
+ my $error = &load_blocklist($list, @data);
+
+ # Check if there is an error to apply.
+ if ($error) {
+ # Append the error to the array of errors.
+ push(@errors, "Could not load $list - $error");
+ }
+ }
+
+ # Return any errors
+ return @errors;
+}
+
#
## sub parse_ip_or_net_list( line )
##