5 claws.get.tlds.pl - IANA TLDs online list to stdout as gchar* array.
7 Copyright (c) 2015 Ricardo Mones <ricardo@mones.org>
9 This program is free software: you can redistribute it and/or modify it
10 under the terms of the GNU General Public License as published by the
11 Free Software Foundation, either version 3 of the License, or (at your
12 option) any later version.
14 This program is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 General Public License for more details.
19 You should have received a copy of the GNU General Public License along
20 with this program. If not, see <http://www.gnu.org/licenses/>.
27 URL => "https://data.iana.org/TLD/tlds-alpha-by-domain.txt"
30 print "/*\n * This is a generated file.\n * See tools/claws.get.tlds.pl\n */\n";
31 print "#ifndef __TLDS_H__\n#define __TLDS_H__\n\n";
32 print "static const gchar *toplvl_domains [] = {\n\t"; # open array
34 my $payload = get URL;
35 my @lines = split /^/, $payload;
41 if (/^#(.*)$/) { # comments
42 my $c = $1; $c =~ s/^\s+|\s+$//g;
46 next if (/^XN--.*$/); # IDNs not supported yet, see bug #1670
47 my $tld = lc $_; # list comes in upper case
48 print "\"$tld\""; ++$j;
49 print "," unless $i >= scalar @lines;
50 print "" . ($j % 5 == 0 or $i >= scalar @lines)? "\n": " ";
51 print "\t" if ($j % 5 == 0 and $i < scalar @lines);
54 print "};\n\n"; # close array