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
61
62
63
64
|
sub nextI
{
if (!$size)
{
$size = -s INDEX;
}
local ($a,$b,$c,$dummy);
$cond = 0;
seek (INDEX,$index * 8,0);
while ($cond == 0)
{
&readnext;
if ($frame == 1)
{
$cond = 1;
}
else
{
$index++;
if ($index > ($size/8-1))
{
$index = $size/8-1;
&prevI;
print "$index\n";
exit 1;
}
}
}
}
sub readnext
{
read (INDEX,$a,4);
read (INDEX,$b,1);
read (INDEX,$c,1);
read (INDEX,$dummy,2);
$offset = unpack ("L",$a);
$frame = unpack ("C",$b);
$file = unpack ("C",$c);
}
sub prevI
{
local ($a,$b,$c,$dummy);
$cond = 0;
seek (INDEX,$index * 8,0);
while ($cond == 0)
{
&readnext;
if ($frame == 1)
{
$cond = 1;
}
else
{
$index--;
seek (INDEX,$index * 8,0);
}
}
}
1;
|