1 | /*************************************** 2 | $Header: /home/amb/cxref/src/RCS/datatype.h 1.14 1999/01/24 16:53:48 amb Exp $ 3 | 4 | C Cross Referencing & Documentation tool. Version 1.5. 5 | 6 | Definition of the different variables types that are used. 7 | ******************/ /****************** 8 | Written by Andrew M. Bishop 9 | 10 | This file Copyright 1995,96,97,99 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 | ***************************************/ 15 | 16 | 17 | #ifndef DATA_TYPE_H 18 | #define DATA_TYPE_H /*+ To stop multiple inclusions. +*/ 19 | 20 | /*+ A pointer type to file information. +*/ 21 | typedef struct _File *File; 22 | 23 | /*+ A pointer type to #include information. +*/ 24 | typedef struct _Include *Include; 25 | 26 | /*+ A pointer type to #define information. +*/ 27 | typedef struct _Define *Define; 28 | 29 | /*+ A pointer type to typedef information. +*/ 30 | typedef struct _Typedef *Typedef; 31 | 32 | /*+ A pointer type to variable information. +*/ 33 | typedef struct _Variable *Variable; 34 | 35 | /*+ A pointer type to function information. +*/ 36 | typedef struct _Function *Function; 37 | 38 | /*+ A pointer type to struct and union information. +*/ 39 | typedef struct _StructUnion *StructUnion; 40 | 41 | /*+ A data structure to contain lists of strings, eg functions that are called. +*/ 42 | typedef struct _StringList 43 | { 44 | int n; /*+ The number of strings in the list. +*/ 45 | char** s; /*+ The strings. +*/ 46 | } 47 | *StringList; 48 | 49 | /*+ A data structure to contain two lists of strings, eg arguments and comments. +*/ 50 | typedef struct _StringList2 51 | { 52 | int n; /*+ The number of strings in the list. +*/ 53 | char** s1; /*+ The first set of strings. +*/ 54 | char** s2; /*+ The second set of strings. +*/ 55 | } 56 | *StringList2; 57 | 58 | 59 | /*+ A data structure to contain a complete file worth of information. +*/ 60 | struct _File 61 | { 62 | char* comment; /*+ The file comment. +*/ 63 | 64 | char* name; /*+ The name of the file. +*/ 65 | 66 | Include includes; /*+ A linked list of include files. +*/ 67 | 68 | Define defines; /*+ A linked list of #defines. +*/ 69 | 70 | Typedef typedefs; /*+ A linked list of type definitions. +*/ 71 | 72 | Variable variables; /*+ A linked list of variable definitions. +*/ 73 | 74 | Function functions; /*+ A linked list of function prototypes. +*/ 75 | 76 | StringList inc_in; /*+ The files that this file is included in. +*/ 77 | 78 | StringList2 f_refs; /*+ The functions that are referenced. +*/ 79 | StringList2 v_refs; /*+ The variables that are referenced. +*/ 80 | }; 81 | 82 | /*+ A data structure to contain information about a #include. +*/ 83 | struct _Include 84 | { 85 | char* comment; /*+ The comment for the include file. +*/ 86 | 87 | char* name; /*+ The name of the included file. +*/ 88 | 89 | int scope; /*+ The type of file, LOCAL or GLOBAL. +*/ 90 | 91 | Include includes; /*+ The files that are include by this file. +*/ 92 | 93 | Include next; /*+ A pointer to the next item. +*/ 94 | }; 95 | 96 | /*+ A data structure to contain information about a #define. +*/ 97 | struct _Define 98 | { 99 | char* comment; /*+ The comment for the #define. +*/ 100 | 101 | char* name; /*+ The name that is defined. +*/ 102 | char* value; /*+ The value that is defined (if simple). +*/ 103 | 104 | StringList2 args; /*+ The arguments to the #define function. +*/ 105 | 106 | int lineno; /*+ The line number that this definition appears on. +*/ 107 | 108 | Define next; /*+ A pointer to the next item. +*/ 109 | }; 110 | 111 | /*+ A data structure to contain the information for a typedef. +*/ 112 | struct _Typedef 113 | { 114 | char* comment; /*+ The comment for the type definition. +*/ 115 | 116 | char* name; /*+ The name of the defined type. +*/ 117 | 118 | char* type; /*+ The type of the definition. +*/ 119 | StructUnion sutype; /*+ The type of the definition if it is a locally declared struct / union. +*/ 120 | Typedef typexref; /*+ The type of the definition if it is not locally declared or a repeat definition. +*/ 121 | 122 | int lineno; /*+ The line number that this type definition appears on. +*/ 123 | 124 | Typedef next; /*+ A pointer to the next item. +*/ 125 | }; 126 | 127 | /*+ A data structure to contain the information for a variable. +*/ 128 | struct _Variable 129 | { 130 | char* comment; /*+ The comment for the variable. +*/ 131 | 132 | char* name; /*+ The name of the variable. +*/ 133 | 134 | char* type; /*+ The type of the variable. +*/ 135 | 136 | int scope; /*+ The scope of the variable, STATIC, GLOBAL or EXTERNAL +*/ 137 | 138 | char* defined; /*+ The name of the file that the variable is defined in as global if extern here. +*/ 139 | 140 | char* incfrom; /*+ The name of the file that the variable is included from if any. +*/ 141 | 142 | StringList2 visible; /*+ The names of the files that the variable is visible in. +*/ 143 | StringList2 used; /*+ The names of the files that the variable is used in. +*/ 144 | 145 | int lineno; /*+ The line number that this variable definition appears on. +*/ 146 | 147 | Variable next; /*+ A pointer to the next item. +*/ 148 | }; 149 | 150 | /*+ A data structure to contain information for a function definition. +*/ 151 | struct _Function 152 | { 153 | char* comment; /*+ The comment for the function. +*/ 154 | 155 | char* name; /*+ The name of the function. +*/ 156 | 157 | char* type; /*+ The return type of the function. +*/ 158 | char* cret; /*+ A comment for the returned value. +*/ 159 | 160 | char* protofile; /*+ The name of the file where the function is prototyped +*/ 161 | 162 | char* incfrom; /*+ The name of the file that the function is included from if any. +*/ 163 | 164 | StringList2 args; /*+ The arguments to the function. +*/ 165 | 166 | int scope; /*+ The scope of the function, LOCAL or GLOBAL. +*/ 167 | 168 | StringList protos; /*+ The functions that are prototyped within this function. +*/ 169 | 170 | StringList2 calls; /*+ The functions that are called from this function. +*/ 171 | StringList2 called; /*+ The names of the functions that call this one. +*/ 172 | StringList2 used; /*+ The places that the function is used, (references not direct calls). +*/ 173 | 174 | StringList2 v_refs; /*+ The variables that are referenced from this function. +*/ 175 | StringList2 f_refs; /*+ The functions that are referenced from this function. +*/ 176 | 177 | int lineno; /*+ The line number that this function definition appears on. +*/ 178 | 179 | Function next; /*+ A pointer to the next item. +*/ 180 | }; 181 | 182 | /*+ A data structure to contain a structure definition to allow structures to be matched to their typedefs (if any). +*/ 183 | struct _StructUnion 184 | { 185 | char* comment; /*+ The comment for the struct or union or simple component. +*/ 186 | 187 | char* name; /*+ The name of the struct or union or simple component. +*/ 188 | 189 | int n_comp; /*+ The number of sub-components (if none then it is simple). +*/ 190 | StructUnion* comps; /*+ The sub-components. +*/ 191 | }; 192 | 193 | 194 | /*++++++++++++++++++++++++++++++++++++++ 195 | A function to add a pointer to the end of a linked list. 196 | 197 | dst The destination, where the pointer is to be added to. 198 | 199 | type The type of the pointer. 200 | 201 | src The pointer that is to be added to the end of the linked list. 202 | ++++++++++++++++++++++++++++++++++++++*/ 203 | 204 | #define AddToLinkedList(dst,type,src) { \ 205 | if(dst) \ 206 | { \ 207 | type temp=dst; \ 208 | while(temp && temp->next) \ 209 | temp=temp->next; \ 210 | temp->next=src; \ 211 | } \ 212 | else \ 213 | dst=src; \ 214 | } 215 | #endif /* DATA_TYPE_H */