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