# File func.c

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

C Cross Referencing & Documentation tool. Version 1.5.
Handle Function 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 debugging information from this file.

`#define DEBUG 0`

## External Variables

option_xref
The current parsing options.

`extern int option_xref`

Defined in: | cxref.c

CurFile
The current file that is being processed.

`extern File CurFile`

Defined in: | cxref.c

in_header
When in a header file include functions from that file (except inline functions).

`extern int in_header`

Defined in: | preproc.c

## Local Variables

cur_func
The current function, this is initialised by the start of a possible declaration and maintained until all of the arguments have been added and confirmation that it is a definition and not a prototype is seen.

`static Function cur_func`

Used in: | CheckFunctionVariableRef()
| ResetFunctionAnalyser()
| SeenFuncIntComment()
| SeenFunctionArg()
| SeenFunctionCall()
| SeenFunctionDeclaration()
| SeenFunctionDefinition()
| SeenFunctionProto()

prototypes
The list of function prototypes and the files that they are defined in.

`static StringList2 prototypes`

Used in: | CheckFunctionVariableRef()
| ResetFunctionAnalyser()
| SeenFunctionDefinition()
| SeenFunctionProto()

## Global Function CheckFunctionVariableRef()

Function that is called when a function or variable is referenced in the current function.

`void CheckFunctionVariableRef ( char* name, int in_a_function )`

`char* name`
  The name of the function or variable that is referenced.
`int in_a_function`
  Whether the reference is from within a function or at the top level of the file.

Prototyped in: | cxref.h
Calls: | AddToStringList2() | slist.c
| IsAScopeVariable() | var.c
| strcmp()
Called by: | yyparse() | parse-yacc.c
References Variables: | CurFile | cxref.c
| cur_func | func.c
| option_xref | cxref.c
| prototypes | func.c

## Global Function DeleteFunctionType()

Delete the specified Function type.

`void DeleteFunctionType ( Function func )`

`Function func`
  The Function type to be deleted.

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

## Global Function ResetFunctionAnalyser()

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

`void ResetFunctionAnalyser ( void )`

Prototyped in: | cxref.h
Calls: | DeleteFunctionType() | func.c
| DeleteStringList2() | slist.c
Called by: | main() | cxref.c
References Variables: | CurFile | cxref.c
| cur_func | func.c
| prototypes | func.c

## Global Function SeenFuncIntComment()

Function that is called when a comment is seen, that may be in a function body.

`int SeenFuncIntComment ( char* comment )`

`int SeenFuncIntComment`
  Returns a true value if the comment was accepted as an function internal comment.
`char* comment`
  The comment that has been seen.

Prototyped in: | cxref.h
Calls: | ConcatStrings() | memory.c
| SafeFree() | memory.c
| SafeMallocString() | memory.c
Called by: | SeenComment() | comment.c
References Variables: | cur_func | func.c

## Global Function SeenFunctionArg()

Function that is called when a function argument is seen in the current function declaration.

`void SeenFunctionArg ( char* name, char* type )`

`char* name`
  The name of the argument.
`char* type`
  The type of the argument, or NULL if a traditional style function definition.

Prototyped in: | cxref.h
Calls: | AddToStringList2() | slist.c
| GetCurrentComment() | comment.c
| SafeFree() | memory.c
| SafeMallocString() | memory.c
| SplitComment() | comment.c
| strcmp()
Called by: | yyparse() | parse-yacc.c
References Variables: | cur_func | func.c

## Global Function SeenFunctionCall()

Function that is called when a function call is seen in the current function.

`void SeenFunctionCall ( char* name )`

`char* name`
  The name of the function that is called.

Prototyped in: | cxref.h
Calls: | AddToStringList2() | slist.c
Called by: | yyparse() | parse-yacc.c
References Variables: | cur_func | func.c
| option_xref | cxref.c

## Global Function SeenFunctionDeclaration()

Function that is called when a function declaration is seen. This may or may not be a function defintion, we will need to wait and see.

`void SeenFunctionDeclaration ( char* name, int scope )`

`char* name`
  The name of the function.
`int scope`
  The scope of the function definition.

Prototyped in: | cxref.h
Calls: | DeleteFunctionType() | func.c
| GetCurrentComment() | comment.c
| NewFunctionType() | func.c
| SafeMallocString() | memory.c
Called by: | yyparse() | parse-yacc.c
References Variables: | cur_func | func.c
| in_header | preproc.c
| parse_file | parse-lex.c
| parse_line | parse-lex.c

## Global Function SeenFunctionDefinition()

Called when a possible function definition is confirmed.

`void SeenFunctionDefinition ( char* type )`

`char* type`
  The type of the function, or NULL at the end of a definition.

Prototyped in: | cxref.h
Calls: | ConcatStrings() | memory.c
| GetCurrentComment() | comment.c
| SafeFree() | memory.c
| SafeMallocString() | memory.c
| SplitComment() | comment.c
| strchr(), strcmp()
Called by: | yyparse() | parse-yacc.c
References Variables: | CurFile | cxref.c
| cur_func | func.c
| option_xref | cxref.c
| prototypes | func.c

## Global Function SeenFunctionProto()

Function that is called when a function prototype is seen.

`void SeenFunctionProto ( char* name, int in_a_function )`

`char* name`
  The name of the function.
`int in_a_function`
  Whether the reference is from within a function or at the top level of the file.

Prototyped in: | cxref.h
Calls: | AddToStringList() | slist.c
| AddToStringList2() | slist.c
| NewStringList2() | slist.c
Called by: | yyparse() | parse-yacc.c
References Variables: | cur_func | func.c
| option_xref | cxref.c
| parse_file | parse-lex.c
| prototypes | func.c

## Local Function NewFunctionType()

Create a new Function Type variable.

`static Function NewFunctionType ( char* name, char* type )`

`Function NewFunctionType`
  Returns the new Function variable.
`char* name`
  The name of the function.
`char* type`
  The type of the function.

Prototyped in: | func.c
Calls: | NewStringList() | slist.c
| NewStringList2() | slist.c
| SafeCalloc() | memory.c
| SafeMallocString() | memory.c
Called by: | SeenFunctionDeclaration() | func.c