diff options
author | dawes <dawes> | 1994-05-08 05:15:39 +0000 |
---|---|---|
committer | dawes <dawes> | 1994-05-08 05:15:39 +0000 |
commit | 26cbaf0592d91707c44f5c48a507b38b7a0e22ce (patch) | |
tree | 4920b459790ab7061f831482a69ee278430ed261 | |
parent | 40b49d595726bf76151b26de64e9a716aa596c2e (diff) |
Minix support + SVR4/STREAMSCONN hack
-rw-r--r-- | lib/Xdmcp/Fill.c | 56 | ||||
-rw-r--r-- | lib/Xdmcp/Flush.c | 42 |
2 files changed, 98 insertions, 0 deletions
diff --git a/lib/Xdmcp/Fill.c b/lib/Xdmcp/Fill.c index 09fa5ee14..0309a216b 100644 --- a/lib/Xdmcp/Fill.c +++ b/lib/Xdmcp/Fill.c @@ -1,5 +1,6 @@ /* * $XConsortium: Fill.c,v 1.9 94/04/17 20:16:35 rws Exp $ + * $XFree86$ * * Copyright (c) 1989 X Consortium @@ -28,6 +29,12 @@ in this Software without prior written authorization from the X Consortium. * Author: Keith Packard, MIT X Consortium */ +/* Hack for SVR4 -- use TCPCONN */ +#ifdef STREAMSCONN +#undef STREAMSCONN +#define TCPCONN +#endif + #ifdef WIN32 #define _WILLWINSOCK_ #endif @@ -44,10 +51,13 @@ in this Software without prior written authorization from the X Consortium. #include <winsock.h> #undef BOOL #else +#ifndef MINIX #include <sys/socket.h> +#endif /* !MINIX */ #endif #endif +#ifndef MINIX int XdmcpFill (fd, buffer, from, fromlen) int fd; @@ -94,3 +104,49 @@ XdmcpFill (fd, buffer, from, fromlen) } return TRUE; } +#else /* MINIX */ +int +MNX_XdmcpFill (fd, buffer, from, fromlen, data, datalen) + int fd; + XdmcpBufferPtr buffer; + XdmcpNetaddr from; /* return */ + int *fromlen; /* return */ + char *data; + int datalen; +{ + BYTE *newBuf; + struct sockaddr_in *from_addr; + udp_io_hdr_t *udp_io_hdr; + + if (buffer->size < XDM_MAX_MSGLEN) + { + newBuf = (BYTE *) Xalloc (XDM_MAX_MSGLEN); + if (newBuf) + { + Xfree (buffer->data); + buffer->data = newBuf; + buffer->size = XDM_MAX_MSGLEN; + } + } + buffer->pointer = 0; + udp_io_hdr= (udp_io_hdr_t *)data; + data += sizeof(udp_io_hdr_t) + udp_io_hdr->uih_ip_opt_len; + datalen -= sizeof(udp_io_hdr_t) + udp_io_hdr->uih_ip_opt_len; + buffer->count= udp_io_hdr->uih_data_len; + if (buffer->count > datalen) + { + buffer->count= 0; + return FALSE; + } + bcopy(data, (char *)buffer->data, buffer->count); + from_addr= (struct sockaddr_in *)from; + from_addr->sin_family= AF_INET; + from_addr->sin_addr.s_addr= udp_io_hdr->uih_src_addr; + from_addr->sin_port= udp_io_hdr->uih_src_port; + if (buffer->count < 6) { + buffer->count = 0; + return FALSE; + } + return TRUE; +} +#endif /* !MINIX */ diff --git a/lib/Xdmcp/Flush.c b/lib/Xdmcp/Flush.c index 10a3b300f..ce23a9370 100644 --- a/lib/Xdmcp/Flush.c +++ b/lib/Xdmcp/Flush.c @@ -1,5 +1,6 @@ /* * $XConsortium: Flush.c,v 1.10 94/04/17 20:16:35 rws Exp $ + * $XFree86$ * * Copyright (c) 1989 X Consortium @@ -28,6 +29,12 @@ in this Software without prior written authorization from the X Consortium. * Author: Keith Packard, MIT X Consortium */ +/* Hack for SVR4 -- use TCPCONN */ +#ifdef STREAMSCONN +#undef STREAMSCONN +#define TCPCONN +#endif + #ifdef WIN32 #define _WILLWINSOCK_ #endif @@ -44,7 +51,9 @@ in this Software without prior written authorization from the X Consortium. #include <winsock.h> #undef BOOL #else +#ifndef MINIX #include <sys/socket.h> +#endif /* !MINIX */ #endif #endif @@ -56,6 +65,12 @@ XdmcpFlush (fd, buffer, to, tolen) int tolen; { int result; +#ifdef MINIX + struct sockaddr_in *to_addr; + char *b; + udp_io_hdr_t *udp_io_hdr; + int flags, s_errno; +#endif /* MINIX */ #ifdef STREAMSCONN struct t_unitdata dataunit; @@ -69,10 +84,37 @@ XdmcpFlush (fd, buffer, to, tolen) if (result < 0) return FALSE; #else +#ifndef MINIX result = sendto (fd, (char *)buffer->data, buffer->pointer, 0, (struct sockaddr *)to, tolen); if (result != buffer->pointer) return FALSE; +#else /* MINIX */ + to_addr= (struct sockaddr_in *)to; + b= (char *)Xalloc(buffer->pointer + sizeof(udp_io_hdr_t)); + if (b == NULL) + return FALSE; + udp_io_hdr= (udp_io_hdr_t *)b; + bcopy((char *)buffer->data, b+sizeof(udp_io_hdr_t), buffer->pointer); + udp_io_hdr->uih_dst_addr= to_addr->sin_addr.s_addr; + udp_io_hdr->uih_dst_port= to_addr->sin_port; + udp_io_hdr->uih_ip_opt_len= 0; + udp_io_hdr->uih_data_len= buffer->pointer; + + /* Make the write synchronous by turning of asynch I/O */ + flags= fcntl(fd, F_GETFD); + fcntl(fd, F_SETFD, flags & ~FD_ASYNCHIO); + result= write(fd, b, buffer->pointer + sizeof(udp_io_hdr_t)); + s_errno= errno; + Xfree(b); + fcntl(fd, F_SETFD, flags); + if (result != buffer->pointer + sizeof(udp_io_hdr_t)) + { + ErrorF("XdmcpFlush: unable to write: %d, '%s'\n", result, + strerror(s_errno)); + return FALSE; + } +#endif /* MINIX */ #endif return TRUE; } |