1 |
/* $Id: main.c,v 1.1 1997/03/22 20:02:35 cnh Exp cnh $ */ |
2 |
|
3 |
/* |
4 |
Driver routine for generating hypertext instrumented code |
5 |
from a tree of Fortran source. Hypertext instrumentation allows |
6 |
symbols (subroutine names, variable names etc... ) |
7 |
to be selected in a browser. When a symbol is selected |
8 |
a table showing the definition of that symbol and all |
9 |
its occurences within the full code tree appears. |
10 |
For each occurence synopsis information, for example |
11 |
the line number the file name and the source text of the |
12 |
line referred to is shown. |
13 |
This table is also hypertext. By selecting entries in the |
14 |
table, for example the line number or the file name or |
15 |
a variable in the source text line that is reproduced |
16 |
other elements of the hypertext can be brought up. |
17 |
A mechanism for displaying attributes related to symbols |
18 |
is also includeed. Attributes describe what class or |
19 |
classes a symbol belongs to, for example is the symbol |
20 |
a function name, an input parameter, a compile time |
21 |
operator etc... Summary tables are also generated |
22 |
for viewing the output by attribute. |
23 |
A mechanism for linking to an external document, such |
24 |
as a text manual, is also included. |
25 |
*/ |
26 |
|
27 |
#include <stdio.h> |
28 |
#include <string.h> |
29 |
#include <ctype.h> |
30 |
|
31 |
#include "DD.h" |
32 |
#include "FD.h" |
33 |
#include "GLOBALS.h" |
34 |
|
35 |
/* Variable Dictionary Parser */ |
36 |
FILE *VarDicin; |
37 |
int VarDicParseError = 0; |
38 |
int VarDicdebug; |
39 |
char *vDictTitleWord = NULL; |
40 |
static char vDictDefaultTitleWord[] = "DICTIONARY"; |
41 |
|
42 |
/* F90 Symbol Parser */ |
43 |
FILE *F90symin; |
44 |
int nSrcFile=0; /* Counter for source file number */ |
45 |
int F90symdebug; |
46 |
|
47 |
/* Command Line Arguments */ |
48 |
struct{ |
49 |
char *dictFile; /* Variable dictionary file */ |
50 |
char *outDir; /* Output directory */ |
51 |
int nSFiles; /* No. files in source list */ |
52 |
char **srcFiles; /* Files containing source */ |
53 |
} argList; |
54 |
|
55 |
main (argc, argv) |
56 |
int argc; |
57 |
char *argv[]; |
58 |
{ |
59 |
char vdictName[MAXPATHNAM]; |
60 |
char procdictName[MAXPATHNAM]; |
61 |
char parmdictName[MAXPATHNAM]; |
62 |
char compdictName[MAXPATHNAM]; |
63 |
FILE *htout; |
64 |
|
65 |
/* Process inout args */ |
66 |
if ( GetArgs(argc, argv) == 0 ) { |
67 |
fprintf(stderr, |
68 |
"Usage: %s [-d Dictionary] [-o OutputDirectory] file(s)\n",argv[0]); |
69 |
exit(0); |
70 |
} |
71 |
|
72 |
/* Create output directory */ |
73 |
if ( argList.outDir == NULL ) { |
74 |
argList.outDir = OUTDIR; |
75 |
} |
76 |
if ( makeOutputDirectories(argList.outDir) != 0 ) { |
77 |
fprintf(stderr,"Unables to create output directory structure\n"); |
78 |
fprintf(stderr,"%s\n",argList.outDir); |
79 |
fprintf(stderr,"%s/%s\n",argList.outDir,SRCSUF); |
80 |
fprintf(stderr,"%s/%s\n",argList.outDir,VARSUF); |
81 |
exit(0); |
82 |
} |
83 |
|
84 |
/* Scan input name definition table */ |
85 |
VarDicdebug=0; |
86 |
ParseVarDic(); |
87 |
if ( VarDicParseError != 0 ) |
88 |
{ |
89 |
if ( argList.dictFile != NULL ) { |
90 |
fprintf(stderr,"Error(s) occured reading dictionary \"%s\".", |
91 |
argList.dictFile); |
92 |
} |
93 |
fprintf(stderr," Program ending.\n"); |
94 |
exit(); |
95 |
} |
96 |
|
97 |
/* Scan code to get all variable names */ |
98 |
/* Set initial state of F77/F90 analyser */ |
99 |
F90symdebug=0; |
100 |
inNameList=0; |
101 |
inIfdef=0; |
102 |
clearNameIsProcName(); |
103 |
/* Run the analysis */ |
104 |
ParseF90Code(); |
105 |
|
106 |
/* Sort the table of variable uses */ |
107 |
tblSort(); |
108 |
|
109 |
/* Print out the data dictionary */ |
110 |
ddPrint(); |
111 |
|
112 |
/* Generate individual variable description tables */ |
113 |
GenerateVarTables(); |
114 |
|
115 |
/* Generate large single table */ |
116 |
ddSort(); |
117 |
|
118 |
sprintf(vdictName,"%s/%s",rootDir,VDICT); |
119 |
vdictfd = fopen(vdictName,"w"); |
120 |
|
121 |
sprintf(procdictName,"%s/%s%s",rootDir,PROCDICT,HTMLSUF); |
122 |
procdictfd = fopen(procdictName,"w"); |
123 |
|
124 |
sprintf(parmdictName,"%s/%s%s",rootDir,PARMDICT,HTMLSUF); |
125 |
parmdictfd = fopen(parmdictName,"w"); |
126 |
|
127 |
sprintf(compdictName,"%s/%s%s",rootDir,COMPDICT,HTMLSUF); |
128 |
compdictfd = fopen(compdictName,"w"); |
129 |
|
130 |
|
131 |
/* Table of all symbols */ |
132 |
GenerateVDict(); |
133 |
/* Table of just procedure names */ |
134 |
ddSetCurrent(0); |
135 |
GenerateProcDict(); |
136 |
/* Table of just compile time switching symbols */ |
137 |
ddSetCurrent(0); |
138 |
GeneratePrecompDict(); |
139 |
/* Table of just runtime parameters */ |
140 |
ddSetCurrent(0); |
141 |
GenerateParamDict(); |
142 |
|
143 |
/* Generate index of variables */ |
144 |
ddSetCurrent(0); |
145 |
GenerateVDictIndex(); |
146 |
|
147 |
ddSetCurrent(0); |
148 |
/* Generate tables of source files and directories */ |
149 |
fdTab(); |
150 |
|
151 |
/* Generate the HTML menus */ |
152 |
/* Top level menu */ |
153 |
mainMenu(); |
154 |
/* Submenu for browsing all symbol list */ |
155 |
ddSetCurrent(0); |
156 |
allSymbolsMenu(); |
157 |
/* Submenu for browsing functions and procedures list */ |
158 |
ddSetCurrent(0); |
159 |
allSubfuncMenu(); |
160 |
/* Submenu for browsing runtime parameters list */ |
161 |
ddSetCurrent(0); |
162 |
allRTParmMenu(); |
163 |
/* Submenu for browsing compile time switches list */ |
164 |
ddSetCurrent(0); |
165 |
allCTParmMenu(); |
166 |
/* Submenu for browsing source by directory and file name */ |
167 |
allDFMenu(); |
168 |
|
169 |
} |
170 |
|
171 |
mainMenu() { |
172 |
FILE *htout; |
173 |
/* Try a bit of extra HTML */ |
174 |
/* Main Menu */ |
175 |
htout=fopen("code_reference.htm","w"); |
176 |
html_start(htout); html_ul(htout); |
177 |
|
178 |
html_entryli(htout,"Overview","callTree.html target=mainBodyFrame","h3"); |
179 |
html_entryli(htout,"Subroutines and Functions","code_reference-subfunc_exp.htm","h3"); |
180 |
html_entryli(htout,"Runtime Parameters","code_reference-rtparm_exp.htm","h3"); |
181 |
html_entryli(htout,"Compile Time Parameters","code_reference-ctparm_exp.htm","h3"); |
182 |
html_entryli(htout,"Source Files","code_reference-sf_exp.htm","h3"); |
183 |
html_entryli(htout,"All Symbols","code_reference-vi_exp.htm","h3"); |
184 |
|
185 |
html_eul(htout); html_end(htout); |
186 |
fprintf(htout,"\n"); |
187 |
fclose(htout); |
188 |
|
189 |
} |
190 |
|
191 |
allSymbolsMenu() { |
192 |
FILE *htout; |
193 |
ddRecord *curRec; |
194 |
char curLetter = ' '; |
195 |
char clstr[2]; |
196 |
char subURL[MAXPATHNAM]; |
197 |
|
198 |
/* VI Sub-Menu */ |
199 |
htout=fopen("code_reference-vi_exp.htm","w"); |
200 |
html_start(htout); |
201 |
fprintf(htout,"\n"); |
202 |
html_ul(htout); |
203 |
fprintf(htout,"<H3>%s</H3>","Variable Index"); |
204 |
|
205 |
html_ul(htout); |
206 |
html_entryli(htout,"All (compact form)","vdb/index.htm target=codeBrowserWindow","h4"); |
207 |
html_entryli(htout,"All (detailed form)","vdb/vdict.htm target=codeBrowserWindow","h4"); |
208 |
html_li(htout); |
209 |
while ( ddGetCurrent(&curRec) != 0 ){ |
210 |
if ( toupper(curRec->name[0]) != curLetter ){ |
211 |
curLetter = toupper(curRec->name[0]); |
212 |
sprintf(subURL,"%s/%s_pref%c%s target=codeBrowserWindow", |
213 |
rootDir,"vdict",curLetter,HTMLSUF); |
214 |
clstr[0]=curLetter;clstr[1]='\0'; |
215 |
html_entry(htout,clstr,subURL,"h4"); fprintf(htout,", "); |
216 |
} |
217 |
} |
218 |
html_eli(htout); |
219 |
html_eul(htout); |
220 |
|
221 |
html_eul(htout); |
222 |
html_end(htout); |
223 |
fprintf(htout,"\n"); |
224 |
fclose(htout); |
225 |
} |
226 |
|
227 |
allSubfuncMenu() { |
228 |
FILE *htout; |
229 |
ddRecord *curRec; |
230 |
char curLetter = ' '; |
231 |
char clstr[2]; |
232 |
char subURL[MAXPATHNAM]; |
233 |
|
234 |
/* VI Sub-Menu */ |
235 |
htout=fopen("code_reference-subfunc_exp.htm","w"); |
236 |
html_start(htout); |
237 |
fprintf(htout,"\n"); |
238 |
|
239 |
fprintf(htout,"<H3>%s</H3","Subroutines and Functions"); |
240 |
html_ul(htout); |
241 |
sprintf(subURL,"%s/%s%s target=codeBrowserWindow", |
242 |
rootDir,PROCDICT,HTMLSUF); |
243 |
html_entryli(htout,"All",subURL,"h4"); |
244 |
html_li(htout); |
245 |
while ( ddGetCurrent(&curRec) != 0 ){ |
246 |
if ( curRec->isProcName == 1 ) { |
247 |
if ( toupper(curRec->name[0]) != curLetter ){ |
248 |
curLetter = toupper(curRec->name[0]); |
249 |
sprintf(subURL,"%s/%s_pref%c%s target=codeBrowserWindow", |
250 |
rootDir,PROCDICT,curLetter,HTMLSUF); |
251 |
clstr[0]=curLetter;clstr[1]='\0'; |
252 |
html_entry(htout,clstr,subURL,"h4"); fprintf(htout,", "); |
253 |
} |
254 |
} |
255 |
} |
256 |
html_eli(htout); |
257 |
html_eul(htout); |
258 |
|
259 |
html_end(htout); |
260 |
fprintf(htout,"\n"); |
261 |
fclose(htout); |
262 |
} |
263 |
|
264 |
allRTParmMenu() { |
265 |
FILE *htout; |
266 |
ddRecord *curRec; |
267 |
char curLetter = ' '; |
268 |
char clstr[2]; |
269 |
char subURL[MAXPATHNAM]; |
270 |
|
271 |
/* RTparm Sub-Menu */ |
272 |
htout=fopen("code_reference-rtparm_exp.htm","w"); |
273 |
html_start(htout); |
274 |
html_start(htout); |
275 |
|
276 |
fprintf(htout,"<H3>%s</H3>","Runtime Parameters"); |
277 |
html_ul(htout); |
278 |
sprintf(subURL,"%s/%s%s target=codeBrowserWindow", |
279 |
rootDir,PARMDICT,HTMLSUF); |
280 |
html_entryli(htout,"All",subURL,"h4"); |
281 |
html_li(htout); |
282 |
while ( ddGetCurrent(&curRec) != 0 ){ |
283 |
if ( curRec->isInNameList == 1 ) { |
284 |
if ( toupper(curRec->name[0]) != curLetter ){ |
285 |
curLetter = toupper(curRec->name[0]); |
286 |
sprintf(subURL,"%s/%s_pref%c%s target=codeBrowserWindow", |
287 |
rootDir,PARMDICT,curLetter,HTMLSUF); |
288 |
clstr[0]=curLetter;clstr[1]='\0'; |
289 |
html_entry(htout,clstr,subURL,"h4"); fprintf(htout,", "); |
290 |
} |
291 |
} |
292 |
} |
293 |
html_eli(htout); |
294 |
html_eul(htout); |
295 |
|
296 |
html_end(htout); |
297 |
fprintf(htout,"\n"); |
298 |
fclose(htout); |
299 |
} |
300 |
|
301 |
allCTParmMenu() { |
302 |
FILE *htout; |
303 |
ddRecord *curRec; |
304 |
char curLetter = ' '; |
305 |
char clstr[2]; |
306 |
char subURL[MAXPATHNAM]; |
307 |
|
308 |
/* CTparm Sub-Menu */ |
309 |
htout=fopen("code_reference-ctparm_exp.htm","w"); |
310 |
html_start(htout); html_ul(htout); |
311 |
fprintf(htout,"\n"); |
312 |
|
313 |
html_entryli(htout,"Overview","callTree.html target=mainBodyFrame","h3"); |
314 |
html_entryli(htout,"Subroutines and Functions","code_reference-subfunc_exp.htm","h3"); |
315 |
html_entryli(htout,"Runtime Parameters","code_reference-rtparm_exp.htm","h3"); |
316 |
html_entryli(htout,"Compile Time Parameters","code_reference.htm","h3"); |
317 |
html_ul(htout); |
318 |
sprintf(subURL,"%s/%s%s target=mainBodyFrame", |
319 |
rootDir,COMPDICT,HTMLSUF); |
320 |
html_entryli(htout,"All",subURL,"h4"); |
321 |
html_li(htout); |
322 |
while ( ddGetCurrent(&curRec) != 0 ){ |
323 |
if ( curRec->isInIfdef == 1 ) { |
324 |
if ( toupper(curRec->name[0]) != curLetter ){ |
325 |
curLetter = toupper(curRec->name[0]); |
326 |
sprintf(subURL,"%s/%s_pref%c%s target=mainBodyFrame", |
327 |
rootDir,COMPDICT,curLetter,HTMLSUF); |
328 |
clstr[0]=curLetter;clstr[1]='\0'; |
329 |
html_entry(htout,clstr,subURL,"h4"); fprintf(htout,", "); |
330 |
} |
331 |
} |
332 |
} |
333 |
html_eli(htout); |
334 |
html_eul(htout); |
335 |
html_entryli(htout,"Source Files","code_reference-sf_exp.htm","h3"); |
336 |
html_entryli(htout,"All Symbols","code_reference-vi_exp.htm","h3"); |
337 |
|
338 |
html_eul(htout); html_end(htout); |
339 |
fprintf(htout,"\n"); |
340 |
fclose(htout); |
341 |
} |
342 |
|
343 |
allDFMenu() { |
344 |
FILE *htout; |
345 |
ddRecord *curRec; |
346 |
char curLetter = ' '; |
347 |
char clstr[2]; |
348 |
char subURL[MAXPATHNAM]; |
349 |
|
350 |
/* CTparm Sub-Menu */ |
351 |
htout=fopen("code_reference-sf_exp.htm","w"); |
352 |
html_start(htout); |
353 |
fprintf(htout,"\n"); |
354 |
fprintf(htout,"<H3>%s</H3>","Source Tree"); |
355 |
|
356 |
html_ul(htout); |
357 |
sprintf(subURL,"%s/%s%s target=codeBrowserWindow", |
358 |
rootDir,SFDICT,HTMLSUF); |
359 |
html_entryli(htout,"All",subURL,"h4"); |
360 |
fdFlistAlpha(htout); |
361 |
fdDirList(htout); |
362 |
html_eli(htout); |
363 |
html_eul(htout); |
364 |
|
365 |
html_end(htout); |
366 |
fprintf(htout,"\n"); |
367 |
fclose(htout); |
368 |
} |
369 |
|
370 |
int GetArgs( argc, argv) |
371 |
/* Process inout args */ |
372 |
int argc; char *argv[]; |
373 |
{ |
374 |
char *curArg; int i; char curOp; int rc; |
375 |
|
376 |
rc =1; |
377 |
|
378 |
for ( i = 1; i<argc; ++i){ |
379 |
curArg = argv[i]; |
380 |
if ( curArg[0] == '-' ) { |
381 |
curOp = argv[i][1]; |
382 |
} else { |
383 |
switch (curOp) { |
384 |
case 'd': |
385 |
argList.dictFile = argv[i]; |
386 |
curOp='\0'; |
387 |
break; |
388 |
case 'o': |
389 |
curOp='\0'; |
390 |
argList.outDir = argv[i]; |
391 |
break; |
392 |
case '\0': |
393 |
if ( argList.srcFiles == NULL ){ |
394 |
argList.srcFiles = (char **)malloc( sizeof(*(argList.srcFiles)) ); |
395 |
} else { |
396 |
argList.srcFiles = (char **) |
397 |
realloc(argList.srcFiles, |
398 |
(argList.nSFiles+1)*sizeof(*(argList.srcFiles)) ); |
399 |
} |
400 |
argList.nSFiles = argList.nSFiles+1; |
401 |
if ( argList.srcFiles != NULL ) { |
402 |
*(argList.srcFiles+(argList.nSFiles-1)) = argv[i]; |
403 |
} |
404 |
break; |
405 |
default: |
406 |
fprintf(stderr,"Unknown option \"%c\"\n",curOp); |
407 |
curOp='\0'; |
408 |
rc = 0; |
409 |
break; |
410 |
} |
411 |
} |
412 |
} |
413 |
return(rc); |
414 |
} |
415 |
|
416 |
VarDicerror(s) |
417 |
char *s; |
418 |
{ |
419 |
fprintf(stderr,"Error: unrecognised input. <%s> Line %d Column %d\n", |
420 |
currentFile,Lno,Cno); |
421 |
VarDicParseError=1; |
422 |
} |
423 |
|
424 |
ParseVarDic() |
425 |
{ |
426 |
int i; FILE *file; |
427 |
/* Parser variable initialisation */ |
428 |
curName = NULL; |
429 |
curHref = NULL; |
430 |
curText = NULL; |
431 |
curUnits = NULL; |
432 |
curFootNotes = NULL; |
433 |
|
434 |
if ( argList.dictFile != NULL ){ |
435 |
file = fopen(argList.dictFile,"r"); |
436 |
if (!file){ |
437 |
fprintf(stderr,"Unable to open file \"%s\"\n",argList.dictFile); |
438 |
} |
439 |
else |
440 |
{VarDicin = file; currentFile=argList.dictFile; |
441 |
Lno=1; Cno=1; |
442 |
VarDicparse(); |
443 |
fclose(file); |
444 |
} |
445 |
} |
446 |
} |
447 |
|
448 |
GenerateParamDict() |
449 |
/* |
450 |
Generate tables of runtime parameters |
451 |
*/ |
452 |
{ |
453 |
ddRecord *curRec; |
454 |
char *note; |
455 |
char curLetter = ' '; |
456 |
FILE *vdictfd_sub = NULL; |
457 |
char vdictSubName[MAXPATHNAM]; |
458 |
char vDictSubHeader[1024]; |
459 |
static char vDictHeader[] = "Alphabetic table of All Runtime Parameters"; |
460 |
|
461 |
fprintf(stderr,"Hi there \n"); |
462 |
/* HTML headers */ |
463 |
vDictTitleWord=vDictHeader; |
464 |
vDictStart(parmdictfd); |
465 |
vDictTitleWord=NULL; |
466 |
|
467 |
/* Table Entry */ |
468 |
while ( ddGetCurrent(&curRec) != 0 ){ |
469 |
if ( curRec->isInNameList == 1 ) { |
470 |
if ( toupper(curRec->name[0]) != curLetter ){ |
471 |
curLetter = toupper(curRec->name[0]); |
472 |
html_indexRecord(parmdictfd,curLetter); |
473 |
html_columnHeading(parmdictfd); |
474 |
|
475 |
/* Do sub listing for this letter and/or symbol */ |
476 |
if ( vdictfd_sub != NULL ) { vDictClose(vdictfd_sub); } |
477 |
sprintf(vdictSubName,"%s/%s_pref%c%s",rootDir,PARMDICT,curLetter,HTMLSUF); |
478 |
vdictfd_sub = fopen(vdictSubName,"w"); |
479 |
sprintf(vDictSubHeader,"Table of runtime parameters starting with \"%c\"",curLetter); |
480 |
vDictTitleWord=vDictSubHeader; |
481 |
vDictStart(vdictfd_sub); |
482 |
vDictTitleWord=NULL; |
483 |
html_columnHeading(vdictfd_sub); |
484 |
} |
485 |
|
486 |
/* Start row */ |
487 |
fprintf(parmdictfd,"<TR>\n"); |
488 |
fprintf(vdictfd_sub,"<TR>\n"); |
489 |
|
490 |
/* Variable name column */ |
491 |
vDictNameCol( parmdictfd, curRec ); |
492 |
vDictNameCol( vdictfd_sub, curRec ); |
493 |
|
494 |
/* Variable def, units, refs column */ |
495 |
vDictDefnCol( parmdictfd, curRec ); |
496 |
vDictDefnCol( vdictfd_sub, curRec ); |
497 |
|
498 |
/* Variable use count */ |
499 |
vDictUsesCol( parmdictfd, curRec ); |
500 |
vDictUsesCol( vdictfd_sub, curRec ); |
501 |
|
502 |
/* End of row */ |
503 |
fprintf(parmdictfd,"</TR>\n"); |
504 |
fprintf(parmdictfd,"\n"); |
505 |
fprintf(vdictfd_sub,"</TR>\n"); |
506 |
fprintf(vdictfd_sub,"\n"); |
507 |
} |
508 |
} |
509 |
|
510 |
if ( parmdictfd != NULL ) { |
511 |
/* End last Table of uses */ |
512 |
fprintf(parmdictfd,"</TABLE>"); |
513 |
/* End document */ |
514 |
fprintf(parmdictfd,"</HTML>\n"); |
515 |
fclose(parmdictfd); |
516 |
} |
517 |
if ( vdictfd_sub != NULL ) { vDictClose(vdictfd_sub); } |
518 |
} |
519 |
|
520 |
GeneratePrecompDict() |
521 |
/* |
522 |
Generate tables of compile time parameters |
523 |
*/ |
524 |
{ |
525 |
ddRecord *curRec; |
526 |
char *note; |
527 |
char curLetter = ' '; |
528 |
FILE *vdictfd_sub = NULL; |
529 |
char vdictSubName[MAXPATHNAM]; |
530 |
char vDictSubHeader[1024]; |
531 |
static char vDictHeader[] = "Alphabetic table of All Compile Time Parameters"; |
532 |
|
533 |
fprintf(stderr,"Hi there \n"); |
534 |
/* HTML headers */ |
535 |
vDictTitleWord=vDictHeader; |
536 |
vDictStart(compdictfd); |
537 |
vDictTitleWord=NULL; |
538 |
|
539 |
/* Table Entry */ |
540 |
while ( ddGetCurrent(&curRec) != 0 ){ |
541 |
if ( curRec->isInIfdef == 1 ) { |
542 |
if ( toupper(curRec->name[0]) != curLetter ){ |
543 |
curLetter = toupper(curRec->name[0]); |
544 |
html_indexRecord(compdictfd,curLetter); |
545 |
html_columnHeading(compdictfd); |
546 |
|
547 |
/* Do sub listing for this letter and/or symbol */ |
548 |
if ( vdictfd_sub != NULL ) { vDictClose(vdictfd_sub); } |
549 |
sprintf(vdictSubName,"%s/%s_pref%c%s",rootDir,COMPDICT,curLetter,HTMLSUF); |
550 |
vdictfd_sub = fopen(vdictSubName,"w"); |
551 |
sprintf(vDictSubHeader,"Table of compile time parameters starting with \"%c\"",curLetter); |
552 |
vDictTitleWord=vDictSubHeader; |
553 |
vDictStart(vdictfd_sub); |
554 |
vDictTitleWord=NULL; |
555 |
html_columnHeading(vdictfd_sub); |
556 |
} |
557 |
|
558 |
/* Start row */ |
559 |
fprintf(compdictfd,"<TR>\n"); |
560 |
fprintf(vdictfd_sub,"<TR>\n"); |
561 |
|
562 |
/* Variable name column */ |
563 |
vDictNameCol( compdictfd, curRec ); |
564 |
vDictNameCol( vdictfd_sub, curRec ); |
565 |
|
566 |
/* Variable def, units, refs column */ |
567 |
vDictDefnCol( compdictfd, curRec ); |
568 |
vDictDefnCol( vdictfd_sub, curRec ); |
569 |
|
570 |
/* Variable use count */ |
571 |
vDictUsesCol( compdictfd, curRec ); |
572 |
vDictUsesCol( vdictfd_sub, curRec ); |
573 |
|
574 |
/* End of row */ |
575 |
fprintf(compdictfd,"</TR>\n"); |
576 |
fprintf(compdictfd,"\n"); |
577 |
fprintf(vdictfd_sub,"</TR>\n"); |
578 |
fprintf(vdictfd_sub,"\n"); |
579 |
} |
580 |
} |
581 |
|
582 |
if ( compdictfd != NULL ) { |
583 |
/* End last Table of uses */ |
584 |
fprintf(compdictfd,"</TABLE>"); |
585 |
/* End document */ |
586 |
fprintf(compdictfd,"</HTML>\n"); |
587 |
fclose(compdictfd); |
588 |
} |
589 |
if ( vdictfd_sub != NULL ) { vDictClose(vdictfd_sub); } |
590 |
} |
591 |
|
592 |
GenerateProcDict() |
593 |
/* |
594 |
Generate tables of procedures |
595 |
*/ |
596 |
{ |
597 |
ddRecord *curRec; |
598 |
char *note; |
599 |
char curLetter = ' '; |
600 |
FILE *vdictfd_sub = NULL; |
601 |
char vdictSubName[MAXPATHNAM]; |
602 |
char vDictSubHeader[1024]; |
603 |
static char vDictHeader[] = "Alphabetic table of all subroutines and functions"; |
604 |
|
605 |
fprintf(stderr,"Hi there \n"); |
606 |
/* HTML headers */ |
607 |
vDictTitleWord=vDictHeader; |
608 |
vDictStart(procdictfd); |
609 |
vDictTitleWord=NULL; |
610 |
|
611 |
/* Table Entry */ |
612 |
while ( ddGetCurrent(&curRec) != 0 ) { |
613 |
if ( curRec->isProcName == 1 ) { |
614 |
if ( toupper(curRec->name[0]) != curLetter ){ |
615 |
curLetter = toupper(curRec->name[0]); |
616 |
html_indexRecord(procdictfd,curLetter); |
617 |
html_columnHeading(procdictfd); |
618 |
|
619 |
/* Do sub listing for this letter and/or symbol */ |
620 |
if ( vdictfd_sub != NULL ) { vDictClose(vdictfd_sub); } |
621 |
sprintf(vdictSubName,"%s/%s_pref%c%s",rootDir,PROCDICT,curLetter,HTMLSUF); |
622 |
vdictfd_sub = fopen(vdictSubName,"w"); |
623 |
sprintf(vDictSubHeader,"Table of subroutines anf functions starting with \"%c\"",curLetter); |
624 |
vDictTitleWord=vDictSubHeader; |
625 |
vDictStart(vdictfd_sub); |
626 |
vDictTitleWord=NULL; |
627 |
html_columnHeading(vdictfd_sub); |
628 |
|
629 |
} |
630 |
|
631 |
/* Start row */ |
632 |
fprintf(procdictfd,"<TR>\n"); |
633 |
fprintf(vdictfd_sub,"<TR>\n"); |
634 |
|
635 |
/* Variable name column */ |
636 |
vDictNameCol( procdictfd, curRec ); |
637 |
vDictNameCol( vdictfd_sub, curRec ); |
638 |
|
639 |
/* Variable def, units, refs column */ |
640 |
vDictDefnCol( procdictfd, curRec ); |
641 |
vDictDefnCol( vdictfd_sub, curRec ); |
642 |
|
643 |
/* Variable use count */ |
644 |
vDictUsesCol( procdictfd, curRec ); |
645 |
vDictUsesCol( vdictfd_sub, curRec ); |
646 |
|
647 |
/* End of row */ |
648 |
fprintf(procdictfd,"</TR>\n"); |
649 |
fprintf(procdictfd,"\n"); |
650 |
fprintf(vdictfd_sub,"</TR>\n"); |
651 |
fprintf(vdictfd_sub,"\n"); |
652 |
} |
653 |
} |
654 |
|
655 |
if ( procdictfd != NULL ) { |
656 |
/* End last Table of uses */ |
657 |
fprintf(procdictfd,"</TABLE>"); |
658 |
/* End document */ |
659 |
fprintf(procdictfd,"</HTML>\n"); |
660 |
fclose(procdictfd); |
661 |
} |
662 |
if ( vdictfd_sub != NULL ) { vDictClose(vdictfd_sub); } |
663 |
} |
664 |
|
665 |
GenerateVDict() |
666 |
{ |
667 |
ddRecord *curRec; |
668 |
char *note; |
669 |
char curLetter = ' '; |
670 |
FILE *vdictfd_sub = NULL; |
671 |
char vdictSubName[MAXPATHNAM]; |
672 |
char vDictSubHeader[1024]; |
673 |
static char vDictHeader[] = "Alphabetic table of all symbols"; |
674 |
|
675 |
fprintf(stderr,"Hi there \n"); |
676 |
/* HTML headers */ |
677 |
vDictTitleWord=vDictHeader; |
678 |
vDictStart(vdictfd); |
679 |
vDictTitleWord=NULL; |
680 |
|
681 |
/* Table Entry */ |
682 |
while ( ddGetCurrent(&curRec) != 0 ){ |
683 |
if ( toupper(curRec->name[0]) != curLetter ){ |
684 |
curLetter = toupper(curRec->name[0]); |
685 |
html_indexRecord(vdictfd,curLetter); |
686 |
html_columnHeading(vdictfd); |
687 |
|
688 |
/* Do sub listing for this letter and/or symbol */ |
689 |
if ( vdictfd_sub != NULL ) { vDictClose(vdictfd_sub); } |
690 |
sprintf(vdictSubName,"%s/%s_pref%c%s",rootDir,"vdict",curLetter,HTMLSUF); |
691 |
vdictfd_sub = fopen(vdictSubName,"w"); |
692 |
sprintf(vDictSubHeader,"Table of symbols starting with \"%c\"",curLetter); |
693 |
vDictTitleWord=vDictSubHeader; |
694 |
vDictStart(vdictfd_sub); |
695 |
vDictTitleWord=NULL; |
696 |
html_columnHeading(vdictfd_sub); |
697 |
|
698 |
} |
699 |
|
700 |
/* Start row */ |
701 |
fprintf(vdictfd,"<TR>\n"); |
702 |
fprintf(vdictfd_sub,"<TR>\n"); |
703 |
|
704 |
/* Variable name column */ |
705 |
vDictNameCol( vdictfd, curRec ); |
706 |
vDictNameCol( vdictfd_sub, curRec ); |
707 |
|
708 |
/* Variable def, units, refs column */ |
709 |
vDictDefnCol( vdictfd, curRec ); |
710 |
vDictDefnCol( vdictfd_sub, curRec ); |
711 |
|
712 |
/* Variable use count */ |
713 |
vDictUsesCol( vdictfd, curRec ); |
714 |
vDictUsesCol( vdictfd_sub, curRec ); |
715 |
|
716 |
/* End of row */ |
717 |
fprintf(vdictfd,"</TR>\n"); |
718 |
fprintf(vdictfd,"\n"); |
719 |
fprintf(vdictfd_sub,"</TR>\n"); |
720 |
fprintf(vdictfd_sub,"\n"); |
721 |
|
722 |
} |
723 |
|
724 |
if ( vdictfd != NULL ) { |
725 |
/* End last Table of uses */ |
726 |
fprintf(vdictfd,"</TABLE>"); |
727 |
/* End document */ |
728 |
fprintf(vdictfd,"</HTML>\n"); |
729 |
fclose(vdictfd); |
730 |
} |
731 |
if ( vdictfd_sub != NULL ) { vDictClose(vdictfd_sub); } |
732 |
|
733 |
} |
734 |
GenerateVDictIndex() |
735 |
{ |
736 |
FILE *fd; char fName[MAXPATHNAM]; |
737 |
char curLetter = ' '; |
738 |
ddRecord *curRec; |
739 |
|
740 |
/* HTML headers */ |
741 |
sprintf(fName,"%s/%s%s",rootDir,"index",HTMLSUF); |
742 |
fd = fopen(fName,"w"); |
743 |
fprintf(fd,"<HTML>"); fprintf(fd,"<HEAD>"); fprintf(fd,"</HEAD>"); |
744 |
fprintf(fd,"<TITLE>Name Index</TITLE>\n"); |
745 |
fprintf(fd,"<BODY text=\"#000000\" bgcolor=\"#FFFFFF\">"); |
746 |
|
747 |
while ( ddGetCurrent(&curRec) != 0 ){ |
748 |
if ( toupper(curRec->name[0]) != curLetter ){ |
749 |
curLetter = toupper(curRec->name[0]); |
750 |
/* |
751 |
fprintf(fd,"<BR><FONT SIZE=8 ><B>%c</A></B></FONT>\n",curLetter); |
752 |
fprintf(fd,"<FONT SIZE=2 ><B> \n"); */ |
753 |
fprintf(fd,"<BR><BR> \n"); |
754 |
fprintf(fd,"</LI><LI> \n"); |
755 |
} else { |
756 |
fprintf(fd,",\n"); |
757 |
} |
758 |
if ( curRec->active > 0 ) { |
759 |
fprintf(fd,"<A HREF=%s/%s%s>",VARSUF,curRec->key,HTMLSUF); |
760 |
fprintf(fd,"%s</A>",curRec->name); |
761 |
} else { |
762 |
fprintf(fd,"%s",curRec->name); |
763 |
} |
764 |
} |
765 |
/* End document */ |
766 |
fprintf(fd,"</BODY>\n"); |
767 |
fprintf(fd,"</HTML>\n"); |
768 |
fclose(fd); |
769 |
|
770 |
} |
771 |
|
772 |
int html_indexRecord(curFd, letter) |
773 |
FILE *curFd; |
774 |
char letter; |
775 |
{ |
776 |
int i; |
777 |
|
778 |
fprintf(curFd,"<TR>\n"); |
779 |
fprintf(curFd," <TD COLSPAN=3>\n"); |
780 |
fprintf(curFd," <FONT SIZE=8 ><B><A NAME=i_%c>%c</A></B></FONT>\n",letter,letter); |
781 |
fprintf(curFd," <FONT SIZE=2 ><B>\n"); |
782 |
for (i=0;i<24;i=i+3){ |
783 |
fprintf(curFd," <A HREF=#i_%c><U>%c</U></A>",'A'+i,'A'+i); |
784 |
fprintf(curFd," <A HREF=#i_%c><U>%c</U></A>",'A'+i+1,'A'+i+1); |
785 |
fprintf(curFd," <A HREF=#i_%c><U>%c</U></A>\n",'A'+i+2,'A'+i+2); |
786 |
} |
787 |
fprintf(curFd," <A HREF=#i_%c><U>%c</U></A>",'Y','Y'); |
788 |
fprintf(curFd," <A HREF=#i_%c><U>%c</U></A>\n",'Z','Z'); |
789 |
fprintf(curFd," </FONT></B>\n"); |
790 |
fprintf(curFd," </TD>\n"); |
791 |
fprintf(curFd,"</TR>\n"); |
792 |
fprintf(curFd,"\n"); |
793 |
} |
794 |
|
795 |
int html_columnHeading(FILE *curFd) |
796 |
{ |
797 |
fprintf(curFd,"<TR>\n"); |
798 |
fprintf(curFd," <TD VALIGN=\"CENTER\" HEIGHT=40 ALIGN=\"CENTER\"> "); |
799 |
fprintf(curFd," <FONT SIZE=5><B><U>Symbol </U></B></FONT>"); |
800 |
fprintf(curFd," </TD>\n"); |
801 |
fprintf(curFd," <TD VALIGN=\"CENTER\" HEIGHT=40 ALIGN=\"CENTER\"> "); |
802 |
fprintf(curFd," <FONT SIZE=5><B><U>Description</U></B></FONT>"); |
803 |
fprintf(curFd," </TD>\n"); |
804 |
fprintf(curFd," <TD VALIGN=\"CENTER\" HEIGHT=40 ALIGN=\"CENTER\"> "); |
805 |
fprintf(curFd," <FONT SIZE=5><B><U>Uses</U></B></FONT>"); |
806 |
fprintf(curFd," </TD>\n"); |
807 |
fprintf(curFd,"</TR>\n"); |
808 |
fprintf(curFd,"\n"); |
809 |
} |
810 |
|
811 |
int vDictClose(FILE *curFd) |
812 |
{ |
813 |
/* End last Table of uses */ |
814 |
fprintf(curFd,"</TABLE>"); |
815 |
/* End document */ |
816 |
fprintf(curFd,"</BODY></HTML>\n"); |
817 |
fclose(curFd); |
818 |
} |
819 |
|
820 |
int vDictStart(FILE *curFd) |
821 |
{ |
822 |
fprintf(curFd,"<HTML>\n"); |
823 |
fprintf(curFd,"<HEAD>\n"); |
824 |
fprintf(curFd,"</HEAD>\n"); |
825 |
if ( vDictTitleWord == NULL ) vDictTitleWord = vDictDefaultTitleWord; |
826 |
fprintf(curFd,"<TITLE>%s</TITLE>\n",vDictTitleWord); |
827 |
fprintf(curFd,"<BODY text=\"#000000\" bgcolor=\"#FFFFFF\">"); |
828 |
/* Begin table */ |
829 |
fprintf(curFd, |
830 |
"<TABLE BORDER CELLSPACING=1 BORDERCOLOR=\"#000000\" CELLPADDING=2 >\n"); |
831 |
} |
832 |
|
833 |
int vDictNameCol(FILE *vdictfd, ddRecord *curRec) |
834 |
{ |
835 |
if ( curRec->active > 0 ) { |
836 |
fprintf(vdictfd," <TD>\n <B><FONT FACE=\"Courier\"><A HREF=%s/%s%s> ", |
837 |
VARSUF,curRec->key,HTMLSUF); |
838 |
fprintf(vdictfd,"%s </A></B></FONT>\n </TD>\n",curRec->name); |
839 |
} else { |
840 |
fprintf(vdictfd," <TD>\n <B><FONT FACE=\"Courier\">"); |
841 |
fprintf(vdictfd,"%s </B></FONT>\n </TD>\n",curRec->name); |
842 |
} |
843 |
} |
844 |
|
845 |
vDictDefnCol(FILE *vdictfd, ddRecord *curRec ) |
846 |
{ |
847 |
char *note; |
848 |
fprintf(vdictfd," <TD>\n"); |
849 |
fprintf(vdictfd," <A NAME=var.%s>",curRec->name); |
850 |
if ( curRec->textEntry != NULL ) { |
851 |
fprintf(vdictfd," %s</A>\n",curRec->textEntry); |
852 |
} else { |
853 |
fprintf(vdictfd," <B><U> </U></B></A>\n"); |
854 |
/* fprintf(vdictfd," <B><U>%s %s %s %s</U></B></A>\n", |
855 |
"*** NO DEFINITION ***", "*** NO DEFINITION ***", |
856 |
"*** NO DEFINITION ***", "*** NO DEFINITION ***"); */ |
857 |
} |
858 |
if ( curRec->unitsEntry != NULL && strlen(curRec->unitsEntry) != 0 ){ |
859 |
fprintf(vdictfd," (<I>units</I>: %s ) \n",curRec->unitsEntry); |
860 |
} |
861 |
if ( curRec->hrefEntry != NULL && strlen(curRec->hrefEntry) != 0 ){ |
862 |
fprintf(vdictfd," <sub><A HREF=%s><IMG SRC=\"OpenBookIcon.gif\"",curRec->hrefEntry); |
863 |
fprintf(vdictfd,"WIDTH=30 HEIGHT=15 ALT=\"Goto Manual\"></A></sub>\n"); |
864 |
} |
865 |
if ( curRec->footNotesEntry != NULL ){ |
866 |
fprintf(vdictfd," <sup><B>"); |
867 |
note=strtok(curRec->footNotesEntry," "); |
868 |
fprintf(vdictfd,"<A HREF=#footnote_%s>%s</A>",note,note); |
869 |
while ( (note = strtok((char *)NULL," ")) != (char *)NULL ) { |
870 |
fprintf(vdictfd,"\n, <A HREF=#footnote_%s>%s</A>",note,note); |
871 |
} |
872 |
fprintf(vdictfd,"</B></sup>\n"); |
873 |
} |
874 |
fprintf(vdictfd," </TD>\n"); |
875 |
} |
876 |
|
877 |
int vDictUsesCol(FILE *vdictfd, ddRecord *curRec) |
878 |
{ |
879 |
fprintf(vdictfd," <TD>\n"); |
880 |
fprintf(vdictfd," %d\n",curRec->active); |
881 |
fprintf(vdictfd," </TD>\n"); |
882 |
} |
883 |
|
884 |
/* Record new entry in dd */ |
885 |
int addRecord() |
886 |
{ |
887 |
ddRecord rec; int recNo; |
888 |
rec.name = curName; |
889 |
rec.hrefEntry = curHref; |
890 |
rec.textEntry = curText; |
891 |
rec.unitsEntry = curUnits; |
892 |
rec.footNotesEntry = curFootNotes; |
893 |
rec.active = 0; |
894 |
fprintf(stdout,"Adding DD record %s\n",rec.name); |
895 |
fflush(stdout); |
896 |
|
897 |
/* Make dd entry */ |
898 |
ddAdd(&rec); |
899 |
|
900 |
/* Free temporary name string copies */ |
901 |
if ( curName != NULL ) { |
902 |
fprintf(stdout,"Free %s\n",curName);fflush(stdout); |
903 |
free(curName);curName=NULL; |
904 |
} |
905 |
if ( curHref != NULL ) { |
906 |
fprintf(stdout,"Free %s\n",curHref);fflush(stdout); |
907 |
free(curHref);curHref=NULL; |
908 |
} |
909 |
if ( curText != NULL ) { |
910 |
fprintf(stdout,"Free %s\n",curText);fflush(stdout); |
911 |
free(curText);curText=NULL; |
912 |
} |
913 |
if ( curUnits != NULL ) { |
914 |
fprintf(stdout,"Free %s\n",curUnits);fflush(stdout); |
915 |
free(curUnits);curUnits=NULL; |
916 |
} |
917 |
if ( curFootNotes != NULL ) { |
918 |
fprintf(stdout,"Free %s\n",curFootNotes);fflush(stdout); |
919 |
free(curFootNotes);curFootNotes=NULL; |
920 |
} |
921 |
|
922 |
fprintf(stdout,"Added DD record \n"); |
923 |
fflush(stdout); |
924 |
} |
925 |
|
926 |
/* Join two strdup created strings and free the originals */ |
927 |
char *strjoin(s1, s2) |
928 |
char *s1; char *s2; |
929 |
{ |
930 |
char *s; |
931 |
|
932 |
fprintf(stdout, "strjoin called \n"); |
933 |
fflush(stdout); |
934 |
|
935 |
/* DEBUG - Die if both strings are NULL */ |
936 |
/* if ( s1 == NULL && s2 == NULL ) exit(); */ |
937 |
|
938 |
/* If either string is NULL return other */ |
939 |
if ( s1 == NULL ) return(s2); |
940 |
if ( s2 == NULL ) return(s1); |
941 |
|
942 |
s = (char *)malloc(strlen(s1)+strlen(s2)+1); |
943 |
s = strcpy(s,s1); |
944 |
s = strcat(s,s2); |
945 |
|
946 |
} |
947 |
|
948 |
/* Like strdup but changes \. into . */ |
949 |
char *strcopy(s1) |
950 |
char *s1; |
951 |
{ |
952 |
char *s; int i;int l; int bs; int el; |
953 |
|
954 |
/* If string is NULL return. */ |
955 |
if ( s1 == NULL ) return(s1); |
956 |
s = strdup(s1); |
957 |
return(s); |
958 |
|
959 |
l = strlen(s1)+1; bs = 0; el=0; |
960 |
s = (char *)malloc(l); |
961 |
if ( s == NULL ) return(s); |
962 |
for ( i=0;i<l;++i) { |
963 |
if ( bs == 0 ) { |
964 |
if ( s1[i] != '\\' ) { |
965 |
s[el]=s1[i];++el; |
966 |
} |
967 |
else { |
968 |
bs = 1; |
969 |
} |
970 |
} else { |
971 |
s[el]=s1[i];++el; bs=0; |
972 |
} |
973 |
} |
974 |
s[el]='\0'; |
975 |
return(s); |
976 |
} |
977 |
|
978 |
int ParseF90Code() |
979 |
/* Read the source code */ |
980 |
{ |
981 |
int i; FILE *file; int j; |
982 |
char tmpFileName[MAXPATHNAM]; |
983 |
char srcFileName[MAXPATHNAM]; |
984 |
char srcDirName[MAXPATHNAM]; |
985 |
|
986 |
/* Create scratch file for loggin variable uses */ |
987 |
sprintf(tmpFileName,"%s/%s",OUTDIR,TMP1); |
988 |
tmpfd = fopen(tmpFileName,"w"); |
989 |
|
990 |
/* Parse the list of source files */ |
991 |
if ( argList.nSFiles > 0 ) { |
992 |
for (i=1;i<=argList.nSFiles;++i){ |
993 |
file = fopen(argList.srcFiles[i-1],"r"); |
994 |
if (!file) { |
995 |
fprintf(stderr,"Unable to open file \"%s\"\n",argList.srcFiles[i-1]); |
996 |
} else { |
997 |
F90symin = file; |
998 |
currentFile=argList.srcFiles[i-1]; |
999 |
j=strlen(argList.srcFiles[i-1]); |
1000 |
while ( j > 0 && *(argList.srcFiles[i-1]+j-1) != '/') --j; |
1001 |
currentProcedure=NOPROC; |
1002 |
Lno=1; Cno=1; |
1003 |
currentLineHtml[0]=(char)NULL; |
1004 |
/* Create file for writing html source */ |
1005 |
++nSrcFile; |
1006 |
sprintf(sHtmlName,"%s/%d%s",srcDir,nSrcFile,HTMLSUF); |
1007 |
srcfd=fopen(sHtmlName,"w"); |
1008 |
sprintf(sHtmlName,"%d%s",nSrcFile,HTMLSUF); |
1009 |
fprintf(srcfd,"<HTML>\n"); |
1010 |
fprintf(srcfd,"<TITLE>%s</TITLE>\n",currentFile); |
1011 |
fprintf(srcfd,"<BODY text=\"#000000\" bgcolor=\"#FFFFFF\">\n"); |
1012 |
fprintf(srcfd,"<PRE>\n"); |
1013 |
|
1014 |
F90symparse(); |
1015 |
fprintf(srcfd,"</PRE></BODY></HTML>\n"); |
1016 |
fclose(srcfd); |
1017 |
fclose(file); |
1018 |
/* Write directory, file and HTML src name */ |
1019 |
strncpy(srcDirName,argList.srcFiles[i-1],MAXPATHNAM-1); |
1020 |
srcDirName[j]='\0'; |
1021 |
if ( j == 0 ) { |
1022 |
srcDirName[0] = '.'; |
1023 |
srcDirName[1] = '/'; |
1024 |
srcDirName[2] = '\0'; |
1025 |
} |
1026 |
strncpy(srcFileName,argList.srcFiles[i-1]+j,MAXPATHNAM-1); |
1027 |
srcFileName[MAXPATHNAM]='\0'; |
1028 |
printf("HTM %s %s %s\n", |
1029 |
srcDirName, srcFileName,sHtmlName); |
1030 |
/* Add entry to the "FileDirectory" table. */ |
1031 |
fdAdd( srcDirName, srcFileName, sHtmlName ); |
1032 |
} |
1033 |
} |
1034 |
fdPrint(); |
1035 |
} |
1036 |
else |
1037 |
{ |
1038 |
currentFile="STANDARD INPUT";currentLineHtml[0]=(char)NULL; |
1039 |
F90symparse(); |
1040 |
} |
1041 |
|
1042 |
fclose(tmpfd); |
1043 |
} |
1044 |
|
1045 |
int tblSort() |
1046 |
{ |
1047 |
/* |
1048 |
use system() to sort tmp1 > tmp2. |
1049 |
Sort removes multiple entries so that if a variable appears |
1050 |
multiple times on a single line only one table entry will |
1051 |
be generated. |
1052 |
*/ |
1053 |
char command[500]; |
1054 |
sprintf(command,"sort %s/%s | uniq | grep -v '^ *$' > %s/%s", |
1055 |
OUTDIR,TMP1,OUTDIR,TMP2); |
1056 |
system(command); |
1057 |
} |
1058 |
|
1059 |
int GenerateVarTables() |
1060 |
{ |
1061 |
char tmpFileName[MAXPATHNAM]; |
1062 |
char vdFileName[MAXPATHNAM]; |
1063 |
char ioBuff[currentLineHtmlSize*2]; |
1064 |
char *vNam, *vLast, *lineRef, *fileRef, *procRef, *codeRec; |
1065 |
char *note; |
1066 |
FILE *tabfd; |
1067 |
ddRecord *curRec; |
1068 |
ddRecord rec; |
1069 |
|
1070 |
sprintf(tmpFileName,"%s/%s",OUTDIR,TMP2); |
1071 |
tabfd = fopen(tmpFileName,"r"); |
1072 |
vLast = NULL; vdictfd = NULL; |
1073 |
|
1074 |
while ( fscanf(tabfd,"%[^\n]%*[\n]",ioBuff) != EOF ) { |
1075 |
vNam = strtok(ioBuff,","); |
1076 |
lineRef = strtok(NULL,","); |
1077 |
/* Trick here that should be fixed. */ |
1078 |
/* Testing lineRef != NULL checks to see whether the */ |
1079 |
/* there was a format error in the sorted file. The */ |
1080 |
/* file will only have an error if the parsing rules */ |
1081 |
/* are incomplete. */ |
1082 |
if ( lineRef != NULL ) { |
1083 |
fileRef = strtok(NULL,","); |
1084 |
procRef = strtok(NULL,","); |
1085 |
codeRec = procRef+strlen(procRef)+1; |
1086 |
if ( vLast == NULL || strcmp(vNam,vLast) != 0 ) { |
1087 |
if ( vLast != NULL ){ free(vLast);} |
1088 |
vLast = strdup(vNam); |
1089 |
rec.name = vNam; |
1090 |
curRec = ddFind(&rec); |
1091 |
if ( curRec == NULL ) { |
1092 |
printf("Variable %s NOT FOUND\n",vNam); |
1093 |
exit(1); |
1094 |
} else { |
1095 |
printf("New variable %s key = %s\n",vNam,curRec->key); |
1096 |
} |
1097 |
if ( vdictfd != NULL ){ |
1098 |
/* End Table of uses */ |
1099 |
fprintf(vdictfd,"</TABLE>"); |
1100 |
/* End document */ |
1101 |
fprintf(vdictfd,"</HTML>\n"); |
1102 |
fclose(vdictfd); |
1103 |
} |
1104 |
sprintf(vdFileName,"%s/%s/%s%s",OUTDIR,VARSUF,curRec->key,HTMLSUF); |
1105 |
vdictfd = fopen(vdFileName,"w"); |
1106 |
/* HTML headers */ |
1107 |
fprintf(vdictfd,"<HTML>\n"); |
1108 |
fprintf(vdictfd,"<HEAD>\n"); |
1109 |
fprintf(vdictfd,"</HEAD>\n"); |
1110 |
fprintf(vdictfd,"<TITLE>Table showing occurences of \"%s\"</TITLE>\n",curRec->name); |
1111 |
fprintf(vdictfd,"<BODY text=\"#000000\" bgcolor=\"#FFFFFF\">\n"); |
1112 |
/* Begin table */ |
1113 |
fprintf(vdictfd, |
1114 |
"<TABLE BORDER CELLSPACING=1 BORDERCOLOR=\"#000000\" CELLPADDING=2 >\n"); |
1115 |
html_columnHeading(vdictfd); |
1116 |
fprintf(vdictfd,"<TR>\n"); |
1117 |
fprintf(vdictfd," <TD>\n <B><FONT FACE=\"Courier\">"); |
1118 |
fprintf(vdictfd,"%s </B></FONT>\n </TD>\n",curRec->name); |
1119 |
fprintf(vdictfd," <TD>\n"); |
1120 |
fprintf(vdictfd," <A NAME=var.%s>",curRec->name); |
1121 |
if ( curRec->textEntry != NULL ) { |
1122 |
fprintf(vdictfd," %s</A>\n",curRec->textEntry); |
1123 |
} |
1124 |
else |
1125 |
{ |
1126 |
fprintf(vdictfd," <B><U> </U></B></A>\n"); |
1127 |
/* fprintf(vdictfd," <B><U>%s %s %s %s</U></B></A>\n", |
1128 |
"*** NO DEFINITION ***", "*** NO DEFINITION ***", |
1129 |
"*** NO DEFINITION ***", "*** NO DEFINITION ***"); */ |
1130 |
} |
1131 |
if ( curRec->unitsEntry != NULL && strlen(curRec->unitsEntry) != 0 ){ |
1132 |
fprintf(vdictfd," (<I>units</I>: %s ) \n",curRec->unitsEntry); |
1133 |
} |
1134 |
if ( curRec->hrefEntry != NULL && strlen(curRec->hrefEntry) != 0 ){ |
1135 |
fprintf(vdictfd," <sub><A HREF=%s><IMG SRC=\"OpenBookIcon.gif\"",curRec->hrefEntry); |
1136 |
fprintf(vdictfd,"WIDTH=30 HEIGHT=15 ALT=\"Goto Manual\"></A></sub>\n"); |
1137 |
} |
1138 |
if ( curRec->footNotesEntry != NULL ){ |
1139 |
fprintf(vdictfd," <sup><B>"); |
1140 |
note=strtok(curRec->footNotesEntry," "); |
1141 |
fprintf(vdictfd,"<A HREF=#footnote_%s>%s</A>",note,note); |
1142 |
while ( (note = strtok((char *)NULL," ")) != (char *)NULL ) { |
1143 |
fprintf(vdictfd,"\n, <A HREF=#footnote_%s>%s</A>",note,note); |
1144 |
} |
1145 |
fprintf(vdictfd,"</B></sup>\n"); |
1146 |
} |
1147 |
fprintf(vdictfd," </TD>\n"); |
1148 |
fprintf(vdictfd," <TD>\n"); |
1149 |
fprintf(vdictfd," %d\n",curRec->active); |
1150 |
fprintf(vdictfd," </TD>\n"); |
1151 |
fprintf(vdictfd,"</TR>\n"); |
1152 |
fprintf(vdictfd,"\n"); |
1153 |
/* End header table */ |
1154 |
fprintf(vdictfd,"</TABLE>\n<BR><HR><BR>\n"); |
1155 |
|
1156 |
/* Begin table of uses */ |
1157 |
fprintf(vdictfd, |
1158 |
"<TABLE BORDER CELLSPACING=1 BORDERCOLOR=\"#000000\" CELLPADDING=2 WIDTH=900>\n"); |
1159 |
fprintf(vdictfd,"<TR>\n<TD>File</TD>\n<TD>Line number</TD>\n<TD>Procedure</TD>\n<TD>Code</TD>\n</TR>\n"); |
1160 |
} |
1161 |
/* Table of uses */ |
1162 |
fprintf(vdictfd,"<TR>\n"); |
1163 |
fprintf(vdictfd," <TD>\n"); |
1164 |
fprintf(vdictfd," %s",fileRef); |
1165 |
fprintf(vdictfd," </TD>\n"); |
1166 |
fprintf(vdictfd," <TD>\n"); |
1167 |
fprintf(vdictfd," %s",lineRef); |
1168 |
fprintf(vdictfd," </TD>\n"); |
1169 |
fprintf(vdictfd," <TD>\n"); |
1170 |
fprintf(vdictfd," %s",procRef); |
1171 |
fprintf(vdictfd," </TD>\n"); |
1172 |
fprintf(vdictfd," <TD>\n"); |
1173 |
fprintf(vdictfd," <PRE>%s</PRE>",codeRec); |
1174 |
fprintf(vdictfd," </TD>\n"); |
1175 |
fprintf(vdictfd,"</TR>\n"); |
1176 |
} |
1177 |
} |
1178 |
if ( vdictfd != NULL ){ |
1179 |
/* End last Table of uses */ |
1180 |
fprintf(vdictfd,"</TABLE>"); |
1181 |
/* End document */ |
1182 |
fprintf(vdictfd,"</BODY></HTML>\n"); |
1183 |
fclose(vdictfd); |
1184 |
} |
1185 |
} |