installdox 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. #!/usr/bin/perl
  2. %subst = ( );
  3. $quiet = 0;
  4. if (open(F,"search.cfg"))
  5. {
  6. $_=<F> ; s/[ \t\n]*$//g ; $subst{"_doc"} = $_;
  7. $_=<F> ; s/[ \t\n]*$//g ; $subst{"_cgi"} = $_;
  8. }
  9. while ( @ARGV ) {
  10. $_ = shift @ARGV;
  11. if ( s/^-// ) {
  12. if ( /^l(.*)/ ) {
  13. $v = ($1 eq "") ? shift @ARGV : $1;
  14. ($v =~ /\/$/) || ($v .= "/");
  15. $_ = $v;
  16. if ( /(.+)\@(.+)/ ) {
  17. if ( exists $subst{$1} ) {
  18. $subst{$1} = $2;
  19. } else {
  20. print STDERR "Unknown tag file $1 given with option -l\n";
  21. &usage();
  22. }
  23. } else {
  24. print STDERR "Argument $_ is invalid for option -l\n";
  25. &usage();
  26. }
  27. }
  28. elsif ( /^q/ ) {
  29. $quiet = 1;
  30. }
  31. elsif ( /^\?|^h/ ) {
  32. &usage();
  33. }
  34. else {
  35. print STDERR "Illegal option -$_\n";
  36. &usage();
  37. }
  38. }
  39. else {
  40. push (@files, $_ );
  41. }
  42. }
  43. foreach $sub (keys %subst)
  44. {
  45. if ( $subst{$sub} eq "" )
  46. {
  47. print STDERR "No substitute given for tag file `$sub'\n";
  48. &usage();
  49. }
  50. elsif ( ! $quiet && $sub ne "_doc" && $sub ne "_cgi" )
  51. {
  52. print "Substituting $subst{$sub} for each occurrence of tag file $sub\n";
  53. }
  54. }
  55. if ( ! @files ) {
  56. if (opendir(D,".")) {
  57. foreach $file ( readdir(D) ) {
  58. $match = ".html";
  59. next if ( $file =~ /^\.\.?$/ );
  60. ($file =~ /$match/) && (push @files, $file);
  61. ($file =~ "tree.js") && (push @files, $file);
  62. }
  63. closedir(D);
  64. }
  65. }
  66. if ( ! @files ) {
  67. print STDERR "Warning: No input files given and none found!\n";
  68. }
  69. foreach $f (@files)
  70. {
  71. if ( ! $quiet ) {
  72. print "Editing: $f...\n";
  73. }
  74. $oldf = $f;
  75. $f .= ".bak";
  76. unless (rename $oldf,$f) {
  77. print STDERR "Error: cannot rename file $oldf\n";
  78. exit 1;
  79. }
  80. if (open(F,"<$f")) {
  81. unless (open(G,">$oldf")) {
  82. print STDERR "Error: opening file $oldf for writing\n";
  83. exit 1;
  84. }
  85. if ($oldf ne "tree.js") {
  86. while (<F>) {
  87. s/doxygen\=\"([^ \"\:\t\>\<]*)\:([^ \"\t\>\<]*)\" (href|src)=\"\2/doxygen\=\"$1:$subst{$1}\" \3=\"$subst{$1}/g;
  88. print G "$_";
  89. }
  90. }
  91. else {
  92. while (<F>) {
  93. s/\"([^ \"\:\t\>\<]*)\:([^ \"\t\>\<]*)\", \"\2/\"$1:$subst{$1}\" ,\"$subst{$1}/g;
  94. print G "$_";
  95. }
  96. }
  97. }
  98. else {
  99. print STDERR "Warning file $f does not exist\n";
  100. }
  101. unlink $f;
  102. }
  103. sub usage {
  104. print STDERR "Usage: installdox [options] [html-file [html-file ...]]\n";
  105. print STDERR "Options:\n";
  106. print STDERR " -l tagfile\@linkName tag file + URL or directory \n";
  107. print STDERR " -q Quiet mode\n\n";
  108. exit 1;
  109. }