2006-01-17 22:54:02 +00:00
|
|
|
//* Initializes a new connection node for the MYDDAS list*/
|
|
|
|
static MYDDAS_UTIL_CONNECTION
|
|
|
|
myddas_util_initialize_connection(void *,void *,
|
|
|
|
MYDDAS_UTIL_CONNECTION);
|
|
|
|
|
|
|
|
/* Initializes a new predicate node for the MYDDAS list */
|
|
|
|
static MYDDAS_UTIL_PREDICATE
|
|
|
|
myddas_util_initialize_predicate(char *, int,char *,
|
|
|
|
MYDDAS_UTIL_PREDICATE);
|
|
|
|
|
|
|
|
MYDDAS_GLOBAL
|
2006-03-09 15:52:06 +00:00
|
|
|
myddas_util_initialize_myddas(void){
|
2006-01-17 22:54:02 +00:00
|
|
|
MYDDAS_GLOBAL global = NULL;
|
|
|
|
|
|
|
|
global = (MYDDAS_GLOBAL) malloc (sizeof(struct myddas_global));
|
|
|
|
|
|
|
|
global->myddas_top_connections = NULL;
|
2006-02-05 02:11:56 +00:00
|
|
|
#ifdef MYDDAS_TOP_LEVEL
|
|
|
|
global->myddas_top_level_connection = NULL;
|
|
|
|
#endif
|
2006-01-17 22:54:02 +00:00
|
|
|
#ifdef MYDDAS_STATS
|
|
|
|
global->myddas_statistics = (MYDDAS_GLOBAL_STATS) malloc (sizeof(struct myddas_global_stats));
|
2006-02-05 02:11:56 +00:00
|
|
|
MYDDAS_STATS_INITIALIZE_TIME_STRUCT(global->myddas_statistics->total_db_row,time_final);
|
2006-05-03 19:02:29 +01:00
|
|
|
MYDDAS_STATS_INITIALIZE_TIME_STRUCT(global->myddas_statistics->total_translate,time_final);
|
2006-01-17 22:54:02 +00:00
|
|
|
#endif
|
|
|
|
return global;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Inserts the new node on the front of the list */
|
|
|
|
static MYDDAS_UTIL_CONNECTION
|
|
|
|
myddas_util_initialize_connection(void *conn,void *enviromment,
|
|
|
|
MYDDAS_UTIL_CONNECTION next){
|
|
|
|
|
|
|
|
MYDDAS_UTIL_CONNECTION new = malloc (sizeof(struct myddas_list_connection));
|
|
|
|
if (new == NULL)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
new->predicates=NULL;
|
|
|
|
new->connection=conn;
|
|
|
|
new->odbc_enviromment=enviromment;
|
|
|
|
|
|
|
|
/* It saves n queries, doing at once n+1 queries */
|
|
|
|
new->total_number_queries=0; //Default
|
|
|
|
new->actual_number_queries=0;
|
|
|
|
new->queries = NULL;
|
|
|
|
|
|
|
|
/* List integrity */
|
|
|
|
new->next=next;
|
|
|
|
new->previous=NULL;
|
|
|
|
/* If there's already at least one node
|
|
|
|
on the list */
|
|
|
|
if (next != NULL)
|
|
|
|
next->previous=new;
|
|
|
|
|
|
|
|
#ifdef MYDDAS_STATS
|
|
|
|
new->totalNumberOfRows=0;
|
2006-02-05 02:11:56 +00:00
|
|
|
|
|
|
|
MYDDAS_STATS_INITIALIZE_TIME_STRUCT(new->totalTimeofDBServer,time_final);
|
|
|
|
MYDDAS_STATS_INITIALIZE_TIME_STRUCT(new->lastTimeofDBServer,time_final);
|
|
|
|
MYDDAS_STATS_INITIALIZE_TIME_STRUCT(new->totalFromDBServer,time_final);
|
|
|
|
MYDDAS_STATS_INITIALIZE_TIME_STRUCT(new->lastFromDBServer,time_final);
|
|
|
|
|
2006-01-17 22:54:02 +00:00
|
|
|
new->lastBytesTransfered=0;
|
|
|
|
new->totalBytesTransfered=0;
|
|
|
|
new->total_querys_made=0;
|
|
|
|
#endif
|
|
|
|
return new;
|
|
|
|
}
|
|
|
|
|
|
|
|
static MYDDAS_UTIL_PREDICATE
|
|
|
|
myddas_util_initialize_predicate(char *pred_name, int pred_arity,
|
|
|
|
char *pred_module, MYDDAS_UTIL_PREDICATE next){
|
|
|
|
MYDDAS_UTIL_PREDICATE new = malloc (sizeof(struct myddas_list_preds));
|
|
|
|
if (new == NULL)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
new->pred_name=pred_name;
|
|
|
|
new->pred_arity=pred_arity;
|
|
|
|
new->pred_module=pred_module;
|
|
|
|
|
|
|
|
/* List integrity */
|
|
|
|
new->next=next;
|
|
|
|
new->previous=NULL;
|
|
|
|
/* If there's already at least one node
|
|
|
|
on the list */
|
|
|
|
if (next != NULL)
|
|
|
|
next->previous=new;
|
|
|
|
|
|
|
|
return new;
|
|
|
|
}
|
2006-02-05 02:11:56 +00:00
|
|
|
|