From 25253bb125e6e199aed7d328f845ce462826f06e Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Sat, 22 Sep 2001 22:54:33 +0000 Subject: [PATCH] Provide some initial support for building the ODBC driver for an already installed iODBC or unixODBC driver manager. In particular, use the include files provided by the driver manager over our own, and use the odbcinst library of the driver manager rather than gpps.c. Migrate portability sections common to several files into psqlodbc.h. --- GNUmakefile | 21 +++++++++++++++++---- bind.c | 8 -------- connection.c | 7 ++----- connection.h | 10 ---------- convert.c | 25 ++----------------------- dlg_specific.c | 14 +------------- dlg_specific.h | 2 -- drvconn.c | 8 +------- environ.h | 10 ---------- execute.c | 9 +-------- gpps.c | 2 +- gpps.h | 4 +++- info.c | 11 +---------- lobj.c | 2 +- misc.c | 15 --------------- misc.h | 5 ----- odbcapi.c | 7 ------- odbcapi30.c | 7 ------- options.c | 10 ---------- parse.c | 7 ------- pgapifunc.h | 7 ------- pgtypes.c | 10 ---------- psqlodbc.c | 9 +-------- psqlodbc.h | 42 +++++++++++++++++++++++++++++++++++++++--- qresult.c | 1 + results.c | 7 ------- setup.c | 3 +-- socket.c | 1 + socket.h | 2 -- statement.c | 14 +------------- statement.h | 9 +-------- tuple.c | 1 + tuplelist.c | 1 + 33 files changed, 77 insertions(+), 214 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index 2d9a1e6..2f7d05a 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -2,7 +2,7 @@ # # GNUMakefile for psqlodbc (Postgres ODBC driver) # -# $Header: /home/heikki/psqlodbc-cvs-copy/psqlodbc/Attic/GNUmakefile,v 1.19 2001/09/11 23:27:10 petere Exp $ +# $Header: /home/heikki/psqlodbc-cvs-copy/psqlodbc/Attic/GNUmakefile,v 1.20 2001/09/22 22:54:32 petere Exp $ # #------------------------------------------------------------------------- @@ -11,23 +11,36 @@ top_builddir = ../../.. include $(top_builddir)/src/Makefile.global # Shared library parameters +ifeq ($(with_unixodbc),yes) +NAME = odbcpsql +else NAME = psqlodbc +endif SO_MAJOR_VERSION = 0 SO_MINOR_VERSION = 27 -override CPPFLAGS := -I$(srcdir) $(CPPFLAGS) -DHAVE_CONFIG_H -DODBCINSTDIR='"$(odbcinst_ini_dir)"' +override CPPFLAGS := -I$(srcdir) $(CPPFLAGS) -DODBCINSTDIR='"$(odbcinst_ini_dir)"' OBJS = info.o bind.o columninfo.o connection.o convert.o drvconn.o \ environ.o execute.o lobj.o misc.o options.o \ pgtypes.o psqlodbc.o qresult.o results.o socket.o parse.o statement.o \ - gpps.o tuple.o tuplelist.o dlg_specific.o odbcapi.o $(OBJX) + tuple.o tuplelist.o dlg_specific.o odbcapi.o ifdef MULTIBYTE OBJS += multibyte.o endif -SHLIB_LINK = $(filter -lm -lnsl -lsocket, $(LIBS)) +SHLIB_LINK += $(filter -lm -lnsl -lsocket, $(LIBS)) +ifeq ($(with_unixodbc),yes) +SHLIB_LINK += -lodbcinst +endif +ifeq ($(with_iodbc),yes) +SHLIB_LINK += -liodbcinst +endif +ifeq ($(with_unixodbc)$(with_iodbc),nono) +OBJS += gpps.o +endif all: all-lib diff --git a/bind.c b/bind.c index ce17236..062632d 100644 --- a/bind.c +++ b/bind.c @@ -22,14 +22,6 @@ #include #include -#ifndef WIN32 -#include "iodbc.h" -#include "isql.h" -#include "isqlext.h" -#else -#include "sql.h" -#include "sqlext.h" -#endif #include "pgapifunc.h" diff --git a/connection.c b/connection.c index 7dc3fde..70c7b78 100644 --- a/connection.c +++ b/connection.c @@ -14,12 +14,12 @@ */ /* Multibyte support Eiji Tokuya 2001-03-15 */ +#include "connection.h" + #include #include #include -#include "connection.h" - #include "environ.h" #include "socket.h" #include "statement.h" @@ -31,9 +31,6 @@ #include "multibyte.h" #endif -#ifdef WIN32 -#include -#endif #include "pgapifunc.h" #define STMT_INCREMENT 16 /* how many statement holders to allocate diff --git a/connection.h b/connection.h index fc3560d..505325a 100644 --- a/connection.h +++ b/connection.h @@ -14,16 +14,6 @@ #include #include -#ifndef WIN32 -#include "iodbc.h" -#include "isql.h" -#include "isqlext.h" -#else -#include -#include -#include -#endif - typedef enum { diff --git a/convert.c b/convert.c index f39a34f..03d1b08 100644 --- a/convert.c +++ b/convert.c @@ -17,26 +17,16 @@ */ /* Multibyte support Eiji Tokuya 2001-03-15 */ +#include "convert.h" + #include #include #include -#include "psqlodbc.h" #ifdef MULTIBYTE #include "multibyte.h" #endif -#ifndef WIN32 -#include "iodbc.h" -#include "isql.h" -#include "isqlext.h" -#else -#include -#include -#include -#endif - -#include "convert.h" #include #include #include @@ -48,17 +38,6 @@ #include "connection.h" #include "pgapifunc.h" -#ifndef WIN32 -#ifndef HAVE_STRICMP -#define stricmp(s1,s2) strcasecmp(s1,s2) -#define strnicmp(s1,s2,n) strncasecmp(s1,s2,n) -#endif -#ifndef SCHAR -typedef signed char SCHAR; - -#endif -#endif - /* * How to map ODBC scalar functions {fn func(args)} to Postgres. diff --git a/dlg_specific.c b/dlg_specific.c index c02f633..e67a1dc 100644 --- a/dlg_specific.c +++ b/dlg_specific.c @@ -17,20 +17,8 @@ */ /* Multibyte support Eiji Tokuya 2001-03-15 */ -#include "psqlodbc.h" - -#ifndef WIN32 -#include -#include "gpps.h" -#define SQLGetPrivateProfileString(a,b,c,d,e,f) GetPrivateProfileString(a,b,c,d,e,f) -#define SQLWritePrivateProfileString(a,b,c,d) WritePrivateProfileString(a,b,c,d) -#ifndef HAVE_STRICMP -#define stricmp(s1,s2) strcasecmp(s1,s2) -#define strnicmp(s1,s2,n) strncasecmp(s1,s2,n) -#endif -#endif - #include "dlg_specific.h" + #include "convert.h" #ifdef MULTIBYTE diff --git a/dlg_specific.h b/dlg_specific.h index 6fc04ad..16a159c 100644 --- a/dlg_specific.h +++ b/dlg_specific.h @@ -13,9 +13,7 @@ #include "connection.h" #ifdef WIN32 -#include #include -#include #include "resource.h" #endif diff --git a/drvconn.c b/drvconn.c index 781bdd5..f2d5dab 100644 --- a/drvconn.c +++ b/drvconn.c @@ -25,18 +25,12 @@ #define NEAR #else #include -#include #endif #include -#ifndef WIN32 -#define stricmp(s1,s2) strcasecmp(s1,s2) -#define strnicmp(s1,s2,n) strncasecmp(s1,s2,n) -#else -#include +#ifdef WIN32 #include -#include #include "resource.h" #endif #include "pgapifunc.h" diff --git a/environ.h b/environ.h index 6d50fa6..7b463b3 100644 --- a/environ.h +++ b/environ.h @@ -11,16 +11,6 @@ #include "psqlodbc.h" -#ifndef WIN32 -#include "iodbc.h" -#include "isql.h" -#include "isqlext.h" -#else -#include -#include -#include -#endif - #define ENV_ALLOC_ERROR 1 /********** Environment Handle *************/ diff --git a/execute.c b/execute.c index d13a37e..9914079 100644 --- a/execute.c +++ b/execute.c @@ -14,17 +14,10 @@ */ #include "psqlodbc.h" + #include #include -#ifndef WIN32 -#include "iodbc.h" -#include "isqlext.h" -#else -#include -#include -#endif - #include "connection.h" #include "statement.h" #include "qresult.h" diff --git a/gpps.c b/gpps.c index 450f0b1..3f013bc 100644 --- a/gpps.c +++ b/gpps.c @@ -19,7 +19,7 @@ *------- */ -#ifndef WIN32 +#if !defined(WIN32) && !defined(WITH_UNIXODBC) && !defined(WITH_IODBC) #include "gpps.h" diff --git a/gpps.h b/gpps.h index c0b6a20..48b6722 100644 --- a/gpps.h +++ b/gpps.h @@ -8,9 +8,11 @@ #ifndef WIN32 #include -#include "iodbc.h" #endif +#define SQLGetPrivateProfileString(a,b,c,d,e,f) GetPrivateProfileString(a,b,c,d,e,f) +#define SQLWritePrivateProfileString(a,b,c,d) WritePrivateProfileString(a,b,c,d) + #ifdef __cplusplus extern "C" { diff --git a/info.c b/info.c index 6ff0d0b..5f4059b 100644 --- a/info.c +++ b/info.c @@ -22,16 +22,7 @@ #include #ifndef WIN32 -#include "iodbc.h" -#include "isql.h" -#include "isqlext.h" #include -#else -#include -#include -#include - -#include #endif #include "tuple.h" @@ -2060,7 +2051,7 @@ PGAPI_Statistics( char column_name[MAX_INFO_STRING], relhasrules[MAX_INFO_STRING]; char **column_names = 0; - Int4 column_name_len; + SQLINTEGER column_name_len; int total_columns = 0; char error = TRUE; ConnInfo *ci; diff --git a/lobj.c b/lobj.c index 16d592e..6b55b82 100644 --- a/lobj.c +++ b/lobj.c @@ -13,7 +13,7 @@ */ #include "lobj.h" -#include "psqlodbc.h" + #include "connection.h" diff --git a/misc.c b/misc.c index 87a4ee0..b17c45e 100644 --- a/misc.c +++ b/misc.c @@ -143,21 +143,6 @@ qlog(char *fmt,...) #endif -/* Undefine these because windows.h will redefine and cause a warning */ - -#ifdef WIN32 -#undef va_start -#undef va_end -#endif - -#ifndef WIN32 -#include "iodbc.h" -#include "isql.h" -#else -#include -#include -#endif - /* * returns STRCPY_FAIL, STRCPY_TRUNCATED, or #bytes copied diff --git a/misc.h b/misc.h index 016b4b7..5cedd4c 100644 --- a/misc.h +++ b/misc.h @@ -11,11 +11,6 @@ #include "psqlodbc.h" -#ifndef WIN32 -#include "gpps.h" -#define SQLGetPrivateProfileString(a,b,c,d,e,f) GetPrivateProfileString(a,b,c,d,e,f) -#endif - #include /* Uncomment MY_LOG define to compile in the mylog() statements. diff --git a/odbcapi.c b/odbcapi.c index dbb3142..9718aa9 100644 --- a/odbcapi.c +++ b/odbcapi.c @@ -34,13 +34,6 @@ #include #include -#ifndef WIN32 -#include "iodbc.h" -#include "isqlext.h" -#else -#include -#include -#endif #include "pgapifunc.h" #include "connection.h" #include "statement.h" diff --git a/odbcapi30.c b/odbcapi30.c index e657595..2468858 100644 --- a/odbcapi30.c +++ b/odbcapi30.c @@ -24,13 +24,6 @@ #include #include -#ifndef WIN32 -#include "iodbc.h" -#include "isqlext.h" -#else -#include -#include -#endif #include "environ.h" #include "connection.h" #include "statement.h" diff --git a/options.c b/options.c index a9a0a28..bc22118 100644 --- a/options.c +++ b/options.c @@ -16,16 +16,6 @@ #include "psqlodbc.h" #include -#ifndef WIN32 -#include "iodbc.h" -#include "isql.h" -#include "isqlext.h" -#else -#include -#include -#include -#endif - #include "environ.h" #include "connection.h" #include "statement.h" diff --git a/parse.c b/parse.c index 0f0aff6..4fa7fff 100644 --- a/parse.c +++ b/parse.c @@ -38,13 +38,6 @@ #include "multibyte.h" #endif -#ifndef WIN32 -#ifndef HAVE_STRICMP -#define stricmp(s1,s2) strcasecmp(s1,s2) -#define strnicmp(s1,s2,n) strncasecmp(s1,s2,n) -#endif -#endif - #define FLD_INCR 32 #define TAB_INCR 8 #define COL_INCR 16 diff --git a/pgapifunc.h b/pgapifunc.h index a4aca5f..72a5286 100644 --- a/pgapifunc.h +++ b/pgapifunc.h @@ -10,13 +10,6 @@ #include #include -#ifndef WIN32 -#include "iodbc.h" -#include "isqlext.h" -#else -#include -#include -#endif RETCODE SQL_API PGAPI_AllocConnect(HENV EnvironmentHandle, HDBC FAR *ConnectionHandle); diff --git a/pgtypes.c b/pgtypes.c index dd242d7..0af9653 100644 --- a/pgtypes.c +++ b/pgtypes.c @@ -23,16 +23,6 @@ #include "connection.h" #include "qresult.h" -#ifndef WIN32 -#include "iodbc.h" -#include "isql.h" -#include "isqlext.h" -#else -#include -#include -#include -#endif - Int4 getCharPrecision(StatementClass *stmt, Int4 type, int col, int handle_unknown_size_as); diff --git a/psqlodbc.c b/psqlodbc.c index ad15637..3c8ff2a 100644 --- a/psqlodbc.c +++ b/psqlodbc.c @@ -16,15 +16,8 @@ #include "psqlodbc.h" #include "dlg_specific.h" -#ifndef WIN32 -#include "iodbc.h" -#include "isql.h" -#include "isqlext.h" -#else +#ifdef WIN32 #include -#include -#include -#include #endif GLOBAL_VALUES globals; diff --git a/psqlodbc.h b/psqlodbc.h index 98fd472..94b9c76 100644 --- a/psqlodbc.h +++ b/psqlodbc.h @@ -5,26 +5,58 @@ * * Comments: See "notice.txt" for copyright and license information. * - * $Id: psqlodbc.h,v 1.48 2001/09/08 16:20:16 inoue Exp $ + * $Id: psqlodbc.h,v 1.49 2001/09/22 22:54:33 petere Exp $ * */ #ifndef __PSQLODBC_H__ #define __PSQLODBC_H__ -#ifdef HAVE_CONFIG_H +#ifndef WIN32 #include "pg_config.h" +#else +#include #endif #include /* for FILE* pointers: see GLOBAL_VALUES */ +/* Must come before sql.h */ +#define ODBCVER 0x0250 + + +#if defined(WIN32) || defined(WITH_UNIXODBC) || defined(WITH_IODBC) +#include +#include +#else +#include "iodbc.h" +#include "isql.h" +#include "isqlext.h" +#endif + +#if defined(WIN32) +#include +#elif defined(WITH_UNIXODBC) +#include +#elif defined(WITH_IODBC) +#include +#else +#include "gpps.h" +#endif + #ifndef WIN32 #define Int4 long int #define UInt4 unsigned int #define Int2 short #define UInt2 unsigned short + +#if !defined(WITH_UNIXODBC) && !defined(WITH_IODBC) typedef float SFLOAT; typedef double SDOUBLE; +#endif + +#ifndef CALLBACK +#define CALLBACK +#endif #else #define Int4 int @@ -35,8 +67,12 @@ typedef double SDOUBLE; typedef UInt4 Oid; +#ifndef WIN32 +#define stricmp strcasecmp +#define strnicmp strncasecmp +#endif + /* Driver stuff */ -#define ODBCVER 0x0250 #define DRIVER_ODBC_VER "02.50" #define DRIVERNAME "PostgreSQL ODBC" diff --git a/qresult.c b/qresult.c index 103b299..b3c8f6f 100644 --- a/qresult.c +++ b/qresult.c @@ -21,6 +21,7 @@ */ #include "qresult.h" + #include "misc.h" #include #include diff --git a/results.c b/results.c index 2475eee..c5652ff 100644 --- a/results.c +++ b/results.c @@ -29,13 +29,6 @@ #include -#ifndef WIN32 -#include "iodbc.h" -#include "isqlext.h" -#else -#include -#include -#endif #include "pgapifunc.h" diff --git a/setup.c b/setup.c index 65f3423..6b75840 100644 --- a/setup.c +++ b/setup.c @@ -14,10 +14,9 @@ */ #include "psqlodbc.h" + #include "connection.h" -#include #include -#include #include #include #include "resource.h" diff --git a/socket.c b/socket.c index fbfb5ca..28a7af2 100644 --- a/socket.c +++ b/socket.c @@ -13,6 +13,7 @@ */ #include "socket.h" + #include "connection.h" #ifndef WIN32 diff --git a/socket.h b/socket.h index f4c7b9e..b49bebe 100644 --- a/socket.h +++ b/socket.h @@ -36,8 +36,6 @@ typedef unsigned int in_addr_t; #define SOCKETFD SOCKET #endif -#include "psqlodbc.h" - #define SOCKET_ALREADY_CONNECTED 1 #define SOCKET_HOST_NOT_FOUND 2 #define SOCKET_COULD_NOT_CREATE_SOCKET 3 diff --git a/statement.c b/statement.c index 9efd4fb..ea296ea 100644 --- a/statement.c +++ b/statement.c @@ -13,6 +13,7 @@ */ #include "statement.h" + #include "bind.h" #include "connection.h" #include "qresult.h" @@ -23,22 +24,9 @@ #include #include -#ifndef WIN32 -#include "iodbc.h" -#include "isql.h" -#else -#include -#include -#endif #include "pgapifunc.h" -#ifndef WIN32 -#ifndef HAVE_STRICMP -#define stricmp(s1,s2) strcasecmp(s1,s2) -#define strnicmp(s1,s2,n) strncasecmp(s1,s2,n) -#endif -#endif #define PRN_NULLCHECK diff --git a/statement.h b/statement.h index 834eb00..c1a2152 100644 --- a/statement.h +++ b/statement.h @@ -10,15 +10,8 @@ #define __STATEMENT_H__ #include "psqlodbc.h" -#include "bind.h" -#ifndef WIN32 -#include "iodbc.h" -#include "isql.h" -#else -#include -#include -#endif +#include "bind.h" #ifndef FALSE diff --git a/tuple.c b/tuple.c index 658b7a7..512f36d 100644 --- a/tuple.c +++ b/tuple.c @@ -18,6 +18,7 @@ */ #include "tuple.h" + #include #include diff --git a/tuplelist.c b/tuplelist.c index 284ee8e..5f38716 100644 --- a/tuplelist.c +++ b/tuplelist.c @@ -14,6 +14,7 @@ */ #include "tuplelist.h" + #include #include "tuple.h" -- 2.39.5