# File html.c

RCS Header: /home/amb/cxref/RCS/html.c 1.27 1999/01/28 19:19:36 amb Exp

C Cross Referencing & Documentation tool. Version 1.5.
Writes the HTML output.

## Included Files

- `#include <stdlib.h>`

- `#include <stdio.h>`

- `#include <string.h>`

- `#include <sys/types.h>`

- `#include <sys/stat.h>`

- `#include <unistd.h>`

- `#include "memory.h"`

- `#include "datatype.h"`

- `#include "cxref.h"`
  - `#include "datatype.h"`

## Preprocessor definitions

The file extension to use for the output files.

`#define HTML_FILE ".html"`

`#define HTML_FILE_BACKUP ".html~"`

The file extension to use for the output source files.

`#define HTML_SRC_FILE ".src.html"`

The name of the output tex file that contains the appendix.

`#define HTML_APDX ".apdx"`

A macro to determine the HTML version we should produce.

`#define HTML20`

`#define HTML32`

`#define HTMLSRC`

## External Variables

option_verbatim_comments
The comments are to be inserted verbatim.

`extern int option_verbatim_comments`

Defined in: | cxref.c

option_html
The type of HTML output to produce.

`extern int option_html`

Defined in: | cxref.c

option_odir
The name of the directory for the output.

`extern char* option_odir`

Defined in: | cxref.c

option_name
The base name of the file for the output.

`extern char* option_name`

Defined in: | cxref.c

## Local Variables

goback
The directories to go back to get to the base output directory.

`static char* goback`

Used in: | WriteHTMLFile()
| WriteHTMLFilePart()
| WriteHTMLFunction()
| WriteHTMLInclude()
| WriteHTMLSubInclude()
| WriteHTMLVariable()

of
The output file for the HTML.

`static FILE* of`

Used in: | WriteHTMLAppendix()
| WriteHTMLDefine()
| WriteHTMLFile()
| WriteHTMLFilePart()
| WriteHTMLFunction()
| WriteHTMLInclude()
| WriteHTMLStructUnion()
| WriteHTMLSubInclude()
| WriteHTMLTypedef()
| WriteHTMLVariable()

filename
The name of the file.

`static char* filename`

Used in: | WriteHTMLDefine()
| WriteHTMLFile()
| WriteHTMLFunction()
| WriteHTMLTypedef()
| WriteHTMLVariable()

## Global Function WriteHTMLAppendix()

Write out the appendix information.

`void WriteHTMLAppendix ( StringList files, StringList2 funcs, StringList2 vars, StringList2 types )`

`StringList files`
  The list of files to write.
`StringList2 funcs`
  The list of functions to write.
`StringList2 vars`
  The list of variables to write.
`StringList2 types`
  The list of types to write.

Prototyped in: | cxref.h
Calls: | ConcatStrings() | memory.c
| WriteHTMLDocument() | html.c
| WriteHTMLPostamble() | html.c
| WriteHTMLPreamble() | html.c
| html() | html.c
| exit(), fclose(), fopen(), fprintf(), strncmp()
Called by: | main() | cxref.c
References Variables: | of | html.c
| option_name | cxref.c
| option_odir | cxref.c

## Global Function WriteHTMLFile()

Write an html file for a complete File structure and all components.

`void WriteHTMLFile ( File file )`

`File file`
  The File structure to output.

The file structure is broken into its components and they are each written out.

Prototyped in: | cxref.h
Calls: | ConcatStrings() | memory.c
| WriteHTMLDefine() | html.c
| WriteHTMLDocument() | html.c
| WriteHTMLFilePart() | html.c
| WriteHTMLFunction() | html.c
| WriteHTMLInclude() | html.c
| WriteHTMLPostamble() | html.c
| WriteHTMLPreamble() | html.c
| WriteHTMLSource() | html.c
| WriteHTMLTypedef() | html.c
| WriteHTMLVariable() | html.c
| html() | html.c
| exit(), fclose(), fopen(), fprintf(), mkdir(), stat(), strlen()
Called by: | main() | cxref.c
References Variables: | filename | html.c
| goback | html.c
| of | html.c
| option_html | cxref.c
| option_name | cxref.c
| option_odir | cxref.c

