]> git.donarmstrong.com Git - debbugs.git/blob - Debbugs/Common.pm
* When a bug can't be found in control@; indicate to user that it may
[debbugs.git] / Debbugs / Common.pm
1 package Debbugs::Common; 
2
3 use strict;
4
5 BEGIN {
6         use Exporter   ();
7         use vars       qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
8
9         # set the version for version checking
10         $VERSION     = 1.00;
11
12         @ISA         = qw(Exporter);
13         @EXPORT      = qw(&fail &NameToPathHash &sani &quit);
14         %EXPORT_TAGS = (  );     # eg: TAG => [ qw!name1 name2! ],
15
16         # your exported package globals go here,
17         # as well as any optionally exported functions
18         @EXPORT_OK   = qw();
19 }
20
21 use vars      @EXPORT_OK;
22 use Debbugs::Config qw(%Globals);
23 use FileHandle;
24 my @cleanups;
25 my $DEBUG = new FileHandle;
26
27 sub fail
28 {
29         print "$_[0]\n";
30         exit 1;
31 }
32 sub NameToPathHash
33 {
34 #   12345 -> 5/4/3/12345
35 #   12 -> s/2/1/12
36     my $name = $_[0];
37     my $tmp = $name;
38     $name =~ /^.*?(.)(.)(.)$/ ;
39     if(!defined($1)) {
40         $name =~ /^(.*?)(.)(.)$/ ;
41         $tmp = "$1$2$3"."s";
42     }
43     $tmp =~ /^.*?(.)(.)(.)$/ ;
44     return "$3/$2/$1/$name";
45 }
46
47 sub DEBUG
48 {
49     print $DEBUG $_;
50 }
51 sub quit
52 {
53     DEBUG("quitting >$_[0]<\n");
54     my $u;
55     while ($u= $cleanups[$#cleanups]) { &$u; }
56     die "*** $_[0]\n";
57 }
58 sub sani
59 {
60     HTML::Entities::encode($a);
61 }
62 1;
63 END { }       # module clean-up code here (global destructor)