98 #if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VMS) || defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_NETWARE) || defined(OPENSSL_SYS_VOS) || defined(OPENSSL_SYS_BEOS)
114 #include OPENSSL_UNISTD
115 #include <sys/types.h>
116 #include <sys/socket.h>
118 # ifdef OPENSSL_SYS_VXWORKS
119 # include <streams/un.h>
133 # define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
139 struct sockaddr_un addr;
143 unsigned char egdbuf[2], tempbuf[255], *retrievebuf;
145 memset(&addr, 0,
sizeof(addr));
146 addr.sun_family = AF_UNIX;
147 if (strlen(path) >=
sizeof(addr.sun_path))
149 BUF_strlcpy(addr.sun_path,path,
sizeof addr.sun_path);
150 len =
offsetof(
struct sockaddr_un, sun_path) + strlen(path);
151 fd = socket(AF_UNIX, SOCK_STREAM, 0);
152 if (fd == -1)
return (-1);
156 if (connect(fd, (
struct sockaddr *)&addr, len) == 0)
190 egdbuf[1] = bytes < 255 ? bytes : 255;
192 while (numbytes != 2)
194 num = write(fd, egdbuf + numbytes, 2 - numbytes);
216 while (numbytes != 1)
218 num =
read(fd, egdbuf, 1);
244 retrievebuf = buf + ret;
246 retrievebuf = tempbuf;
248 while (numbytes != egdbuf[0])
250 num =
read(fd, retrievebuf + numbytes, egdbuf[0] - numbytes);
279 if (fd != -1) close(fd);
289 if (num < 1)
goto err;