Config.pm untested

filter: Statementstmt 0.0% 0 / 35 Branchbran 0.0% 0 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 55 CC 6 SCAR 27.4
CC
6
Cov
0%
_init
30.0
check
6.0
new
2.0
CRAP 15.5
1 #!/usr/bin/perl
2  
3 # EvilBoss-api - API for creating FTN-tools
4 #
5 # (EB)Config.pm - read EvilBoss configuration file
6 #
7 # Copyright (c) 2004-2005 Alex Soukhotine, 2:5030/1157
8 #
9 # This program is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 2 of the License, or
12 # (at your option) any later version.
13 #
14 # $Id$
15  
16 package EvilBoss::Config;
17  
18 require Exporter;
19  
20 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
21  
22 $VERSION = 1.01;
23  
24 @ISA=qw(Exporter);
25 #@EXPORT = qw(&f1 &f3 &name);
26 %EXPORT_TAGS=();
27  
28 #@EXPORT_OK = qw(&name);
29  
30 $ConfigFile="/etc/ftn/evilboss.conf";
31  
32 sub new
33 {
34 my $classname = shift;
35 my $self = {};
36 bless($self,$classname);
37 $self->_init(@_);
38 return $self;
39 }
40  
41 sub DESTROY
42 {
43 my $self = shift;
44 }
45  
46 sub _init
47 {
48 my $self = shift;
49  
50 $ConfigFile=$_[0] if (@_);
51  
52 if (open(EBCONF,"<$ConfigFile"))
53 {
54 while(<EBCONF>)
55 {
56 if (/^\s*(\w+)\s+([\w\d:\/\., -]+)\#*/)
57 {
58 if (!$self->{$1})
59 {
60 $self->{$1}=$2;
61 }
62 else
63 {
64 my @tmp=$1;
65 push(@tmp,$self->{$1});
66 push(@tmp,$2);
67 $self->{$1}=@tmp;
68 }
69 }
70 }
71 close(EBCONF);
72 }
73 }
74  
75 sub check
76 {
77 my $self = shift;
78 for ($i=0;$_[$i];$i++)
79 {
80 return 0 if (!$self->{$_[$i]});
81 }
82 return 1;
83 }
84  
85  
86 1;