% This LaTeX file generated by cxref
% cxref program (c) Andrew M. Bishop 1995,96,97.

\markboth{File rtf.c}{File rtf.c}
\section{File rtf.c}
\label{file_rtf.c}

{\bf RCS Header: /home/amb/cxref/RCS/rtf.c 1.3 1999/01/11 19:34:07 amb Exp }

\smallskip

  C Cross Referencing \& Documentation tool. Version 1.5.

  Writes the RTF output.


\subsection*{Included Files}

\begin{cxreftabi}
{\stt \#include <stdlib.h>} &\\
\end{cxreftabi}

\medskip
\begin{cxreftabi}
{\stt \#include <stdio.h>} &\\
\end{cxreftabi}

\medskip
\begin{cxreftabi}
{\stt \#include <string.h>} &\\
\end{cxreftabi}

\medskip
\begin{cxreftabi}
{\stt \#include <sys/types.h>} &\\
\end{cxreftabi}

\medskip
\begin{cxreftabi}
{\stt \#include <sys/stat.h>} &\\
\end{cxreftabi}

\medskip
\begin{cxreftabi}
{\stt \#include <unistd.h>} &\\
\end{cxreftabi}

\medskip
\begin{cxreftabi}
{\stt \#include "memory.h"} &\cxreffile{memory.h}\\
\end{cxreftabi}

\medskip
\begin{cxreftabi}
{\stt \#include "datatype.h"} &\cxreffile{datatype.h}\\
\end{cxreftabi}

\medskip
\begin{cxreftabi}
{\stt \#include "cxref.h"} &\cxreffile{cxref.h}\\
\hspace*{0.2in}{\stt \#include "datatype.h"} &\cxreffile{datatype.h}\\
\end{cxreftabi}


\subsection*{Preprocessor definitions}

 The name of the output rtf file. 

\smallskip
{\stt \#define RTF\_FILE ".rtf"}

\medskip
{\stt \#define RTF\_FILE\_BACKUP ".rtf$\sim$"}

\medskip
 The name of the output rtf file that contains the appendix. 

\smallskip
{\stt \#define RTF\_APDX ".apdx"}

\medskip
{\stt \#define STYLE\_NORM "$\backslash$$\backslash$s0$\backslash$$\backslash$f0$\backslash$$\backslash$fs24"}

\medskip
{\stt \#define STYLE\_H1 "$\backslash$$\backslash$s1$\backslash$$\backslash$f0$\backslash$$\backslash$fs40$\backslash$$\backslash$b$\backslash$$\backslash$sb400$\backslash$$\backslash$sa200$\backslash$$\backslash$keepn$\backslash$$\backslash$keep"}

\medskip
{\stt \#define STYLE\_H2 "$\backslash$$\backslash$s2$\backslash$$\backslash$f0$\backslash$$\backslash$fs32$\backslash$$\backslash$b$\backslash$$\backslash$sb200$\backslash$$\backslash$sa100$\backslash$$\backslash$keepn$\backslash$$\backslash$keep"}

\medskip
{\stt \#define STYLE\_H3 "$\backslash$$\backslash$s3$\backslash$$\backslash$f0$\backslash$$\backslash$fs28$\backslash$$\backslash$b$\backslash$$\backslash$sb100$\backslash$$\backslash$sa100$\backslash$$\backslash$keepn$\backslash$$\backslash$keep"}

\medskip
{\stt \#define STYLE\_H4 "$\backslash$$\backslash$s4$\backslash$$\backslash$f0$\backslash$$\backslash$fs24$\backslash$$\backslash$b$\backslash$$\backslash$sb100$\backslash$$\backslash$sa50$\backslash$$\backslash$keepn$\backslash$$\backslash$keep"}

\medskip
{\stt \#define STYLE\_TT "$\backslash$$\backslash$s5$\backslash$$\backslash$f1$\backslash$$\backslash$fs20$\backslash$$\backslash$ql$\backslash$$\backslash$sb50$\backslash$$\backslash$sa50"}

\medskip
{\stt \#define STYLE\_IND "$\backslash$$\backslash$s6$\backslash$$\backslash$f0$\backslash$$\backslash$fs24$\backslash$$\backslash$ql$\backslash$$\backslash$li720"}


\subsection{Variables}


\subsubsection{External Variables}

{\bf option\_verbatim\_comments}
\label{var_option_verbatim_comments_rtf.c}

 The comments are to be inserted verbatim. 

\smallskip
{\stt extern int option\_verbatim\_comments}

\smallskip
\begin{cxreftabiii}
Defined in:& cxref.c & \ & \cxrefvar{option_verbatim_comments}{cxref.c}\\
\end{cxreftabiii}

\medskip
{\bf option\_odir}
\label{var_option_odir_rtf.c}

 The name of the directory for the output. 

\smallskip
{\stt extern char* option\_odir}

\smallskip
\begin{cxreftabiii}
Defined in:& cxref.c & \ & \cxrefvar{option_odir}{cxref.c}\\
\end{cxreftabiii}

\medskip
{\bf option\_name}
\label{var_option_name_rtf.c}

 The base name of the file for the output. 

\smallskip
{\stt extern char* option\_name}

\smallskip
\begin{cxreftabiii}
Defined in:& cxref.c & \ & \cxrefvar{option_name}{cxref.c}\\
\end{cxreftabiii}


\subsubsection{Local Variables}

{\bf of}
\label{var_of_rtf.c}

 The output file for the RTF. 

\smallskip
{\stt static FILE* of}

\smallskip
\begin{cxreftabiii}
Used in:\ & WriteRTFAppendix() & \ & \cxreffunc{WriteRTFAppendix}{rtf.c}\\
\ & WriteRTFDefine() & \ & \cxreffunc{WriteRTFDefine}{rtf.c}\\
\ & WriteRTFFile() & \ & \cxreffunc{WriteRTFFile}{rtf.c}\\
\ & WriteRTFFilePart() & \ & \cxreffunc{WriteRTFFilePart}{rtf.c}\\
\cxreftabbreak{cxreftabiii}
\ & WriteRTFFunction() & \ & \cxreffunc{WriteRTFFunction}{rtf.c}\\
\ & WriteRTFInclude() & \ & \cxreffunc{WriteRTFInclude}{rtf.c}\\
\cxreftabbreak{cxreftabiii}
\ & WriteRTFStructUnion() & \ & \cxreffunc{WriteRTFStructUnion}{rtf.c}\\
\ & WriteRTFSubInclude() & \ & \cxreffunc{WriteRTFSubInclude}{rtf.c}\\
\ & WriteRTFTypedef() & \ & \cxreffunc{WriteRTFTypedef}{rtf.c}\\
\ & WriteRTFVariable() & \ & \cxreffunc{WriteRTFVariable}{rtf.c}\\
\end{cxreftabiii}


\subsection{Functions}


\subsubsection{Global Function WriteRTFAppendix()}
\label{func_WriteRTFAppendix_rtf.c}

  Write out the appendix information.

\smallskip
{\stt void WriteRTFAppendix ( StringList files, StringList2 funcs, StringList2 vars, StringList2 types )}

\smallskip
\begin{cxrefarglist}
\cxrefargitem{StringList files} The list of files to write.
\cxrefargitem{StringList2 funcs} The list of functions to write.
\cxrefargitem{StringList2 vars} The list of variables to write.
\cxrefargitem{StringList2 types} The list of types to write.
\end{cxrefarglist}

\smallskip
\begin{cxreftabiii}
Prototype:& cxref.h & \ & \cxreffile{cxref.h}\\
Calls:\ & ConcatStrings() & memory.c & \cxreffunc{ConcatStrings}{memory.c}\\
\ & WriteRTFPostamble() & rtf.c & \cxreffunc{WriteRTFPostamble}{rtf.c}\\
\ & WriteRTFPreamble() & rtf.c & \cxreffunc{WriteRTFPreamble}{rtf.c}\\
\cxreftabbreak{cxreftabiii}
\ & rtf() & rtf.c & \cxreffunc{rtf}{rtf.c}\\
\ & \cxreftabiiispan{ exit(), fclose(), fopen(), fprintf(), strncmp()} &\\
Called by:\ & main() & cxref.c & \cxreffunc{main}{cxref.c}\\
Refs Var:\ & of & rtf.c & \cxrefvar{of}{rtf.c}\\
\ & option\_name & cxref.c & \cxrefvar{option_name}{cxref.c}\\
\ & option\_odir & cxref.c & \cxrefvar{option_odir}{cxref.c}\\
\end{cxreftabiii}


\subsubsection{Global Function WriteRTFFile()}
\label{func_WriteRTFFile_rtf.c}

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

\smallskip
{\stt void WriteRTFFile ( File file )}

\smallskip
\begin{cxrefarglist}
\cxrefargitem{File file} The File structure to output.
\end{cxrefarglist}

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

\smallskip
\begin{cxreftabiii}
Prototype:& cxref.h & \ & \cxreffile{cxref.h}\\
Calls:\ & ConcatStrings() & memory.c & \cxreffunc{ConcatStrings}{memory.c}\\
\ & WriteRTFDefine() & rtf.c & \cxreffunc{WriteRTFDefine}{rtf.c}\\
\ & WriteRTFFilePart() & rtf.c & \cxreffunc{WriteRTFFilePart}{rtf.c}\\
\cxreftabbreak{cxreftabiii}
\ & WriteRTFFunction() & rtf.c & \cxreffunc{WriteRTFFunction}{rtf.c}\\
\ & WriteRTFInclude() & rtf.c & \cxreffunc{WriteRTFInclude}{rtf.c}\\
\ & WriteRTFPostamble() & rtf.c & \cxreffunc{WriteRTFPostamble}{rtf.c}\\
\ & WriteRTFPreamble() & rtf.c & \cxreffunc{WriteRTFPreamble}{rtf.c}\\
\ & WriteRTFTypedef() & rtf.c & \cxreffunc{WriteRTFTypedef}{rtf.c}\\
\ & WriteRTFVariable() & rtf.c & \cxreffunc{WriteRTFVariable}{rtf.c}\\
\ & rtf() & rtf.c & \cxreffunc{rtf}{rtf.c}\\
\ & \cxreftabiiispan{ exit(), fclose(), fopen(), fprintf(), mkdir(), stat(), strlen()} &\\
Called by:\ & main() & cxref.c & \cxreffunc{main}{cxref.c}\\
\cxreftabbreak{cxreftabiii}
Refs Var:\ & of & rtf.c & \cxrefvar{of}{rtf.c}\\
\ & option\_odir & cxref.c & \cxrefvar{option_odir}{cxref.c}\\
\end{cxreftabiii}


\subsubsection{Global Function WriteRTFFileDelete()}
\label{func_WriteRTFFileDelete_rtf.c}

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

\smallskip
{\stt void WriteRTFFileDelete ( char* name )}

\smallskip
\begin{cxrefarglist}
\cxrefargitem{char* name} The name of the file to delete.
\end{cxrefarglist}

\smallskip
\begin{cxreftabiii}
Prototype:& cxref.h & \ & \cxreffile{cxref.h}\\
Calls:\ & ConcatStrings() & memory.c & \cxreffunc{ConcatStrings}{memory.c}\\
\ & \cxreftabiiispan{ unlink()} &\\
Called by:\ & main() & cxref.c & \cxreffunc{main}{cxref.c}\\
Refs Var:\ & option\_odir & cxref.c & \cxrefvar{option_odir}{cxref.c}\\
\cxreftabbreak{cxreftabiii}
\end{cxreftabiii}


\subsubsection{Local Function WriteRTFDefine()}
\label{func_WriteRTFDefine_rtf.c}

  Write a Define structure out.

\smallskip
{\stt static void WriteRTFDefine ( Define def )}

\smallskip
\begin{cxrefarglist}
\cxrefargitem{Define def} The Define structure to output.
\end{cxrefarglist}

\smallskip
\begin{cxreftabiii}
Prototype:& rtf.c & \ & \cxreffile{rtf.c}\\
Calls:\ & rtf() & rtf.c & \cxreffunc{rtf}{rtf.c}\\
\ & \cxreftabiiispan{ fprintf()} &\\
Called by:\ & WriteRTFFile() & rtf.c & \cxreffunc{WriteRTFFile}{rtf.c}\\
Refs Var:\ & of & rtf.c & \cxrefvar{of}{rtf.c}\\
\cxreftabbreak{cxreftabiii}
\end{cxreftabiii}


\subsubsection{Local Function WriteRTFFilePart()}
\label{func_WriteRTFFilePart_rtf.c}

  Write a File structure out.

\smallskip
{\stt static void WriteRTFFilePart ( File file )}

\smallskip
\begin{cxrefarglist}
\cxrefargitem{File file} The File to output.
\end{cxrefarglist}

\smallskip
\begin{cxreftabiii}
Prototype:& rtf.c & \ & \cxreffile{rtf.c}\\
Calls:\ & rtf() & rtf.c & \cxreffunc{rtf}{rtf.c}\\
\ & \cxreftabiiispan{ fprintf(), strstr()} &\\
Called by:\ & WriteRTFFile() & rtf.c & \cxreffunc{WriteRTFFile}{rtf.c}\\
Refs Var:\ & of & rtf.c & \cxrefvar{of}{rtf.c}\\
\cxreftabbreak{cxreftabiii}
\ & option\_verbatim\_comments & cxref.c & \cxrefvar{option_verbatim_comments}{cxref.c}\\
\end{cxreftabiii}


\subsubsection{Local Function WriteRTFFunction()}
\label{func_WriteRTFFunction_rtf.c}

  Write a Function structure out.

\smallskip
{\stt static void WriteRTFFunction ( Function func, char* filename )}

\smallskip
\begin{cxrefarglist}
\cxrefargitem{Function func} The Function structure to output.
\cxrefargitem{char* filename} The name of the file that is being processed (required for the cross reference label).
\end{cxrefarglist}

\smallskip
\begin{cxreftabiii}
Prototype:& rtf.c & \ & \cxreffile{rtf.c}\\
Calls:\ & rtf() & rtf.c & \cxreffunc{rtf}{rtf.c}\\
\ & \cxreftabiiispan{ fprintf(), strcmp(), strncmp(), strstr()} &\\
Called by:\ & WriteRTFFile() & rtf.c & \cxreffunc{WriteRTFFile}{rtf.c}\\
Refs Var:\ & of & rtf.c & \cxrefvar{of}{rtf.c}\\
\cxreftabbreak{cxreftabiii}
\ & option\_verbatim\_comments & cxref.c & \cxrefvar{option_verbatim_comments}{cxref.c}\\
\end{cxreftabiii}


\subsubsection{Local Function WriteRTFInclude()}
\label{func_WriteRTFInclude_rtf.c}

  Write an Include structure out.

\smallskip
{\stt static void WriteRTFInclude ( Include inc )}

\smallskip
\begin{cxrefarglist}
\cxrefargitem{Include inc} The Include structure to output.
\end{cxrefarglist}

\smallskip
\begin{cxreftabiii}
Prototype:& rtf.c & \ & \cxreffile{rtf.c}\\
Calls:\ & WriteRTFSubInclude() & rtf.c & \cxreffunc{WriteRTFSubInclude}{rtf.c}\\
\ & rtf() & rtf.c & \cxreffunc{rtf}{rtf.c}\\
\ & \cxreftabiiispan{ fprintf()} &\\
Called by:\ & WriteRTFFile() & rtf.c & \cxreffunc{WriteRTFFile}{rtf.c}\\
\cxreftabbreak{cxreftabiii}
Refs Var:\ & of & rtf.c & \cxrefvar{of}{rtf.c}\\
\end{cxreftabiii}


\subsubsection{Local Function WriteRTFPostamble()}
\label{func_WriteRTFPostamble_rtf.c}

  Write out the tail of an RTF file.

\smallskip
{\stt static void WriteRTFPostamble ( FILE* f )}

\smallskip
\begin{cxrefarglist}
\cxrefargitem{FILE* f} The file to write to.
\end{cxrefarglist}

\smallskip
\begin{cxreftabiii}
Prototype:& rtf.c & \ & \cxreffile{rtf.c}\\
Calls:\ & \cxreftabiiispan{ fputs()} &\\
Called by:\ & WriteRTFAppendix() & rtf.c & \cxreffunc{WriteRTFAppendix}{rtf.c}\\
\ & WriteRTFFile() & rtf.c & \cxreffunc{WriteRTFFile}{rtf.c}\\
\end{cxreftabiii}


\subsubsection{Local Function WriteRTFPreamble()}
\label{func_WriteRTFPreamble_rtf.c}

  Write out the head of an RTF file.

\smallskip
{\stt static void WriteRTFPreamble ( FILE* f )}

\smallskip
\begin{cxrefarglist}
\cxrefargitem{FILE* f} The file to write to.
\end{cxrefarglist}

\smallskip
\begin{cxreftabiii}
Prototype:& rtf.c & \ & \cxreffile{rtf.c}\\
Calls:\ & \cxreftabiiispan{ fputs(), strcmp()} &\\
Called by:\ & WriteRTFAppendix() & rtf.c & \cxreffunc{WriteRTFAppendix}{rtf.c}\\
\ & WriteRTFFile() & rtf.c & \cxreffunc{WriteRTFFile}{rtf.c}\\
\end{cxreftabiii}


\subsubsection{Local Function WriteRTFStructUnion()}
\label{func_WriteRTFStructUnion_rtf.c}

  Write a structure / union structure out.

\smallskip
{\stt static void WriteRTFStructUnion ( StructUnion su, int depth )}

\smallskip
\begin{cxrefarglist}
\cxrefargitem{StructUnion su} The structure / union to write.
\cxrefargitem{int depth} The current depth within the structure.
\end{cxrefarglist}

\smallskip
\begin{cxreftabiii}
Prototype:& rtf.c & \ & \cxreffile{rtf.c}\\
Calls:\ & WriteRTFStructUnion() & rtf.c & \cxreffunc{WriteRTFStructUnion}{rtf.c}\\
\ & rtf() & rtf.c & \cxreffunc{rtf}{rtf.c}\\
\ & \cxreftabiiispan{ fprintf(), strstr()} &\\
Called by:\ & WriteRTFStructUnion() & rtf.c & \cxreffunc{WriteRTFStructUnion}{rtf.c}\\
\cxreftabbreak{cxreftabiii}
\ & WriteRTFTypedef() & rtf.c & \cxreffunc{WriteRTFTypedef}{rtf.c}\\
Refs Var:\ & of & rtf.c & \cxrefvar{of}{rtf.c}\\
\end{cxreftabiii}


\subsubsection{Local Function WriteRTFSubInclude()}
\label{func_WriteRTFSubInclude_rtf.c}

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

\smallskip
{\stt static void WriteRTFSubInclude ( Include inc, int depth )}

\smallskip
\begin{cxrefarglist}
\cxrefargitem{Include inc} The Include structure to output.
\cxrefargitem{int depth} The depth of the include hierarchy.
\end{cxrefarglist}

\smallskip
\begin{cxreftabiii}
Prototype:& rtf.c & \ & \cxreffile{rtf.c}\\
Calls:\ & WriteRTFSubInclude() & rtf.c & \cxreffunc{WriteRTFSubInclude}{rtf.c}\\
\ & rtf() & rtf.c & \cxreffunc{rtf}{rtf.c}\\
\ & \cxreftabiiispan{ fprintf()} &\\
Called by:\ & WriteRTFInclude() & rtf.c & \cxreffunc{WriteRTFInclude}{rtf.c}\\
\cxreftabbreak{cxreftabiii}
\ & WriteRTFSubInclude() & rtf.c & \cxreffunc{WriteRTFSubInclude}{rtf.c}\\
Refs Var:\ & of & rtf.c & \cxrefvar{of}{rtf.c}\\
\end{cxreftabiii}


\subsubsection{Local Function WriteRTFTypedef()}
\label{func_WriteRTFTypedef_rtf.c}

  Write a Typedef structure out.

\smallskip
{\stt static void WriteRTFTypedef ( Typedef type, char* filename )}

\smallskip
\begin{cxrefarglist}
\cxrefargitem{Typedef type} The Typedef structure to output.
\cxrefargitem{char* filename} The name of the file that is being processed (required for the cross reference label).
\end{cxrefarglist}

\smallskip
\begin{cxreftabiii}
Prototype:& rtf.c & \ & \cxreffile{rtf.c}\\
Calls:\ & WriteRTFStructUnion() & rtf.c & \cxreffunc{WriteRTFStructUnion}{rtf.c}\\
\ & rtf() & rtf.c & \cxreffunc{rtf}{rtf.c}\\
\ & \cxreftabiiispan{ fprintf(), strncmp()} &\\
Called by:\ & WriteRTFFile() & rtf.c & \cxreffunc{WriteRTFFile}{rtf.c}\\
\cxreftabbreak{cxreftabiii}
Refs Var:\ & of & rtf.c & \cxrefvar{of}{rtf.c}\\
\end{cxreftabiii}


\subsubsection{Local Function WriteRTFVariable()}
\label{func_WriteRTFVariable_rtf.c}

  Write a Variable structure out.

\smallskip
{\stt static void WriteRTFVariable ( Variable var, char* filename )}

\smallskip
\begin{cxrefarglist}
\cxrefargitem{Variable var} The Variable structure to output.
\cxrefargitem{char* filename} The name of the file that is being processed (required for the cross reference label).
\end{cxrefarglist}

\smallskip
\begin{cxreftabiii}
Prototype:& rtf.c & \ & \cxreffile{rtf.c}\\
Calls:\ & rtf() & rtf.c & \cxreffunc{rtf}{rtf.c}\\
\ & \cxreftabiiispan{ fprintf()} &\\
Called by:\ & WriteRTFFile() & rtf.c & \cxreffunc{WriteRTFFile}{rtf.c}\\
Refs Var:\ & of & rtf.c & \cxrefvar{of}{rtf.c}\\
\cxreftabbreak{cxreftabiii}
\end{cxreftabiii}


\subsubsection{Local Function rtf()}
\label{func_rtf_rtf.c}

  Make the input string safe to output as RTF ( not $\backslash$, \{ or \} ).

\smallskip
{\stt static char* rtf ( char* c, int verbatim )}

\smallskip
\begin{cxrefarglist}
\cxrefargitem{char* rtf} Returns a safe RTF string.
\cxrefargitem{char* c} A non-safe RTF string.
\cxrefargitem{int verbatim} Set to true inside a verbatim environment.
\end{cxrefarglist}

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

\smallskip
\begin{cxreftabiii}
Prototype:& rtf.c & \ & \cxreffile{rtf.c}\\
Calls:\ & CopyOrSkip() & warn-raw.c & \cxreffunc{CopyOrSkip}{warn-raw.c}\\
\ & SafeFree() & memory.c & \cxreffunc{SafeFree}{memory.c}\\
\ & SafeMalloc() & memory.c & \cxreffunc{SafeMalloc}{memory.c}\\
\cxreftabbreak{cxreftabiii}
\ & SafeRealloc() & memory.c & \cxreffunc{SafeRealloc}{memory.c}\\
\ & \cxreftabiiispan{ strncpy()} &\\
Called by:\ & WriteRTFAppendix() & rtf.c & \cxreffunc{WriteRTFAppendix}{rtf.c}\\
\ & WriteRTFDefine() & rtf.c & \cxreffunc{WriteRTFDefine}{rtf.c}\\
\ & WriteRTFFile() & rtf.c & \cxreffunc{WriteRTFFile}{rtf.c}\\
\ & WriteRTFFilePart() & rtf.c & \cxreffunc{WriteRTFFilePart}{rtf.c}\\
\ & WriteRTFFunction() & rtf.c & \cxreffunc{WriteRTFFunction}{rtf.c}\\
\ & WriteRTFInclude() & rtf.c & \cxreffunc{WriteRTFInclude}{rtf.c}\\
\ & WriteRTFStructUnion() & rtf.c & \cxreffunc{WriteRTFStructUnion}{rtf.c}\\
\cxreftabbreak{cxreftabiii}
\ & WriteRTFSubInclude() & rtf.c & \cxreffunc{WriteRTFSubInclude}{rtf.c}\\
\ & WriteRTFTypedef() & rtf.c & \cxreffunc{WriteRTFTypedef}{rtf.c}\\
\ & WriteRTFVariable() & rtf.c & \cxreffunc{WriteRTFVariable}{rtf.c}\\
\end{cxreftabiii}

