Provide some initial support for building the ODBC driver for
authorPeter Eisentraut <peter_e@gmx.net>
Sat, 22 Sep 2001 22:54:33 +0000 (22:54 +0000)
committerPeter Eisentraut <peter_e@gmx.net>
Sat, 22 Sep 2001 22:54:33 +0000 (22:54 +0000)
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.

33 files changed:
GNUmakefile
bind.c
connection.c
connection.h
convert.c
dlg_specific.c
dlg_specific.h
drvconn.c
environ.h
execute.c
gpps.c
gpps.h
info.c
lobj.c
misc.c
misc.h
odbcapi.c
odbcapi30.c
options.c
parse.c
pgapifunc.h
pgtypes.c
psqlodbc.c
psqlodbc.h
qresult.c
results.c
setup.c
socket.c
socket.h
statement.c
statement.h
tuple.c
tuplelist.c

index 2d9a1e69808af65b818f702699f2a2227bb6639d..2f7d05afe588af297bb453cfb15ff61a120ca930 100644 (file)
@@ -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 ce1723654865d07fb70103c69ac7f0d4f22ce64b..062632df4800e1a2955d0ef7f4b58dd4fa166377 100644 (file)
--- a/bind.c
+++ b/bind.c
 #include <stdlib.h>
 #include <string.h>
 
-#ifndef WIN32
-#include "iodbc.h"
-#include "isql.h"
-#include "isqlext.h"
-#else
-#include "sql.h"
-#include "sqlext.h"
-#endif
 #include "pgapifunc.h"
 
 
index 7dc3fde0b259c04a9a2e8bd0377b605873a10a8e..70c7b782309fe452fc0a6d4c0195c343ccba6d9e 100644 (file)
  */
 /* Multibyte support   Eiji Tokuya 2001-03-15 */
 
+#include "connection.h"
+
 #include <stdio.h>
 #include <string.h>
 #include <ctype.h>
 
-#include "connection.h"
-
 #include "environ.h"
 #include "socket.h"
 #include "statement.h"
@@ -31,9 +31,6 @@
 #include "multibyte.h"
 #endif
 
-#ifdef WIN32
-#include <odbcinst.h>
-#endif
 #include "pgapifunc.h"
 
 #define STMT_INCREMENT 16      /* how many statement holders to allocate
index fc3560d35225b6264ff7d255476361a090677fab..505325ad68291e09965c3d7277b79be925c39ea1 100644 (file)
 #include <stdlib.h>
 #include <string.h>
 
