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 *, struct ECPGtype *, struct ECPGstruct_member **); |
37 | struct ECPGtype *ECPGmake_simple_type(enum ECPGttype, char *, int); |
38 | struct ECPGtype *ECPGmake_array_type(struct ECPGtype *, char *); |
39 | struct ECPGtype *ECPGmake_struct_type(struct ECPGstruct_member *, enum ECPGttype, char *, char *); |
40 | struct ECPGstruct_member *ECPGstruct_member_dup(struct ECPGstruct_member *); |
41 | |
42 | /* Frees a type. */ |
43 | void ECPGfree_struct_member(struct ECPGstruct_member *); |
44 | void ECPGfree_type(struct ECPGtype *); |
45 | |
46 | /* Dump a type. |
47 | The type is dumped as: |
48 | type-tag <comma> reference-to-variable <comma> arrsize <comma> size <comma> |
49 | Where: |
50 | type-tag is one of the simple types or varchar. |
51 | reference-to-variable can be a reference to a struct element. |
52 | arrsize is the size of the array in case of array fetches. Otherwise 0. |
53 | size is the maxsize in case it is a varchar. Otherwise it is the size of |
54 | the variable (required to do array fetches of structs). |
55 | */ |
56 | void ECPGdump_a_type(FILE *, const char *, struct ECPGtype *, const int, |
57 | const char *, struct ECPGtype *, const int, |
58 | const char *, const char *, char *, |
59 | const char *, const char *); |
60 | |
61 | /* A simple struct to keep a variable and its type. */ |
62 | struct ECPGtemp_type |
63 | { |
64 | struct ECPGtype *type; |
65 | const char *name; |
66 | }; |
67 | |
68 | extern const char *ecpg_type_name(enum ECPGttype type); |
69 | |
70 | /* some stuff for whenever statements */ |
71 | enum WHEN_TYPE |
72 | { |
73 | W_NOTHING, |
74 | W_CONTINUE, |
75 | W_BREAK, |
76 | W_SQLPRINT, |
77 | W_GOTO, |
78 | W_DO, |
79 | W_STOP |
80 | }; |
81 | |
82 | struct when |
83 | { |
84 | enum WHEN_TYPE code; |
85 | char *command; |
86 | char *str; |
87 | }; |
88 | |
89 | struct index |
90 | { |
91 | char *index1; |
92 | char *index2; |
93 | char *str; |
94 | }; |
95 | |
96 | struct su_symbol |
97 | { |
98 | char *su; |
99 | char *symbol; |
100 | }; |
101 | |
102 | struct prep |
103 | { |
104 | char *name; |
105 | char *stmt; |
106 | char *type; |
107 | }; |
108 | |
109 | struct exec |
110 | { |
111 | char *name; |
112 | char *type; |
113 | }; |
114 | |
115 | struct this_type |
116 | { |
117 | enum ECPGttype type_enum; |
118 | char *type_str; |
119 | char *type_dimension; |
120 | char *type_index; |
121 | char *type_sizeof; |
122 | }; |
123 | |
124 | struct _include_path |
125 | { |
126 | char *path; |
127 | struct _include_path *next; |
128 | }; |
129 | |
130 | struct cursor |
131 | { |
132 | char *name; |
133 | char *function; |
134 | char *command; |
135 | char *connection; |
136 | bool opened; |
137 | struct arguments *argsinsert; |
138 | struct arguments *argsinsert_oos; |
139 | struct arguments *argsresult; |
140 | struct arguments *argsresult_oos; |
141 | struct cursor *next; |
142 | }; |
143 | |
144 | struct typedefs |
145 | { |
146 | char *name; |
147 | struct this_type *type; |
148 | struct ECPGstruct_member *struct_member_list; |
149 | int brace_level; |
150 | struct typedefs *next; |
151 | }; |
152 | |
153 | struct _defines |
154 | { |
155 | char *olddef; |
156 | char *newdef; |
157 | int pertinent; |
158 | void *used; |
159 | struct _defines *next; |
160 | }; |
161 | |
162 | /* This is a linked list of the variable names and types. */ |
163 | struct variable |
164 | { |
165 | char *name; |
166 | struct ECPGtype *type; |
167 | int brace_level; |
168 | struct variable *next; |
169 | }; |
170 | |
171 | struct arguments |
172 | { |
173 | struct variable *variable; |
174 | struct variable *indicator; |
175 | struct arguments *next; |
176 | }; |
177 | |
178 | struct descriptor |
179 | { |
180 | char *name; |
181 | char *connection; |
182 | struct descriptor *next; |
183 | }; |
184 | |
185 | struct assignment |
186 | { |
187 | char *variable; |
188 | enum ECPGdtype value; |
189 | struct assignment *next; |
190 | }; |
191 | |
192 | enum errortype |
193 | { |
194 | ET_WARNING, ET_ERROR |
195 | }; |
196 | |
197 | struct fetch_desc |
198 | { |
199 | char *str; |
200 | char *name; |
201 | }; |
202 | |
203 | #endif /* _ECPG_PREPROC_TYPE_H */ |
204 | |