File: file.c

package info (click to toggle)
cxref 1.5c-9
  • links: PTS
  • area: main
  • in suites: woody
  • size: 1,504 kB
  • ctags: 1,359
  • sloc: ansic: 16,721; yacc: 1,930; sh: 722; lex: 416; makefile: 345; lisp: 256; python: 80; perl: 78
file content (137 lines) | stat: -rw-r--r-- 3,000 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/***************************************
  $Header: /home/amb/cxref/RCS/file.c 1.10 1997/05/17 15:06:01 amb Exp $

  C Cross Referencing & Documentation tool. Version 1.4.

  Sets up the top level File structure.
  ******************/ /******************
  Written by Andrew M. Bishop

  This file Copyright 1995,96,97 Andrew M. Bishop
  It may be distributed under the GNU Public License, version 2, or
  any higher version.  See section COPYING of the GNU Public license
  for conditions under which this file may be redistributed.
  ***************************************/

/*+ To control the debugging in this file. +*/
#define DEBUG 0

#include <stdlib.h>
#include <stdio.h>
#include <string.h>

#include "memory.h"
#include "datatype.h"
#include "cxref.h"

/*+ This contains the File that is currently being documented to allow the other functions access to it. +*/
extern File CurFile;

/*++++++++++++++++++++++++++++++++++++++
  Creates a new File structure.

  File NewFile Returns the new file structure.

  char* name The name of the file.
  ++++++++++++++++++++++++++++++++++++++*/

File NewFile(char* name)
{
 File file=(File)Calloc(1,sizeof(struct _File));

 file->name=MallocString(name);
 file->inc_in=NewStringList();
 file->f_refs=NewStringList2();
 file->v_refs=NewStringList2();

 return(file);
}


/*++++++++++++++++++++++++++++++++++++++
  Called when a file comment has been seen. Only the first of multiple comments in a file are used.

  char* comment The comment for the file.
  ++++++++++++++++++++++++++++++++++++++*/

void SeenFileComment(char* comment)
{
 if(!CurFile->comment)
    CurFile->comment=MallocString(comment);
}


/*++++++++++++++++++++++++++++++++++++++
  Deletes a file structure.

  File file The file structure to be deleted.

  This is required to go through each of the elements in the File structure and delete each of them in turn.
  ++++++++++++++++++++++++++++++++++++++*/

void DeleteFile(File file)
{
 if(file->comment) Free(file->comment);
 if(file->name)    Free(file->name);

 if(file->inc_in)  DeleteStringList(file->inc_in);
 if(file->f_refs)  DeleteStringList2(file->f_refs);
 if(file->v_refs)  DeleteStringList2(file->v_refs);

 if(file->includes)
   {
    Include p=file->includes;
    do{
       Include n=p->next;
       DeleteIncludeType(p);
       p=n;
      }
    while(p);
   }

 if(file->defines)
   {
    Define p=file->defines;
    do{
       Define n=p->next;
       DeleteDefineType(p);
       p=n;
      }
    while(p);
   }

 if(file->typedefs)
   {
    Typedef p=file->typedefs;
    do{
       Typedef n=p->next;
       DeleteTypedefType(p);
       p=n;
      }
    while(p);
   }

 if(file->variables)
   {
    Variable p=file->variables;
    do{
       Variable n=p->next;
       DeleteVariableType(p);
       p=n;
      }
    while(p);
   }

 if(file->functions)
   {
    Function p=file->functions;
    do{
       Function n=p->next;
       DeleteFunctionType(p);
       p=n;
      }
    while(p);
   }

 Free(file);
}