File: servers.pl

package info (click to toggle)
xemacs21-packages 2009.02.17.dfsg.1-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 116,928 kB
  • ctags: 88,975
  • sloc: lisp: 1,232,060; ansic: 16,570; java: 13,514; xml: 6,477; sh: 4,611; makefile: 4,036; asm: 3,007; perl: 839; cpp: 500; ruby: 257; csh: 96; haskell: 93; awk: 49; python: 47
file content (48 lines) | stat: -rwxr-xr-x 1,404 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/perl

# Convert mIRC's servers.ini to a elisp structure.
# Get the file from http://www.mirc.co.uk/servers.ini

# TODO: We need a separate file where we can store regexp/functions
# to match a erc-server-announced-name against a erc-networks-alist entry.
# For sanity, we'df need a lookup procedure here, and insert the
# regexp/function instead of the nil value in the erc-networks-alist.
#
# There is a error somehow in the servers.ini. There are two
# undernets, undernet and Undernet. They are the same though.
# So we'd need to unify them somehow (change case)?

print "(defcustom erc-server-alist\n'(\n";
while (<>) {
    if(($sname, $shost, $sport, $grp) = $_ =~ /^n\d+=(.*)SERVER:(.*):(.*)GROUP:(.*)/){
  $groups{$grp}+=1;
  @ports = split ",", $sport;
  print "  (\"$sname\" '$grp \"$shost\" ";
  if ($#ports==0) {
      if (($p1,$p2)=$sport=~/(\d+)-(\d+)/) {
	  print "(($p1 $p2))";}
      else {
	  print $sport;
      }
  }
  else {
      print "(";
      foreach $port (@ports) {
	  if (($p1,$p2)=$port=~/(\d+)-(\d+)/) {
	      print "($p1 $p2) ";}
	  else {
	      print $port." ";
	  }
      }
      print ")";
  }
  print ")\n";
}
}
print ")\n  \"Server Alist\"\n  :group 'erc\n  :type 'sexp)\n\n";

print "(defcustom erc-networks-alist\n'(\n";
foreach $grp (sort(keys(%groups))) {
    print "  ($grp nil)\n";
}
print ")\n  \"Network alist\"\n  :group 'erc\n  :type 'sexp)\n";