#include "type.h"#include "parser/keywords.h"#include <errno.h>#include <limits.h>

Go to the source code of this file.
| #define INDICATOR_NOT_ARRAY 4 |
Definition at line 115 of file extern.h.
Referenced by ECPGdump_a_type().
| #define INDICATOR_NOT_SIMPLE 7 |
Definition at line 118 of file extern.h.
Referenced by ECPGdump_a_type().
| #define INDICATOR_NOT_STRUCT 6 |
Definition at line 117 of file extern.h.
Referenced by ECPGdump_a_type().
| #define OUT_OF_MEMORY 5 |
Definition at line 116 of file extern.h.
Referenced by mm_alloc(), and mm_strdup().
| #define PARSE_ERROR 3 |
Definition at line 114 of file extern.h.
Referenced by adjust_array(), check_indicator(), drop_descriptor(), ECPGdump_a_type(), ECPGfree_type(), ECPGnumeric_lvalue(), find_struct(), find_struct_member(), find_variable(), get_dtype(), get_type(), get_typedef(), lookup_descriptor(), main(), output_get_descr(), output_get_descr_header(), output_set_descr(), and output_set_descr_header().
| enum COMPAT_MODE |
| ECPG_COMPAT_PGSQL | |
| ECPG_COMPAT_INFORMIX | |
| ECPG_COMPAT_INFORMIX_SE | |
| ECPG_COMPAT_PGSQL | |
| ECPG_COMPAT_INFORMIX | |
| ECPG_COMPAT_INFORMIX_SE |
Definition at line 120 of file extern.h.
{
ECPG_COMPAT_PGSQL = 0, ECPG_COMPAT_INFORMIX, ECPG_COMPAT_INFORMIX_SE
};
| void add_descriptor | ( | char * | , | |
| char * | ||||
| ) |
Definition at line 76 of file descriptor.c.
References mm_alloc(), and descriptor::name.
{
struct descriptor *new;
if (name[0] != '"')
return;
new = (struct descriptor *) mm_alloc(sizeof(struct descriptor));
new->next = descriptors;
new->name = mm_alloc(strlen(name) + 1);
strcpy(new->name, name);
if (connection)
{
new->connection = mm_alloc(strlen(connection) + 1);
strcpy(new->connection, connection);
}
else
new->connection = connection;
descriptors = new;
}
Definition at line 379 of file variable.c.
References arguments::indicator, mm_alloc(), arguments::next, and arguments::variable.
Definition at line 391 of file variable.c.
References mm_alloc(), variable::next, and arguments::next.
| void adjust_array | ( | enum | ECPGttype, | |
| char ** | , | |||
| char ** | , | |||
| char * | , | |||
| char * | , | |||
| int | , | |||
| bool | ||||
| ) |
Definition at line 506 of file variable.c.
References ECPGt_char, ECPGt_string, ECPGt_struct, ECPGt_union, ECPGt_unsigned_char, ECPGt_varchar, ET_FATAL, mm_strdup(), mmerror(), ngettext, and PARSE_ERROR.
{
if (atoi(type_index) >= 0)
{
if (atoi(*length) >= 0)
mmerror(PARSE_ERROR, ET_FATAL, "multidimensional arrays are not supported");
*length = type_index;
}
if (atoi(type_dimension) >= 0)
{
if (atoi(*dimension) >= 0 && atoi(*length) >= 0)
mmerror(PARSE_ERROR, ET_FATAL, "multidimensional arrays are not supported");
if (atoi(*dimension) >= 0)
*length = *dimension;
*dimension = type_dimension;
}
if (pointer_len > 2)
mmerror(PARSE_ERROR, ET_FATAL, ngettext("multilevel pointers (more than 2 levels) are not supported; found %d level",
"multilevel pointers (more than 2 levels) are not supported; found %d levels", pointer_len),
pointer_len);
if (pointer_len > 1 && type_enum != ECPGt_char && type_enum != ECPGt_unsigned_char && type_enum != ECPGt_string)
mmerror(PARSE_ERROR, ET_FATAL, "pointer to pointer is not supported for this data type");
if (pointer_len > 1 && (atoi(*length) >= 0 || atoi(*dimension) >= 0))
mmerror(PARSE_ERROR, ET_FATAL, "multidimensional arrays are not supported");
if (atoi(*length) >= 0 && atoi(*dimension) >= 0 && pointer_len)
mmerror(PARSE_ERROR, ET_FATAL, "multidimensional arrays are not supported");
switch (type_enum)
{
case ECPGt_struct:
case ECPGt_union:
/* pointer has to get dimension 0 */
if (pointer_len)
{
*length = *dimension;
*dimension = mm_strdup("0");
}
if (atoi(*length) >= 0)
mmerror(PARSE_ERROR, ET_FATAL, "multidimensional arrays for structures are not supported");
break;
case ECPGt_varchar:
/* pointer has to get dimension 0 */
if (pointer_len)
*dimension = mm_strdup("0");
/* one index is the string length */
if (atoi(*length) < 0)
{
*length = *dimension;
*dimension = mm_strdup("-1");
}
break;
case ECPGt_char:
case ECPGt_unsigned_char:
case ECPGt_string:
/* char ** */
if (pointer_len == 2)
{
*length = *dimension = mm_strdup("0");
break;
}
/* pointer has to get length 0 */
if (pointer_len == 1)
*length = mm_strdup("0");
/* one index is the string length */
if (atoi(*length) < 0)
{
/*
* make sure we return length = -1 for arrays without given
* bounds
*/
if (atoi(*dimension) < 0 && !type_definition)
/*
* do not change this for typedefs since it will be
* changed later on when the variable is defined
*/
*length = mm_strdup("1");
else if (strcmp(*dimension, "0") == 0)
*length = mm_strdup("-1");
else
*length = *dimension;
*dimension = mm_strdup("-1");
}
break;
default:
/* a pointer has dimension = 0 */
if (pointer_len)
{
*length = *dimension;
*dimension = mm_strdup("0");
}
if (atoi(*length) >= 0)
mmerror(PARSE_ERROR, ET_FATAL, "multidimensional arrays for simple data types are not supported");
break;
}
}
| void base_yyerror | ( | const char * | ) |
Referenced by ECPGdump_a_type(), and ECPGfree_type().
| int base_yylex | ( | void | ) |
| int base_yyparse | ( | void | ) |
| void check_indicator | ( | struct ECPGtype * | ) |
Definition at line 461 of file variable.c.
References check_indicator(), ECPGt_array, ECPGt_int, ECPGt_long, ECPGt_long_long, ECPGt_short, ECPGt_struct, ECPGt_union, ECPGt_unsigned_int, ECPGt_unsigned_long, ECPGt_unsigned_long_long, ECPGt_unsigned_short, ECPGtype::element, ET_ERROR, ECPGtype::members, mmerror(), ECPGstruct_member::next, PARSE_ERROR, ECPGstruct_member::type, ECPGtype::type, and ECPGtype::u.
Referenced by check_indicator().
{
/* make sure this is a valid indicator variable */
switch (var->type)
{
struct ECPGstruct_member *p;
case ECPGt_short:
case ECPGt_int:
case ECPGt_long:
case ECPGt_long_long:
case ECPGt_unsigned_short:
case ECPGt_unsigned_int:
case ECPGt_unsigned_long:
case ECPGt_unsigned_long_long:
break;
case ECPGt_struct:
case ECPGt_union:
for (p = var->u.members; p; p = p->next)
check_indicator(p->type);
break;
case ECPGt_array:
check_indicator(var->u.element);
break;
default:
mmerror(PARSE_ERROR, ET_ERROR, "indicator variable must have an integer type");
break;
}
}
| struct variable* descriptor_variable | ( | const char * | name, | |
| int | input | |||
| ) | [read] |
Definition at line 317 of file descriptor.c.
References NULL, and strlcpy().
{
static char descriptor_names[2][MAX_DESCRIPTOR_NAMELEN];
static struct ECPGtype descriptor_type = {ECPGt_descriptor, NULL, NULL, NULL, {NULL}, 0};
static struct variable varspace[2] = {
{descriptor_names[0], &descriptor_type, 0, NULL},
{descriptor_names[1], &descriptor_type, 0, NULL}
};
strlcpy(descriptor_names[input], name, sizeof(descriptor_names[input]));
return &varspace[input];
}
| void drop_descriptor | ( | char * | , | |
| char * | ||||
| ) |
Definition at line 99 of file descriptor.c.
References descriptor::connection, ET_WARNING, free, i, mmerror(), descriptor::name, descriptor::next, and PARSE_ERROR.
{
struct descriptor *i;
struct descriptor **lastptr = &descriptors;
if (name[0] != '"')
return;
for (i = descriptors; i; lastptr = &i->next, i = i->next)
{
if (strcmp(name, i->name) == 0)
{
if ((!connection && !i->connection)
|| (connection && i->connection
&& strcmp(connection, i->connection) == 0))
{
*lastptr = i->next;
if (i->connection)
free(i->connection);
free(i->name);
free(i);
return;
}
}
}
mmerror(PARSE_ERROR, ET_WARNING, "descriptor \"%s\" does not exist", name);
}
| void dump_variables | ( | struct arguments * | , | |
| int | ||||
| ) |
Definition at line 438 of file variable.c.
References variable::brace_level, dump_variables(), ECPGdump_a_type(), free, arguments::indicator, mm_strdup(), variable::name, arguments::next, NULL, variable::type, arguments::variable, and yyout.
Referenced by dump_variables(), and output_statement().
{
if (list == NULL)
return;
/*
* The list is build up from the beginning so lets first dump the end of
* the list:
*/
dump_variables(list->next, mode);
/* Then the current element and its indicator */
ECPGdump_a_type(yyout, list->variable->name, list->variable->type, list->variable->brace_level,
list->indicator->name, list->indicator->type, list->indicator->brace_level,
NULL, NULL, mm_strdup("0"), NULL, NULL);
/* Then release the list element. */
if (mode != 0)
free(list);
}
| int filtered_base_yylex | ( | void | ) |
Definition at line 48 of file parser.c.
References base_yylex(), have_lookahead, lookahead_token, lookahead_yylloc, lookahead_yylval, and YYLTYPE.
{
int cur_token;
int next_token;
YYSTYPE cur_yylval;
YYLTYPE cur_yylloc;
/* Get next token --- we might already have it */
if (have_lookahead)
{
cur_token = lookahead_token;
base_yylval = lookahead_yylval;
base_yylloc = lookahead_yylloc;
have_lookahead = false;
}
else
cur_token = base_yylex();
/* Do we need to look ahead for a possible multiword token? */
switch (cur_token)
{
case NULLS_P:
/*
* NULLS FIRST and NULLS LAST must be reduced to one token
*/
cur_yylval = base_yylval;
cur_yylloc = base_yylloc;
next_token = base_yylex();
switch (next_token)
{
case FIRST_P:
cur_token = NULLS_FIRST;
break;
case LAST_P:
cur_token = NULLS_LAST;
break;
default:
/* save the lookahead token for next time */
lookahead_token = next_token;
lookahead_yylval = base_yylval;
lookahead_yylloc = base_yylloc;
have_lookahead = true;
/* and back up the output info to cur_token */
base_yylval = cur_yylval;
base_yylloc = cur_yylloc;
break;
}
break;
case WITH:
/*
* WITH TIME must be reduced to one token
*/
cur_yylval = base_yylval;
cur_yylloc = base_yylloc;
next_token = base_yylex();
switch (next_token)
{
case TIME:
cur_token = WITH_TIME;
break;
default:
/* save the lookahead token for next time */
lookahead_token = next_token;
lookahead_yylval = base_yylval;
lookahead_yylloc = base_yylloc;
have_lookahead = true;
/* and back up the output info to cur_token */
base_yylval = cur_yylval;
base_yylloc = cur_yylloc;
break;
}
break;
default:
break;
}
return cur_token;
}
| struct variable* find_variable | ( | char * | ) | [read] |
Definition at line 194 of file variable.c.
References variable::brace_level, ECPGmake_array_type(), ECPGmake_simple_type(), ECPGmake_struct_type(), ECPGt_array, ECPGt_struct, ECPGt_union, ET_FATAL, find_simple(), find_struct(), mmerror(), new_variable(), variable::next, NULL, PARSE_ERROR, and variable::type.
Referenced by ECPGdump_a_type(), ECPGnumeric_lvalue(), find_struct(), output_get_descr(), and output_set_descr().
{
char *next,
*end;
struct variable *p;
int count;
next = strpbrk(name, ".[-");
if (next)
{
if (*next == '[')
{
/*
* We don't care about what's inside the array braces so just eat
* up the characters
*/
for (count = 1, end = next + 1; count; end++)
{
switch (*end)
{
case '[':
count++;
break;
case ']':
count--;
break;
default:
break;
}
}
if (*end == '.')
p = find_struct(name, next, end);
else
{
char c = *next;
*next = '\0';
p = find_simple(name);
if (p == NULL)
mmerror(PARSE_ERROR, ET_FATAL, "variable \"%s\" is not declared", name);
*next = c;
switch (p->type->u.element->type)
{
case ECPGt_array:
return (new_variable(name, ECPGmake_array_type(ECPGmake_simple_type(p->type->u.element->u.element->type, p->type->u.element->u.element->size, p->type->u.element->u.element->counter), p->type->u.element->size), p->brace_level));
case ECPGt_struct:
case ECPGt_union:
return (new_variable(name, ECPGmake_struct_type(p->type->u.element->u.members, p->type->u.element->type, p->type->u.element->type_name, p->type->u.element->struct_sizeof), p->brace_level));
default:
return (new_variable(name, ECPGmake_simple_type(p->type->u.element->type, p->type->u.element->size, p->type->u.element->counter), p->brace_level));
}
}
}
else
p = find_struct(name, next, next);
}
else
p = find_simple(name);
if (p == NULL)
mmerror(PARSE_ERROR, ET_FATAL, "variable \"%s\" is not declared", name);
return (p);
}
| const char* get_dtype | ( | enum | ECPGdtype | ) |
Definition at line 601 of file type.c.
References ECPGd_cardinality, ECPGd_count, ECPGd_data, ECPGd_di_code, ECPGd_di_precision, ECPGd_indicator, ECPGd_key_member, ECPGd_length, ECPGd_name, ECPGd_nullable, ECPGd_octet, ECPGd_precision, ECPGd_ret_length, ECPGd_ret_octet, ECPGd_scale, ECPGd_type, ET_ERROR, mmerror(), and PARSE_ERROR.
Referenced by output_get_descr(), and output_set_descr().
{
switch (type)
{
case ECPGd_count:
return ("ECPGd_countr");
break;
case ECPGd_data:
return ("ECPGd_data");
break;
case ECPGd_di_code:
return ("ECPGd_di_code");
break;
case ECPGd_di_precision:
return ("ECPGd_di_precision");
break;
case ECPGd_indicator:
return ("ECPGd_indicator");
break;
case ECPGd_key_member:
return ("ECPGd_key_member");
break;
case ECPGd_length:
return ("ECPGd_length");
break;
case ECPGd_name:
return ("ECPGd_name");
break;
case ECPGd_nullable:
return ("ECPGd_nullable");
break;
case ECPGd_octet:
return ("ECPGd_octet");
break;
case ECPGd_precision:
return ("ECPGd_precision");
break;
case ECPGd_ret_length:
return ("ECPGd_ret_length");
case ECPGd_ret_octet:
return ("ECPGd_ret_octet");
break;
case ECPGd_scale:
return ("ECPGd_scale");
break;
case ECPGd_type:
return ("ECPGd_type");
break;
case ECPGd_cardinality:
return ("ECPGd_cardinality");
default:
mmerror(PARSE_ERROR, ET_ERROR, "unrecognized descriptor item code %d", type);
}
return NULL;
}
| struct typedefs* get_typedef | ( | char * | ) | [read] |
Definition at line 494 of file variable.c.
References ET_FATAL, mmerror(), typedefs::next, PARSE_ERROR, and types.
| char* hashline_number | ( | void | ) |
Definition at line 89 of file output.c.
References input_filename, mm_alloc(), and yylineno.
Referenced by output_line_number().
{
/* do not print line numbers if we are in debug mode */
if (input_filename
#ifdef YYDEBUG
&& !yydebug
#endif
)
{
char *line = mm_alloc(strlen("\n#line %d \"%s\"\n") + sizeof(int) * CHAR_BIT * 10 / 3 + strlen(input_filename));
sprintf(line, "\n#line %d \"%s\"\n", yylineno, input_filename);
return line;
}
return EMPTY;
}
| void lex_init | ( | void | ) |
Referenced by main().
| struct descriptor* lookup_descriptor | ( | char * | , | |
| char * | ||||
| ) | [read] |
Definition at line 129 of file descriptor.c.
References descriptor::connection, ET_WARNING, i, mmerror(), descriptor::name, descriptor::next, and PARSE_ERROR.
{
struct descriptor *i;
if (name[0] != '"')
return NULL;
for (i = descriptors; i; i = i->next)
{
if (strcmp(name, i->name) == 0)
{
if ((!connection && !i->connection)
|| (connection && i->connection
&& strcmp(connection, i->connection) == 0))
return i;
}
}
mmerror(PARSE_ERROR, ET_WARNING, "descriptor \"%s\" does not exist", name);
return NULL;
}
| void* mm_alloc | ( | size_t | ) |
Referenced by add_descriptor(), add_include_path(), add_preprocessor_define(), add_variable_to_head(), add_variable_to_tail(), ECPGdump_a_simple(), ECPGdump_a_struct(), ECPGmake_simple_type(), ECPGmake_struct_member(), hashline_number(), main(), new_variable(), push_assignment(), and sqlda_variable().
| void* * mm_realloc | ( | void * | , | |
| size_t | ||||
| ) |
| char* mm_strdup | ( | const char * | ) |
Definition at line 25 of file type.c.
References ET_FATAL, mmerror(), NULL, and OUT_OF_MEMORY.
Referenced by add_preprocessor_define(), adjust_array(), dump_variables(), ECPGdump_a_type(), ECPGmake_struct_member(), ECPGmake_struct_type(), new_variable(), output_get_descr(), output_set_descr(), and sqlda_variable().
{
char *new = strdup(string);
if (new == NULL)
mmerror(OUT_OF_MEMORY, ET_FATAL, "out of memory");
return new;
}
| void mmerror | ( | int | , | |
| enum | errortype, | |||
| const char * | , | |||
| ... | ||||
| ) |
Referenced by adjust_array(), check_indicator(), drop_descriptor(), ECPGdump_a_type(), ECPGfree_type(), ECPGnumeric_lvalue(), find_struct(), find_struct_member(), find_variable(), get_dtype(), get_type(), get_typedef(), lookup_descriptor(), main(), mm_alloc(), mm_strdup(), output_get_descr(), output_get_descr_header(), output_set_descr(), and output_set_descr_header().
Definition at line 10 of file variable.c.
References variable::brace_level, mm_alloc(), mm_strdup(), variable::name, variable::next, and variable::type.
Referenced by find_struct_member(), and find_variable().
{
struct variable *p = (struct variable *) mm_alloc(sizeof(struct variable));
p->name = mm_strdup(name);
p->type = type;
p->brace_level = brace_level;
p->next = allvariables;
allvariables = p;
return (p);
}
| void output_deallocate_prepare_statement | ( | char * | ) |
Definition at line 162 of file output.c.
References compat, free, NULL, output_escaped_str(), whenever_action(), and yyout.
{
const char *con = connection ? connection : "NULL";
if (strcmp(name, "all") != 0)
{
fprintf(yyout, "{ ECPGdeallocate(__LINE__, %d, %s, ", compat, con);
output_escaped_str(name, true);
fputs(");", yyout);
}
else
fprintf(yyout, "{ ECPGdeallocate_all(__LINE__, %d, %s);", compat, con);
whenever_action(2);
free(name);
if (connection != NULL)
free(connection);
}
| void output_get_descr | ( | char * | , | |
| char * | ||||
| ) |
Definition at line 170 of file descriptor.c.
References variable::brace_level, drop_assignments(), ECPGd_key_member, ECPGd_nullable, ECPGdump_a_type(), ET_WARNING, find_variable(), get_dtype(), mm_strdup(), mmerror(), variable::name, assignment::next, NULL, PARSE_ERROR, variable::type, assignment::value, assignment::variable, whenever_action(), and yyout.
{
struct assignment *results;
fprintf(yyout, "{ ECPGget_desc(__LINE__, %s, %s,", desc_name, index);
for (results = assignments; results != NULL; results = results->next)
{
const struct variable *v = find_variable(results->variable);
switch (results->value)
{
case ECPGd_nullable:
mmerror(PARSE_ERROR, ET_WARNING, "nullable is always 1");
break;
case ECPGd_key_member:
mmerror(PARSE_ERROR, ET_WARNING, "key_member is always 0");
break;
default:
break;
}
fprintf(yyout, "%s,", get_dtype(results->value));
ECPGdump_a_type(yyout, v->name, v->type, v->brace_level, NULL, NULL, -1, NULL, NULL, mm_strdup("0"), NULL, NULL);
}
drop_assignments();
fputs("ECPGd_EODT);\n", yyout);
whenever_action(2 | 1);
}
| void void output_get_descr_header | ( | char * | ) |
Definition at line 151 of file descriptor.c.
References drop_assignments(), ECPGd_count, ECPGnumeric_lvalue(), ET_WARNING, mmerror(), assignment::next, PARSE_ERROR, assignment::value, assignment::variable, whenever_action(), and yyout.
{
struct assignment *results;
fprintf(yyout, "{ ECPGget_desc_header(__LINE__, %s, &(", desc_name);
for (results = assignments; results != NULL; results = results->next)
{
if (results->value == ECPGd_count)
ECPGnumeric_lvalue(results->variable);
else
mmerror(PARSE_ERROR, ET_WARNING, "descriptor header item \"%d\" does not exist", results->value);
}
drop_assignments();
fprintf(yyout, "));\n");
whenever_action(3);
}
| void output_line_number | ( | void | ) |
Definition at line 10 of file output.c.
References free, hashline_number(), and yyout.
Referenced by main(), output_simple_statement(), and whenever_action().
{
char *line = hashline_number();
fprintf(yyout, "%s", line);
free(line);
}
| void output_prepare_statement | ( | char * | , | |
| char * | ||||
| ) |
Definition at line 148 of file output.c.
References free, NULL, output_escaped_str(), questionmarks, whenever_action(), and yyout.
{
fprintf(yyout, "{ ECPGprepare(__LINE__, %s, %d, ", connection ? connection : "NULL", questionmarks);
output_escaped_str(name, true);
fputs(", ", yyout);
output_escaped_str(stmt, true);
fputs(");", yyout);
whenever_action(2);
free(name);
if (connection != NULL)
free(connection);
}
| void output_set_descr | ( | char * | , | |
| char * | ||||
| ) |
Definition at line 261 of file descriptor.c.
References variable::brace_level, descriptor_item_name(), drop_assignments(), ECPGd_cardinality, ECPGd_data, ECPGd_di_code, ECPGd_di_precision, ECPGd_indicator, ECPGd_key_member, ECPGd_length, ECPGd_name, ECPGd_nullable, ECPGd_octet, ECPGd_precision, ECPGd_ret_length, ECPGd_ret_octet, ECPGd_scale, ECPGd_type, ECPGdump_a_type(), ET_FATAL, find_variable(), get_dtype(), mm_strdup(), mmerror(), variable::name, assignment::next, NULL, PARSE_ERROR, variable::type, assignment::value, assignment::variable, whenever_action(), and yyout.
{
struct assignment *results;
fprintf(yyout, "{ ECPGset_desc(__LINE__, %s, %s,", desc_name, index);
for (results = assignments; results != NULL; results = results->next)
{
const struct variable *v = find_variable(results->variable);
switch (results->value)
{
case ECPGd_cardinality:
case ECPGd_di_code:
case ECPGd_di_precision:
case ECPGd_precision:
case ECPGd_scale:
mmerror(PARSE_ERROR, ET_FATAL, "descriptor item \"%s\" is not implemented",
descriptor_item_name(results->value));
break;
case ECPGd_key_member:
case ECPGd_name:
case ECPGd_nullable:
case ECPGd_octet:
case ECPGd_ret_length:
case ECPGd_ret_octet:
mmerror(PARSE_ERROR, ET_FATAL, "descriptor item \"%s\" cannot be set",
descriptor_item_name(results->value));
break;
case ECPGd_data:
case ECPGd_indicator:
case ECPGd_length:
case ECPGd_type:
fprintf(yyout, "%s,", get_dtype(results->value));
ECPGdump_a_type(yyout, v->name, v->type, v->brace_level, NULL, NULL, -1, NULL, NULL, mm_strdup("0"), NULL, NULL);
break;
default:
;
}
}
drop_assignments();
fputs("ECPGd_EODT);\n", yyout);
whenever_action(2 | 1);
}
| void output_set_descr_header | ( | char * | ) |
Definition at line 200 of file descriptor.c.
References drop_assignments(), ECPGd_count, ECPGnumeric_lvalue(), ET_WARNING, mmerror(), assignment::next, PARSE_ERROR, assignment::value, assignment::variable, whenever_action(), and yyout.
{
struct assignment *results;
fprintf(yyout, "{ ECPGset_desc_header(__LINE__, %s, (int)(", desc_name);
for (results = assignments; results != NULL; results = results->next)
{
if (results->value == ECPGd_count)
ECPGnumeric_lvalue(results->variable);
else
mmerror(PARSE_ERROR, ET_WARNING, "descriptor header item \"%d\" does not exist", results->value);
}
drop_assignments();
fprintf(yyout, "));\n");
whenever_action(3);
}
| void output_simple_statement | ( | char * | ) |
Definition at line 19 of file output.c.
References free, output_escaped_str(), and output_line_number().
{
output_escaped_str(stmt, false);
output_line_number();
free(stmt);
}
| void output_statement | ( | char * | , | |
| int | , | |||
| enum | ECPG_statement_type | |||
| ) |
Definition at line 116 of file output.c.
References argsinsert, argsresult, auto_prepare, compat, dump_variables(), ecpg_statement_type_name, ECPGst_exec_immediate, ECPGst_execute, ECPGst_prepnormal, force_indicator, free, NULL, output_escaped_str(), questionmarks, reset_variables(), whenever_action(), and yyout.
{
fprintf(yyout, "{ ECPGdo(__LINE__, %d, %d, %s, %d, ", compat, force_indicator, connection ? connection : "NULL", questionmarks);
if (st == ECPGst_execute || st == ECPGst_exec_immediate)
{
fprintf(yyout, "%s, %s, ", ecpg_statement_type_name[st], stmt);
}
else
{
if (st == ECPGst_prepnormal && auto_prepare)
fputs("ECPGst_prepnormal, \"", yyout);
else
fputs("ECPGst_normal, \"", yyout);
output_escaped_str(stmt, false);
fputs("\", ", yyout);
}
/* dump variables to C file */
dump_variables(argsinsert, 1);
fputs("ECPGt_EOIT, ", yyout);
dump_variables(argsresult, 1);
fputs("ECPGt_EORT);", yyout);
reset_variables();
whenever_action(whenever_mode | 2);
free(stmt);
if (connection != NULL)
free(connection);
}
| void parser_init | ( | void | ) |
| void push_assignment | ( | char * | , | |
| enum | ECPGdtype | |||
| ) |
Definition at line 21 of file descriptor.c.
References mm_alloc(), and assignment::variable.
{
struct assignment *new = (struct assignment *) mm_alloc(sizeof(struct assignment));
new->next = assignments;
new->variable = mm_alloc(strlen(var) + 1);
strcpy(new->variable, var);
new->value = value;
assignments = new;
}
| void remove_typedefs | ( | int | ) |
Definition at line 261 of file variable.c.
References typedefs::brace_level, ECPGt_struct, ECPGt_union, free, typedefs::name, typedefs::next, typedefs::struct_member_list, typedefs::type, this_type::type_enum, and types.
{
struct typedefs *p,
*prev;
for (p = prev = types; p;)
{
if (p->brace_level >= brace_level)
{
/* remove it */
if (p == types)
prev = types = p->next;
else
prev->next = p->next;
if (p->type->type_enum == ECPGt_struct || p->type->type_enum == ECPGt_union)
free(p->struct_member_list);
free(p->type);
free(p->name);
free(p);
if (prev == types)
p = types;
else
p = prev ? prev->next : NULL;
}
else
{
prev = p;
p = prev->next;
}
}
}
Definition at line 409 of file variable.c.
References arguments::next, and arguments::variable.
| void remove_variables | ( | int | ) |
Definition at line 295 of file variable.c.
References cursor::argsinsert, cursor::argsresult, variable::brace_level, cur, ECPGfree_type(), free, variable::name, variable::next, arguments::next, cursor::next, NULL, variable::type, and arguments::variable.
{
struct variable *p,
*prev;
for (p = prev = allvariables; p;)
{
if (p->brace_level >= brace_level)
{
/* is it still referenced by a cursor? */
struct cursor *ptr;
for (ptr = cur; ptr != NULL; ptr = ptr->next)
{
struct arguments *varptr,
*prevvar;
for (varptr = prevvar = ptr->argsinsert; varptr != NULL; varptr = varptr->next)
{
if (p == varptr->variable)
{
/* remove from list */
if (varptr == ptr->argsinsert)
ptr->argsinsert = varptr->next;
else
prevvar->next = varptr->next;
}
}
for (varptr = prevvar = ptr->argsresult; varptr != NULL; varptr = varptr->next)
{
if (p == varptr->variable)
{
/* remove from list */
if (varptr == ptr->argsresult)
ptr->argsresult = varptr->next;
else
prevvar->next = varptr->next;
}
}
}
/* remove it */
if (p == allvariables)
prev = allvariables = p->next;
else
prev->next = p->next;
ECPGfree_type(p->type);
free(p->name);
free(p);
if (prev == allvariables)
p = allvariables;
else
p = prev ? prev->next : NULL;
}
else
{
prev = p;
p = prev->next;
}
}
}
| void reset_variables | ( | void | ) |
Definition at line 369 of file variable.c.
Referenced by output_statement().
{
argsinsert = NULL;
argsresult = NULL;
}
| const ScanKeyword* ScanCKeywordLookup | ( | const char * | ) |
Definition at line 64 of file c_keywords.c.
References lengthof, and ScanKeyword::name.
{
const ScanKeyword *low = &ScanCKeywords[0];
const ScanKeyword *high = &ScanCKeywords[lengthof(ScanCKeywords) - 1];
while (low <= high)
{
const ScanKeyword *middle;
int difference;
middle = low + (high - low) / 2;
difference = strcmp(middle->name, text);
if (difference == 0)
return middle;
else if (difference < 0)
low = middle + 1;
else
high = middle - 1;
}
return NULL;
}
| const ScanKeyword* ScanECPGKeywordLookup | ( | const char * | text | ) |
Definition at line 89 of file ecpg_keywords.c.
References lengthof, NumSQLScanKeywords, and ScanKeywordLookup().
{
const ScanKeyword *res;
/* First check SQL symbols defined by the backend. */
res = ScanKeywordLookup(text, SQLScanKeywords, NumSQLScanKeywords);
if (res)
return res;
/* Try ECPG-specific keywords. */
res = ScanKeywordLookup(text, ECPGScanKeywords, lengthof(ECPGScanKeywords));
if (res)
return res;
return NULL;
}
| void scanner_finish | ( | void | ) |
| void scanner_init | ( | const char * | ) |
| struct variable* sqlda_variable | ( | const char * | name | ) | [read] |
Definition at line 331 of file descriptor.c.
References variable::brace_level, mm_alloc(), mm_strdup(), variable::name, variable::next, and variable::type.
{
struct variable *p = (struct variable *) mm_alloc(sizeof(struct variable));
p->name = mm_strdup(name);
p->type = (struct ECPGtype *) mm_alloc(sizeof(struct ECPGtype));
p->type->type = ECPGt_sqlda;
p->type->size = NULL;
p->type->struct_sizeof = NULL;
p->type->u.element = NULL;
p->type->counter = 0;
p->brace_level = 0;
p->next = NULL;
return p;
}
| void whenever_action | ( | int | ) |
Definition at line 61 of file output.c.
References when::code, output_line_number(), print_action(), W_NOTHING, when_warn, and yyout.
Referenced by output_deallocate_prepare_statement(), output_get_descr(), output_get_descr_header(), output_prepare_statement(), output_set_descr(), output_set_descr_header(), and output_statement().
{
if ((mode & 1) == 1 && when_nf.code != W_NOTHING)
{
output_line_number();
fprintf(yyout, "\nif (sqlca.sqlcode == ECPG_NOT_FOUND) ");
print_action(&when_nf);
}
if (when_warn.code != W_NOTHING)
{
output_line_number();
fprintf(yyout, "\nif (sqlca.sqlwarn[0] == 'W') ");
print_action(&when_warn);
}
if (when_error.code != W_NOTHING)
{
output_line_number();
fprintf(yyout, "\nif (sqlca.sqlcode < 0) ");
print_action(&when_error);
}
if ((mode & 2) == 2)
fputc('}', yyout);
output_line_number();
}
| struct arguments* argsinsert |
Definition at line 365 of file variable.c.
Referenced by output_statement().
| struct arguments* argsresult |
Definition at line 366 of file variable.c.
Referenced by output_statement().
Definition at line 21 of file ecpg.c.
Referenced by main(), and output_statement().
| int braces_open |
| enum COMPAT_MODE compat |
Definition at line 25 of file ecpg.c.
Referenced by ECPGconnect(), main(), output_deallocate_prepare_statement(), and output_statement().
| char* connection |
Definition at line 28 of file ecpg.c.
Referenced by _bt_first(), _bt_preprocess_array_keys(), _bt_preprocess_keys(), _hash_first(), BeginCopy(), CopyOneRowTo(), CopyTo(), DoCopy(), dsynonym_init(), fallbackSplit(), gbt_num_union(), gbt_var_picksplit(), gbt_var_union(), get_docrep(), gist_box_union(), gistXLogSplit(), gistXLogUpdate(), hashing(), inet_net_ntop_ipv6(), isort(), lquery_in(), ltree_union(), NextCopyFrom(), NormalizeSubWord(), OverrideSearchPathMatchesCurrent(), plainnode(), queryin(), read_dictionary(), remove_from_unowned_list(), remove_variables(), slist_delete(), test_timing(), tsvector_strip(), tsvectorin(), txid_current_snapshot(), txid_snapshot_recv(), and vacuum().
| char* current_function |
| char* descriptor_index |
| char* descriptor_name |
Referenced by main().
| struct ECPGtype ecpg_no_indicator |
Referenced by ECPGdump_a_struct().
Definition at line 18 of file ecpg.c.
Referenced by main(), and output_statement().
| struct _include_path* include_paths |
| char* input_filename |
Referenced by hashline_number(), and main().
| struct variable no_indicator |
| char* output_filename |
Definition at line 19 of file ecpg.c.
Referenced by main(), output_prepare_statement(), and output_statement().
| int ret_value |
Definition at line 14 of file ecpg.c.
Referenced by main(), and pltcl_trigger_handler().
| int struct_level |
| struct ECPGstruct_member* struct_member_list[STRUCT_DEPTH] |
| char * token_start |
Definition at line 29 of file ecpg.c.
Referenced by get_typedef(), PLy_procedure_create(), remove_typedefs(), and writezone().
Definition at line 30 of file output.c.
Referenced by main(), and whenever_action().
| int yylineno |
Referenced by hashline_number().
| FILE * yyout |
Referenced by dump_variables(), ECPGnumeric_lvalue(), main(), output_deallocate_prepare_statement(), output_escaped_str(), output_get_descr(), output_get_descr_header(), output_line_number(), output_prepare_statement(), output_set_descr(), output_set_descr_header(), output_statement(), print_action(), and whenever_action().
| char* yytext |
Referenced by __attribute__(), and internal_yylex().
1.7.1