Allow non-admin or Vista users to create log fils in the home
authorHiroshi Inoue <inoue@tpf.co.jp>
Wed, 11 Apr 2007 15:22:23 +0000 (15:22 +0000)
committerHiroshi Inoue <inoue@tpf.co.jp>
Wed, 11 Apr 2007 15:22:23 +0000 (15:22 +0000)
directory.

bind.c
dlg_specific.c
dlg_specific.h
dlg_wingui.c
inouealc.c
msdtc_enlist.cpp
mylog.c
socket.c
version.h
win32.mak

diff --git a/bind.c b/bind.c
index f3b318f39d66c40578fef9f9f6b59778293a775a..1bcfeee931263331c2985506bb03349393470837 100644 (file)
--- a/bind.c
+++ b/bind.c
@@ -542,7 +542,7 @@ extend_parameter_bindings(APDFields *self, int num_params)
        self->allocated = num_params;
    }
 
-   mylog("exit extend_parameter_bindings=%p\n", self->parameters);
+   mylog("exit %s=%p\n", func, self->parameters);
 }
 
 void
@@ -575,7 +575,7 @@ extend_iparameter_bindings(IPDFields *self, int num_params)
        self->allocated = num_params;
    }
 
-   mylog("exit extend_iparameter_bindings=%p\n", self->parameters);
+   mylog("exit %s=%p\n", func, self->parameters);
 }
 
 void
@@ -689,9 +689,10 @@ APD_free_params(APDFields *apdopts, char option)
 void
 PDATA_free_params(PutDataInfo *pdata, char option)
 {
+   CSTR    func = "PDATA_free_params";
    int         i;
 
-   mylog("PDATA_free_params:  ENTER, self=%p\n", pdata);
+   mylog("%s:  ENTER, self=%p\n", func, pdata);
 
    if (!pdata->pdata)
        return;
@@ -717,7 +718,7 @@ PDATA_free_params(PutDataInfo *pdata, char option)
        pdata->allocated = 0;
    }
 
-   mylog("PDATA_free_params:  EXIT\n");
+   mylog("%s:  EXIT\n", func);
 }
 
 /*
@@ -726,7 +727,9 @@ PDATA_free_params(PutDataInfo *pdata, char option)
 void
 IPD_free_params(IPDFields *ipdopts, char option)
 {
-   mylog("IPD_free_params:  ENTER, self=%p\n", ipdopts);
+   CSTR    func = "IPD_free_params";
+
+   mylog("%s:  ENTER, self=%p\n", func, ipdopts);
 
    if (!ipdopts->parameters)
        return;
@@ -737,7 +740,7 @@ IPD_free_params(IPDFields *ipdopts, char option)
        ipdopts->allocated = 0;
    }
 
-   mylog("IPD_free_params:  EXIT\n");
+   mylog("%s:  EXIT\n", func);
 }
 
 void
@@ -791,7 +794,7 @@ extend_column_bindings(ARDFields *self, int num_columns)
    /* SQLExecDirect(...)  # returns 5 cols */
    /* SQLExecDirect(...)  # returns 10 cols  (now OK) */
 
-   mylog("exit extend_column_bindings=%p\n", self->bindings);
+   mylog("exit %s=%p\n", func, self->bindings);
 }
 
 void
@@ -1022,7 +1025,7 @@ extend_putdata_info(PutDataInfo *self, int num_params, BOOL shrink)
        }
    }
 
