upload tizen1.0 source
[framework/uifw/xorg/lib/libxdmcp.git] / Flush.c
1 /*
2 Copyright 1989, 1998  The Open Group
3
4 Permission to use, copy, modify, distribute, and sell this software and its
5 documentation for any purpose is hereby granted without fee, provided that
6 the above copyright notice appear in all copies and that both that
7 copyright notice and this permission notice appear in supporting
8 documentation.
9
10 The above copyright notice and this permission notice shall be included in
11 all copies or substantial portions of the Software.
12
13 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
16 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
17 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19
20 Except as contained in this notice, the name of The Open Group shall not be
21 used in advertising or otherwise to promote the sale, use or other dealings
22 in this Software without prior written authorization from The Open Group.
23  * *
24  * Author:  Keith Packard, MIT X Consortium
25  */
26
27 #ifdef WIN32
28 #define _WILLWINSOCK_
29 #endif
30 #ifdef HAVE_CONFIG_H
31 #include <config.h>
32 #endif
33 #include <X11/Xos.h>
34 #include <X11/X.h>
35 #include <X11/Xmd.h>
36 #include <X11/Xdmcp.h>
37
38 #ifdef STREAMSCONN
39 #include <tiuser.h>
40 #else
41 #ifdef WIN32
42 #include <X11/Xwinsock.h>
43 #else
44 #include <sys/socket.h>
45 #endif
46 #endif
47
48 int
49 XdmcpFlush (int fd, XdmcpBufferPtr buffer, XdmcpNetaddr to, int tolen)
50 {
51     int result;
52 #ifdef STREAMSCONN
53     struct t_unitdata dataunit;
54
55     dataunit.addr.buf = to;
56     dataunit.addr.len = tolen;
57     dataunit.opt.len = 0;       /* default options */
58     dataunit.udata.buf = (char *)buffer->data;
59     dataunit.udata.len = buffer->pointer;
60     result = t_sndudata(fd, &dataunit);
61     if (result < 0)
62         return FALSE;
63 #else
64     result = sendto (fd, (char *)buffer->data, buffer->pointer, 0,
65                      (struct sockaddr *)to, tolen);
66     if (result != buffer->pointer)
67         return FALSE;
68 #endif
69     return TRUE;
70 }