flatmax@597: #!/usr/bin/perl flatmax@597: flatmax@597: %subst = ( ); flatmax@597: $quiet = 0; flatmax@597: flatmax@597: while ( @ARGV ) { flatmax@597: $_ = shift @ARGV; flatmax@597: if ( s/^-// ) { flatmax@597: if ( /^l(.*)/ ) { flatmax@597: $v = ($1 eq "") ? shift @ARGV : $1; flatmax@597: ($v =~ /\/$/) || ($v .= "/"); flatmax@597: $_ = $v; flatmax@597: if ( /(.+)\@(.+)/ ) { flatmax@597: if ( exists $subst{$1} ) { flatmax@597: $subst{$1} = $2; flatmax@597: } else { flatmax@597: print STDERR "Unknown tag file $1 given with option -l\n"; flatmax@597: &usage(); flatmax@597: } flatmax@597: } else { flatmax@597: print STDERR "Argument $_ is invalid for option -l\n"; flatmax@597: &usage(); flatmax@597: } flatmax@597: } flatmax@597: elsif ( /^q/ ) { flatmax@597: $quiet = 1; flatmax@597: } flatmax@597: elsif ( /^\?|^h/ ) { flatmax@597: &usage(); flatmax@597: } flatmax@597: else { flatmax@597: print STDERR "Illegal option -$_\n"; flatmax@597: &usage(); flatmax@597: } flatmax@597: } flatmax@597: else { flatmax@597: push (@files, $_ ); flatmax@597: } flatmax@597: } flatmax@597: flatmax@597: foreach $sub (keys %subst) flatmax@597: { flatmax@597: if ( $subst{$sub} eq "" ) flatmax@597: { flatmax@597: print STDERR "No substitute given for tag file `$sub'\n"; flatmax@597: &usage(); flatmax@597: } flatmax@597: elsif ( ! $quiet && $sub ne "_doc" && $sub ne "_cgi" ) flatmax@597: { flatmax@597: print "Substituting $subst{$sub} for each occurrence of tag file $sub\n"; flatmax@597: } flatmax@597: } flatmax@597: flatmax@597: if ( ! @files ) { flatmax@597: if (opendir(D,".")) { flatmax@597: foreach $file ( readdir(D) ) { flatmax@597: $match = ".html"; flatmax@597: next if ( $file =~ /^\.\.?$/ ); flatmax@597: ($file =~ /$match/) && (push @files, $file); flatmax@597: ($file =~ /\.svg/) && (push @files, $file); flatmax@597: ($file =~ "navtree.js") && (push @files, $file); flatmax@597: } flatmax@597: closedir(D); flatmax@597: } flatmax@597: } flatmax@597: flatmax@597: if ( ! @files ) { flatmax@597: print STDERR "Warning: No input files given and none found!\n"; flatmax@597: } flatmax@597: flatmax@597: foreach $f (@files) flatmax@597: { flatmax@597: if ( ! $quiet ) { flatmax@597: print "Editing: $f...\n"; flatmax@597: } flatmax@597: $oldf = $f; flatmax@597: $f .= ".bak"; flatmax@597: unless (rename $oldf,$f) { flatmax@597: print STDERR "Error: cannot rename file $oldf\n"; flatmax@597: exit 1; flatmax@597: } flatmax@597: if (open(F,"<$f")) { flatmax@597: unless (open(G,">$oldf")) { flatmax@597: print STDERR "Error: opening file $oldf for writing\n"; flatmax@597: exit 1; flatmax@597: } flatmax@597: if ($oldf ne "tree.js") { flatmax@597: while () { flatmax@597: s/doxygen\=\"([^ \"\:\t\>\<]*)\:([^ \"\t\>\<]*)\" (xlink:href|href|src)=\"\2/doxygen\=\"$1:$subst{$1}\" \3=\"$subst{$1}/g; flatmax@597: print G "$_"; flatmax@597: } flatmax@597: } flatmax@597: else { flatmax@597: while () { flatmax@597: s/\"([^ \"\:\t\>\<]*)\:([^ \"\t\>\<]*)\", \"\2/\"$1:$subst{$1}\" ,\"$subst{$1}/g; flatmax@597: print G "$_"; flatmax@597: } flatmax@597: } flatmax@597: } flatmax@597: else { flatmax@597: print STDERR "Warning file $f does not exist\n"; flatmax@597: } flatmax@597: unlink $f; flatmax@597: } flatmax@597: flatmax@597: sub usage { flatmax@597: print STDERR "Usage: installdox [options] [html-file [html-file ...]]\n"; flatmax@597: print STDERR "Options:\n"; flatmax@597: print STDERR " -l tagfile\@linkName tag file + URL or directory \n"; flatmax@597: print STDERR " -q Quiet mode\n\n"; flatmax@597: exit 1; flatmax@597: }