1 /***************************************
4 C Cross Referencing & Documentation tool. Version 1.5f.
6 Writes the HTML output.
7 ******************/ /******************
8 Written by Andrew M. Bishop
10 This file Copyright 1995,96,97,98,99,2001,02,04 Andrew M. Bishop
11 It may be distributed under the GNU Public License, version 2, or
12 any higher version. See section COPYING of the GNU Public license
13 for conditions under which this file may be redistributed.
14 ***************************************/
19 #include <sys/types.h>
27 /*+ The file extension to use for the output files. +*/
28 #define HTML_FILE ".html"
29 #define HTML_FILE_BACKUP ".html~"
31 /*+ The file extension to use for the output source files. +*/
32 #define HTML_SRC_FILE ".src.html"
34 /*+ The name of the output tex file that contains the appendix. +*/
35 #define HTML_APDX ".apdx"
37 /*+ A macro to determine the HTML version we should produce. +*/
38 #define HTML20 (option_html&1)
39 #define HTML32 (option_html&2)
40 #define HTMLSRC (option_html&16)
42 /*+ The comments are to be inserted verbatim. +*/
43 extern int option_verbatim_comments
;
45 /*+ The type of HTML output to produce. +*/
46 extern int option_html
;
48 /*+ The name of the directory for the output. +*/
49 extern char* option_odir
;
51 /*+ The base name of the file for the output. +*/
52 extern char* option_name
;
54 /*+ The information about the cxref run, +*/
55 extern char *run_command
, /*+ the command line options. +*/
56 *run_cpp_command
; /*+ the cpp command and options. +*/
58 /*+ The directories to go back to get to the base output directory. +*/
59 static char* goback
=NULL
;
61 static void WriteHTMLFilePart(File file
);
62 static void WriteHTMLInclude(Include inc
);
63 static void WriteHTMLSubInclude(Include inc
,int depth
);
64 static void WriteHTMLDefine(Define def
);
65 static void WriteHTMLTypedef(Typedef type
);
66 static void WriteHTMLStructUnion(StructUnion su
,int depth
);
67 static void WriteHTMLVariable(Variable var
);
68 static void WriteHTMLFunction(Function func
);
70 static void WriteHTMLDocument(char* name
,int appendix
);
71 static void WriteHTMLPreamble(FILE* f
,char* title
,int sourcefile
);
72 static void WriteHTMLPostamble(FILE* f
,int sourcefile
);
74 void WriteHTMLSource(char *name
);
76 static char* html(char* c
,int verbatim
);
78 /*+ The output file for the HTML. +*/
81 /*+ The name of the file. +*/
82 static char *filename
;
85 /*++++++++++++++++++++++++++++++++++++++
86 Write an html file for a complete File structure and all components.
88 File file The File structure to output.
89 ++++++++++++++++++++++++++++++++++++++*/
91 void WriteHTMLFile(File file
)
98 /* Write the including file. */
100 WriteHTMLDocument(file
->name
,0);
104 ofile
=ConcatStrings(4,option_odir
,"/",file
->name
,HTML_FILE
);
109 struct stat stat_buf
;
110 int i
,ofl
=strlen(ofile
);
112 for(i
=strlen(option_odir
)+1;i
<ofl
;i
++)
116 if(stat(ofile
,&stat_buf
))
117 mkdir(ofile
,S_IRUSR
|S_IWUSR
|S_IXUSR
|S_IRGRP
|S_IXGRP
|S_IROTH
|S_IXOTH
);
125 {fprintf(stderr
,"cxref: Failed to open the HTML output file '%s'\n",ofile
);exit(1);}
127 for(goback
="",i
=strlen(file
->name
);i
>0;i
--)
128 if(file
->name
[i
]=='/')
129 goback
=ConcatStrings(2,goback
,"../");
131 /* Write out a header. */
133 WriteHTMLPreamble(of
,ConcatStrings(5,"Cross reference for ",file
->name
," of ",option_name
,"."),0);
135 /*+ The file structure is broken into its components and they are each written out. +*/
137 WriteHTMLFilePart(file
);
141 Include inc
=file
->includes
;
142 fprintf(of
,"\n<hr>\n<h2>Included Files</h2>\n\n");
144 WriteHTMLInclude(inc
);
146 while((inc
=inc
->next
));
151 Define def
=file
->defines
;
152 fprintf(of
,"\n<hr>\n<h2>Preprocessor definitions</h2>\n\n");
154 if(def
!=file
->defines
)
156 WriteHTMLDefine(def
);
158 while((def
=def
->next
));
163 Typedef type
=file
->typedefs
;
165 WriteHTMLTypedef(type
);
167 while((type
=type
->next
));
172 int any_to_mention
=0;
173 Variable var
=file
->variables
;
176 if(var
->scope
&(GLOBAL
|LOCAL
|EXTERNAL
|EXTERN_F
))
179 while((var
=var
->next
));
183 int first_ext
=1,first_local
=1;
184 Variable var
=file
->variables
;
186 if(var
->scope
&GLOBAL
)
187 WriteHTMLVariable(var
);
189 while((var
=var
->next
));
192 if(var
->scope
&(EXTERNAL
|EXTERN_F
) && !(var
->scope
&GLOBAL
))
195 {fprintf(of
,"\n<hr>\n<h2>External Variables</h2>\n\n"); first_ext
=0;}
198 WriteHTMLVariable(var
);
201 while((var
=var
->next
));
207 {fprintf(of
,"\n<hr>\n<h2>Local Variables</h2>\n\n"); first_local
=0;}
210 WriteHTMLVariable(var
);
213 while((var
=var
->next
));
219 Function func
=file
->functions
;
221 if(func
->scope
&(GLOBAL
|EXTERNAL
))
222 WriteHTMLFunction(func
);
224 while((func
=func
->next
));
225 func
=file
->functions
;
227 if(func
->scope
&LOCAL
)
228 WriteHTMLFunction(func
);
230 while((func
=func
->next
));
233 WriteHTMLPostamble(of
,0);
237 /* Write out the source file. */
240 WriteHTMLSource(file
->name
);
242 /* Clear the memory in html() */
244 html(NULL
,0); html(NULL
,0); html(NULL
,0); html(NULL
,0);
248 /*++++++++++++++++++++++++++++++++++++++
249 Write a File structure out.
251 File file The File to output.
252 ++++++++++++++++++++++++++++++++++++++*/
254 static void WriteHTMLFilePart(File file
)
259 fprintf(of
,"<h1><a name=\"file\" href=\"%s%s%s\">File %s</a></h1>\n",goback
,file
->name
,HTML_SRC_FILE
,html(file
->name
,0));
261 fprintf(of
,"<h1><a name=\"file\">File %s</a></h1>\n",html(file
->name
,0));
265 if(option_verbatim_comments
)
266 fprintf(of
,"<pre>\n%s\n</pre>\n\n",html(file
->comment
,0));
269 char *rcs1
=strstr(file
->comment
,"$Header"),*rcs2
=NULL
;
272 rcs2
=strstr(&rcs1
[1],"$");
276 fprintf(of
,"<b>RCS %s</b>\n<p>\n",html(&rcs1
[1],0));
281 fprintf(of
,"%s\n<p>\n",html(&rcs2
[2],0));
283 fprintf(of
,"%s\n<p>\n",html(file
->comment
,0));
292 fprintf(of
,"<dl compact>\n");
294 fprintf(of
,"<table>\n");
295 for(i
=0;i
<file
->inc_in
->n
;i
++)
298 fprintf(of
,"<dt>Included in:\n<dd><ul>\n");
299 else if(HTML32
&& i
==0)
300 fprintf(of
,"<tr><td>Included in:\n");
302 fprintf(of
,"<tr><td> \n");
303 fprintf(of
,"<%s><a href=\"%s%s"HTML_FILE
"#file\">%s</a><br>\n",HTML20
?"li":"td",goback
,file
->inc_in
->s
[i
],html(file
->inc_in
->s
[i
],0));
306 fprintf(of
,"</ul>\n</dl>\n");
308 fprintf(of
,"</table>\n");
311 if(file
->f_refs
->n
|| file
->v_refs
->n
)
314 fprintf(of
,"<dl compact>\n");
316 fprintf(of
,"<table>\n");
324 fprintf(of
,"<dt>References Functions:\n<dd><ul>\n");
326 fprintf(of
,"<tr><td>References Functions:\n");
328 for(i
=0;i
<file
->f_refs
->n
;i
++)
329 if(file
->f_refs
->s2
[i
])
331 if(HTML32
&& i
!=others
)
332 fprintf(of
,"<tr><td> \n");
334 fprintf(of
,"<li><a href=\"%s%s"HTML_FILE
"#func-%s\">%s() : %s</a>\n",goback
,file
->f_refs
->s2
[i
],file
->f_refs
->s1
[i
],html(file
->f_refs
->s1
[i
],0),html(file
->f_refs
->s2
[i
],0));
336 fprintf(of
,"<td><a href=\"%s%s"HTML_FILE
"#func-%s\">%s()</a><td><a href=\"%s%s"HTML_FILE
"#func-%s\">%s</a>\n",goback
,file
->f_refs
->s2
[i
],file
->f_refs
->s1
[i
],html(file
->f_refs
->s1
[i
],0),goback
,file
->f_refs
->s2
[i
],file
->f_refs
->s1
[i
],html(file
->f_refs
->s2
[i
],0));
346 fprintf(of
,"<td colspan=2>");
348 fprintf(of
,"<tr><td> \n<td colspan=2>");
349 for(i
=0;i
<file
->f_refs
->n
;i
++)
350 if(!file
->f_refs
->s2
[i
])
351 fprintf(of
,--others
?" %s(),":" %s()",html(file
->f_refs
->s1
[i
],0));
356 fprintf(of
,"</ul>\n");
364 fprintf(of
,"<dt>References Variables:\n<dd><ul>\n");
366 fprintf(of
,"<tr><td>References Variables:\n");
368 for(i
=0;i
<file
->v_refs
->n
;i
++)
369 if(file
->v_refs
->s2
[i
])
371 if(HTML32
&& i
!=others
)
372 fprintf(of
,"<tr><td> \n");
374 fprintf(of
,"<li><a href=\"%s%s"HTML_FILE
"#var-%s\">%s : %s</a>\n",goback
,file
->v_refs
->s2
[i
],file
->v_refs
->s1
[i
],html(file
->v_refs
->s1
[i
],0),html(file
->v_refs
->s2
[i
],0));
376 fprintf(of
,"<td><a href=\"%s%s"HTML_FILE
"#var-%s\">%s</a><td><a href=\"%s%s"HTML_FILE
"#var-%s\">%s</a>\n",goback
,file
->v_refs
->s2
[i
],file
->v_refs
->s1
[i
],html(file
->v_refs
->s1
[i
],0),goback
,file
->v_refs
->s2
[i
],file
->v_refs
->s1
[i
],html(file
->v_refs
->s2
[i
],0));
386 fprintf(of
,"<td colspan=2>");
388 fprintf(of
,"<tr><td> \n<td colspan=2>");
389 for(i
=0;i
<file
->v_refs
->n
;i
++)
390 if(!file
->v_refs
->s2
[i
])
391 fprintf(of
,--others
?" %s,":" %s",html(file
->v_refs
->s1
[i
],0));
396 fprintf(of
,"</ul>\n");
399 if(file
->f_refs
->n
|| file
->v_refs
->n
)
402 fprintf(of
,"</dl>\n");
404 fprintf(of
,"</table>\n");
409 /*++++++++++++++++++++++++++++++++++++++
410 Write an Include structure out.
412 Include inc The Include structure to output.
413 ++++++++++++++++++++++++++++++++++++++*/
415 static void WriteHTMLInclude(Include inc
)
418 fprintf(of
,"%s\n<p>\n",html(inc
->comment
,0));
420 fprintf(of
,"<ul>\n");
422 if(inc
->scope
==LOCAL
)
423 fprintf(of
,"<li><tt><a href=\"%s%s"HTML_FILE
"#file\">#include \"%s\"</a></tt>\n",goback
,inc
->name
,html(inc
->name
,0));
425 fprintf(of
,"<li><tt>#include <%s></tt>\n",html(inc
->name
,0));
428 WriteHTMLSubInclude(inc
->includes
,1);
430 fprintf(of
,"</ul>\n");
434 /*++++++++++++++++++++++++++++++++++++++
435 Write an Sub Include structure out. (An include structure that is included from another file.)
437 Include inc The Include structure to output.
439 int depth The depth of the include hierarchy.
440 ++++++++++++++++++++++++++++++++++++++*/
442 static void WriteHTMLSubInclude(Include inc
,int depth
)
444 fprintf(of
,"<ul>\n");
448 if(inc
->scope
==LOCAL
)
449 fprintf(of
,"<li><tt><a href=\"%s%s"HTML_FILE
"#file\">#include \"%s\"</a></tt>\n",goback
,inc
->name
,html(inc
->name
,0));
451 fprintf(of
,"<li><tt>#include <%s></tt>\n",html(inc
->name
,0));
454 WriteHTMLSubInclude(inc
->includes
,depth
+1);
459 fprintf(of
,"</ul>\n");
463 /*++++++++++++++++++++++++++++++++++++++
464 Write a Define structure out.
466 Define def The Define structure to output.
467 ++++++++++++++++++++++++++++++++++++++*/
469 static void WriteHTMLDefine(Define def
)
475 fprintf(of
,"%s\n<p>\n",html(def
->comment
,0));
478 fprintf(of
,"<tt><a href=\"%s%s%s#line%d\">#define %s</a>",goback
,filename
,HTML_SRC_FILE
,def
->lineno
,html(def
->name
,0));
480 fprintf(of
,"<tt>#define %s",html(def
->name
,0));
483 fprintf(of
," %s",html(def
->value
,0));
488 for(i
=0;i
<def
->args
->n
;i
++)
489 fprintf(of
,i
?", %s":"%s",html(def
->args
->s1
[i
],0));
492 fprintf(of
,"</tt><br>\n");
494 for(i
=0;i
<def
->args
->n
;i
++)
500 fprintf(of
,"<dl compact>\n");
501 for(i
=0;i
<def
->args
->n
;i
++)
502 fprintf(of
,"<dt><tt>%s</tt>\n<dd>%s\n",html(def
->args
->s1
[i
],0),def
->args
->s2
[i
]?html(def
->args
->s2
[i
],0):"");
503 fprintf(of
,"</dl>\n");
508 /*++++++++++++++++++++++++++++++++++++++
509 Write a Typedef structure out.
511 Typedef type The Typedef structure to output.
512 ++++++++++++++++++++++++++++++++++++++*/
514 static void WriteHTMLTypedef(Typedef type
)
516 fprintf(of
,"\n<hr>\n<h2>");
518 if(!strncmp("enum",type
->name
,4))
519 fprintf(of
,"<a name=\"type-enum-%s\">",&type
->name
[5]);
521 if(!strncmp("union",type
->name
,5))
522 fprintf(of
,"<a name=\"type-union-%s\">",&type
->name
[6]);
524 if(!strncmp("struct",type
->name
,6))
525 fprintf(of
,"<a name=\"type-struct-%s\">",&type
->name
[7]);
527 fprintf(of
,"<a name=\"type-%s\">",type
->name
);
530 fprintf(of
,"Typedef %s",html(type
->name
,0));
532 fprintf(of
,"Type %s",html(type
->name
,0));
534 fprintf(of
,"</a></h2>\n");
537 fprintf(of
,"%s\n<p>\n",html(type
->comment
,0));
542 fprintf(of
,"<tt><a href=\"%s%s%s#line%d\">typedef %s</a></tt><br>\n",goback
,filename
,HTML_SRC_FILE
,type
->lineno
,html(type
->type
,0));
544 fprintf(of
,"<tt>typedef %s</tt><br>\n",html(type
->type
,0));
546 else if(type
->sutype
)
549 fprintf(of
,"<tt><a href=\"%s%s%s#line%d\">%s</a></tt><br>\n",goback
,filename
,HTML_SRC_FILE
,type
->lineno
,html(type
->sutype
->name
,0));
551 fprintf(of
,"<tt>%s</tt><br>\n",html(type
->sutype
->name
,0));
557 fprintf(of
,"<ul>\n");
559 fprintf(of
,"<table>\n");
560 WriteHTMLStructUnion(type
->sutype
,0);
562 fprintf(of
,"</ul>\n");
564 fprintf(of
,"</table>\n");
569 fprintf(of
,"<dl compact>\n<dt>See:\n<dd><ul>\n");
570 if(type
->typexref
->type
)
571 fprintf(of
,"<li><a href=\"#type-%s\">Typedef %s</a>\n",type
->typexref
->name
,html(type
->typexref
->name
,0));
573 if(!strncmp("enum",type
->typexref
->name
,4))
574 fprintf(of
,"<li><a href=\"#type-enum-%s\">Type %s</a>\n",&type
->typexref
->name
[5],html(type
->typexref
->name
,0));
576 if(!strncmp("union",type
->typexref
->name
,5))
577 fprintf(of
,"<li><a href=\"#type-union-%s\">Type %s</a>\n",&type
->typexref
->name
[6],html(type
->typexref
->name
,0));
579 if(!strncmp("struct",type
->typexref
->name
,6))
580 fprintf(of
,"<li><a href=\"#type-struct-%s\">Type %s</a>\n",&type
->typexref
->name
[7],html(type
->typexref
->name
,0));
581 fprintf(of
,"</ul>\n</dl>\n");
586 /*++++++++++++++++++++++++++++++++++++++
587 Write a structure / union structure out.
589 StructUnion su The structure / union to write.
591 int depth The current depth within the structure.
592 ++++++++++++++++++++++++++++++++++++++*/
594 static void WriteHTMLStructUnion(StructUnion su
, int depth
)
599 splitsu
=strstr(su
->name
,"{...}");
600 if(splitsu
) splitsu
[-1]=0;
604 if(depth
&& su
->comment
&& !su
->comps
)
605 fprintf(of
,"<li><tt>%s; </tt>%s<br>\n",html(su
->name
,0),html(su
->comment
,0));
606 else if(!depth
|| su
->comps
)
607 fprintf(of
,"<li><tt>%s</tt><br>\n",html(su
->name
,0));
609 fprintf(of
,"<li><tt>%s;</tt><br>\n",html(su
->name
,0));
613 fprintf(of
,"<tr><td>");
615 fprintf(of
," ");
616 if(!depth
|| su
->comps
)
617 fprintf(of
,"<tt>%s</tt>",html(su
->name
,0));
619 fprintf(of
,"<tt>%s;</tt>",html(su
->name
,0));
621 if(depth
&& su
->comment
&& !su
->comps
)
622 fprintf(of
,html(su
->comment
,0));
624 fprintf(of
," ");
628 if(!depth
|| su
->comps
)
632 fprintf(of
,"<ul>\n");
633 fprintf(of
,"<li><tt>{</tt><br>\n");
637 fprintf(of
,"<tr><td>");
639 fprintf(of
," ");
640 fprintf(of
," <tt>{</tt>");
641 fprintf(of
,"<td> \n");
644 for(i
=0;i
<su
->n_comp
;i
++)
645 WriteHTMLStructUnion(su
->comps
[i
],depth
+1);
649 fprintf(of
,"<li><tt>}</tt><br>\n");
650 fprintf(of
,"</ul>\n");
654 fprintf(of
,"<tr><td>");
656 fprintf(of
," ");
657 fprintf(of
," <tt>}</tt>");
658 fprintf(of
,"<td> \n");
665 if(depth
&& su
->comment
)
666 fprintf(of
,"<li><tt>%s; </tt>%s<br>\n",splitsu
[5]?html(&splitsu
[6],0):"",html(su
->comment
,0));
668 fprintf(of
,"<li><tt>%s;</tt><br>\n",splitsu
[5]?html(&splitsu
[6],0):"");
672 fprintf(of
,"<tr><td>");
674 fprintf(of
," ");
675 fprintf(of
,"<tt>%s;</tt>",splitsu
[5]?html(&splitsu
[6],0):"");
676 if(depth
&& su
->comment
)
677 fprintf(of
,"<td>%s\n",html(su
->comment
,0));
679 fprintf(of
,"<td> \n");
684 if(splitsu
) splitsu
[-1]=' ';
688 /*++++++++++++++++++++++++++++++++++++++
689 Write a Variable structure out.
691 Variable var The Variable structure to output.
692 ++++++++++++++++++++++++++++++++++++++*/
694 static void WriteHTMLVariable(Variable var
)
698 if(var
->scope
&GLOBAL
)
699 fprintf(of
,"\n<hr>\n<h2><a name=\"var-%s\">Global Variable %s</a></h2>\n",var
->name
,html(var
->name
,0));
701 fprintf(of
,"<b><a name=\"var-%s\">%s</a></b><br>\n",var
->name
,html(var
->name
,0));
704 fprintf(of
,"%s\n<p>\n",html(var
->comment
,0));
706 if(HTMLSRC
&& var
->scope
&(GLOBAL
|LOCAL
))
709 fprintf(of
,"<tt><a href=\"%s%s%s#line%d\">",goback
,var
->incfrom
,HTML_SRC_FILE
,var
->lineno
);
711 fprintf(of
,"<tt><a href=\"%s%s%s#line%d\">",goback
,filename
,HTML_SRC_FILE
,var
->lineno
);
717 fprintf(of
,"static ");
719 if(!(var
->scope
&GLOBAL
) && var
->scope
&(EXTERNAL
|EXTERN_F
))
720 fprintf(of
,"extern ");
722 fprintf(of
,"%s",html(var
->type
,0));
725 fprintf(of
,"</a></tt><br>\n");
727 fprintf(of
,"</tt><br>\n");
729 if(var
->scope
&(GLOBAL
|LOCAL
))
731 if(var
->incfrom
|| var
->visible
->n
|| var
->used
->n
)
734 fprintf(of
,"<dl compact>\n");
736 fprintf(of
,"<table>\n");
742 fprintf(of
,"<dt>Included from:\n<dd><ul>\n");
744 fprintf(of
,"<tr><td>Included from\n");
745 fprintf(of
,"<%s><a href=\"%s%s"HTML_FILE
"#var-%s\">%s</a>\n",HTML20
?"li":"td",goback
,var
->incfrom
,var
->name
,html(var
->incfrom
,0));
747 fprintf(of
,"</ul>\n");
752 for(i
=0;i
<var
->visible
->n
;i
++)
755 fprintf(of
,"<dt>Visible in:\n<dd><ul>\n");
756 else if(HTML32
&& i
==0)
757 fprintf(of
,"<tr><td>Visible in:\n");
759 fprintf(of
,"<tr><td> \n");
760 if(var
->visible
->s1
[i
][0]=='$' && !var
->visible
->s1
[i
][1])
761 fprintf(of
,"<%s><a href=\"%s%s"HTML_FILE
"#file\">%s</a>\n",HTML20
?"li":"td> <td",goback
,var
->visible
->s2
[i
],html(var
->visible
->s2
[i
],0));
764 fprintf(of
,"<li><a href=\"%s%s"HTML_FILE
"#func-%s\">%s() : %s</a>\n",goback
,var
->visible
->s2
[i
],var
->visible
->s1
[i
],html(var
->visible
->s1
[i
],0),html(var
->visible
->s2
[i
],0));
766 fprintf(of
,"<td><a href=\"%s%s"HTML_FILE
"#func-%s\">%s()</a><td><a href=\"%s%s"HTML_FILE
"#func-%s\">%s</a>\n",goback
,var
->visible
->s2
[i
],var
->visible
->s1
[i
],html(var
->visible
->s1
[i
],0),goback
,var
->visible
->s2
[i
],var
->visible
->s1
[i
],html(var
->visible
->s2
[i
],0));
769 fprintf(of
,"</ul>\n");
774 for(i
=0;i
<var
->used
->n
;i
++)
777 fprintf(of
,"<dt>Used in:\n<dd><ul>\n");
778 else if(HTML32
&& i
==0)
779 fprintf(of
,"<tr><td>Used in:\n");
781 fprintf(of
,"<tr><td> \n");
782 if(var
->used
->s1
[i
][0]=='$' && !var
->used
->s1
[i
][1])
783 fprintf(of
,"<%s><a href=\"%s%s"HTML_FILE
"#file\">%s</a>\n",HTML20
?"li":"td> <td",goback
,var
->used
->s2
[i
],html(var
->used
->s2
[i
],0));
787 fprintf(of
,"<%s><a href=\"#func-%s\">%s()</a>\n",HTML20
?"li":"td",var
->used
->s1
[i
],html(var
->used
->s1
[i
],0));
790 fprintf(of
,"<li><a href=\"%s%s"HTML_FILE
"#func-%s\">%s() : %s</a>\n",goback
,var
->used
->s2
[i
],var
->used
->s1
[i
],html(var
->used
->s1
[i
],0),html(var
->used
->s2
[i
],0));
792 fprintf(of
,"<td><a href=\"%s%s"HTML_FILE
"#func-%s\">%s()</a><td><a href=\"%s%s"HTML_FILE
"#func-%s\">%s</a>\n",goback
,var
->used
->s2
[i
],var
->used
->s1
[i
],html(var
->used
->s1
[i
],0),goback
,var
->used
->s2
[i
],var
->used
->s1
[i
],html(var
->used
->s2
[i
],0));
796 fprintf(of
,"</ul>\n");
799 if(var
->incfrom
|| var
->visible
->n
|| var
->used
->n
)
802 fprintf(of
,"</dl>\n");
804 fprintf(of
,"\n</table>\n");
808 if(var
->scope
&(EXTERNAL
|EXTERN_F
) && var
->defined
)
811 fprintf(of
,"<dl compact>\n");
813 fprintf(of
,"<table>\n");
815 fprintf(of
,"<dt>Defined in:\n<dd><ul>\n");
817 fprintf(of
,"<tr><td>Defined in:\n");
818 fprintf(of
,"<%s><a href=\"%s%s"HTML_FILE
"#var-%s\">%s</a>\n",HTML20
?"li":"td",goback
,var
->defined
,html(var
->name
,0),var
->defined
);
820 fprintf(of
,"</ul>\n</dl>\n");
822 fprintf(of
,"\n</table>\n");
827 /*++++++++++++++++++++++++++++++++++++++
828 Write a Function structure out.
830 Function func The Function structure to output.
831 ++++++++++++++++++++++++++++++++++++++*/
833 static void WriteHTMLFunction(Function func
)
836 char* comment2
=NULL
,*type
;
838 if(func
->scope
&(GLOBAL
|EXTERNAL
))
839 fprintf(of
,"\n<hr>\n<h2><a name=\"func-%s\">Global Function %s()</a></h2>\n",func
->name
,html(func
->name
,0));
841 fprintf(of
,"\n<hr>\n<h2><a name=\"func-%s\">Local Function %s()</a></h2>\n",func
->name
,html(func
->name
,0));
845 if(option_verbatim_comments
)
846 fprintf(of
,"<pre>\n%s\n</pre>\n\n",html(func
->comment
,0));
849 comment2
=strstr(func
->comment
,"\n\n");
852 fprintf(of
,"%s\n<p>\n",html(func
->comment
,0));
859 fprintf(of
,"<tt><a href=\"%s%s%s#line%d\">",goback
,func
->incfrom
,HTML_SRC_FILE
,func
->lineno
);
861 fprintf(of
,"<tt><a href=\"%s%s%s#line%d\">",goback
,filename
,HTML_SRC_FILE
,func
->lineno
);
866 if(func
->scope
&LOCAL
)
867 fprintf(of
,"static ");
868 if(func
->scope
&INLINED
)
869 fprintf(of
,"inline ");
871 if((type
=strstr(func
->type
,"()")))
873 fprintf(of
,"%s ( ",html(func
->type
,0));
875 for(i
=0;i
<func
->args
->n
;i
++)
876 fprintf(of
,i
?", %s":"%s",html(func
->args
->s1
[i
],0));
879 {fprintf(of
," %s",html(&type
[1],0));type
[0]='(';}
884 fprintf(of
,"</a></tt><br>\n");
886 fprintf(of
,"</tt><br>\n");
888 pret
=strncmp("void ",func
->type
,5) && func
->cret
;
889 for(pargs
=0,i
=0;i
<func
->args
->n
;i
++)
890 pargs
= pargs
|| ( strcmp("void",func
->args
->s1
[i
]) && func
->args
->s2
[i
] );
894 fprintf(of
,"<dl compact>\n");
896 fprintf(of
,"<dt><tt>%s</tt>\n<dd>%s\n",html(func
->type
,0),func
->cret
?html(func
->cret
,0):" ");
898 for(i
=0;i
<func
->args
->n
;i
++)
899 fprintf(of
,"<dt><tt>%s</tt>\n<dd>%s\n",html(func
->args
->s1
[i
],0),func
->args
->s2
[i
]?html(func
->args
->s2
[i
],0):" ");
900 fprintf(of
,"</dl>\n");
905 fprintf(of
,"%s\n<p>\n",html(&comment2
[2],0));
909 if(func
->protofile
|| func
->incfrom
|| func
->calls
->n
|| func
->called
->n
|| func
->used
->n
|| func
->f_refs
->n
|| func
->v_refs
->n
)
912 fprintf(of
,"<dl compact>\n");
914 fprintf(of
,"<table>\n");
920 fprintf(of
,"<dt>Prototyped in:\n<dd><ul>\n");
922 fprintf(of
,"<tr><td>Prototyped in:\n");
923 fprintf(of
,"<%s><a href=\"%s%s"HTML_FILE
"#file\">%s</a>\n",HTML20
?"li":"td colspan=2",goback
,func
->protofile
,html(func
->protofile
,0));
925 fprintf(of
,"</ul>\n");
931 fprintf(of
,"<dt>Included from:\n<dd><ul>\n");
933 fprintf(of
,"<tr><td>Included from:\n");
934 fprintf(of
,"<%s><a href=\"%s%s"HTML_FILE
"#func-%s\">%s</a>\n",HTML20
?"li":"td colspan=2",goback
,func
->incfrom
,func
->name
,html(func
->incfrom
,0));
936 fprintf(of
,"</ul>\n");
944 fprintf(of
,"<dt>Calls:\n<dd><ul>\n");
946 fprintf(of
,"<tr><td>Calls:\n");
948 for(i
=0;i
<func
->calls
->n
;i
++)
949 if(func
->calls
->s2
[i
])
951 if(HTML32
&& i
!=others
)
952 fprintf(of
,"<tr><td> \n");
954 fprintf(of
,"<li><a href=\"%s%s"HTML_FILE
"#func-%s\">%s() : %s</a>\n",goback
,func
->calls
->s2
[i
],func
->calls
->s1
[i
],html(func
->calls
->s1
[i
],0),html(func
->calls
->s2
[i
],0));
956 fprintf(of
,"<td><a href=\"%s%s"HTML_FILE
"#func-%s\">%s()</a><td><a href=\"%s%s"HTML_FILE
"#func-%s\">%s</a>\n",goback
,func
->calls
->s2
[i
],func
->calls
->s1
[i
],html(func
->calls
->s1
[i
],0),goback
,func
->calls
->s2
[i
],func
->calls
->s1
[i
],html(func
->calls
->s2
[i
],0));
966 fprintf(of
,"<td colspan=2>");
968 fprintf(of
,"<tr><td> \n<td colspan=2>");
969 for(i
=0;i
<func
->calls
->n
;i
++)
970 if(!func
->calls
->s2
[i
])
971 fprintf(of
,--others
?"%s(), ":"%s()",html(func
->calls
->s1
[i
],0));
976 fprintf(of
,"</ul>\n");
982 fprintf(of
,"<dt>Called by:\n<dd><ul>\n");
984 fprintf(of
,"<tr><td>Called by:\n");
985 for(i
=0;i
<func
->called
->n
;i
++)
988 fprintf(of
,"<tr><td> \n");
990 fprintf(of
,"<li><a href=\"%s%s"HTML_FILE
"#func-%s\">%s() : %s</a>\n",goback
,func
->called
->s2
[i
],func
->called
->s1
[i
],html(func
->called
->s1
[i
],0),html(func
->called
->s2
[i
],0));
992 fprintf(of
,"<td><a href=\"%s%s"HTML_FILE
"#func-%s\">%s()</a><td><a href=\"%s%s"HTML_FILE
"#func-%s\">%s</a>\n",goback
,func
->called
->s2
[i
],func
->called
->s1
[i
],html(func
->called
->s1
[i
],0),goback
,func
->called
->s2
[i
],func
->called
->s1
[i
],html(func
->called
->s2
[i
],0));
995 fprintf(of
,"</ul>\n");
1001 fprintf(of
,"<dt>Used in:\n<dd><ul>\n");
1003 fprintf(of
,"<tr><td>Used in:\n");
1004 for(i
=0;i
<func
->used
->n
;i
++)
1007 fprintf(of
,"<tr><td> \n");
1008 if(func
->used
->s1
[i
][0]=='$' && !func
->used
->s1
[i
][1])
1009 fprintf(of
,"<%s><a href=\"%s%s"HTML_FILE
"#file\">%s</a>\n",HTML20
?"li":"td> <td",goback
,func
->used
->s2
[i
],html(func
->used
->s2
[i
],0));
1012 fprintf(of
,"<li><a href=\"%s%s"HTML_FILE
"#func-%s\">%s() : %s</a>\n",goback
,func
->used
->s2
[i
],func
->used
->s1
[i
],html(func
->used
->s1
[i
],0),html(func
->used
->s2
[i
],0));
1014 fprintf(of
,"<td><a href=\"%s%s"HTML_FILE
"#func-%s\">%s()</a><td><a href=\"%s%s"HTML_FILE
"#func-%s\">%s</a>\n",goback
,func
->used
->s2
[i
],func
->used
->s1
[i
],html(func
->used
->s1
[i
],0),goback
,func
->used
->s2
[i
],func
->used
->s1
[i
],html(func
->used
->s2
[i
],0));
1017 fprintf(of
,"</ul>\n");
1025 fprintf(of
,"<dt>References Functions:\n<dd><ul>\n");
1027 fprintf(of
,"<tr><td>References Functions:\n");
1029 for(i
=0;i
<func
->f_refs
->n
;i
++)
1030 if(func
->f_refs
->s2
[i
])
1032 if(HTML32
&& i
!=others
)
1033 fprintf(of
,"<tr><td> \n");
1035 fprintf(of
,"<li><a href=\"%s%s"HTML_FILE
"#func-%s\">%s() : %s</a>\n",goback
,func
->f_refs
->s2
[i
],func
->f_refs
->s1
[i
],html(func
->f_refs
->s1
[i
],0),html(func
->f_refs
->s2
[i
],0));
1037 fprintf(of
,"<td><a href=\"%s%s"HTML_FILE
"#func-%s\">%s()</a><td><a href=\"%s%s"HTML_FILE
"#func-%s\">%s</a>\n",goback
,func
->f_refs
->s2
[i
],func
->f_refs
->s1
[i
],html(func
->f_refs
->s1
[i
],0),goback
,func
->f_refs
->s2
[i
],func
->f_refs
->s1
[i
],html(func
->f_refs
->s2
[i
],0));
1047 fprintf(of
,"<td colspan=2>");
1049 fprintf(of
,"<tr><td> \n<td colspan=2>");
1050 for(i
=0;i
<func
->f_refs
->n
;i
++)
1051 if(!func
->f_refs
->s2
[i
])
1052 fprintf(of
,--others
?"%s(), ":"%s()",html(func
->f_refs
->s1
[i
],0));
1057 fprintf(of
,"</ul>\n");
1065 fprintf(of
,"<dt>References Variables:\n<dd><ul>\n");
1067 fprintf(of
,"<tr><td>References Variables:\n");
1069 for(i
=0;i
<func
->v_refs
->n
;i
++)
1070 if(func
->v_refs
->s2
[i
])
1072 if(HTML32
&& i
!=others
)
1073 fprintf(of
,"<tr><td> \n");
1075 fprintf(of
,"<li><a href=\"%s%s"HTML_FILE
"#var-%s\">%s : %s</a>\n",goback
,func
->v_refs
->s2
[i
],func
->v_refs
->s1
[i
],html(func
->v_refs
->s1
[i
],0),html(func
->v_refs
->s2
[i
],0));
1077 fprintf(of
,"<td><a href=\"%s%s"HTML_FILE
"#var-%s\">%s</a><td><a href=\"%s%s"HTML_FILE
"#var-%s\">%s</a>\n",goback
,func
->v_refs
->s2
[i
],func
->v_refs
->s1
[i
],html(func
->v_refs
->s1
[i
],0),goback
,func
->v_refs
->s2
[i
],func
->v_refs
->s1
[i
],html(func
->v_refs
->s2
[i
],0));
1087 fprintf(of
,"<td colspan=2>");
1089 fprintf(of
,"<tr><td> \n<td colspan=2>");
1090 for(i
=0;i
<func
->v_refs
->n
;i
++)
1091 if(!func
->v_refs
->s2
[i
])
1092 fprintf(of
,--others
?"%s, ":"%s",html(func
->v_refs
->s1
[i
],0));
1097 fprintf(of
,"</ul>\n");
1100 if(func
->protofile
|| func
->incfrom
|| func
->calls
->n
|| func
->called
->n
|| func
->used
->n
|| func
->f_refs
->n
|| func
->v_refs
->n
)
1103 fprintf(of
,"</dl>\n");
1105 fprintf(of
,"\n</table>\n");
1110 /*++++++++++++++++++++++++++++++++++++++
1111 Write out a file that will include the current information.
1113 char* name The name of the file.
1115 int appendix set to non-zero if the appendix file is to be added, else a normal source file.
1116 ++++++++++++++++++++++++++++++++++++++*/
1118 static void WriteHTMLDocument(char* name
,int appendix
)
1123 char *inc_file
,*ofile
,*ifile
;
1126 inc_file
=ConcatStrings(4,"<a href=\"",name
,HTML_FILE
,"\">Appendix</a><br>\n");
1128 inc_file
=ConcatStrings(6,"<a href=\"",name
,HTML_FILE
,"#file\">",name
,"</a><br>\n");
1129 ifile
=ConcatStrings(4,option_odir
,"/",option_name
,HTML_FILE
);
1130 ofile
=ConcatStrings(4,option_odir
,"/",option_name
,HTML_FILE_BACKUP
);
1132 in
=fopen(ifile
,"r");
1135 in
=fopen(ifile
,"w");
1137 {fprintf(stderr
,"cxref: Failed to open the main HTML output file '%s'\n",ifile
);exit(1);}
1139 WriteHTMLPreamble(in
,ConcatStrings(3,"Cross Reference Of ",option_name
,"."),1);
1140 WriteHTMLPostamble(in
,1);
1143 in
=fopen(ifile
,"r");
1146 out
=fopen(ofile
,"w");
1149 {fprintf(stderr
,"cxref: Failed to open the main HTML output file '%s'\n",ofile
);exit(1);}
1151 while(fgets(line
,256,in
))
1153 if(!strcmp(inc_file
,line
) ||
1154 (!strncmp("<!--",line
,4) && !strncmp(inc_file
,line
+4,strlen(inc_file
))) ||
1155 (!strncmp("<!-- ",line
,5) && !strncmp(inc_file
,line
+5,strlen(inc_file
))))
1157 if(line
[0]=='<' && !strcmp("<!-- End-Of-Source-Files -->\n",line
))
1163 fputs("<!-- Appendix -->\n",out
);
1165 fputs("<hr>\n",out
);
1166 fputs("<h1>Appendix</h1>\n",out
);
1168 fputs(inc_file
,out
);
1172 fputs(inc_file
,out
);
1187 rename(ofile
,ifile
);
1194 /*++++++++++++++++++++++++++++++++++++++
1195 Write out a standard pre-amble.
1197 FILE* f The file to write the pre amble to.
1199 char* title The title of the file.
1201 int sourcefile True if the Source-Files line is to be included.
1202 ++++++++++++++++++++++++++++++++++++++*/
1204 static void WriteHTMLPreamble(FILE* f
,char* title
,int sourcefile
)
1207 fputs("<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n",f
);
1209 fputs("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2//EN\">\n",f
);
1211 fputs("<!-- This HTML file generated by cxref. -->\n",f
);
1212 fputs("<!-- cxref program (c) Andrew M. Bishop 1995,96,97,98,99. -->\n",f
);
1218 fprintf(f
,"Cxref: %s %s\n",run_command
,filename
);
1220 fprintf(f
,"Cxref: %s\n",run_command
);
1221 fprintf(f
,"CPP : %s\n",run_cpp_command
);
1225 fputs("<HTML>\n",f
);
1227 fputs("<HEAD>\n",f
);
1230 fputs("</TITLE>\n",f
);
1231 fputs("</HEAD>\n",f
);
1233 fputs("<BODY>\n",f
);
1237 fputs("<h1>Source Files</h1>\n",f
);
1239 fputs("<!-- Begin-Of-Source-Files -->\n",f
);
1244 /*++++++++++++++++++++++++++++++++++++++
1245 Write out a standard post-amble. This includes the end of document marker.
1247 FILE* f The file to write the post amble to.
1249 int sourcefile True if the Source-Files line is to be included.
1250 ++++++++++++++++++++++++++++++++++++++*/
1252 static void WriteHTMLPostamble(FILE* f
,int sourcefile
)
1257 fputs("<!-- End-Of-Source-Files -->\n",f
);
1260 fputs("</BODY>\n",f
);
1261 fputs("</HTML>\n",f
);
1265 /*++++++++++++++++++++++++++++++++++++++
1266 Write out the appendix information.
1268 StringList files The list of files to write.
1270 StringList2 funcs The list of functions to write.
1272 StringList2 vars The list of variables to write.
1274 StringList2 types The list of types to write.
1275 ++++++++++++++++++++++++++++++++++++++*/
1277 void WriteHTMLAppendix(StringList files
,StringList2 funcs
,StringList2 vars
,StringList2 types
)
1284 /* Write the bits to the including file. */
1286 WriteHTMLDocument(ConcatStrings(2,option_name
,HTML_APDX
),1);
1290 ofile
=ConcatStrings(5,option_odir
,"/",option_name
,HTML_APDX
,HTML_FILE
);
1292 of
=fopen(ofile
,"w");
1295 {fprintf(stderr
,"cxref: Failed to open the HTML appendix file '%s'\n",ofile
);exit(1);}
1297 /* Write the file structure out */
1299 WriteHTMLPreamble(of
,ConcatStrings(3,"Cross reference index of ",option_name
,"."),0);
1301 fprintf(of
,"<h1>Cross References</h1>\n");
1303 if(files
->n
|| funcs
->n
|| vars
->n
|| types
->n
)
1305 fprintf(of
,"<ul>\n");
1307 fprintf(of
,"<li><a href=\"#files\">Files</a>\n");
1309 fprintf(of
,"<li><a href=\"#functions\">Global Functions</a>\n");
1311 fprintf(of
,"<li><a href=\"#variables\">Global Variables</a>\n");
1313 fprintf(of
,"<li><a href=\"#types\">Defined Types</a>\n");
1314 fprintf(of
,"</ul>\n");
1317 /* Write out the appendix of files. */
1321 fprintf(of
,"\n<hr>\n<h2><a name=\"files\">Files</a></h2>\n");
1322 fprintf(of
,"<ul>\n");
1323 for(i
=0;i
<files
->n
;i
++)
1324 fprintf(of
,"<li><a href=\"%s"HTML_FILE
"#file\">%s</a>\n",files
->s
[i
],html(files
->s
[i
],0));
1325 fprintf(of
,"</ul>\n");
1328 /* Write out the appendix of functions. */
1332 fprintf(of
,"\n<hr>\n<h2><a name=\"functions\">Global Functions</a></h2>\n");
1333 fprintf(of
,"<ul>\n");
1334 for(i
=0;i
<funcs
->n
;i
++)
1335 fprintf(of
,"<li><a href=\"%s"HTML_FILE
"#func-%s\">%s() : %s</a>\n",funcs
->s2
[i
],funcs
->s1
[i
],html(funcs
->s1
[i
],0),html(funcs
->s2
[i
],0));
1336 fprintf(of
,"</ul>\n");
1339 /* Write out the appendix of variables. */
1343 fprintf(of
,"\n<hr>\n<h2><a name=\"variables\">Global Variables</a></h2>\n");
1344 fprintf(of
,"<ul>\n");
1345 for(i
=0;i
<vars
->n
;i
++)
1346 fprintf(of
,"<li><a href=\"%s"HTML_FILE
"#var-%s\">%s : %s</a>\n",vars
->s2
[i
],vars
->s1
[i
],html(vars
->s1
[i
],0),html(vars
->s2
[i
],0));
1347 fprintf(of
,"</ul>\n");
1350 /* Write out the appendix of types. */
1354 fprintf(of
,"\n<hr>\n<h2><a name=\"types\">Defined Types</a></h2>\n");
1355 fprintf(of
,"<ul>\n");
1356 for(i
=0;i
<types
->n
;i
++)
1357 if(!strncmp("enum",types
->s1
[i
],4))
1358 fprintf(of
,"<li><a href=\"%s"HTML_FILE
"#type-enum-%s\">%s : %s</a>\n",types
->s2
[i
],&types
->s1
[i
][5],html(types
->s1
[i
],0),html(types
->s2
[i
],0));
1360 if(!strncmp("union",types
->s1
[i
],5))
1361 fprintf(of
,"<li><a href=\"%s"HTML_FILE
"#type-union-%s\">%s : %s</a>\n",types
->s2
[i
],&types
->s1
[i
][6],html(types
->s1
[i
],0),html(types
->s2
[i
],0));
1363 if(!strncmp("struct",types
->s1
[i
],6))
1364 fprintf(of
,"<li><a href=\"%s"HTML_FILE
"#type-struct-%s\">%s : %s</a>\n",types
->s2
[i
],&types
->s1
[i
][7],html(types
->s1
[i
],0),html(types
->s2
[i
],0));
1366 fprintf(of
,"<li><a href=\"%s"HTML_FILE
"#type-%s\">%s : %s</a>\n",types
->s2
[i
],types
->s1
[i
],html(types
->s1
[i
],0),html(types
->s2
[i
],0));
1367 fprintf(of
,"</ul>\n");
1370 WriteHTMLPostamble(of
,0);
1374 /* Clear the memory in html(,0) */
1376 html(NULL
,0); html(NULL
,0); html(NULL
,0); html(NULL
,0);
1380 /*++++++++++++++++++++++++++++++++++++++
1381 Delete the HTML file and main file reference that belong to the named file.
1383 char *name The name of the file to delete.
1384 ++++++++++++++++++++++++++++++++++++++*/
1386 void WriteHTMLFileDelete(char *name
)
1391 char *inc_file
,*ofile
,*ifile
;
1393 ofile
=ConcatStrings(4,option_odir
,"/",name
,HTML_FILE
);
1396 inc_file
=ConcatStrings(6,"<a href=\"",name
,HTML_FILE
,"#file\">",name
,"</a><br>\n");
1397 ifile
=ConcatStrings(4,option_odir
,"/",option_name
,HTML_FILE
);
1398 ofile
=ConcatStrings(4,option_odir
,"/",option_name
,HTML_FILE_BACKUP
);
1400 in
=fopen(ifile
,"r");
1401 out
=fopen(ofile
,"w");
1404 {fprintf(stderr
,"cxref: Failed to open the main HTML output file '%s'\n",ofile
);fclose(in
);}
1407 while(fgets(line
,256,in
))
1409 if(!strcmp(inc_file
,line
) ||
1410 (!strncmp("<!--",line
,4) && !strncmp(inc_file
,line
+4,strlen(inc_file
)-1)) ||
1411 (!strncmp("<!-- ",line
,5) && !strncmp(inc_file
,line
+5,strlen(inc_file
)-1)))
1423 rename(ofile
,ifile
);
1436 /*++++++++++++++++++++++++++++++++++++++
1437 Write out the source file.
1439 char *name The name of the source file.
1440 ++++++++++++++++++++++++++++++++++++++*/
1442 void WriteHTMLSource(char *name
)
1451 ofile
=ConcatStrings(4,option_odir
,"/",name
,HTML_SRC_FILE
);
1453 in
=fopen(ifile
,"r");
1455 {fprintf(stderr
,"cxref: Failed to open the source file '%s'\n",ifile
);exit(1);}
1457 out
=fopen(ofile
,"w");
1459 {fprintf(stderr
,"cxref: Failed to open the HTML output source file '%s'\n",ofile
);exit(1);}
1461 WriteHTMLPreamble(out
,ConcatStrings(2,"Source File ",name
),0);
1462 fputs("<pre>\n",out
);
1466 while(fgets(line
,256,in
))
1471 else if(lineno
==100)
1473 else if(lineno
==1000)
1475 else if(lineno
==10000)
1477 fprintf(out
,"<a name=\"line%d\">%d%s|</a> %s",lineno
,lineno
,pad
,html(line
,1));
1480 fputs("</pre>\n",out
);
1481 WriteHTMLPostamble(out
,0);
1488 /*++++++++++++++++++++++++++++++++++++++
1489 Make the input string safe to output as HTML ( not <, >, & or " ).
1491 char* html Returns a safe HTML string.
1493 char* c A non-safe HTML string.
1495 int verbatim Set to true if the text is to be output verbatim ignoring the comment +html+ directives.
1497 The function can only be called four times in each fprintf() since it returns one of only four static strings.
1498 ++++++++++++++++++++++++++++++++++++++*/
1500 static char* html(char* c
,int verbatim
)
1502 static char safe
[4][256],*malloced
[4]={NULL
,NULL
,NULL
,NULL
};
1505 int i
=0,j
=0,delta
=7,len
=256-delta
;
1514 {Free(malloced
[which
]);malloced
[which
]=NULL
;}
1519 i
=CopyOrSkip(c
,"html",©
,&skip
);
1523 for(;j
<len
&& c
[i
];i
++)
1526 {ret
[j
++]=c
[i
]; if(c
[i
]=='\n') copy
=0;}
1528 { if(c
[i
]=='\n') skip
=0;}
1535 strcpy(&ret
[j
],"<");j
+=4;
1538 strcpy(&ret
[j
],">");j
+=4;
1541 strcpy(&ret
[j
],"&");j
+=5;
1544 if(j
&& ret
[j
-1]=='\n')
1546 strcpy(&ret
[j
],"<br>");j
+=4;
1555 i
+=CopyOrSkip(c
+i
,"html",©
,&skip
);
1558 if(c
[i
]) /* Not finished */
1561 malloced
[which
]=Realloc(malloced
[which
],len
+delta
+256);
1563 {malloced
[which
]=Malloc(len
+delta
+256); strncpy(malloced
[which
],ret
,(unsigned)j
);}
1564 ret
=malloced
[which
];