*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/libpq/pqcomm.c,v 1.5 1996/11/06 08:48:30 scrappy 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
#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 */
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();
if (envport)
return(atoi(envport));
- return(atoi(POSTPORT));
+ return(atoi(DEF_PGPORT));
}
/* --------------------------------
int
pq_getstr(char *s, int maxlen)
{
- int c;
+ int c = '\0';
if (Pfin == (FILE *) NULL) {
/* elog(DEBUG, "Input descriptor is null"); */
int
pq_getnchar(char *s, int off, int maxlen)
{
- int c;
+ int c = '\0';
if (Pfin == (FILE *) NULL) {
/* elog(DEBUG, "Input descriptor is null"); */
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);
}
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";
port->mask = 1 << port->sock;
-#ifndef WIN32
/* reset to non-blocking */
fcntl(port->sock, F_SETFL, 1);
-#endif /* WIN32 */
return(STATUS_OK);
}
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;
+}