Flush.c revision 7a3b38f7
1ff559fabSmrg/*
2ff559fabSmrg * $Xorg: Flush.c,v 1.4 2001/02/09 02:03:48 xorgcvs Exp $
3ff559fabSmrg *
4ff559fabSmrg *
5ff559fabSmrgCopyright 1989, 1998  The Open Group
6ff559fabSmrg
7ff559fabSmrgPermission to use, copy, modify, distribute, and sell this software and its
8ff559fabSmrgdocumentation for any purpose is hereby granted without fee, provided that
9ff559fabSmrgthe above copyright notice appear in all copies and that both that
10ff559fabSmrgcopyright notice and this permission notice appear in supporting
11ff559fabSmrgdocumentation.
12ff559fabSmrg
13ff559fabSmrgThe above copyright notice and this permission notice shall be included in
14ff559fabSmrgall copies or substantial portions of the Software.
15ff559fabSmrg
16ff559fabSmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17ff559fabSmrgIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18ff559fabSmrgFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
19ff559fabSmrgOPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
20ff559fabSmrgAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21ff559fabSmrgCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22ff559fabSmrg
23ff559fabSmrgExcept as contained in this notice, the name of The Open Group shall not be
24ff559fabSmrgused in advertising or otherwise to promote the sale, use or other dealings
25ff559fabSmrgin this Software without prior written authorization from The Open Group.
26ff559fabSmrg * *
27ff559fabSmrg * Author:  Keith Packard, MIT X Consortium
28ff559fabSmrg */
29ff559fabSmrg
30ff559fabSmrg/* $XFree86: xc/lib/Xdmcp/Flush.c,v 3.7 2001/07/23 13:15:42 dawes Exp $ */
31ff559fabSmrg
32ff559fabSmrg#ifdef WIN32
33ff559fabSmrg#define _WILLWINSOCK_
34ff559fabSmrg#endif
35ff559fabSmrg#ifdef HAVE_CONFIG_H
36ff559fabSmrg#include <config.h>
37ff559fabSmrg#endif
38ff559fabSmrg#include <X11/Xos.h>
39ff559fabSmrg#include <X11/X.h>
40ff559fabSmrg#include <X11/Xmd.h>
41ff559fabSmrg#include <X11/Xdmcp.h>
42ff559fabSmrg
43ff559fabSmrg#ifdef STREAMSCONN
44ff559fabSmrg#include <tiuser.h>
45ff559fabSmrg#else
46ff559fabSmrg#ifdef WIN32
47ff559fabSmrg#include <X11/Xwinsock.h>
48ff559fabSmrg#else
49ff559fabSmrg#ifndef Lynx
50ff559fabSmrg#include <sys/socket.h>
51ff559fabSmrg#else
52ff559fabSmrg#include <socket.h>
53ff559fabSmrg#endif /* !Lynx */
54ff559fabSmrg#endif
55ff559fabSmrg#endif
56ff559fabSmrg
57ff559fabSmrgint
587a3b38f7SmrgXdmcpFlush (int fd, XdmcpBufferPtr buffer, XdmcpNetaddr to, int tolen)
59ff559fabSmrg{
60ff559fabSmrg    int result;
61ff559fabSmrg#ifdef STREAMSCONN
62ff559fabSmrg    struct t_unitdata dataunit;
63ff559fabSmrg
64ff559fabSmrg    dataunit.addr.buf = to;
65ff559fabSmrg    dataunit.addr.len = tolen;
66ff559fabSmrg    dataunit.opt.len = 0;	/* default options */
67ff559fabSmrg    dataunit.udata.buf = (char *)buffer->data;
68ff559fabSmrg    dataunit.udata.len = buffer->pointer;
69ff559fabSmrg    result = t_sndudata(fd, &dataunit);
70ff559fabSmrg    if (result < 0)
71ff559fabSmrg	return FALSE;
72ff559fabSmrg#else
73ff559fabSmrg    result = sendto (fd, (char *)buffer->data, buffer->pointer, 0,
74ff559fabSmrg		     (struct sockaddr *)to, tolen);
75ff559fabSmrg    if (result != buffer->pointer)
76ff559fabSmrg	return FALSE;
77ff559fabSmrg#endif
78ff559fabSmrg    return TRUE;
79ff559fabSmrg}
80