35 if(filename == NULL)
return -1;
39 if(cptr != NULL) *cptr =
'\0';
40 fout = fopen(filename,
"w");
41 if(
fout == NULL)
return -1;
47 if(
fout == NULL)
return -1;
62 if(ret < 0)
return ret;
63 fprintf(
fout,
"%s",line);
69 return printf(
"\\begin{document}\n");
74 return printf(
"\\end{document}\n");
81 char *cptr, *start, *section, *name;
83 if(
fout == NULL)
return -1;
84 if(filename == NULL)
return -1;
87 fin = fopen(filename,
"r");
90 printf (
"rlReport::include() ERROR: Could not find %s\n",filename);
91 ::printf(
"rlReport::include() ERROR: Could not find %s\n",filename);
94 while(fgets(line,
sizeof(line)-1,fin) != NULL)
96 fprintf(
fout,
"%s",line);
103 fin = fopen(filename,
"r");
106 printf (
"rlReport::include() ERROR: Could not find %s\n",filename);
107 ::printf(
"rlReport::include() ERROR: Could not find %s\n",filename);
110 while(fgets(line,
sizeof(line)-1,fin) != NULL)
113 while(*start !=
'\0')
115 cptr = strstr(start,
"\\$[");
118 fprintf(
fout,
"%s",start);
124 fprintf(
fout,
"%s", start);
127 cptr = strchr(cptr,
']');
130 ::printf(
"rlReport::include ERROR in line=%s", line);
138 cptr = strchr(cptr,
']');
141 ::printf(
"rlReport::include ERROR in line=%s", line);
148 fprintf(
fout,
"%s", ini->
text(section,name));
159 if(
fout == NULL)
return -1;
160 if(documentclass == NULL) documentclass =
"\\documentclass[a4paper]{article}";
161 if(language == NULL) language =
"\\usepackage[english]{babel}";
162 if(inputenc == NULL) inputenc =
"\\usepackage[utf8]{inputenc}";
163 if(layout == NULL) layout =
"\\setlength{\\parindent}{0pt} \\setlength{\\topmargin}{-50pt} \\setlength{\\oddsidemargin}{0pt} \\setlength{\\textwidth}{480pt} \\setlength{\\textheight}{700pt}";
165 fprintf(
fout,
"%s",
"% --- header begin ------------------------------------------------------------------------------------------------\n");
166 fprintf(
fout,
" %s\n", documentclass);
167 fprintf(
fout,
" %s\n", inputenc);
168 fprintf(
fout,
"%s",
" \\usepackage[pdftex]{hyperref}\n");
169 fprintf(
fout,
"%s",
" \\pdfcatalog{/UseThumbs /UseOutlines}\n");
170 fprintf(
fout,
"%s",
" \\usepackage{amssymb}\n");
171 fprintf(
fout,
"%s",
" \\newcommand{\\arrow}{\\begin{math}->\\end{math}} % define arrow symbol\n");
172 fprintf(
fout,
"%s",
" \\newcommand{\\asterix}{\\begin{math}*\\end{math}} % define asterix symbol\n");
173 fprintf(
fout,
" %s\n", language);
174 fprintf(
fout,
"%s",
" \\usepackage{textcomp} % define euro\n");
175 fprintf(
fout,
"%s",
" \\usepackage{longtable} % use tables over several pages\n");
176 fprintf(
fout,
"%s",
" \\usepackage{colortbl}\n");
177 fprintf(
fout,
"%s",
"\n");
178 fprintf(
fout,
"%s",
" % % --- documentation support for sourcecode -------------\n");
179 fprintf(
fout,
"%s",
" \\usepackage{listings}\n");
180 fprintf(
fout,
"%s",
" \\usepackage{color}\n");
181 fprintf(
fout,
"%s",
" \\definecolor{white}{rgb}{1.0,1.0,1.0}\n");
182 fprintf(
fout,
"%s",
" \\definecolor{gray}{rgb}{0.5,0.5,0.5}\n");
183 fprintf(
fout,
"%s",
" \\definecolor{darkred}{rgb}{0.5,0.0,0.0}\n");
184 fprintf(
fout,
"%s",
" \\definecolor{lightgray}{rgb}{0.95,0.95,0.95}\n");
185 fprintf(
fout,
"%s",
" \\definecolor{mygray}{gray}{0.55}\n");
186 fprintf(
fout,
"%s",
" \\newcommand{\\simplecodestyle}{\\lstset{basicstyle=\\ttfamily\\small\\mdseries,backgroundcolor=\\color{lightgray},breaklines=true}}\n");
187 fprintf(
fout,
"%s",
" \\newcommand{\\codestyle}{\\lstset{basicstyle=\\ttfamily\\small\\mdseries,keywordstyle=\\bfseries\\color{blue},commentstyle=\\color{gray},stringstyle=\\color{darkred},backgroundcolor=\\color{lightgray},breaklines=true}}\n");
188 fprintf(
fout,
"%s",
" \\newcommand{\\simplecodebegin}[1]{\\simplecodestyle\\begin{lstlisting}[frame=single,flexiblecolumns=true,tabsize={8},inputencoding={utf8},title={#1}]}\n");
189 fprintf(
fout,
"%s",
" \\newcommand{\\bashbegin}[1]{\\codestyle\\begin{lstlisting}[language=bash,frame=single,flexiblecolumns=true,tabsize={8},inputencoding={utf8},title={#1}]}\n");
190 fprintf(
fout,
"%s",
" \\newcommand{\\bashsimple}[0]{\\codestyle\\begin{lstlisting}[language=bash,frame=single,flexiblecolumns=true,tabsize={8},inputencoding={utf8}]}\n");
191 fprintf(
fout,
"%s",
" \\newcommand{\\cppbegin}[1]{\\codestyle\\begin{lstlisting}[language=C++,frame=single,flexiblecolumns=true,tabsize={8},inputencoding={utf8},title={#1}]}\n");
192 fprintf(
fout,
"%s",
" \\newcommand{\\cppsimple}[0]{\\codestyle\\begin{lstlisting}[language=C++,frame=single,flexiblecolumns=true],tabsize={8},inputencoding={utf8}}\n");
193 fprintf(
fout,
"%s",
" \\newcommand{\\cppend}{\\end{lstlisting}}\n");
194 fprintf(
fout,
"%s",
" \\newcommand{\\pybegin}[1]{\\codestyle\\begin{lstlisting}[language=Python,frame=single,flexiblecolumns=true,tabsize={8},inputencoding={utf8},title={#1}]}\n");
195 fprintf(
fout,
"%s",
" \\newcommand{\\xmlbegin}[1]{\\codestyle\\begin{lstlisting}[language=XML,frame=single,flexiblecolumns=true,tabsize={8},inputencoding={utf8},title={#1}]}\n");
196 fprintf(
fout,
"%s",
" \\newcommand{\\tclbegin}[1]{\\codestyle\\begin{lstlisting}[language=tcl,frame=single,flexiblecolumns=true,tabsize={8},inputencoding={utf8},title={#1}]}\n");
197 fprintf(
fout,
"%s",
" \\lstdefinelanguage{mylua}\n");
198 fprintf(
fout,
"%s",
" {keywords={while,for,elseif,if,else,then,do,end,return,function,and,or,not,nil,true,false},\n");
199 fprintf(
fout,
"%s",
" sensitive=true,\n");
200 fprintf(
fout,
"%s",
" morecomment=[l][\\color{mygray}]{--},\n");
201 fprintf(
fout,
"%s",
" string=[b],\n");
202 fprintf(
fout,
"%s",
" }\n");
203 fprintf(
fout,
"%s",
" \\newcommand{\\luabegin}[1]{\\codestyle\\begin{lstlisting}[language=mylua,frame=single,flexiblecolumns=true,tabsize={8},inputencoding={utf8},title={#1}]}\n");
204 fprintf(
fout,
"%s",
" % % --- usage example begin -----------------------------\n");
205 fprintf(
fout,
"%s",
" % \\cppbegin{Titel of our C++ code snippet}\n");
206 fprintf(
fout,
"%s",
" % printf(\"hello world\\n\");\n");
207 fprintf(
fout,
"%s",
" % \\end{lstlisting}\n");
208 fprintf(
fout,
"%s",
" % % --- usage example end -------------------------------\n");
209 fprintf(
fout,
"%s",
"\n");
210 fprintf(
fout,
"%s",
"\n");
211 fprintf(
fout,
"%s",
" % % --- graphics support --------------------------------\n");
212 fprintf(
fout,
"%s",
" \\usepackage{graphicx}\n");
213 fprintf(
fout,
"%s",
" \\usepackage{float}\n");
214 fprintf(
fout,
"%s",
" \\newcommand{\\img}[3]{\n");
215 fprintf(
fout,
"%s",
" \\setlength\\fboxsep{0pt}\n");
216 fprintf(
fout,
"%s",
" \\setlength\\fboxrule{1pt}\n");
217 fprintf(
fout,
"%s",
" \\begin{figure}\n");
218 fprintf(
fout,
"%s",
" \\begin{center}\n");
219 fprintf(
fout,
"%s",
" \\fbox{\\includegraphics[scale=#1]{#2}}\n");
220 fprintf(
fout,
"%s",
" \\caption{#3}\n");
221 fprintf(
fout,
"%s",
" \\end{center}\n");
222 fprintf(
fout,
"%s",
" \\end{figure}\n");
223 fprintf(
fout,
"%s",
" }\n");
224 fprintf(
fout,
"%s",
" \\newcommand{\\imgH}[3]{\n");
225 fprintf(
fout,
"%s",
" \\setlength\\fboxsep{0pt}\n");
226 fprintf(
fout,
"%s",
" \\setlength\\fboxrule{1pt}\n");
227 fprintf(
fout,
"%s",
" \\begin{figure}[H]\n");
228 fprintf(
fout,
"%s",
" \\begin{center}\n");
229 fprintf(
fout,
"%s",
" \\fbox{\\includegraphics[scale=#1]{#2}}\n");
230 fprintf(
fout,
"%s",
" \\caption{#3}\n");
231 fprintf(
fout,
"%s",
" \\end{center}\n");
232 fprintf(
fout,
"%s",
" \\end{figure}\n");
233 fprintf(
fout,
"%s",
" }\n");
234 fprintf(
fout,
"%s",
"\n");
235 fprintf(
fout,
"%s",
" % % --- definition of the paper layout ------------------- \n");
236 fprintf(
fout,
" %s\n", layout);
237 fprintf(
fout,
"%s",
"% --- header end --------------------------------------------------------------------------------------------------\n");
245 if(
fout == NULL)
return -1;
246 if(filename == NULL)
return -1;
247 if(t.
read(filename) < 0)
249 printf (
"rlReport::includeCSV() ERROR: Could not find %s\n",filename);
250 ::printf(
"rlReport::includeCSV() ERROR: Could not find %s\n",filename);
255 while(t.
exists(x,1) && xmax < 1024) xmax = x++;
257 while(t.
exists(1,y) && ymax < 256*256) ymax = y++;
259 printf(
"\\begin{center}\n");
260 printf(
"\\begin{longtable}");
264 while(x <= xmax) {
printf(
" | l"); x++; }
267 for(y=1; y<=ymax; y++)
269 if(y==1 && use_first_row_as_title)
printf(
" \\rowcolor{gray}\n");;
271 for(x=1; x<=xmax; x++)
274 if(x < xmax)
printf(
"& ");
277 if(y < ymax)
printf(
" \\hline\n");
280 if(legend != NULL)
printf(
" \\caption{%s}\n", legend);
282 printf(
"\\end{longtable}\n");
283 printf(
"\\end{center}\n");
289 if(
fout == NULL)
return -1;
290 if(filename == NULL)
return -1;
291 if(legend == NULL) legend =
"";
292 printf(
"\\img{%.1f}{%s}{%s}\n", scale, filename, legend);
300 if(
fout == NULL)
return -1;
301 if(command == NULL)
return -1;
302 sprintf(cmd,
"%s > %s.temp", command,
file.
text());
304 sprintf(cmd,
"%s.temp",
file.
text());
313 sprintf(cmd,
"pdflatex -interaction=nonstopmode %s.tex",
file.
text());
319 sprintf(cmd,
"%s %s.tex", command,
file.
text());
const char * text(int column, int row)
const char * text(const char *section, const char *name)
int read(const char *filename)
int printf(const char *format,...)
int includeHeader(const char *documentclass="\ocumentclass[a4paper]{article}", const char *language="\sepackage[english]{babel}", const char *inputenc="\sepackage[utf8]{inputenc}", const char *layout="\etlength{\arindent}{0pt} \etlength{\opmargin}{-50pt} \etlength{\ddsidemargin}{0pt} \etlength{\extwidth}{480pt} \etlength{\extheight}{700pt}")
int spawn(const char *command)
int open(const char *filename)
int rlvsnprintf(char *text, int len, const char *format, va_list ap)
int includeImage(const char *filename, const char *legend=NULL, float scale=1.0f)
int include(const char *filename, rlIniFile *ini=NULL)
int pdflatex(const char *command=NULL)
int includeCSV(const char *filename, int use_first_row_as_title=1, const char *legend=NULL, char delimitor='\t')
int exists(int column, int row)