-   mylog("exit extend_putdata_info=%p\n", self->pdata);
+   mylog("exit %s=%p\n", func, self->pdata);
 }
 void   reset_a_putdata_info(PutDataInfo *pdata_info, int ipar)
 {
index a75b8c9970f92aff76009d1857da9f97d3ccfe3a..a4b6e5f3835a4e2ef42d8344161a132d7f49a0e2 100644 (file)
@@ -890,44 +890,46 @@ getDSNinfo(ConnInfo *ci, char overwrite)
  * This function writes any global parameters (that can be manipulated)
  * to the ODBCINST.INI portion of the registry
  */
-void
+int
 writeDriverCommoninfo(const char *fileName, const char *sectionName,
             const GLOBAL_VALUES *comval)
 {
    char        tmp[128];
+   int     errc = 0;
 
    if (ODBCINST_INI == fileName && NULL == sectionName)
        sectionName = DBMS_NAME;
  
    sprintf(tmp, "%d", comval->commlog);
-   SQLWritePrivateProfileString(sectionName,
-                                INI_COMMLOG, tmp, fileName);
+   if (!SQLWritePrivateProfileString(sectionName, INI_COMMLOG, tmp, fileName))
+       errc--;
 
    sprintf(tmp, "%d", comval->debug);
-   SQLWritePrivateProfileString(sectionName,
-                                INI_DEBUG, tmp, fileName);
+   if (!SQLWritePrivateProfileString(sectionName, INI_DEBUG, tmp, fileName))
+       errc--;
 
    sprintf(tmp, "%d", comval->fetch_max);
-   SQLWritePrivateProfileString(sectionName,
-                                INI_FETCH, tmp, fileName);
+   if (!SQLWritePrivateProfileString(sectionName, INI_FETCH, tmp, fileName))
+       errc--;
 
    if (stricmp(ODBCINST_INI, fileName) == 0)
-       return;
+       return errc;
 
    sprintf(tmp, "%d", comval->fetch_max);
-   SQLWritePrivateProfileString(sectionName,
-                                INI_FETCH, tmp, fileName);
+   if (!SQLWritePrivateProfileString(sectionName, INI_FETCH, tmp, fileName))
+       errc--;
 
    sprintf(tmp, "%d", comval->disable_optimizer);
-   SQLWritePrivateProfileString(sectionName,
-                                INI_OPTIMIZER, tmp, fileName);
+   if (!SQLWritePrivateProfileString(sectionName, INI_OPTIMIZER, tmp, fileName))
+       errc--;
 
    sprintf(tmp, "%d", comval->ksqo);
-   SQLWritePrivateProfileString(sectionName,
-                                INI_KSQO, tmp, fileName);
+   if (!SQLWritePrivateProfileString(sectionName, INI_KSQO, tmp, fileName))
+       errc--;
 
    sprintf(tmp, "%d", comval->unique_index);
-   SQLWritePrivateProfileString(sectionName, INI_UNIQUEINDEX, tmp, fileName);
+   if (!SQLWritePrivateProfileString(sectionName, INI_UNIQUEINDEX, tmp, fileName))
+       errc--;
    /*
     * Never update the onlyread from this module.
     */
@@ -939,49 +941,51 @@ writeDriverCommoninfo(const char *fileName, const char *sectionName,
    }
 
    sprintf(tmp, "%d", comval->use_declarefetch);
-   SQLWritePrivateProfileString(sectionName,
-                                INI_USEDECLAREFETCH, tmp, fileName);
+   if (!SQLWritePrivateProfileString(sectionName, INI_USEDECLAREFETCH, tmp, fileName))
+       errc--;
 
    sprintf(tmp, "%d", comval->unknown_sizes);
-   SQLWritePrivateProfileString(sectionName,
-                                INI_UNKNOWNSIZES, tmp, fileName);
+   if (!SQLWritePrivateProfileString(sectionName, INI_UNKNOWNSIZES, tmp, fileName))
+       errc--;
 
    sprintf(tmp, "%d", comval->text_as_longvarchar);
-   SQLWritePrivateProfileString(sectionName,
-                                INI_TEXTASLONGVARCHAR, tmp, fileName);
+   if (!SQLWritePrivateProfileString(sectionName, INI_TEXTASLONGVARCHAR, tmp, fileName))
+       errc--;
 
    sprintf(tmp, "%d", comval->unknowns_as_longvarchar);
-   SQLWritePrivateProfileString(sectionName,
-                              INI_UNKNOWNSASLONGVARCHAR, tmp, fileName);
+   if (!SQLWritePrivateProfileString(sectionName, INI_UNKNOWNSASLONGVARCHAR, tmp, fileName))
+       errc--;
 
    sprintf(tmp, "%d", comval->bools_as_char);
-   SQLWritePrivateProfileString(sectionName,
-                                INI_BOOLSASCHAR, tmp, fileName);
+   if (!SQLWritePrivateProfileString(sectionName, INI_BOOLSASCHAR, tmp, fileName))
+       errc--;
 
    sprintf(tmp, "%d", comval->parse);
-   SQLWritePrivateProfileString(sectionName,
-                                INI_PARSE, tmp, fileName);
+   if (!SQLWritePrivateProfileString(sectionName, INI_PARSE, tmp, fileName))
+       errc--;
 
    sprintf(tmp, "%d", comval->cancel_as_freestmt);
-   SQLWritePrivateProfileString(sectionName,
-                                INI_CANCELASFREESTMT, tmp, fileName);
+   if (!SQLWritePrivateProfileString(sectionName, INI_CANCELASFREESTMT, tmp, fileName))
+       errc--;
 
    sprintf(tmp, "%d", comval->max_varchar_size);
-   SQLWritePrivateProfileString(sectionName,
-                                INI_MAXVARCHARSIZE, tmp, fileName);
+   if (!SQLWritePrivateProfileString(sectionName, INI_MAXVARCHARSIZE, tmp, fileName))
+       errc--;
 
    sprintf(tmp, "%d", comval->max_longvarchar_size);
-   SQLWritePrivateProfileString(sectionName,
-                                INI_MAXLONGVARCHARSIZE, tmp, fileName);
+   if (!SQLWritePrivateProfileString(sectionName, INI_MAXLONGVARCHARSIZE, tmp, fileName))
+       errc--;
 
-   SQLWritePrivateProfileString(sectionName,
-   INI_EXTRASYSTABLEPREFIXES, comval->extra_systable_prefixes, fileName);
+   if (!SQLWritePrivateProfileString(sectionName, INI_EXTRASYSTABLEPREFIXES, comval->extra_systable_prefixes, fileName))
+       errc--;
 
    /*
     * Never update the conn_setting from this module
     * SQLWritePrivateProfileString(sectionName, INI_CONNSETTINGS,
     * comval->conn_settings, fileName);
     */
+
+   return errc;
 }
 
 /* This is for datasource based options only */
index ff213aa52b9044396c6e26dc0e79a023ef850ad5..aafb94504ffb2b9ab94c62dcc78377b592e1ac2f 100644 (file)
@@ -265,7 +265,7 @@ LRESULT CALLBACK manage_dsnProc(HWND hdlg,
 #endif   /* WIN32 */
 
 void       updateGlobals(void);
-void       writeDriverCommoninfo(const char *fileName, const char *sectionName,
+int        writeDriverCommoninfo(const char *fileName, const char *sectionName,
        const GLOBAL_VALUES *);
 void       writeDSNinfo(const ConnInfo *ci);
 void       getDSNdefaults(ConnInfo *ci);
index e22a8ca9e996650ee076f6c662284e20552244a7..70ca7f5828de8e61f237d4124e96d4795ab62c43 100644 (file)
@@ -256,7 +256,11 @@ driver_options_update(HWND hdlg, ConnInfo *ci, const char *updateDriver)
        GetDlgItemText(hdlg, DRV_CONNSETTINGS, comval->conn_settings, sizeof(comval->conn_settings));
 
    if (updateDriver)
-       writeDriverCommoninfo(ODBCINST_INI, updateDriver, comval);
+   {
+       if (writeDriverCommoninfo(ODBCINST_INI, updateDriver, comval) < 0)
+           MessageBox(hdlg, "impossible to update the values, sorry", "Update Error", MB_ICONEXCLAMATION | MB_OK);
+;
+   }
 
    /* fall through */
    return 0;
@@ -364,7 +368,8 @@ global_optionsProc(HWND hdlg,
                case IDOK:
                    globals.commlog = IsDlgButtonChecked(hdlg, DRV_COMMLOG);
                    globals.debug = IsDlgButtonChecked(hdlg, DRV_DEBUG);
-                   writeDriverCommoninfo(ODBCINST_INI, NULL, &globals);
+                   if (writeDriverCommoninfo(ODBCINST_INI, NULL, &globals) < 0)
+                       MessageBox(hdlg, "Sorry, impossible to update the values\nWrite permission seems to be needed", "Update Error", MB_ICONEXCLAMATION | MB_OK);
 #ifdef _HANDLE_ENLIST_IN_DTC_
            hmodule = DtcProc("SetMsdtclog", &proc);
            if (proc)
index 9f03211d0b2cf6a262c1f2ff47c0ea9223db89f3..067278255921d0ce3a01d830eb60bfaaad60109a 100644 (file)
@@ -1,18 +1,6 @@
 #undef _MEMORY_DEBUG_
 #include   "psqlodbc.h"
 
-/*
-#undef malloc
-#undef calloc
-#undef realloc
-#undef strdup
-#undef free
-#undef memcpy
-#undef strcpy
-#undef strncpy
-#undef strncpy_null
-#undef memset
-*/
 #ifdef WIN32
 #ifdef _DEBUG
 /* #include    <stdlib.h> */
index 1a7a556c79306f94994327bc6fce602c924febc5..721d1c9715cbacd97ac00f4be1cace94883952c8 100755 (executable)
@@ -10,6 +10,7 @@
 
 #ifdef _HANDLE_ENLIST_IN_DTC_
 
+#undef _MEMORY_DEBUG_
 #ifndef    _WIN32_WINNT
 #define    _WIN32_WINNT    0x0400
 #endif /* _WIN32_WINNT */
diff --git a/mylog.c b/mylog.c
index e4068095c3699da22b4798e36bec3514e44e4dad..cc287d0477d7f6ad0f4fb560ccd90b5f0a232d68 100644 (file)
--- a/mylog.c
+++ b/mylog.c
 #include "psqlodbc.h"
 
 #include <stdio.h>
+#include <stdlib.h>
 #include <stdarg.h>
 #include <string.h>
 #include <time.h>
 
 #ifndef WIN32
+#define    GENERAL_ERRNO       (errno)
+#define    GENERAL_ERRNO_SET(e)    (errno = e)
 #include <pwd.h>
 #include <sys/types.h>
 #include <unistd.h>
 #else
+#define    GENERAL_ERRNO       (GetLastError())
+#define    GENERAL_ERRNO_SET(e)    SetLastError(e)
 #include <process.h>           /* Byron: is this where Windows keeps def.
                                 * of getpid ? */
 #endif
 
 extern GLOBAL_VALUES globals;
-void       generate_filename(const char *, const char *, char *);
-
+void   generate_filename(const char *, const char *, char *);
 
 void
 generate_filename(const char *dirname, const char *prefix, char *filename)
@@ -60,6 +64,26 @@ generate_filename(const char *dirname, const char *prefix, char *filename)
    return;
 }
 
+static void
+generate_homefile(const char *prefix, char *filename)
+{
+   char    dir[_MAX_PATH];
+#ifdef WIN32
+   const char *ptr;
+
+   dir[0] = '\0';
+   if (ptr=getenv("HOMEDRIVE"), NULL != ptr)
+       strcat(dir, ptr);
+   if (ptr=getenv("HOMEPATH"), NULL != ptr)
+       strcat(dir, ptr);
+#else
+   strcpy(dir, "~");   
+#endif /* WIN32 */
+   generate_filename(dir, prefix, filename);
+
+   return;
+}
+
 #if defined(WIN_MULTITHREAD_SUPPORT)
 static CRITICAL_SECTION    qlog_cs, mylog_cs;
 #elif defined(POSIX_MULTITHREAD_SUPPORT)
@@ -129,8 +153,11 @@ mylog(const char *fmt,...)
 {
    va_list     args;
    char        filebuf[80];
+   int     gerrno;
 
    if (!mylog_on)  return;
+
+   gerrno = GENERAL_ERRNO;
    ENTER_MYLOG_CS;
 #ifdef LOGGING_PROCESS_TIME
    if (!start_time)
@@ -142,38 +169,47 @@ mylog(const char *fmt,...)
    {
        generate_filename(MYLOGDIR, MYLOGFILE, filebuf);
        MLOGFP = fopen(filebuf, PG_BINARY_A);
+       if (!MLOGFP)
+       {
+           generate_homefile(MYLOGFILE, filebuf);
+           MLOGFP = fopen(filebuf, PG_BINARY_A);
+       }
        if (MLOGFP)
            setbuf(MLOGFP, NULL);
+       else
+           mylog_on = 0;
    }
 
-#ifdef WIN_MULTITHREAD_SUPPORT
-#ifdef WIN32
    if (MLOGFP)
-#ifdef LOGGING_PROCESS_TIME
    {
+#ifdef WIN_MULTITHREAD_SUPPORT
+#ifdef LOGGING_PROCESS_TIME
        DWORD   proc_time = timeGetTime() - start_time;
        fprintf(MLOGFP, "[%u-%d.%03d]", GetCurrentThreadId(), proc_time / 1000, proc_time % 1000);
-   }
 #else
        fprintf(MLOGFP, "[%u]", GetCurrentThreadId());
 #endif /* LOGGING_PROCESS_TIME */
-#endif /* WIN32 */
 #endif /* WIN_MULTITHREAD_SUPPORT */
 #if defined(POSIX_MULTITHREAD_SUPPORT)
-   if (MLOGFP)
        fprintf(MLOGFP, "[%lu]", pthread_self());
 #endif /* POSIX_MULTITHREAD_SUPPORT */
-   if (MLOGFP)
        vfprintf(MLOGFP, fmt, args);
+   }
 
    va_end(args);
    LEAVE_MYLOG_CS;
+   GENERAL_ERRNO_SET(gerrno);
 }
 void
 forcelog(const char *fmt,...)
 {
+   static BOOL force_on = TRUE;
    va_list     args;
    char        filebuf[80];
+   int     gerrno = GENERAL_ERRNO;
+
+   if (!force_on)
+       return;
 
    ENTER_MYLOG_CS;
    va_start(args, fmt);
@@ -184,13 +220,20 @@ forcelog(const char *fmt,...)
        MLOGFP = fopen(filebuf, PG_BINARY_A);
        if (MLOGFP)
            setbuf(MLOGFP, NULL);
-   }
-   if (!MLOGFP)
-   {
-       generate_filename("C:\\podbclog", MYLOGFILE, filebuf);
-       MLOGFP = fopen(filebuf, PG_BINARY_A);
+       if (!MLOGFP)
+       {
+           generate_homefile(MYLOGFILE, filebuf);
+           MLOGFP = fopen(filebuf, PG_BINARY_A);
+       }
+       if (!MLOGFP)
+       {
+           generate_filename("C:\\podbclog", MYLOGFILE, filebuf);
+           MLOGFP = fopen(filebuf, PG_BINARY_A);
+       }
        if (MLOGFP)
            setbuf(MLOGFP, NULL);
+       else
+           force_on = FALSE;
    }
    if (MLOGFP)
    {
@@ -212,6 +255,7 @@ forcelog(const char *fmt,...)
    }
    va_end(args);
    LEAVE_MYLOG_CS;
+   GENERAL_ERRNO_SET(gerrno);
 }
 static void mylog_initialize()
 {
@@ -244,9 +288,11 @@ qlog(char *fmt,...)
 {
    va_list     args;
    char        filebuf[80];
+   int     gerrno;
 
    if (!qlog_on)   return;
 
+   gerrno = GENERAL_ERRNO;
    ENTER_QLOG_CS;
 #ifdef LOGGING_PROCESS_TIME
    if (!start_time)
@@ -258,8 +304,15 @@ qlog(char *fmt,...)
    {
        generate_filename(QLOGDIR, QLOGFILE, filebuf);
        QLOGFP = fopen(filebuf, PG_BINARY_A);
+       if (!QLOGFP)
+       {
+           generate_homefile(QLOGFILE, filebuf);
+           QLOGFP = fopen(filebuf, PG_BINARY_A);
+       }
        if (QLOGFP)
            setbuf(QLOGFP, NULL);
+       else
+           qlog_on = 0;
    }
 
    if (QLOGFP)
@@ -273,6 +326,7 @@ qlog(char *fmt,...)
 
    va_end(args);
    LEAVE_QLOG_CS;
+   GENERAL_ERRNO_SET(gerrno);
 }
 static void qlog_initialize()
 {
index 1975d53453da27b1c9ed13831c8dbb6655426146..5da82d3396743bd2c954c22306baa2fc32256128 100644 (file)
--- a/socket.c
+++ b/socket.c
@@ -204,7 +204,7 @@ SOCK_connect_to(SocketClass *self, unsigned short port, char *hostname, long tim
    struct addrinfo rest, *addrs = NULL, *curadr = NULL;
    int family = 0; 
    char    retval = 0;
-
+   int gerrno;
 
    if (self->socket != (SOCKETFD) -1)
    {
@@ -315,7 +315,8 @@ retry:
        time_t  t_now, t_finish = 0;
        BOOL    tm_exp = FALSE;
 
-       switch (SOCK_ERRNO)
+       gerrno = SOCK_ERRNO;
+       switch (gerrno)
        {
            case 0:
            case EINPROGRESS:
@@ -339,11 +340,12 @@ retry:
            FD_SET(self->socket, &fds);
            FD_SET(self->socket, &except_fds);
            ret = select((int) self->socket + 1, NULL, &fds, &except_fds, timeout > 0 ? &tm : NULL);
+           gerrno = SOCK_ERRNO;
            if (0 < ret)
                break;
            else if (0 == ret)
                tm_exp = TRUE;
-           else if (EINTR != SOCK_ERRNO)
+           else if (EINTR != gerrno)
                break;
            else if (timeout > 0)
            {
@@ -364,7 +366,7 @@ retry:
        else if (0 > ret)
        {
            SOCK_set_error(self, SOCKET_COULD_NOT_CONNECT, "Could not connect .. select error occured.");
-           mylog("select error ret=%d ERROR=%d\n", ret, SOCK_ERRNO);
+           mylog("select error ret=%d ERROR=%d\n", ret, gerrno);
            goto cleanup;
        }
        if (getsockopt(self->socket, SOL_SOCKET, SO_ERROR,
@@ -420,7 +422,7 @@ cleanup:
 #define    MAX_RETRY_COUNT 30
 static int SOCK_wait_for_ready(SocketClass *sock, BOOL output, int retry_count)
 {
-   int ret;
+   int ret, gerrno;
    fd_set  fds, except_fds;
    struct  timeval tm;
    BOOL    no_timeout = (0 != retry_count && (retry_count < 0 || (!sock->ssl)));
@@ -436,7 +438,8 @@ static int SOCK_wait_for_ready(SocketClass *sock, BOOL output, int retry_count)
            tm.tv_usec = 0;
        }
        ret = select((int)sock->socket + 1, output ? NULL : &fds, output ? &fds : NULL, &except_fds, no_timeout ? NULL : &tm);
-   } while (ret < 0 && EINTR == SOCK_ERRNO);
+       gerrno = SOCK_ERRNO;
+   } while (ret < 0 && EINTR == gerrno);
    if (retry_count < 0)
        retry_count *= -1;
    if (0 == ret && retry_count > MAX_RETRY_COUNT)
@@ -467,12 +470,13 @@ static int SOCK_wait_for_ready(SocketClass *sock, BOOL output, int retry_count)
 static int SOCK_SSL_recv(SocketClass *sock, void *buffer, int len)
 {
    CSTR    func = "SOCK_SSL_recv";
-   int n, err, retry_count = 0;
+   int n, err, gerrno, retry_count = 0;
 
 retry:
    n = SSL_read(sock->ssl, buffer, len);
    err = SSL_get_error(sock->ssl, len);
-inolog("%s: %d get_error=%d Lasterror=%d\n", func, n, err, SOCK_ERRNO);
+   gerrno = SOCK_ERRNO;
+inolog("%s: %d get_error=%d Lasterror=%d\n", func, n, err, gerrno);
    switch (err)
    {
        case    SSL_ERROR_NONE:
@@ -511,12 +515,13 @@ inolog("%s: %d get_error=%d Lasterror=%d\n", func, n, err, SOCK_ERRNO);
 static int SOCK_SSL_send(SocketClass *sock, void *buffer, int len)
 {
    CSTR    func = "SOCK_SSL_send";
-   int n, err, retry_count = 0;
+   int n, err, gerrno, retry_count = 0;
 
 retry:
    n = SSL_write(sock->ssl, buffer, len);
    err = SSL_get_error(sock->ssl, len);
-inolog("%s: %d get_error=%d Lasterror=%d\n", func,  n, err, SOCK_ERRNO);
+   gerrno = SOCK_ERRNO;
+inolog("%s: %d get_error=%d Lasterror=%d\n", func,  n, err, gerrno);
    switch (err)
    {
        case    SSL_ERROR_NONE:
@@ -714,7 +719,7 @@ SOCK_put_int(SocketClass *self, int value, short len)
 Int4
 SOCK_flush_output(SocketClass *self)
 {
-   int written, pos = 0, retry_count = 0, ttlsnd = 0;
+   int written, pos = 0, retry_count = 0, ttlsnd = 0, gerrno;
 
    if (!self)
        return -1;
@@ -726,9 +731,10 @@ SOCK_flush_output(SocketClass *self)
            written = SOCK_SSL_send(self, (char *) self->buffer_out + pos, self->buffer_filled_out);
        else
            written = send(self->socket, (char *) self->buffer_out + pos, self->buffer_filled_out, 0);
+       gerrno = SOCK_ERRNO;
        if (written < 0)
        {
-           switch (SOCK_ERRNO)
+           switch (gerrno)
            {
                case EINTR:
                    continue;
@@ -755,7 +761,7 @@ SOCK_flush_output(SocketClass *self)
 UCHAR
 SOCK_get_next_byte(SocketClass *self)
 {
-   int retry_count = 0;
+   int retry_count = 0, gerrno;
    BOOL    maybeEOF = FALSE;
 
    if (!self)
@@ -771,13 +777,14 @@ retry:
            self->buffer_filled_in = SOCK_SSL_recv(self, (char *) self->buffer_in, self->buffer_size);
        else
            self->buffer_filled_in = recv(self->socket, (char *) self->buffer_in, self->buffer_size, 0);
+       gerrno = SOCK_ERRNO;
 
        mylog("read %d, global_socket_buffersize=%d\n", self->buffer_filled_in, self->buffer_size);
 
        if (self->buffer_filled_in < 0)
        {
-mylog("Lasterror=%d\n", SOCK_ERRNO);
-           switch (SOCK_ERRNO)
+mylog("Lasterror=%d\n", gerrno);
+           switch (gerrno)
            {
                case    EINTR:
                    goto retry;
@@ -826,7 +833,7 @@ inolog("ECONNRESET\n");
 void
 SOCK_put_next_byte(SocketClass *self, UCHAR next_byte)
 {
-   int bytes_sent, pos = 0, retry_count = 0;
+   int bytes_sent, pos = 0, retry_count = 0, gerrno;
 
    if (!self)
        return;
@@ -843,9 +850,10 @@ SOCK_put_next_byte(SocketClass *self, UCHAR next_byte)
                bytes_sent = SOCK_SSL_send(self, (char *) self->buffer_out + pos, self->buffer_filled_out);
            else
                bytes_sent = send(self->socket, (char *) self->buffer_out + pos, self->buffer_filled_out, 0);
+           gerrno = SOCK_ERRNO;
            if (bytes_sent < 0)
            {
-               switch (SOCK_ERRNO)
+               switch (gerrno)
                {
                    case    EINTR:
                        continue;
index bedaad2ba23277dc67bcc368cf3e518c4cbf027e..17e166421d992fce891c016bf74022131ff90312 100644 (file)
--- a/version.h
+++ b/version.h
@@ -12,6 +12,6 @@
 #define POSTGRESDRIVERVERSION      "08.02.0205"
 #define POSTGRES_RESOURCE_VERSION  "08.02.0205\0"
 #define PG_DRVFILE_VERSION     8,2,02,05
-#define PG_BUILD_VERSION       "200704050001"
+#define PG_BUILD_VERSION       "200704110001"
 
 #endif
index b9e62befcc59ae239dddfa177ba5ab632812cbdb..4b2f2923bd093cb43b6f1a14b111c2b8a1e9ae8c 100644 (file)
--- a/win32.mak
+++ b/win32.mak
@@ -242,7 +242,7 @@ BSC32_SBRS= \
    
 LINK32=link.exe
 LIB32=lib.exe
-LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib $(OUTDIR)\$(DTCLIB).lib winmm.lib /nologo /dll /pdb:"$(OUTDIR)\psqlodbc.pdb" /machine:I386 /def:"$(DEF_FILE)" /out:"$(OUTDIR)\$(MAINDLL)" /implib:"$(OUTDIR)\$(MAINLIB).lib" 
+LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib $(OUTDIR)\$(DTCLIB).lib winmm.lib /nologo /dll /machine:I386 /def:"$(DEF_FILE)"
 !IF  "$(ANSI_VERSION)" == "yes"
 DEF_FILE= "psqlodbca.def"
 !ELSE
@@ -301,35 +301,35 @@ LINK32_OBJS= \
    "$(INTDIR)\psqlodbc.res"
 
 DTCDEF_FILE= "$(DTCLIB).def"
-LIB_DTCLIBFLAGS=/nologo /machine:I386 /def:"$(DTCDEF_FILE)" /out:"$(OUTDIR)\$(DTCLIB).lib"
+LIB_DTCLIBFLAGS=/nologo /machine:I386 /def:"$(DTCDEF_FILE)"
 
-LINK32_DTCFLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib uuid.lib wsock32.lib XOleHlp.lib $(OUTDIR)\$(MAINLIB).lib Delayimp.lib /DelayLoad:XOLEHLP.DLL /nologo /dll /incremental:no /pdb:"$(OUTDIR)\$(DTCLIB).pdb" /machine:I386 /out:"$(OUTDIR)\$(DTCDLL)"
+LINK32_DTCFLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib uuid.lib wsock32.lib XOleHlp.lib $(OUTDIR)\$(MAINLIB).lib Delayimp.lib /DelayLoad:XOLEHLP.DLL /nologo /dll /incremental:no /machine:I386
 LINK32_DTCOBJS= \
    "$(INTDIR)\msdtc_enlist.obj" "$(INTDIR)\xalibname.obj"
 
 XADEF_FILE= "$(XALIB).def"
-LINK32_XAFLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib odbc32.lib odbccp32.lib uuid.lib wsock32.lib /nologo /dll /incremental:no /pdb:"$(OUTDIR)\$(XALIB).pdb" /machine:I386 /def:"$(XADEF_FILE)" /out:"$(OUTDIR)\$(XADLL)" /implib:"$(OUTDIR)\$(XALIB).lib"
+LINK32_XAFLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib odbc32.lib odbccp32.lib uuid.lib wsock32.lib /nologo /dll /incremental:no /machine:I386 /def:"$(XADEF_FILE)"
 LINK32_XAOBJS= \
    "$(INTDIR)\pgxalib.obj" 
 
 "$(OUTDIR)\$(MAINDLL)" : $(DEF_FILE) $(LINK32_OBJS)
     $(LINK32) @<<
-  $(LINK32_FLAGS) $(LINK32_OBJS)
+  $(LINK32_FLAGS) $(LINK32_OBJS) /pdb:$*.pdb /implib:$*.lib /out:$@
 <<
 
 "$(OUTDIR)\$(DTCLIB).lib" : $(DTCDEF_FILE) $(LINK32_DTCOBJS)
     $(LIB32) @<<
-  $(LIB_DTCLIBFLAGS) $(LINK32_DTCOBJS)
+  $(LIB_DTCLIBFLAGS) $(LINK32_DTCOBJS) /out:$@
 <<
 
 "$(OUTDIR)\$(DTCDLL)" : $(DTCDEF_FILE) $(LINK32_DTCOBJS)
     $(LINK32) @<<
-  $(LINK32_DTCFLAGS) $(LINK32_DTCOBJS) "$(OUTDIR)\$(DTCLIB).exp" 
+  $(LINK32_DTCFLAGS) $(LINK32_DTCOBJS) $*.exp /pdb:$*.pdb /out:$@ 
 <<
 
 "$(OUTDIR)\$(XADLL)" : $(XADEF_FILE) $(LINK32_XAOBJS)
     $(LINK32) @<<
-  $(LINK32_XAFLAGS) $(LINK32_XAOBJS)
+  $(LINK32_XAFLAGS) $(LINK32_XAOBJS) /pdb:$*.pdb /implib:$*.lib /out:$@
 <<