Debian Codegraph @

src/interfaces/ecpg/preproc/type.h

raw
1 /*
2 * src/interfaces/ecpg/preproc/type.h
3 */
4 #ifndef _ECPG_PREPROC_TYPE_H
5 #define _ECPG_PREPROC_TYPE_H
6
7 #include "ecpgtype.h"
8
9 struct ECPGtype;
10 struct ECPGstruct_member
11 {
12 char *name;
13 struct ECPGtype *type;
14 struct ECPGstruct_member *next;
15 };
16
17 struct ECPGtype
18 {
19 enum ECPGttype type;
20 char *type_name; /* For struct and union types it is the struct
21 * name */
22 char *size; /* For array it is the number of elements. For
23 * varchar it is the maxsize of the area. */
24 char *struct_sizeof; /* For a struct this is the sizeof() type as
25 * string */
26 union
27 {
28 struct ECPGtype *element; /* For an array this is the type of the
29 * element */
30 struct ECPGstruct_member *members; /* A pointer to a list of members. */
31 } u;
32 int counter;
33 };
34
35 /* Everything is malloced. */
36 void ECPGmake_struct_member(const char *name, struct ECPGtype *type,
37 struct ECPGstruct_member **start);
38 struct ECPGtype *ECPGmake_simple_type(enum ECPGttype type, const char *size, int counter);
39 struct ECPGtype *ECPGmake_array_type(struct ECPGtype *type, const char *size);
40 struct ECPGtype *ECPGmake_struct_type(struct ECPGstruct_member *rm,
41 enum ECPGttype type,
42 const char *type_name,
43 const char *struct_sizeof);
44 struct ECPGstruct_member *ECPGstruct_member_dup(struct ECPGstruct_member *rm);
45
46 /* Frees a type. */
47 void ECPGfree_struct_member(struct ECPGstruct_member *rm);
48 void ECPGfree_type(struct ECPGtype *type);
49
50 /* Dump a type.
51 The type is dumped as:
52 type-tag <comma> reference-to-variable <comma> arrsize <comma> size <comma>
53 Where:
54 type-tag is one of the simple types or varchar.
55 reference-to-variable can be a reference to a struct element.
56 arrsize is the size of the array in case of array fetches. Otherwise 0.
57 size is the maxsize in case it is a varchar. Otherwise it is the size of
58 the variable (required to do array fetches of structs).
59 */
60 void ECPGdump_a_type(FILE *o, const char *name, struct ECPGtype *type,
61 const int brace_level, const char *ind_name,
62 struct ECPGtype *ind_type, const int ind_brace_level,
63 const char *prefix, const char *ind_prefix,
64 char *arr_str_size, const char *struct_sizeof,
65 const char *ind_struct_sizeof);
66
67 /* A simple struct to keep a variable and its type. */
68 struct ECPGtemp_type
69 {
70 struct ECPGtype *type;
71 const char *name;
72 };
73
74 extern const char *ecpg_type_name(enum ECPGttype type);
75
76 /* some stuff for whenever statements */
77 enum WHEN_TYPE
78 {
79 W_NOTHING,
80 W_CONTINUE,
81 W_BREAK,
82 W_SQLPRINT,
83 W_GOTO,
84 W_DO,
85 W_STOP
86 };
87
88 struct when
89 {
90 enum WHEN_TYPE code;
91 char *command;
92 char *str;
93 };
94
95 struct index
96 {
97 const char *index1;
98 const char *index2;
99 const char *str;
100 };
101
102 struct su_symbol
103 {
104 const char *su;
105 const char *symbol;
106 };
107
108 struct prep
109 {
110 const char *name;
111 const char *stmt;
112 const char *type;
113 };
114
115 struct exec
116 {
117 const char *name;
118 const char *type;
119 };
120
121 struct this_type
122 {
123 char *type_storage;
124 enum ECPGttype type_enum;
125 char *type_str;
126 char *type_dimension;
127 char *type_index;
128 char *type_sizeof;
129 };
130
131 struct _include_path
132 {
133 char *path;
134 struct _include_path *next;
135 };
136
137 struct cursor
138 {
139 char *name;
140 char *function;
141 char *command;
142 char *connection;
143 bool opened;
144 struct arguments *argsinsert;
145 struct arguments *argsinsert_oos;
146 struct arguments *argsresult;
147 struct arguments *argsresult_oos;
148 struct cursor *next;
149 };
150
151 struct declared_list
152 {
153 char *name;
154 char *connection;
155 struct declared_list *next;
156 };
157
158 struct typedefs
159 {
160 char *name;
161 struct this_type *type;
162 struct ECPGstruct_member *struct_member_list;
163 int brace_level;
164 struct typedefs *next;
165 };
166
167 /*
168 * Info about a defined symbol (macro), coming from a -D command line switch
169 * or a define command in the program. These are stored in a simple list.
170 * Because ecpg supports compiling multiple files per run, we have to remember
171 * the command-line definitions and be able to revert to those; this motivates
172 * storing cmdvalue separately from value.
173 * name and value are separately-malloc'd strings; cmdvalue typically isn't.
174 * used is NULL unless we are currently expanding the macro, in which case
175 * it points to the buffer before the one scanning the macro; we reset it
176 * to NULL upon returning to that buffer. This is used to prevent recursive
177 * expansion of the macro.
178 */
179 struct _defines
180 {
181 char *name; /* symbol's name */
182 char *value; /* current value, or NULL if undefined */
183 const char *cmdvalue; /* value set on command line, or NULL */
184 void *used; /* buffer pointer, or NULL */
185 struct _defines *next; /* list link */
186 };
187
188 /* This is a linked list of the variable names and types. */
189 struct variable
190 {
191 char *name;
192 struct ECPGtype *type;
193 int brace_level;
194 struct variable *next;
195 };
196
197 struct arguments
198 {
199 struct variable *variable;
200 struct variable *indicator;
201 struct arguments *next;
202 };
203
204 struct descriptor
205 {
206 char *name;
207 char *connection;
208 struct descriptor *next;
209 };
210
211 struct assignment
212 {
213 char *variable;
214 enum ECPGdtype value;
215 struct assignment *next;
216 };
217
218 enum errortype
219 {
220 ET_WARNING, ET_ERROR
221 };
222
223 struct fetch_desc
224 {
225 const char *str;
226 const char *name;
227 };
228
229 struct describe
230 {
231 int input;
232 const char *stmt_name;
233 };
234
235 #endif /* _ECPG_PREPROC_TYPE_H */