blob: 0e29e828242752ecb653a596d8610818e48975be (
plain)
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
51
52
53
54
55
56
57
58
59
60
|
#!/usr/bin/perl
# RTFL
#
# Copyright 2014 Sebastian Geerken <sgeerken@dillo.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Usage: rtfl-check-objects
#
# Use RTFL messages to check for invalid object access.
#
# N. b. that parsing is incorrect, see <doc/rtfl.html#scripts>.
%exist_objects = { };
%all_objects = { };
%ident_objects = { };
sub check_object
{
my $id1 = $_[0], $id2 = $ident_objects{$_[0]};
if (!($exist_objects{$id1} || ($id2 && $exist_objects{$id2}))) {
if ($all_objects{$id1} || ($id2 && $all_objects{$id2})) {
print "--- Object $id1 has been deleted: ---\n$_";
} else {
print "--- Object $id1 has never existed: ---\n$_";
}
}
}
while(<STDIN>) {
if (/^\[rtfl[^\]]*\][^:]*:[^:]*:[^:]*:(obj-)?create:([^:]*):/) {
$exist_objects{$2}++;
$all_objects{$2} = 1;
} elsif (/^\[rtfl[^\]]*\][^:]*:[^:]*:[^:]*:(obj-)?delete:(.*)$/) {
$exist_objects{$2}--;
} elsif (/^\[rtfl[^\]]*\][^:]*:[^:]*:[^:]*:(obj-)?ident:([^:]*):(.*)$/) {
if($2 ne $3) {
$ident_objects{$2} = $3;
$ident_objects{$3} = $2;
}
} elsif (/^\[rtfl[^\]]*\][^:]*:[^:]*:[^:]*:(obj-)?(msg|set|enter|leave):([^:]*):/ ||
/^\[rtfl[^\]]*\][^:]*:[^:]*:[^:]*:(obj-)?(msg-start|msg-end|leave):(.*)$/) {
check_object ($3);
} elsif (/^\[rtfl[^\]]*\][^:]*:[^:]*:[^:]*:(obj-)?assoc:([^:]*):(.*)$/) {
check_object ($2);
check_object ($3);
}
}
|