2 Copyright 1989, 1998 The Open Group
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
10 The above copyright notice and this permission notice shall be included in
11 all copies or substantial portions of the Software.
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.
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.
24 * Author: Keith Packard, MIT X Consortium
33 #include <X11/Xdmcp.h>
38 XdmcpBufferPtr buffer,
39 const XdmcpHeaderPtr header)
43 if ((int)buffer->size < 6 + (int)header->length)
45 newData = (BYTE *) malloc(XDM_MAX_MSGLEN * sizeof (BYTE));
48 free((unsigned long *)(buffer->data));
49 buffer->data = newData;
50 buffer->size = XDM_MAX_MSGLEN;
53 if (!XdmcpWriteCARD16 (buffer, header->version))
55 if (!XdmcpWriteCARD16 (buffer, header->opcode))
57 if (!XdmcpWriteCARD16 (buffer, header->length))
63 XdmcpWriteARRAY8 (XdmcpBufferPtr buffer, const ARRAY8Ptr array)
67 if (!XdmcpWriteCARD16 (buffer, array->length))
69 for (i = 0; i < (int)array->length; i++)
70 if (!XdmcpWriteCARD8 (buffer, array->data[i]))
76 XdmcpWriteARRAY16 (XdmcpBufferPtr buffer, const ARRAY16Ptr array)
80 if (!XdmcpWriteCARD8 (buffer, array->length))
82 for (i = 0; i < (int)array->length; i++)
83 if (!XdmcpWriteCARD16 (buffer, array->data[i]))
89 XdmcpWriteARRAY32 (XdmcpBufferPtr buffer, const ARRAY32Ptr array)
93 if (!XdmcpWriteCARD8 (buffer, array->length))
95 for (i = 0; i < (int)array->length; i++)
96 if (!XdmcpWriteCARD32 (buffer, array->data[i]))
102 XdmcpWriteARRAYofARRAY8 (XdmcpBufferPtr buffer, ARRAYofARRAY8Ptr array)
106 if (!XdmcpWriteCARD8 (buffer, array->length))
108 for (i = 0; i < (int)array->length; i++)
109 if (!XdmcpWriteARRAY8 (buffer, &array->data[i]))
116 XdmcpBufferPtr buffer,
119 if (buffer->pointer >= buffer->size)
121 buffer->data[buffer->pointer++] = (BYTE) value;
127 XdmcpBufferPtr buffer,
130 if (!XdmcpWriteCARD8 (buffer, value >> 8))
132 if (!XdmcpWriteCARD8 (buffer, value & 0xff))
139 XdmcpBufferPtr buffer,
142 if (!XdmcpWriteCARD8 (buffer, value >> 24))
144 if (!XdmcpWriteCARD8 (buffer, (value >> 16) & 0xff))
146 if (!XdmcpWriteCARD8 (buffer, (value >> 8) & 0xff))
148 if (!XdmcpWriteCARD8 (buffer, value & 0xff))