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(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 this_type 110 { 111 enum ECPGttype type_enum; 112 char *type_str; 113 char *type_dimension; 114 char *type_index; 115 char *type_sizeof; 116 }; 117 118 struct _include_path 119 { 120 char *path; 121 struct _include_path *next; 122 }; 123 124 struct cursor 125 { 126 char *name; 127 char *function; 128 char *command; 129 char *connection; 130 bool opened; 131 struct arguments *argsinsert; 132 struct arguments *argsinsert_oos; 133 struct arguments *argsresult; 134 struct arguments *argsresult_oos; 135 struct cursor *next; 136 }; 137 138 struct typedefs 139 { 140 char *name; 141 struct this_type *type; 142 struct ECPGstruct_member *struct_member_list; 143 int brace_level; 144 struct typedefs *next; 145 }; 146 147 struct _defines 148 { 149 char *old; 150 char *new; 151 int pertinent; 152 void *used; 153 struct _defines *next; 154 }; 155 156 /* This is a linked list of the variable names and types. */ 157 struct variable 158 { 159 char *name; 160 struct ECPGtype *type; 161 int brace_level; 162 struct variable *next; 163 }; 164 165 struct arguments 166 { 167 struct variable *variable; 168 struct variable *indicator; 169 struct arguments *next; 170 }; 171 172 struct descriptor 173 { 174 char *name; 175 char *connection; 176 struct descriptor *next; 177 }; 178 179 struct assignment 180 { 181 char *variable; 182 enum ECPGdtype value; 183 struct assignment *next; 184 }; 185 186 enum errortype 187 { 188 ET_WARNING, ET_ERROR 189 }; 190 191 struct fetch_desc 192 { 193 char *str; 194 char *name; 195 }; 196 197 #endif /* _ECPG_PREPROC_TYPE_H */ 198