summaryrefslogtreecommitdiffstats
path: root/src/instdox.cpp
diff options
context:
space:
mode:
authormueller <mueller@afe2bf4a-e733-0410-8a33-86f594647bc7>1999-12-15 19:25:10 (GMT)
committermueller <mueller@afe2bf4a-e733-0410-8a33-86f594647bc7>1999-12-15 19:25:10 (GMT)
commit719f0a35063be88eddcc4ed8fe7a940de47ef20c (patch)
treecc1cd70cf5761ddf72ff114c0b65576c3f4c1d2a /src/instdox.cpp
parentbd30c025c4651ddda467f1af09d4c7ccab397bde (diff)
downloadDoxygen-719f0a35063be88eddcc4ed8fe7a940de47ef20c.zip
Doxygen-719f0a35063be88eddcc4ed8fe7a940de47ef20c.tar.gz
Doxygen-719f0a35063be88eddcc4ed8fe7a940de47ef20c.tar.bz2
initial version
Diffstat (limited to 'src/instdox.cpp')
-rw-r--r--src/instdox.cpp164
1 files changed, 164 insertions, 0 deletions
diff --git a/src/instdox.cpp b/src/instdox.cpp
new file mode 100644
index 0000000..ad22c89
--- /dev/null
+++ b/src/instdox.cpp
@@ -0,0 +1,164 @@
+/******************************************************************************
+ *
+ * $Id$
+ *
+ * Copyright (C) 1997-1999 by Dimitri van Heesch.
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation under the terms of the GNU General Public License is hereby
+ * granted. No representations are made about the suitability of this software
+ * for any purpose. It is provided "as is" without express or implied warranty.
+ * See the GNU General Public License for more details.
+ *
+ * All output generated with Doxygen is not covered by this license.
+ *
+ */
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <qstring.h>
+#include <qfile.h>
+#include <qfileinf.h>
+#include <qtstream.h>
+
+#include "instdox.h"
+#include "doxygen.h"
+#include "config.h"
+#include "message.h"
+
+void writeInstallScript()
+{
+ QString fileName=htmlOutputDir+"/installdox";
+ QFile f(fileName);
+ if (f.open(IO_WriteOnly))
+ {
+ QTextStream t(&f);
+ t << "#!" << perlPath << endl << endl << "%subst = ( ";
+
+ char *s=tagFileList.first();
+ while (s)
+ {
+ QFileInfo fi(s);
+ t << "\"" << fi.fileName() << "\", \"\"";
+ s=tagFileList.next();
+ if (s) t << ", ";
+ }
+
+ t << ");\n";
+ t << "$quiet = 0;\n";
+ t << "\n";
+ t << "if (open(F,\"search.cfg\"))\n";
+ t << "{\n";
+ t << " $_=<F> ; s/[ \\t\\n]*$//g ; $subst{\"_doc\"} = $_;\n";
+ t << " $_=<F> ; s/[ \\t\\n]*$//g ; $subst{\"_cgi\"} = $_;\n";
+ t << "}\n";
+ t << "\n";
+ t << "while ( @ARGV ) {\n";
+ t << " $_ = shift @ARGV;\n";
+ t << " if ( s/^-// ) {\n";
+ t << " if ( /^l(.*)/ ) {\n";
+ t << " $v = ($1 eq \"\") ? shift @ARGV : $1;\n";
+ t << " ($v =~ /\\/$/) || ($v .= \"/\");\n";
+ t << " $_ = $v;\n";
+ t << " if ( /(.+)\\@(.+)/ ) {\n";
+ t << " if ( exists $subst{$1} ) {\n";
+ t << " $subst{$1} = $2;\n";
+ t << " } else {\n";
+ t << " print STDERR \"Unknown tag file $1 given with option -l\\n\";\n";
+ t << " &usage();\n";
+ t << " }\n";
+ t << " } else {\n";
+ t << " print STDERR \"Argument $_ is invalid for option -l\\n\";\n";
+ t << " &usage();\n";
+ t << " }\n";
+ t << " }\n";
+ t << " elsif ( /^q/ ) {\n";
+ t << " $quiet = 1;\n";
+ t << " }\n";
+ t << " elsif ( /^\\?|^h/ ) {\n";
+ t << " &usage();\n";
+ t << " }\n";
+ t << " else {\n";
+ t << " print STDERR \"Illegal option -$_\\n\";\n";
+ t << " &usage();\n";
+ t << " }\n";
+ t << " }\n";
+ t << " else {\n";
+ t << " push (@files, $_ );\n";
+ t << " }\n";
+ t << "}\n";
+ t << "\n";
+ t << "foreach $sub (keys %subst)\n";
+ t << "{\n";
+ t << " if ( $subst{$sub} eq \"\" ) \n";
+ t << " {\n";
+ t << " print STDERR \"No substitute given for tag file `$sub'\\n\";\n";
+ t << " &usage();\n";
+ t << " }\n";
+ t << " elsif ( ! $quiet && $sub!=\"_doc\" && $sub!=\"_cgi\" )\n";
+ t << " {\n";
+ t << " print \"Substituting $subst{$sub} for each occurence of tag file $sub\\n\"; \n";
+ t << " }\n";
+ t << "}\n";
+ t << "\n";
+ t << "if ( ! @files ) {\n";
+ t << " if (opendir(D,\".\")) {\n";
+ t << " foreach $file ( readdir(D) ) {\n";
+ t << " $match = \".html\";\n";
+ t << " next if ( $file =~ /^\\.\\.?$/ );\n";
+ t << " ($file =~ /$match/) && (push @files, $file);\n";
+ t << " }\n";
+ t << " closedir(D);\n";
+ t << " }\n";
+ t << "}\n";
+ t << "\n";
+ t << "if ( ! @files ) {\n";
+ t << " print STDERR \"Warning: No input files given and non found!\\n\";\n";
+ t << "}\n";
+ t << "\n";
+ t << "foreach $f (@files)\n";
+ t << "{\n";
+ t << " if ( ! $quiet ) {\n";
+ t << " print \"Editing: $f...\\n\";\n";
+ t << " }\n";
+ t << " $oldf = $f;\n";
+ t << " $f .= \".bak\";\n";
+ t << " unless (rename $oldf,$f) {\n";
+ t << " print STDERR \"Error: cannot rename file $oldf\\n\";\n";
+ t << " exit 1;\n";
+ t << " }\n";
+ t << " if (open(F,\"<$f\")) {\n";
+ t << " unless (open(G,\">$oldf\")) {\n";
+ t << " print STDERR \"Error: opening file $oldf for writing\\n\";\n";
+ t << " exit 1;\n";
+ t << " }\n";
+ t << " while (<F>) {\n";
+ t << " s/doxygen\\=\\\"([^ \\\"\\:\\t\\>\\<]*)\\:([^ \\\"\\t\\>\\<]*)\\\" (href|src)=\\\"\\2/doxygen\\=\\\"$1:$subst{$1}\\\" \\3=\\\"$subst{$1}/g;\n";
+ t << " print G \"$_\";\n";
+ t << " }\n";
+ t << " } \n";
+ t << " else {\n";
+ t << " print STDERR \"Warning file $f does not exist\\n\";\n";
+ t << " }\n";
+ t << " unlink $f;\n";
+ t << "}\n";
+ t << "\n";
+ t << "sub usage {\n";
+ t << " print STDERR \"Usage: installdox [options] [html-file [html-file ...]]\\n\";\n";
+ t << " print STDERR \"Options:\\n\";\n";
+ t << " print STDERR \" -l tagfile\\@linkName tag file + URL or directory \\n\";\n";
+ t << " print STDERR \" -q Quiet mode\\n\\n\";\n";
+ t << " exit 1;\n";
+ t << "}\n";
+ }
+ else
+ {
+ err("Error: Cannot open file %s for writing\n",fileName.data());
+ }
+ f.close();
+ struct stat stat_struct;
+ stat(fileName,&stat_struct);
+#if !defined(_WIN32)
+ chmod(fileName,stat_struct.st_mode|S_IXUSR|S_IXGRP|S_IXOTH);
+#endif
+}