## Global Function WriteHTMLFileDelete()

Delete the HTML file and main file reference that belong to the named file.

`void WriteHTMLFileDelete ( char* name )`

`char* name`
  The name of the file to delete.

Prototyped in: | cxref.h
Calls: | ConcatStrings() | memory.c
| fclose(), fgets(), fopen(), fprintf(), fputs(), rename(), strcmp(), strlen(), strncmp(), unlink()
Called by: | main() | cxref.c
References Variables: | option_name | cxref.c
| option_odir | cxref.c

## Global Function WriteHTMLSource()

Write out the source file.

`void WriteHTMLSource ( char* name )`

`char* name`
  The name of the source file.

Prototyped in: | html.c
Calls: | ConcatStrings() | memory.c
| WriteHTMLPostamble() | html.c
| WriteHTMLPreamble() | html.c
| html() | html.c
| exit(), fclose(), fgets(), fopen(), fprintf(), fputs(), strcpy()
Called by: | WriteHTMLFile() | html.c
References Variables: | option_odir | cxref.c

## Local Function WriteHTMLDefine()

Write a Define structure out.

`static void WriteHTMLDefine ( Define def )`

`Define def`
  The Define structure to output.

Prototyped in: | html.c
Calls: | html() | html.c
| fprintf()
Called by: | WriteHTMLFile() | html.c
References Variables: | filename | html.c
| of | html.c
| option_html | cxref.c

## Local Function WriteHTMLDocument()

Write out a file that will include the current information.

`static void WriteHTMLDocument ( char* name, int appendix )`

`char* name`
  The name of the file.
`int appendix`
  set to non-zero if the appendix file is to be added, else a normal source file.

Prototyped in: | html.c
Calls: | ConcatStrings() | memory.c
| WriteHTMLPostamble() | html.c
| WriteHTMLPreamble() | html.c
| exit(), fclose(), fgets(), fopen(), fprintf(), fputs(), rename(), strcmp(), strlen(), strncmp(), unlink()
Called by: | WriteHTMLAppendix() | html.c
| WriteHTMLFile() | html.c
References Variables: | option_name | cxref.c
| option_odir | cxref.c

## Local Function WriteHTMLFilePart()

Write a File structure out.

`static void WriteHTMLFilePart ( File file )`

`File file`
  The File to output.

Prototyped in: | html.c
Calls: | html() | html.c
| fprintf(), strstr()
Called by: | WriteHTMLFile() | html.c
References Variables: | goback | html.c
| of | html.c
| option_html | cxref.c
| option_verbatim_comments | cxref.c

## Local Function WriteHTMLFunction()

Write a Function structure out.

`static void WriteHTMLFunction ( Function func )`

`Function func`
  The Function structure to output.

Prototyped in: | html.c
Calls: | html() | html.c
| fprintf(), strcmp(), strncmp(), strstr()
Called by: | WriteHTMLFile() | html.c
References Variables: | filename | html.c
| goback | html.c
| of | html.c
| option_html | cxref.c
| option_verbatim_comments | cxref.c

## Local Function WriteHTMLInclude()

Write an Include structure out.

`static void WriteHTMLInclude ( Include inc )`

`Include inc`
  The Include structure to output.

Prototyped in: | html.c
Calls: | WriteHTMLSubInclude() | html.c
| html() | html.c
| fprintf()
Called by: | WriteHTMLFile() | html.c
References Variables: | goback | html.c
| of | html.c

## Local Function WriteHTMLPostamble()

Write out a standard post-amble. This includes the end of document marker.

`static void WriteHTMLPostamble ( FILE* f, int sourcefile )`

