summaryrefslogtreecommitdiff
path: root/xc/lib/Xdmcp/Whead.c
blob: 980d92c1259890939bb1c9b7f410fa602436bd6c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*
 * $TOG: Whead.c /main/5 1998/02/06 14:41:48 kaleb $
 *
 * 
Copyright 1989, 1998  The Open Group

All Rights Reserved.

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Except as contained in this notice, the name of The Open Group shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
 * *
 * Author:  Keith Packard, MIT X Consortium
 */

/* $XFree86: xc/lib/Xdmcp/Whead.c,v 1.2 1998/10/10 15:25:17 dawes Exp $ */

#include <X11/Xos.h>
#include <X11/X.h>
#include <X11/Xmd.h>
#include <X11/Xdmcp.h>

int
XdmcpWriteHeader (
    XdmcpBufferPtr  buffer,
    XdmcpHeaderPtr  header)
{
    BYTE    *newData;

    if ((int)buffer->size < 6 + (int)header->length)
    {
	newData = (BYTE *) Xalloc (XDM_MAX_MSGLEN * sizeof (BYTE));
	if (!newData)
	    return FALSE;
	Xfree ((unsigned long *)(buffer->data));
	buffer->data = newData;
	buffer->size = XDM_MAX_MSGLEN;
    }
    buffer->pointer = 0;
    if (!XdmcpWriteCARD16 (buffer, header->version))
	return FALSE;
    if (!XdmcpWriteCARD16 (buffer, header->opcode))
	return FALSE;
    if (!XdmcpWriteCARD16 (buffer, header->length))
	return FALSE;
    return TRUE;
}