Remove traces of code that tries to compile on Unix without a driver manager.
authorPeter Eisentraut <[email protected]>
Sat, 10 Jul 2004 22:26:27 +0000 (22:26 +0000)
committerPeter Eisentraut <[email protected]>
Sat, 10 Jul 2004 22:26:27 +0000 (22:26 +0000)
Look automatically for a driver manager if none is requested explicitly.

Makefile.am
configure.ac
gpps.c [deleted file]
gpps.h [deleted file]
psqlodbc.h

index a3b0b4b771bbe5aa93c6f2943289b4ba8817444d..77facdb8da49b21ef5eb103fabd53f93891329f0 100644 (file)
@@ -2,7 +2,7 @@
 #
 # Makefile.am for psqlodbc (PostgreSQL ODBC driver)
 #
-# $Header: /home/heikki/psqlodbc-cvs-copy/psqlodbc/Makefile.am,v 1.12 2004/07/05 09:55:16 dpage Exp $
+# $Header: /home/heikki/psqlodbc-cvs-copy/psqlodbc/Makefile.am,v 1.13 2004/07/10 22:26:26 petere Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -18,11 +18,11 @@ psqlodbc_la_SOURCES = \
    pgtypes.c psqlodbc.c qresult.c results.c socket.c parse.c \
    statement.c tuple.c tuplelist.c dlg_specific.c odbcapi.c \
    multibyte.c \
-   gpps.c odbcapi30.c pgapi30.c info30.c descriptor.c
+   odbcapi30.c pgapi30.c info30.c descriptor.c
 
 psqlodbc_la_SOURCES += \
    bind.h columninfo.h connection.h convert.h descriptor.h \
-   dlg_specific.h environ.h gpps.h \
+   dlg_specific.h environ.h \
    lobj.h md5.h misc.h multibyte.h pgapifunc.h pgtypes.h \
    psqlodbc.h qresult.h resource.h socket.h statement.h tuple.h \
    tuplelist.h version.h
@@ -34,16 +34,6 @@ endif
 
 EXTRA_psqlodbc_la_SOURCES = md5.c
 
-if with_unixodbc
-psqlodbc_la_LIBADD = -lodbcinst
-else
-if with_iodbc
-psqlodbc_la_LIBADD = -liodbcinst
-else
-AM_CPPFLAGS = -DODBCINSTDIR='"$(odbcinst_ini_dir)"'
-endif
-endif
-
 dist_pkgdata_DATA = odbc.sql odbc-drop.sql
 BUILT_SOURCES = odbc-drop.sql
 
index 6fa7a4399dc0ab8be4fbc17a2496ff9e168419ca..1a9f4159a5f8facfe4874fefe1d7abb96fe6b001 100644 (file)
@@ -10,21 +10,41 @@ AM_MAINTAINER_MODE
 AC_DEFINE(DRIVER_CURSOR_IMPLEMENT, 1,
    [Define to 1 to build with driver cursors option)])
 
+#
+# Decide which ODBC driver manager to use
+#
 PGAC_ARG_BOOL(with, unixodbc, no,
-              [  --with-unixodbc         build ODBC driver for unixODBC],
-              [AC_DEFINE(WITH_UNIXODBC, 1,
-                         [Define to 1 to build with unixODBC support (--with-unixodbc)])
-               AC_DEFINE(SQL_WCHART_CONVERT, [], [Define to use wchar_t as SQLWCHAR in unixODBC])])
+              [  --with-unixodbc         build ODBC driver for unixODBC (default)],
+              [AC_CHECK_LIB(odbcinst, SQLGetPrivateProfileString, [],
+                            [AC_MSG_ERROR([unixODBC driver manager not found])])])
 
 PGAC_ARG_BOOL(with, iodbc, no,
               [  --with-iodbc            build ODBC driver for iODBC],
-              [AC_DEFINE(WITH_IODBC, 1,
-                         [Define to 1 to build with iODBC support (--with-iodbc)])])
+              [AC_CHECK_LIB(iodbcinst, SQLGetPrivateProfileString, [],
+                            [AC_MSG_ERROR([iODBC driver manager not found])])])
 
 if test "$with_unixodbc" = yes && test "$with_iodbc" = yes; then
   AC_MSG_ERROR([ODBC driver cannot be built for both unixODBC and iODBC])
 fi
 
