2 # Files.pl: Open and close, read and probably write files.
4 # Version: v0.2 (2000502)
8 if (&IsParam("useStrict")) { use strict; }
10 # File: Language support.
16 if (!open(FILE, $file)) {
17 &ERROR("FAILED loadLang ($file): $!");
21 undef %lang; # for rehash.
25 if ($_ eq "" || /^#/) {
37 &status("loadLang: bad line ('$_')");
41 $lang{$replyName}{$_} = 1;
47 &status("Loaded lang $file ($langCount items)");
55 if (!open(FILE, $file)) {
56 &ERROR("FAILED loadIgnore ($file): $!");
66 if (/^(\S+)[\t\s]+(\S+)([\t\s]+.*)?$/) {
74 &status("Loaded ignore $file ($count masks)");
77 # File: Irc Servers list.
83 if (!open(FILE, $file)) {
84 &ERROR("FAILED loadIRCServers ($file): $!");
93 if (/^(\S+)(:(\d+))?$/) {
95 $ircPort{$1} = ($3 || 6667);
97 &status("loadIRCServers: invalid line => '$_'.");
103 &status("Loaded ircServers $file (". scalar(@ircServers) ." servers)");
109 %userList = (); # clear it.
111 if (!open(FILE, $file)) {
112 &ERROR("FAILED loadUsers ($file): $!");
122 if (/^UserEntry\s+(.+?)\s/) {
126 if (/^\s*(\w+)\s+(.+);$/) {
127 my ($opt,$val) = ($1,$2);
131 $val =~ s/\+// if ($opt =~ /^flags$/i);
133 if ($opt =~ /^mask$/i) {
134 $userList{$userName}{$opt}{$val} = 1;
136 $userList{$userName}{$opt} = $val;
138 } elsif (/^\s*\}\s*$/) {
143 &status("parse error: User Entry $userName without right brace");
149 return unless (&IsParam("VERBOSITY"));
152 &status("Loaded userlist $file (". scalar(keys %userList) ." users)");
153 foreach $userName (keys %userList) {
154 &status(" $userName:");
155 &status(" flags: +$userList{$userName}{'flags'}");
157 foreach (keys %{$userList{$userName}{'mask'}}) {
158 &status(" hostmask: $_");