]> granicus.if.org Git - postgresql/blob - src/interfaces/ecpg/preproc/type.h
94c1e56f532c023eaf97cd8bdcca77797a84c145
[postgresql] / src / interfaces / ecpg / preproc / type.h
1 #ifndef _ECPG_PREPROC_TYPE_H
2 #define _ECPG_PREPROC_TYPE_H
3
4 #include "ecpgtype.h"
5
6 struct ECPGtype;
7 struct ECPGstruct_member
8 {
9         char       *name;
10         struct ECPGtype *type;
11         struct ECPGstruct_member *next;
12 };
13
14 struct ECPGtype
15 {
16         enum ECPGttype type;
17         char       *size;                       /* For array it is the number of elements. For
18                                                                  * varchar it is the maxsize of the area. */
19         char       *struct_sizeof;      /* For a struct this is the sizeof() type as
20                                                                  * string */
21         union
22         {
23                 struct ECPGtype *element;               /* For an array this is the type of
24                                                                                  * the element */
25                 struct ECPGstruct_member *members;              /* A pointer to a list of
26                                                                                                  * members. */
27         }                       u;
28         int                     lineno;
29 };
30
31 /* Everything is malloced. */
32 void            ECPGmake_struct_member(char *, struct ECPGtype *, struct ECPGstruct_member **);
33 struct ECPGtype *ECPGmake_simple_type(enum ECPGttype, char *, int);
34 struct ECPGtype *ECPGmake_varchar_type(enum ECPGttype, long);
35 struct ECPGtype *ECPGmake_array_type(struct ECPGtype *, char *);
36 struct ECPGtype *ECPGmake_struct_type(struct ECPGstruct_member *, enum ECPGttype, char *);
37 struct ECPGstruct_member *ECPGstruct_member_dup(struct ECPGstruct_member *);
38
39 /* Frees a type. */
40 void            ECPGfree_struct_member(struct ECPGstruct_member *);
41 void            ECPGfree_type(struct ECPGtype *);
42
43 /* Dump a type.
44    The type is dumped as:
45    type-tag <comma> reference-to-variable <comma> arrsize <comma> size <comma>
46    Where:
47    type-tag is one of the simple types or varchar.
48    reference-to-variable can be a reference to a struct element.
49    arrsize is the size of the array in case of array fetches. Otherwise 0.
50    size is the maxsize in case it is a varchar. Otherwise it is the size of
51            the variable (required to do array fetches of structs).
52  */
53 void ECPGdump_a_type(FILE *, const char *, struct ECPGtype *,
54                                 const char *, struct ECPGtype *, const char *,
55                                 const char *, char *, const char *, const char *);
56
57 /* A simple struct to keep a variable and its type. */
58 struct ECPGtemp_type
59 {
60         struct ECPGtype *type;
61         const char *name;
62 };
63
64 extern const char *ecpg_type_name(enum ECPGttype type);
65
66 /* some stuff for whenever statements */
67 enum WHEN_TYPE
68 {
69         W_NOTHING,
70         W_CONTINUE,
71         W_BREAK,
72         W_SQLPRINT,
73         W_GOTO,
74         W_DO,
75         W_STOP
76 };
77
78 struct when
79 {
80         enum WHEN_TYPE code;
81         char       *command;
82         char       *str;
83 };
84
85 struct index
86 {
87         char       *index1;
88         char       *index2;
89         char       *str;
90 };
91
92 struct su_symbol
93 {
94         char       *su;
95         char       *symbol;
96 };
97
98 struct prep
99 {
100         char       *name;
101         char       *stmt;
102         char       *type;
103 };
104
105 struct this_type
106 {
107         enum ECPGttype type_enum;
108         char       *type_str;
109         char       *type_dimension;
110         char       *type_index;
111         char       *type_sizeof;
112 };
113
114 struct _include_path
115 {
116         char       *path;
117         struct _include_path *next;
118 };
119
120 struct cursor
121 {
122         char       *name;
123         char       *command;
124         char       *connection;
125         bool            opened;
126         struct arguments *argsinsert;
127         struct arguments *argsresult;
128         struct cursor *next;
129 };
130
131 struct typedefs
132 {
133         char       *name;
134         struct this_type *type;
135         struct ECPGstruct_member *struct_member_list;
136         int                     brace_level;
137         struct typedefs *next;
138 };
139
140 struct _defines
141 {
142         char       *old;
143         char       *new;
144         int                     pertinent;
145         void       *used;
146         struct _defines *next;
147 };
148
149 /* This is a linked list of the variable names and types. */
150 struct variable
151 {
152         char       *name;
153         struct ECPGtype *type;
154         int                     brace_level;
155         struct variable *next;
156 };
157
158 struct arguments
159 {
160         struct variable *variable;
161         struct variable *indicator;
162         struct arguments *next;
163 };
164
165 struct descriptor
166 {
167         char       *name;
168         char       *connection;
169         struct descriptor *next;
170 };
171
172 struct assignment
173 {
174         char       *variable;
175         enum ECPGdtype value;
176         struct assignment *next;
177 };
178
179 enum errortype
180 {
181         ET_WARNING, ET_ERROR, ET_FATAL
182 };
183
184 struct fetch_desc
185 {
186         char       *str;
187         char       *name;
188 };
189
190 typedef struct ScanKeyword
191 {
192         char       *name;
193         int                     value;
194 } ScanKeyword;
195
196 #endif   /* _ECPG_PREPROC_TYPE_H */