aboutsummaryrefslogtreecommitdiffstats
path: root/socket.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2000-12-06 17:42:23 +0000
committerEric S. Raymond <esr@thyrsus.com>2000-12-06 17:42:23 +0000
commit012d86a81392ac10183b2cc7abe7f06132fc30b6 (patch)
treedad070209f49b1cc1abbb59ee69eba7d14a6fecb /socket.c
parent6da7693ce8c3391c5b7e1cf61edd89a4179961a8 (diff)
downloadfetchmail-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.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/socket.c b/socket.c
index 3777e6d9..26a46c2a 100644
--- a/socket.c
+++ b/socket.c
@@ -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)