#!/usr/bin/perl use strict; my($cmd, $cmdstr, $input, $output, $arg, $TMP, $suppress); # Make sure local scripts can run $ENV{PATH} = $ENV{PATH} . ":."; $suppress = 0; # This script runs through the specified docbook source, and applies the # commands in blocks. It also plays games with conditional # inclusion of text... # # # ... as above ... # # execute blocks happen as the file is read (including recursively) # postexecute blocks happen once the entire file has been processed, and have # default input of the processed file # This should be fixed... open TMP, "> builddb-$$.tmp"; process("execute", "", \*STDIN, \*TMP); close TMP; open TMP, "< builddb-$$.tmp"; process("postexecute", "builddb-$$.tmp", \*TMP, \*STDOUT); close TMP; unlink "builddb-$$.tmp"; exit; sub process($){ my($exblock, $exfilename, $INPTR, $OUTPTR) = @_; while(<$INPTR>){ if((/(.*)<\/slidetext>/) || (/(.*)<\/noslide>/)){ $suppress = 0; } elsif((/(.*)/) && ($ARGV[0] ne "jpg")){ $suppress = 1; } elsif((/(.*)/) && ($ARGV[0] ne "jpg")){ } elsif(/(.*)/){ if($ARGV[0] eq "jpg"){ $suppress = 1; } } elsif(/(.*)/){ } elsif(/(.*)<\/slideinclude>/){ } elsif((/(.*)<$exblock>(.*)<\/$exblock>(.*)/) && ($suppress == 0)){ print $OUTPTR $1; $cmd = $2; $_ = $cmd; if(//){ $input = $cmd; $input =~ s/.*//; $input =~ s/<\/input>.*//; } else{ $input = ""; } if(//){ $output = $cmd; $output =~ s/.*//; $output =~ s/<\/output>.*//; } else{ $output = ""; } if(//){ $arg = $cmd; $arg =~ s/.*//; $arg =~ s/<\/args>.*//; } else{ $arg = ""; } $cmd =~ s/.*//; $cmd =~ s/<\/cmd>.*//; if(($cmd ne "todo") && ($cmd ne "nextedition") && ($cmd ne "cat")){ if($arg ne ""){ $cmdstr = "$cmd $arg $ARGV[0]"; } else{ $cmdstr = "$cmd $ARGV[0]"; } if($input ne ""){ if($exblock ne "postexecute"){ $cmdstr = "$cmdstr $input < $input"; } else{ $cmdstr = "$cmdstr < $input"; } } elsif($exblock eq "postexecute"){ $cmdstr = "$cmdstr < $exfilename"; } if($output ne ""){ $cmdstr = "$cmdstr > $output"; } print STDERR "Executing: $cmdstr\n"; $output=`$cmdstr`; $output =~ s/([^\r])\n/$1\r\n/g; print $OUTPTR "$output"; } elsif($cmd eq "todo"){ print $OUTPTR "
\n"; print $OUTPTR "$input\n"; print $OUTPTR `eqimg todo.png eps`; print $OUTPTR "
\n"; } elsif($cmd eq "nextedition"){ } elsif($cmd eq "cat"){ $output=`cat $input`; print $OUTPTR "$output"; } print $OUTPTR "$3"; } elsif($suppress == 0){ print $OUTPTR $_; } } }