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