*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/libpq/pqcomm.c,v 1.46 1998/06/21 16:39:10 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/libpq/pqcomm.c,v 1.50 1998/07/26 04:30:28 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
* pq_getinserv - initialize address from host and service name
* pq_connect - create remote input / output connection
* pq_accept - accept remote input / output connection
- * pq_async_notify - receive notification from backend.
*
* NOTES
* These functions are used by both frontend applications and
#include "libpq/auth.h"
#include "libpq/libpq.h" /* where the declarations go */
#include "storage/ipc.h"
-#ifdef MB
-#include "commands/variable.h"
+#ifdef MULTIBYTE
+#include "mb/pg_wchar.h"
#endif
/* ----------------
FILE *Pfout,
*Pfin;
FILE *Pfdebug; /* debugging libpq */
-int PQAsyncNotifyWaiting; /* for async. notification */
/* --------------------------------
* pq_init - open portal file descriptors
fclose(Pfout);
Pfout = NULL;
}
- PQAsyncNotifyWaiting = 0;
PQnotifies_init();
- pq_unregoob();
}
/* --------------------------------
{
int c = '\0';
-#ifdef MB
+#ifdef MULTIBYTE
unsigned char *p, *ps;
int len;
*s++ = c;
*s = '\0';
-#ifdef MB
+#ifdef MULTIBYTE
p = pg_client_to_server(ps, len);
if (ps != p) { /* actual conversion has been done? */
strcpy(ps, p);
void
pq_putstr(char *s)
{
-#ifdef MB
+#ifdef MULTIBYTE
unsigned char *p;
p = pg_server_to_client(s, strlen(s));
}
}
-/* ---
- * pq_sendoob - send a string over the out-of-band channel
- * pq_recvoob - receive a string over the oob channel
- * NB: Fortunately, the out-of-band channel doesn't conflict with
- * buffered I/O because it is separate from regular com. channel.
- * ---
- */
-int
-pq_sendoob(char *msg, int len)
-{
- int fd = fileno(Pfout);
-
- return send(fd, msg, len, MSG_OOB);
-}
-
-int
-pq_recvoob(char *msgPtr, int len)
-{
- int fd = fileno(Pfout);
-
- return recv(fd, msgPtr, len, MSG_OOB);
-}
-
/* --------------------------------
* pq_getinaddr - initialize address from host and port number
* --------------------------------
return (pq_getinaddr(sin, host, ntohs(ss->s_port)));
}
-/*
- * register an out-of-band listener proc--at most one allowed.
- * This is used for receiving async. notification from the backend.
- */
-void
-pq_regoob(void (*fptr) ())
-{
- int fd = fileno(Pfout);
-
-#if defined(hpux)
- ioctl(fd, FIOSSAIOOWN, MyProcPid);
-#elif defined(sco)
- ioctl(fd, SIOCSPGRP, MyProcPid);
-#else
- fcntl(fd, F_SETOWN, MyProcPid);
-#endif /* hpux */
- pqsignal(SIGURG, fptr);
-}
-
-void
-pq_unregoob()
-{
- pqsignal(SIGURG, SIG_DFL);
-}
-
-
-void
-pq_async_notify()
-{
- char msg[20];
-
- /* int len = sizeof(msg); */
- int len = 20;
-
- if (pq_recvoob(msg, len) >= 0)
- {
- /* debugging */
- printf("received notification: %s\n", msg);
- PQAsyncNotifyWaiting = 1;
- /* PQappendNotify(msg+1); */
- }
- else
- {
- extern int errno;
-
- printf("SIGURG but no data: len = %d, err=%d\n", len, errno);
- }
-}
-
/*
* Streams -- wrapper around Unix socket system calls
*
pqdebug("%s", PQerrormsg);
return (STATUS_ERROR);
}
- bzero(&saddr, sizeof(saddr));
+ MemSet((char *) &saddr, 0, sizeof(saddr));
saddr.sa.sa_family = family;
if (family == AF_UNIX)
{
}
if (family == AF_UNIX)
- on_exitpg(StreamDoUnlink, NULL);
+ on_proc_exit(StreamDoUnlink, NULL);
listen(fd, SOMAXCONN);
return (STATUS_OK);
}
-#ifdef MB
+#ifdef MULTIBYTE
void
pq_putncharlen(char *s, int n)
{