summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStig Bakken <ssb@php.net>1999-04-20 01:03:12 (GMT)
committerStig Bakken <ssb@php.net>1999-04-20 01:03:12 (GMT)
commit54468d2e75aeb1ace053ff405f5f539a0012ba76 (patch)
treee308e39abaefdb62a90deaeb6329ca023f815592
parentb7c30c1bdf209bc270755bcafac45908fc8daf2f (diff)
downloadphp-54468d2e75aeb1ace053ff405f5f539a0012ba76.tar.gz
odbc compiles and runs on UNIX again (tested with Solid 2.3)
-rw-r--r--Makefile.in5
-rw-r--r--acconfig.h.in62
-rw-r--r--acinclude.m447
-rw-r--r--build-defs.h.in7
-rw-r--r--config.h.in78
-rw-r--r--ext/odbc/config.m448
-rw-r--r--ext/odbc/odbc.c779
-rw-r--r--ext/odbc/php3_odbc.h680
-rw-r--r--internal_functions.c2
-rw-r--r--main/php.h7
-rwxr-xr-xscripts/preconfig4
11 files changed, 541 insertions, 1178 deletions
diff --git a/Makefile.in b/Makefile.in
index 07dd3f5..f363e5e 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -86,7 +86,8 @@ LIBS = $(PHPLIBS) $(EXTRA_LIBS) @SYBASE_CT_LFLAGS@ @SYBASE_CT_LIBS@ @FHTTPD_LIB@
all: $(BINNAME)
-all-recursive clean-recursive distclean-recursive:
+all-recursive clean-recursive distclean-recursive \
+maintainer-clean-depend-recursive:
@set fnord $(MAKEFLAGS); amf=$$2; \
for subdir in $(SUBDIRS); do \
target=`echo $@ | sed s/-recursive//`; \
@@ -140,6 +141,8 @@ distclean: clean distclean-recursive
-rm -f do-conf test/test.log extra/gd/bdf2gdfont
-rm -f doc/Makefile regex/Makefile
+maintainer-clean-depend: maintainer-clean-depend-recursive
+
bench: $(BINNAME)
./$(BINNAME) -c. tests/bench.phtml
diff --git a/acconfig.h.in b/acconfig.h.in
index 663f5b9..c5d3f9e 100644
--- a/acconfig.h.in
+++ b/acconfig.h.in
@@ -1,4 +1,9 @@
-/* This is the default configuration file to read */
+/* This is the default configuration file to read -*- C -*- */
+
+/* these are defined by automake */
+#undef PACKAGE
+#undef VERSION
+
#define CONFIGURATION_FILE_PATH "php3.ini"
#define USE_CONFIG_FILE 1
@@ -29,15 +34,9 @@
/* Define if you have the resolv library (-lresolv). */
#define HAVE_LIBRESOLV 0
-/* Define if you have the gd library (-lgd). */
-#define HAVE_LIBGD 0
-
/* Define if you have the zlib library */
#define HAVE_ZLIB 0
-/* Define if you have the gd version 1.3 library (-lgd). */
-#define HAVE_LIBGD13 0
-
/* Define if you want safe mode enabled by default. */
#define PHP_SAFE_MODE 0
@@ -55,21 +54,7 @@
/* in GET/POST/Cookie data */
#define MAGIC_QUOTES 1
-/* Define if you want the logging to go to ndbm/gdbm/flatfile */
-#define LOG_DBM 0
-#define LOG_DBM_DIR "."
-
-/* Define if you want the logging to go to a mysql database */
-#define LOG_MYSQL 0
-
-/* Define if you want the logging to go to a mysql database */
-#define LOG_MSQL 0
-
-/* Define these if you are using an SQL database for logging */
-#define LOG_SQL_HOST ""
-#define LOG_SQL_DB ""
-
-/* Define if you an ndbm compatible library (-ldbm). */
+/* Define if you have an ndbm compatible library (-ldbm). */
#define NDBM 0
/* Define if you have the gdbm library (-lgdbm). */
@@ -79,12 +64,6 @@
#define REGEX 0
#define HSREGEX 0
-/* Define if you want Solid database support */
-#define HAVE_SOLID 0
-
-/* Define if you want to use the supplied dbase library */
-#define DBASE 0
-
/* Define if you want Hyperwave support */
#define HYPERWAVE 0
@@ -97,15 +76,6 @@
/* Define if you have the Oracle version 8 database client libraries */
#define HAVE_OCI8 0
-/* Define if you want to use the iODBC database driver */
-#define HAVE_IODBC 0
-
-/* Define if you want to use the OpenLink ODBC database driver */
-#define HAVE_OPENLINK 0
-
-/* Define if you have the AdabasD client libraries */
-#define HAVE_ADABAS 0
-
/* Define if you want the LDAP directory interface */
#define HAVE_LDAP 0
@@ -115,12 +85,6 @@
/* Define if you want the IMAP directory interface */
#define HAVE_IMAP 0
-/* Define if you want to use a custom ODBC database driver */
-#define HAVE_CODBC 0
-
-/* Define to use the unified ODBC interface */
-#define HAVE_UODBC 0
-
/* Define if you have libdl (used for dynamic linking) */
#define HAVE_LIBDL 0
@@ -157,10 +121,6 @@
/* Define if your Apache has src/include/ap_compat.h */
#define HAVE_AP_COMPAT_H 0
-#ifndef HAVE_EMPRESS
-#define HAVE_EMPRESS 0
-#endif
-
#define HAVE_SYBASE 0
#define HAVE_SYBASE_CT 0
@@ -176,10 +136,6 @@
#define HAVE_PGSQL 0
#endif
-#ifndef HAVE_VELOCIS
-#define HAVE_VELOCIS 0
-#endif
-
#ifndef HAVE_IFX
#define HAVE_IFX 0
#endif
@@ -200,8 +156,10 @@
#define MSQL1 0
#define HAVE_FILEPRO 0
-#define HAVE_SOLID 0
+
+#ifndef DEBUG /* should be set to ZEND_DEBUG */
#define DEBUG 0
+#endif
/* Define if your system has the gettimeofday() call */
#define HAVE_GETTIMEOFDAY 0
diff --git a/acinclude.m4 b/acinclude.m4
index b4220b2..84b3151 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -34,53 +34,6 @@ AC_DEFUN(AC_MSQL_VERSION,[
])
dnl
-dnl Figure out which library file to link with for the Solid support.
-dnl
-AC_DEFUN(AC_FIND_SOLID_LIBS,[
- AC_MSG_CHECKING([Solid library file])
- ac_solid_uname_s=`uname -s 2>/dev/null`
- case $ac_solid_uname_s in
- AIX) ac_solid_os=a3x;;
- HP-UX) ac_solid_os=h9x;;
- IRIX) ac_solid_os=irx;;
- Linux) ac_solid_os=lux;;
- SunOS) ac_solid_os=ssx;; # should we deal with SunOS 4?
- FreeBSD) ac_solid_os=fbx;;
- # "uname -s" on SCO makes no sense.
- esac
- SOLID_LIBS=`echo $1/scl${ac_solid_os}*.so | cut -d' ' -f1`
- if test ! -f $SOLID_LIBS; then
- SOLID_LIBS=`echo $1/scl${ac_solid_os}*.a | cut -d' ' -f1`
- fi
- if test ! -f $SOLID_LIBS; then
- SOLID_LIBS=`echo $1/scl2x${ac_solid_os}*.a | cut -d' ' -f1`
- fi
- if test ! -f $SOLID_LIBS; then
- SOLID_LIBS=`echo $1/scl2x${ac_solid_os}*.a | cut -d' ' -f1`
- fi
- if test ! -f $SOLID_LIBS; then
- SOLID_LIBS=`echo $1/bcl${ac_solid_os}*.so | cut -d' ' -f1`
- fi
- if test ! -f $SOLID_LIBS; then
- SOLID_LIBS=`echo $1/bcl${ac_solid_os}*.a | cut -d' ' -f1`
- fi
- AC_MSG_RESULT(`echo $SOLID_LIBS | sed -e 's!.*/!!'`)
-])
-
-dnl
-dnl Figure out which library file to link with for the Empress support.
-dnl
-AC_DEFUN(AC_FIND_EMPRESS_LIBS,[
- AC_MSG_CHECKING([Empress library file])
- EMPRESS_LIBS=`echo $1/empodbc.so | cut -d' ' -f1`
- if test ! -f $EMPRESS_LIBS; then
- EMPRESS_LIBS=`echo $1/empodbc.a | cut -d' ' -f1`
- fi
- AC_MSG_RESULT(`echo $EMPRESS_LIBS | sed -e 's!.*/!!'`)
-])
-
-
-dnl
dnl See if we have broken header files like SunOS has.
dnl
AC_DEFUN(AC_MISSING_FCLOSE_DECL,[
diff --git a/build-defs.h.in b/build-defs.h.in
index 4197077..4bb8330 100644
--- a/build-defs.h.in
+++ b/build-defs.h.in
@@ -83,3 +83,10 @@
#define PHP_LDAP_LIBS "@LDAP_LIBS@"
#define PHP_VELOCIS_INCLUDE "@VELOCIS_INCLUDE@"
#define PHP_VELOCIS_LIBS "@VELOCIS_LIBS@"
+
+#define ODBC_TYPE "@ODBC_TYPE@"
+#define ODBC_INCDIR "@ODBC_INCDIR@"
+#define ODBC_INCLUDE "@ODBC_INCLUDE@"
+#define ODBC_LIBDIR "@ODBC_LIBDIR@"
+#define ODBC_LFLAGS "@ODBC_LFLAGS@"
+#define ODBC_LIBS "@ODBC_LIBS@"
diff --git a/config.h.in b/config.h.in
index 7f45fed..c0c9a43 100644
--- a/config.h.in
+++ b/config.h.in
@@ -65,7 +65,10 @@
/* Define to `int' if <sys/types.h> doesn't define. */
#undef uid_t
-/* This is the default configuration file to read */
+/* these are defined by automake */
+#undef PACKAGE
+#undef VERSION
+
#define CONFIGURATION_FILE_PATH "php3.ini"
#define USE_CONFIG_FILE 1
@@ -92,15 +95,9 @@
/* Define if you have the resolv library (-lresolv). */
#define HAVE_LIBRESOLV 0
-/* Define if you have the gd library (-lgd). */
-#define HAVE_LIBGD 0
-
/* Define if you have the zlib library */
#define HAVE_ZLIB 0
-/* Define if you have the gd version 1.3 library (-lgd). */
-#define HAVE_LIBGD13 0
-
/* Define if you want safe mode enabled by default. */
#define PHP_SAFE_MODE 0
@@ -118,7 +115,7 @@
/* in GET/POST/Cookie data */
#define MAGIC_QUOTES 1
-/* Define if you an ndbm compatible library (-ldbm). */
+/* Define if you have an ndbm compatible library (-ldbm). */
#define NDBM 0
/* Define if you have the gdbm library (-lgdbm). */
@@ -128,12 +125,6 @@
#define REGEX 0
#define HSREGEX 0
-/* Define if you want Solid database support */
-#define HAVE_SOLID 0
-
-/* Define if you want to use the supplied dbase library */
-#define DBASE 0
-
/* Define if you want Hyperwave support */
#define HYPERWAVE 0
@@ -143,15 +134,6 @@
/* Define if you have the Oracle version 8 database client libraries */
#define HAVE_OCI8 0
-/* Define if you want to use the iODBC database driver */
-#define HAVE_IODBC 0
-
-/* Define if you want to use the OpenLink ODBC database driver */
-#define HAVE_OPENLINK 0
-
-/* Define if you have the AdabasD client libraries */
-#define HAVE_ADABAS 0
-
/* Define if you want the LDAP directory interface */
#define HAVE_LDAP 0
@@ -161,12 +143,6 @@
/* Define if you want the IMAP directory interface */
#define HAVE_IMAP 0
-/* Define if you want to use a custom ODBC database driver */
-#define HAVE_CODBC 0
-
-/* Define to use the unified ODBC interface */
-#define HAVE_UODBC 0
-
/* Define if you have libdl (used for dynamic linking) */
#define HAVE_LIBDL 0
@@ -203,10 +179,6 @@
/* Define if your Apache has src/include/ap_compat.h */
#define HAVE_AP_COMPAT_H 0
-#ifndef HAVE_EMPRESS
-#define HAVE_EMPRESS 0
-#endif
-
#define HAVE_SYBASE 0
#define HAVE_SYBASE_CT 0
@@ -222,10 +194,6 @@
#define HAVE_PGSQL 0
#endif
-#ifndef HAVE_VELOCIS
-#define HAVE_VELOCIS 0
-#endif
-
#ifndef HAVE_IFX
#define HAVE_IFX 0
#endif
@@ -246,8 +214,10 @@
#define MSQL1 0
#define HAVE_FILEPRO 0
-#define HAVE_SOLID 0
+
+#ifndef DEBUG /* should be set to ZEND_DEBUG */
#define DEBUG 0
+#endif
/* Define if you want to enable bc style precision math support */
#define WITH_BCMATH 0
@@ -295,6 +265,38 @@
/* Define to compile with mod_dav support */
#define HAVE_MOD_DAV 0
+/* Define if you want to use the supplied dbase library */
+#define DBASE 0
+/* Define if you have the gd library (-lgd). */
+#define HAVE_LIBGD 0
+
+/* Define if you have the gd version 1.3 library (-lgd). */
+#define HAVE_LIBGD13 0
+/* Define if you want Solid database support */
+#define HAVE_SOLID 0
+
+/* Define if you want to use the iODBC database driver */
+#define HAVE_IODBC 0
+
+/* Define if you want to use the OpenLink ODBC database driver */
+#define HAVE_OPENLINK 0
+
+/* Define if you have the AdabasD client libraries */
+#define HAVE_ADABAS 0
+
+/* Define if you want to use a custom ODBC database driver */
+#define HAVE_CODBC 0
+
+/* Define to use the unified ODBC interface */
+#define HAVE_UODBC 0
+
+#ifndef HAVE_EMPRESS
+#define HAVE_EMPRESS 0
+#endif
+
+#ifndef HAVE_VELOCIS
+#define HAVE_VELOCIS 0
+#endif
/* Define if you have the crypt function. */
#undef HAVE_CRYPT
diff --git a/ext/odbc/config.m4 b/ext/odbc/config.m4
index 8fee81c..e1429cd 100644
--- a/ext/odbc/config.m4
+++ b/ext/odbc/config.m4
@@ -4,6 +4,52 @@ dnl ODBC_LIBDIR
dnl ODBC_LIBS
dnl ODBC_LFLAGS
+dnl
+dnl Figure out which library file to link with for the Solid support.
+dnl
+AC_DEFUN(AC_FIND_SOLID_LIBS,[
+ AC_MSG_CHECKING([Solid library file])
+ ac_solid_uname_s=`uname -s 2>/dev/null`
+ case $ac_solid_uname_s in
+ AIX) ac_solid_os=a3x;;
+ HP-UX) ac_solid_os=h9x;;
+ IRIX) ac_solid_os=irx;;
+ Linux) ac_solid_os=lux;;
+ SunOS) ac_solid_os=ssx;; # should we deal with SunOS 4?
+ FreeBSD) ac_solid_os=fbx;;
+ # "uname -s" on SCO makes no sense.
+ esac
+ ODBC_LIBS=`echo $1/scl${ac_solid_os}*.so | cut -d' ' -f1`
+ if test ! -f $ODBC_LIBS; then
+ ODBC_LIBS=`echo $1/scl${ac_solid_os}*.a | cut -d' ' -f1`
+ fi
+ if test ! -f $ODBC_LIBS; then
+ ODBC_LIBS=`echo $1/scl2x${ac_solid_os}*.a | cut -d' ' -f1`
+ fi
+ if test ! -f $ODBC_LIBS; then
+ ODBC_LIBS=`echo $1/scl2x${ac_solid_os}*.a | cut -d' ' -f1`
+ fi
+ if test ! -f $ODBC_LIBS; then
+ ODBC_LIBS=`echo $1/bcl${ac_solid_os}*.so | cut -d' ' -f1`
+ fi
+ if test ! -f $ODBC_LIBS; then
+ ODBC_LIBS=`echo $1/bcl${ac_solid_os}*.a | cut -d' ' -f1`
+ fi
+ AC_MSG_RESULT(`echo $ODBC_LIBS | sed -e 's!.*/!!'`)
+])
+
+dnl
+dnl Figure out which library file to link with for the Empress support.
+dnl
+AC_DEFUN(AC_FIND_EMPRESS_LIBS,[
+ AC_MSG_CHECKING([Empress library file])
+ ODBC_LIBS=`echo $1/empodbc.so | cut -d' ' -f1`
+ if test ! -f $ODBC_LIBS; then
+ ODBC_LIBS=`echo $1/empodbc.a | cut -d' ' -f1`
+ fi
+ AC_MSG_RESULT(`echo $ODBC_LIBS | sed -e 's!.*/!!'`)
+])
+
if test -z "$ODBC_TYPE"; then
AC_MSG_CHECKING(for Adabas support)
AC_ARG_WITH(adabas,
@@ -46,7 +92,7 @@ AC_ARG_WITH(solid,
ODBC_TYPE=solid
AC_DEFINE(HAVE_SOLID)
AC_MSG_RESULT(yes)
- AC_FIND_SOLID_LIBS($SOLID_LIBDIR)
+ AC_FIND_SOLID_LIBS($ODBC_LIBDIR)
else
AC_MSG_RESULT(no)
fi
diff --git a/ext/odbc/odbc.c b/ext/odbc/odbc.c
index e2bdc84..254feb9 100644
--- a/ext/odbc/odbc.c
+++ b/ext/odbc/odbc.c
@@ -23,7 +23,7 @@
| If you did not, or have any questions about PHP licensing, please |
| contact core@php.net. |
+----------------------------------------------------------------------+
- | Authors: Stig Sæther Bakken <ssb@guardian.no> |
+ | Authors: Stig Sæther Bakken <ssb@fast.no> |
| Andreas Karajannis <Andreas.Karajannis@gmd.de> |
| Frank M. Kromann <fmk@businessnet.dk> Support for DB/2 CLI |
+----------------------------------------------------------------------+
@@ -34,137 +34,78 @@
/* This file is based on the Adabas D extension.
* Adabas D will no longer be supported as separate module.
*/
-#define IS_EXT_MODULE
-#if !PHP_31
-#undef THREAD_SAFE
-#endif
-#ifdef THREAD_SAFE
-#include "tls.h"
-#endif
-#if !(WIN32|WINNT)
-#include "config.h"
-#include "build-defs.h"
-#endif
-#include <fcntl.h>
-
#include "php.h"
-#include "dl/phpdl.h"
-#include "ext/standard/php3_standard.h"
-#include "php3_odbc.h"
-#include "functions/head.h"
-#include "snprintf.h"
-
-#if HAVE_UODBC
-
-#ifdef THREAD_SAFE
-void *UODBC_MUTEX;
-DWORD UODBC_TLS;
-static int numthreads=0;
-
-typedef struct UODBC_GLOBAL_STRUCT {
- UODBC_MODULE PHP3_UODBC_MODULE;
-} UODBC_GLOBAL_STRUCT;
-
-#define UODBC_GLOBAL(a) UODBC_GLOBALS->a
-
-#define UODBC_TLS_VARS UODBC_GLOBAL_STRUCT *UODBC_GLOBALS = TlsGetValue(UODBC_TLS);
+#undef THREAD_SAFE
-#else
-UODBC_MODULE PHP3_UODBC_MODULE;
-#define UODBC_GLOBAL(a) a
-#define UODBC_TLS_VARS
-#endif
+#if HAVE_UODBC
-function_entry UODBC_FUNCTIONS[] = {
- UODBC_FE(setoption, NULL),
- UODBC_FE(autocommit, NULL),
- UODBC_FE(close, NULL),
- UODBC_FE(close_all, NULL),
- UODBC_FE(commit, NULL),
- UODBC_FE(connect, NULL),
- UODBC_FE(pconnect, NULL),
- UODBC_FE(cursor, NULL),
- UODBC_FE_ALIAS(do, exec, NULL),
- UODBC_FE(exec, NULL),
- UODBC_FE(prepare, NULL),
- UODBC_FE(execute, NULL),
- UODBC_FE(fetch_row, NULL),
- UODBC_FE(fetch_into, NULL),
- UODBC_FE(field_len, NULL),
- UODBC_FE(field_name, NULL),
- UODBC_FE(field_type, NULL),
- UODBC_FE(field_num, NULL),
- UODBC_FE(free_result, NULL),
- UODBC_FE(num_fields, NULL),
- UODBC_FE(num_rows, NULL),
- UODBC_FE(result, NULL),
- UODBC_FE(result_all, NULL),
- UODBC_FE(rollback, NULL),
- UODBC_FE(binmode, NULL),
- UODBC_FE(longreadlen, NULL),
-#if defined(USE_ODBC_ALIAS) && defined(UODBC_UNIQUE_NAMES)
- UODBC_ALIAS(setoption, NULL),
- UODBC_ALIAS(autocommit, NULL),
- UODBC_ALIAS(close, NULL),
- UODBC_ALIAS(close_all, NULL),
- UODBC_ALIAS(commit, NULL),
- UODBC_ALIAS(connect, NULL),
- UODBC_ALIAS(pconnect, NULL),
- UODBC_ALIAS(cursor, NULL),
- UODBC_ALIAS_FE(do, exec, NULL),
- UODBC_ALIAS(exec, NULL),
- UODBC_ALIAS(prepare, NULL),
- UODBC_ALIAS(execute, NULL),
- UODBC_ALIAS(fetch_row, NULL),
- UODBC_ALIAS(fetch_into, NULL),
- UODBC_ALIAS(field_len, NULL),
- UODBC_ALIAS(field_name, NULL),
- UODBC_ALIAS(field_type, NULL),
- UODBC_ALIAS(field_num, NULL),
- UODBC_ALIAS(free_result, NULL),
- UODBC_ALIAS(num_fields, NULL),
- UODBC_ALIAS(num_rows, NULL),
- UODBC_ALIAS(result, NULL),
- UODBC_ALIAS(result_all, NULL),
- UODBC_ALIAS(rollback, NULL),
- UODBC_ALIAS(binmode, NULL),
- UODBC_ALIAS(longreadlen, NULL),
-#endif
-#if HAVE_SOLID
- {"solid_fetch_prev",php3_solid_fetch_prev, NULL},
-#endif
-#if 0 && HAVE_IODBC /* this won't work with the new system */
-/* for backwards compatibility with the older odbc module*/
- {"sqlconnect", php3_uodbc_connect, NULL},
- {"sqldisconnect", php3_uodbc_close, NULL},
- {"sqlfetch", php3_uodbc_fetch_row, NULL},
- {"sqlexecdirect", php3_uodbc_do, NULL},
- {"sqlgetdata", php3_uodbc_result, NULL},
- {"sqlfree", php3_uodbc_free_result, NULL},
- {"sqlrowcount", php3_uodbc_num_rows, NULL},
-#endif
+# if !(WIN32|WINNT)
+# include "config.h"
+# include "build-defs.h"
+# endif
+
+# include <fcntl.h>
+
+# include "dl/phpdl.h"
+# include "ext/standard/php3_standard.h"
+# include "php3_odbc.h"
+# include "functions/head.h"
+# include "snprintf.h"
+# include "php_ini.h"
+
+# ifndef ZS
+php_odbc_globals odbc_globals;
+# endif
+
+function_entry odbc_functions[] = {
+ PHP_FE(odbc_setoption, NULL)
+ PHP_FE(odbc_autocommit, NULL)
+ PHP_FE(odbc_close, NULL)
+ PHP_FE(odbc_close_all, NULL)
+ PHP_FE(odbc_commit, NULL)
+ PHP_FE(odbc_connect, NULL)
+ PHP_FE(odbc_pconnect, NULL)
+ PHP_FE(odbc_cursor, NULL)
+ PHP_FE(odbc_exec, NULL)
+ PHP_FE(odbc_prepare, NULL)
+ PHP_FE(odbc_execute, NULL)
+ PHP_FE(odbc_fetch_row, NULL)
+ PHP_FE(odbc_fetch_into, NULL)
+ PHP_FE(odbc_field_len, NULL)
+ PHP_FE(odbc_field_name, NULL)
+ PHP_FE(odbc_field_type, NULL)
+ PHP_FE(odbc_field_num, NULL)
+ PHP_FE(odbc_free_result, NULL)
+ PHP_FE(odbc_num_fields, NULL)
+ PHP_FE(odbc_num_rows, NULL)
+ PHP_FE(odbc_result, NULL)
+ PHP_FE(odbc_result_all, NULL)
+ PHP_FE(odbc_rollback, NULL)
+ PHP_FE(odbc_binmode, NULL)
+ PHP_FE(odbc_longreadlen, NULL)
+ PHP_FALIAS(odbc_do, odbc_exec, NULL)
{ NULL, NULL, NULL }
};
-php3_module_entry UODBC_MODULE_ENTRY = {
- UODBC_MODULE_NAME,
- UODBC_FUNCTIONS,
- PHP3_MINIT_UODBC,
- PHP3_MSHUTDOWN_UODBC,
- PHP3_RINIT_UODBC,
+php3_module_entry odbc_module_entry = {
+ "ODBC",
+ odbc_functions,
+ php3_minit_odbc,
+ php3_mshutdown_odbc,
+ php3_rinit_odbc,
NULL,
- PHP3_INFO_UODBC,
+ php3_info_odbc,
STANDARD_MODULE_PROPERTIES
};
#if COMPILE_DL
-DLEXPORT php3_module_entry *get_module() { return &UODBC_MODULE_ENTRY; };
+DLEXPORT php3_module_entry *get_module() { return &odbc_module_entry; };
#endif
-static void _free_result(UODBC_RESULT *res)
+static void _free_result(odbc_result *res)
{
int i;
@@ -179,7 +120,7 @@ static void _free_result(UODBC_RESULT *res)
}
if (res->stmt){
#if HAVE_SOLID
- SQLTransact(UODBC_GLOBAL(PHP3_UODBC_MODULE).henv, res->conn_ptr->hdbc,
+ SQLTransact(ODBCG(henv), res->conn_ptr->hdbc,
(UWORD)SQL_COMMIT);
#endif
SQLFreeStmt(res->stmt,SQL_DROP);
@@ -193,121 +134,107 @@ static void _free_result(UODBC_RESULT *res)
static int _results_cleanup(list_entry *le)
{
- UODBC_TLS_VARS;
+ ODBC_TLS_VARS;
- if (le->type == UODBC_GLOBAL(PHP3_UODBC_MODULE).le_result){
- UODBC_CONNECTION *conn = ((UODBC_RESULT *) le->ptr)->conn_ptr;
- if (!conn->open && ((UODBC_RESULT *) le->ptr)->stmt){
- SQLFreeStmt(((UODBC_RESULT *) le->ptr)->stmt,SQL_DROP);
+ if (le->type == ODBCG(le_result)) {
+ odbc_connection *conn = ((odbc_result *) le->ptr)->conn_ptr;
+ if (!conn->open && ((odbc_result *) le->ptr)->stmt){
+ SQLFreeStmt(((odbc_result *) le->ptr)->stmt,SQL_DROP);
#if !HAVE_DB2
- ((UODBC_RESULT *) le->ptr)->stmt = NULL;
+ ((odbc_result *) le->ptr)->stmt = NULL;
#endif
}
}
return 0;
}
-static void _close_connection(UODBC_CONNECTION *conn)
+static void _close_connection(odbc_connection *conn)
{
/* FIXME
* Closing a connection will fail if there are
* pending transactions
*/
- UODBC_TLS_VARS;
+ ODBC_TLS_VARS;
conn->open = 0;
- _php3_hash_apply(UODBC_GLOBAL(PHP3_UODBC_MODULE).resource_list,
+ _php3_hash_apply(ODBCG(resource_list),
(int (*)(void *))_results_cleanup);
SQLDisconnect(conn->hdbc);
SQLFreeConnect(conn->hdbc);
efree(conn);
- UODBC_GLOBAL(PHP3_UODBC_MODULE).num_links--;
+ ODBCG(num_links)--;
}
-static void _close_pconnection(UODBC_CONNECTION *conn)
+static void _close_pconnection(odbc_connection *conn)
{
- UODBC_TLS_VARS;
+ ODBC_TLS_VARS;
conn->open = 0;
- _php3_hash_apply(UODBC_GLOBAL(PHP3_UODBC_MODULE).resource_plist,
+ _php3_hash_apply(ODBCG(resource_plist),
(int (*)(void *))_results_cleanup);
SQLDisconnect(conn->hdbc);
SQLFreeConnect(conn->hdbc);
free(conn);
- UODBC_GLOBAL(PHP3_UODBC_MODULE).num_links--;
- UODBC_GLOBAL(PHP3_UODBC_MODULE).num_persistent--;
+ ODBCG(num_links)--;
+ ODBCG(num_persistent)--;
+}
+
+
+static PHP_INI_MH(odbc_param_int)
+{
+ long *p;
+ ODBC_TLS_VARS;
+
+ p = (long *) (globals + (size_t)mh_arg);
+ *p = atoi(new_value);
+
+ return SUCCESS;
}
-int PHP3_MINIT_UODBC(INIT_FUNC_ARGS)
+static PHP_INI_MH(odbc_param_str)
+{
+ char **p;
+ ODBC_TLS_VARS;
+
+ p = (char **) (globals + (size_t)mh_arg);
+ *p = new_value;
+
+ return SUCCESS;
+}
+
+
+PHP_INI_BEGIN()
+ PHP_INI_ENTRY("odbc.allow_persistent", "1", PHP_INI_SYSTEM, odbc_param_int, (void *)XtOffsetOf(php_odbc_globals, allow_persistent))
+ PHP_INI_ENTRY("odbc.max_persistent", "-1", PHP_INI_SYSTEM, odbc_param_int, (void *)XtOffsetOf(php_odbc_globals, max_persistent))
+ PHP_INI_ENTRY("odbc.max_links", "-1", PHP_INI_SYSTEM, odbc_param_int, (void *)XtOffsetOf(php_odbc_globals, max_links))
+ PHP_INI_ENTRY("odbc.default_db", NULL, PHP_INI_ALL, odbc_param_str, (void *)XtOffsetOf(php_odbc_globals, defDB))
+ PHP_INI_ENTRY("odbc.default_user", NULL, PHP_INI_ALL, odbc_param_str, (void *)XtOffsetOf(php_odbc_globals, defUser))
+ PHP_INI_ENTRY("odbc.default_pw", NULL, PHP_INI_ALL, odbc_param_str, (void *)XtOffsetOf(php_odbc_globals, defPW))
+ PHP_INI_ENTRY("odbc.defaultlrl", "4096", PHP_INI_ALL, odbc_param_int, (void *)XtOffsetOf(php_odbc_globals, defaultlrl))
+ PHP_INI_ENTRY("odbc.defaultbinmode", "1", PHP_INI_ALL, odbc_param_str, (void *)XtOffsetOf(php_odbc_globals, defPW))
+PHP_INI_END()
+
+
+int php3_minit_odbc(INIT_FUNC_ARGS)
{
#ifdef SQLANY_BUG
HDBC foobar;
RETCODE rc;
#endif
+ ODBC_TLS_VARS;
-#if defined(THREAD_SAFE)
- UODBC_GLOBAL_STRUCT *UODBC_GLOBALS;
-
- PHP3_MUTEX_ALLOC(UODBC_MUTEX);
- PHP3_MUTEX_LOCK(UODBC_MUTEX);
- numthreads++;
- if (numthreads==1){
- if (!PHP3_TLS_PROC_STARTUP(UODBC_TLS)){
- PHP3_MUTEX_UNLOCK(UODBC_MUTEX);
- PHP3_MUTEX_FREE(UODBC_MUTEX);
- return FAILURE;
- }
- }
- PHP3_MUTEX_UNLOCK(UODBC_MUTEX);
- if(!PHP3_TLS_THREAD_INIT(UODBC_TLS,UODBC_GLOBALS,UODBC_GLOBAL_STRUCT)){
- PHP3_MUTEX_FREE(UODBC_MUTEX);
- return FAILURE;
- }
-#endif
-
- SQLAllocEnv(&UODBC_GLOBAL(PHP3_UODBC_MODULE).henv);
+ REGISTER_INI_ENTRIES();
+ SQLAllocEnv(&ODBCG(henv));
-#if !PHP_31
- cfg_get_string(ODBC_INI_VAR(default_db),
- &UODBC_GLOBAL(PHP3_UODBC_MODULE).defDB);
- cfg_get_string(ODBC_INI_VAR(default_user),
- &UODBC_GLOBAL(PHP3_UODBC_MODULE).defUser);
- cfg_get_string(ODBC_INI_VAR(default_pw),
- &UODBC_GLOBAL(PHP3_UODBC_MODULE).defPW);
- if (cfg_get_long(ODBC_INI_VAR(allow_persistent),
- &UODBC_GLOBAL(PHP3_UODBC_MODULE).allow_persistent)
- == FAILURE) {
- UODBC_GLOBAL(PHP3_UODBC_MODULE).allow_persistent = -1;
- }
- if (cfg_get_long(ODBC_INI_VAR(max_persistent),
- &UODBC_GLOBAL(PHP3_UODBC_MODULE).max_persistent)
- == FAILURE) {
- UODBC_GLOBAL(PHP3_UODBC_MODULE).max_persistent = -1;
- }
- if (cfg_get_long(ODBC_INI_VAR(max_links),
- &UODBC_GLOBAL(PHP3_UODBC_MODULE).max_links)
- == FAILURE) {
- UODBC_GLOBAL(PHP3_UODBC_MODULE).max_links = -1;
- }
-#else
- UODBC_GLOBAL(PHP3_UODBC_MODULE).allow_persistent = -1;
- UODBC_GLOBAL(PHP3_UODBC_MODULE).max_persistent = -1;
- UODBC_GLOBAL(PHP3_UODBC_MODULE).max_links = -1;
-#endif
-
- UODBC_GLOBAL(PHP3_UODBC_MODULE).num_persistent = 0;
-
- UODBC_GLOBAL(PHP3_UODBC_MODULE).le_result =
- register_list_destructors(_free_result, NULL);
- UODBC_GLOBAL(PHP3_UODBC_MODULE).le_conn =
- register_list_destructors(_close_connection, NULL);
- UODBC_GLOBAL(PHP3_UODBC_MODULE).le_pconn =
- register_list_destructors(NULL, _close_pconnection);
+ ODBCG(num_persistent) = 0;
+ ODBCG(le_result) = register_list_destructors(_free_result, NULL);
+ ODBCG(le_conn) = register_list_destructors(_close_connection, NULL);
+ ODBCG(le_pconn) = register_list_destructors(NULL, _close_pconnection);
#ifdef SQLANY_BUG
/* Make a dumb connection to avoid crash on SQLFreeEnv(),
@@ -315,12 +242,11 @@ int PHP3_MINIT_UODBC(INIT_FUNC_ARGS)
* This is required for SQL Anywhere 5.5.00 on QNX 4.24 at least.
* The SQLANY_BUG should be defined in CFLAGS.
*/
- if ( SQLAllocConnect(UODBC_GLOBAL(PHP3_UODBC_MODULE).henv, &foobar) != SQL_SUCCESS )
- UODBC_SQL_ERROR(SQL_NULL_HDBC, SQL_NULL_HSTMT, "SQLAllocConnect");
- else
- {
- rc = SQLConnect(foobar, UODBC_GLOBAL(PHP3_UODBC_MODULE).defDB, SQL_NTS, UODBC_GLOBAL(PHP3_UODBC_MODULE).defUser,
- SQL_NTS, UODBC_GLOBAL(PHP3_UODBC_MODULE).defPW, SQL_NTS);
+ if ( SQLAllocConnect(ODBCG(henv), &foobar) != SQL_SUCCESS ) {
+ ODBC_SQL_ERROR(SQL_NULL_HDBC, SQL_NULL_HSTMT, "SQLAllocConnect");
+ } else {
+ rc = SQLConnect(foobar, ODBCG(defDB), SQL_NTS, ODBCG(defUser),
+ SQL_NTS, ODBCG(defPW), SQL_NTS);
if(rc == SQL_SUCCESS || rc == SQL_SUCCESS_WITH_INFO)
SQLDisconnect( foobar );
SQLFreeConnect( foobar );
@@ -341,79 +267,40 @@ int PHP3_MINIT_UODBC(INIT_FUNC_ARGS)
}
-int PHP3_RINIT_UODBC(INIT_FUNC_ARGS)
+int php3_rinit_odbc(INIT_FUNC_ARGS)
{
- UODBC_TLS_VARS;
-
- UODBC_GLOBAL(PHP3_UODBC_MODULE).defConn = -1;
- UODBC_GLOBAL(PHP3_UODBC_MODULE).num_links =
- UODBC_GLOBAL(PHP3_UODBC_MODULE).num_persistent;
-#if PHP_31
- UODBC_GLOBAL(PHP3_UODBC_MODULE).defaultlrl = 4096;
- UODBC_GLOBAL(PHP3_UODBC_MODULE).defaultbinmode = 1;
-#else
- if (cfg_get_long(ODBC_INI_VAR(defaultlrl), &UODBC_GLOBAL(PHP3_UODBC_MODULE).defaultlrl)
- == FAILURE){
- UODBC_GLOBAL(PHP3_UODBC_MODULE).defaultlrl = 4096;
- }
- if (cfg_get_long(ODBC_INI_VAR(defaultbinmode), &UODBC_GLOBAL(PHP3_UODBC_MODULE).defaultbinmode) == FAILURE){
- UODBC_GLOBAL(PHP3_UODBC_MODULE).defaultbinmode = 1;
- }
-#endif
+ ODBC_TLS_VARS;
+
+ ODBCG(defConn) = -1;
+ ODBCG(num_links) = ODBCG(num_persistent);
+
return SUCCESS;
}
-int PHP3_MSHUTDOWN_UODBC(SHUTDOWN_FUNC_ARGS)
+int php3_mshutdown_odbc(SHUTDOWN_FUNC_ARGS)
{
- UODBC_TLS_VARS;
+ ODBC_TLS_VARS;
+
+ SQLFreeEnv(ODBCG(henv));
- SQLFreeEnv(UODBC_GLOBAL(PHP3_UODBC_MODULE).henv);
-#ifdef THREAD_SAFE
- PHP3_TLS_THREAD_FREE(UODBC_GLOBALS);
- PHP3_MUTEX_LOCK(UODBC_MUTEX);
- numthreads--;
- if (!numthreads) {
- PHP3_TLS_PROC_SHUTDOWN(UODBC_TLS);
- PHP3_MUTEX_UNLOCK(UODBC_MUTEX);
- PHP3_MUTEX_FREE(UODBC_MUTEX);
- return SUCCESS;
- }
- PHP3_MUTEX_UNLOCK(UODBC_MUTEX);
-#endif
return SUCCESS;
}
-void PHP3_INFO_UODBC(void)
+void php3_info_odbc(void)
{
- UODBC_TLS_VARS;
+ ODBC_TLS_VARS;
-#if HAVE_SOLID
- php3_printf("Unified ODBC Support active (compiled with Solid)");
-#elif HAVE_ADABAS
- php3_printf("Unified ODBC Support active (compiled with Adabas D)");
-#elif HAVE_IODBC && !(WIN32|WINNT)
- php3_printf("Unified ODBC Support active (compiled with iODBC)");
-#elif HAVE_VELOCIS
- php3_printf("Unified ODBC Support active (compiled with Velocis)");
-#elif HAVE_DB2
- php3_printf("Unified ODBC Support active (compiled with IBM DB2)");
-#elif WIN32|WINNT
- php3_printf("Unified ODBC Support active (compiled with win32 ODBC)");
-#elif HAVE_EMPRESS
- PUTS("Unified ODBC Support active (compiled with Empress)");
-#else
- php3_printf("Unified ODBC Support active (compiled with unknown library)");
-#endif
+ php3_printf("ODBC compiled with \"" ODBC_TYPE "\" library");
php3_printf("<BR>");
#if DEBUG
- php3_printf("default_db: %s<br>\n",UODBC_GLOBAL(PHP3_UODBC_MODULE).defDB);
- php3_printf("default_user: %s<br>\n",UODBC_GLOBAL(PHP3_UODBC_MODULE).defUser);
- php3_printf("default_pw: %s<br>\n",UODBC_GLOBAL(PHP3_UODBC_MODULE).defPW);
+ php3_printf("default_db: %s<br>\n", ODBCG(defDB));
+ php3_printf("default_user: %s<br>\n", ODBCG(defUser));
+ php3_printf("default_pw: %s<br>\n", ODBCG(defPW));
#endif
- php3_printf("allow_persistent: %d<br>\n",UODBC_GLOBAL(PHP3_UODBC_MODULE).allow_persistent);
- php3_printf("max_persistent: %d<br>\n",UODBC_GLOBAL(PHP3_UODBC_MODULE).max_persistent);
- php3_printf("max_links: %d<br>\n",UODBC_GLOBAL(PHP3_UODBC_MODULE).max_links);
+ php3_printf("allow_persistent: %d<br>\n", ODBCG(allow_persistent));
+ php3_printf("max_persistent: %d<br>\n", ODBCG(max_persistent));
+ php3_printf("max_links: %d<br>\n", ODBCG(max_links));
}
@@ -422,83 +309,56 @@ void PHP3_INFO_UODBC(void)
* List management functions
*/
-int UODBC_ADD_RESULT(HashTable *list,UODBC_RESULT *result)
+int odbc_add_result(HashTable *list,odbc_result *result)
{
- UODBC_TLS_VARS;
- return php3_list_insert(result, UODBC_GLOBAL(PHP3_UODBC_MODULE).le_result);
+ ODBC_TLS_VARS;
+ return php3_list_insert(result, ODBCG(le_result));
}
-UODBC_RESULT *UODBC_GET_RESULT(HashTable *list, int ind)
+odbc_result *odbc_get_result(HashTable *list, int ind)
{
- UODBC_RESULT *res;
+ odbc_result *res;
int type;
- UODBC_TLS_VARS;
+ ODBC_TLS_VARS;
- res = (UODBC_RESULT*)php3_list_find(ind, &type);
- if (!res || type != UODBC_GLOBAL(PHP3_UODBC_MODULE).le_result) {
+ res = (odbc_result*)php3_list_find(ind, &type);
+ if (!res || type != ODBCG(le_result)) {
php3_error(E_WARNING, "Bad result index %d", ind);
return NULL;
}
return res;
}
-void UODBC_DEL_RESULT(HashTable *list, int ind)
+void odbc_del_result(HashTable *list, int ind)
{
- UODBC_RESULT *res;
+ odbc_result *res;
int type;
- UODBC_TLS_VARS;
+ ODBC_TLS_VARS;
- res = (UODBC_RESULT *)php3_list_find(ind, &type);
- if (!res || type != UODBC_GLOBAL(PHP3_UODBC_MODULE).le_result) {
+ res = (odbc_result *)php3_list_find(ind, &type);
+ if (!res || type != ODBCG(le_result)) {
php3_error(E_WARNING,"Can't find result %d", ind);
return;
}
php3_list_delete(ind);
}
-#if 0
-int UODBC_ADD_CONN(HashTable *list, HDBC conn)
-{
- UODBC_TLS_VARS;
- return php3_list_insert(conn, UODBC_GLOBAL(PHP3_UODBC_MODULE).le_conn);
-}
-
-void uodbc_make_def_conn(HashTable *list)
-{
- HDBC new_conn;
- RETCODE rc;
- UODBC_TLS_VARS;
-
- SQLAllocConnect(UODBC_GLOBAL(PHP3_UODBC_MODULE).henv, &new_conn);
- rc = SQLConnect(new_conn, UODBC_GLOBAL(PHP3_UODBC_MODULE).defDB,
- SQL_NTS, UODBC_GLOBAL(PHP3_UODBC_MODULE).defUser,
- SQL_NTS, UODBC_GLOBAL(PHP3_UODBC_MODULE).defPW, SQL_NTS);
-
- if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO){
- UODBC_SQL_ERROR(new_conn, SQL_NULL_HSTMT, "SQLConnect");
- } else {
- UODBC_GLOBAL(PHP3_UODBC_MODULE).defConn = uodbc_add_conn(list, new_conn);
- }
-}
-#endif
-
-UODBC_CONNECTION *UODBC_GET_CONN(HashTable *list, int ind)
+odbc_connection *odbc_get_conn(HashTable *list, int ind)
{
- UODBC_CONNECTION *conn = NULL;
+ odbc_connection *conn = NULL;
int type;
HashTable *plist;
- UODBC_TLS_VARS;
+ ODBC_TLS_VARS;
- plist = UODBC_GLOBAL(PHP3_UODBC_MODULE).resource_plist;
+ plist = ODBCG(resource_plist);
- conn = (UODBC_CONNECTION *)php3_list_find(ind, &type);
- if (conn && (type == UODBC_GLOBAL(PHP3_UODBC_MODULE).le_conn ||
- type == UODBC_GLOBAL(PHP3_UODBC_MODULE).le_pconn))
+ conn = (odbc_connection *)php3_list_find(ind, &type);
+ if (conn && (type == ODBCG(le_conn) || type == ODBCG(le_pconn))) {
return conn;
+ }
- conn = (UODBC_CONNECTION *)php3_plist_find(ind, &type);
- if (conn && (type == UODBC_GLOBAL(PHP3_UODBC_MODULE).le_conn ||
- type == UODBC_GLOBAL(PHP3_UODBC_MODULE).le_pconn))
+ conn = (odbc_connection *)php3_plist_find(ind, &type);
+ if (conn && (type == ODBCG(le_conn) || type == ODBCG(le_pconn)))
return conn;
php3_error(E_WARNING,"Bad ODBC connection number (%d)", ind);
@@ -506,18 +366,18 @@ UODBC_CONNECTION *UODBC_GET_CONN(HashTable *list, int ind)
}
#if HAVE_DB2
-void UODBC_SQL_ERROR(SQLHANDLE conn, SQLHANDLE stmt, char *func)
+void ODBC_SQL_ERROR(SQLHANDLE conn, SQLHANDLE stmt, char *func)
#else
-void UODBC_SQL_ERROR(HDBC conn, HSTMT stmt, char *func)
+void ODBC_SQL_ERROR(HDBC conn, HSTMT stmt, char *func)
#endif
{
char state[6]; /* Not used */
SDWORD error; /* Not used */
char errormsg[255];
SWORD errormsgsize; /* Not used */
- UODBC_TLS_VARS;
+ ODBC_TLS_VARS;
- SQLError(UODBC_GLOBAL(PHP3_UODBC_MODULE).henv, conn, stmt, state,
+ SQLError(ODBCG(henv), conn, stmt, state,
&error, errormsg, sizeof(errormsg)-1, &errormsgsize);
if (func) {
php3_error(E_WARNING, "SQL error: %s, SQL state %s in %s",
@@ -531,29 +391,29 @@ void UODBC_SQL_ERROR(HDBC conn, HSTMT stmt, char *func)
/* Main User Functions */
/* {{{ proto odbc_close_all(void)
Close all ODBC connections */
-UODBC_FUNCTION(close_all)
+PHP_FUNCTION(odbc_close_all)
{
void *ptr;
int type;
int i, nument = _php3_hash_next_free_element(list);
- UODBC_TLS_VARS;
+ ODBC_TLS_VARS;
for (i = 1; i < nument; i++) {
ptr = php3_list_find(i, &type);
- if (ptr && (type == UODBC_GLOBAL(PHP3_UODBC_MODULE).le_conn ||
- type == UODBC_GLOBAL(PHP3_UODBC_MODULE).le_pconn)){
+ if (ptr && (type == ODBCG(le_conn) ||
+ type == ODBCG(le_pconn))) {
php3_list_delete(i);
}
}
}
/* }}} */
-void php3_uodbc_fetch_attribs(INTERNAL_FUNCTION_PARAMETERS, int mode)
+void php3_odbc_fetch_attribs(INTERNAL_FUNCTION_PARAMETERS, int mode)
{
int res_ind;
- UODBC_RESULT *result;
+ odbc_result *result;
pval *arg1, *arg2;
- UODBC_TLS_VARS;
+ ODBC_TLS_VARS;
if (getParameters(ht, 2, &arg1, &arg2) == FAILURE)
WRONG_PARAM_COUNT;
@@ -564,7 +424,7 @@ void php3_uodbc_fetch_attribs(INTERNAL_FUNCTION_PARAMETERS, int mode)
res_ind = arg1->value.lval;
if (res_ind){
- if ((result = UODBC_GET_RESULT(list, res_ind)) == NULL){
+ if ((result = odbc_get_result(list, res_ind)) == NULL){
RETURN_FALSE;
}
if (mode)
@@ -573,9 +433,9 @@ void php3_uodbc_fetch_attribs(INTERNAL_FUNCTION_PARAMETERS, int mode)
result->binmode = arg2->value.lval;
} else {
if (mode)
- UODBC_GLOBAL(PHP3_UODBC_MODULE).defaultlrl = arg2->value.lval;
+ ODBCG(defaultlrl) = arg2->value.lval;
else
- UODBC_GLOBAL(PHP3_UODBC_MODULE).defaultbinmode = arg2->value.lval;
+ ODBCG(defaultbinmode) = arg2->value.lval;
}
RETURN_TRUE
@@ -583,29 +443,29 @@ void php3_uodbc_fetch_attribs(INTERNAL_FUNCTION_PARAMETERS, int mode)
/* {{{ proto odbc_binmode(int result_id, int mode)
Handle binary column data */
-UODBC_FUNCTION(binmode)
+PHP_FUNCTION(odbc_binmode)
{
- php3_uodbc_fetch_attribs(INTERNAL_FUNCTION_PARAM_PASSTHRU,0);
+ php3_odbc_fetch_attribs(INTERNAL_FUNCTION_PARAM_PASSTHRU,0);
}
/* }}} */
/* {{{ proto odbc_longreadlen(int result_id, int length)
Handle LONG columns */
-UODBC_FUNCTION(longreadlen)
+PHP_FUNCTION(odbc_longreadlen)
{
- php3_uodbc_fetch_attribs(INTERNAL_FUNCTION_PARAM_PASSTHRU,1);
+ php3_odbc_fetch_attribs(INTERNAL_FUNCTION_PARAM_PASSTHRU,1);
}
/* }}} */
-int UODBC_BINDCOLS(UODBC_RESULT *result)
+int odbc_bindcols(odbc_result *result)
{
int i;
SWORD colnamelen; /* Not used */
SDWORD displaysize;
- UODBC_TLS_VARS;
+ ODBC_TLS_VARS;
- result->values = (UODBC_RESULT_VALUE *)
- emalloc(sizeof(UODBC_RESULT_VALUE)*result->numcols);
+ result->values = (odbc_result_value *)
+ emalloc(sizeof(odbc_result_value)*result->numcols);
if (result->values == NULL){
php3_error(E_WARNING, "Out of memory");
@@ -613,8 +473,8 @@ int UODBC_BINDCOLS(UODBC_RESULT *result)
return 0;
}
- result->longreadlen = UODBC_GLOBAL(PHP3_UODBC_MODULE).defaultlrl;
- result->binmode = UODBC_GLOBAL(PHP3_UODBC_MODULE).defaultbinmode;
+ result->longreadlen = ODBCG(defaultlrl);
+ result->binmode = ODBCG(defaultbinmode);
for(i = 0; i < result->numcols; i++){
SQLColAttributes(result->stmt, (UWORD)(i+1), SQL_COLUMN_NAME,
@@ -658,13 +518,13 @@ int UODBC_BINDCOLS(UODBC_RESULT *result)
/* {{{ proto odbc_prepare(int connection_id, string query)
Prepares a statement for execution */
-UODBC_FUNCTION(prepare)
+PHP_FUNCTION(odbc_prepare)
{
pval *arg1, *arg2;
int conn;
char *query;
- UODBC_RESULT *result=NULL;
- UODBC_CONNECTION *curr_conn=NULL;
+ odbc_result *result=NULL;
+ odbc_connection *curr_conn=NULL;
RETCODE rc;
if (getParameters(ht, 2, &arg1, &arg2) == FAILURE){
@@ -675,7 +535,7 @@ UODBC_FUNCTION(prepare)
conn = arg1->value.lval;
query = arg2->value.str.val;
- if ((curr_conn = UODBC_GET_CONN(list, conn)) == NULL){
+ if ((curr_conn = odbc_get_conn(list, conn)) == NULL){
RETURN_FALSE;
}
@@ -683,7 +543,7 @@ UODBC_FUNCTION(prepare)
_php3_stripslashes(query,NULL);
#endif
- result = (UODBC_RESULT *)emalloc(sizeof(UODBC_RESULT));
+ result = (odbc_result *)emalloc(sizeof(odbc_result));
if (result == NULL){
php3_error(E_WARNING, "Out of memory");
RETURN_FALSE;
@@ -694,18 +554,18 @@ UODBC_FUNCTION(prepare)
rc = SQLAllocStmt(curr_conn->hdbc, &(result->stmt));
if (rc == SQL_INVALID_HANDLE){
efree(result);
- php3_error(E_WARNING, "SQLAllocStmt error 'Invalid Handle' in php3_uodbc_prepare");
+ php3_error(E_WARNING, "SQLAllocStmt error 'Invalid Handle' in php3_odbc_prepare");
RETURN_FALSE;
}
if (rc == SQL_ERROR){
- UODBC_SQL_ERROR(curr_conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
+ ODBC_SQL_ERROR(curr_conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
efree(result);
RETURN_FALSE;
}
if ((rc = SQLPrepare(result->stmt, query, SQL_NTS)) != SQL_SUCCESS){
- UODBC_SQL_ERROR(curr_conn->hdbc, result->stmt, "SQLPrepare");
+ ODBC_SQL_ERROR(curr_conn->hdbc, result->stmt, "SQLPrepare");
SQLFreeStmt(result->stmt, SQL_DROP);
RETURN_FALSE;
}
@@ -714,7 +574,7 @@ UODBC_FUNCTION(prepare)
SQLNumResultCols(result->stmt, &(result->numcols));
if (result->numcols > 0){
- if (!UODBC_BINDCOLS(result)){
+ if (!odbc_bindcols(result)){
efree(result);
RETURN_FALSE;
}
@@ -723,7 +583,7 @@ UODBC_FUNCTION(prepare)
}
result->conn_ptr = curr_conn;
result->fetched = 0;
- RETURN_LONG(UODBC_ADD_RESULT(list, result));
+ RETURN_LONG(odbc_add_result(list, result));
}
/* }}} */
@@ -732,7 +592,7 @@ UODBC_FUNCTION(prepare)
*/
/* {{{ proto odbc_execute(int result_id [, array parameters_array])
Execute a prepared statement */
-extern UODBC_FUNCTION(execute)
+extern PHP_FUNCTION(odbc_execute)
{
pval *arg1, *arg2, arr, *tmp;
typedef struct params_t {
@@ -743,7 +603,7 @@ extern UODBC_FUNCTION(execute)
char *filename;
SWORD sqltype, scale, nullable;
UDWORD precision;
- UODBC_RESULT *result=NULL;
+ odbc_result *result=NULL;
int res_ind, numArgs, i, ne;
RETCODE rc;
@@ -766,7 +626,7 @@ extern UODBC_FUNCTION(execute)
res_ind = arg1->value.lval;
/* check result */
- if ((result = UODBC_GET_RESULT(list, res_ind)) == NULL){
+ if ((result = odbc_get_result(list, res_ind)) == NULL){
RETURN_FALSE;
}
@@ -855,7 +715,7 @@ extern UODBC_FUNCTION(execute)
rc = SQLFreeStmt(result->stmt, SQL_CLOSE);
if (rc == SQL_ERROR){
- UODBC_SQL_ERROR(result->conn_ptr->hdbc, result->stmt, "SQLFreeStmt");
+ ODBC_SQL_ERROR(result->conn_ptr->hdbc, result->stmt, "SQLFreeStmt");
}
rc = SQLExecute(result->stmt);
@@ -873,7 +733,7 @@ extern UODBC_FUNCTION(execute)
}
} else {
if (rc != SQL_SUCCESS){
- UODBC_SQL_ERROR(result->conn_ptr->hdbc, result->stmt, "SQLExecute");
+ ODBC_SQL_ERROR(result->conn_ptr->hdbc, result->stmt, "SQLExecute");
RETVAL_FALSE;
}
}
@@ -900,13 +760,13 @@ extern UODBC_FUNCTION(execute)
*/
/* {{{ proto odbc_cursor(int result_id)
Get cursor name */
-UODBC_FUNCTION(cursor)
+PHP_FUNCTION(odbc_cursor)
{
pval *arg1;
int res_ind;
SWORD len, max_len;
char *cursorname;
- UODBC_RESULT *result;
+ odbc_result *result;
RETCODE rc;
if (getParameters(ht, 1, &arg1) == FAILURE){
@@ -916,7 +776,7 @@ UODBC_FUNCTION(cursor)
res_ind = arg1->value.lval;
/* check result */
- if ((result = UODBC_GET_RESULT(list, res_ind)) == NULL) {
+ if ((result = odbc_get_result(list, res_ind)) == NULL) {
RETURN_FALSE;
}
rc = SQLGetInfo(result->conn_ptr->hdbc,SQL_MAX_CURSOR_NAME_LEN,
@@ -937,15 +797,15 @@ UODBC_FUNCTION(cursor)
SDWORD error; /* Not used */
char errormsg[255];
SWORD errormsgsize; /* Not used */
- UODBC_TLS_VARS;
+ ODBC_TLS_VARS;
- SQLError(UODBC_GLOBAL(PHP3_UODBC_MODULE).henv, result->conn_ptr->hdbc,
+ SQLError(ODBCG(henv), result->conn_ptr->hdbc,
result->stmt, state, &error, errormsg,
sizeof(errormsg)-1, &errormsgsize);
if (!strncmp(state,"S1015",5)){
sprintf(cursorname,"php3_curs_%d", (int)result->stmt);
if (SQLSetCursorName(result->stmt,cursorname,SQL_NTS) != SQL_SUCCESS){
- UODBC_SQL_ERROR(result->conn_ptr->hdbc,result->stmt,
+ ODBC_SQL_ERROR(result->conn_ptr->hdbc,result->stmt,
"SQLSetCursorName");
RETVAL_FALSE;
} else {
@@ -967,13 +827,13 @@ UODBC_FUNCTION(cursor)
/* {{{ proto odbc_exec(int connection_id, string query)
Prepare and execute an SQL statement */
-UODBC_FUNCTION(exec)
+PHP_FUNCTION(odbc_exec)
{
pval *arg1, *arg2;
int conn;
char *query;
- UODBC_RESULT *result=NULL;
- UODBC_CONNECTION *curr_conn=NULL;
+ odbc_result *result=NULL;
+ odbc_connection *curr_conn=NULL;
RETCODE rc;
#if HAVE_SQL_EXTENDED_FETCH
UDWORD scrollopts;
@@ -987,7 +847,7 @@ UODBC_FUNCTION(exec)
conn = arg1->value.lval;
query = arg2->value.str.val;
- if ((curr_conn = UODBC_GET_CONN(list, conn)) == NULL){
+ if ((curr_conn = odbc_get_conn(list, conn)) == NULL){
RETURN_FALSE;
}
@@ -995,7 +855,7 @@ UODBC_FUNCTION(exec)
_php3_stripslashes(query,NULL);
#endif
- result = (UODBC_RESULT *)emalloc(sizeof(UODBC_RESULT));
+ result = (odbc_result *)emalloc(sizeof(odbc_result));
if (result == NULL){
php3_error(E_WARNING, "Out of memory");
RETURN_FALSE;
@@ -1003,13 +863,13 @@ UODBC_FUNCTION(exec)
rc = SQLAllocStmt(curr_conn->hdbc, &(result->stmt));
if (rc == SQL_INVALID_HANDLE){
- php3_error(E_WARNING, "SQLAllocStmt error 'Invalid Handle' in PHP3_UODBC_DO");
+ php3_error(E_WARNING, "SQLAllocStmt error 'Invalid Handle' in PHP3_ODBC_DO");
efree(result);
RETURN_FALSE;
}
if (rc == SQL_ERROR){
- UODBC_SQL_ERROR(curr_conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
+ ODBC_SQL_ERROR(curr_conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
efree(result);
RETURN_FALSE;
}
@@ -1025,7 +885,7 @@ UODBC_FUNCTION(exec)
*/
if (SQLSetStmtOption(result->stmt, SQL_CURSOR_TYPE, SQL_CURSOR_DYNAMIC)
== SQL_ERROR){
- UODBC_SQL_ERROR(curr_conn->hdbc, result->stmt, " SQLSetStmtOption");
+ ODBC_SQL_ERROR(curr_conn->hdbc, result->stmt, " SQLSetStmtOption");
SQLFreeStmt(result->stmt, SQL_DROP);
efree(result);
RETURN_FALSE;
@@ -1041,7 +901,7 @@ UODBC_FUNCTION(exec)
/* XXX FIXME we should really check out SQLSTATE with SQLError
* in case rc is SQL_SUCCESS_WITH_INFO here.
*/
- UODBC_SQL_ERROR(curr_conn->hdbc, result->stmt, "SQLExecDirect");
+ ODBC_SQL_ERROR(curr_conn->hdbc, result->stmt, "SQLExecDirect");
SQLFreeStmt(result->stmt, SQL_DROP);
efree(result);
RETURN_FALSE;
@@ -1051,7 +911,7 @@ UODBC_FUNCTION(exec)
/* For insert, update etc. cols == 0 */
if (result->numcols > 0){
- if (!UODBC_BINDCOLS(result)){
+ if (!odbc_bindcols(result)){
efree(result);
RETURN_FALSE;
}
@@ -1060,16 +920,16 @@ UODBC_FUNCTION(exec)
}
result->conn_ptr = curr_conn;
result->fetched = 0;
- RETURN_LONG(UODBC_ADD_RESULT(list, result));
+ RETURN_LONG(odbc_add_result(list, result));
}
/* }}} */
/* {{{ proto odbc_fetch_into(int result_id [, int rownumber], array result_array)
Fetch one result row into an array */
-UODBC_FUNCTION(fetch_into)
+PHP_FUNCTION(odbc_fetch_into)
{
int res_ind, numArgs, i;
- UODBC_RESULT *result;
+ odbc_result *result;
RETCODE rc;
SWORD sql_c_type;
char *buf = NULL;
@@ -1119,7 +979,7 @@ UODBC_FUNCTION(fetch_into)
res_ind = arg1->value.lval;
/* check result */
- if ((result = UODBC_GET_RESULT(list, res_ind)) == NULL){
+ if ((result = odbc_get_result(list, res_ind)) == NULL){
RETURN_FALSE;
}
@@ -1182,7 +1042,7 @@ UODBC_FUNCTION(fetch_into)
buf, result->longreadlen + 1, &result->values[i].vallen);
if (rc == SQL_ERROR) {
- UODBC_SQL_ERROR(result->conn_ptr->hdbc, result->stmt, "SQLGetData");
+ ODBC_SQL_ERROR(result->conn_ptr->hdbc, result->stmt, "SQLGetData");
efree(buf);
RETURN_FALSE;
}
@@ -1217,7 +1077,7 @@ UODBC_FUNCTION(fetch_into)
void php3_solid_fetch_prev(INTERNAL_FUNCTION_PARAMETERS)
{
int res_ind;
- UODBC_RESULT *result;
+ odbc_result *result;
RETCODE rc;
pval *arg1;
@@ -1228,7 +1088,7 @@ void php3_solid_fetch_prev(INTERNAL_FUNCTION_PARAMETERS)
res_ind = arg1->value.lval;
/* check result */
- if ((result = UODBC_GET_RESULT(list, res_ind)) == NULL) {
+ if ((result = odbc_get_result(list, res_ind)) == NULL) {
RETURN_FALSE;
}
@@ -1250,11 +1110,11 @@ void php3_solid_fetch_prev(INTERNAL_FUNCTION_PARAMETERS)
/* {{{ proto odbc_fetch_row(int result_id [, int row_number])
Fetch a row */
-UODBC_FUNCTION(fetch_row)
+PHP_FUNCTION(odbc_fetch_row)
{
int res_ind, numArgs;
SDWORD rownum = 1;
- UODBC_RESULT *result;
+ odbc_result *result;
RETCODE rc;
pval *arg1, *arg2;
#if HAVE_SQL_EXTENDED_FETCH
@@ -1277,7 +1137,7 @@ UODBC_FUNCTION(fetch_row)
res_ind = arg1->value.lval;
/* check result */
- if ((result = UODBC_GET_RESULT(list, res_ind)) == NULL) {
+ if ((result = odbc_get_result(list, res_ind)) == NULL) {
RETURN_FALSE;
}
@@ -1312,13 +1172,13 @@ UODBC_FUNCTION(fetch_row)
/* {{{ proto odbc_result(int result_id, mixed field)
Get result data */
-UODBC_FUNCTION(result)
+PHP_FUNCTION(odbc_result)
{
char *field;
int res_ind;
int field_ind;
SWORD sql_c_type = SQL_C_CHAR;
- UODBC_RESULT *result;
+ odbc_result *result;
int i = 0;
RETCODE rc;
SDWORD fieldsize;
@@ -1349,7 +1209,7 @@ UODBC_FUNCTION(result)
}
/* check result */
- if ((result = UODBC_GET_RESULT(list, res_ind)) == NULL) {
+ if ((result = odbc_get_result(list, res_ind)) == NULL) {
RETURN_FALSE;
}
@@ -1427,7 +1287,7 @@ UODBC_FUNCTION(result)
field, fieldsize, &result->values[field_ind].vallen);
if (rc == SQL_ERROR) {
- UODBC_SQL_ERROR(result->conn_ptr->hdbc, result->stmt, "SQLGetData");
+ ODBC_SQL_ERROR(result->conn_ptr->hdbc, result->stmt, "SQLGetData");
efree(field);
RETURN_FALSE;
}
@@ -1471,7 +1331,7 @@ UODBC_FUNCTION(result)
field, fieldsize, &result->values[field_ind].vallen);
if (rc == SQL_ERROR) {
- UODBC_SQL_ERROR(result->conn_ptr->hdbc, result->stmt, "SQLGetData");
+ ODBC_SQL_ERROR(result->conn_ptr->hdbc, result->stmt, "SQLGetData");
efree(field);
RETURN_FALSE;
}
@@ -1495,11 +1355,11 @@ UODBC_FUNCTION(result)
/* {{{ proto odbc_result_all(int result_id [, string format])
Print result as HTML table */
-UODBC_FUNCTION(result_all)
+PHP_FUNCTION(odbc_result_all)
{
char *buf = NULL;
int res_ind, numArgs;
- UODBC_RESULT *result;
+ odbc_result *result;
int i;
RETCODE rc;
pval *arg1, *arg2;
@@ -1525,7 +1385,7 @@ UODBC_FUNCTION(result_all)
res_ind = arg1->value.lval;
/* check result */
- if ((result = UODBC_GET_RESULT(list, res_ind)) == NULL) {
+ if ((result = odbc_get_result(list, res_ind)) == NULL) {
RETURN_FALSE;
}
@@ -1587,7 +1447,7 @@ UODBC_FUNCTION(result_all)
php3_printf("<td>");
if (rc == SQL_ERROR) {
- UODBC_SQL_ERROR(result->conn_ptr->hdbc, result->stmt, "SQLGetData");
+ ODBC_SQL_ERROR(result->conn_ptr->hdbc, result->stmt, "SQLGetData");
php3_printf("</td></tr></table>");
efree(buf);
RETURN_FALSE;
@@ -1631,7 +1491,7 @@ UODBC_FUNCTION(result_all)
/* {{{ proto odbc_free_result(int result_id)
Free resources associated with a result */
-UODBC_FUNCTION(free_result)
+PHP_FUNCTION(odbc_free_result)
{
pval *arg1;
@@ -1639,24 +1499,24 @@ UODBC_FUNCTION(free_result)
WRONG_PARAM_COUNT;
}
convert_to_long(arg1);
- UODBC_DEL_RESULT(list, arg1->value.lval);
+ odbc_del_result(list, arg1->value.lval);
RETURN_TRUE;
}
/* }}} */
/* {{{ proto odbc_connect(string DSN, string user, string password [, int cursor_option])
Connect to a datasource */
-UODBC_FUNCTION(connect)
+PHP_FUNCTION(odbc_connect)
{
- PHP3_UODBC_DO_CONNECT(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
+ php3_odbc_do_connect(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
}
/* }}} */
/* {{{ proto odbc_connect(string DSN, string user, string password [, int cursor_option])
Establish a persistant connection to a datasource */
-UODBC_FUNCTION(pconnect)
+PHP_FUNCTION(odbc_pconnect)
{
- PHP3_UODBC_DO_CONNECT(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
+ php3_odbc_do_connect(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
}
/* }}} */
@@ -1673,22 +1533,22 @@ UODBC_FUNCTION(pconnect)
* "globals" in this module should actualy be per-connection variables. I
* simply fixed things to get them working for now. Shane
*/
-void PHP3_UODBC_DO_CONNECT(INTERNAL_FUNCTION_PARAMETERS, int persistent)
+void php3_odbc_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
{
char *db = NULL;
char *uid = NULL;
char *pwd = NULL;
pval *arg1, *arg2, *arg3, *arg4;
- UODBC_CONNECTION *db_conn;
+ odbc_connection *db_conn;
RETCODE rc;
list_entry *index_ptr;
char *hashed_details;
int hashed_len, len, id, cur_opt;
int type;
- UODBC_TLS_VARS;
+ ODBC_TLS_VARS;
- UODBC_GLOBAL(PHP3_UODBC_MODULE).resource_list = list;
- UODBC_GLOBAL(PHP3_UODBC_MODULE).resource_plist = plist;
+ ODBCG(resource_list) = list;
+ ODBCG(resource_plist) = plist;
/* Now an optional 4th parameter specifying the cursor type
* defaulting to the cursors default
@@ -1713,7 +1573,7 @@ void PHP3_UODBC_DO_CONNECT(INTERNAL_FUNCTION_PARAMETERS, int persistent)
cur_opt == SQL_CUR_USE_ODBC ||
cur_opt == SQL_CUR_USE_DRIVER ||
cur_opt == SQL_CUR_DEFAULT) ) {
- php3_error(E_WARNING, "uODBC: Invalid Cursor type (%d)", cur_opt);
+ php3_error(E_WARNING, "odbc: Invalid Cursor type (%d)", cur_opt);
RETURN_FALSE;
}
break;
@@ -1730,29 +1590,24 @@ void PHP3_UODBC_DO_CONNECT(INTERNAL_FUNCTION_PARAMETERS, int persistent)
uid = arg2->value.str.val;
pwd = arg3->value.str.val;
- if (UODBC_GLOBAL(PHP3_UODBC_MODULE).allow_persistent <= 0) {
+ if (ODBCG(allow_persistent) <= 0) {
persistent = 0;
}
- if (UODBC_GLOBAL(PHP3_UODBC_MODULE).max_links != -1 &&
- UODBC_GLOBAL(PHP3_UODBC_MODULE).num_links >=
- UODBC_GLOBAL(PHP3_UODBC_MODULE).max_links) {
- php3_error(E_WARNING, "uODBC: Too many open links (%d)",
- UODBC_GLOBAL(PHP3_UODBC_MODULE).num_links);
+ if (ODBCG(max_links) != -1 && ODBCG(num_links) >= ODBCG(max_links)) {
+ php3_error(E_WARNING, "odbc: Too many open links (%d)",
+ ODBCG(num_links));
RETURN_FALSE;
}
/* the user requested a persistent connection */
- if (persistent &&
- UODBC_GLOBAL(PHP3_UODBC_MODULE).max_persistent != -1 &&
- UODBC_GLOBAL(PHP3_UODBC_MODULE).num_persistent >=
- UODBC_GLOBAL(PHP3_UODBC_MODULE).max_persistent) {
- php3_error(E_WARNING,"uODBC: Too many open persistent links (%d)",
- UODBC_GLOBAL(PHP3_UODBC_MODULE).num_persistent);
+ if (persistent && ODBCG(max_persistent) != -1 && ODBCG(num_persistent) >= ODBCG(max_persistent)) {
+ php3_error(E_WARNING,"odbc: Too many open persistent links (%d)",
+ ODBCG(num_persistent));
RETURN_FALSE;
}
- len = strlen(db) + strlen(uid) + strlen(pwd) + strlen(UODBC_NAME) + 5;
+ len = strlen(db) + strlen(uid) + strlen(pwd) + sizeof(ODBC_TYPE) - 1 + 5;
hashed_details = emalloc(len);
if (hashed_details == NULL) {
@@ -1760,7 +1615,7 @@ void PHP3_UODBC_DO_CONNECT(INTERNAL_FUNCTION_PARAMETERS, int persistent)
RETURN_FALSE;
}
- hashed_len = _php3_sprintf(hashed_details, "%s_%s_%s_%s_%d", UODBC_NAME, db, uid, pwd, cur_opt);
+ hashed_len = _php3_sprintf(hashed_details, "%s_%s_%s_%s_%d", ODBC_TYPE, db, uid, pwd, cur_opt);
/* FIXME the idea of checking to see if our connection is already persistent
is good, but it adds a lot of overhead to non-persistent connections. We
@@ -1777,12 +1632,12 @@ void PHP3_UODBC_DO_CONNECT(INTERNAL_FUNCTION_PARAMETERS, int persistent)
list_entry new_le, new_index_ptr;
if (persistent) {
- db_conn = (UODBC_CONNECTION *)malloc(sizeof(UODBC_CONNECTION));
+ db_conn = (odbc_connection *)malloc(sizeof(odbc_connection));
} else {
- db_conn = (UODBC_CONNECTION *)emalloc(sizeof(UODBC_CONNECTION));
+ db_conn = (odbc_connection *)emalloc(sizeof(odbc_connection));
}
- SQLAllocConnect(UODBC_GLOBAL(PHP3_UODBC_MODULE).henv, &db_conn->hdbc);
+ SQLAllocConnect(ODBCG(henv), &db_conn->hdbc);
#if HAVE_SOLID
SQLSetConnectOption(db_conn->hdbc, SQL_TRANSLATE_OPTION,
SQL_SOLID_XLATOPT_NOCNV);
@@ -1800,7 +1655,7 @@ void PHP3_UODBC_DO_CONNECT(INTERNAL_FUNCTION_PARAMETERS, int persistent)
if(cur_opt != SQL_CUR_DEFAULT){
rc = SQLSetConnectOption(db_conn->hdbc, SQL_ODBC_CURSORS, cur_opt);
if (rc != SQL_SUCCESS ) { /* && rc != SQL_SUCCESS_WITH_INFO ? */
- UODBC_SQL_ERROR(db_conn->hdbc, SQL_NULL_HSTMT, "SQLSetConnectOption");
+ ODBC_SQL_ERROR(db_conn->hdbc, SQL_NULL_HSTMT, "SQLSetConnectOption");
SQLFreeConnect(db_conn->hdbc);
if (persistent)
free(db_conn);
@@ -1855,7 +1710,7 @@ void PHP3_UODBC_DO_CONNECT(INTERNAL_FUNCTION_PARAMETERS, int persistent)
#endif
if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- UODBC_SQL_ERROR(db_conn->hdbc, SQL_NULL_HSTMT, "SQLConnect");
+ ODBC_SQL_ERROR(db_conn->hdbc, SQL_NULL_HSTMT, "SQLConnect");
SQLFreeConnect(db_conn->hdbc);
if (persistent)
free(db_conn);
@@ -1865,10 +1720,10 @@ void PHP3_UODBC_DO_CONNECT(INTERNAL_FUNCTION_PARAMETERS, int persistent)
}
db_conn->open = 1;
if (persistent){
- new_le.type = UODBC_GLOBAL(PHP3_UODBC_MODULE).le_pconn;
+ new_le.type = ODBCG(le_pconn);
new_le.ptr = db_conn;
return_value->value.lval =
- php3_plist_insert(db_conn, UODBC_GLOBAL(PHP3_UODBC_MODULE).le_pconn);
+ php3_plist_insert(db_conn, ODBCG(le_pconn));
new_index_ptr.ptr = (void *) return_value->value.lval;
#ifdef THREAD_SAFE
new_index_ptr.type = _php3_le_index_ptr();
@@ -1883,12 +1738,12 @@ void PHP3_UODBC_DO_CONNECT(INTERNAL_FUNCTION_PARAMETERS, int persistent)
efree(hashed_details);
RETURN_FALSE;
}
- UODBC_GLOBAL(PHP3_UODBC_MODULE).num_persistent++;
+ ODBCG(num_persistent)++;
} else {
- new_le.type = UODBC_GLOBAL(PHP3_UODBC_MODULE).le_conn;
+ new_le.type = ODBCG(le_conn);
new_le.ptr = db_conn;
return_value->value.lval =
- php3_list_insert(db_conn, UODBC_GLOBAL(PHP3_UODBC_MODULE).le_conn);
+ php3_list_insert(db_conn, ODBCG(le_conn));
new_index_ptr.ptr = (void *) return_value->value.lval;
#ifdef THREAD_SAFE
new_index_ptr.type = _php3_le_index_ptr();
@@ -1905,7 +1760,7 @@ void PHP3_UODBC_DO_CONNECT(INTERNAL_FUNCTION_PARAMETERS, int persistent)
}
}
- UODBC_GLOBAL(PHP3_UODBC_MODULE).num_links++;
+ ODBCG(num_links)++;
} else {
/* we are already connected */
@@ -1922,9 +1777,9 @@ void PHP3_UODBC_DO_CONNECT(INTERNAL_FUNCTION_PARAMETERS, int persistent)
/* first see if there is a persistent connection and use it,
else, if we are making a non-persistent connect, check our
non-persistent list */
- db_conn = (UODBC_CONNECTION *)php3_plist_find(id, &type);
+ db_conn = (odbc_connection *)php3_plist_find(id, &type);
if(!db_conn && !persistent)
- db_conn = (UODBC_CONNECTION *)php3_list_find(id, &type);
+ db_conn = (odbc_connection *)php3_list_find(id, &type);
/* FIXME test if the connection is dead */
@@ -1932,8 +1787,8 @@ void PHP3_UODBC_DO_CONNECT(INTERNAL_FUNCTION_PARAMETERS, int persistent)
* implicitly when needed. Cool.
*/
- if (db_conn && (type == UODBC_GLOBAL(PHP3_UODBC_MODULE).le_conn ||
- type == UODBC_GLOBAL(PHP3_UODBC_MODULE).le_pconn)){
+ if (db_conn && (type == ODBCG(le_conn) ||
+ type == ODBCG(le_pconn))){
return_value->value.lval = id;
} else {
efree(hashed_details);
@@ -1946,12 +1801,12 @@ void PHP3_UODBC_DO_CONNECT(INTERNAL_FUNCTION_PARAMETERS, int persistent)
/* {{{ proto odbc_close(int connection_id)
Close an ODBC connection */
-UODBC_FUNCTION(close)
+PHP_FUNCTION(odbc_close)
{
pval *arg1;
HDBC conn;
int type, ind;
- UODBC_TLS_VARS;
+ ODBC_TLS_VARS;
if (getParameters(ht, 1, &arg1) == FAILURE) {
WRONG_PARAM_COUNT;
@@ -1960,8 +1815,8 @@ UODBC_FUNCTION(close)
ind = (int)arg1->value.lval;
conn = (HDBC)php3_list_find(ind, &type);
if (!conn ||
- (type != UODBC_GLOBAL(PHP3_UODBC_MODULE).le_conn &&
- type != UODBC_GLOBAL(PHP3_UODBC_MODULE).le_pconn)) {
+ (type != ODBCG(le_conn) &&
+ type != ODBCG(le_pconn))) {
return;
}
php3_list_delete(ind);
@@ -1970,9 +1825,9 @@ UODBC_FUNCTION(close)
/* {{{ proto odbc_num_rows(int result_id)
Get number of rows in a result */
-UODBC_FUNCTION(num_rows)
+PHP_FUNCTION(odbc_num_rows)
{
- UODBC_RESULT *result;
+ odbc_result *result;
SDWORD rows;
pval *arg1;
@@ -1982,7 +1837,7 @@ UODBC_FUNCTION(num_rows)
convert_to_long(arg1);
- if ((result = UODBC_GET_RESULT(list, arg1->value.lval)) == NULL) {
+ if ((result = odbc_get_result(list, arg1->value.lval)) == NULL) {
RETURN_FALSE;
}
@@ -1993,9 +1848,9 @@ UODBC_FUNCTION(num_rows)
/* {{{ proto odbc_num_fields(int result_id)
Get number of columns in a result */
-UODBC_FUNCTION(num_fields)
+PHP_FUNCTION(odbc_num_fields)
{
- UODBC_RESULT *result;
+ odbc_result *result;
pval *arg1;
if ( getParameters(ht, 1, &arg1) == FAILURE) {
@@ -2004,7 +1859,7 @@ UODBC_FUNCTION(num_fields)
convert_to_long(arg1);
- if ((result = UODBC_GET_RESULT(list, arg1->value.lval)) == NULL) {
+ if ((result = odbc_get_result(list, arg1->value.lval)) == NULL) {
RETURN_FALSE;
}
RETURN_LONG(result->numcols);
@@ -2013,9 +1868,9 @@ UODBC_FUNCTION(num_fields)
/* {{{ proto odbc_field_name(int result_id, int field_number)
Get a column name */
-UODBC_FUNCTION(field_name)
+PHP_FUNCTION(odbc_field_name)
{
- UODBC_RESULT *result;
+ odbc_result *result;
pval *arg1, *arg2;
if (getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
@@ -2025,7 +1880,7 @@ UODBC_FUNCTION(field_name)
convert_to_long(arg1);
convert_to_long(arg2);
- if ((result = UODBC_GET_RESULT(list, arg1->value.lval)) == NULL) {
+ if ((result = odbc_get_result(list, arg1->value.lval)) == NULL) {
RETURN_FALSE;
}
@@ -2050,9 +1905,9 @@ UODBC_FUNCTION(field_name)
/* {{{ proto odbc_field_type(int result_id, int field_number)
Get the datatype of a column */
-UODBC_FUNCTION(field_type)
+PHP_FUNCTION(odbc_field_type)
{
- UODBC_RESULT *result;
+ odbc_result *result;
char tmp[32];
SWORD tmplen;
pval *arg1, *arg2;
@@ -2064,7 +1919,7 @@ UODBC_FUNCTION(field_type)
convert_to_long(arg1);
convert_to_long(arg2);
- if ((result = UODBC_GET_RESULT(list, arg1->value.lval)) == NULL) {
+ if ((result = odbc_get_result(list, arg1->value.lval)) == NULL) {
RETURN_FALSE;
}
@@ -2086,9 +1941,9 @@ UODBC_FUNCTION(field_type)
/* {{{ proto odbc_field_len(int result_id, int field_number)
Get the length of a column */
-UODBC_FUNCTION(field_len)
+PHP_FUNCTION(odbc_field_len)
{
- UODBC_RESULT *result;
+ odbc_result *result;
SDWORD len;
pval *arg1, *arg2;
@@ -2099,7 +1954,7 @@ UODBC_FUNCTION(field_len)
convert_to_long(arg1);
convert_to_long(arg2);
- if ((result = UODBC_GET_RESULT(list, arg1->value.lval)) == NULL) {
+ if ((result = odbc_get_result(list, arg1->value.lval)) == NULL) {
RETURN_FALSE;
}
@@ -2121,11 +1976,11 @@ UODBC_FUNCTION(field_len)
/* {{{ proto odbc_field_num(int result_id, string field_name)
Return column number */
-UODBC_FUNCTION(field_num)
+PHP_FUNCTION(odbc_field_num)
{
int field_ind;
char *fname;
- UODBC_RESULT *result;
+ odbc_result *result;
int i;
pval *arg1, *arg2;
@@ -2141,7 +1996,7 @@ UODBC_FUNCTION(field_num)
php3_error(E_WARNING, "No tuples available at this result index");
RETURN_FALSE;
}
- if ((result = UODBC_GET_RESULT(list, arg1->value.lval)) == NULL) {
+ if ((result = odbc_get_result(list, arg1->value.lval)) == NULL) {
RETURN_FALSE;
}
@@ -2158,9 +2013,9 @@ UODBC_FUNCTION(field_num)
/* {{{ proto odbc_autocommit(int connection_id, int OnOff)
Toggle autocommit mode */
-UODBC_FUNCTION(autocommit)
+PHP_FUNCTION(odbc_autocommit)
{
- UODBC_CONNECTION *curr_conn;
+ odbc_connection *curr_conn;
RETCODE rc;
pval *arg1, *arg2 = NULL;
int argc;
@@ -2183,7 +2038,7 @@ UODBC_FUNCTION(autocommit)
convert_to_long(arg2);
}
- if ((curr_conn = UODBC_GET_CONN(list, arg1->value.lval)) == NULL) {
+ if ((curr_conn = odbc_get_conn(list, arg1->value.lval)) == NULL) {
RETURN_FALSE;
}
@@ -2192,7 +2047,7 @@ UODBC_FUNCTION(autocommit)
(arg2->value.lval) ?
SQL_AUTOCOMMIT_ON : SQL_AUTOCOMMIT_OFF);
if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO){
- UODBC_SQL_ERROR(curr_conn->hdbc, SQL_NULL_HSTMT, "Set autocommit");
+ ODBC_SQL_ERROR(curr_conn->hdbc, SQL_NULL_HSTMT, "Set autocommit");
RETURN_FALSE;
}
RETVAL_TRUE;
@@ -2201,7 +2056,7 @@ UODBC_FUNCTION(autocommit)
rc = SQLGetConnectOption(curr_conn->hdbc, SQL_AUTOCOMMIT, (PTR)&status);
if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO){
- UODBC_SQL_ERROR(curr_conn->hdbc, SQL_NULL_HSTMT, "Test autocommit");
+ ODBC_SQL_ERROR(curr_conn->hdbc, SQL_NULL_HSTMT, "Test autocommit");
RETURN_FALSE;
}
RETVAL_LONG((long)status);
@@ -2209,12 +2064,12 @@ UODBC_FUNCTION(autocommit)
}
/* }}} */
-void PHP3_UODBC_TRANSACT(INTERNAL_FUNCTION_PARAMETERS, int type)
+void PHP3_ODBC_TRANSACT(INTERNAL_FUNCTION_PARAMETERS, int type)
{
- UODBC_CONNECTION *curr_conn;
+ odbc_connection *curr_conn;
RETCODE rc;
pval *arg1;
- UODBC_TLS_VARS;
+ ODBC_TLS_VARS;
if ( getParameters(ht, 1, &arg1) == FAILURE) {
WRONG_PARAM_COUNT;
@@ -2222,13 +2077,13 @@ void PHP3_UODBC_TRANSACT(INTERNAL_FUNCTION_PARAMETERS, int type)
convert_to_long(arg1);
- if ((curr_conn = UODBC_GET_CONN(list, arg1->value.lval)) == NULL){
+ if ((curr_conn = odbc_get_conn(list, arg1->value.lval)) == NULL){
RETURN_FALSE;
}
- rc = SQLTransact(UODBC_GLOBAL(PHP3_UODBC_MODULE).henv, curr_conn->hdbc, (UWORD)((type)?SQL_COMMIT:SQL_ROLLBACK));
+ rc = SQLTransact(ODBCG(henv), curr_conn->hdbc, (UWORD)((type)?SQL_COMMIT:SQL_ROLLBACK));
if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO){
- UODBC_SQL_ERROR(curr_conn->hdbc, SQL_NULL_HSTMT, "SQLTransact");
+ ODBC_SQL_ERROR(curr_conn->hdbc, SQL_NULL_HSTMT, "SQLTransact");
RETURN_FALSE;
}
@@ -2237,26 +2092,26 @@ void PHP3_UODBC_TRANSACT(INTERNAL_FUNCTION_PARAMETERS, int type)
/* {{{ proto odbc_commit(int connection_id)
Commit an ODBC transaction */
-UODBC_FUNCTION(commit)
+PHP_FUNCTION(odbc_commit)
{
- PHP3_UODBC_TRANSACT(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
+ PHP3_ODBC_TRANSACT(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
}
/* }}} */
/* {{{ proto odbc_rollback(int connection_id)
Rollback a transaction */
-UODBC_FUNCTION(rollback)
+PHP_FUNCTION(odbc_rollback)
{
- PHP3_UODBC_TRANSACT(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
+ PHP3_ODBC_TRANSACT(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
}
/* }}} */
/* {{{ proto odbc_setoption(??)
?? */
-UODBC_FUNCTION(setoption)
+PHP_FUNCTION(odbc_setoption)
{
- UODBC_CONNECTION *curr_conn;
- UODBC_RESULT *result;
+ odbc_connection *curr_conn;
+ odbc_result *result;
RETCODE rc;
pval *arg1, *arg2, *arg3, *arg4;
@@ -2271,22 +2126,22 @@ UODBC_FUNCTION(setoption)
switch (arg2->value.lval) {
case 1: /* SQLSetConnectOption */
- if ((curr_conn = UODBC_GET_CONN(list, arg1->value.lval)) == NULL){
+ if ((curr_conn = odbc_get_conn(list, arg1->value.lval)) == NULL){
RETURN_FALSE;
}
rc = SQLSetConnectOption(curr_conn->hdbc, (unsigned short)(arg3->value.lval), (arg4->value.lval));
if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO){
- UODBC_SQL_ERROR(curr_conn->hdbc, SQL_NULL_HSTMT, "SetConnectOption");
+ ODBC_SQL_ERROR(curr_conn->hdbc, SQL_NULL_HSTMT, "SetConnectOption");
RETURN_FALSE;
}
break;
case 2: /* SQLSetStmtOption */
- if ((result = UODBC_GET_RESULT(list, arg1->value.lval)) == NULL) {
+ if ((result = odbc_get_result(list, arg1->value.lval)) == NULL) {
RETURN_FALSE;
}
rc = SQLSetStmtOption(result->stmt, (unsigned short)(arg3->value.lval), (arg4->value.lval));
if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO){
- UODBC_SQL_ERROR(result->conn_ptr->hdbc, result->stmt, "SetStmtOption");
+ ODBC_SQL_ERROR(result->conn_ptr->hdbc, result->stmt, "SetStmtOption");
RETURN_FALSE;
}
break;
diff --git a/ext/odbc/php3_odbc.h b/ext/odbc/php3_odbc.h
index 1357553..2e5abe9 100644
--- a/ext/odbc/php3_odbc.h
+++ b/ext/odbc/php3_odbc.h
@@ -30,377 +30,39 @@
/* $Id$ */
-#ifndef _UNIFIED_ODBC_H
-#define _UNIFIED_ODBC_H
+#ifndef _PHP_ODBC_H
+# define _PHP_ODBC_H
-#if HAVE_UODBC
+# if HAVE_UODBC
-/*these defines are used to seperate the different
-database modules that use the uodbc interface so that
-two or more of them can be compiled into the same
-php binary*/
-
-/*
-*
-* Defines for ODBC
-*
-*/
-#if HAVE_UODBC
-/* win32 vars for thread local storage */
-#define UODBC_MUTEX uodbc_mutex
-#define UODBC_TLS UODBCTls
-#define UODBC_GLOBAL_STRUCT uodbc_global_struct
-#define UODBC_GLOBALS uodbc_globals
-/* defines for variables, structs, etc */
-#define UODBC_MODULE_NAME "ODBC (uODBC)"
-#define UODBC_FUNCTIONS uodbc_functions
-#define UODBC_MODULE_ENTRY uodbc_module_entry
-#define UODBC_CONNECTION uodbc_connection
-#define UODBC_RESULT_VALUE uodbc_result_value
-#define UODBC_RESULT uodbc_result
-#define UODBC_MODULE uodbc_module
-#define PHP3_UODBC_MODULE php3_uodbc_module
-
-/* function defines */
-#define PHP3_MINIT_UODBC php3_minit_uodbc
-#define PHP3_MSHUTDOWN_UODBC php3_mshutdown_uodbc
-#define PHP3_RINIT_UODBC php3_rinit_uodbc
-#define PHP3_INFO_UODBC php3_info_uodbc
-#define PHP3_UODBC_SETOPTION php3_uodbc_setoption
-#define PHP3_UODBC_AUTOCOMMIT php3_uodbc_autocommit
-#define PHP3_UODBC_CLOSE php3_uodbc_close
-#define PHP3_UDOBC_CLOSE_ALL php3_uodbc_close_all
-#define PHP3_UODBC_COMMIT php3_uodbc_commit
-#define PHP3_UODBC_CONNECT php3_uodbc_connect
-#define PHP3_UODBC_PCONNECT php3_uodbc_pconnect
-#define PHP3_UODBC_DO_CONNECT php3_uodbc_do_connect
-#define PHP3_UODBC_CURSOR php3_uodbc_cursor
-#define PHP3_UODBC_DO php3_uodbc_do
-#define PHP3_UODBC_EXECUTE php3_uodbc_execute
-#define PHP3_UODBC_FETCH_INTO php3_uodbc_fetch_into
-#define PHP3_UODBC_FETCH_ROW php3_uodbc_fetch_row
-#define PHP3_UODBC_FIELD_LEN php3_uodbc_field_len
-#define PHP3_UODBC_FIELD_NAME php3_uodbc_field_name
-#define PHP3_UODBC_FIELD_TYPE php3_uodbc_field_type
-#define PHP3_UODBC_FIELD_NUM php3_uodbc_field_num
-#define PHP3_UODBC_FREE_RESULT php3_uodbc_free_result
-#define PHP3_UODBC_NUM_FIELDS php3_uodbc_num_fields
-#define PHP3_UODBC_NUM_ROWS php3_uodbc_num_rows
-#define PHP3_UODBC_PREPARE php3_uodbc_prepare
-#define PHP3_UODBC_RESULT php3_uodbc_result
-#define PHP3_UODBC_RESULT_ALL php3_uodbc_result_all
-#define PHP3_UODBC_ROLLBACK php3_uodbc_rollback
-#define PHP3_UODBC_TRANSACT php3_uodbc_transact
-#define PHP3_UODBC_BINMODE php3_uodbc_binmode
-#define PHP3_UODBC_LONGREADLEN php3_uodbc_longreadlen
-
-/* internal function defines */
-#define UODBC_ADD_RESULT uodbc_add_result
-#define UODBC_GET_RESULT uodbc_get_result
-#define UODBC_DEL_RESULT uodbc_del_result
-#define UODBC_ADD_CONN uodbc_add_conn
-#define UODBC_GET_CONN uodbc_get_conn
-#define UODBC_DEL_CONN uodbc_del_conn
-#define UODBC_SQL_ERROR uodbc_sql_error
-#define UODBC_BINDCOLS uodbc_bindcols
-#define _FREE_UODBC_RESULT _free_uodbc_result
-#define _CLOSE_UODBC_CONNECTION _close_uodbc_connection
-#define _CLOSE_UODBC_PCONNECTION _close_uodbc_pconnection
-/* function name defines */
-#define ODBC_SETOPTION "odbc_setoption"
-#define ODBC_AUTOCOMMIT "odbc_autocommit"
-#define ODBC_CLOSE "odbc_close"
-#define ODBC_CLOSE_ALL "odbc_close_all"
-#define ODBC_COMMIT "odbc_commit"
-#define ODBC_CONNECT "odbc_connect"
-#define ODBC_PCONNECT "odbc_pconnect"
-#define ODBC_CURSOR "odbc_cursor"
-#define ODBC_DO "odbc_do"
-#define ODBC_EXEC "odbc_exec"
-#define ODBC_PREPARE "odbc_prepare"
-#define ODBC_EXECUTE "odbc_execute"
-#define ODBC_FETCH_ROW "odbc_fetch_row"
-#define ODBC_FETCH_INTO "odbc_fetch_into"
-#define ODBC_FIELD_LEN "odbc_field_len"
-#define ODBC_FIELD_NAME "odbc_field_name"
-#define ODBC_FIELD_TYPE "odbc_field_type"
-#define ODBC_FIELD_NUM "odbc_field_num"
-#define ODBC_FREE_RESULT "odbc_free_result"
-#define ODBC_NUM_FIELDS "odbc_num_fields"
-#define ODBC_NUM_ROWS "odbc_num_rows"
-#define ODBC_RESULT "odbc_result"
-#define ODBC_RESULT_ALL "odbc_result_all"
-#define ODBC_ROLLBACK "odbc_rollback"
-#define ODBC_TRANSACT "odbc_transact"
-#define ODBC_DO_CONNECT "odbc_do_connect"
-#define ODBC_LONGREADLEN "odbc_longreadlen"
-#define ODBC_BINMODE "odbc_binmode"
-
-/* ini variable defines */
-#define ODBC_INI_DEFAULTDB "uodbc.default_db"
-#define ODBC_INI_DEFAULTUSER "uodbc.default_user"
-#define ODBC_INI_DEFAULTPW "uodbc.default_pw"
-#define ODBC_INI_ALLOWPERSISTENT "uodbc.allow_persistent"
-#define ODBC_INI_MAXPERSISTENT "uodbc.max_persistent"
-#define ODBC_INI_MAXLINKS "uodbc.max_links"
-#define ODBC_INI_DEFAULTLRL "uodbc.defaultlrl"
-#define ODBC_INI_DEFAULTBINMODE "uodbc.defaultbinmode"
-#endif
-
-/*
-*
-* Defines for SOLID
-*
-*/
-
-
-#if 0 /* HAVE_SOLID turned off for now,
- will use above uodbc defines for now */
-/* win32 vars for thread local storage */
-#define UODBC_MUTEX solid_mutex
-#define UODBC_TLS SOLIDTls
-#define UODBC_GLOBAL_STRUCT solid_global_struct
-#define UODBC_GLOBALS solid_globals
-/* defines for variables, structs, etc */
-#define UODBC_MODULE_NAME "SOLID (uODBC)"
-#define UODBC_FUNCTIONS solid_functions
-#define UODBC_MODULE_ENTRY solid_module_entry
-#define UODBC_CONNECTION solid_connection
-#define UODBC_RESULT_VALUE solid_result_value
-#define UODBC_RESULT solid_result
-#define UODBC_MODULE solid_module
-#define PHP3_UODBC_MODULE php3_solid_module
-
-/* function defines */
-#define PHP3_MINIT_UODBC php3_minit_solid
-#define PHP3_MSHUTDOWN_UODBC php3_mshutdown_solid
-#define PHP3_RINIT_UODBC php3_rinit_solid
-#define PHP3_INFO_UODBC php3_info_solid
-#define PHP3_UODBC_SETOPTION php3_solid_setoption
-#define PHP3_UODBC_AUTOCOMMIT php3_solid_autocommit
-#define PHP3_UODBC_CLOSE php3_solid_close
-#define PHP3_UDOBC_CLOSE_ALL php3_solid_close_all
-#define PHP3_UODBC_COMMIT php3_solid_commit
-#define PHP3_UODBC_CONNECT php3_solid_connect
-#define PHP3_UODBC_PCONNECT php3_solid_pconnect
-#define PHP3_UODBC_DO_CONNECT php3_solid_do_connect
-#define PHP3_UODBC_CURSOR php3_solid_cursor
-#define PHP3_UODBC_DO php3_solid_do
-#define PHP3_UODBC_EXECUTE php3_solid_execute
-#define PHP3_UODBC_FETCH_INTO php3_solid_fetch_into
-#define PHP3_UODBC_FETCH_ROW php3_solid_fetch_row
-#define PHP3_UODBC_FIELD_LEN php3_solid_field_len
-#define PHP3_UODBC_FIELD_NAME php3_solid_field_name
-#define PHP3_UODBC_FIELD_TYPE php3_solid_field_type
-#define PHP3_UODBC_FREE_RESULT php3_solid_free_result
-#define PHP3_UODBC_NUM_FIELDS php3_solid_num_fields
-#define PHP3_UODBC_NUM_ROWS php3_solid_num_rows
-#define PHP3_UODBC_PREPARE php3_solid_prepare
-#define PHP3_UODBC_RESULT php3_solid_result
-#define PHP3_UODBC_RESULT_ALL php3_solid_result_all
-#define PHP3_UODBC_ROLLBACK php3_solid_rollback
-#define PHP3_UODBC_TRANSACT php3_solid_transact
-
-/* internal function defines */
-#define UODBC_ADD_RESULT solid_add_result
-#define UODBC_GET_RESULT solid_get_result
-#define UODBC_DEL_RESULT solid_del_result
-#define UODBC_ADD_CONN solid_add_conn
-#define UODBC_GET_CONN solid_get_conn
-#define UODBC_DEL_CONN solid_del_conn
-#define UODBC_SQL_ERROR solid_sql_error
-#define UODBC_BINDCOLS solid_bindcols
-#define _FREE_UODBC_RESULT _free_solid_result
-#define _CLOSE_UODBC_CONNECTION _close_solid_connection
-#define _CLOSE_UODBC_PCONNECTION _close_solid_pconnection
-/* function name defines */
-#define ODBC_SETOPTION "solid_setoption"
-#define ODBC_AUTOCOMMIT "solid_autocommit"
-#define ODBC_CLOSE "solid_close"
-#define ODBC_CLOSE_ALL "solid_close_all"
-#define ODBC_COMMIT "solid_commit"
-#define ODBC_CONNECT "solid_connect"
-#define ODBC_PCONNECT "solid_pconnect"
-#define ODBC_CURSOR "solid_cursor"
-#define ODBC_DO "solid_do"
-#define ODBC_EXEC "solid_exec"
-#define ODBC_PREPARE "solid_prepare"
-#define ODBC_EXECUTE "solid_execute"
-#define ODBC_FETCH_ROW "solid_fetch_row"
-#define ODBC_FETCH_INTO "solid_fetch_into"
-#define ODBC_FIELD_LEN "solid_field_len"
-#define ODBC_FIELD_NAME "solid_field_name"
-#define ODBC_FIELD_TYPE "solid_field_type"
-#define ODBC_FREE_RESULT "solid_free_result"
-#define ODBC_NUM_FIELDS "solid_num_fields"
-#define ODBC_NUM_ROWS "solid_num_rows"
-#define ODBC_RESULT "solid_result"
-#define ODBC_RESULT_ALL "solid_result_all"
-#define ODBC_ROLLBACK "solid_rollback"
-#define ODBC_TRANSACT "solid_transact"
-#define ODBC_DO_CONNECT "solid_do_connect"
-
-/* ini variable defines */
-#define ODBC_INI_DEFAULTDB "solid.default_db"
-#define ODBC_INI_DEFAULTUSER "solid.default_user"
-#define ODBC_INI_DEFAULTPW "solid.default_pw"
-#define ODBC_INI_ALLOWPERSISTENT "solid.allow_persistent"
-#define ODBC_INI_MAXPERSISTENT "solid.max_persistent"
-#define ODBC_INI_MAXLINKS "solid.max_links"
-#endif
+# ifndef MSVC5
+# define FAR
+# endif
+/* checking in the same order as in configure.in */
-/*
-*
-* Defines for ADABAS
-*
-*/
-
-
-#if 0 /* HAVE_ADABAS turned for for now, uses
- defines from the ODBC section */
-/* win32 vars for thread local storage */
-#define UODBC_MUTEX adabas_mutex
-#define UODBC_TLS ADABASTls
-#define UODBC_GLOBAL_STRUCT adabas_global_struct
-#define UODBC_GLOBALS adabas_globals
-/* defines for variables, structs, etc */
-#define UODBC_MODULE_NAME "ADABAS D (uODBC)"
-#define UODBC_FUNCTIONS adabas_functions
-#define UODBC_MODULE_ENTRY adabas_module_entry
-#define UODBC_CONNECTION adabas_connection
-#define UODBC_RESULT_VALUE adabas_result_value
-#define UODBC_RESULT adabas_result
-#define UODBC_MODULE adabas_module
-#define PHP3_UODBC_MODULE php3_adabas_module
-
-/* function defines */
-#define PHP3_MINIT_UODBC php3_minit_adabas
-#define PHP3_MSHUTDOWN_UODBC php3_mshutdown_adabas
-#define PHP3_RINIT_UODBC php3_rinit_adabas
-#define PHP3_INFO_UODBC php3_info_adabas
-#define PHP3_UODBC_SETOPTION php3_adabas_setoption
-#define PHP3_UODBC_AUTOCOMMIT php3_adabas_autocommit
-#define PHP3_UODBC_CLOSE php3_adabas_close
-#define PHP3_UDOBC_CLOSE_ALL php3_adabas_close_all
-#define PHP3_UODBC_COMMIT php3_adabas_commit
-#define PHP3_UODBC_CONNECT php3_adabas_connect
-#define PHP3_UODBC_PCONNECT php3_adabas_pconnect
-#define PHP3_UODBC_DO_CONNECT php3_adabas_do_connect
-#define PHP3_UODBC_CURSOR php3_adabas_cursor
-#define PHP3_UODBC_DO php3_adabas_do
-#define PHP3_UODBC_EXECUTE php3_adabas_execute
-#define PHP3_UODBC_FETCH_INTO php3_adabas_fetch_into
-#define PHP3_UODBC_FETCH_ROW php3_adabas_fetch_row
-#define PHP3_UODBC_FIELD_LEN php3_adabas_field_len
-#define PHP3_UODBC_FIELD_NAME php3_adabas_field_name
-#define PHP3_UODBC_FIELD_TYPE php3_adabas_field_type
-#define PHP3_UODBC_FREE_RESULT php3_adabas_free_result
-#define PHP3_UODBC_NUM_FIELDS php3_adabas_num_fields
-#define PHP3_UODBC_NUM_ROWS php3_adabas_num_rows
-#define PHP3_UODBC_PREPARE php3_adabas_prepare
-#define PHP3_UODBC_RESULT php3_adabas_result
-#define PHP3_UODBC_RESULT_ALL php3_adabas_result_all
-#define PHP3_UODBC_ROLLBACK php3_adabas_rollback
-#define PHP3_UODBC_TRANSACT php3_adabas_transact
-
-/* internal function defines */
-#define UODBC_ADD_RESULT adabas_add_result
-#define UODBC_GET_RESULT adabas_get_result
-#define UODBC_DEL_RESULT adabas_del_result
-#define UODBC_ADD_CONN adabas_add_conn
-#define UODBC_GET_CONN adabas_get_conn
-#define UODBC_DEL_CONN adabas_del_conn
-#define UODBC_SQL_ERROR adabas_sql_error
-#define UODBC_BINDCOLS adabas_bindcols
-#define _FREE_UODBC_RESULT _free_adabas_result
-#define _CLOSE_UODBC_CONNECTION _close_adabas_connection
-#define _CLOSE_UODBC_PCONNECTION _close_adabas_pconnection
-/* function name defines */
-#define ODBC_SETOPTION "adabas_setoption"
-#define ODBC_AUTOCOMMIT "adabas_autocommit"
-#define ODBC_CLOSE "adabas_close"
-#define ODBC_CLOSE_ALL "adabas_close_all"
-#define ODBC_COMMIT "adabas_commit"
-#define ODBC_CONNECT "adabas_connect"
-#define ODBC_PCONNECT "adabas_pconnect"
-#define ODBC_CURSOR "adabas_cursor"
-#define ODBC_DO "adabas_do"
-#define ODBC_EXEC "adabas_exec"
-#define ODBC_PREPARE "adabas_prepare"
-#define ODBC_EXECUTE "adabas_execute"
-#define ODBC_FETCH_ROW "adabas_fetch_row"
-#define ODBC_FETCH_INTO "adabas_fetch_into"
-#define ODBC_FIELD_LEN "adabas_field_len"
-#define ODBC_FIELD_NAME "adabas_field_name"
-#define ODBC_FIELD_TYPE "adabas_field_type"
-#define ODBC_FREE_RESULT "adabas_free_result"
-#define ODBC_NUM_FIELDS "adabas_num_fields"
-#define ODBC_NUM_ROWS "adabas_num_rows"
-#define ODBC_RESULT "adabas_result"
-#define ODBC_RESULT_ALL "adabas_result_all"
-#define ODBC_ROLLBACK "adabas_rollback"
-#define ODBC_TRANSACT "adabas_transact"
-#define ODBC_DO_CONNECT "adabas_do_connect"
-
-/* ini variable defines */
-#define ODBC_INI_DEFAULTDB "adabas.default_db"
-#define ODBC_INI_DEFAULTUSER "adabas.default_user"
-#define ODBC_INI_DEFAULTPW "adabas.default_pw"
-#define ODBC_INI_ALLOWPERSISTENT "adabas.allow_persistent"
-#define ODBC_INI_MAXPERSISTENT "adabas.max_persistent"
-#define ODBC_INI_MAXLINKS "adabas.max_links"
-#endif
+# if HAVE_SOLID /* Solid Server */
-/* checking in the same order as in configure.in */
-# if HAVE_SOLID
# include <cli0core.h>
# include <cli0ext1.h>
# define HAVE_SQL_EXTENDED_FETCH 0
extern void php3_solid_fetch_prev(INTERNAL_FUNCTION_PARAMETERS);
-# if defined(UODBC_UNIQUE_NAMES)
-# define UODBC_TYPE solid
-# define UODBC_NAME "solid"
-# define UODBC_FE(name, arg_types) UODBC_NAMED_FE(solid_##name, php3_solid_##name, arg_types)
-# define UODBC_FE_ALIAS(php_name, name, arg_types) UODBC_NAMED_FE(solid_##php_name, php3_solid_##name, arg_types)
-# define UODBC_FUNCTION(name) UODBC_NAMED_FUNCTION(php3_solid_##name)
-# define UODBC_FNAME(name) php3i_solid_##name
-# define ODBC_INI_VAR_NAME(name) #name
-# define ODBC_INI_VAR(a) ODBC_INI_VAR_NAME(solid.##a)
-# define UODBC_VAR_NAME(name) name
-# define UODBC_VAR(a) UODBC_VAR_NAME(solid_##a)
-# define PHP3_UODBC_VAR(a) UODBC_VAR_NAME(php3_solid_##a)
-# define UODBC_MODULE_ENTRY UODBC_VAR(module_entry)
-# define solid_module_ptr &UODBC_MODULE_ENTRY
-# endif
-#elif HAVE_EMPRESS
+# elif HAVE_EMPRESS /* Empress */
+
# include <sql.h>
# include <sqlext.h>
# define HAVE_SQL_EXTENDED_FETCH 0
-#elif HAVE_ADABAS
-#include <WINDOWS.H>
-#include <sql.h>
-#include <sqlext.h>
+# elif HAVE_ADABAS /* Adabas D */
+
+# include <WINDOWS.H>
+# include <sql.h>
+# include <sqlext.h>
# define HAVE_SQL_EXTENDED_FETCH 1
-# if defined(UODBC_UNIQUE_NAMES)
-# define UODBC_TYPE adabas
-# define UODBC_NAME "adabas"
-# define UODBC_FE(name, arg_types) UODBC_NAMED_FE(ada_##name, php3_ada_##name, arg_types)
-# define UODBC_FE_ALIAS(php_name, name, arg_types) UODBC_NAMED_FE(ada_##php_name, php3_ada_##name, arg_types)
-# define UODBC_FUNCTION(name) UODBC_NAMED_FUNCTION(php3_ada_##name)
-# define UODBC_FNAME(name) php3i_ada_##name
-# define ODBC_INI_VAR_NAME(name) #name
-# define ODBC_INI_VAR(a) ODBC_INI_VAR_NAME(ada.##a)
-# define UODBC_VAR_NAME(name) name
-# define UODBC_VAR(a) UODBC_VAR_NAME(ada_##a)
-# define PHP3_UODBC_VAR(a) UODBC_VAR_NAME(php3_ada_##a)
-# define UODBC_MODULE_ENTRY UODBC_VAR(module_entry)
-# define ada_module_ptr &UODBC_MODULE_ENTRY
-# endif
-# elif HAVE_IODBC && !(WIN32|WINNT)
+# elif HAVE_IODBC /* iODBC library */
+
# include <isql.h>
# include <isqlext.h>
# include <odbc_types.h>
@@ -412,255 +74,105 @@ extern void php3_solid_fetch_prev(INTERNAL_FUNCTION_PARAMETERS);
# define SQL_SO_DYNAMIC 0x00000004L
# define SQL_LEN_DATA_AT_EXEC_OFFSET (-100)
# define SQL_LEN_DATA_AT_EXEC(length) (-(length)+SQL_LEN_DATA_AT_EXEC_OFFSET)
-# if defined(UODBC_UNIQUE_NAMES)
-# define UODBC_TYPE iodbc
-# define UODBC_NAME "iodbc"
-# define UODBC_FE(name, arg_types) UODBC_NAMED_FE(iodbc_##name, php3_iodbc_##name, arg_types)
-# define UODBC_FE_ALIAS(php_name, name, arg_types) UODBC_NAMED_FE(iodbc_##php_name, php3_iodbc_##name, arg_types)
-# define UODBC_FUNCTION(name) UODBC_NAMED_FUNCTION(php3_iodbc_##name)
-# define UODBC_FNAME(name) php3i_iodbc_##name
-# define ODBC_INI_VAR_NAME(name) #name
-# define ODBC_INI_VAR(a) ODBC_INI_VAR_NAME(iodbc.##a)
-# define UODBC_VAR_NAME(name) name
-# define UODBC_VAR(a) UODBC_VAR_NAME(iodbc_##a)
-# define PHP3_UODBC_VAR(a) UODBC_VAR_NAME(php3_iodbc_##a)
-# define UODBC_MODULE_ENTRY UODBC_VAR(module_entry)
-# define iodbc_module_ptr &UODBC_MODULE_ENTRY
-# endif
-#elif HAVE_OPENLINK
+# elif HAVE_OPENLINK /* OpenLink ODBC drivers */
# include <iodbc.h>
# include <isql.h>
# include <isqlext.h>
# include <udbcext.h>
# define HAVE_SQL_EXTENDED_FETCH 1
-# if defined(UODBC_UNIQUE_NAMES)
-# define UODBC_TYPE opnlnk
-# define UODBC_NAME "opnlnk"
-# define UODBC_FE(name, arg_types) UODBC_NAMED_FE(opnlnk_##name, php3_opnlnk_##name, arg_types)
-# define UODBC_FE_ALIAS(php_name, name, arg_types) UODBC_NAMED_FE(opnlnk_##php_name, php3_opnlnk_##name, arg_types)
-# define UODBC_FUNCTION(name) UODBC_NAMED_FUNCTION(php3_opnlnk_##name)
-# define UODBC_FNAME(name) php3i_opnlnk_##name
-# define ODBC_INI_VAR_NAME(name) #name
-# define ODBC_INI_VAR(a) ODBC_INI_VAR_NAME(opnlnk.##a)
-# define UODBC_VAR_NAME(name) name
-# define UODBC_VAR(a) UODBC_VAR_NAME(opnlnk_##a)
-# define PHP3_UODBC_VAR(a) UODBC_VAR_NAME(php3_opnlnk_##a)
-# define UODBC_MODULE_ENTRY UODBC_VAR(module_entry)
-# define opnlnk_module_ptr &UODBC_MODULE_ENTRY
-# endif
-#elif HAVE_VELOCIS
-/* Nothing ??? */
+# elif HAVE_VELOCIS /* Raima Velocis */
+
# define UNIX
# define HAVE_SQL_EXTENDED_FETCH 1
# include <sql.h>
# include <sqlext.h>
-# if defined(UODBC_UNIQUE_NAMES)
-# define UODBC_TYPE velocis
-# define UODBC_NAME "velocis"
-# define UODBC_FE(name, arg_types) UODBC_NAMED_FE(velocis_##name, php3_velocis_##name, arg_types)
-# define UODBC_FE_ALIAS(php_name, name, arg_types) UODBC_NAMED_FE(velocis_##php_name, php3_velocis_##name, arg_types)
-# define UODBC_FUNCTION(name) UODBC_NAMED_FUNCTION(php3_velocis_##name)
-# define UODBC_FNAME(name) php3i_velocis_##name
-# define ODBC_INI_VAR_NAME(name) #name
-# define ODBC_INI_VAR(a) ODBC_INI_VAR_NAME(velocis.##a)
-# define UODBC_VAR_NAME(name) name
-# define UODBC_VAR(a) UODBC_VAR_NAME(velocis_##a)
-# define PHP3_UODBC_VAR(a) UODBC_VAR_NAME(php3_velocis_##a)
-# define UODBC_MODULE_ENTRY UODBC_VAR(module_entry)
-# define velocis_module_ptr &UODBC_MODULE_ENTRY
-# endif
-#elif HAVE_CODBC
+# elif HAVE_CODBC /* Custom ODBC */
+
# define HAVE_SQL_EXTENDED_FETCH 1
# include <odbc.h>
-# if defined(UODBC_UNIQUE_NAMES)
-# define UODBC_TYPE codbc
-# define UODBC_NAME "codbc"
-# define UODBC_FE(name, arg_types) UODBC_NAMED_FE(codbc_##name, php3_codbc_##name, arg_types)
-# define UODBC_FE_ALIAS(php_name, name, arg_types) UODBC_NAMED_FE(codbc_##php_name, php3_codbc_##name, arg_types)
-# define UODBC_FUNCTION(name) UODBC_NAMED_FUNCTION(php3_codbc_##name)
-# define UODBC_FNAME(name) php3i_codbc_##name
-# define ODBC_INI_VAR_NAME(name) #name
-# define ODBC_INI_VAR(a) ODBC_INI_VAR_NAME(codbc.##a)
-# define UODBC_VAR_NAME(name) name
-# define UODBC_VAR(a) UODBC_VAR_NAME(codbc_##a)
-# define PHP3_UODBC_VAR(a) UODBC_VAR_NAME(php3_codbc_##a)
-# define UODBC_MODULE_ENTRY UODBC_VAR(module_entry)
-# define codbc_module_ptr &UODBC_MODULE_ENTRY
-# endif
-#elif HAVE_DB2
+# elif HAVE_DB2 /* DB2 CLI */
+
# define HAVE_SQL_EXTENDED_FETCH 1
# include <sqlcli1.h>
# ifdef DB268K
/* Need to include ASLM for 68K applications */
# include <LibraryManager.h>
# endif
-# if defined(UODBC_UNIQUE_NAMES)
-# define UODBC_TYPE db2
-# define UODBC_NAME "db2"
-# define UODBC_FE(name, arg_types) UODBC_NAMED_FE(db2_##name, php3_db2_##name, arg_types)
-# define UODBC_FE_ALIAS(php_name, name, arg_types) UODBC_NAMED_FE(db2_##php_name, php3_db2_##name, arg_types)
-# define UODBC_FUNCTION(name) UODBC_NAMED_FUNCTION(php3_db2_##name)
-# define UODBC_FNAME(name) php3i_db2_##name
-# define ODBC_INI_VAR_NAME(name) #name
-# define ODBC_INI_VAR(a) ODBC_INI_VAR_NAME(db2.##a)
-# define UODBC_VAR_NAME(name) name
-# define UODBC_VAR(a) UODBC_VAR_NAME(db2_##a)
-# define PHP3_UODBC_VAR(a) UODBC_VAR_NAME(php3_db2_##a)
-# define UODBC_MODULE_ENTRY UODBC_VAR(module_entry)
-# define db2_module_ptr &UODBC_MODULE_ENTRY
-# endif
# else /* MS ODBC */
+
# define HAVE_SQL_EXTENDED_FETCH 1
# include <WINDOWS.H>
# include <sql.h>
# include <sqlext.h>
-# if defined(UODBC_UNIQUE_NAMES)
-# define UODBC_TYPE wodbc
-# define UODBC_NAME "wodbc"
-# define UODBC_FE(name, arg_types) UODBC_NAMED_FE(wodbc_##name, php3_wodbc_##name, arg_types)
-# define UODBC_FE_ALIAS(php_name, name, arg_types) UODBC_NAMED_FE(wodbc_##php_name, php3_wodbc_##name, arg_types)
-# define UODBC_FUNCTION(name) UODBC_NAMED_FUNCTION(php3_wodbc_##name)
-# define UODBC_FNAME(name) php3i_wodbc_##name
-# define ODBC_INI_VAR_NAME(name) #name
-# define ODBC_INI_VAR(a) ODBC_INI_VAR_NAME(wuodbc.##a)
-# define UODBC_VAR_NAME(name) name
-# define UODBC_VAR(a) UODBC_VAR_NAME(wodbc_##a)
-# define PHP3_UODBC_VAR(a) UODBC_VAR_NAME(php3_wuodbc_##a)
-# define UODBC_MODULE_ENTRY UODBC_VAR(module_entry)
-# define wodbc_module_ptr &UODBC_MODULE_ENTRY
-# endif
# endif
-
-#if !defined(UODBC_UNIQUE_NAMES)
-#define UODBC_TYPE odbc
-#define UODBC_NAME "odbc"
-#define UODBC_FE(name, arg_types) UODBC_NAMED_FE(odbc_##name, php3_odbc_##name, arg_types)
-#define UODBC_FE_ALIAS(php_name, name, arg_types) UODBC_NAMED_FE(odbc_##php_name, php3_odbc_##name, arg_types)
-#define UODBC_FUNCTION(name) UODBC_NAMED_FUNCTION(php3_odbc_##name)
-#define UODBC_FNAME(name) php3i_odbc_##name
-#define ODBC_INI_VAR_NAME(name) #name
-#define ODBC_INI_VAR(a) ODBC_INI_VAR_NAME(uodbc.##a)
-#define UODBC_VAR_NAME(name) name
-#define UODBC_VAR(a) UODBC_VAR_NAME(uodbc_##a)
-#define PHP3_UODBC_VAR(a) UODBC_VAR_NAME(php3_uodbc_##a)
-#define UODBC_MODULE_ENTRY UODBC_VAR(module_entry)
-#define uodbc_module_ptr &UODBC_MODULE_ENTRY
-#else
-#define UODBC_ALIAS(name, arg_types) UODBC_NAMED_FE(odbc_##name, php3_odbc_##name, arg_types)
-#define UODBC_ALIAS_FE(php_name, name, arg_types) UODBC_NAMED_FE(odbc_##php_name, php3_odbc_##name, arg_types)
-#endif
-
-
-
-/*
-*
-* Defines for ODBC
-*
-*/
-
-/* win32 vars for thread local storage */
-#define UODBC_MUTEX UODBC_VAR(mutex)
-#define UODBC_TLS UODBC_VAR(Tls)
-#define UODBC_GLOBAL_STRUCT UODBC_VAR(global_struct)
-#define UODBC_GLOBALS UODBC_VAR(globals)
-/* defines for variables, structs, etc */
-#define UODBC_MODULE_NAME "ODBC"
-#define UODBC_FUNCTIONS UODBC_VAR(functions)
-#define UODBC_CONNECTION UODBC_VAR(connection)
-#define UODBC_RESULT_VALUE UODBC_VAR(result_value)
-#define UODBC_RESULT UODBC_VAR(result)
-#define UODBC_MODULE UODBC_VAR(module)
-#define UODBC_MODULE_PTR UODBC_VAR(module_ptr)
-#define PHP3_UODBC_MODULE PHP3_UODBC_VAR(module)
-
-/* function defines */
-#define PHP3_MINIT_UODBC UODBC_FNAME(minit)
-#define PHP3_MSHUTDOWN_UODBC UODBC_FNAME(mshutdown)
-#define PHP3_RINIT_UODBC UODBC_FNAME(rinit)
-#define PHP3_INFO_UODBC UODBC_FNAME(info)
-
-/* internal function defines */
-#define UODBC_ADD_RESULT UODBC_FNAME(add_result)
-#define UODBC_GET_RESULT UODBC_FNAME(get_result)
-#define UODBC_DEL_RESULT UODBC_FNAME(del_result)
-#define UODBC_ADD_CONN UODBC_FNAME(add_conn)
-#define UODBC_GET_CONN UODBC_FNAME(get_conn)
-#define UODBC_DEL_CONN UODBC_FNAME(del_conn)
-#define UODBC_SQL_ERROR UODBC_FNAME(sql_error)
-#define UODBC_BINDCOLS UODBC_FNAME(bindcols)
-#define PHP3_UODBC_DO_CONNECT UODBC_FNAME(_do_connect)
-#define PHP3_UODBC_TRANSACT UODBC_FNAME(_do_transact)
-
-# ifndef MSVC5
-# define FAR
-# endif
-
-extern php3_module_entry UODBC_MODULE_ENTRY;
-
-/* uODBC functions */
-extern int PHP3_MINIT_UODBC(INIT_FUNC_ARGS);
-extern int PHP3_MSHUTDOWN_UODBC(void);
-extern int PHP3_RINIT_UODBC(INIT_FUNC_ARGS);
-extern void PHP3_INFO_UODBC(void);
-extern UODBC_FUNCTION(setoption);
-extern UODBC_FUNCTION(autocommit);
-extern UODBC_FUNCTION(close);
-extern UODBC_FUNCTION(close_all);
-extern UODBC_FUNCTION(commit);
-extern UODBC_FUNCTION(connect);
-extern UODBC_FUNCTION(pconnect);
-extern void PHP3_UODBC_DO_CONNECT(INTERNAL_FUNCTION_PARAMETERS, int);
-extern UODBC_FUNCTION(cursor);
-extern UODBC_FUNCTION(exec);
-/*extern UODBC_FUNCTION(do);*/
-extern UODBC_FUNCTION(execute);
-extern UODBC_FUNCTION(fetch_into);
-extern UODBC_FUNCTION(fetch_row);
-extern UODBC_FUNCTION(field_len);
-extern UODBC_FUNCTION(field_name);
-extern UODBC_FUNCTION(field_type);
-extern UODBC_FUNCTION(field_num);
-extern UODBC_FUNCTION(free_result);
-extern UODBC_FUNCTION(num_fields);
-extern UODBC_FUNCTION(num_rows);
-extern UODBC_FUNCTION(prepare);
-extern UODBC_FUNCTION(result);
-extern UODBC_FUNCTION(result_all);
-extern UODBC_FUNCTION(rollback);
-extern void PHP3_UODBC_TRANSACT(INTERNAL_FUNCTION_PARAMETERS, int);
-extern UODBC_FUNCTION(binmode);
-extern UODBC_FUNCTION(longreadlen);
-
-typedef struct UODBC_CONNECTION {
+extern php3_module_entry odbc_module_entry;
+# define odbc_module_ptr &odbc_module_entry
+
+
+/* user functions */
+extern int php3_minit_odbc(INIT_FUNC_ARGS);
+extern int php3_mshutdown_odbc(SHUTDOWN_FUNC_ARGS);
+extern int php3_rinit_odbc(INIT_FUNC_ARGS);
+extern void php3_info_odbc(void);
+extern PHP_FUNCTION(odbc_setoption);
+extern PHP_FUNCTION(odbc_autocommit);
+extern PHP_FUNCTION(odbc_close);
+extern PHP_FUNCTION(odbc_close_all);
+extern PHP_FUNCTION(odbc_commit);
+extern PHP_FUNCTION(odbc_connect);
+extern PHP_FUNCTION(odbc_pconnect);
+extern void php3_odbc_do_connect(INTERNAL_FUNCTION_PARAMETERS, int);
+extern PHP_FUNCTION(odbc_cursor);
+extern PHP_FUNCTION(odbc_exec);
+extern PHP_FUNCTION(odbc_do);
+extern PHP_FUNCTION(odbc_execute);
+extern PHP_FUNCTION(odbc_fetch_into);
+extern PHP_FUNCTION(odbc_fetch_row);
+extern PHP_FUNCTION(odbc_field_len);
+extern PHP_FUNCTION(odbc_field_name);
+extern PHP_FUNCTION(odbc_field_type);
+extern PHP_FUNCTION(odbc_field_num);
+extern PHP_FUNCTION(odbc_free_result);
+extern PHP_FUNCTION(odbc_num_fields);
+extern PHP_FUNCTION(odbc_num_rows);
+extern PHP_FUNCTION(odbc_prepare);
+extern PHP_FUNCTION(odbc_result);
+extern PHP_FUNCTION(odbc_result_all);
+extern PHP_FUNCTION(odbc_rollback);
+extern void php3_odbc_transact(INTERNAL_FUNCTION_PARAMETERS, int);
+extern PHP_FUNCTION(odbc_binmode);
+extern PHP_FUNCTION(odbc_longreadlen);
+
+typedef struct odbc_connection {
#if HAVE_DB2
SQLHANDLE hdbc;
#else
HDBC hdbc;
#endif
int open;
-} UODBC_CONNECTION;
+} odbc_connection;
-typedef struct UODBC_RESULT_VALUE {
+typedef struct odbc_result_value {
char name[32];
char *value;
long int vallen;
SDWORD coltype;
-} UODBC_RESULT_VALUE;
+} odbc_result_value;
-typedef struct UODBC_RESULT {
+typedef struct odbc_result {
#if HAVE_DB2
SQLHANDLE stmt;
#else
HSTMT stmt;
#endif
- UODBC_RESULT_VALUE *values;
+ odbc_result_value *values;
SWORD numcols;
SWORD numparams;
# if HAVE_SQL_EXTENDED_FETCH
@@ -669,8 +181,8 @@ typedef struct UODBC_RESULT {
long longreadlen;
int binmode;
int fetched;
- UODBC_CONNECTION *conn_ptr;
-} UODBC_RESULT;
+ odbc_connection *conn_ptr;
+} odbc_result;
typedef struct {
#if HAVE_DB2
@@ -692,34 +204,54 @@ typedef struct {
long defaultbinmode;
HashTable *resource_list;
HashTable *resource_plist;
-} UODBC_MODULE;
+} php_odbc_globals;
-# ifndef THREAD_SAFE
-extern UODBC_MODULE PHP3_UODBC_MODULE;
+# ifndef ZTS
+extern php_odbc_globals odbc_globals;
# endif
-int UODBC_ADD_RESULT(HashTable *list, UODBC_RESULT *result);
-UODBC_RESULT *UODBC_GET_RESULT(HashTable *list, int count);
-void UODBC_DEL_RESULT(HashTable *list, int count);
-int UODBC_ADD_CONN(HashTable *list, HDBC conn);
-UODBC_CONNECTION *UODBC_GET_CONN(HashTable *list, int count);
-void UODBC_DEL_CONN(HashTable *list, int ind);
+int odbc_add_result(HashTable *list, odbc_result *result);
+odbc_result *odbc_get_result(HashTable *list, int count);
+void odbc_del_result(HashTable *list, int count);
+int odbc_add_conn(HashTable *list, HDBC conn);
+odbc_connection *odbc_get_conn(HashTable *list, int count);
+void odbc_del_conn(HashTable *list, int ind);
#if HAVE_DB2
-void UODBC_SQL_ERROR(SQLHANDLE conn, SQLHANDLE stmt, char *func);
+void odbc_sql_error(SQLHANDLE conn, SQLHANDLE stmt, char *func);
#else
-void UODBC_SQL_ERROR(HDBC conn, HSTMT stmt, char *func);
+void odbc_sql_error(HDBC conn, HSTMT stmt, char *func);
#endif
-int UODBC_BINDCOLS(UODBC_RESULT *result);
+int odbc_bindcols(odbc_result *result);
#define IS_SQL_LONG(x) (x == SQL_LONGVARBINARY || x == SQL_LONGVARCHAR)
#define IS_SQL_BINARY(x) (x == SQL_BINARY || x == SQL_VARBINARY || x == SQL_LONGVARBINARY)
+#ifdef ZTS
+# define ODBCLS_D php_odbc_globals *odbc_globals
+# define ODBCLS_DC , ODBCLS_D
+# define ODBCLS_C odbc_globals
+# define ODBCLS_CC , ODBCLS_C
+# define ODBCG(v) (odbc_globals->v)
+# define ODBCLS_FETCH() php_odbc_globals *odbc_globals = ts_resource(odbc_globals_id)
+# define ODBC_TLS_VARS char *globals; ODBCLS_FETCH(); globals = (char *)odbc_globals;
#else
-# define uodbc_module_ptr NULL
+# define ODBCLS_D
+# define ODBCLS_DC
+# define ODBCLS_C
+# define ODBCLS_CC
+# define ODBCG(v) (odbc_globals.v)
+# define ODBCLS_FETCH()
+# define ODBC_TLS_VARS char *globals = (char *)&odbc_globals
+extern ZEND_API php_odbc_globals odbc_globals;
+#endif
+
+#else
+
+# define odbc_module_ptr NULL
-#endif /* HAVE_UODBC || HAVE_DB2 */
+#endif /* HAVE_UODBC */
-#endif /* _UNIFIED_ODBC_H */
+#endif /* _PHP_ODBC_H */
/*
* Local variables:
diff --git a/internal_functions.c b/internal_functions.c
index b464d8c..215dd03 100644
--- a/internal_functions.c
+++ b/internal_functions.c
@@ -96,7 +96,7 @@ zend_module_entry *php3_builtin_modules[] =
filepro_module_ptr,
sybase_module_ptr,
sybct_module_ptr,
- uodbc_module_ptr,
+ odbc_module_ptr,
dbase_module_ptr,
hw_module_ptr,
regexp_module_ptr,
diff --git a/main/php.h b/main/php.h
index e877dfa..b087058 100644
--- a/main/php.h
+++ b/main/php.h
@@ -39,6 +39,12 @@
#include "php_version.h"
#include "zend.h"
+#ifdef PACKAGE
+# undef PACKAGE
+#endif
+#ifdef VERSION
+# undef VERSION
+#endif
#include "zend_API.h"
@@ -329,6 +335,7 @@ extern PHPAPI int php3_fhttpd_write(char *a,int n);
#define PHP_NAMED_FE(php_name, name, arg_types) { #php_name, name, arg_types },
#define PHP_FE(name, arg_types) PHP_NAMED_FE(name, php3_##name, arg_types)
+#define PHP_FALIAS(name, alias, arg_types) PHP_NAMED_FE(name, php3_##alias, arg_types)
diff --git a/scripts/preconfig b/scripts/preconfig
index b230de4..40d182d 100755
--- a/scripts/preconfig
+++ b/scripts/preconfig
@@ -4,7 +4,7 @@
makefiles=`echo ext/*/Makefile.am | sed -e 's/\.am//g'`
sed -e "s#@@EXT_MAKEFILES@@#$makefiles#" configure.in.in > configure.in.new
-if ! cmp configure.in configure.in.new 2>/dev/null; then
+if ! cmp configure.in configure.in.new > /dev/null 2>&1; then
mv configure.in.new configure.in
else
rm -f configure.in.new
@@ -17,7 +17,7 @@ if test "$confighfiles" != "ext/*/config.h.stub"; then
cat $file >> acconfig.h.new
done
fi
-if ! cmp acconfig.h acconfig.h.new 2>/dev/null; then
+if ! cmp acconfig.h acconfig.h.new > /dev/null 2>&1; then
mv acconfig.h.new acconfig.h
autoheader
else