Re: [PATCHES] libpq-win32 patches

2003-09-05 Thread Andreas Pflug
Hi Bruce,


+
+/* getpwuid doesn't exist under win32 */
+#define getpwuid(uid) NULL
+
#endif /* pg_config_h_win32__ */
   

Why was this needed?  I realize we don't have getpwuid() on Win32, but
we do have GetUserName() for cases where we need the name but not the
directory.
Because all the getpwuid() calls seem ifdef'ed out under Win32 anyway, I
don't understand why you needed it.
I believe it was the first thing I did to have libpq compile at all. 
Later, I went into the ssl code and made it work, effectively commenting 
out all calls to getpwuid() making that line unnecessary.



Can't we check the OS version via the compiler?  Maybe not portabily
between the various compilers supported.
 

If you're talking about the WIN32 macro, this should be supported by 
every compiler running for win32, because windows headers rely on this.

Regards,
Andreas


---(end of broadcast)---
TIP 2: you can get off all lists at once with the unregister command
   (send unregister YourEmailAddressHere to [EMAIL PROTECTED])


Re: [PATCHES] libpq-win32 patches

2003-09-04 Thread Bruce Momjian

OK, I have applied this patch, except for this part:

 Index: include/pg_config.h.win32
 ===
 RCS file: /projects/cvsroot/pgsql-server/src/include/pg_config.h.win32,v
 retrieving revision 1.11
 diff -u -r1.11 pg_config.h.win32
 --- include/pg_config.h.win32 12 Jun 2003 08:15:29 -  1.11
 +++ include/pg_config.h.win32 31 Aug 2003 23:22:31 -
 @@ -60,4 +60,9 @@
  #include windows.h
  #endif
  
 +#include port/win32.h
 +
 +/* getpwuid doesn't exist under win32 */
 +#define getpwuid(uid) NULL
 +
  #endif /* pg_config_h_win32__ */

Why was this needed?  I realize we don't have getpwuid() on Win32, but
we do have GetUserName() for cases where we need the name but not the
directory.

Because all the getpwuid() calls seem ifdef'ed out under Win32 anyway, I
don't understand why you needed it.

---

Andreas Pflug wrote:
 Hm,
 
 I don't see any reaction on my posts from last sunday, neither in this 
 list nor in unapplied patches, did they get lost?
 If so, attached is a combined patch for all three problems with libpq 
 compiling under win32.
 
 Regards,
 Andreas
 

 cvs diff -u interfaces\libpq\fe-connect.c interfaces\libpq\fe-exec.c 
 interfaces\libpq\fe-secure.c interfaces\libpq\libpq-int.h include\pg_config.h.win32 
 interfaces\libpq\win32.c interfaces\libpq\win32.mak (in directory C:\postgresql\src\)
 Index: interfaces/libpq/fe-connect.c
 ===
 RCS file: /projects/cvsroot/pgsql-server/src/interfaces/libpq/fe-connect.c,v
 retrieving revision 1.259
 diff -u -r1.259 fe-connect.c
 --- interfaces/libpq/fe-connect.c 4 Aug 2003 02:40:16 -   1.259
 +++ interfaces/libpq/fe-connect.c 31 Aug 2003 23:22:25 -
 @@ -48,7 +48,7 @@
  
  /* For FNCTL_NONBLOCK */
  #if defined(WIN32) || defined(__BEOS__)
 -long ioctlsocket_ret;
 +long ioctlsocket_ret=1;
  #endif
  
  #define PGPASSFILE .pgpass
  
 Index: interfaces/libpq/fe-exec.c
 ===
 RCS file: /projects/cvsroot/pgsql-server/src/interfaces/libpq/fe-exec.c,v
 retrieving revision 1.146
 diff -u -r1.146 fe-exec.c
 --- interfaces/libpq/fe-exec.c27 Aug 2003 00:33:34 -  1.146
 +++ interfaces/libpq/fe-exec.c31 Aug 2003 23:22:28 -
 @@ -2304,7 +2304,7 @@
   if (buffer == NULL)
   return NULL;
  
 - for (i = j = buflen = 0; i  strtextlen;)
 + for (i = j = buflen = 0; i  (int)strtextlen;)
   {
   switch (strtext[i])
   {
 Index: interfaces/libpq/fe-secure.c
 ===
 RCS file: /projects/cvsroot/pgsql-server/src/interfaces/libpq/fe-secure.c,v
 retrieving revision 1.29
 diff -u -r1.29 fe-secure.c
 --- interfaces/libpq/fe-secure.c  4 Aug 2003 17:25:14 -   1.29
 +++ interfaces/libpq/fe-secure.c  31 Aug 2003 23:22:29 -
 @@ -312,7 +312,7 @@
   printfPQExpBuffer(conn-errorMessage,
 
 libpq_gettext(SSL SYSCALL error: EOF detected\n));
  
 - SOCK_ERRNO = ECONNRESET;
 + SOCK_ERRNO_SET(ECONNRESET);
   n = -1;
   }
   break;
 @@ -322,7 +322,7 @@
 libpq_gettext(SSL error: %s\n), 
 SSLerrmessage());
   /* fall through */
   case SSL_ERROR_ZERO_RETURN:
 - SOCK_ERRNO = ECONNRESET;
 + SOCK_ERRNO_SET(ECONNRESET);
   n = -1;
   break;
   default:
 @@ -383,7 +383,7 @@
   {
   printfPQExpBuffer(conn-errorMessage,
 
 libpq_gettext(SSL SYSCALL error: EOF detected\n));
 - SOCK_ERRNO = ECONNRESET;
 + SOCK_ERRNO_SET(ECONNRESET);
   n = -1;
   }
   break;
 @@ -393,7 +393,7 @@
 libpq_gettext(SSL error: %s\n), 
 SSLerrmessage());
   /* fall through */
   case SSL_ERROR_ZERO_RETURN:
 - SOCK_ERRNO = ECONNRESET;
 + SOCK_ERRNO_SET(ECONNRESET);
   n = -1;
   break;
 

