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