USE_MYDDAS when we have a driver for the DBMS

This commit is contained in:
Vítor Santos Costa 2015-02-10 09:17:59 +00:00
parent 350caa388b
commit 081b2a464e
7 changed files with 221 additions and 184 deletions

125
configure vendored
View File

@ -700,6 +700,7 @@ ARCHIVE_CPPFLAGS
ARCHIVE_LIBS
ARCHIVE_PLTARGETS
ARCHIVE_TARGETS
CLIB_FLAGS_LIBUUID
CLIB_LIBUUID
CLIB_CRYPTOBJ
CLIB_CRYPTLIBS
@ -10501,7 +10502,8 @@ done
if test "$yap_cv_mysql" = yes
then
YAP_EXTRAS="$YAP_EXTRAS -DMYDDAS_MYSQL"
use_myddas=true
YAP_EXTRAS="$YAP_EXTRAS -DMYDDAS_MYSQL"
fi
case "$target_os" in
@ -10728,6 +10730,7 @@ done
if test "$yap_cv_odbc" != no
then
use_myddas=true
YAP_EXTRAS="$YAP_EXTRAS -DMYDDAS_ODBC"
fi
@ -10791,6 +10794,7 @@ done
if test "$yap_cv_sqlite3" != no
then
use_myddas=true
YAP_EXTRAS="$YAP_EXTRAS -DMYDDAS_SQLITE3"
fi
@ -10804,6 +10808,11 @@ done
YAP_EXTRAS="$YAP_EXTRAS -DMYDDAS_TOP_LEVEL"
fi
if test "$use_myddas" = true; then
YAP_EXTRAS="$YAP_EXTRAS -DUSE_MYDDAS=1"
fi
MYDDAS_LIBS="$LIBS"
LIBS="$OLD_LIBS"
CPPFLAGS="$OLD_CPPFLAGS"
@ -10829,8 +10838,6 @@ fi
@ -11801,6 +11808,7 @@ fi
CLIB_TARGETS="socket.$SO cgi.$SO memfile.$SO files.$SO mime.$SO crypt.$SO time.$SO"
case "$PLARCH" in
@ -11980,7 +11988,69 @@ fi
fi
dl to be installed in various places.
# brew in OSX
if test -d /usr/local/opt/ossp-uuid; then
CPPFLAGS="$CPPFLAGS -I /usr/local/opt/ossp-uuid/include"
UUID_LIB_PATH="-L /usr/local/opt/ossp-uuid/lib"
fi
# /opt
if test -d /opt/include/ossp; then
CPPFLAGS="$CPPFLAGS -I /opt/include"
UUID_LIB_PATH="-L /opt/lib"
fi
# /usr/local
if test -d /opt/include/ossp; then
CPPFLAGS="$CPPFLAGS -I /opt/include"
UUID_LIB_PATH="-L /opt/lib"
fi
if test x"$UUID_H" = "x"; then
ac_fn_c_check_header_compile "$LINENO" "ossp/uuid.h" "ac_cv_header_ossp_uuid_h" "/*first*/
"
if test "x$ac_cv_header_ossp_uuid_h" = xyes; then :
UUID_H=ossp/uuid.h
has_uuid=true
fi
fi
if test x"$UUID_H" = "x" -a ! -d /usr/include/uuid; then
ac_fn_c_check_header_compile "$LINENO" "uuid/uuid.h" "ac_cv_header_uuid_uuid_h" "/*first*/
"
if test "x$ac_cv_header_uuid_uuid_h" = xyes; then :
UUID_H=uuid/uuid.h
has_uuid=true
fi
fi
if test x"$UUID_H" = "x"; then
ac_fn_c_check_header_compile "$LINENO" "uuid.h" "ac_cv_header_uuid_h" "/*first*/
"
if test "x$ac_cv_header_uuid_h" = xyes; then :
UUID_H=uuid.h
has_uuid=true
fi
fi
if test x"$UUID_H" = "x"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Cannot find uuid.h -- dropping uuid.pl" >&5
$as_echo "$as_me: WARNING: Cannot find uuid.h -- dropping uuid.pl" >&2;}
else
cat >>confdefs.h <<_ACEOF
#define UUID_H <$UUID_H>
_ACEOF
has_uuid=true
fi
if test x"$has_uuid" != "x"; then
ac_fn_c_check_func "$LINENO" "uuid_create" "ac_cv_func_uuid_create"
if test "x$ac_cv_func_uuid_create" = xyes; then :
has_uuid=true
@ -12024,7 +12094,7 @@ fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_uuid_uuid_create" >&5
$as_echo "$ac_cv_lib_uuid_uuid_create" >&6; }
if test "x$ac_cv_lib_uuid_uuid_create" = xyes; then :
CLIB_LIBUUID=-luuid
CLIB_LIBUUID="$UUID_LIB_PATH -luuid"
has_uuid=true
fi
@ -12038,45 +12108,6 @@ $as_echo "$as_me: WARNING: Cannot find libossp-uuid or libuuid -- dropping uuid
fi
if test x"$has_uuid" != "x"; then
if test x"$UUID_H" = "x"; then
ac_fn_c_check_header_compile "$LINENO" "ossp/uuid.h" "ac_cv_header_ossp_uuid_h" "/*first*/
"
if test "x$ac_cv_header_ossp_uuid_h" = xyes; then :
UUID_H=ossp/uuid.h
fi
fi
if test x"$UUID_H" = "x" -a ! -d /usr/include/uuid; then
ac_fn_c_check_header_compile "$LINENO" "uuid/uuid.h" "ac_cv_header_uuid_uuid_h" "/*first*/
"
if test "x$ac_cv_header_uuid_uuid_h" = xyes; then :
UUID_H=uuid/uuid.h
fi
fi
if test x"$UUID_H" = "x"; then
ac_fn_c_check_header_compile "$LINENO" "uuid.h" "ac_cv_header_uuid_h" "/*first*/
"
if test "x$ac_cv_header_uuid_h" = xyes; then :
UUID_H=uuid.h
fi
fi
if test x"$UUID_H" = "x"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Cannot find uuid.h -- dropping uuid.pl" >&5
$as_echo "$as_me: WARNING: Cannot find uuid.h -- dropping uuid.pl" >&2;}
else
cat >>confdefs.h <<_ACEOF
#define UUID_H <$UUID_H>
_ACEOF
CLIB_TARGETS="$CLIB_TARGETS uuid.$SO"
fi
fi
@ -14317,7 +14348,7 @@ else
JAVA_TEST=Test.java
CLASS_TEST=Test.class
cat << \EOF > $JAVA_TEST
/* #line 14320 "configure" */
/* #line 14351 "configure" */
public class Test {
}
EOF
@ -14493,7 +14524,7 @@ EOF
if uudecode$EXEEXT Test.uue; then
ac_cv_prog_uudecode_base64=yes
else
echo "configure: 14496: uudecode had trouble decoding base 64 file 'Test.uue'" >&5
echo "configure: 14527: uudecode had trouble decoding base 64 file 'Test.uue'" >&5
echo "configure: failed file was:" >&5
cat Test.uue >&5
ac_cv_prog_uudecode_base64=no
@ -14624,7 +14655,7 @@ else
JAVA_TEST=Test.java
CLASS_TEST=Test.class
cat << \EOF > $JAVA_TEST
/* #line 14627 "configure" */
/* #line 14658 "configure" */
public class Test {
}
EOF
@ -14659,7 +14690,7 @@ JAVA_TEST=Test.java
CLASS_TEST=Test.class
TEST=Test
cat << \EOF > $JAVA_TEST
/* [#]line 14662 "configure" */
/* [#]line 14693 "configure" */
public class Test {
public static void main (String args[]) {
System.exit (0);

View File

@ -53,6 +53,7 @@ macro_log_feature (SQLITE3_FOUND "SQLite3"
"http://www.sqlite3.org" FALSE)
if (ODBC_FOUND OR MYSQL_FOUND OR SQLITE3_FOUND)
add_definitions (-DUSE_MYDDAS=1)
add_library (myddas SHARED ${MYDDAS_SOURCES})
target_link_libraries(myddas libYap)
if (ODBC_FOUND)

View File

@ -48,7 +48,7 @@ MYDDAS_SOURCES= \
myddas_mysql.c \
myddas_odbc.c \
myddas_sqlite3.c \
myddas_util.c \
myddas_util.c \
myddas_initialization.c \
myddas_shared.c \
myddas_statistics.c \
@ -93,8 +93,8 @@ install_myddas:
if [ $$count -ne 0 ]; then \
mkdir -p $(DESTDIR)$(SHAREDIR); \
for p in $(MYDDAS_PROLOG); \
do name=`basename $$p .ypp`; echo $$name;\
cpp $(YAP_EXTRAS) -P -E -w $$p > $(DESTDIR)$(SHAREDIR)/$$name.yap; \
do name=`basename $$p .ypp`; echo $$name;\
cpp $(YAP_EXTRAS) -P -E -w $$p > $(DESTDIR)$(SHAREDIR)/$$name.yap; \
done; \
fi

View File

@ -1,6 +1,6 @@
/* MYDDAS */
#if defined MYDDAS_MYSQL || defined MYDDAS_ODCB || defined MYDDAS_SQLITE3
#ifdef USE_MYDDAS
/* myddas_initialization.c */
MYDDAS_GLOBAL myddas_init_initialize_myddas(void);
@ -71,4 +71,3 @@ void Yap_InitBackMYDDAS_SharedPreds(void);
#if defined MYDDAS_TOP_LEVEL && defined MYDDAS_MYSQL //&& defined HAVE_LIBREADLINE
void Yap_InitMYDDAS_TopLevelPreds(void);
#endif

View File

@ -14,8 +14,8 @@ AC_ARG_ENABLE(myddas,
else
yap_cv_myddas=$withval
LDFLAGS="$LDFLAGS -L${yap_cv_myddas}/lib "
CPPFLAGS="$CPPFLAGS -I${yap_cv_myddas}/include "
MYDDAS_CPPFLAGS="$MYDDAS_CPPFLAGS -I${yap_cv_myddas}/include "
CPPFLAGS="$CPPFLAGS -I${yap_cv_myddas}/include "
MYDDAS_CPPFLAGS="$MYDDAS_CPPFLAGS -I${yap_cv_myddas}/include "
fi,
[yap_cv_myddas=/usr])
@ -28,7 +28,7 @@ AC_ARG_WITH(mysql,
else
yap_cv_mysql=$withval
LDFLAGS="$LDFLAGS -L${yap_cv_mysql}/lib "
CPPFLAGS="$CPPFLAGS -I${yap_cv_mysql}/include "
CPPFLAGS="$CPPFLAGS -I${yap_cv_mysql}/include "
MYDDAS_CPPFLAGS="$MYDDAS_CPPFLAGS -I${yap_cv_mysql}/include "
fi,
[yap_cv_mysql=/usr])
@ -42,7 +42,7 @@ AC_ARG_WITH(odbc,
else
yap_cv_odbc=$withval
LDFLAGS="$LDFLAGS -L${yap_cv_odbc}/lib "
CPPFLAGS="$CPPFLAGS -I${yap_cv_odbc}/include "
CPPFLAGS="$CPPFLAGS -I${yap_cv_odbc}/include "
MYDDAS_CPPFLAGS="$MYDDAS_CPPFLAGS -I${yap_cv_odbc}/include "
fi,
[yap_cv_odbc=/usr])
@ -56,8 +56,8 @@ AC_ARG_WITH(sqlite3,
else
yap_cv_sqlite3=$withval
LDFLAGS="$LDFLAGS -L${yap_cv_sqlite3}/lib "
CPPFLAGS="$CPPFLAGS -I${yap_cv_sqlite3}/include "
MYDDAS_CPPFLAGS="$MYDDAS_CPPFLAGS -I${yap_cv_sqlite3}/include "
CPPFLAGS="$CPPFLAGS -I${yap_cv_sqlite3}/include "
MYDDAS_CPPFLAGS="$MYDDAS_CPPFLAGS -I${yap_cv_sqlite3}/include "
fi,
[yap_cv_sqlite3=/usr])
@ -83,17 +83,18 @@ then
dnl check for mysql
AC_SEARCH_LIBS(mysql_init, [mysqlclient], [yap_cv_mysql="yes" MYDDAS_LIBS="-lmysqlclient $MYDDAS_LIBS"], [yap_cv_mysql="no"])
AC_CHECK_HEADERS(mysql/mysql.h, [], [yap_cv_mysql="no"])
if test "$yap_cv_mysql" = yes
if test "$yap_cv_mysql" = yes
then
YAP_EXTRAS="$YAP_EXTRAS -DMYDDAS_MYSQL"
use_myddas=true
YAP_EXTRAS="$YAP_EXTRAS -DMYDDAS_MYSQL"
fi
dnl check for odbc
case "$target_os" in
*darwin*)
LIBS="$LIBS -framework CoreFoundation"
;;
**)
**)
;;
esac
AC_SEARCH_LIBS(SQLAllocHandle, [odbc], [yap_cv_odbc="yes"], [yap_cv_odbc="no"])
@ -116,11 +117,12 @@ then
#from SWI ODBC library.
AC_CHECK_HEADERS(windef.h)
AC_CHECK_HEADERS(sql.h, [yap_cv_odbc="yes" ], [yap_cv_odbc="no"])
if test "$yap_cv_odbc" != no
if test "$yap_cv_odbc" != no
then
use_myddas=true
YAP_EXTRAS="$YAP_EXTRAS -DMYDDAS_ODBC"
fi
#from SWI PROSQLITE library.
AC_CHECK_LIB(sqlite3, sqlite3_open,
LIBS="-lsqlite3 $LIBS"
@ -128,8 +130,9 @@ then
AC_CHECK_HEADERS(sqlite3.h, [], [yap_cv_sqlite3="no"])
if test "$yap_cv_sqlite3" != no
if test "$yap_cv_sqlite3" != no
then
use_myddas=true
YAP_EXTRAS="$YAP_EXTRAS -DMYDDAS_SQLITE3"
fi
@ -143,15 +146,18 @@ then
YAP_EXTRAS="$YAP_EXTRAS -DMYDDAS_TOP_LEVEL"
fi
if test "$use_myddas" = true; then
YAP_EXTRAS="$YAP_EXTRAS -DUSE_MYDDAS=1"
fi
MYDDAS_LIBS="$LIBS"
LIBS="$OLD_LIBS"
CPPFLAGS="$OLD_CPPFLAGS"
LIBS="$OLD_LIBS"
CPPFLAGS="$OLD_CPPFLAGS"
else
ENABLE_MYDDAS=""
fi
fi
AC_SUBST(PKG_MYDDAS)
AC_SUBST(MYDDAS_CPPFLAGS)
AC_SUBST(MYDDAS_LIBS)

View File

@ -1,4 +1,4 @@
#if defined MYDDAS_ODBC || defined MYDDAS_MYSQL || defined MYDDAS_SQLITE3
#ifdef USE_MYDDAS
#include <stdio.h>
#include <stdlib.h>
@ -15,13 +15,13 @@
MYDDAS_GLOBAL
myddas_init_initialize_myddas(void){
MYDDAS_GLOBAL global = NULL;
/* We cannot call MYDDAS_MALLOC were because the global
register isn't yet initialized */
global = (MYDDAS_GLOBAL) malloc (sizeof(struct myddas_global));
#ifdef DEBUG
printf ("MALLOC %p %s %d\n",global,__FILE__,__LINE__);
#endif
#endif
global->myddas_top_connections = NULL;
#ifdef MYDDAS_TOP_LEVEL
global->myddas_top_level_connection = NULL;
@ -30,7 +30,7 @@ myddas_init_initialize_myddas(void){
global->myddas_statistics = (MYDDAS_GLOBAL_STATS) malloc (sizeof(struct myddas_global_stats));
#ifdef DEBUG
printf ("MALLOC %p %s %d\n",global->myddas_statistics,__FILE__,__LINE__);
#endif
#endif
global->myddas_statistics->stats = NULL;
#endif
@ -46,18 +46,18 @@ myddas_init_initialize_myddas(void){
global->free_called = 0;
global->memory_freed = 0;
#endif
return global;
}
/* Inserts the new node on the front of the list */
MYDDAS_UTIL_CONNECTION
MYDDAS_UTIL_CONNECTION
myddas_init_initialize_connection(void *conn,void *enviromment,
MYDDAS_UTIL_CONNECTION next){
CACHE_REGS
MYDDAS_UTIL_CONNECTION new = NULL;
MYDDAS_MALLOC(new,struct myddas_list_connection);
if (new == NULL)
{
return NULL;
@ -74,11 +74,11 @@ myddas_init_initialize_connection(void *conn,void *enviromment,
/* List integrity */
new->next=next;
new->previous=NULL;
/* If there's already at least one node
/* If there's already at least one node
on the list */
if (next != NULL)
next->previous=new;
#ifdef MYDDAS_STATS
new->stats = NULL;
new->stats = myddas_stats_initialize_connection_stats();
@ -86,30 +86,30 @@ myddas_init_initialize_connection(void *conn,void *enviromment,
return new;
}
MYDDAS_UTIL_PREDICATE
MYDDAS_UTIL_PREDICATE
myddas_init_initialize_predicate(char *pred_name, int pred_arity,
char *pred_module, MYDDAS_UTIL_PREDICATE next){
CACHE_REGS
MYDDAS_UTIL_PREDICATE new = NULL;
MYDDAS_MALLOC(new,struct myddas_list_preds);
if (new == NULL)
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
/* If there's already at least one node
on the list */
if (next != NULL)
next->previous=new;
return new;
}
#endif
#endif

View File

@ -15,7 +15,7 @@
* *
*************************************************************************/
#if defined MYDDAS_MYSQL || defined MYDDAS_ODBC
#ifdef USE_MYDDAS
#include "Yap.h"
#include "Yatom.h"
@ -44,7 +44,7 @@ static Int c_db_stats( USES_REGS1 );
static Int c_db_stats_walltime( USES_REGS1 );
static Int c_db_stats_translate( USES_REGS1 );
static Int c_db_stats_time( USES_REGS1 );
#endif
#endif
#ifdef DEBUG
static Int c_db_check( USES_REGS1 );
#endif
@ -53,7 +53,7 @@ void Yap_InitMYDDAS_SharedPreds(void)
{
/* c_db_initialize_myddas */
Yap_InitCPred("c_db_initialize_myddas",0,c_db_initialize_myddas, 0);
/* c_db_connection_type: Connection x Type */
Yap_InitCPred("c_db_connection_type",2,c_db_connection_type, 0);
@ -62,7 +62,7 @@ void Yap_InitMYDDAS_SharedPreds(void)
/* c_db_check_if_exists_pred : PredName * Arity * Connection */
Yap_InitCPred("c_db_check_if_exists_pred",3,c_db_check_if_exists_pred, 0);
/* c_db_delete_pred : Module * PredName * Arity */
Yap_InitCPred("c_db_delete_predicate",3,c_db_delete_predicate, 0);
@ -92,20 +92,20 @@ void Yap_InitBackMYDDAS_SharedPreds(void)
{
/* Gives all the predicates associated to a given connection */
Yap_InitCPredBack("c_db_preds_conn", 4, sizeof(Int),
c_db_preds_conn_start,
c_db_preds_conn_start,
c_db_preds_conn_continue, 0);
/* Gives all the connections stored on the MYDDAS Structure*/
Yap_InitCPredBack("c_db_connection", 1, sizeof(Int),
c_db_connection_start,
c_db_connection_continue, 0);
c_db_connection_start,
c_db_connection_continue, 0);
}
/* Initialize all of the MYDDAS global structures */
static Int
static Int
c_db_initialize_myddas( USES_REGS1 ){
Yap_REGS.MYDDAS_GLOBAL_POINTER = myddas_init_initialize_myddas();
Yap_REGS.MYDDAS_GLOBAL_POINTER = myddas_init_initialize_myddas();
#ifdef MYDDAS_STATS
Yap_REGS.MYDDAS_GLOBAL_POINTER = myddas_stats_initialize_global_stats(Yap_REGS.MYDDAS_GLOBAL_POINTER);
#endif /* MYDDAS_STATS */
@ -113,40 +113,40 @@ c_db_initialize_myddas( USES_REGS1 ){
}
/* Gives the type of a given connection,
in other words, type will be mysql or odbc
/* Gives the type of a given connection,
in other words, type will be mysql or odbc
NOTE: In order to use this predicate, the connection*/
/* c_db_connection_type: +Connection * ?Type */
static Int
static Int
c_db_connection_type ( USES_REGS1 ){
Term arg_con = Deref(ARG1);
Term arg_type = Deref(ARG2);
Int *con = (Int *) IntegerOfTerm(arg_con);
Int type = myddas_util_connection_type(con);
if (type == 1) /* MYSQL Connection */
Yap_unify(arg_type, MkAtomTerm(Yap_LookupAtom("mysql")));
else if (type ==2) /* ODBC Connection */
Yap_unify(arg_type, MkAtomTerm(Yap_LookupAtom("odbc")));
else /* Not a valid connection*/
return FALSE;
return TRUE;
}
/* db_add_preds: PredName * Arity * Module * Connection*/
static Int
static Int
c_db_add_preds ( USES_REGS1 ){
Term arg_nome = Deref(ARG1);
Term arg_aridade = Deref(ARG2);
Term arg_module = Deref(ARG3);
Term arg_conn = Deref(ARG4);
/* PredEntry *pe; */
/* pe = RepPredProp(PredPropByFunc(FunctorOfTerm(arg_pred),arg_module)); */
char *nome = AtomName(AtomOfTerm(arg_nome));
char *module = AtomName(AtomOfTerm(arg_module));
@ -160,22 +160,22 @@ c_db_add_preds ( USES_REGS1 ){
#endif
return FALSE;
}
return TRUE;
}
static Int
static Int
c_db_check_if_exists_pred ( USES_REGS1 ){
Term arg_nome = Deref(ARG1);
Term arg_aridade = Deref(ARG2);
Term arg_module = Deref(ARG3);
char *nome = AtomName(AtomOfTerm(arg_nome));
char *module = AtomName(AtomOfTerm(arg_module));
Int aridade = IntegerOfTerm(arg_aridade);
if (myddas_util_search_predicate(nome,aridade,module) == NULL)
return FALSE;
else
@ -183,17 +183,17 @@ c_db_check_if_exists_pred ( USES_REGS1 ){
}
static Int
static Int
c_db_delete_predicate( USES_REGS1 ){
Term arg_module = Deref(ARG1);
Term arg_name = Deref(ARG2);
Term arg_arity = Deref(ARG3);
char *module = AtomName(AtomOfTerm(arg_module));
char *name = AtomName(AtomOfTerm(arg_name));
Int arity = IntegerOfTerm(arg_arity);
MYDDAS_UTIL_PREDICATE predicate =
MYDDAS_UTIL_PREDICATE predicate =
myddas_util_search_predicate(name,arity,module);
if (predicate == NULL)
return FALSE;
@ -204,29 +204,29 @@ c_db_delete_predicate( USES_REGS1 ){
}
static Int
static Int
c_db_multi_queries_number( USES_REGS1 ){
Term arg_conn = Deref(ARG1);
Term arg_number = Deref(ARG2);
Int *conn = (Int *) IntegerOfTerm(arg_conn);
MYDDAS_UTIL_CONNECTION node =
MYDDAS_UTIL_CONNECTION node =
myddas_util_search_connection(conn);
if (node == NULL)
return FALSE;
if (IsVarTerm(arg_number)){
Yap_unify(arg_number,MkIntegerTerm(((Int)myddas_util_get_total_multi_queries_number(node))+1));
}
}
else {
Int number = IntegerOfTerm(arg_number);
number--;
myddas_util_set_total_multi_queries_number(node,number);
}
return TRUE;
}
static Int
@ -236,17 +236,17 @@ c_db_connection_start( USES_REGS1 ){
Yap_REGS.MYDDAS_GLOBAL_POINTER->myddas_top_connections;
EXTRA_CBACK_ARG(1,1)=(CELL) MkIntegerTerm((Int)node);
return (c_db_connection_continue( PASS_REGS1 ));
}
static Int
c_db_connection_continue( USES_REGS1 ){
Term arg_conn = Deref(ARG1);
MYDDAS_UTIL_CONNECTION node;
node = (MYDDAS_UTIL_CONNECTION) IntegerOfTerm(EXTRA_CBACK_ARG(1,1));
/* There is no connections */
if (node == NULL)
{
@ -256,35 +256,35 @@ c_db_connection_continue( USES_REGS1 ){
Yap_unify(arg_conn, MkIntegerTerm((Int)(node->connection)));
EXTRA_CBACK_ARG(1,1)=(CELL) MkIntegerTerm((Int)(node->next));
return TRUE;
}
/* db_preds_conn : Connection(+) * Pred_name(-) * Pred_arity */
static Int
c_db_preds_conn_start ( USES_REGS1 ){
Term arg_conn = Deref(ARG1);
Int *conn = (Int *) IntegerOfTerm(arg_conn);
MYDDAS_UTIL_CONNECTION node =
MYDDAS_UTIL_CONNECTION node =
myddas_util_search_connection(conn);
/* Caso a ligacao já tenha sido apagada*/
if (node == NULL)
{
cut_fail();
return FALSE;
}
void *pointer = myddas_util_get_list_pred(node);
EXTRA_CBACK_ARG(4,1)=(CELL) MkIntegerTerm((Int)pointer);
return (c_db_preds_conn_continue( PASS_REGS1 ));
}
/* db_preds_conn : Connection(+) * Pred_name(-) * Pred_arity*/
static Int
static Int
c_db_preds_conn_continue ( USES_REGS1 ){
Term module = Deref(ARG2);
Term name = Deref(ARG3);
@ -292,11 +292,11 @@ c_db_preds_conn_continue ( USES_REGS1 ){
void *pointer;
pointer = (void *) IntegerOfTerm(EXTRA_CBACK_ARG(4,1));
if (pointer != NULL)
{
EXTRA_CBACK_ARG(4,1)=(CELL) MkIntegerTerm((Int)myddas_util_get_pred_next(pointer));
if (!Yap_unify(module, MkAtomTerm(Yap_LookupAtom(myddas_util_get_pred_module(pointer))))){
return FALSE;
}
@ -318,7 +318,7 @@ c_db_preds_conn_continue ( USES_REGS1 ){
#ifdef DEBUG
static Int
static Int
c_db_check( USES_REGS1 ){
check_int();
return TRUE;
@ -352,7 +352,7 @@ c_db_stats_translate( USES_REGS1 ){
MYDDAS_STATS_TIME start;
MYDDAS_STATS_TIME end;
MYDDAS_STATS_TIME total_time,diff;
#ifdef DEBUG
@ -363,20 +363,20 @@ c_db_stats_translate( USES_REGS1 ){
end = (MYDDAS_STATS_TIME) IntegerOfTerm(arg_end);
MYDDAS_STATS_GET_TRANSLATE(total_time);
MYDDAS_STATS_INITIALIZE_TIME_STRUCT(diff,time_copy);
myddas_stats_subtract_time(diff,end,start);
diff = myddas_stats_time_copy_to_final(diff);
myddas_stats_add_time(total_time,diff,total_time);
MyddasULInt count;
MYDDAS_STATS_GET_TRANSLATE_COUNT(count);
MYDDAS_STATS_SET_TRANSLATE_COUNT(++count);
MYDDAS_FREE(diff,struct myddas_stats_time_struct);
MYDDAS_FREE(start, struct myddas_stats_time_struct);
MYDDAS_FREE(end, struct myddas_stats_time_struct);
return TRUE;
#ifdef DEBUG
}
@ -391,9 +391,9 @@ static Int
c_db_stats_time( USES_REGS1 ){
Term arg_reference = Deref(ARG1);
Term arg_time = Deref(ARG2);
Term final_term;
MYDDAS_STATS_STRUCT struc = (MYDDAS_STATS_STRUCT)IntegerOfTerm(arg_reference);
Functor functor_count = Yap_MkFunctor(Yap_LookupAtom("count"),1);
Term count_number[1];
@ -401,7 +401,7 @@ c_db_stats_time( USES_REGS1 ){
Term number[1];
switch(struc->type){
case integer:
{
Functor functor = Yap_MkFunctor(Yap_LookupAtom("myddas_integer"),2);
@ -412,26 +412,26 @@ c_db_stats_time( USES_REGS1 ){
integer = struc->u.integer.integer;
number[0] = MkIntegerTerm(integer);
integer_number[0] = Yap_MkApplTerm(unit,1,number);;
count_number[0] = MkIntegerTerm(struc->count);
integer_number[1] = Yap_MkApplTerm(functor_count,1,count_number);
final_term = Yap_MkApplTerm(functor,2,integer_number);
break;
}
case time_str:
{
MYDDAS_STATS_TIME time = struc->u.time_str.time_str;
Functor functor = Yap_MkFunctor(Yap_LookupAtom("myddas_time"),6);
Term time_numbers[6];
MyddasUInt time_number;
unit = Yap_MkFunctor(Yap_LookupAtom("hours"),1);
time_number = MYDDAS_STATS_TIME_HOURS(time);
number[0] = MkIntegerTerm(time_number);
time_numbers[0] = Yap_MkApplTerm(unit,1,number);;
unit = Yap_MkFunctor(Yap_LookupAtom("minutes"),1);
time_number = MYDDAS_STATS_TIME_MINUTES(time);
number[0] = MkIntegerTerm(time_number);
@ -441,23 +441,23 @@ c_db_stats_time( USES_REGS1 ){
time_number = MYDDAS_STATS_TIME_SECONDS(time);
number[0] = MkIntegerTerm(time_number);
time_numbers[2] = Yap_MkApplTerm(unit,1,number);;
unit = Yap_MkFunctor(Yap_LookupAtom("miliseconds"),1);
time_number = MYDDAS_STATS_TIME_MILISECONDS(time);
number[0] = MkIntegerTerm(time_number);
time_numbers[3] = Yap_MkApplTerm(unit,1,number);;
unit = Yap_MkFunctor(Yap_LookupAtom("microseconds"),1);
time_number = MYDDAS_STATS_TIME_MICROSECONDS(time);
time_number = MYDDAS_STATS_TIME_MICROSECONDS(time);
number[0] = MkIntegerTerm(time_number);
time_numbers[4] = Yap_MkApplTerm(unit,1,number);;
count_number[0] = MkIntegerTerm(struc->count);
time_numbers[5] = Yap_MkApplTerm(functor_count,1,count_number);
final_term = Yap_MkApplTerm(functor,6,time_numbers);
break;
}
default:
#ifdef DEBUG
printf ("ERROR: c_db_stats_time unknow option\n");
@ -465,7 +465,7 @@ c_db_stats_time( USES_REGS1 ){
return FALSE;
break;
}
if (!Yap_unify(arg_time,final_term )){
return FALSE;
}
@ -474,20 +474,20 @@ c_db_stats_time( USES_REGS1 ){
}
//Returns the stats of this module in a list
static Int
static Int
c_db_stats( USES_REGS1 ) {
Term arg_conn = Deref(ARG1);
Term arg_list = Deref(ARG2);
MyddasPointer *conn = (MyddasPointer *) (IntegerOfTerm(arg_conn));
// TODO
if (get_myddas_top() == 0 ){ /* We want all the statistics */
return FALSE;
}
MYDDAS_STATS_STRUCT str;
MYDDAS_UTIL_CONNECTION
MYDDAS_UTIL_CONNECTION
node = myddas_util_search_connection(conn);
Term head, list;
list = arg_list;
@ -514,7 +514,7 @@ c_db_stats( USES_REGS1 ) {
// processing all the SQL Querys
head = HeadOfTerm(list);
list = TailOfTerm(list);
str = myddas_stats_get_stat(node->stats,1);
Yap_unify(head, MkIntegerTerm((MyddasInt)str));
#ifdef DEBUG
@ -522,13 +522,13 @@ c_db_stats( USES_REGS1 ) {
printf ("Reference to time Spent by the Server, on all the SQL Querys\n");
MYDDAS_STATS_PRINT_TIME_STRUCT(time);
printf ("\n\n");
#endif
#endif
//[Index 3] -> Total of Time Spent by the DB Server
// processing a the last SQL Query
head = HeadOfTerm(list);
list = TailOfTerm(list);
str = myddas_stats_get_stat(node->stats,2);
Yap_unify(head, MkIntegerTerm((MyddasInt)str));
#ifdef DEBUG
@ -537,12 +537,12 @@ c_db_stats( USES_REGS1 ) {
MYDDAS_STATS_PRINT_TIME_STRUCT(time);
printf ("\n\n");
#endif
//[Index 4] -> Total of Time Spent by the DB Server
// transfering all the results of the SQL Querys
head = HeadOfTerm(list);
list = TailOfTerm(list);
str = myddas_stats_get_stat(node->stats,3);
Yap_unify(head, MkIntegerTerm((MyddasInt)str));
#ifdef DEBUG
@ -551,12 +551,12 @@ c_db_stats( USES_REGS1 ) {
MYDDAS_STATS_PRINT_TIME_STRUCT(time);
printf ("\n\n");
#endif
//[Index 5] -> Total of Time Spent by the DB Server
// transfering the result of the last SQL Query
head = HeadOfTerm(list);
list = TailOfTerm(list);
str = myddas_stats_get_stat(node->stats,4);
Yap_unify(head, MkIntegerTerm((MyddasInt)str));
#ifdef DEBUG
@ -565,14 +565,14 @@ c_db_stats( USES_REGS1 ) {
MYDDAS_STATS_PRINT_TIME_STRUCT(time);
printf ("\n\n");
#endif
//[Index 6] -> Total of Time Spent by the
//[Index 6] -> Total of Time Spent by the
// db_row_function
head = HeadOfTerm(list);
list = TailOfTerm(list);
str = myddas_stats_get_stat(Yap_REGS.MYDDAS_GLOBAL_POINTER->myddas_statistics->stats,1);
Yap_unify(head, MkIntegerTerm((MyddasInt)str));
#ifdef DEBUG
MYDDAS_STATS_GET_DB_ROW_FUNCTION(time);
@ -580,8 +580,8 @@ c_db_stats( USES_REGS1 ) {
MYDDAS_STATS_PRINT_TIME_STRUCT(time);
printf ("\n\n");
#endif
//[Index 7] -> Total of Bytes Transfered by the
//[Index 7] -> Total of Bytes Transfered by the
// DB Server on all SQL Querys
head = HeadOfTerm(list);
list = TailOfTerm(list);
@ -593,12 +593,12 @@ c_db_stats( USES_REGS1 ) {
printf ("Bytes Transfered by the DB Server from all querys\n");
printf ("%llu\n\n",(MyddasULInt)number);
#endif
//[Index 8] -> Total of Bytes Transfered by the
//[Index 8] -> Total of Bytes Transfered by the
// DB Server on the last SQL Query
head = HeadOfTerm(list);
list = TailOfTerm(list);
str = myddas_stats_get_stat(node->stats,7);
Yap_unify(head, MkIntegerTerm((MyddasPointer)str));
#ifdef DEBUG
@ -618,7 +618,7 @@ c_db_stats( USES_REGS1 ) {
printf ("%llu\n\n",(MyddasULInt)number);
#endif
//[Index 10] -> Total of Time Spent by the
//[Index 10] -> Total of Time Spent by the
// translate predicate
head = HeadOfTerm(list);
list = TailOfTerm(list);
@ -640,13 +640,13 @@ c_db_stats( USES_REGS1 ) {
printf ("Number of times malloc was called in MYDDAS: %lu \n",nr);
MYDDAS_MEMORY_FREE_NR(nr);
printf ("Number of times free was called in MYDDAS : %lu \n",nr);
MYDDAS_MEMORY_MALLOC_SIZE(nr);
printf ("Total memory allocated in MYDDAS: %lu \n",nr);
MYDDAS_MEMORY_FREE_SIZE(nr);
printf ("Total memory freed in MYDDAS : %lu \n",nr);
#endif
return TRUE;
}
@ -660,7 +660,7 @@ void Yap_MYDDAS_delete_all_myddas_structs(void)
CACHE_REGS
/* NAO ESQUECER DE FAZER ISTO TB PARA O DB_CLOSE*/
MYDDAS_GLOBAL global =
MYDDAS_GLOBAL global =
Yap_REGS.MYDDAS_GLOBAL_POINTER;
/* In case that the MYDDAS module isn't loaded */
@ -669,11 +669,11 @@ void Yap_MYDDAS_delete_all_myddas_structs(void)
MYDDAS_UTIL_CONNECTION connections =
global->myddas_top_connections;
/* Delete all connections */
for(;connections!=NULL;connections=connections->next)
myddas_util_delete_connection(connections->connection);
#ifdef MYDDAS_STATS
myddas_stats_delete_stats_list(global->myddas_statistics->stats);
MYDDAS_FREE(global->myddas_statistics,struct myddas_global_stats);
@ -687,13 +687,13 @@ void Yap_MYDDAS_delete_all_myddas_structs(void)
printf ("Number of times malloc was called in MYDDAS: " UInt_FORMAT " \n",(UInt)nr);
MYDDAS_MEMORY_FREE_NR(nr);
printf ("Number of times free was called in MYDDAS : " UInt_FORMAT " \n",(UInt)nr);
MYDDAS_MEMORY_MALLOC_SIZE(nr);
printf ("Total memory allocated in MYDDAS: " UInt_FORMAT " \n",(UInt)nr);
MYDDAS_MEMORY_FREE_SIZE(nr);
printf ("Total memory freed in MYDDAS : " UInt_FORMAT " \n",(UInt)nr);
#endif
}
@ -725,11 +725,11 @@ init_myddas(void)
#ifdef MYDDAS_MYSQL_INIT
if (yap_init->myddas) {
Yap_PutValue(AtomMyddasGoal,MkIntegerTerm(yap_init->myddas));
/* Mandatory Fields */
Yap_PutValue(AtomMyddasUser,MkAtomTerm(Yap_LookupAtom(yap_init->myddas_user)));
Yap_PutValue(AtomMyddasDB,MkAtomTerm(Yap_LookupAtom(yap_init->myddas_db)));
/* Non-Mandatory Fields */
if (yap_init->myddas_pass != NULL)
Yap_PutValue(AtomMyddasPass,MkAtomTerm(Yap_LookupAtom(yap_init->myddas_pass)));
@ -756,7 +756,7 @@ int WINAPI PROTO(win_myddas, (HANDLE, DWORD, LPVOID));
int WINAPI win_myddas(HANDLE hinst, DWORD reason, LPVOID reserved)
{
switch (reason)
switch (reason)
{
case DLL_PROCESS_ATTACH:
break;