1#! @PERL@
2#
3# -*-perl-*-
4#
5# This little script reads Fido nodelist.XXX (and points24.YYY) in and
6# generates a list with the following format from it:
7# <mailaddress> TAB <realname> TAB <comment>
8# To reduce the size of the generated list, only Region 24 of the
9# nodelist is used.
10#
11# The generated list can be used in combination of Thomas Roessler's
12# lbdb for the Mutt mailreader.
13#
14##########################################################################
15#
16#   Copyright (C) 1998-2005  Roland Rosenfeld <roland@spinnaker.de>
17#
18#   This program is free software; you can redistribute it and/or
19#   modify it under the terms of the GNU General Public License as
20#   published by the Free Software Foundation; either version 2 of
21#   the License, or (at your option) any later version.
22#
23#   This program is distributed in the hope that it will be useful,
24#   but WITHOUT ANY WARRANTY; without even the implied warranty of
25#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
26#   General Public License for more details.
27#
28#   You should have received a copy of the GNU General Public License
29#   along with this program; if not, write to the Free Software Foundation,
30#   Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301,, USA.
31#
32##########################################################################
33
34$database="$ENV{HOME}/.lbdb/nodelist";
35
36if (@ARGV == 0 || @ARGV >2
37    || !($ARGV[0] =~ /nodelist\.\d\d\d$/i)
38    || ((@ARGV == 2) && !($ARGV[1] =~ /points24\.\d\d\d$/i ))) {
39  die "Usage: $0 nodelist.XXX [points24.YYY]\n";
40}
41
42open (DB, ">$database") || die "Cannot open $database for writing";
43
44#
45# Process Nodelist:
46#
47
48$zone=2;
49$net=0;
50$node=0;
51
52open (NODELIST, "<$ARGV[0]") || die "Cannot open $ARGV[0]";
53while (<NODELIST>) {
54  next if /^;/;
55  ($special,$number,$bbs,$city,$name) = split(/,/);
56
57  if ($special =~ /Zone/) {
58    $zone=$number;
59    $net=$number;
60    $node=0;
61  } elsif ($special =~ /Region/) {
62    $net=$number;
63    $node=0;
64  } elsif ($special =~ /Host/) {
65    $net=$number;
66    $node=0;
67  } elsif ($special =~ /Down|Hold/) {
68    next;
69  } else {
70    $node = $number;
71  }
72
73  $address = "$name\@f$node.n$net.z$zone.fidonet.org";
74  $name =~ s/_/ /g;
75  $bbs =~ s/_/ /g;
76
77  #
78  # Restrict to Region 24:
79  #
80#  if ($zone =~ /^2$/ && $net =~ /^24/ ) {
81    print DB "$address\t$name\t$bbs\n";
82#  }
83}
84close NODELIST;
85
86
87#
88# Process Pointlist:
89#
90
91$zone=2;
92$net=0;
93$node=0;
94$point=0;
95
96open (POINTLIST, "<$ARGV[1]") || die "Cannot open $ARGV[1]";
97while (<POINTLIST>) {
98  next if /^;/;
99  ($special,$number,$bbs,$city,$name) = split(/,/);
100
101  if ($special =~ /Region/) {
102    next;
103  } elsif ($special =~ /Host/) {
104    ($net,$node) = split(/\//, $bbs);
105    next;
106  } elsif ($special =~ /Down|Hold/) {
107    next;
108  } else {
109    $point = $number;
110  }
111
112  $address = "$name\@p$point.f$node.n$net.z$zone.fidonet.org";
113  $name =~ s/_/ /g;
114  $city =~ s/_/ /g;
115
116  print DB "$address\t$name\t$city\n";
117
118}
119close NODELIST;
120
121
122close DB;
123