Back out socket path until it works.
authorBruce Momjian <bruce@momjian.us>
Wed, 22 Nov 2000 02:47:30 +0000 (02:47 +0000)
committerBruce Momjian <bruce@momjian.us>
Wed, 22 Nov 2000 02:47:30 +0000 (02:47 +0000)
src/include/libpq/pqcomm.h

index 93c872266bec8003fcc354ca3ac1e939af378d7a..02edc1d22d947ff992383c61f36443022fe129c0 100644 (file)
@@ -51,16 +51,17 @@ typedef union SockAddr
 /* Configure the UNIX socket address for the well known port. */
 
 #if defined(SUN_LEN)
+#define UNIXSOCK_PATH(sun,port,defpath) \
+        ((defpath && defpath[0] != '\0') ? (strncpy((sun).sun_path, defpath, sizeof((sun).sun_path)), (sun).sun_path[sizeof((sun).sun_path)-1] = '\0') : sprintf((sun).sun_path, "/tmp/.s.PGSQL.%d", (port)))
 #define UNIXSOCK_LEN(sun) \
         (SUN_LEN(&(sun)))
 #else
+#define UNIXSOCK_PATH(sun,port,defpath) \
+        ((defpath && defpath[0] != '\0') ? (strncpy((sun).sun_path, defpath, sizeof((sun).sun_path)), (sun).sun_path[sizeof((sun).sun_path)-1] = '\0') : sprintf((sun).sun_path, "/tmp/.s.PGSQL.%d", (port)))
 #define UNIXSOCK_LEN(sun) \
         (strlen((sun).sun_path)+ offsetof(struct sockaddr_un, sun_path))
 #endif
 
-#define UNIXSOCK_PATH(sun,port,defpath) \
-        (snprintf((sun).sun_path, UNIXSOCK_LEN(sun), "/tmp/.s.PGSQL.%d", (port)))
-
 /*
  *             We do this because sun_len is in BSD's struct, while others don't.
  *             We never actually set BSD's sun_len, and I can't think of a