]> granicus.if.org Git - postgresql/blobdiff - src/backend/libpq/pqcomm.c
From: Dan McGuirk <mcguirk@indirect.com>
[postgresql] / src / backend / libpq / pqcomm.c
index 76707512c59faa8b0653bf04e6fff124375cbbae..6b8ecdac28bc0d5673acd6f84ba6ae303324e8d3 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *    $Header: /cvsroot/pgsql/src/backend/libpq/pqcomm.c,v 1.6 1996/11/08 05:56:21 momjian Exp $
+ *    $Header: /cvsroot/pgsql/src/backend/libpq/pqcomm.c,v 1.12 1997/03/12 21:17:58 scrappy Exp $
  *
  *-------------------------------------------------------------------------
  */
  */
 #include <stdio.h>
 #include <string.h>
+#include <signal.h>
 #include <errno.h>
 #include <fcntl.h>
-#include <signal.h>
-#ifndef WIN32
 #include <unistd.h>            /* for ttyname() */
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <netdb.h>
 #include <netinet/in.h>
-#include <sys/socket.h>
 #include <arpa/inet.h>
-#else
-#include <winsock.h>
-#endif /* WIN32 */
 
 #if defined(linux)
 #ifndef SOMAXCONN
@@ -59,7 +54,7 @@
 
 #include <postgres.h>
 
-#include <libpq/pqsignal.h>    /* substitute for <signal.h> */
+#include <libpq/pqsignal.h>
 #include <libpq/auth.h>
 #include <libpq/libpq.h>       /* where the declarations go */
 
@@ -78,17 +73,8 @@ int PQAsyncNotifyWaiting;    /* for async. notification */
 void
 pq_init(int fd)
 {
-#ifdef WIN32
-    int in, out;
-
-    in = _open_osfhandle(fd, _O_RDONLY);
-    out = _open_osfhandle(fd, _O_APPEND);
-    Pfin = fdopen(in, "rb");
-    Pfout = fdopen(out, "wb");
-#else
     Pfin = fdopen(fd, "r");
     Pfout = fdopen(dup(fd), "w");
-#endif /* WIN32 */
     if (!Pfin || !Pfout)
        elog(FATAL, "pq_init: Couldn't initialize socket connection");
     PQnotifies_init();
@@ -140,7 +126,7 @@ pq_getport()
     
     if (envport)
        return(atoi(envport));
-    return(atoi(POSTPORT));
+    return(atoi(DEF_PGPORT));
 }
 
 /* --------------------------------
@@ -488,26 +474,19 @@ pq_getinserv(struct sockaddr_in *sin, char *host, char *serv)
 void
 pq_regoob(void (*fptr)())
 {
-#ifdef WIN32
-    /* Who knows what to do here? */
-    return;
-#else
     int fd = fileno(Pfout);
 #if defined(hpux)
     ioctl(fd, FIOSSAIOOWN, getpid());
 #else /* hpux */
     fcntl(fd, F_SETOWN, getpid());
 #endif /* hpux */
-    (void) signal(SIGURG,fptr);
-#endif /* WIN32 */    
+    (void) pqsignal(SIGURG,fptr);
 }
 
 void
 pq_unregoob()
 {
-#ifndef WIN32
-    signal(SIGURG,SIG_DFL);
-#endif /* WIN32 */    
+    pqsignal(SIGURG,SIG_DFL);
 }
 
 
@@ -555,15 +534,6 @@ StreamServerPort(char *hostName, short portName, int *fdP)
     int                        fd;
     int                 one = 1;
     
-#ifdef WIN32
-    /* This is necessary to make it possible for a backend to use
-    ** stdio to read from the socket.
-    */
-    int optionvalue = SO_SYNCHRONOUS_NONALERT;
-
-    setsockopt(INVALID_SOCKET, SOL_SOCKET, SO_OPENTYPE, (char *)&optionvalue,
-              sizeof(optionvalue));
-#endif /* WIN32 */
 
     if (! hostName)
        hostName = "localhost";
@@ -649,10 +619,8 @@ StreamConnection(int server_fd, Port *port)
     
     port->mask = 1 << port->sock;
 
-#ifndef WIN32    
     /* reset to non-blocking */
     fcntl(port->sock, F_SETFL, 1);
-#endif /* WIN32 */    
     
     return(STATUS_OK);
 }
@@ -735,3 +703,29 @@ StreamOpen(char *hostName, short portName, Port *port)
     
     return(STATUS_OK);
 }
+
+static char *authentication_type_name[] = {
+    0, 0, 0, 0, 0, 0, 0, 
+    "the default authentication type", 
+    0, 0,
+    "Kerberos v4",
+    "Kerberos v5",
+    "host-based authentication",
+    "unauthenication",
+    "plaintext password authentication"
+};
+
+char *name_of_authentication_type(int type)
+{
+    char *result = 0;
+
+    if(type >= 1 && type <= LAST_AUTHENTICATION_TYPE) {
+       result = authentication_type_name[type];
+    }
+
+    if(result == 0) {
+       result = "<unknown authentication type>";
+    }
+
+    return result;
+}