#!/usr/bin/perl -s require "/home/cms/bin/choosers.pl"; use XML::Parser; die "Usage: $0 \n" unless @ARGV; $0 =~ m|((.*)/)?[^/]+|; $binpath = $2; require "$binpath/template.pl"; foreach $infile (@ARGV) { $outfile = $infile; $outfile =~ s|source/(.*)\.xml$|site/$1\.html|; @paths = &fnparse($infile); $filepath = $paths[0]; $filename = $paths[1]; if($filename eq "index.xml") { $outfile =~ s|index\.html$|main\.html| if $frames; } print STDERR "makedep $infile\n" if $makedep; &choosetemplate($filepath); &chooseparser($filepath); ($infile_ticker = $infile) =~ s|.xml|_ticker.txt|; ($filename = $outfile) =~ s|^site/|/|; $compilefunc = &get_template($template); if($makedep) { push @depends, $infile_ticker if( -e $infile_ticker); print "$outfile: ", join(" ", @depends), " $parser\n"; } else { require $parser; %data=(); &do_parse(); $result = &$compilefunc(\%data); open(OUT,">$outfile"); print OUT $result; close(OUT); } } sub default_parse { $parser = new XML::Parser(Style => 'Subs', Handlers => {Char => \&handle_char}, ErrorContext=>3); $parser->parsefile($infile); } sub fnparse { $_[0] =~ m|^((.*)/)?([^/]+)$|; return ($1, $3); } sub copyhash { local($ref) = @_; local(%theirhash) = %$ref; local(%myhash); foreach $key (keys(%theirhash)) { $myhash{$key} = $theirhash{$key}; } return \%myhash; } sub istrue { local($ref) = @_; $type = &typeof($ref); if($type eq "VALUE") { return !!$ref; } elsif($type eq "SCALAR") { return !!$$ref; } elsif($type eq "ARRAY") { local(@a) = @$ref; return !!(scalar(@arr)); } elsif($type eq "HASH") { local(%h) = %$ref; return !!(scalar(%h)); } } sub typeof { local($ref) = @_; local($r) = ref($ref); $r = "VALUE" unless $r; local($s) = sprintf("%s", $r); return $s; }