|
9 | 9 | * Portions Copyright (c) 1996-2000, PostgreSQL, Inc |
10 | 10 | * Portions Copyright (c) 1994, Regents of the University of California |
11 | 11 | * |
12 | | - * $Id: pqcomm.h,v 1.48 2000/11/22 02:47:30 momjian Exp $ |
| 12 | + * $Id: pqcomm.h,v 1.49 2000/11/22 03:40:19 momjian Exp $ |
13 | 13 | * |
14 | 14 | *------------------------------------------------------------------------- |
15 | 15 | */ |
@@ -51,17 +51,16 @@ typedef union SockAddr |
51 | 51 | /* Configure the UNIX socket address for the well known port. */ |
52 | 52 |
|
53 | 53 | #if defined(SUN_LEN) |
54 | | -#define UNIXSOCK_PATH(sun,port,defpath) \ |
55 | | - ((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))) |
56 | 54 | #define UNIXSOCK_LEN(sun) \ |
57 | 55 | (SUN_LEN(&(sun))) |
58 | 56 | #else |
59 | | -#define UNIXSOCK_PATH(sun,port,defpath) \ |
60 | | - ((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))) |
61 | 57 | #define UNIXSOCK_LEN(sun) \ |
62 | 58 | (strlen((sun).sun_path)+ offsetof(struct sockaddr_un, sun_path)) |
63 | 59 | #endif |
64 | 60 |
|
| 61 | +#define UNIXSOCK_PATH(sun,port,defpath) \ |
| 62 | + (sprintf((sun).sun_path, "%s/.s.PGSQL.%d", ((defpath) && *(defpath) != '\0') ? (defpath) : "/tmp", (port))) |
| 63 | + |
65 | 64 | /* |
66 | 65 | * We do this because sun_len is in BSD's struct, while others don't. |
67 | 66 | * We never actually set BSD's sun_len, and I can't think of a |
|
0 commit comments