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