# File preproc.c

RCS Header: /home/amb/cxref/RCS/preproc.c 1.16 1999/01/24 16:53:49 amb Exp

C Cross Referencing & Documentation tool. Version 1.5.
Collects the pre-processing instruction stuff.

## Included Files

- `#include <stdlib.h>`

- `#include <stdio.h>`

- `#include <string.h>`

- `#include <unistd.h>`

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

- `#include "memory.h"`

- `#include "datatype.h"`

- `#include "parse-yy.h"`
  - `#include <stdio.h>`
  - `#include <stdlib.h>`

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

## Preprocessor definitions

Control the output of debugging information for this file.

`#define DEBUG 0`

## Global Variable in_header

When in a header file, this is set to 1, to allow most of the stuff to be skipped.

`int in_header`

Visible in: |  | func.c
|  | parse-lex.c
|  | parse-yacc.c
|  | preproc.c
|  | var.c
Used in: | ResetPreProcAnalyser() | preproc.c
| SeenFileChange() | preproc.c
| SeenFunctionDeclaration() | func.c
| SeenVariableDefinition() | var.c
| yylex() | parse-lex.c
| yyparse() | parse-yacc.c

## External Variables

CurFile
The file that is currently being processed.

`extern File CurFile`

Defined in: | cxref.c

option_incdirs
The name of the include directories specified on the command line.

`extern char** option_incdirs`

Defined in: | cxref.c

option_nincdirs
The number of include directories on the command line.

`extern int option_nincdirs`

Defined in: | cxref.c

## Local Variables

cur_inc
The current #include we are looking at.

`static Include cur_inc`

Used in: | ResetPreProcAnalyser()
| SeenFileChange()
| SeenInclude()
| SeenIncludeComment()

cur_def
The current #define we are looking at.

`static Define cur_def`

Used in: | ResetPreProcAnalyser()
| SeenDefine()
| SeenDefineComment()
| SeenDefineFuncArgComment()
| SeenDefineFunctionArg()
| SeenDefineValue()

inc_depth
The depth of includes.

`static int inc_depth`

Used in: | ResetPreProcAnalyser()
| SeenFileChange()
| SeenInclude()

inc_type
The type of include at this depth.

`static char* inc_type`

Used in: | ResetPreProcAnalyser()
| SeenFileChange()
| SeenInclude()

cwd
The working directory.

`static char* cwd`

Used in: | ResetPreProcAnalyser()
| SeenFileChange()

## Global Function DeleteDefineType()

Delete the specified Define type.

`void DeleteDefineType ( Define def )`

`Define def`
  The Define type to be deleted.

Prototyped in: | cxref.h
Calls: | DeleteStringList2() | slist.c
| SafeFree() | memory.c
Called by: | DeleteFile() | file.c

## Global Function DeleteIncludeType()

Delete the specified Include type.

`void DeleteIncludeType ( Include inc )`

`Include inc`
  The Include type to be deleted.

Prototyped in: | cxref.h
Calls: | DeleteIncludeType() | preproc.c
| SafeFree() | memory.c
Called by: | DeleteFile() | file.c
| DeleteIncludeType() | preproc.c

## Global Function ResetPreProcAnalyser()

Tidy up all of the local variables in case of a problem and abnormal parser termination.

`void ResetPreProcAnalyser ( void )`

Prototyped in: | cxref.h
Calls: | SafeFree() | memory.c
Called by: | main() | cxref.c
References Variables: | cur_def | preproc.c
| cur_inc | preproc.c
| cwd | preproc.c
| in_header | preproc.c
| inc_depth | preproc.c
| inc_type | preproc.c

## Global Function SeenDefine()

Function that is called when a #define is seen in the current file.

`void SeenDefine ( char* name )`

`char* name`
  The name of the #defined symbol.

Prototyped in: | cxref.h
Calls: | GetCurrentComment() | comment.c
| NewDefineType() | preproc.c
| SafeMallocString() | memory.c
Called by: | yylex() | parse-lex.c
References Variables: | CurFile | cxref.c
| cur_def | preproc.c
| parse_line | parse-lex.c

