<!DOCTYPE LINUXDOC SYSTEM>

<!-- This SGML file generated by cxref. -->
<!-- cxref program (c) Andrew M. Bishop 1995,96,97,98. -->

<article>

<title>Cross reference for xref.c of cxref.
<author>cxref

<sect>File xref.c
<bf>RCS Header: /home/amb/cxref/RCS/xref.c 1.15 1997/05/18 10:05:52 amb Exp </bf>
<p>

  C Cross Referencing &amp; Documentation tool. Version 1.4.
<newline>
  Cross referencing of functions.
<p>

<sect1>Included Files

<p>
<itemize>
<item><tt>#include &lt;stdlib.h&gt;</tt>
</itemize>
<itemize>
<item><tt>#include &lt;stdio.h&gt;</tt>
</itemize>
<itemize>
<item><tt>#include &lt;string.h&gt;</tt>
</itemize>
<itemize>
<item><tt>#include &lt;unistd.h&gt;</tt>
</itemize>
<itemize>
<item><tt>#include &quot;memory.h&quot;</tt>
</itemize>
<itemize>
<item><tt>#include &quot;datatype.h&quot;</tt>
</itemize>
<itemize>
<item><tt>#include &quot;cxref.h&quot;</tt>
<itemize>
<item><tt>#include &quot;datatype.h&quot;</tt>
</itemize>
</itemize>

<sect1>Preprocessor definitions

<p>
 The names of the function cross reference files. 
<p>
<tt>#define XREF_FUNC_FILE &quot;.function&quot;</tt><newline>
<p>
<tt>#define XREF_FUNC_BACKUP &quot;.function&tilde;&quot;</tt><newline>
<p>
 The names of the variable cross reference files. 
<p>
<tt>#define XREF_VAR_FILE &quot;.variable&quot;</tt><newline>
<p>
<tt>#define XREF_VAR_BACKUP &quot;.variable&tilde;&quot;</tt><newline>
<p>
 The names of the include cross reference files. 
<p>
<tt>#define XREF_INC_FILE &quot;.include&quot;</tt><newline>
<p>
<tt>#define XREF_INC_BACKUP &quot;.include&tilde;&quot;</tt><newline>
<p>
 The names of the type cross reference files. 
<p>
<tt>#define XREF_TYPE_FILE &quot;.typedef&quot;</tt><newline>
<p>
<tt>#define XREF_TYPE_BACKUP &quot;.typedef&tilde;&quot;</tt><newline>

<sect1>External Variables

<p>
<bf>option_odir</bf><newline>
 The name of the directory for the output. 
<p>
<tt>extern char* option_odir</tt><newline>
<descrip>
<tag>Defined in:</tag>
<itemize>
<item>option_odir</itemize>
</descrip>
<p>
<bf>option_name</bf><newline>
 The base name of the file for the output. 
<p>
<tt>extern char* option_name</tt><newline>
<descrip>
<tag>Defined in:</tag>
<itemize>
<item>option_name</itemize>
</descrip>
<p>
<bf>option_xref</bf><newline>
 The option for cross referencing. 
<p>
<tt>extern int option_xref</tt><newline>
<descrip>
<tag>Defined in:</tag>
<itemize>
<item>option_xref</itemize>
</descrip>
<p>
<bf>option_index</bf><newline>
 The option for indexing. 
<p>
<tt>extern int option_index</tt><newline>
<descrip>
<tag>Defined in:</tag>
<itemize>
<item>option_index</itemize>
</descrip>

<sect1>Global Function CreateAppendix()

<p>  Create the appendix of files, global functions, global variables and types.
<p>
<tt>void CreateAppendix ( StringList files, StringList2 funcs, StringList2 vars, StringList2 types )</tt><newline>
<descrip>
<tag><tt>StringList files</tt></tag>
The list of files to create.
<tag><tt>StringList2 funcs</tt></tag>
The list of functions to create.
<tag><tt>StringList2 vars</tt></tag>
The list of variables to create.
<tag><tt>StringList2 types</tt></tag>
The list of types to create.
</descrip>
<descrip>
<tag>Prototyped in:</tag>
<itemize>
<item>cxref.h
</itemize>
<tag>Calls:</tag>
<itemize>
<item>AddToStringList()  :  slist.c
<item>AddToStringList2()  :  slist.c
<item>ConcatStrings()  :  memory.c
<item>fclose(), fgets(), fopen(), fscanf(), strlen()
</itemize>
<tag>Called by:</tag>
<itemize>
<item>main()  :  cxref.c
</itemize>
<tag>References Variables:</tag>
<itemize>
<item>option_index  :  cxref.c
<item>option_name  :  cxref.c
<item>option_odir  :  cxref.c
</itemize>
</descrip>

<sect1>Global Function CrossReference()

<p>  Cross reference the functions, variables and includes that are used in this file
  with the global functions, variables and includes. The types that are defined are also listed here.
<p>
<tt>void CrossReference ( File file )</tt><newline>
<descrip>
<tag><tt>File file</tt></tag>
The file structure containing the information.
</descrip>
<descrip>
<tag>Prototyped in:</tag>
<itemize>
<item>cxref.h
</itemize>
<tag>Calls:</tag>
<itemize>
<item>AddToStringList()  :  slist.c
<item>ConcatStrings()  :  memory.c
<item>check_for_called()  :  xref.c
<item>check_for_caller()  :  xref.c
<item>check_for_var()  :  xref.c
<item>check_for_var_func()  :  xref.c
<item>fixup_extern_var()  :  xref.c
<item>exit(), fclose(), fgets(), fopen(), fprintf(), fputs(), fscanf(), rename(), strcmp(), unlink()
</itemize>
<tag>Called by:</tag>
<itemize>
<item>main()  :  cxref.c
</itemize>
<tag>References Variables:</tag>
<itemize>
<item>option_name  :  cxref.c
<item>option_odir  :  cxref.c
<item>option_xref  :  cxref.c
</itemize>
</descrip>

