|
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.47 2000/11/22 02:38:25 momjian Exp $ |
| 12 | + * $Id: pqcomm.h,v 1.48 2000/11/22 02:47:30 momjian Exp $ |
13 | 13 | * |
14 | 14 | *------------------------------------------------------------------------- |
15 | 15 | */ |
@@ -51,16 +51,17 @@ 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))) |
54 | 56 | #define UNIXSOCK_LEN(sun) \ |
55 | 57 | (SUN_LEN(&(sun))) |
56 | 58 | #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))) |
57 | 61 | #define UNIXSOCK_LEN(sun) \ |
58 | 62 | (strlen((sun).sun_path)+ offsetof(struct sockaddr_un, sun_path)) |
59 | 63 | #endif |
60 | 64 |
|
61 | | -#define UNIXSOCK_PATH(sun,port,defpath) \ |
62 | | - (snprintf((sun).sun_path, UNIXSOCK_LEN(sun), "/tmp/.s.PGSQL.%d", (port))) |
63 | | - |
64 | 65 | /* |
65 | 66 | * We do this because sun_len is in BSD's struct, while others don't. |
66 | 67 | * We never actually set BSD's sun_len, and I can't think of a |
|
0 commit comments