diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2000-12-06 17:42:23 +0000 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2000-12-06 17:42:23 +0000 |
commit | 012d86a81392ac10183b2cc7abe7f06132fc30b6 (patch) | |
tree | dad070209f49b1cc1abbb59ee69eba7d14a6fecb /socket.c | |
parent | 6da7693ce8c3391c5b7e1cf61edd89a4179961a8 (diff) | |
download | fetchmail-012d86a81392ac10183b2cc7abe7f06132fc30b6.tar.gz fetchmail-012d86a81392ac10183b2cc7abe7f06132fc30b6.tar.bz2 fetchmail-012d86a81392ac10183b2cc7abe7f06132fc30b6.zip |
Samuel Leo's LMTP enhancement.
svn path=/trunk/; revision=2995
Diffstat (limited to 'socket.c')
-rw-r--r-- | socket.c | 26 |
1 files changed, 26 insertions, 0 deletions
@@ -18,6 +18,7 @@ #else #include <net/socket.h> #endif +#include <sys/un.h> #include <netinet/in.h> #ifdef HAVE_ARPA_INET_H #include <arpa/inet.h> @@ -188,6 +189,31 @@ int SockCheckOpen(int fd) } #endif /* __UNUSED__ */ +int UnixOpen(const char *path) +{ + int sock = -1; + struct sockaddr_un ad; + memset(&ad, 0, sizeof(ad)); + ad.sun_family = AF_UNIX; + strncpy(ad.sun_path, path, sizeof(ad.sun_path)-1); + + sock = socket( AF_UNIX, SOCK_STREAM, 0 ); + if (sock < 0) + { + h_errno = 0; + return -1; + } + if (connect(sock, (struct sockaddr *) &ad, sizeof(ad)) < 0) + { + int olderr = errno; + fm_close(sock); /* don't use SockClose, no traffic yet */ + h_errno = 0; + errno = olderr; + return -1; + } + return sock; +} + #if INET6_ENABLE int SockOpen(const char *host, const char *service, const char *options, const char *plugin) |