summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--xc/config/cf/host.def1
-rw-r--r--xc/lib/Xdmcp/A8Eq.c47
-rw-r--r--xc/lib/Xdmcp/AA16.c48
-rw-r--r--xc/lib/Xdmcp/AA32.c48
-rw-r--r--xc/lib/Xdmcp/AA8.c48
-rw-r--r--xc/lib/Xdmcp/Alloc.c63
-rw-r--r--xc/lib/Xdmcp/AofA8.c48
-rw-r--r--xc/lib/Xdmcp/CA8.c46
-rw-r--r--xc/lib/Xdmcp/CmpKey.c46
-rw-r--r--xc/lib/Xdmcp/DA16.c43
-rw-r--r--xc/lib/Xdmcp/DA32.c42
-rw-r--r--xc/lib/Xdmcp/DA8.c42
-rw-r--r--xc/lib/Xdmcp/DAofA8.c46
-rw-r--r--xc/lib/Xdmcp/DecKey.c46
-rw-r--r--xc/lib/Xdmcp/Fill.c99
-rw-r--r--xc/lib/Xdmcp/Flush.c80
-rw-r--r--xc/lib/Xdmcp/GenKey.c65
-rw-r--r--xc/lib/Xdmcp/Imakefile117
-rw-r--r--xc/lib/Xdmcp/IncKey.c46
-rw-r--r--xc/lib/Xdmcp/RA16.c69
-rw-r--r--xc/lib/Xdmcp/RA32.c69
-rw-r--r--xc/lib/Xdmcp/RA8.c69
-rw-r--r--xc/lib/Xdmcp/RAofA8.c72
-rw-r--r--xc/lib/Xdmcp/RC16.c49
-rw-r--r--xc/lib/Xdmcp/RC32.c53
-rw-r--r--xc/lib/Xdmcp/RC8.c44
-rw-r--r--xc/lib/Xdmcp/RHead.c45
-rw-r--r--xc/lib/Xdmcp/RR.c40
-rw-r--r--xc/lib/Xdmcp/RaA16.c48
-rw-r--r--xc/lib/Xdmcp/RaA32.c48
-rw-r--r--xc/lib/Xdmcp/RaA8.c48
-rw-r--r--xc/lib/Xdmcp/RaAoA8.c48
-rw-r--r--xc/lib/Xdmcp/Unwrap.c92
-rw-r--r--xc/lib/Xdmcp/WA16.c48
-rw-r--r--xc/lib/Xdmcp/WA32.c48
-rw-r--r--xc/lib/Xdmcp/WA8.c48
-rw-r--r--xc/lib/Xdmcp/WAofA8.c48
-rw-r--r--xc/lib/Xdmcp/WC16.c47
-rw-r--r--xc/lib/Xdmcp/WC32.c50
-rw-r--r--xc/lib/Xdmcp/WC8.c46
-rw-r--r--xc/lib/Xdmcp/Whead.c61
-rw-r--r--xc/lib/Xdmcp/Wrap.c130
-rw-r--r--xc/lib/Xdmcp/Wrap.h12
-rw-r--r--xc/lib/Xdmcp/Xdmcp.h178
44 files changed, 2531 insertions, 0 deletions
diff --git a/xc/config/cf/host.def b/xc/config/cf/host.def
index ab5ba6178..6aeec6ff9 100644
--- a/xc/config/cf/host.def
+++ b/xc/config/cf/host.def
@@ -93,6 +93,7 @@
#define BuildLibrariesForXServers NO
#define BuildLibrariesForConfigTools NO
#define BuildGLXLibrary YES
+#define BuildXdmcpLib YES
#define BuildXInputLib NO
#define BuildXIE NO
#define BuildPexExt NO
diff --git a/xc/lib/Xdmcp/A8Eq.c b/xc/lib/Xdmcp/A8Eq.c
new file mode 100644
index 000000000..dbb33c83f
--- /dev/null
+++ b/xc/lib/Xdmcp/A8Eq.c
@@ -0,0 +1,47 @@
+/*
+ * $Xorg: A8Eq.c,v 1.4 2001/02/09 02:03:48 xorgcvs Exp $
+ *
+ *
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+ */
+
+#include <X11/Xos.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xdmcp.h>
+
+int
+XdmcpARRAY8Equal (array1, array2)
+ ARRAY8Ptr array1, array2;
+{
+ int i;
+
+ if (array1->length != array2->length)
+ return FALSE;
+ for (i = 0; i < (int)array1->length; i++)
+ if (array1->data[i] != array2->data[i])
+ return FALSE;
+ return TRUE;
+}
diff --git a/xc/lib/Xdmcp/AA16.c b/xc/lib/Xdmcp/AA16.c
new file mode 100644
index 000000000..d1318e6cd
--- /dev/null
+++ b/xc/lib/Xdmcp/AA16.c
@@ -0,0 +1,48 @@
+/*
+ * $Xorg: AA16.c,v 1.4 2001/02/09 02:03:48 xorgcvs Exp $
+ *
+ *
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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/AA16.c,v 1.4 2001/12/14 19:54:54 dawes Exp $ */
+
+#include <X11/Xos.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xdmcp.h>
+
+int
+XdmcpAllocARRAY16 (ARRAY16Ptr array, int length)
+{
+ CARD16Ptr newData;
+
+ newData = (CARD16Ptr) Xalloc (length * sizeof (CARD16));
+ if (!newData)
+ return FALSE;
+ array->length = length;
+ array->data = newData;
+ return TRUE;
+}
diff --git a/xc/lib/Xdmcp/AA32.c b/xc/lib/Xdmcp/AA32.c
new file mode 100644
index 000000000..82f9fb10e
--- /dev/null
+++ b/xc/lib/Xdmcp/AA32.c
@@ -0,0 +1,48 @@
+/*
+ * $Xorg: AA32.c,v 1.4 2001/02/09 02:03:48 xorgcvs Exp $
+ *
+ *
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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/AA32.c,v 1.4 2001/12/14 19:54:54 dawes Exp $ */
+
+#include <X11/Xos.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xdmcp.h>
+
+int
+XdmcpAllocARRAY32 (ARRAY32Ptr array, int length)
+{
+ CARD32Ptr newData;
+
+ newData = (CARD32Ptr) Xalloc (length * sizeof (CARD32));
+ if (!newData)
+ return FALSE;
+ array->length = length;
+ array->data = newData;
+ return TRUE;
+}
diff --git a/xc/lib/Xdmcp/AA8.c b/xc/lib/Xdmcp/AA8.c
new file mode 100644
index 000000000..aace23bfa
--- /dev/null
+++ b/xc/lib/Xdmcp/AA8.c
@@ -0,0 +1,48 @@
+/*
+ * $Xorg: AA8.c,v 1.4 2001/02/09 02:03:48 xorgcvs Exp $
+ *
+ *
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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/AA8.c,v 1.4 2001/12/14 19:54:54 dawes Exp $ */
+
+#include <X11/Xos.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xdmcp.h>
+
+int
+XdmcpAllocARRAY8 (ARRAY8Ptr array, int length)
+{
+ CARD8Ptr newData;
+
+ newData = (CARD8Ptr) Xalloc (length * sizeof (CARD8));
+ if (!newData)
+ return FALSE;
+ array->length = length;
+ array->data = newData;
+ return TRUE;
+}
diff --git a/xc/lib/Xdmcp/Alloc.c b/xc/lib/Xdmcp/Alloc.c
new file mode 100644
index 000000000..f69a1f3f5
--- /dev/null
+++ b/xc/lib/Xdmcp/Alloc.c
@@ -0,0 +1,63 @@
+/*
+ * $Xorg: Alloc.c,v 1.4 2001/02/09 02:03:48 xorgcvs Exp $
+ *
+ *
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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/Alloc.c,v 3.5 2001/12/14 19:54:54 dawes Exp $ */
+
+/* stubs for use when Xalloc, Xrealloc and Xfree are not defined */
+
+#include <X11/Xos.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xdmcp.h>
+#include <stdlib.h>
+
+void *
+Xalloc (unsigned long amount)
+{
+ if (amount == 0)
+ amount = 1;
+ return malloc (amount);
+}
+
+void *
+Xrealloc (void *old, unsigned long amount)
+{
+ if (amount == 0)
+ amount = 1;
+ if (!old)
+ return malloc (amount);
+ return realloc ((char *) old, amount);
+}
+
+void
+Xfree (void *old)
+{
+ if (old)
+ free ((char *) old);
+}
diff --git a/xc/lib/Xdmcp/AofA8.c b/xc/lib/Xdmcp/AofA8.c
new file mode 100644
index 000000000..4338854db
--- /dev/null
+++ b/xc/lib/Xdmcp/AofA8.c
@@ -0,0 +1,48 @@
+/*
+ * $Xorg: AofA8.c,v 1.4 2001/02/09 02:03:48 xorgcvs Exp $
+ *
+ *
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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/AofA8.c,v 1.4 2001/12/14 19:54:54 dawes Exp $ */
+
+#include <X11/Xos.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xdmcp.h>
+
+int
+XdmcpAllocARRAYofARRAY8 (ARRAYofARRAY8Ptr array, int length)
+{
+ ARRAY8Ptr newData;
+
+ newData = (ARRAY8Ptr) Xalloc (length * sizeof (ARRAY8));
+ if (!newData)
+ return FALSE;
+ array->length = length;
+ array->data = newData;
+ return TRUE;
+}
diff --git a/xc/lib/Xdmcp/CA8.c b/xc/lib/Xdmcp/CA8.c
new file mode 100644
index 000000000..627e8242a
--- /dev/null
+++ b/xc/lib/Xdmcp/CA8.c
@@ -0,0 +1,46 @@
+/*
+ * $Xorg: CA8.c,v 1.4 2001/02/09 02:03:48 xorgcvs Exp $
+ *
+ *
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+ */
+
+#include <X11/Xos.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xdmcp.h>
+#include <X11/Xfuncs.h>
+
+int
+XdmcpCopyARRAY8 (src, dst)
+ ARRAY8Ptr src, dst;
+{
+ dst->length = src->length;
+ dst->data = (CARD8 *) Xalloc (dst->length * sizeof (CARD8));
+ if (!dst->data)
+ return FALSE;
+ memmove (dst->data, src->data, src->length * sizeof (CARD8));
+ return TRUE;
+}
diff --git a/xc/lib/Xdmcp/CmpKey.c b/xc/lib/Xdmcp/CmpKey.c
new file mode 100644
index 000000000..fedb422b2
--- /dev/null
+++ b/xc/lib/Xdmcp/CmpKey.c
@@ -0,0 +1,46 @@
+/*
+ * $Xorg: CmpKey.c,v 1.4 2001/02/09 02:03:48 xorgcvs Exp $
+ *
+ *
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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/CmpKey.c,v 1.4 2001/12/14 19:54:54 dawes Exp $ */
+
+#include <X11/Xos.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xdmcp.h>
+
+int
+XdmcpCompareKeys (XdmAuthKeyPtr a, XdmAuthKeyPtr b)
+{
+ int i;
+
+ for (i = 0; i < 8; i++)
+ if (a->data[i] != b->data[i])
+ return FALSE;
+ return TRUE;
+}
diff --git a/xc/lib/Xdmcp/DA16.c b/xc/lib/Xdmcp/DA16.c
new file mode 100644
index 000000000..32e951f1a
--- /dev/null
+++ b/xc/lib/Xdmcp/DA16.c
@@ -0,0 +1,43 @@
+/*
+ * $Xorg: DA16.c,v 1.4 2001/02/09 02:03:48 xorgcvs Exp $
+ *
+ *
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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/DA16.c,v 1.6 2001/12/14 19:54:54 dawes Exp $ */
+
+#include <X11/Xos.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xdmcp.h>
+
+void
+XdmcpDisposeARRAY16 (ARRAY16Ptr array)
+{
+ if (array->data != NULL) Xfree (array->data);
+ array->length = 0;
+ array->data = NULL;
+}
diff --git a/xc/lib/Xdmcp/DA32.c b/xc/lib/Xdmcp/DA32.c
new file mode 100644
index 000000000..e27842b1b
--- /dev/null
+++ b/xc/lib/Xdmcp/DA32.c
@@ -0,0 +1,42 @@
+/*
+ * $Xorg: DA32.c,v 1.4 2001/02/09 02:03:48 xorgcvs Exp $
+ *
+ *
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+ */
+
+#include <X11/Xos.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xdmcp.h>
+
+void
+XdmcpDisposeARRAY32 (array)
+ ARRAY32Ptr array;
+{
+ if (array->data != NULL) Xfree (array->data);
+ array->length = 0;
+ array->data = NULL;
+}
diff --git a/xc/lib/Xdmcp/DA8.c b/xc/lib/Xdmcp/DA8.c
new file mode 100644
index 000000000..a808d9a09
--- /dev/null
+++ b/xc/lib/Xdmcp/DA8.c
@@ -0,0 +1,42 @@
+/*
+ * $Xorg: DA8.c,v 1.4 2001/02/09 02:03:48 xorgcvs Exp $
+ *
+ *
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+ */
+
+#include <X11/Xos.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xdmcp.h>
+
+void
+XdmcpDisposeARRAY8 (array)
+ ARRAY8Ptr array;
+{
+ if (array->data != NULL) Xfree (array->data);
+ array->length = 0;
+ array->data = NULL;
+}
diff --git a/xc/lib/Xdmcp/DAofA8.c b/xc/lib/Xdmcp/DAofA8.c
new file mode 100644
index 000000000..0e818a3e9
--- /dev/null
+++ b/xc/lib/Xdmcp/DAofA8.c
@@ -0,0 +1,46 @@
+/*
+ * $Xorg: DAofA8.c,v 1.4 2001/02/09 02:03:48 xorgcvs Exp $
+ *
+ *
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+ */
+
+#include <X11/Xos.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xdmcp.h>
+
+void
+XdmcpDisposeARRAYofARRAY8 (array)
+ ARRAYofARRAY8Ptr array;
+{
+ int i;
+
+ for (i = 0; i < (int)array->length; i++)
+ XdmcpDisposeARRAY8 (&array->data[i]);
+ if (array->data != NULL) Xfree (array->data);
+ array->length = 0;
+ array->data = NULL;
+}
diff --git a/xc/lib/Xdmcp/DecKey.c b/xc/lib/Xdmcp/DecKey.c
new file mode 100644
index 000000000..14b363783
--- /dev/null
+++ b/xc/lib/Xdmcp/DecKey.c
@@ -0,0 +1,46 @@
+/*
+ * $Xorg: DecKey.c,v 1.4 2001/02/09 02:03:48 xorgcvs Exp $
+ *
+ *
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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/DecKey.c,v 1.4 2001/12/14 19:54:54 dawes Exp $ */
+
+#include <X11/Xos.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xdmcp.h>
+
+void
+XdmcpDecrementKey (XdmAuthKeyPtr key)
+{
+ int i;
+
+ i = 7;
+ while (key->data[i]-- == 0)
+ if (--i < 0)
+ break;
+}
diff --git a/xc/lib/Xdmcp/Fill.c b/xc/lib/Xdmcp/Fill.c
new file mode 100644
index 000000000..a5845de74
--- /dev/null
+++ b/xc/lib/Xdmcp/Fill.c
@@ -0,0 +1,99 @@
+/*
+ * $Xorg: Fill.c,v 1.4 2001/02/09 02:03:48 xorgcvs Exp $
+ *
+ *
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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/Fill.c,v 3.9 2001/12/14 19:54:54 dawes Exp $ */
+
+#ifdef WIN32
+#define _WILLWINSOCK_
+#endif
+#include <X11/Xos.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xdmcp.h>
+
+#ifdef STREAMSCONN
+#include <tiuser.h>
+#else
+#ifdef WIN32
+#include <X11/Xwinsock.h>
+#else
+#ifndef Lynx
+#include <sys/socket.h>
+#else
+#include <socket.h>
+#endif /* !Lynx */
+#endif
+#endif
+
+int
+XdmcpFill (fd, buffer, from, fromlen)
+ int fd;
+ XdmcpBufferPtr buffer;
+ XdmcpNetaddr from; /* return */
+ int *fromlen; /* return */
+{
+ BYTE *newBuf;
+#ifdef STREAMSCONN
+ struct t_unitdata dataunit;
+ int gotallflag, result;
+#endif
+
+ if (buffer->size < XDM_MAX_MSGLEN)
+ {
+ newBuf = (BYTE *) Xalloc (XDM_MAX_MSGLEN);
+ if (newBuf)
+ {
+ Xfree (buffer->data);
+ buffer->data = newBuf;
+ buffer->size = XDM_MAX_MSGLEN;
+ }
+ }
+ buffer->pointer = 0;
+#ifdef STREAMSCONN
+ dataunit.addr.buf = from;
+ dataunit.addr.maxlen = *fromlen;
+ dataunit.opt.maxlen = 0; /* don't care to know about options */
+ dataunit.udata.buf = (char *)buffer->data;
+ dataunit.udata.maxlen = buffer->size;
+ result = t_rcvudata (fd, &dataunit, &gotallflag);
+ if (result < 0) {
+ return FALSE;
+ }
+ buffer->count = dataunit.udata.len;
+ *fromlen = dataunit.addr.len;
+#else
+ buffer->count = recvfrom (fd, (char*)buffer->data, buffer->size, 0,
+ (struct sockaddr *)from, (void *)fromlen);
+#endif
+ if (buffer->count < 6) {
+ buffer->count = 0;
+ return FALSE;
+ }
+ return TRUE;
+}
diff --git a/xc/lib/Xdmcp/Flush.c b/xc/lib/Xdmcp/Flush.c
new file mode 100644
index 000000000..a83e27d21
--- /dev/null
+++ b/xc/lib/Xdmcp/Flush.c
@@ -0,0 +1,80 @@
+/*
+ * $Xorg: Flush.c,v 1.4 2001/02/09 02:03:48 xorgcvs Exp $
+ *
+ *
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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/Flush.c,v 3.8 2001/12/14 19:54:54 dawes Exp $ */
+
+#ifdef WIN32
+#define _WILLWINSOCK_
+#endif
+#include <X11/Xos.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xdmcp.h>
+
+#ifdef STREAMSCONN
+#include <tiuser.h>
+#else
+#ifdef WIN32
+#include <X11/Xwinsock.h>
+#else
+#ifndef Lynx
+#include <sys/socket.h>
+#else
+#include <socket.h>
+#endif /* !Lynx */
+#endif
+#endif
+
+int
+XdmcpFlush (fd, buffer, to, tolen)
+ int fd;
+ XdmcpBufferPtr buffer;
+ XdmcpNetaddr to;
+ int tolen;
+{
+ int result;
+#ifdef STREAMSCONN
+ struct t_unitdata dataunit;
+
+ dataunit.addr.buf = to;
+ dataunit.addr.len = tolen;
+ dataunit.opt.len = 0; /* default options */
+ dataunit.udata.buf = (char *)buffer->data;
+ dataunit.udata.len = buffer->pointer;
+ result = t_sndudata(fd, &dataunit);
+ if (result < 0)
+ return FALSE;
+#else
+ result = sendto (fd, (char *)buffer->data, buffer->pointer, 0,
+ (struct sockaddr *)to, tolen);
+ if (result != buffer->pointer)
+ return FALSE;
+#endif
+ return TRUE;
+}
diff --git a/xc/lib/Xdmcp/GenKey.c b/xc/lib/Xdmcp/GenKey.c
new file mode 100644
index 000000000..4769baa3b
--- /dev/null
+++ b/xc/lib/Xdmcp/GenKey.c
@@ -0,0 +1,65 @@
+/*
+ * $Xorg: GenKey.c,v 1.4 2001/02/09 02:03:48 xorgcvs Exp $
+ *
+ *
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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/GenKey.c,v 3.8 2001/12/14 19:54:54 dawes Exp $ */
+
+#include <X11/Xos.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xdmcp.h>
+
+static void
+getbits (long data, unsigned char *dst)
+{
+ dst[0] = (data ) & 0xff;
+ dst[1] = (data >> 8) & 0xff;
+ dst[2] = (data >> 16) & 0xff;
+ dst[3] = (data >> 24) & 0xff;
+}
+
+#define Time_t time_t
+
+#include <stdlib.h>
+
+#if defined(SYSV) || defined(SVR4)
+#define srandom srand48
+#define random lrand48
+#endif
+
+void
+XdmcpGenerateKey (XdmAuthKeyPtr key)
+{
+ long lowbits, highbits;
+
+ srandom ((int)getpid() ^ time((Time_t *)0));
+ lowbits = random ();
+ highbits = random ();
+ getbits (lowbits, key->data);
+ getbits (highbits, key->data + 4);
+}
diff --git a/xc/lib/Xdmcp/Imakefile b/xc/lib/Xdmcp/Imakefile
new file mode 100644
index 000000000..8b05c40f1
--- /dev/null
+++ b/xc/lib/Xdmcp/Imakefile
@@ -0,0 +1,117 @@
+XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:45:48 cpqbld Exp $
+
+
+
+
+XCOMM $XFree86: xc/lib/Xdmcp/Imakefile,v 3.5 2001/01/17 19:42:43 dawes Exp $
+
+#define DoNormalLib NormalLibXdmcp
+#define DoSharedLib SharedLibXdmcp
+#define DoExtraLib SharedLibXdmcp
+#define DoDebugLib DebugLibXdmcp
+#define DoProfileLib ProfileLibXdmcp
+#define LibName Xdmcp
+#define SoRev SOXDMCPREV
+#define IncSubdir X11
+
+#if HasXdmAuth
+AUTHDEFS = -DHASXDMAUTH
+AUTHSRCS = Wrap.c Unwrap.c Wraphelp.c
+AUTHOBJS = Wrap.o Unwrap.o Wraphelp.o
+#endif
+
+DEFINES = $(AUTHDEFS)
+
+HEADERS = Xdmcp.h
+
+SRCS = \
+ A8Eq.c \
+ AA8.c \
+ AA16.c \
+ AA32.c \
+ AofA8.c \
+ CA8.c \
+ DA8.c \
+ DA16.c \
+ DA32.c \
+ DAofA8.c \
+ Fill.c \
+ Flush.c \
+ RA8.c \
+ RA16.c \
+ RA32.c \
+ RAofA8.c \
+ RC8.c \
+ RC16.c \
+ RC32.c \
+ RHead.c \
+ RR.c \
+ RaA8.c \
+ RaA16.c \
+ RaA32.c \
+ RaAoA8.c \
+ WA8.c \
+ WA16.c \
+ WA32.c \
+ WAofA8.c \
+ WC8.c \
+ WC16.c \
+ WC32.c \
+ Whead.c \
+ Alloc.c \
+ CmpKey.c \
+ DecKey.c \
+ GenKey.c \
+ IncKey.c \
+ $(AUTHSRCS)
+
+OBJS = \
+ A8Eq.o \
+ AA8.o \
+ AA16.o \
+ AA32.o \
+ AofA8.o \
+ CA8.o \
+ DA8.o \
+ DA16.o \
+ DA32.o \
+ DAofA8.o \
+ Fill.o \
+ Flush.o \
+ RA8.o \
+ RA16.o \
+ RA32.o \
+ RAofA8.o \
+ RC8.o \
+ RC16.o \
+ RC32.o \
+ RHead.o \
+ RR.o \
+ RaA8.o \
+ RaA16.o \
+ RaA32.o \
+ RaAoA8.o \
+ WA8.o \
+ WA16.o \
+ WA32.o \
+ WAofA8.o \
+ WC8.o \
+ WC16.o \
+ WC32.o \
+ Whead.o \
+ Alloc.o \
+ CmpKey.o \
+ DecKey.o \
+ GenKey.o \
+ IncKey.o \
+ $(AUTHOBJS)
+
+#include <Library.tmpl>
+
+#ifdef WraphelpSourceRule
+WraphelpSourceRule()
+#endif
+SpecialCLibObjectRule(Fill,$(ICONFIGFILES),$(CONNECTION_FLAGS))
+SpecialCLibObjectRule(Flush,$(ICONFIGFILES),$(CONNECTION_FLAGS))
+
+DependTarget()
diff --git a/xc/lib/Xdmcp/IncKey.c b/xc/lib/Xdmcp/IncKey.c
new file mode 100644
index 000000000..1b2a7fd8e
--- /dev/null
+++ b/xc/lib/Xdmcp/IncKey.c
@@ -0,0 +1,46 @@
+/*
+ * $Xorg: IncKey.c,v 1.4 2001/02/09 02:03:48 xorgcvs Exp $
+ *
+ *
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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/IncKey.c,v 1.4 2001/12/14 19:54:54 dawes Exp $ */
+
+#include <X11/Xos.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xdmcp.h>
+
+void
+XdmcpIncrementKey (XdmAuthKeyPtr key)
+{
+ int i;
+
+ i = 7;
+ while (++key->data[i] == 0)
+ if (--i < 0)
+ break;
+}
diff --git a/xc/lib/Xdmcp/RA16.c b/xc/lib/Xdmcp/RA16.c
new file mode 100644
index 000000000..3453ce451
--- /dev/null
+++ b/xc/lib/Xdmcp/RA16.c
@@ -0,0 +1,69 @@
+/*
+ * $Xorg: RA16.c,v 1.5 2001/02/09 02:03:48 xorgcvs Exp $
+ *
+ *
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+ */
+
+#include <X11/Xos.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xdmcp.h>
+
+int
+XdmcpReadARRAY16 (buffer, array)
+ XdmcpBufferPtr buffer;
+ ARRAY16Ptr array;
+{
+ int i;
+
+ if (!XdmcpReadCARD8 (buffer, &array->length)) {
+
+ /* Must set array->data to NULL to guarantee safe call of
+ * XdmcpDisposeARRAY*(array) (which calls Xfree(array->data));
+ * see defect 7329 */
+ array->data = 0;
+ return FALSE;
+ }
+ if (!array->length)
+ {
+ array->data = NULL;
+ return TRUE;
+ }
+ array->data = (CARD16 *) Xalloc (array->length * sizeof (CARD16));
+ if (!array->data)
+ return FALSE;
+ for (i = 0; i < (int)array->length; i++)
+ {
+ if (!XdmcpReadCARD16 (buffer, &array->data[i]))
+ {
+ Xfree (array->data);
+ array->data = NULL;
+ array->length = 0;
+ return FALSE;
+ }
+ }
+ return TRUE;
+}
diff --git a/xc/lib/Xdmcp/RA32.c b/xc/lib/Xdmcp/RA32.c
new file mode 100644
index 000000000..21c078c10
--- /dev/null
+++ b/xc/lib/Xdmcp/RA32.c
@@ -0,0 +1,69 @@
+/*
+ * $Xorg: RA32.c,v 1.5 2001/02/09 02:03:48 xorgcvs Exp $
+ *
+ *
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+ */
+
+#include <X11/Xos.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xdmcp.h>
+
+int
+XdmcpReadARRAY32 (buffer, array)
+ XdmcpBufferPtr buffer;
+ ARRAY32Ptr array;
+{
+ int i;
+
+ if (!XdmcpReadCARD8 (buffer, &array->length)) {
+
+ /* Must set array->data to NULL to guarantee safe call of
+ * XdmcpDisposeARRAY*(array) (which calls Xfree(array->data));
+ * see defect 7329 */
+ array->data = 0;
+ return FALSE;
+ }
+ if (!array->length)
+ {
+ array->data = NULL;
+ return TRUE;
+ }
+ array->data = (CARD32 *) Xalloc (array->length * sizeof (CARD32));
+ if (!array->data)
+ return FALSE;
+ for (i = 0; i < (int)array->length; i++)
+ {
+ if (!XdmcpReadCARD32 (buffer, &array->data[i]))
+ {
+ Xfree (array->data);
+ array->data = NULL;
+ array->length = 0;
+ return FALSE;
+ }
+ }
+ return TRUE;
+}
diff --git a/xc/lib/Xdmcp/RA8.c b/xc/lib/Xdmcp/RA8.c
new file mode 100644
index 000000000..50a6d23aa
--- /dev/null
+++ b/xc/lib/Xdmcp/RA8.c
@@ -0,0 +1,69 @@
+/*
+ * $Xorg: RA8.c,v 1.5 2001/02/09 02:03:48 xorgcvs Exp $
+ *
+ *
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+ */
+
+#include <X11/Xos.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xdmcp.h>
+
+int
+XdmcpReadARRAY8 (buffer, array)
+ XdmcpBufferPtr buffer;
+ ARRAY8Ptr array;
+{
+ int i;
+
+ if (!XdmcpReadCARD16 (buffer, &array->length)) {
+
+ /* Must set array->data to NULL to guarantee safe call of
+ * XdmcpDisposeARRAY*(array) (which calls Xfree(array->data));
+ * see defect 7329 */
+ array->data = 0;
+ return FALSE;
+ }
+ if (!array->length)
+ {
+ array->data = NULL;
+ return TRUE;
+ }
+ array->data = (CARD8 *) Xalloc (array->length * sizeof (CARD8));
+ if (!array->data)
+ return FALSE;
+ for (i = 0; i < (int)array->length; i++)
+ {
+ if (!XdmcpReadCARD8 (buffer, &array->data[i]))
+ {
+ Xfree (array->data);
+ array->data = NULL;
+ array->length = 0;
+ return FALSE;
+ }
+ }
+ return TRUE;
+}
diff --git a/xc/lib/Xdmcp/RAofA8.c b/xc/lib/Xdmcp/RAofA8.c
new file mode 100644
index 000000000..b4b2ceaf2
--- /dev/null
+++ b/xc/lib/Xdmcp/RAofA8.c
@@ -0,0 +1,72 @@
+/*
+ * $Xorg: RAofA8.c,v 1.6 2001/02/09 02:03:48 xorgcvs Exp $
+ *
+ *
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+ */
+
+#include <X11/Xos.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xdmcp.h>
+
+int
+XdmcpReadARRAYofARRAY8 (buffer, array)
+ XdmcpBufferPtr buffer;
+ ARRAYofARRAY8Ptr array;
+{
+ int i;
+
+ if (!XdmcpReadCARD8 (buffer, &array->length)) {
+
+ /* Must set array->data to NULL to guarantee safe call of
+ * XdmcpDisposeARRAY*(array) (which calls Xfree(array->data));
+ * see defect 7329 */
+ array->data = 0;
+ return FALSE;
+ }
+ if (!array->length)
+ {
+ array->data = NULL;
+ return TRUE;
+ }
+ array->data = (ARRAY8 *) Xalloc (array->length * sizeof (ARRAY8));
+ if (!array->data)
+ return FALSE;
+ for (i = 0; i < (int)array->length; i++)
+ {
+ if (!XdmcpReadARRAY8 (buffer, &array->data[i]))
+ {
+
+ /* All arrays allocated thus far in the loop must be freed
+ * if there is an error in the read.
+ * See Defect 7328 */
+ array->length = i;
+ XdmcpDisposeARRAYofARRAY8(array);
+ return FALSE;
+ }
+ }
+ return TRUE;
+}
diff --git a/xc/lib/Xdmcp/RC16.c b/xc/lib/Xdmcp/RC16.c
new file mode 100644
index 000000000..ff2604dcd
--- /dev/null
+++ b/xc/lib/Xdmcp/RC16.c
@@ -0,0 +1,49 @@
+/*
+ * $Xorg: RC16.c,v 1.4 2001/02/09 02:03:48 xorgcvs Exp $
+ *
+ *
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+ */
+
+#include <X11/Xos.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xdmcp.h>
+
+int
+XdmcpReadCARD16 (buffer, valuep)
+ XdmcpBufferPtr buffer;
+ CARD16Ptr valuep;
+{
+ CARD8 high, low;
+
+ if (XdmcpReadCARD8 (buffer, &high) &&
+ XdmcpReadCARD8 (buffer, &low))
+ {
+ *valuep = (((CARD16) high) << 8) | ((CARD16) low);
+ return TRUE;
+ }
+ return FALSE;
+}
diff --git a/xc/lib/Xdmcp/RC32.c b/xc/lib/Xdmcp/RC32.c
new file mode 100644
index 000000000..a86556346
--- /dev/null
+++ b/xc/lib/Xdmcp/RC32.c
@@ -0,0 +1,53 @@
+/*
+ * $Xorg: RC32.c,v 1.4 2001/02/09 02:03:48 xorgcvs Exp $
+ *
+ *
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+ */
+
+#include <X11/Xos.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xdmcp.h>
+
+int
+XdmcpReadCARD32 (buffer, valuep)
+ XdmcpBufferPtr buffer;
+ CARD32Ptr valuep;
+{
+ CARD8 byte0, byte1, byte2, byte3;
+ if (XdmcpReadCARD8 (buffer, &byte0) &&
+ XdmcpReadCARD8 (buffer, &byte1) &&
+ XdmcpReadCARD8 (buffer, &byte2) &&
+ XdmcpReadCARD8 (buffer, &byte3))
+ {
+ *valuep = (((CARD32) byte0) << 24) |
+ (((CARD32) byte1) << 16) |
+ (((CARD32) byte2) << 8) |
+ (((CARD32) byte3));
+ return TRUE;
+ }
+ return FALSE;
+}
diff --git a/xc/lib/Xdmcp/RC8.c b/xc/lib/Xdmcp/RC8.c
new file mode 100644
index 000000000..7c3d11aba
--- /dev/null
+++ b/xc/lib/Xdmcp/RC8.c
@@ -0,0 +1,44 @@
+/*
+ * $Xorg: RC8.c,v 1.4 2001/02/09 02:03:48 xorgcvs Exp $
+ *
+ *
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+ */
+
+#include <X11/Xos.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xdmcp.h>
+
+int
+XdmcpReadCARD8 (buffer, valuep)
+ XdmcpBufferPtr buffer;
+ CARD8Ptr valuep;
+{
+ if (buffer->pointer >= buffer->count)
+ return FALSE;
+ *valuep = (CARD8) buffer->data[buffer->pointer++];
+ return TRUE;
+}
diff --git a/xc/lib/Xdmcp/RHead.c b/xc/lib/Xdmcp/RHead.c
new file mode 100644
index 000000000..b0af982ef
--- /dev/null
+++ b/xc/lib/Xdmcp/RHead.c
@@ -0,0 +1,45 @@
+/*
+ * $Xorg: RHead.c,v 1.4 2001/02/09 02:03:48 xorgcvs Exp $
+ *
+ *
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+ */
+
+#include <X11/Xos.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xdmcp.h>
+
+int
+XdmcpReadHeader (buffer, header)
+ XdmcpBufferPtr buffer;
+ XdmcpHeaderPtr header;
+{
+ if (XdmcpReadCARD16 (buffer, &header->version) &&
+ XdmcpReadCARD16 (buffer, &header->opcode) &&
+ XdmcpReadCARD16 (buffer, &header->length))
+ return TRUE;
+ return FALSE;
+}
diff --git a/xc/lib/Xdmcp/RR.c b/xc/lib/Xdmcp/RR.c
new file mode 100644
index 000000000..1fa1dca32
--- /dev/null
+++ b/xc/lib/Xdmcp/RR.c
@@ -0,0 +1,40 @@
+/*
+ * $Xorg: RR.c,v 1.4 2001/02/09 02:03:48 xorgcvs Exp $
+ *
+ *
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+ */
+
+#include <X11/Xos.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xdmcp.h>
+
+int
+XdmcpReadRemaining (buffer)
+ XdmcpBufferPtr buffer;
+{
+ return buffer->count - buffer->pointer;
+}
diff --git a/xc/lib/Xdmcp/RaA16.c b/xc/lib/Xdmcp/RaA16.c
new file mode 100644
index 000000000..fd1dbd891
--- /dev/null
+++ b/xc/lib/Xdmcp/RaA16.c
@@ -0,0 +1,48 @@
+/*
+ * $Xorg: RaA16.c,v 1.4 2001/02/09 02:03:48 xorgcvs Exp $
+ *
+ *
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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/RaA16.c,v 1.4 2001/12/14 19:54:55 dawes Exp $ */
+
+#include <X11/Xos.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xdmcp.h>
+
+int
+XdmcpReallocARRAY16 (ARRAY16Ptr array, int length)
+{
+ CARD16Ptr newData;
+
+ newData = (CARD16Ptr) Xrealloc (array->data, length * sizeof (CARD16));
+ if (!newData)
+ return FALSE;
+ array->length = length;
+ array->data = newData;
+ return TRUE;
+}
diff --git a/xc/lib/Xdmcp/RaA32.c b/xc/lib/Xdmcp/RaA32.c
new file mode 100644
index 000000000..dd6e72e83
--- /dev/null
+++ b/xc/lib/Xdmcp/RaA32.c
@@ -0,0 +1,48 @@
+/*
+ * $Xorg: RaA32.c,v 1.4 2001/02/09 02:03:48 xorgcvs Exp $
+ *
+ *
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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/RaA32.c,v 1.4 2001/12/14 19:54:55 dawes Exp $ */
+
+#include <X11/Xos.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xdmcp.h>
+
+int
+XdmcpReallocARRAY32 (ARRAY32Ptr array, int length)
+{
+ CARD32Ptr newData;
+
+ newData = (CARD32Ptr) Xrealloc (array->data, length * sizeof (CARD32));
+ if (!newData)
+ return FALSE;
+ array->length = length;
+ array->data = newData;
+ return TRUE;
+}
diff --git a/xc/lib/Xdmcp/RaA8.c b/xc/lib/Xdmcp/RaA8.c
new file mode 100644
index 000000000..f64ef6464
--- /dev/null
+++ b/xc/lib/Xdmcp/RaA8.c
@@ -0,0 +1,48 @@
+/*
+ * $Xorg: RaA8.c,v 1.4 2001/02/09 02:03:48 xorgcvs Exp $
+ *
+ *
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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/RaA8.c,v 1.4 2001/12/14 19:54:55 dawes Exp $ */
+
+#include <X11/Xos.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xdmcp.h>
+
+int
+XdmcpReallocARRAY8 (ARRAY8Ptr array, int length)
+{
+ CARD8Ptr newData;
+
+ newData = (CARD8Ptr) Xrealloc (array->data, length * sizeof (CARD8));
+ if (!newData)
+ return FALSE;
+ array->length = length;
+ array->data = newData;
+ return TRUE;
+}
diff --git a/xc/lib/Xdmcp/RaAoA8.c b/xc/lib/Xdmcp/RaAoA8.c
new file mode 100644
index 000000000..d6eeb7dd9
--- /dev/null
+++ b/xc/lib/Xdmcp/RaAoA8.c
@@ -0,0 +1,48 @@
+/*
+ * $Xorg: RaAoA8.c,v 1.4 2001/02/09 02:03:48 xorgcvs Exp $
+ *
+ *
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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/RaAoA8.c,v 1.4 2001/12/14 19:54:55 dawes Exp $ */
+
+#include <X11/Xos.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xdmcp.h>
+
+int
+XdmcpReallocARRAYofARRAY8 (ARRAYofARRAY8Ptr array, int length)
+{
+ ARRAY8Ptr newData;
+
+ newData = (ARRAY8Ptr) Xrealloc (array->data, length * sizeof (ARRAY8));
+ if (!newData)
+ return FALSE;
+ array->length = length;
+ array->data = newData;
+ return TRUE;
+}
diff --git a/xc/lib/Xdmcp/Unwrap.c b/xc/lib/Xdmcp/Unwrap.c
new file mode 100644
index 000000000..56da32238
--- /dev/null
+++ b/xc/lib/Xdmcp/Unwrap.c
@@ -0,0 +1,92 @@
+/*
+ * $Xorg: Unwrap.c,v 1.4 2001/02/09 02:03:48 xorgcvs Exp $
+ *
+ *
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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/Unwrap.c,v 1.4 2001/12/14 19:54:55 dawes Exp $ */
+
+#include <X11/Xos.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xdmcp.h>
+
+#ifdef HASXDMAUTH
+
+/*
+ * The following function exists only to demonstrate the
+ * desired functional interface for this routine. You will
+ * need to add the appropriate algorithm if you wish to
+ * use XDM-AUTHENTICATION-1/XDM-AUTHORIZATION-1.
+ *
+ * The interface for this routine is quite simple. All three
+ * arguments are arrays of 8 unsigned characters, the first two
+ * are 64 bits of useful data, the last is 56 bits of useful
+ * data packed into 8 bytes, using the low 7 bits of each
+ * byte, filling the high bit with odd parity.
+ *
+ * Examine the XDMCP specification for the correct algorithm
+ */
+
+#include "Wrap.h"
+
+void
+XdmcpUnwrap (
+ unsigned char *input,
+ unsigned char *wrapper,
+ unsigned char *output,
+ int bytes)
+{
+ int i, j, k;
+ unsigned char tmp[8];
+ unsigned char blocks[2][8];
+ unsigned char expand_wrapper[8];
+ auth_wrapper_schedule schedule;
+
+ _XdmcpWrapperToOddParity (wrapper, expand_wrapper);
+ _XdmcpAuthSetup (expand_wrapper, schedule);
+
+ k = 0;
+ for (j = 0; j < bytes; j += 8)
+ {
+ if (bytes - j < 8)
+ return; /* bad input length */
+ for (i = 0; i < 8; i++)
+ blocks[k][i] = input[j + i];
+ _XdmcpAuthDoIt ((unsigned char *) (input + j), (unsigned char *) tmp, schedule, 0);
+ /* block chaining */
+ k = (k == 0) ? 1 : 0;
+ for (i = 0; i < 8; i++)
+ {
+ if (j == 0)
+ output[j + i] = tmp[i];
+ else
+ output[j + i] = tmp[i] ^ blocks[k][i];
+ }
+ }
+}
+
+#endif /* HASXDMAUTH */
diff --git a/xc/lib/Xdmcp/WA16.c b/xc/lib/Xdmcp/WA16.c
new file mode 100644
index 000000000..4f625b7ad
--- /dev/null
+++ b/xc/lib/Xdmcp/WA16.c
@@ -0,0 +1,48 @@
+/*
+ * $Xorg: WA16.c,v 1.4 2001/02/09 02:03:48 xorgcvs Exp $
+ *
+ *
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+ */
+
+#include <X11/Xos.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xdmcp.h>
+
+int
+XdmcpWriteARRAY16 (buffer, array)
+ XdmcpBufferPtr buffer;
+ ARRAY16Ptr array;
+{
+ int i;
+
+ if (!XdmcpWriteCARD8 (buffer, array->length))
+ return FALSE;
+ for (i = 0; i < (int)array->length; i++)
+ if (!XdmcpWriteCARD16 (buffer, array->data[i]))
+ return FALSE;
+ return TRUE;
+}
diff --git a/xc/lib/Xdmcp/WA32.c b/xc/lib/Xdmcp/WA32.c
new file mode 100644
index 000000000..140c750cc
--- /dev/null
+++ b/xc/lib/Xdmcp/WA32.c
@@ -0,0 +1,48 @@
+/*
+ * $Xorg: WA32.c,v 1.4 2001/02/09 02:03:48 xorgcvs Exp $
+ *
+ *
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+ */
+
+#include <X11/Xos.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xdmcp.h>
+
+int
+XdmcpWriteARRAY32 (buffer, array)
+ XdmcpBufferPtr buffer;
+ ARRAY32Ptr array;
+{
+ int i;
+
+ if (!XdmcpWriteCARD8 (buffer, array->length))
+ return FALSE;
+ for (i = 0; i < (int)array->length; i++)
+ if (!XdmcpWriteCARD32 (buffer, array->data[i]))
+ return FALSE;
+ return TRUE;
+}
diff --git a/xc/lib/Xdmcp/WA8.c b/xc/lib/Xdmcp/WA8.c
new file mode 100644
index 000000000..3bd738a68
--- /dev/null
+++ b/xc/lib/Xdmcp/WA8.c
@@ -0,0 +1,48 @@
+/*
+ * $Xorg: WA8.c,v 1.4 2001/02/09 02:03:48 xorgcvs Exp $
+ *
+ *
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+ */
+
+#include <X11/Xos.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xdmcp.h>
+
+int
+XdmcpWriteARRAY8 (buffer, array)
+ XdmcpBufferPtr buffer;
+ ARRAY8Ptr array;
+{
+ int i;
+
+ if (!XdmcpWriteCARD16 (buffer, array->length))
+ return FALSE;
+ for (i = 0; i < (int)array->length; i++)
+ if (!XdmcpWriteCARD8 (buffer, array->data[i]))
+ return FALSE;
+ return TRUE;
+}
diff --git a/xc/lib/Xdmcp/WAofA8.c b/xc/lib/Xdmcp/WAofA8.c
new file mode 100644
index 000000000..84ba454d8
--- /dev/null
+++ b/xc/lib/Xdmcp/WAofA8.c
@@ -0,0 +1,48 @@
+/*
+ * $Xorg: WAofA8.c,v 1.4 2001/02/09 02:03:48 xorgcvs Exp $
+ *
+ *
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+ */
+
+#include <X11/Xos.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xdmcp.h>
+
+int
+XdmcpWriteARRAYofARRAY8 (buffer, array)
+ XdmcpBufferPtr buffer;
+ ARRAYofARRAY8Ptr array;
+{
+ int i;
+
+ if (!XdmcpWriteCARD8 (buffer, array->length))
+ return FALSE;
+ for (i = 0; i < (int)array->length; i++)
+ if (!XdmcpWriteARRAY8 (buffer, &array->data[i]))
+ return FALSE;
+ return TRUE;
+}
diff --git a/xc/lib/Xdmcp/WC16.c b/xc/lib/Xdmcp/WC16.c
new file mode 100644
index 000000000..738d6588e
--- /dev/null
+++ b/xc/lib/Xdmcp/WC16.c
@@ -0,0 +1,47 @@
+/*
+ * $Xorg: WC16.c,v 1.4 2001/02/09 02:03:48 xorgcvs Exp $
+ *
+ *
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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/WC16.c,v 1.5 2001/12/14 19:54:55 dawes Exp $ */
+
+#include <X11/Xos.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xdmcp.h>
+
+int
+XdmcpWriteCARD16 (
+ XdmcpBufferPtr buffer,
+ unsigned value)
+{
+ if (!XdmcpWriteCARD8 (buffer, value >> 8))
+ return FALSE;
+ if (!XdmcpWriteCARD8 (buffer, value & 0xff))
+ return FALSE;
+ return TRUE;
+}
diff --git a/xc/lib/Xdmcp/WC32.c b/xc/lib/Xdmcp/WC32.c
new file mode 100644
index 000000000..51ae48dbf
--- /dev/null
+++ b/xc/lib/Xdmcp/WC32.c
@@ -0,0 +1,50 @@
+/*
+ * $Xorg: WC32.c,v 1.4 2001/02/09 02:03:49 xorgcvs Exp $
+ *
+ *
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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/WC32.c,v 1.5 2001/12/14 19:54:55 dawes Exp $ */
+
+#include <X11/Xos.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xdmcp.h>
+
+int
+XdmcpWriteCARD32 (
+ XdmcpBufferPtr buffer,
+ unsigned value)
+{
+ if (!XdmcpWriteCARD8 (buffer, value >> 24))
+ return FALSE;
+ if (!XdmcpWriteCARD8 (buffer, (value >> 16) & 0xff))
+ return FALSE;
+ if (!XdmcpWriteCARD8 (buffer, (value >> 8) & 0xff))
+ return FALSE;
+ if (!XdmcpWriteCARD8 (buffer, value & 0xff))
+ return FALSE;
+ return TRUE;
+}
diff --git a/xc/lib/Xdmcp/WC8.c b/xc/lib/Xdmcp/WC8.c
new file mode 100644
index 000000000..625e86077
--- /dev/null
+++ b/xc/lib/Xdmcp/WC8.c
@@ -0,0 +1,46 @@
+/*
+ * $Xorg: WC8.c,v 1.4 2001/02/09 02:03:49 xorgcvs Exp $
+ *
+ *
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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/WC8.c,v 1.5 2001/12/14 19:54:55 dawes Exp $ */
+
+#include <X11/Xos.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xdmcp.h>
+
+int
+XdmcpWriteCARD8 (
+ XdmcpBufferPtr buffer,
+ unsigned value)
+{
+ if (buffer->pointer >= buffer->size)
+ return FALSE;
+ buffer->data[buffer->pointer++] = (BYTE) value;
+ return TRUE;
+}
diff --git a/xc/lib/Xdmcp/Whead.c b/xc/lib/Xdmcp/Whead.c
new file mode 100644
index 000000000..ae1d6917c
--- /dev/null
+++ b/xc/lib/Xdmcp/Whead.c
@@ -0,0 +1,61 @@
+/*
+ * $Xorg: Whead.c,v 1.4 2001/02/09 02:03:49 xorgcvs Exp $
+ *
+ *
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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.4 2001/12/14 19:54:55 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;
+}
diff --git a/xc/lib/Xdmcp/Wrap.c b/xc/lib/Xdmcp/Wrap.c
new file mode 100644
index 000000000..5f4870b22
--- /dev/null
+++ b/xc/lib/Xdmcp/Wrap.c
@@ -0,0 +1,130 @@
+/*
+ * $Xorg: Wrap.c,v 1.4 2001/02/09 02:03:49 xorgcvs Exp $
+ *
+ *
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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/Wrap.c,v 1.4 2001/12/14 19:54:56 dawes Exp $ */
+
+#include <X11/Xos.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xdmcp.h>
+
+#ifdef HASXDMAUTH
+
+/*
+ * The following function exists only to demonstrate the
+ * desired functional interface for this routine. You will
+ * need to add the appropriate algorithm if you wish to
+ * use XDM-AUTHENTICATION-1/XDM-AUTHORIZATION-1.
+ *
+ * Examine the XDMCP specification for the correct algorithm
+ */
+
+#include "Wrap.h"
+
+void
+XdmcpWrap (
+ unsigned char *input,
+ unsigned char *wrapper,
+ unsigned char *output,
+ int bytes)
+{
+ int i, j;
+ int len;
+ unsigned char tmp[8];
+ unsigned char expand_wrapper[8];
+ auth_wrapper_schedule schedule;
+
+ _XdmcpWrapperToOddParity (wrapper, expand_wrapper);
+ _XdmcpAuthSetup (expand_wrapper, schedule);
+ for (j = 0; j < bytes; j += 8)
+ {
+ len = 8;
+ if (bytes - j < len)
+ len = bytes - j;
+ /* block chaining */
+ for (i = 0; i < len; i++)
+ {
+ if (j == 0)
+ tmp[i] = input[i];
+ else
+ tmp[i] = input[j + i] ^ output[j - 8 + i];
+ }
+ for (; i < 8; i++)
+ {
+ if (j == 0)
+ tmp[i] = 0;
+ else
+ tmp[i] = 0 ^ output[j - 8 + i];
+ }
+ _XdmcpAuthDoIt (tmp, (output + j), schedule, 1);
+ }
+}
+
+/*
+ * Given a 56 bit wrapper in XDMCP format, create a 56
+ * bit wrapper in 7-bits + odd parity format
+ */
+
+static int
+OddParity (unsigned char c)
+{
+ c = c ^ (c >> 4);
+ c = c ^ (c >> 2);
+ c = c ^ (c >> 1);
+ return ~c & 0x1;
+}
+
+/*
+ * Spread the 56 bit wrapper among 8 bytes, using the upper 7 bits
+ * of each byte, and storing an odd parity bit in the low bit
+ */
+
+void
+_XdmcpWrapperToOddParity (
+ unsigned char *in,
+ unsigned char *out)
+{
+ int ashift, bshift;
+ int i;
+ unsigned char c;
+
+ ashift = 7;
+ bshift = 1;
+ for (i = 0; i < 7; i++)
+ {
+ c = ((in[i] << ashift) | (in[i+1] >> bshift)) & 0x7f;
+ out[i] = (c << 1) | OddParity (c);
+ ashift--;
+ bshift++;
+ }
+ c = in[i];
+ out[i] = (c << 1) | OddParity(c);
+}
+
+#endif
diff --git a/xc/lib/Xdmcp/Wrap.h b/xc/lib/Xdmcp/Wrap.h
new file mode 100644
index 000000000..b9ec1cfb2
--- /dev/null
+++ b/xc/lib/Xdmcp/Wrap.h
@@ -0,0 +1,12 @@
+/* $Xorg: Wrap.h,v 1.3 2000/08/17 19:45:50 cpqbld Exp $ */
+/*
+ * header file for compatibility with something useful
+ */
+
+/* $XFree86: xc/lib/Xdmcp/Wrap.h,v 1.3 2001/01/17 19:42:44 dawes Exp $ */
+
+typedef unsigned char auth_cblock[8]; /* block size */
+
+typedef struct auth_ks_struct { auth_cblock _; } auth_wrapper_schedule[16];
+
+extern void _XdmcpWrapperToOddParity (unsigned char *in, unsigned char *out);
diff --git a/xc/lib/Xdmcp/Xdmcp.h b/xc/lib/Xdmcp/Xdmcp.h
new file mode 100644
index 000000000..faf2af486
--- /dev/null
+++ b/xc/lib/Xdmcp/Xdmcp.h
@@ -0,0 +1,178 @@
+/* $Xorg: Xdmcp.h,v 1.7 2001/04/13 14:43:00 steve Exp $ */
+/*
+ * Copyright 1989 Network Computing Devices, Inc., Mountain View, California.
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted, provided
+ * that the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of N.C.D. not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. N.C.D. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ */
+/* $XFree86: xc/lib/Xdmcp/Xdmcp.h,v 3.7 2003/07/09 15:27:29 tsi Exp $ */
+
+#ifndef _XDMCP_H_
+#define _XDMCP_H_
+
+#include <X11/Xmd.h>
+
+#include <X11/Xfuncproto.h>
+
+_XFUNCPROTOBEGIN
+
+#define XDM_PROTOCOL_VERSION 1
+#define XDM_UDP_PORT 177
+#define XDM_MAX_MSGLEN 8192
+#define XDM_MIN_RTX 2
+#define XDM_MAX_RTX 32
+#define XDM_RTX_LIMIT 7
+#define XDM_KA_RTX_LIMIT 4
+#define XDM_DEF_DORMANCY (3 * 60) /* 3 minutes */
+#define XDM_MAX_DORMANCY (24 * 60 * 60) /* 24 hours */
+
+typedef enum {
+ BROADCAST_QUERY = 1, QUERY, INDIRECT_QUERY, FORWARD_QUERY,
+ WILLING, UNWILLING, REQUEST, ACCEPT, DECLINE, MANAGE, REFUSE,
+ FAILED, KEEPALIVE, ALIVE
+} xdmOpCode;
+
+typedef enum {
+ XDM_QUERY, XDM_BROADCAST, XDM_INDIRECT, XDM_COLLECT_QUERY,
+ XDM_COLLECT_BROADCAST_QUERY, XDM_COLLECT_INDIRECT_QUERY,
+ XDM_START_CONNECTION, XDM_AWAIT_REQUEST_RESPONSE,
+ XDM_AWAIT_MANAGE_RESPONSE, XDM_MANAGE, XDM_RUN_SESSION, XDM_OFF,
+ XDM_AWAIT_USER_INPUT, XDM_KEEPALIVE, XDM_AWAIT_ALIVE_RESPONSE,
+#if defined(IPv6) && defined(AF_INET6)
+ XDM_MULTICAST, XDM_COLLECT_MULTICAST_QUERY,
+#endif
+ XDM_KEEP_ME_LAST
+} xdmcp_states;
+
+#ifdef NOTDEF
+/* table of hosts */
+
+#define XDM_MAX_STR_LEN 21
+#define XDM_MAX_HOSTS 20
+struct xdm_host_table {
+ struct sockaddr_in sockaddr;
+ char name[XDM_MAX_STR_LEN];
+ char status[XDM_MAX_STR_LEN];
+};
+#endif /* NOTDEF */
+
+typedef CARD8 *CARD8Ptr;
+typedef CARD16 *CARD16Ptr;
+typedef CARD32 *CARD32Ptr;
+
+typedef struct _ARRAY8 {
+ CARD16 length;
+ CARD8Ptr data;
+} ARRAY8, *ARRAY8Ptr;
+
+typedef struct _ARRAY16 {
+ CARD8 length;
+ CARD16Ptr data;
+} ARRAY16, *ARRAY16Ptr;
+
+typedef struct _ARRAY32 {
+ CARD8 length;
+ CARD32Ptr data;
+} ARRAY32, *ARRAY32Ptr;
+
+typedef struct _ARRAYofARRAY8 {
+ CARD8 length;
+ ARRAY8Ptr data;
+} ARRAYofARRAY8, *ARRAYofARRAY8Ptr;
+
+typedef struct _XdmcpHeader {
+ CARD16 version, opcode, length;
+} XdmcpHeader, *XdmcpHeaderPtr;
+
+typedef struct _XdmcpBuffer {
+ BYTE *data;
+ int size; /* size of buffer pointed by to data */
+ int pointer; /* current index into data */
+ int count; /* bytes read from network into data */
+} XdmcpBuffer, *XdmcpBufferPtr;
+
+typedef struct _XdmAuthKey {
+ BYTE data[8];
+} XdmAuthKeyRec, *XdmAuthKeyPtr;
+
+
+/* implementation-independent network address structure.
+ Equiv to sockaddr* for sockets and netbuf* for STREAMS. */
+
+typedef char *XdmcpNetaddr;
+
+extern int XdmcpWriteARRAY16(XdmcpBufferPtr buffer, ARRAY16Ptr array);
+extern int XdmcpWriteARRAY32(XdmcpBufferPtr buffer, ARRAY32Ptr array);
+extern int XdmcpWriteARRAY8(XdmcpBufferPtr buffer, ARRAY8Ptr array);
+extern int XdmcpWriteARRAYofARRAY8(XdmcpBufferPtr buffer, ARRAYofARRAY8Ptr array);
+extern int XdmcpWriteCARD16(XdmcpBufferPtr buffer, unsigned value);
+extern int XdmcpWriteCARD32(XdmcpBufferPtr buffer, unsigned value);
+extern int XdmcpWriteCARD8(XdmcpBufferPtr buffer, unsigned value);
+extern int XdmcpWriteHeader(XdmcpBufferPtr buffer, XdmcpHeaderPtr header);
+
+extern int XdmcpFlush(int fd, XdmcpBufferPtr buffer, XdmcpNetaddr to, int tolen);
+
+extern int XdmcpReadARRAY16(XdmcpBufferPtr buffer, ARRAY16Ptr array);
+extern int XdmcpReadARRAY32(XdmcpBufferPtr buffer, ARRAY32Ptr array);
+extern int XdmcpReadARRAY8(XdmcpBufferPtr buffer, ARRAY8Ptr array);
+extern int XdmcpReadARRAYofARRAY8(XdmcpBufferPtr buffer, ARRAYofARRAY8Ptr array);
+extern int XdmcpReadCARD16(XdmcpBufferPtr buffer, CARD16Ptr valuep);
+extern int XdmcpReadCARD32(XdmcpBufferPtr buffer, CARD32Ptr valuep);
+extern int XdmcpReadCARD8(XdmcpBufferPtr buffer, CARD8Ptr valuep);
+extern int XdmcpReadHeader(XdmcpBufferPtr buffer, XdmcpHeaderPtr header);
+
+extern int XdmcpFill(int fd, XdmcpBufferPtr buffer, XdmcpNetaddr from, int *fromlen);
+
+extern int XdmcpReadRemaining(XdmcpBufferPtr buffer);
+
+extern void XdmcpDisposeARRAY8(ARRAY8Ptr array);
+extern void XdmcpDisposeARRAY16(ARRAY16Ptr array);
+extern void XdmcpDisposeARRAY32(ARRAY32Ptr array);
+extern void XdmcpDisposeARRAYofARRAY8(ARRAYofARRAY8Ptr array);
+
+extern int XdmcpCopyARRAY8(ARRAY8Ptr src, ARRAY8Ptr dst);
+
+extern int XdmcpARRAY8Equal(ARRAY8Ptr array1, ARRAY8Ptr array2);
+
+extern void XdmcpGenerateKey (XdmAuthKeyPtr key);
+extern void XdmcpIncrementKey (XdmAuthKeyPtr key);
+extern void XdmcpDecrementKey (XdmAuthKeyPtr key);
+#ifdef HASXDMAUTH
+extern void XdmcpWrap(unsigned char *input, unsigned char *wrapper, unsigned char *output, int bytes);
+extern void XdmcpUnwrap(unsigned char *input, unsigned char *wrapper, unsigned char *output, int bytes);
+#endif
+
+#ifndef TRUE
+#define TRUE 1
+#define FALSE 0
+#endif
+
+#if !defined(Xalloc) && !defined(xalloc) && !defined(Xrealloc)
+extern void *Xalloc (unsigned long amount);
+extern void *Xrealloc (void *old, unsigned long amount);
+extern void Xfree(void *old);
+#endif
+
+extern int XdmcpCompareKeys (XdmAuthKeyPtr a, XdmAuthKeyPtr b);
+
+extern int XdmcpAllocARRAY16 (ARRAY16Ptr array, int length);
+extern int XdmcpAllocARRAY32 (ARRAY32Ptr array, int length);
+extern int XdmcpAllocARRAY8 (ARRAY8Ptr array, int length);
+extern int XdmcpAllocARRAYofARRAY8 (ARRAYofARRAY8Ptr array, int length);
+
+extern int XdmcpReallocARRAY16 (ARRAY16Ptr array, int length);
+extern int XdmcpReallocARRAY32 (ARRAY32Ptr array, int length);
+extern int XdmcpReallocARRAY8 (ARRAY8Ptr array, int length);
+extern int XdmcpReallocARRAYofARRAY8 (ARRAYofARRAY8Ptr array, int length);
+
+_XFUNCPROTOEND
+
+#endif /* _XDMCP_H_ */