OSDN Git Service

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