<sect1>Global Function CrossReferenceDelete()

<p>  Delete the named file from the cross reference database.
<p>
<tt>void CrossReferenceDelete ( char* name )</tt><newline>
<descrip>
<tag><tt>char* name</tt></tag>
The name of the file that is to be deleted.
</descrip>
<descrip>
<tag>Prototyped in:</tag>
<itemize>
<item>cxref.h
</itemize>
<tag>Calls:</tag>
<itemize>
<item>ConcatStrings()  :  memory.c
<item>fclose(), fgets(), fopen(), fprintf(), fputs(), fscanf(), rename(), strcmp(), unlink()
</itemize>
<tag>Called by:</tag>
<itemize>
<item>main()  :  cxref.c
</itemize>
<tag>References Variables:</tag>
<itemize>
<item>option_name  :  cxref.c
<item>option_odir  :  cxref.c
</itemize>
</descrip>

<sect1>Local Function check_for_called()

<p>  Check through all of the functions in this file to see if any of them are called or referenced.
<p>
<tt>static void check_for_called ( File file, char* called, char* caller, char* filename )</tt><newline>
<descrip>
<tag><tt>File file</tt></tag>
The file structure.
<tag><tt>char* called</tt></tag>
The function that is called.
<tag><tt>char* caller</tt></tag>
The function that the called function is called from.
<tag><tt>char* filename</tt></tag>
The file that the function is called from.
</descrip>
<descrip>
<tag>Prototyped in:</tag>
<itemize>
<item>xref.c
</itemize>
<tag>Calls:</tag>
<itemize>
<item>AddToStringList2()  :  slist.c
<item>strcmp()
</itemize>
<tag>Called by:</tag>
<itemize>
<item>CrossReference()  :  xref.c
</itemize>
</descrip>

<sect1>Local Function check_for_caller()

<p>  Check through all of the functions in this file to see if any of them are callers or referencers.
<p>
<tt>static void check_for_caller ( File file, char* called, char* filename )</tt><newline>
<descrip>
<tag><tt>File file</tt></tag>
The file structure.
<tag><tt>char* called</tt></tag>
The function that is called.
<tag><tt>char* filename</tt></tag>
The file that the called function is in.
</descrip>
<descrip>
<tag>Prototyped in:</tag>
<itemize>
<item>xref.c
</itemize>
<tag>Calls:</tag>
<itemize>
<item>SafeMallocString()  :  memory.c
<item>strcmp()
</itemize>
<tag>Called by:</tag>
<itemize>
<item>CrossReference()  :  xref.c
</itemize>
</descrip>

<sect1>Local Function check_for_var()

<p>  Check through all of the variables in this file to see if any of them are extern usage of others.
<p>
<tt>static void check_for_var ( File file, char* variable, char* filename, int scope, char* funcname )</tt><newline>
<descrip>
<tag><tt>File file</tt></tag>
The file structure.
<tag><tt>char* variable</tt></tag>
The global variable name.
<tag><tt>char* filename</tt></tag>
The file that the variable is used in.
<tag><tt>int scope</tt></tag>
The scope of the variable in the foreign file.
<tag><tt>char* funcname</tt></tag>
The name of a function that uses the variable.
</descrip>
<descrip>
<tag>Prototyped in:</tag>
<itemize>
<item>xref.c
</itemize>
<tag>Calls:</tag>
<itemize>
<item>AddToStringList2()  :  slist.c
<item>SafeMallocString()  :  memory.c
<item>strcmp()
</itemize>
<tag>Called by:</tag>
<itemize>
<item>CrossReference()  :  xref.c
</itemize>
</descrip>

<sect1>Local Function check_for_var_func()

<p>  Check through the function to see if it uses the variable, if func is NULL then check the file.
<p>
<tt>static int check_for_var_func ( File file, Variable var, Function func )</tt><newline>
<descrip>
<tag><tt>int check_for_var_func</tt></tag>
Returns 1 if the variable is referenced from the function or file.
<tag><tt>File file</tt></tag>
The file that the function belongs to.
<tag><tt>Variable var</tt></tag>
The variable that may be referenced.
<tag><tt>Function func</tt></tag>
The function that is to be checked.
</descrip>
<descrip>
<tag>Prototyped in:</tag>
<itemize>
<item>xref.c
</itemize>
<tag>Calls:</tag>
<itemize>
<item>AddToStringList2()  :  slist.c
<item>SafeFree()  :  memory.c
<item>SafeMallocString()  :  memory.c
<item>strcmp()
</itemize>
<tag>Called by:</tag>
<itemize>
<item>CrossReference()  :  xref.c
</itemize>
</descrip>

<sect1>Local Function fixup_extern_var()

<p>  We can only now put in the location of the external variables that we found were used.
  Previously we did not know the location of their global definition.
<p>
<tt>static void fixup_extern_var ( Variable var, StringList2 refs )</tt><newline>
<descrip>
<tag><tt>Variable var</tt></tag>
The list of variables for this file.
<tag><tt>StringList2 refs</tt></tag>
A list of variable references from a file or a function.
</descrip>
<descrip>
<tag>Prototyped in:</tag>
<itemize>
<item>xref.c
</itemize>
<tag>Calls:</tag>
<itemize>
<item>SafeFree()  :  memory.c
<item>SafeMallocString()  :  memory.c
<item>strcmp()
</itemize>
<tag>Called by:</tag>
<itemize>
<item>CrossReference()  :  xref.c
</itemize>
</descrip>

</article>
