test/pipe.c: Avoid printing hundreds of thousand output lines.
[AROS.git] / tools / cxref / file.c
blob9da060ebfd849d50f19df5af33bd879f47dc5765
1 /***************************************
2 $Header$
4 C Cross Referencing & Documentation tool. Version 1.4.
6 Sets up the top level File structure.
7 ******************/ /******************
8 Written by Andrew M. Bishop
10 This file Copyright 1995,96,97 Andrew M. Bishop
11 It may be distributed under the GNU Public License, version 2, or
12 any higher version. See section COPYING of the GNU Public license
13 for conditions under which this file may be redistributed.
14 ***************************************/
16 /*+ To control the debugging in this file. +*/
17 #define DEBUG 0
19 #include <stdlib.h>
20 #include <stdio.h>
21 #include <string.h>
23 #include "memory.h"
24 #include "datatype.h"
25 #include "cxref.h"
27 /*+ This contains the File that is currently being documented to allow the other functions access to it. +*/
28 extern File CurFile;
30 /*++++++++++++++++++++++++++++++++++++++
31 Creates a new File structure.
33 File NewFile Returns the new file structure.
35 char* name The name of the file.
36 ++++++++++++++++++++++++++++++++++++++*/
38 File NewFile(char* name)
40 File file=(File)Calloc(1,sizeof(struct _File));
42 file->name=MallocString(name);
43 file->inc_in=NewStringList();
44 file->f_refs=NewStringList2();
45 file->v_refs=NewStringList2();
47 return(file);
51 /*++++++++++++++++++++++++++++++++++++++
52 Called when a file comment has been seen. Only the first of multiple comments in a file are used.
54 char* comment The comment for the file.
55 ++++++++++++++++++++++++++++++++++++++*/
57 void SeenFileComment(char* comment)
59 if(!CurFile->comment)
60 CurFile->comment=MallocString(comment);
64 /*++++++++++++++++++++++++++++++++++++++
65 Deletes a file structure.
67 File file The file structure to be deleted.
69 This is required to go through each of the elements in the File structure and delete each of them in turn.
70 ++++++++++++++++++++++++++++++++++++++*/
72 void DeleteFile(File file)
74 if(file->comment) Free(file->comment);
75 if(file->name) Free(file->name);
77 if(file->inc_in) DeleteStringList(file->inc_in);
78 if(file->f_refs) DeleteStringList2(file->f_refs);
79 if(file->v_refs) DeleteStringList2(file->v_refs);
81 if(file->includes)
83 Include p=file->includes;
84 do{
85 Include n=p->next;
86 DeleteIncludeType(p);
87 p=n;
89 while(p);
92 if(file->defines)
94 Define p=file->defines;
95 do{
96 Define n=p->next;
97 DeleteDefineType(p);
98 p=n;
100 while(p);
103 if(file->typedefs)
105 Typedef p=file->typedefs;
107 Typedef n=p->next;
108 DeleteTypedefType(p);
109 p=n;
111 while(p);
114 if(file->variables)
116 Variable p=file->variables;
118 Variable n=p->next;
119 DeleteVariableType(p);
120 p=n;
122 while(p);
125 if(file->functions)
127 Function p=file->functions;
129 Function n=p->next;
130 DeleteFunctionType(p);
131 p=n;
133 while(p);
136 Free(file);