File: servers.pl

package info (click to toggle)
erc 5.1.4-3
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 1,444 kB
  • ctags: 1,257
  • sloc: lisp: 14,826; makefile: 190; sh: 52; perl: 33
file content (50 lines) | stat: -rwxr-xr-x 1,457 bytes parent folder | download | duplicates (2)
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
49
50
#!/usr/bin/perl

# Copyright (C) 2002 Free Software Foundation, Inc.

# 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";