`FILE* f`
  The file to write the post amble to.
`int sourcefile`
  True if the Source-Files line is to be included.

Prototyped in: | html.c
Calls: | fputs()
Called by: | WriteHTMLAppendix() | html.c
| WriteHTMLDocument() | html.c
| WriteHTMLFile() | html.c
| WriteHTMLSource() | html.c

## Local Function WriteHTMLPreamble()

Write out a standard pre-amble.

`static void WriteHTMLPreamble ( FILE* f, char* title, int sourcefile )`

`FILE* f`
  The file to write the pre amble to.
`char* title`
  The title of the file.
`int sourcefile`
  True if the Source-Files line is to be included.

Prototyped in: | html.c
Calls: | fputs()
Called by: | WriteHTMLAppendix() | html.c
| WriteHTMLDocument() | html.c
| WriteHTMLFile() | html.c
| WriteHTMLSource() | html.c
References Variables: | option_html | cxref.c

## Local Function WriteHTMLStructUnion()

Write a structure / union structure out.

`static void WriteHTMLStructUnion ( StructUnion su, int depth )`

`StructUnion su`
  The structure / union to write.
`int depth`
  The current depth within the structure.

Prototyped in: | html.c
Calls: | WriteHTMLStructUnion() | html.c
| html() | html.c
| fprintf(), strstr()
Called by: | WriteHTMLStructUnion() | html.c
| WriteHTMLTypedef() | html.c
References Variables: | of | html.c
| option_html | cxref.c

## Local Function WriteHTMLSubInclude()

Write an Sub Include structure out. (An include structure that is included from another file.)

`static void WriteHTMLSubInclude ( Include inc, int depth )`

`Include inc`
  The Include structure to output.
`int depth`
  The depth of the include hierarchy.

Prototyped in: | html.c
Calls: | WriteHTMLSubInclude() | html.c
| html() | html.c
| fprintf()
Called by: | WriteHTMLInclude() | html.c
| WriteHTMLSubInclude() | html.c
References Variables: | goback | html.c
| of | html.c

## Local Function WriteHTMLTypedef()

Write a Typedef structure out.

`static void WriteHTMLTypedef ( Typedef type )`

`Typedef type`
  The Typedef structure to output.

Prototyped in: | html.c
Calls: | WriteHTMLStructUnion() | html.c
| html() | html.c
| fprintf(), strncmp()
Called by: | WriteHTMLFile() | html.c
References Variables: | filename | html.c
| of | html.c
| option_html | cxref.c

## Local Function WriteHTMLVariable()

Write a Variable structure out.

`static void WriteHTMLVariable ( Variable var )`

`Variable var`
  The Variable structure to output.

Prototyped in: | html.c
Calls: | html() | html.c
| fprintf()
Called by: | WriteHTMLFile() | html.c
References Variables: | filename | html.c
| goback | html.c
| of | html.c
| option_html | cxref.c

## Local Function html()

Make the input string safe to output as HTML ( not <, >, & or " ).

`static char* html ( char* c )`

`char* html`
  Returns a safe HTML string.
`char* c`
  A non-safe HTML string.

The function can only be called four times in each fprintf() since it returns one of only four static strings.

Prototyped in: | html.c
Calls: | CopyOrSkip() | warn-raw.c
| SafeFree() | memory.c
| SafeMalloc() | memory.c
| SafeRealloc() | memory.c
| strcpy(), strncpy()
Called by: | WriteHTMLAppendix() | html.c
| WriteHTMLDefine() | html.c
| WriteHTMLFile() | html.c
| WriteHTMLFilePart() | html.c
| WriteHTMLFunction() | html.c
| WriteHTMLInclude() | html.c
| WriteHTMLSource() | html.c
| WriteHTMLStructUnion() | html.c
| WriteHTMLSubInclude() | html.c
| WriteHTMLTypedef() | html.c
| WriteHTMLVariable() | html.c