4 |
## $Id$ |
## $Id$ |
5 |
## ------------------------------------------------------------------------- |
## ------------------------------------------------------------------------- |
6 |
## $Log$ |
## $Log$ |
7 |
|
## Revision 1.5 2003/03/29 06:54:59 joko |
8 |
|
## + sub rap_boot |
9 |
|
## |
10 |
|
## Revision 1.4 2003/03/27 15:58:08 joko |
11 |
|
## enhancement: now can execute perl-programs via 'do' here |
12 |
|
## |
13 |
|
## Revision 1.3 2003/02/20 21:39:49 joko |
14 |
|
## - find_rules moved to Rap.pm |
15 |
|
## |
16 |
|
## Revision 1.2 2003/02/18 19:09:07 jonen |
17 |
|
## + cwd for linux bootstrap |
18 |
|
## |
19 |
## Revision 1.1 2003/02/18 15:30:52 joko |
## Revision 1.1 2003/02/18 15:30:52 joko |
20 |
## + initial commit |
## + initial commit |
21 |
## |
## |
25 |
use strict; |
use strict; |
26 |
use warnings; |
use warnings; |
27 |
|
|
28 |
|
|
29 |
|
use File::Spec::Functions qw( splitpath splitdir catpath catdir ); |
30 |
|
|
31 |
|
sub popdir { |
32 |
|
my $path = shift; |
33 |
|
my $popcount = shift; |
34 |
|
(my $volume, my $directory, my $file) = splitpath( $path ); |
35 |
|
my @dir = splitdir($directory); |
36 |
|
while ($popcount--) { |
37 |
|
pop @dir; |
38 |
|
} |
39 |
|
#pop @dir; |
40 |
|
|
41 |
|
#my $base = catpath($volume, catdir(@dir)); |
42 |
|
my $base = join('/', @dir); |
43 |
|
$base = $volume . $base if $volume; |
44 |
|
|
45 |
|
return $base; |
46 |
|
} |
47 |
|
|
48 |
|
|
49 |
|
|
50 |
BEGIN { |
BEGIN { |
51 |
use FindBin qw($Bin); |
use FindBin qw($Bin); |
52 |
use lib "$Bin/../../libs"; |
#use lib "$Bin/../../libs"; |
53 |
|
my $libpath = popdir($Bin, 2) . '/libs'; |
54 |
|
#print "libpath: $libpath", "\n"; |
55 |
|
#exit; |
56 |
|
my $evs = "use lib '$libpath';"; |
57 |
|
#print "evs: $evs", "\n"; |
58 |
|
eval($evs); |
59 |
|
die($@) if $@; |
60 |
} |
} |
61 |
|
|
62 |
|
|
64 |
use Data::Dumper; |
use Data::Dumper; |
65 |
use Data::Rap; |
use Data::Rap; |
66 |
|
|
|
sub find_rules { |
|
|
return '../etc/rap.xml'; |
|
|
} |
|
67 |
|
|
68 |
sub main { |
sub main { |
69 |
my $argString = shift; |
my $argString = shift; |
70 |
my $rulesfile = find_rules(); |
|
71 |
my $rap = Data::Rap->new( filename => $rulesfile, target => $argString ); |
# check if target is a namespace-string (contains '::') |
72 |
$rap->start(); |
# TODO: move this logic/code to inside Data::Rap! |
73 |
|
if ($argString =~ s/::/\//g) { |
74 |
|
my $res = do "$argString"; |
75 |
|
print $res, "\n" if $res; |
76 |
|
} else { |
77 |
|
my $rap = Data::Rap->new( target => $argString ); |
78 |
|
rap_boot(); |
79 |
|
$rap->start(); |
80 |
|
#$rap->stop(); |
81 |
|
} |
82 |
|
} |
83 |
|
|
84 |
|
sub rap_boot { |
85 |
|
# check for another environment-variable: 'RAPBIN' |
86 |
|
# FIXME: what about 'topic.basedir'??? implement this here! |
87 |
|
# enhance infrastructure to have per-topic basedirs!!! |
88 |
|
chdir $ENV{RAPBIN} if $ENV{RAPBIN}; |
89 |
} |
} |
90 |
|
|
91 |
my @args = @ARGV; |
my @args = @ARGV; |