Initial Commit
[packages] / xemacs-packages / erc / servers.pl
1 #!/usr/bin/perl
2
3 # Convert mIRC's servers.ini to a elisp structure.
4 # Get the file from http://www.mirc.co.uk/servers.ini
5
6 # TODO: We need a separate file where we can store regexp/functions
7 # to match a erc-server-announced-name against a erc-networks-alist entry.
8 # For sanity, we'df need a lookup procedure here, and insert the
9 # regexp/function instead of the nil value in the erc-networks-alist.
10 #
11 # There is a error somehow in the servers.ini. There are two
12 # undernets, undernet and Undernet. They are the same though.
13 # So we'd need to unify them somehow (change case)?
14
15 print "(defcustom erc-server-alist\n'(\n";
16 while (<>) {
17     if(($sname, $shost, $sport, $grp) = $_ =~ /^n\d+=(.*)SERVER:(.*):(.*)GROUP:(.*)/){
18   $groups{$grp}+=1;
19   @ports = split ",", $sport;
20   print "  (\"$sname\" '$grp \"$shost\" ";
21   if ($#ports==0) {
22       if (($p1,$p2)=$sport=~/(\d+)-(\d+)/) {
23           print "(($p1 $p2))";}
24       else {
25           print $sport;
26       }
27   }
28   else {
29       print "(";
30       foreach $port (@ports) {
31           if (($p1,$p2)=$port=~/(\d+)-(\d+)/) {
32               print "($p1 $p2) ";}
33           else {
34               print $port." ";
35           }
36       }
37       print ")";
38   }
39   print ")\n";
40 }
41 }
42 print ")\n  \"Server Alist\"\n  :group 'erc\n  :type 'sexp)\n\n";
43
44 print "(defcustom erc-networks-alist\n'(\n";
45 foreach $grp (sort(keys(%groups))) {
46     print "  ($grp nil)\n";
47 }
48 print ")\n  \"Network alist\"\n  :group 'erc\n  :type 'sexp)\n";