1ff559fabSmrg/*
2ff559fabSmrgCopyright 1989, 1998  The Open Group
3ff559fabSmrg
4ff559fabSmrgPermission to use, copy, modify, distribute, and sell this software and its
5ff559fabSmrgdocumentation for any purpose is hereby granted without fee, provided that
6ff559fabSmrgthe above copyright notice appear in all copies and that both that
7ff559fabSmrgcopyright notice and this permission notice appear in supporting
8ff559fabSmrgdocumentation.
9ff559fabSmrg
10ff559fabSmrgThe above copyright notice and this permission notice shall be included in
11ff559fabSmrgall copies or substantial portions of the Software.
12ff559fabSmrg
13ff559fabSmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14ff559fabSmrgIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15ff559fabSmrgFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
16ff559fabSmrgOPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
17ff559fabSmrgAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18ff559fabSmrgCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19ff559fabSmrg
20ff559fabSmrgExcept as contained in this notice, the name of The Open Group shall not be
21ff559fabSmrgused in advertising or otherwise to promote the sale, use or other dealings
22ff559fabSmrgin this Software without prior written authorization from The Open Group.
23ff559fabSmrg * *
24ff559fabSmrg * Author:  Keith Packard, MIT X Consortium
25ff559fabSmrg */
26ff559fabSmrg
27ff559fabSmrg#ifdef WIN32
28ff559fabSmrg#define _WILLWINSOCK_
29ff559fabSmrg#endif
30ff559fabSmrg#ifdef HAVE_CONFIG_H
31ff559fabSmrg#include <config.h>
32ff559fabSmrg#endif
33ff559fabSmrg#include <X11/Xos.h>
34ff559fabSmrg#include <X11/X.h>
35ff559fabSmrg#include <X11/Xmd.h>
36ff559fabSmrg#include <X11/Xdmcp.h>
3744dda7b2Smrg#include <stdlib.h>
38ff559fabSmrg
39ff559fabSmrg#ifdef WIN32
40ff559fabSmrg#include <X11/Xwinsock.h>
41ff559fabSmrg#else
42ff559fabSmrg#include <sys/socket.h>
43ff559fabSmrg#endif
44ff559fabSmrg
45ff559fabSmrgint
467a3b38f7SmrgXdmcpFill (int fd, XdmcpBufferPtr buffer, XdmcpNetaddr from, int *fromlen)
47ff559fabSmrg{
48ff559fabSmrg    BYTE    *newBuf;
49ff559fabSmrg
50ff559fabSmrg    if (buffer->size < XDM_MAX_MSGLEN)
51ff559fabSmrg    {
5244dda7b2Smrg	newBuf = (BYTE *) malloc(XDM_MAX_MSGLEN);
53ff559fabSmrg	if (newBuf)
54ff559fabSmrg	{
5544dda7b2Smrg	    free(buffer->data);
56ff559fabSmrg	    buffer->data = newBuf;
57ff559fabSmrg	    buffer->size = XDM_MAX_MSGLEN;
58ff559fabSmrg	}
59ff559fabSmrg    }
60ff559fabSmrg    buffer->pointer = 0;
61ff559fabSmrg    buffer->count = recvfrom (fd, (char*)buffer->data, buffer->size, 0,
62ff559fabSmrg			      (struct sockaddr *)from, (void *)fromlen);
63ff559fabSmrg    if (buffer->count < 6) {
64ff559fabSmrg	buffer->count = 0;
65ff559fabSmrg	return FALSE;
66ff559fabSmrg    }
67ff559fabSmrg    return TRUE;
68ff559fabSmrg}
69