Re: [PATCHES] libpq-win32 patches

2003-09-01 Thread Bruce Momjian
Andreas Pflug wrote:
 Hm,
 
 I don't see any reaction on my posts from last sunday, neither in this 
 list nor in unapplied patches, did they get lost?
 If so, attached is a combined patch for all three problems with libpq 
 compiling under win32.


I am working through my mail queue.  Sorry.  They are not lost.

---




 
 Regards,
 Andreas
 

 cvs diff -u interfaces\libpq\fe-connect.c interfaces\libpq\fe-exec.c 
 interfaces\libpq\fe-secure.c interfaces\libpq\libpq-int.h include\pg_config.h.win32 
 interfaces\libpq\win32.c interfaces\libpq\win32.mak (in directory C:\postgresql\src\)
 Index: interfaces/libpq/fe-connect.c
 ===
 RCS file: /projects/cvsroot/pgsql-server/src/interfaces/libpq/fe-connect.c,v
 retrieving revision 1.259
 diff -u -r1.259 fe-connect.c
 --- interfaces/libpq/fe-connect.c 4 Aug 2003 02:40:16 -   1.259
 +++ interfaces/libpq/fe-connect.c 31 Aug 2003 23:22:25 -
 @@ -48,7 +48,7 @@
  
  /* For FNCTL_NONBLOCK */
  #if defined(WIN32) || defined(__BEOS__)
 -long ioctlsocket_ret;
 +long ioctlsocket_ret=1;
  #endif
  
  #define PGPASSFILE .pgpass
  
 Index: interfaces/libpq/fe-exec.c
 ===
 RCS file: /projects/cvsroot/pgsql-server/src/interfaces/libpq/fe-exec.c,v
 retrieving revision 1.146
 diff -u -r1.146 fe-exec.c
 --- interfaces/libpq/fe-exec.c27 Aug 2003 00:33:34 -  1.146
 +++ interfaces/libpq/fe-exec.c31 Aug 2003 23:22:28 -
 @@ -2304,7 +2304,7 @@
   if (buffer == NULL)
   return NULL;
  
 - for (i = j = buflen = 0; i  strtextlen;)
 + for (i = j = buflen = 0; i  (int)strtextlen;)
   {
   switch (strtext[i])
   {
 Index: interfaces/libpq/fe-secure.c
 ===
 RCS file: /projects/cvsroot/pgsql-server/src/interfaces/libpq/fe-secure.c,v
 retrieving revision 1.29
 diff -u -r1.29 fe-secure.c
 --- interfaces/libpq/fe-secure.c  4 Aug 2003 17:25:14 -   1.29
 +++ interfaces/libpq/fe-secure.c  31 Aug 2003 23:22:29 -
 @@ -312,7 +312,7 @@
   printfPQExpBuffer(conn-errorMessage,
 
 libpq_gettext(SSL SYSCALL error: EOF detected\n));
  
 - SOCK_ERRNO = ECONNRESET;
 + SOCK_ERRNO_SET(ECONNRESET);
   n = -1;
   }
   break;
 @@ -322,7 +322,7 @@
 libpq_gettext(SSL error: %s\n), 
 SSLerrmessage());
   /* fall through */
   case SSL_ERROR_ZERO_RETURN:
 - SOCK_ERRNO = ECONNRESET;
 + SOCK_ERRNO_SET(ECONNRESET);
   n = -1;
   break;
   default:
 @@ -383,7 +383,7 @@
   {
   printfPQExpBuffer(conn-errorMessage,
 
 libpq_gettext(SSL SYSCALL error: EOF detected\n));
 - SOCK_ERRNO = ECONNRESET;
 + SOCK_ERRNO_SET(ECONNRESET);
   n = -1;
   }
   break;
 @@ -393,7 +393,7 @@
 libpq_gettext(SSL error: %s\n), 
 SSLerrmessage());
   /* fall through */
   case SSL_ERROR_ZERO_RETURN:
 - SOCK_ERRNO = ECONNRESET;
 + SOCK_ERRNO_SET(ECONNRESET);
   n = -1;
   break;
   default:
 @@ -544,6 +544,9 @@
  static DH  *
  load_dh_file(int keylength)
  {
 +#ifdef WIN32
 +return NULL;
 +#else
   charpwdbuf[BUFSIZ];
   struct passwd pwdstr;
   struct passwd *pwd = NULL;
 @@ -558,6 +561,7 @@
   /* attempt to open file.  It's not an error if it doesn't exist. */
   snprintf(fnbuf, sizeof fnbuf, %s/.postgresql/dh%d.pem,
pwd-pw_dir, keylength);
 +
   if ((fp = fopen(fnbuf, r)) == NULL)
   return NULL;
  
 @@ -583,6 +587,7 @@
   }
  
   return dh;
 +#endif
  }
  
  /*
 @@ -686,6 +691,9 @@
  static int
  client_cert_cb(SSL *ssl, X509 **x509, EVP_PKEY **pkey)
  {
 +#ifdef WIN32
 +   return 0;
 +#else
   charpwdbuf[BUFSIZ];
   struct passwd pwdstr;