]> the.earth.li Git - htag.git/blob - plugins/07sesame
Import Upstream version 0.0.23
[htag.git] / plugins / 07sesame
1 #!/usr/bin/perl -w
2
3 # Copyright (C) 2000-2003 Simon Huggins
4 # Sesame Street style brought to you "by the letter X and the number 1"
5
6 # This program is free software; you can redistribute it and/or modify it
7 # under the terms of the GNU General Public License as published by the Free
8 # Software Foundation; either version 2 of the License, or (at your option)
9 # any later version.
10 #
11 # This program is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 # or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14 # for more details.
15 #
16 # You should have received a copy of the GNU General Public License along
17 # with this program; if not, write to the Free Software Foundation, Inc., 59
18 # Temple Place, Suite 330, Boston, MA 02111-1307  USA
19
20 # Outputs Sesame Street "Brought to you..." to tmpdir/S
21 # Therefore replaces @S... in sigs via merge.
22
23 use integer;
24 use strict;
25
26 my @found = scansigfile("S");
27 return if not @found;
28
29 #srand( time() ^ ($$ + ($$ << 15) )); # Since 5.004 not required
30
31 open(OUT, ">$cfg{'tmpdir'}/S") or htagdie "$0: Could not open $cfg{'tmpdir'}/S: $!\n";
32 reg_deletion("$cfg{'tmpdir'}/S");
33 foreach my $f (@found) {
34         my @f = @{$f};
35         my $recursion = 0;
36         while ($recursion < 30) {
37                 $recursion++;
38                 my $attr = pickone();
39                 if ($f[1] eq "*") {
40                         print OUT $attr,"\n";
41                         $recursion = 255;
42                 } elsif (length $attr <= $f[1]) {
43                         print OUT chunksizealign($attr, $f[1], $f[2]),"\n";
44                         $recursion = 255;
45                 }
46         }
47         if ($recursion != 255) {
48                 htagdie "Recursed too much trying to find chunk <= $f[1].\nPerhaps your space isn't big enough.\n";
49         }
50 }
51 close(OUT);
52 return;
53
54 sub pickone {
55         my $letter = ("A" .. "Z")[rand(26)];
56         my $number = rand(50)+1;
57         $number = " $number" if $number < 10;
58         return "the letter $letter and the number $number";
59 }