-#ifndef WIN32
-#include "iodbc.h"
-#include "isql.h"
-#include "isqlext.h"
-#else
-#include <windows.h>
-#include <sql.h>
-#include <sqlext.h>
-#endif
-
 
 typedef enum
 {
index f39a34f4c159b8a45a9f41f71a6b9cbdb3964670..03d1b0817bcac83f1e9525b60e803dd498d08bdd 100644 (file)
--- a/convert.c
+++ b/convert.c
  */
 /* Multibyte support  Eiji Tokuya  2001-03-15  */
 
+#include "convert.h"
+
 #include <stdio.h>
 #include <string.h>
 #include <ctype.h>
 
-#include "psqlodbc.h"
 #ifdef MULTIBYTE
 #include "multibyte.h"
 #endif
 
-#ifndef WIN32
-#include "iodbc.h"
-#include "isql.h"
-#include "isqlext.h"
-#else
-#include <windows.h>
-#include <sql.h>
-#include <sqlext.h>
-#endif
-
-#include "convert.h"
 #include <time.h>
 #include <math.h>
 #include <stdlib.h>
 #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.
index c02f633fdb3dec8c78415f1ac7b9bb413902c88b..e67a1dc020d329ac95c3f08f6182f9432358592d 100644 (file)
  */
 /* Multibyte support   Eiji Tokuya 2001-03-15 */
 
-#include "psqlodbc.h"
-
-#ifndef WIN32
-#include <string.h>
-#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
index 6fc04ad2fb966b8b1ab8a955bf535767d1e8923b..16a159c3d1a4e363f5af6311882cb38116768479 100644 (file)
@@ -13,9 +13,7 @@
 #include "connection.h"
 
 #ifdef WIN32
-#include  <windows.h>
 #include  <windowsx.h>
-#include  <odbcinst.h>
 #include "resource.h"
 #endif
 
index 781bdd54903eb16f4175912a944d9757dc3f5006..f2d5dab08c7a229f1097ba230417a1e5da83fa7a 100644 (file)
--- a/drvconn.c
+++ b/drvconn.c
 #define NEAR
 #else
 #include <winsock.h>
-#include <sqlext.h>
 #endif
 
 #include <string.h>
 
-#ifndef WIN32
-#define stricmp(s1,s2) strcasecmp(s1,s2)
-#define strnicmp(s1,s2,n)  strncasecmp(s1,s2,n)
-#else
-#include <windows.h>
+#ifdef WIN32
 #include <windowsx.h>
-#include <odbcinst.h>
 #include "resource.h"
 #endif
 #include "pgapifunc.h"
index 6d50fa6b48f89fe9dc97aeedb53e14c630189302..7b463b3e744e093804077c400062d2ed2e61e4c3 100644 (file)
--- a/environ.h
+++ b/environ.h
 
 #include "psqlodbc.h"
 
-#ifndef WIN32
-#include "iodbc.h"
-#include "isql.h"
-#include "isqlext.h"
-#else
-#include <windows.h>
-#include <sql.h>
-#include <sqlext.h>
-#endif
-
 #define ENV_ALLOC_ERROR 1
 
 /**********        Environment Handle  *************/
index d13a37e8effdacbabd9928232d8cafee1233cd53..991407975e7b90713893621505a3360a9fb1ccf9 100644 (file)
--- a/execute.c
+++ b/execute.c
  */
 
 #include "psqlodbc.h"
+
 #include <stdio.h>
 #include <string.h>
 
-#ifndef WIN32
-#include "iodbc.h"
-#include "isqlext.h"
-#else
-#include <windows.h>
-#include <sqlext.h>
-#endif
-
 #include "connection.h"
 #include "statement.h"
 #include "qresult.h"
diff --git a/gpps.c b/gpps.c
index 450f0b1e505925d1b1ab48d78fbfc50292d614b5..3f013bc5d2efd03862dfd9912ed3d2f106ef87f9 100644 (file)
--- 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 c0b6a20796c083ab85e60b3ce2d9a8ceefaba2c1..48b6722573db208195341eb8acf85bae8eaac5b2 100644 (file)
--- a/gpps.h
+++ b/gpps.h
@@ -8,9 +8,11 @@
 
 #ifndef WIN32
 #include <sys/types.h>
-#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 6ff0d0b12e47482a5a67dd5a5cd4a88845771a09..5f4059bd2d8a573f7ee7a195af2136a2bd07cd8d 100644 (file)
--- a/info.c
+++ b/info.c
 #include <stdio.h>
 
 #ifndef WIN32
-#include "iodbc.h"
-#include "isql.h"
-#include "isqlext.h"
 #include <ctype.h>
-#else
-#include <windows.h>
-#include <sql.h>
-#include <sqlext.h>
-
-#include <odbcinst.h>
 #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 16d592eafd229e3a4238f9ec1d3164eafad4db01..6b55b82d54e5632edb1b3bcbb2c79728888cb23d 100644 (file)
--- 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 87a4ee01ff501d2dd989dfc748ca85365dc1733d..b17c45e311063e3f2d4f0ce6387592740d47b369 100644 (file)
--- 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 <windows.h>
-#include <sql.h>
-#endif
-
 
 /*
  * returns STRCPY_FAIL, STRCPY_TRUNCATED, or #bytes copied
diff --git a/misc.h b/misc.h
index 016b4b7a5e91ce41b6abb3c22d14472fd0d0bf87..5cedd4c147e8daeb5172b8548a4b0a059c4de95d 100644 (file)
--- a/misc.h
+++ b/misc.h
 
 #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 <stdio.h>
 
 /* Uncomment MY_LOG define to compile in the mylog() statements.
index dbb3142401f0acedbd71aa667e0308282c8571a2..9718aa9ff3a030d2f94517b67089675ef9950e43 100644 (file)
--- a/odbcapi.c
+++ b/odbcapi.c
 #include <stdio.h>
 #include <string.h>
 
-#ifndef WIN32
-#include "iodbc.h"
-#include "isqlext.h"
-#else
-#include <windows.h>
-#include <sqlext.h>
-#endif
 #include "pgapifunc.h"
 #include "connection.h"
 #include "statement.h"
index e657595c031038806de17eebbdaf8c4946beb369..24688583efd1035de2c8388dd08e45fbe5088bcd 100644 (file)
 #include <stdio.h>
 #include <string.h>
 
-#ifndef WIN32
-#include "iodbc.h"
-#include "isqlext.h"
-#else
-#include <windows.h>
-#include <sqlext.h>
-#endif
 #include "environ.h"
 #include "connection.h"
 #include "statement.h"
index a9a0a287fbd350046bf3a3a436de7a5ee2db97c8..bc221186baa921e74de9264ce8656ba199ab0ba6 100644 (file)
--- a/options.c
+++ b/options.c
 #include "psqlodbc.h"
 #include <string.h>
 
-#ifndef WIN32
-#include "iodbc.h"
-#include "isql.h"
-#include "isqlext.h"
-#else
-#include <windows.h>
-#include <sql.h>
-#include <sqlext.h>
-#endif
-
 #include "environ.h"
 #include "connection.h"
 #include "statement.h"
diff --git a/parse.c b/parse.c
index 0f0aff6e04e9988cfbf154140bca1cb03f76b0c9..4fa7fffea5e06cb690021c72afbbab0ef49fa302 100644 (file)
--- a/parse.c
+++ b/parse.c
 #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
index a4aca5f323d4d129de58caf53e978400c14fcf0c..72a5286e9f476499657a2c5e4cee6ab99403405f 100644 (file)
 #include <stdio.h>
 #include <string.h>
 
-#ifndef WIN32
-#include "iodbc.h"
-#include "isqlext.h"
-#else
-#include <windows.h>
-#include <sqlext.h>
-#endif
 
 RETCODE  SQL_API PGAPI_AllocConnect(HENV EnvironmentHandle,
            HDBC FAR *ConnectionHandle);
index dd242d7bdcdc13a228a8739f4294169a9461824d..0af96536e8fc4f44a44e588655a0677977ddd24b 100644 (file)
--- a/pgtypes.c
+++ b/pgtypes.c
 #include "connection.h"
 #include "qresult.h"
 
-#ifndef WIN32
-#include "iodbc.h"
-#include "isql.h"
-#include "isqlext.h"
-#else
-#include <windows.h>
-#include <sql.h>
-#include <sqlext.h>
-#endif
-
 
 
 Int4       getCharPrecision(StatementClass *stmt, Int4 type, int col, int handle_unknown_size_as);
index ad156379d0a105bb4cf960d2b45b7b0633fb9092..3c8ff2a53fff0d0c2db417cb5e9cc7755e2bcabb 100644 (file)
 #include "psqlodbc.h"
 #include "dlg_specific.h"
 
-#ifndef WIN32
-#include "iodbc.h"
-#include "isql.h"
-#include "isqlext.h"
-#else
+#ifdef WIN32
 #include <winsock.h>
-#include <windows.h>
-#include <sql.h>
-#include <odbcinst.h>
 #endif
 
 GLOBAL_VALUES globals;
index 98fd47205f9cd96c470fd92373369d0933c9ae68..94b9c76701ebd29c36788983620498edfa64e45f 100644 (file)
@@ -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 <windows.h>
 #endif
 
 #include <stdio.h>             /* for FILE* pointers: see GLOBAL_VALUES */
 
+/* Must come before sql.h */
+#define ODBCVER                        0x0250
+
+
+#if defined(WIN32) || defined(WITH_UNIXODBC) || defined(WITH_IODBC)
+#include <sql.h>
+#include <sqlext.h>
+#else
+#include "iodbc.h"
+#include "isql.h"
+#include "isqlext.h"
+#endif
+
+#if defined(WIN32)
+#include <odbcinst.h>
+#elif defined(WITH_UNIXODBC)
+#include <odbcinst.h>
+#elif defined(WITH_IODBC)
+#include <iodbcinst.h>
+#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"
index 103b299ed36f581225a89a8ecf22d8cf84f74d93..b3c8f6fcc097182848acdd2ccd5f67589bc2fbf2 100644 (file)
--- a/qresult.c
+++ b/qresult.c
@@ -21,6 +21,7 @@
  */
 
 #include "qresult.h"
+
 #include "misc.h"
 #include <stdio.h>
 #include <string.h>
index 2475eeef9e3b0be7632a7487f743adb61de02f82..c5652ff984d1ea40fa38c45e14f2d14ae7e74245 100644 (file)
--- a/results.c
+++ b/results.c
 
 #include <stdio.h>
 
-#ifndef WIN32
-#include "iodbc.h"
-#include "isqlext.h"
-#else
-#include <windows.h>
-#include <sqlext.h>
-#endif
 #include "pgapifunc.h"
 
 
diff --git a/setup.c b/setup.c
index 65f3423cf15916af1da990573787022049e9d8ce..6b75840d98e7a8045b0d1e39e1e65c2aa3e7453b 100644 (file)
--- a/setup.c
+++ b/setup.c
  */
 
 #include  "psqlodbc.h"
+
 #include  "connection.h"
-#include  <windows.h>
 #include  <windowsx.h>
-#include  <odbcinst.h>
 #include  <string.h>
 #include  <stdlib.h>
 #include  "resource.h"
index fbfb5ca929797a77be1d456f4339da165cbfd388..28a7af22bb54fb686e12a14042feaab52c47c03f 100644 (file)
--- a/socket.c
+++ b/socket.c
@@ -13,6 +13,7 @@
  */
 
 #include "socket.h"
+
 #include "connection.h"
 
 #ifndef WIN32
index f4c7b9e4e43bd93dc976b51080fd9e8c915930f0..b49bebea9bb2d7dac7ad14ea32da368f23af4d89 100644 (file)
--- 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
index 9efd4fb52c8fff9a3a00faf6dcbad1db3a1baf4e..ea296ea7b3a364b2e35206d999e67622a1b0753e 100644 (file)
@@ -13,6 +13,7 @@
  */
 
 #include "statement.h"
+
 #include "bind.h"
 #include "connection.h"
 #include "qresult.h"
 #include <string.h>
 #include <ctype.h>
 
-#ifndef WIN32
-#include "iodbc.h"
-#include "isql.h"
-#else
-#include <windows.h>
-#include <sql.h>
-#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
 
 
index 834eb005b3d6e6be793fd8ce9ccd245cc7a2aa1c..c1a2152b0c05d1ef84fc81ab68de9ffca3d018bf 100644 (file)
 #define __STATEMENT_H__
 
 #include "psqlodbc.h"
-#include "bind.h"
 
-#ifndef WIN32
-#include "iodbc.h"
-#include "isql.h"
-#else
-#include <windows.h>
-#include <sql.h>
-#endif
+#include "bind.h"
 
 
 #ifndef FALSE
diff --git a/tuple.c b/tuple.c
index 658b7a75ec7d963c21e57b9cb5af5184d4ed2f0d..512f36d2b23de4fdd2b607d67bf130a0a583b56c 100644 (file)
--- a/tuple.c
+++ b/tuple.c
@@ -18,6 +18,7 @@
  */
 
 #include "tuple.h"
+
 #include <string.h>
 #include <stdlib.h>
 
index 284ee8ed440002d287aa8a0aca3eecf769a10df9..5f3871600d63a53c6bd902abbed2e88d2b206606 100644 (file)
@@ -14,6 +14,7 @@
  */
 
 #include "tuplelist.h"
+
 #include <stdlib.h>
 #include "tuple.h"