void writeDiaGraphFromFile(const char *inFile,const char *outDir, const char *outFile,DiaOutputFormat format) { QCString absOutFile = outDir; absOutFile+=portable_pathSeparator(); absOutFile+=outFile; // chdir to the output dir, so dot can find the font file. QCString oldDir = QDir::currentDirPath().utf8(); // go to the html output directory (i.e. path) QDir::setCurrent(outDir); //printf("Going to dir %s\n",QDir::currentDirPath().data()); QCString diaExe = Config_getString(DIA_PATH)+"dia"+portable_commandExtension(); QCString diaArgs; QCString extension; diaArgs+="-n "; if (format==DIA_BITMAP) { diaArgs+="-t png-libart"; extension=".png"; } else if (format==DIA_EPS) { diaArgs+="-t eps"; extension=".eps"; } diaArgs+=" -e \""; diaArgs+=outFile; diaArgs+=extension+"\""; diaArgs+=" \""; diaArgs+=inFile; diaArgs+="\""; int exitCode; //printf("*** running: %s %s outDir:%s %s\n",diaExe.data(),diaArgs.data(),outDir,outFile); portable_sysTimerStart(); if ((exitCode=portable_system(diaExe,diaArgs,FALSE))!=0) { portable_sysTimerStop(); goto error; } portable_sysTimerStop(); if ( (format==DIA_EPS) && (Config_getBool(USE_PDFLATEX)) ) { QCString epstopdfArgs(maxCmdLine); epstopdfArgs.sprintf("\"%s.eps\" --outfile=\"%s.pdf\"", outFile,outFile); portable_sysTimerStart(); if (portable_system("epstopdf",epstopdfArgs)!=0) { err("Problems running epstopdf. Check your TeX installation!\n"); } portable_sysTimerStop(); } error: QDir::setCurrent(oldDir); }
void writeMscGraphFromFile(const char *inFile,const char *outDir, const char *outFile,MscOutputFormat format) { QCString absOutFile = outDir; absOutFile+=portable_pathSeparator(); absOutFile+=outFile; // chdir to the output dir, so dot can find the font file. QCString oldDir = convertToQCString(QDir::currentDirPath()); // go to the html output directory (i.e. path) QDir::setCurrent(outDir); //printf("Going to dir %s\n",QDir::currentDirPath().data()); QCString mscExe = Config_getString("MSCGEN_PATH")+"mscgen"+portable_commandExtension(); QCString mscArgs; QCString extension; if (format==MSC_BITMAP) { mscArgs+="-T png"; extension=".png"; } else if (format==MSC_EPS) { mscArgs+="-T eps"; extension=".eps"; } mscArgs+=" -i \""; mscArgs+=inFile; mscArgs+=".msc\" -o \""; mscArgs+=outFile; mscArgs+=extension+"\""; int exitCode; //printf("*** running: %s %s\n",mscExe.data(),mscArgs.data()); portable_sysTimerStart(); if ((exitCode=portable_system(mscExe,mscArgs,FALSE))!=0) { portable_sysTimerStop(); goto error; } portable_sysTimerStop(); if ( (format==MSC_EPS) && (Config_getBool("USE_PDFLATEX")) ) { QCString epstopdfArgs(maxCmdLine); epstopdfArgs.sprintf("\"%s.eps\" --outfile=\"%s.pdf\"", outFile,outFile); portable_sysTimerStart(); if (portable_system("epstopdf",epstopdfArgs)!=0) { err("error: Problems running epstopdf. Check your TeX installation!\n"); } portable_sysTimerStop(); } error: QDir::setCurrent(oldDir); }
QCString getMscImageMapFromFile(const QCString& inFile, const QCString& outDir, const QCString& relPath,const QCString& context) { QCString outFile = inFile + ".map"; // chdir to the output dir, so dot can find the font file. QCString oldDir = convertToQCString(QDir::currentDirPath()); // go to the html output directory (i.e. path) QDir::setCurrent(outDir); //printf("Going to dir %s\n",QDir::currentDirPath().data()); QCString mscExe = Config_getString("MSCGEN_PATH")+"mscgen"+portable_commandExtension(); QCString mscArgs = "-T ismap -i \""; mscArgs+=inFile + ".msc\" -o \""; mscArgs+=outFile + "\""; int exitCode; portable_sysTimerStart(); if ((exitCode=portable_system(mscExe,mscArgs,FALSE))!=0) { portable_sysTimerStop(); QDir::setCurrent(oldDir); return ""; } portable_sysTimerStop(); QString result; QTextOStream tmpout(&result); convertMapFile(tmpout, outFile, relPath, context); QDir().remove(outFile); QDir::setCurrent(oldDir); return result.data(); }
/* ** Show the difference between two files, one in memory and one on disk. ** ** The difference is the set of edits needed to transform pFile1 into ** zFile2. The content of pFile1 is in memory. zFile2 exists on disk. ** ** Use the internal diff logic if zDiffCmd is NULL. Otherwise call the ** command zDiffCmd to do the diffing. */ static void diff_file( Blob *pFile1, /* In memory content to compare from */ const char *zFile2, /* On disk content to compare to */ const char *zName, /* Display name of the file */ const char *zDiffCmd, /* Command for comparison */ int ignoreEolWs /* Ignore whitespace at end of lines */ ){ if( zDiffCmd==0 ){ Blob out; /* Diff output text */ Blob file2; /* Content of zFile2 */ /* Read content of zFile2 into memory */ blob_zero(&file2); blob_read_from_file(&file2, zFile2); /* Compute and output the differences */ blob_zero(&out); //text_diff(pFile1, &file2, &out, 5, ignoreEolWs); csvs_diff(pFile1, &file2, &out); printf("--- %s\n+++ %s\n", zName, zName); printf("%s\n", blob_str(&out)); /* Release memory resources */ blob_reset(&file2); blob_reset(&out); }else{ int cnt = 0; Blob nameFile1; /* Name of temporary file to old pFile1 content */ Blob cmd; /* Text of command to run */ /* Construct a temporary file to hold pFile1 based on the name of ** zFile2 */ blob_zero(&nameFile1); do{ blob_reset(&nameFile1); blob_appendf(&nameFile1, "%s~%d", zFile2, cnt++); }while( access(blob_str(&nameFile1),0)==0 ); blob_write_to_file(pFile1, blob_str(&nameFile1)); /* Construct the external diff command */ blob_zero(&cmd); blob_appendf(&cmd, "%s ", zDiffCmd); shell_escape(&cmd, blob_str(&nameFile1)); blob_append(&cmd, " ", 1); shell_escape(&cmd, zFile2); /* Run the external diff command */ portable_system(blob_str(&cmd)); /* Delete the temporary file and clean up memory used */ unlink(blob_str(&nameFile1)); blob_reset(&nameFile1); blob_reset(&cmd); } }
/* ** This routine is called when the outbound message is complete and ** it is time to being recieving a reply. */ void transport_flip(void){ if( g.urlIsSsh ){ fprintf(sshOut, "\n\n"); }else if( g.urlIsFile ){ char *zCmd; fclose(transport.pFile); zCmd = mprintf("\"%s\" http \"%s\" \"%s\" \"%s\" 127.0.0.1", g.argv[0], g.urlName, transport.zOutFile, transport.zInFile ); portable_system(zCmd); free(zCmd); transport.pFile = fopen(transport.zInFile, "rb"); } }
bool CiteDict::execute() { //msg("..running bibtex\n"); bool result=TRUE; QCString auxFileName(m_baseFileName + ".aux"); int splitPoint = auxFileName.findRev('/'); QCString dirname = auxFileName.left(splitPoint); QCString basename = auxFileName.mid(splitPoint + 1); QCString oldDir = convertToQCString(QDir::currentDirPath()); QDir::setCurrent(dirname); QCString args; args += "-terse "; args += basename; portable_system("bibtex", args); int exitCode; if ((exitCode=portable_system("bibtex",args))!=0) { err("Problems running bibtex: exit code=%d, command='bibtex', arguments='%s'\n", exitCode,args.data()); result=FALSE; } QDir::setCurrent(oldDir); return result; }
/* ** Show the difference between two files, both in memory. ** ** The difference is the set of edits needed to transform pFile1 into ** pFile2. ** ** Use the internal diff logic if zDiffCmd is NULL. Otherwise call the ** command zDiffCmd to do the diffing. */ static void diff_file_mem( Blob *pFile1, /* In memory content to compare from */ Blob *pFile2, /* In memory content to compare to */ const char *zName, /* Display name of the file */ const char *zDiffCmd, /* Command for comparison */ int ignoreEolWs /* Ignore whitespace at end of lines */ ){ if( zDiffCmd==0 ){ Blob out; /* Diff output text */ blob_zero(&out); text_diff(pFile1, pFile2, &out, 5, ignoreEolWs); printf("--- %s\n+++ %s\n", zName, zName); printf("%s\n", blob_str(&out)); /* Release memory resources */ blob_reset(&out); }else{ Blob cmd; char zTemp1[300]; char zTemp2[300]; /* Construct a temporary file names */ file_tempname(sizeof(zTemp1), zTemp1); file_tempname(sizeof(zTemp2), zTemp2); blob_write_to_file(pFile1, zTemp1); blob_write_to_file(pFile2, zTemp2); /* Construct the external diff command */ blob_zero(&cmd); blob_appendf(&cmd, "%s ", zDiffCmd); shell_escape(&cmd, zTemp1); blob_append(&cmd, " ", 1); shell_escape(&cmd, zTemp2); /* Run the external diff command */ portable_system(blob_str(&cmd)); /* Delete the temporary file and clean up memory used */ unlink(zTemp1); unlink(zTemp2); blob_reset(&cmd); } }
void ClassDiagram::writeFigure(FTextStream &output,const char *path, const char *fileName) const { uint baseRows=base->computeRows(); uint superRows=super->computeRows(); uint baseMaxX, baseMaxLabelWidth, superMaxX, superMaxLabelWidth; base->computeExtremes(&baseMaxLabelWidth,&baseMaxX); super->computeExtremes(&superMaxLabelWidth,&superMaxX); uint rows=baseRows+superRows-1; uint cols=(QMAX(baseMaxX,superMaxX)+gridWidth*2-1)/gridWidth; // Estimate the image aspect width and height in pixels. uint estHeight = rows*40; uint estWidth = cols*(20+QMAX(baseMaxLabelWidth,superMaxLabelWidth)); //printf("Estimated size %d x %d\n",estWidth,estHeight); const float pageWidth = 14.0; // estimated page width in cm. // Somewhat lower to deal with estimation // errors. // compute the image height in centimeters based on the estimates float realHeight = QMIN(rows,12); // real height in cm float realWidth = realHeight * estWidth/(float)estHeight; if (realWidth>pageWidth) // assume that the page width is about 15 cm { realHeight*=pageWidth/realWidth; realWidth=pageWidth; } //output << "}\n"; output << "\\begin{figure}[H]\n" "\\begin{center}\n" "\\leavevmode\n"; output << "\\includegraphics[height=" << realHeight << "cm]{" << fileName << "}" << endl; output << "\\end{center}\n" "\\end{figure}\n"; //printf("writeFigure rows=%d cols=%d\n",rows,cols); QCString epsBaseName=(QCString)path+"/"+fileName; QCString epsName=epsBaseName+".eps"; QFile f1; f1.setName(epsName.data()); if (!f1.open(IO_WriteOnly)) { err("Could not open file %s for writing\n",convertToQCString(f1.name()).data()); exit(1); } FTextStream t(&f1); //printf("writeEPS() rows=%d cols=%d\n",rows,cols); // generate EPS header and postscript variables and procedures t << "%!PS-Adobe-2.0 EPSF-2.0\n"; t << "%%Title: ClassName\n"; t << "%%Creator: Doxygen\n"; t << "%%CreationDate: Time\n"; t << "%%For: \n"; t << "%Magnification: 1.00\n"; t << "%%Orientation: Portrait\n"; t << "%%BoundingBox: 0 0 500 " << estHeight*500.0/(float)estWidth << "\n"; t << "%%Pages: 0\n"; t << "%%BeginSetup\n"; t << "%%EndSetup\n"; t << "%%EndComments\n"; t << "\n"; t << "% ----- variables -----\n"; t << "\n"; t << "/boxwidth 0 def\n"; t << "/boxheight 40 def\n"; t << "/fontheight 24 def\n"; t << "/marginwidth 10 def\n"; t << "/distx 20 def\n"; t << "/disty 40 def\n"; t << "/boundaspect " << estWidth/(float)estHeight << " def % aspect ratio of the BoundingBox (width/height)\n"; t << "/boundx 500 def\n"; t << "/boundy boundx boundaspect div def\n"; t << "/xspacing 0 def\n"; t << "/yspacing 0 def\n"; t << "/rows " << rows << " def\n"; t << "/cols " << cols << " def\n"; t << "/scalefactor 0 def\n"; t << "/boxfont /Times-Roman findfont fontheight scalefont def\n"; t << "\n"; t << "% ----- procedures -----\n"; t << "\n"; t << "/dotted { [1 4] 0 setdash } def\n"; t << "/dashed { [5] 0 setdash } def\n"; t << "/solid { [] 0 setdash } def\n"; t << "\n"; t << "/max % result = MAX(arg1,arg2)\n"; t << "{\n"; t << " /a exch def\n"; t << " /b exch def\n"; t << " a b gt {a} {b} ifelse\n"; t << "} def\n"; t << "\n"; t << "/xoffset % result = MAX(0,(scalefactor-(boxwidth*cols+distx*(cols-1)))/2)\n"; t << "{\n"; t << " 0 scalefactor boxwidth cols mul distx cols 1 sub mul add sub 2 div max\n"; t << "} def\n"; t << "\n"; t << "/cw % boxwidth = MAX(boxwidth, stringwidth(arg1))\n"; t << "{\n"; t << " /str exch def\n"; t << " /boxwidth boxwidth str stringwidth pop max def\n"; t << "} def\n"; t << "\n"; t << "/box % draws a box with text `arg1' at grid pos (arg2,arg3)\n"; t << "{ gsave\n"; t << " 2 setlinewidth\n"; t << " newpath\n"; t << " exch xspacing mul xoffset add\n"; t << " exch yspacing mul\n"; t << " moveto\n"; t << " boxwidth 0 rlineto \n"; t << " 0 boxheight rlineto \n"; t << " boxwidth neg 0 rlineto \n"; t << " 0 boxheight neg rlineto \n"; t << " closepath\n"; t << " dup stringwidth pop neg boxwidth add 2 div\n"; t << " boxheight fontheight 2 div sub 2 div\n"; t << " rmoveto show stroke\n"; t << " grestore\n"; t << "} def \n"; t << "\n"; t << "/mark\n"; t << "{ newpath\n"; t << " exch xspacing mul xoffset add boxwidth add\n"; t << " exch yspacing mul\n"; t << " moveto\n"; t << " 0 boxheight 4 div rlineto\n"; t << " boxheight neg 4 div boxheight neg 4 div rlineto\n"; t << " closepath\n"; t << " eofill\n"; t << " stroke\n"; t << "} def\n"; t << "\n"; t << "/arrow\n"; t << "{ newpath\n"; t << " moveto\n"; t << " 3 -8 rlineto\n"; t << " -6 0 rlineto\n"; t << " 3 8 rlineto\n"; t << " closepath\n"; t << " eofill\n"; t << " stroke\n"; t << "} def\n"; t << "\n"; t << "/out % draws an output connector for the block at (arg1,arg2)\n"; t << "{\n"; t << " newpath\n"; t << " exch xspacing mul xoffset add boxwidth 2 div add\n"; t << " exch yspacing mul boxheight add\n"; t << " /y exch def\n"; t << " /x exch def\n"; t << " x y moveto\n"; t << " 0 disty 2 div rlineto \n"; t << " stroke\n"; t << " 1 eq { x y disty 2 div add arrow } if\n"; t << "} def\n"; t << "\n"; t << "/in % draws an input connector for the block at (arg1,arg2)\n"; t << "{\n"; t << " newpath\n"; t << " exch xspacing mul xoffset add boxwidth 2 div add\n"; t << " exch yspacing mul disty 2 div sub\n"; t << " /y exch def\n"; t << " /x exch def\n"; t << " x y moveto\n"; t << " 0 disty 2 div rlineto\n"; t << " stroke\n"; t << " 1 eq { x y disty 2 div add arrow } if\n"; t << "} def\n"; t << "\n"; t << "/hedge\n"; t << "{\n"; t << " exch xspacing mul xoffset add boxwidth 2 div add\n"; t << " exch yspacing mul boxheight 2 div sub\n"; t << " /y exch def\n"; t << " /x exch def\n"; t << " newpath\n"; t << " x y moveto\n"; t << " boxwidth 2 div distx add 0 rlineto\n"; t << " stroke\n"; t << " 1 eq\n"; t << " { newpath x boxwidth 2 div distx add add y moveto\n"; t << " -8 3 rlineto\n"; t << " 0 -6 rlineto\n"; t << " 8 3 rlineto\n"; t << " closepath\n"; t << " eofill\n"; t << " stroke\n"; t << " } if\n"; t << "} def\n"; t << "\n"; t << "/vedge\n"; t << "{\n"; t << " /ye exch def\n"; t << " /ys exch def\n"; t << " /xs exch def\n"; t << " newpath\n"; t << " xs xspacing mul xoffset add boxwidth 2 div add dup\n"; t << " ys yspacing mul boxheight 2 div sub\n"; t << " moveto\n"; t << " ye yspacing mul boxheight 2 div sub\n"; t << " lineto\n"; t << " stroke\n"; t << "} def\n"; t << "\n"; t << "/conn % connections the blocks from col `arg1' to `arg2' of row `arg3'\n"; t << "{\n"; t << " /ys exch def\n"; t << " /xe exch def\n"; t << " /xs exch def\n"; t << " newpath\n"; t << " xs xspacing mul xoffset add boxwidth 2 div add\n"; t << " ys yspacing mul disty 2 div sub\n"; t << " moveto\n"; t << " xspacing xe xs sub mul 0\n"; t << " rlineto\n"; t << " stroke\n"; t << "} def\n"; t << "\n"; t << "% ----- main ------\n"; t << "\n"; t << "boxfont setfont\n"; t << "1 boundaspect scale\n"; bool done=FALSE; DiagramRow *dr=base->first(); while (dr && !done) { DiagramItem *di=dr->first(); while (di) { done=di->isInList(); t << "(" << di->label() << ") cw\n"; di=dr->next(); } dr=base->next(); } dr=super->first(); dr=super->next(); done=FALSE; while (dr && !done) { DiagramItem *di=dr->first(); while (di) { done=di->isInList(); t << "(" << di->label() << ") cw\n"; di=dr->next(); } dr=super->next(); } t << "/boxwidth boxwidth marginwidth 2 mul add def\n" << "/xspacing boxwidth distx add def\n" << "/yspacing boxheight disty add def\n" << "/scalefactor \n" << " boxwidth cols mul distx cols 1 sub mul add\n" << " boxheight rows mul disty rows 1 sub mul add boundaspect mul \n" << " max def\n" << "boundx scalefactor div boundy scalefactor div scale\n"; t << "\n% ----- classes -----\n\n"; base->drawBoxes(t,0,TRUE,FALSE,baseRows,superRows,0,0); super->drawBoxes(t,0,FALSE,FALSE,baseRows,superRows,0,0); t << "\n% ----- relations -----\n\n"; base->drawConnectors(t,0,TRUE,FALSE,baseRows,superRows,0,0); super->drawConnectors(t,0,FALSE,FALSE,baseRows,superRows,0,0); f1.close(); if (Config_getBool("USE_PDFLATEX")) { QCString epstopdfArgs(4096); epstopdfArgs.sprintf("\"%s.eps\" --outfile=\"%s.pdf\"", epsBaseName.data(),epsBaseName.data()); //printf("Converting eps using `%s'\n",epstopdfCmd.data()); portable_sysTimerStart(); if (portable_system("epstopdf",epstopdfArgs)!=0) { err("error: Problems running epstopdf. Check your TeX installation!\n"); portable_sysTimerStop(); return; } portable_sysTimerStop(); } }
/*! constructs command line of htags(1) and executes it. * \retval TRUE success * \retval FALSE an error has occurred. */ bool Htags::execute(const QCString &htmldir) { static QStrList &inputSource = Config_getList("INPUT"); static bool quiet = Config_getBool("QUIET"); static bool warnings = Config_getBool("WARNINGS"); static QCString htagsOptions = ""; //Config_getString("HTAGS_OPTIONS"); static QCString projectName = Config_getString("PROJECT_NAME"); static QCString projectNumber = Config_getString("PROJECT_NUMBER"); QCString cwd = QDir::currentDirPath().utf8(); if (inputSource.isEmpty()) { g_inputDir.setPath(cwd); } else if (inputSource.count()==1) { g_inputDir.setPath(inputSource.first()); if (!g_inputDir.exists()) err("Cannot find directory %s. " "Check the value of the INPUT tag in the configuration file.\n", inputSource.first() ); } else { err("If you use USE_HTAGS then INPUT should specific a single directory. \n"); return FALSE; } /* * Construct command line for htags(1). */ QCString commandLine = " -g -s -a -n "; if (!quiet) commandLine += "-v "; if (warnings) commandLine += "-w "; if (!htagsOptions.isEmpty()) { commandLine += ' '; commandLine += htagsOptions; } if (!projectName.isEmpty()) { commandLine += "-t \""; commandLine += projectName; if (!projectNumber.isEmpty()) { commandLine += '-'; commandLine += projectNumber; } commandLine += "\" "; } commandLine += " \"" + htmldir + "\""; QCString oldDir = QDir::currentDirPath().utf8(); QDir::setCurrent(g_inputDir.absPath()); //printf("CommandLine=[%s]\n",commandLine.data()); portable_sysTimerStart(); bool result=portable_system("htags",commandLine,FALSE)==0; portable_sysTimerStop(); QDir::setCurrent(oldDir); return result; }
void generatePlantUMLOutput(const char *baseName,const char *outDir,PlantUMLOutputFormat format) { static QCString plantumlJarPath = Config_getString("PLANTUML_JAR_PATH"); QCString pumlExe = "java"; QCString pumlArgs = ""; QStrList &pumlIncludePathList = Config_getList("PLANTUML_INCLUDE_PATH"); char *s=pumlIncludePathList.first(); if (s) { pumlArgs += "-Dplantuml.include.path=\""; pumlArgs += s; s = pumlIncludePathList.next(); } while (s) { pumlArgs += portable_pathListSeparator(); pumlArgs += s; s = pumlIncludePathList.next(); } if (pumlIncludePathList.first()) pumlArgs += "\" "; pumlArgs += "-Djava.awt.headless=true -jar \""+plantumlJarPath+"plantuml.jar\" "; pumlArgs+="-o \""; pumlArgs+=outDir; pumlArgs+="\" "; QCString extension; switch (format) { case PUML_BITMAP: pumlArgs+="-tpng"; extension=".png"; break; case PUML_EPS: pumlArgs+="-teps"; extension=".eps"; break; case PUML_SVG: pumlArgs+="-tsvg"; extension=".svg"; break; } pumlArgs+=" \""; pumlArgs+=baseName; pumlArgs+=".pu\" "; pumlArgs+="-charset " + Config_getString("INPUT_ENCODING") + " "; int exitCode; //printf("*** running: %s %s outDir:%s %s\n",pumlExe.data(),pumlArgs.data(),outDir,outFile); msg("Running PlantUML on generated file %s.pu\n",baseName); portable_sysTimerStart(); if ((exitCode=portable_system(pumlExe,pumlArgs,FALSE))!=0) { err("Problems running PlantUML. Verify that the command 'java -jar \"%splantuml.jar\" -h' works from the command line. Exit code: %d\n", plantumlJarPath.data(),exitCode); } else if (Config_getBool("DOT_CLEANUP")) { QFile(QCString(baseName)+".pu").remove(); } portable_sysTimerStop(); if ( (format==PUML_EPS) && (Config_getBool("USE_PDFLATEX")) ) { QCString epstopdfArgs(maxCmdLine); epstopdfArgs.sprintf("\"%s.eps\" --outfile=\"%s.pdf\"",baseName,baseName); portable_sysTimerStart(); if (exitCode=portable_system("epstopdf",epstopdfArgs)!=0) { err("Problems running epstopdf. Check your TeX installation! Exit code: %d\n",exitCode); } portable_sysTimerStop(); } }
void CiteDict::generatePage() const { //printf("** CiteDict::generatePage() count=%d\n",m_ordering.count()); // do not generate an empty citations page if (isEmpty()) return; // nothing to cite // 1. generate file with markers and citations to OUTPUT_DIRECTORY QFile f; QCString outputDir = Config_getString("OUTPUT_DIRECTORY"); QCString citeListFile = outputDir+"/citelist.doc"; f.setName(citeListFile); if (!f.open(IO_WriteOnly)) { err("could not open file %s for writing\n",citeListFile.data()); } FTextStream t(&f); t << "<!-- BEGIN CITATIONS -->" << endl; t << "<!--" << endl; QDictIterator<CiteInfo> it(m_entries); CiteInfo *ci; for (it.toFirst();(ci=it.current());++it) { t << "\\citation{" << ci->label << "}" << endl; } t << "-->" << endl; t << "<!-- END CITATIONS -->" << endl; t << "<!-- BEGIN BIBLIOGRAPHY -->" << endl; t << "<!-- END BIBLIOGRAPHY -->" << endl; f.close(); // 2. generate bib2xhtml QCString bib2xhtmlFile = outputDir+"/bib2xhtml.pl"; f.setName(bib2xhtmlFile); QCString bib2xhtml = bib2xhtml_pl; if (!f.open(IO_WriteOnly)) { err("could not open file %s for writing\n",bib2xhtmlFile.data()); } f.writeBlock(bib2xhtml, bib2xhtml.length()); f.close(); // 3. generate doxygen.bst QCString doxygenBstFile = outputDir+"/doxygen.bst"; QCString bstData = doxygen_bst; f.setName(doxygenBstFile); if (!f.open(IO_WriteOnly)) { err("could not open file %s for writing\n",doxygenBstFile.data()); } f.writeBlock(bstData, bstData.length()); f.close(); // 4. for html we just copy the bib files to the output so that // bibtex can find them without path (bibtex doesn't support path's // with spaces!) QList<QCString> tempFiles; tempFiles.setAutoDelete(TRUE); QDir thisDir; if (Config_getBool("GENERATE_HTML")) { // copy bib files to the latex output dir QStrList &citeDataList = Config_getList("CITE_BIB_FILES"); QCString bibOutputDir = outputDir+"/"; QFileInfo fo(bibOutputDir); const char *bibdata = citeDataList.first(); while (bibdata) { QCString bibFile = bibdata; if (!bibFile.isEmpty() && bibFile.right(4)!=".bib") bibFile+=".bib"; QFileInfo fi(bibFile); if (fi.exists() && fi.dirPath(TRUE)!=fo.absFilePath()) { if (!bibFile.isEmpty()) { QCString destFile=bibOutputDir+fi.fileName().data(); copyFile(bibFile,destFile); tempFiles.append(new QCString(destFile)); } } else if (!fi.exists()) { err("bib file %s not found!\n",bibFile.data()); } bibdata = citeDataList.next(); } } QCString oldDir = QDir::currentDirPath().utf8(); QDir::setCurrent(outputDir); // 5. run bib2xhtml perl script on the generated file which will insert the // bibliography in citelist.doc portable_system("perl","\""+bib2xhtmlFile+"\" "+getListOfBibFiles(" ",FALSE)+" \""+ citeListFile+"\""); QDir::setCurrent(oldDir); // 6. read back the file f.setName(citeListFile); if (!f.open(IO_ReadOnly)) { err("could not open file %s/citelist.doc for reading\n",outputDir.data()); } bool insideBib=FALSE; QCString doc; QFileInfo fi(citeListFile); QCString input(fi.size()+1); f.readBlock(input.data(),fi.size()); f.close(); input.at(fi.size())='\0'; int p=0,s; //printf("input=[%s]\n",input.data()); while ((s=input.find('\n',p))!=-1) { QCString line = input.mid(p,s-p); //printf("p=%d s=%d line=[%s]\n",p,s,line.data()); p=s+1; if (line.find("<!-- BEGIN BIBLIOGRAPHY")!=-1) insideBib=TRUE; else if (line.find("<!-- END BIBLIOGRAPH")!=-1) insideBib=FALSE; else if (insideBib) doc+=line+"\n"; int i; // determine text to use at the location of the @cite command if (insideBib && (i=line.find("<a name=\"CITEREF_"))!=-1) { int j=line.find("\">["); int k=line.find("]</a>"); if (j!=-1 && k!=-1) { QCString label = line.mid(i+17,j-i-17); QCString number = line.mid(j+2,k-j-1); CiteInfo *ci = m_entries.find(label); //printf("label='%s' number='%s' => %p\n",label.data(),number.data(),ci); if (ci) { ci->text = number; } } } } //printf("doc=[%s]\n",doc.data()); // 7. add it as a page addRelatedPage(CiteConsts::fileName, theTranslator->trCiteReferences(),doc,0,CiteConsts::fileName,1,0,0,0); // 8. for latex we just copy the bib files to the output and let // latex do this work. if (Config_getBool("GENERATE_LATEX")) { // copy bib files to the latex output dir QStrList &citeDataList = Config_getList("CITE_BIB_FILES"); QCString latexOutputDir = Config_getString("LATEX_OUTPUT")+"/"; const char *bibdata = citeDataList.first(); while (bibdata) { QCString bibFile = bibdata; if (!bibFile.isEmpty() && bibFile.right(4)!=".bib") bibFile+=".bib"; QFileInfo fi(bibFile); if (fi.exists()) { if (!bibFile.isEmpty()) { copyFile(bibFile,latexOutputDir+fi.fileName().data()); } } else { err("bib file %s not found!\n",bibFile.data()); } bibdata = citeDataList.next(); } } // 9. Remove temporary files thisDir.remove(citeListFile); thisDir.remove(doxygenBstFile); thisDir.remove(bib2xhtmlFile); while (!tempFiles.isEmpty()) { QCString *s=tempFiles.take(0); thisDir.remove(*s); } }
void writeMscGraphFromFile(const char *inFile,const char *outDir, const char *outFile,MscOutputFormat format) { QCString absOutFile = outDir; absOutFile+=portable_pathSeparator(); absOutFile+=outFile; // chdir to the output dir, so dot can find the font file. QCString oldDir = QDir::currentDirPath().utf8(); // go to the html output directory (i.e. path) QDir::setCurrent(outDir); //printf("Going to dir %s\n",QDir::currentDirPath().data()); QCString mscExe = Config_getString(MSCGEN_PATH)+"mscgen"+portable_commandExtension(); QCString mscArgs; QCString imgName = outFile; switch (format) { case MSC_BITMAP: mscArgs+="-T png"; imgName+=".png"; break; case MSC_EPS: mscArgs+="-T eps"; imgName+=".eps"; break; case MSC_SVG: mscArgs+="-T svg"; imgName+=".svg"; break; default: goto error; // I am not very fond of goto statements, but when in Rome... } mscArgs+=" -i \""; mscArgs+=inFile; mscArgs+="\" -o \""; mscArgs+=imgName+"\""; int exitCode; // printf("*** running: %s %s outDir:%s %s\n",mscExe.data(),mscArgs.data(),outDir,outFile); portable_sysTimerStart(); if ((exitCode=portable_system(mscExe,mscArgs,FALSE))!=0) { portable_sysTimerStop(); goto error; } portable_sysTimerStop(); if ( (format==MSC_EPS) && (Config_getBool(USE_PDFLATEX)) ) { QCString epstopdfArgs(maxCmdLine); epstopdfArgs.sprintf("\"%s.eps\" --outfile=\"%s.pdf\"", outFile,outFile); portable_sysTimerStart(); if (portable_system("epstopdf",epstopdfArgs)!=0) { err("Problems running epstopdf. Check your TeX installation!\n"); } portable_sysTimerStop(); } Doxygen::indexList->addImageFile(imgName); error: QDir::setCurrent(oldDir); }