# File var.c

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

C Cross Referencing & Documentation tool. Version 1.5.
Collects the variable definition stuff.

## Included Files

- `#include <stdlib.h>`

- `#include <stdio.h>`

- `#include <string.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 from this file.

`#define DEBUG 0`

## External Variables

CurFile
The file that is currently being documented.

`extern File CurFile`

Defined in: | cxref.c

in_header
When in a header file make a note of which one for the included variables.

`extern int in_header`

Defined in: | preproc.c

## Local Variables

variable
A list of the variables found at each level of the scope.

`static StringList2* variable`

Used in: | DownScope()
| IsAScopeVariable()
| ResetVariableAnalyser()
| SeenScopeVariable()
| UpScope()

max_scope
The number of levels of scope depth allocated.

`static int max_scope`

Used in: | ResetVariableAnalyser()
| UpScope()

cur_scope
The current scope depth.

`static int cur_scope`

Used in: | DownScope()
| IsAScopeVariable()
| ResetVariableAnalyser()
| SeenScopeVariable()
| UpScope()

## Global Function DeleteVariableType()

Delete the specified Variable type.

`void DeleteVariableType ( Variable var )`

`Variable var`
  The Variable type to be deleted.

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

## Global Function DownScope()

Called when an old scope is exited.

`void DownScope ( void )`

Prototyped in: | cxref.h
Calls: | DeleteStringList2() | slist.c
Called by: | yyparse() | parse-yacc.c
References Variables: | cur_scope | var.c
| variable | var.c

## Global Function IsAScopeVariable()

Check through the scope variables to look for the named one.

`int IsAScopeVariable ( char* name )`

`int IsAScopeVariable`
  Returns 1 if the name does refer to a variable that is scoped.
`char* name`
  The name of the variable to search for.

Prototyped in: | cxref.h
Calls: | strcmp()
Called by: | CheckFunctionVariableRef() | func.c
| yylex() | parse-lex.c
| yyparse() | parse-yacc.c
References Variables: | cur_scope | var.c
| variable | var.c

## Global Function ResetVariableAnalyser()

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

`void ResetVariableAnalyser ( void )`

Prototyped in: | cxref.h
Calls: | DeleteStringList2() | slist.c
| SafeFree() | memory.c
Called by: | main() | cxref.c
References Variables: | cur_scope | var.c
| max_scope | var.c
| variable | var.c

## Global Function SeenScopeVariable()

Add a variable to the list of known variables.

`void SeenScopeVariable ( char* name )`

`char* name`
  The name of the variable.

Prototyped in: | cxref.h
Calls: | AddToStringList2() | slist.c
Called by: | yyparse() | parse-yacc.c
References Variables: | cur_scope | var.c
| variable | var.c

## Global Function SeenVariableDefinition()

Function that is called when a variable definition is seen.

`void SeenVariableDefinition ( char* name, char* type, int scope )`

`char* name`
  The name of the variable.
`char* type`
  The type of the variable.
`int scope`
  The scope of variable that has been seen.

Prototyped in: | cxref.h
Calls: | GetCurrentComment() | comment.c
| NewVariableType() | var.c
| SafeFree() | memory.c
| SafeMallocString() | memory.c
| strcmp()
Called by: | yyparse() | parse-yacc.c
References Variables: | CurFile | cxref.c
| in_header | preproc.c
| parse_file | parse-lex.c
| parse_line | parse-lex.c

## Global Function UpScope()

Called when a new scope is entered.

`void UpScope ( void )`

Prototyped in: | cxref.h
Calls: | NewStringList2() | slist.c
| SafeMalloc() | memory.c
| SafeRealloc() | memory.c
Called by: | yyparse() | parse-yacc.c
References Variables: | cur_scope | var.c
| max_scope | var.c
| variable | var.c

## Local Function NewVariableType()

Create a new variable type.

`static Variable NewVariableType ( char* name, char* type )`

`Variable NewVariableType`
  Returns a new Variable type.
`char* name`
  The name of the variable.
`char* type`
  The type of the variable.

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