+if test "$with_unixodbc" != yes && test "$with_iodbc" != yes; then
+  AC_CHECK_LIB(odbcinst, SQLGetPrivateProfileString,
+               [with_unixodbc=yes],
+               [AC_CHECK_LIB(iodbcinst, SQLGetPrivateProfileString,
+                             [with_iodbc=yes],
+                             [AC_MSG_ERROR([no suitable ODBC driver manager found])])])
+fi
+
+if test "$with_unixodbc" = yes; then
+  AC_DEFINE(WITH_UNIXODBC, 1, [Define to 1 to build with unixODBC support])
+  AC_DEFINE(SQL_WCHART_CONVERT, [], [Define to use wchar_t as SQLWCHAR in unixODBC])
+fi
+
+if test "$with_iodbc" = yes; then
+  AC_DEFINE(WITH_IODBC, 1, [Define to 1 to build with iODBC support])
+fi
+
+
 #
 # Default odbc version number (--with-odbcver), default 0x0300
 #
@@ -46,8 +66,6 @@ AC_ARG_ENABLE(unicode,
                          [Define to disable mapping SQL* to SQL*W])
                AC_CHECK_FUNCS(iswascii)])
 
-AM_CONDITIONAL(with_unixodbc, [test $with_unixodbc = yes])
-AM_CONDITIONAL(with_iodbc, [test $with_iodbc = yes])
 AM_CONDITIONAL(enable_unicode, [test x"$enable_unicode" = xyes])
 
 AC_CHECK_FUNCS(strtoul strtoll)