## Global Function SeenDefineComment()

Function that is called when a comment is seen in a #define definition.

`void SeenDefineComment ( void )`

Prototyped in: | cxref.h
Calls: | GetCurrentComment() | comment.c
| SafeMallocString() | memory.c
Called by: | yylex() | parse-lex.c
References Variables: | cur_def | preproc.c

## Global Function SeenDefineFuncArgComment()

Function that is called when a comment is seen in a #define function definition.

`void SeenDefineFuncArgComment ( void )`

Prototyped in: | cxref.h
Calls: | GetCurrentComment() | comment.c
| SafeMallocString() | memory.c
Called by: | yylex() | parse-lex.c
References Variables: | cur_def | preproc.c

## Global Function SeenDefineFunctionArg()

Function that is called when a #define function argument is seen in the current definition.

`void SeenDefineFunctionArg ( char* name )`

`char* name`
  The argument.

Prototyped in: | cxref.h
Calls: | AddToStringList2() | slist.c
| SplitComment() | comment.c
Called by: | yylex() | parse-lex.c
References Variables: | cur_def | preproc.c

## Global Function SeenDefineValue()

Function that is called when a #define value is seen in the current file.

`void SeenDefineValue ( char* value )`

`char* value`
  The value of the #defined symbol.

Prototyped in: | cxref.h
Calls: | SafeMallocString() | memory.c
Called by: | yylex() | parse-lex.c
References Variables: | cur_def | preproc.c

## Global Function SeenFileChange()

Function that is called when a change in current file is seen.

`void SeenFileChange ( char* name, int flag )`

`char* name`
  The pathname of the included file as determined by gcc.
`int flag`
  The flags that GCC leaves in the file

Prototyped in: | cxref.h
Calls: | CanonicaliseName() | cxref.c
| ConcatStrings() | memory.c
| SafeFree() | memory.c
| SafeMalloc() | memory.c
| SafeMallocString() | memory.c
| SafeRealloc() | memory.c
| SeenInclude() | preproc.c
| SetCurrentComment() | comment.c
| getcwd(), strlen(), strncmp()
Called by: | yylex() | parse-lex.c
References Variables: | cur_inc | preproc.c
| cwd | preproc.c
| in_header | preproc.c
| inc_depth | preproc.c
| inc_type | preproc.c

## Global Function SeenInclude()

Function that is called when an included file is seen in the current file.

`void SeenInclude ( char* name )`

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

Prototyped in: | cxref.h
Calls: | CanonicaliseName() | cxref.c
| ConcatStrings() | memory.c
| GetCurrentComment() | comment.c
| NewIncludeType() | preproc.c
| SafeMallocString() | memory.c
| lstat(), strlen()
Called by: | SeenFileChange() | preproc.c
| yylex() | parse-lex.c
References Variables: | CurFile | cxref.c
| cur_inc | preproc.c
| inc_depth | preproc.c
| inc_type | preproc.c
| option_incdirs | cxref.c
| option_nincdirs | cxref.c

## Global Function SeenIncludeComment()

Function that is called when a comment is seen following a #include.

`void SeenIncludeComment ( void )`

Prototyped in: | cxref.h
Calls: | GetCurrentComment() | comment.c
| SafeMallocString() | memory.c
Called by: | yylex() | parse-lex.c
References Variables: | cur_inc | preproc.c

## Local Function NewDefineType()

Create a new Define datatype.

`static Define NewDefineType ( char* name )`

`Define NewDefineType`
  Return the new Define type.
`char* name`
  The name of the new define.

Prototyped in: | preproc.c
Calls: | NewStringList2() | slist.c
| SafeCalloc() | memory.c
| SafeMallocString() | memory.c
Called by: | SeenDefine() | preproc.c

## Local Function NewIncludeType()

Create a new Include datatype.

`static Include NewIncludeType ( char* name )`

`Include NewIncludeType`
  Return the new Include type.
`char* name`
  The name of the new include.

Prototyped in: | preproc.c
Calls: | SafeCalloc() | memory.c
| SafeMallocString() | memory.c
Called by: | SeenInclude() | preproc.c