diff --git a/gpps.c b/gpps.c
deleted file mode 100644 (file)
index c4351bc..0000000
--- a/gpps.c
+++ /dev/null
@@ -1,452 +0,0 @@
-/*-------
- * GetPrivateProfileString()
- *
- * approximate implementation of
- * Windows NT System Services version of GetPrivateProfileString()
- * probably doesn't handle the NULL key for section name or value key
- * correctly also, doesn't provide Microsoft backwards compatability
- * wrt TAB characters in the value string
- *
- * Microsoft terminates value
- * at the first TAB, but I couldn't discover what the behavior should
- * be regarding TABS in quoted strings so, I treat tabs like any other
- * characters
- *
- * NO comments following value string separated by a TAB
- * are allowed (that is an anachronism anyway)
- * Added code to search for ODBC_INI file in users home directory on
- * Unix
- *-------
- */
-
-#include "config.h"
-#if !defined(WIN32) && !defined(WITH_UNIXODBC) && !defined(WITH_IODBC)
-
-#include "gpps.h"
-
-#include <stdio.h>
-#include <unistd.h>
-#include <ctype.h>
-#include <pwd.h>
-
-#include <sys/types.h>
-#include <string.h>
-#include "misc.h"
-#include "dlg_specific.h"
-
-#ifndef TRUE
-#define TRUE   ((BOOL)1)
-#endif
-#ifndef FALSE
-#define FALSE  ((BOOL)0)
-#endif
-
-#ifndef ODBCINSTDIR
-#error "ODBCINSTDIR must be defined to compile this file"
-#endif
-
-
-/*
- * theIniFileName is searched for in:
- * $HOME/theIniFileName
- * theIniFileName
- * ODBCINSTDIR/ODBCINST_INI
- */
-DWORD
-GetPrivateProfileString(const char *theSection, /* section name */
-                       const char *theKey,     /* search key name */
-                       const char *theDefault, /* default value if not
-                                                * found */
-                       char *theReturnBuffer,  /* return value stored
-                                                * here */
-                       size_t theReturnBufferLength,   /* byte length of return
-                                                        * buffer */
-                       const char *theIniFileName)     /* pathname of ini file
-                                                        * to search */
-{
-   char        buf[MAXPGPATH];
-   char       *ptr = 0;
-   FILE       *aFile = 0;
-   size_t      aLength;
-   char        aLine[2048];
-   char       *aValue;
-   char       *aStart;
-   char       *aString;
-   size_t      aLineLength;
-   size_t      aReturnLength = 0;
-   BOOL        aSectionFound = FALSE;
-   BOOL        aKeyFound = FALSE;
-
-   ptr = (char *) getpwuid(getuid());  /* get user info */
-
-   if (ptr == NULL || (((struct passwd *) ptr)->pw_dir) == NULL || *(((struct passwd *) ptr)->pw_dir) == '\0')
-       ptr = "/home";
-   else
-       ptr = ((struct passwd *) ptr)->pw_dir;  /* get user home dir */
-
-   /*
-    * If it can't be opened because the paths are too long, then skip it,
-    * don't just truncate the path string...  The truncated path might
-    * accidently be an existing file.  The default value will be returned
-    * instead.
-    */
-   if (MAXPGPATH - 1 >= strlen(ptr) + 1 + strlen(theIniFileName))
-   {
-       sprintf(buf, "%s/%s", ptr, theIniFileName);
-       aFile = (FILE *) fopen(buf, PG_BINARY_R);
-   }
-
-   /*
-    * This code makes it so that a file in the users home dir overrides a
-    * the "default" file as passed in
-    */
-   if (!aFile)
-   {
-       aFile = (FILE *) fopen(theIniFileName, PG_BINARY_R);
-       if (!aFile)
-           aFile = (FILE *) fopen(ODBCINSTDIR "/" ODBCINST_INI, PG_BINARY_R);
-   }
-
-   aLength = (theDefault == NULL) ? 0 : strlen(theDefault);
-
-   if (theReturnBufferLength == 0 || theReturnBuffer == NULL)
-   {
-       if (aFile)
-           fclose(aFile);
-       return 0;
-   }
-
-   if (aFile == NULL)
-   {
-       /* no ini file specified, return the default */
-       ++aLength;              /* room for NULL char */
-       aLength = theReturnBufferLength < aLength ?
-           theReturnBufferLength : aLength;
-       strncpy(theReturnBuffer, theDefault, aLength);
-       theReturnBuffer[aLength - 1] = '\0';
-       return aLength - 1;
-   }
-
-   while (fgets(aLine, sizeof(aLine), aFile) != NULL)
-   {
-       aLineLength = strlen(aLine);
-       /* strip final '\n' */
-       if (aLineLength > 0 && aLine[aLineLength - 1] == '\n')
-           aLine[aLineLength - 1] = '\0';
-       switch (*aLine)
-       {
-           case ' ':           /* blank line */
-           case ';':           /* comment line */
-               continue;
-               break;
-
-           case '[':           /* section marker */
-               if ((aString = strchr(aLine, ']')))
-               {
-                   aStart = aLine + 1;
-                   aString--;
-                   while (isspace((unsigned char) *aStart))
-                       aStart++;
-                   while (isspace((unsigned char) *aString))
-                       aString--;
-                   *(aString + 1) = '\0';
-
-                   /* accept as matched if NULL key or exact match */
-                   if (!theSection || !strcmp(aStart, theSection))
-                       aSectionFound = TRUE;
-                   else
-                       aSectionFound = FALSE;
-               }
-               break;
-
-           default:
-
-               /* try to match value keys if in proper section */
-               if (aSectionFound)
-               {
-                   /* try to match requested key */
-                   if ((aString = aValue = strchr(aLine, '=')))
-                   {
-                       *aValue = '\0';
-                       ++aValue;
-
-                       /* strip leading blanks in value field */
-                       while (*aValue == ' ' && aValue < aLine + sizeof(aLine))
-                           *aValue++ = '\0';
-                       if (aValue >= aLine + sizeof(aLine))
-                           aValue = "";
-                   }
-                   else
-                       aValue = "";
-
-                   aStart = aLine;
-                   while (isspace((unsigned char) *aStart))
-                       aStart++;
-
-                   /* strip trailing blanks from key */
-                   if (aString)
-                   {
-                       while (--aString >= aStart && *aString == ' ')
-                           *aString = '\0';
-                   }
-
-                   /* see if key is matched */
-                   if (theKey == NULL || !strcmp(theKey, aStart))
-                   {
-                       /* matched -- first, terminate value part */
-                       aKeyFound = TRUE;
-                       aLength = strlen(aValue);
-
-                       /* remove trailing blanks from aValue if any */
-                       aString = aValue + aLength - 1;
-
-                       while (--aString > aValue && *aString == ' ')
-                       {
-                           *aString = '\0';
-                           --aLength;
-                       }
-
-                       /* unquote value if quoted */
-                       if (aLength >= 2 && aValue[0] == '"' &&
-                           aValue[aLength - 1] == '"')
-                       {
-                           /* string quoted with double quotes */
-
-                           aValue[aLength - 1] = '\0';
-                           ++aValue;
-                           aLength -= 2;
-                       }
-                       else
-                       {
-                           /* single quotes allowed also... */
-                           if (aLength >= 2 && aValue[0] == '\'' &&
-                               aValue[aLength - 1] == '\'')
-                           {
-                               aValue[aLength - 1] = '\0';
-                               ++aValue;
-                               aLength -= 2;
-                           }
-                       }
-
-                       /* compute maximum length copyable */
-                       aLineLength = (aLength <
-                       theReturnBufferLength - aReturnLength) ? aLength :
-                           theReturnBufferLength - aReturnLength;
-
-                       /* do the copy to return buffer */
-                       if (aLineLength)
-                       {
-                           strncpy(&theReturnBuffer[aReturnLength],
-                                   aValue, aLineLength);
-                           aReturnLength += aLineLength;
-                           if (aReturnLength < theReturnBufferLength)
-                           {
-                               theReturnBuffer[aReturnLength] = '\0';
-                               ++aReturnLength;
-                           }
-                       }
-                       if (aFile)
-                       {
-                           fclose(aFile);
-                           aFile = NULL;
-                       }
-                       return aReturnLength > 0 ? aReturnLength - 1 : 0;
-                   }
-               }
-               break;
-       }
-   }
-
-   if (aFile)
-       fclose(aFile);
-
-   if (!aKeyFound)
-   {
-       /* key wasn't found return default */
-       ++aLength;              /* room for NULL char */
-       aLength = theReturnBufferLength < aLength ?
-           theReturnBufferLength : aLength;
-       strncpy(theReturnBuffer, theDefault, aLength);
-       theReturnBuffer[aLength - 1] = '\0';
-       aReturnLength = aLength - 1;
-   }
-   return aReturnLength > 0 ? aReturnLength - 1 : 0;
-}
-
-
-DWORD
-WritePrivateProfileString(const char *theSection,      /* section name */
-                         const char *theKey,   /* write key name */
-                         const char *theBuffer,        /* input buffer */
-                         const char *theIniFileName)   /* pathname of ini file
-                                                        * to write */
-{
-   return 0;
-}
-
-
-#if NOT_USED
-/*
- * Ok. What the hell's the default behaviour for a null input buffer, and null
- * section name. For now if either are null I ignore the request, until
- * I find out different.
- */
-DWORD
-WritePrivateProfileString(char *theSection,        /* section name */
-                         char *theKey, /* write key name */
-                         char *theBuffer,      /* input buffer */
-                         char *theIniFileName) /* pathname of ini file to
-                                                * write */
-{
-   char        buf[MAXPGPATH];
-   char       *ptr = 0;
-   FILE       *aFile = 0;
-   size_t      aLength;
-   char        aLine[2048];
-   char       *aValue;
-   char       *aString;
-   size_t      aLineLength;
-   size_t      aReturnLength = 0;
-
-   BOOL        aSectionFound = FALSE;
-   BOOL        keyFound = FALSE;
-   int         j = 0;
-
-   /* If this isn't correct processing we'll change it later  */
-   if (theSection == NULL || theKey == NULL || theBuffer == NULL ||
-       theIniFileName == NULL)
-       return 0;
-
-   aLength = strlen(theBuffer);
-   if (aLength == 0)
-       return 0;
-
-   j = strlen(theIniFileName) + 1;
-   ptr = (char *) getpwuid(getuid());  /* get user info */
-
-   if (ptr == NULL)
-   {
-       if (MAXPGPATH - 1 < j)
-           theIniFileName[MAXPGPATH - 1] = '\0';
-
-       sprintf(buf, "%s", theIniFileName);
-   }
-   ptr = ((struct passwd *) ptr)->pw_dir;      /* get user home dir */
-   if (ptr == NULL || *ptr == '\0')
-       ptr = "/home";
-
-   /*
-    * This doesn't make it so we find an ini file but allows normal
-    * processing to continue further on down. The likelihood is that the
-    * file won't be found and thus the default value will be returned.
-    */
-   if (MAXPGPATH - 1 < strlen(ptr) + j)
-   {
-       if (MAXPGPATH - 1 < strlen(ptr))
-           ptr[MAXPGPATH - 1] = '\0';
-       else
-           theIniFileName[MAXPGPATH - 1 - strlen(ptr)] = '\0';
-   }
-
-   sprintf(buf, "%s/%s", ptr, theIniFileName);
-
-   /*
-    * This code makes it so that a file in the users home dir overrides a
-    * the "default" file as passed in
-    */
-   aFile = (FILE *) (buf ? fopen(buf, "r+") : NULL);
-   if (!aFile)
-   {
-       sprintf(buf, "%s", theIniFileName);
-       aFile = (FILE *) (buf ? fopen(buf, "r+") : NULL);
-       if (!aFile)
-           return 0;
-   }
-
-   aLength = strlen(theBuffer);
-
-   /*
-    * We have to search for theKey, because if it already exists we have
-    * to overwrite it. If it doesn't exist we just write a new line to
-    * the file.
-    */
-   while (fgets(aLine, sizeof(aLine), aFile) != NULL)
-   {
-       aLineLength = strlen(aLine);
-       /* strip final '\n' */
-       if (aLineLength > 0 && aLine[aLineLength - 1] == '\n')
-           aLine[aLineLength - 1] = '\0';
-       switch (*aLine)
-       {
-           case ' ':           /* blank line */
-           case ';':           /* comment line */
-               continue;
-               break;
-
-           case '[':           /* section marker */
-               if ((aString = strchr(aLine, ']')))
-               {
-                   *aString = '\0';
-
-                   /* accept as matched if key exact match */
-
-                   if (!strcmp(aLine + 1, theSection))
-                       aSectionFound = TRUE;
-               }
-               break;
-
-           default:
-               /* try to match value keys if in proper section */
-               if (aSectionFound)
-               {
-                   /* try to match requested key */
-
-                   if ((aString = aValue = strchr(aLine, '=')))
-                   {
-                       *aValue = '\0';
-                       ++aValue;
-
-                       /* strip leading blanks in value field */
-                       while (*aValue == ' ' && aValue < aLine + sizeof(aLine))
-                           *aValue++ = '\0';
-                       if (aValue >= aLine + sizeof(aLine))
-                           aValue = "";
-                   }
-                   else
-                       aValue = "";
-
-                   /* strip trailing blanks from key */
-                   if (aString)
-                   {
-                       while (--aString >= aLine && *aString == ' ')
-                           *aString = '\0';
-                   }
-
-                   /* see if key is matched */
-                   if (!strcmp(theKey, aLine))
-                   {
-                       keyFound = TRUE;
-                       /* matched -- first, terminate value part */
-
-                       /* overwrite current value */
-                       fseek(aFile, -aLineLength, SEEK_CUR);
-                       /* overwrite key and value */
-                       sprintf(aLine, "%s = %s\n", theKey, theBuffer);
-                       fputs(aLine, aFile);
-                   }
-               }
-       }
-       break;
-   }
-}
-
-if (!keyFound)
-{                              /* theKey wasn't in file so  */
-   if (aFile)
-       fclose(aFile);
-
-   return aReturnLength > 0 ? aReturnLength - 1 : 0;
-}
-#endif   /* NOT_USED */
-
-#endif   /* not WIN32 */
diff --git a/gpps.h b/gpps.h
deleted file mode 100644 (file)
index ab133a8..0000000
--- a/gpps.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/* GetPrivateProfileString
- * for UNIX use
- */
-#ifndef GPPS_H
-#define GPPS_H
-
-#include "psqlodbc.h"
-
-#ifndef WIN32
-#include <sys/types.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"
-{
-#endif
-
-DWORD
-GetPrivateProfileString(const char *theSection, /* section name */
-                       const char *theKey,     /* search key name */
-                       const char *theDefault, /* default value if not
-                                                * found */
-                       char *theReturnBuffer,  /* return valuse stored
-                                                * here */
-                       size_t theBufferLength, /* byte length of return
-                                                * buffer */
-                       const char *theIniFileName);    /* pathname of ini file
-                                                        * to search */
-
-DWORD
-WritePrivateProfileString(const char *theSection,      /* section name */
-                         const char *theKey,   /* write key name */
-                         const char *theBuffer,        /* input buffer */
-                         const char *theIniFileName);  /* pathname of ini file
-                                                        * to write */
-
-#ifdef __cplusplus
-}
-#endif
-
-#ifndef WIN32
-#undef DWORD
-#endif
-
-#endif
index 1424e13d38c98d7b904ff08e229ffdd3ce1ca301..aa65e96ad4029ae207c2cf9bea0d2a90911247ad 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Comments:       See "notice.txt" for copyright and license information.
  *
- * $Id: psqlodbc.h,v 1.83 2004/07/01 09:20:56 dpage Exp $
+ * $Id: psqlodbc.h,v 1.84 2004/07/10 22:26:27 petere Exp $
  *
  */
 
 #ifndef    WIN32
 #undef WIN_MULTITHREAD_SUPPORT
 #endif
-#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>
@@ -55,7 +50,7 @@
 #elif defined(WITH_IODBC)
 #include <iodbcinst.h>
 #else
-#include "gpps.h"
+#error "don't know where to get odbcinst.h"
 #endif