3 Copyright 1986, 1998 The Open Group
7 Permission is hereby granted, free of charge, to any person obtaining a
8 copy of this software and associated documentation files (the
9 "Software"), to deal in the Software without restriction, including
10 without limitation the rights to use, copy, modify, merge, publish,
11 distribute, and/or sell copies of the Software, and to permit persons
12 to whom the Software is furnished to do so, provided that the above
13 copyright notice(s) and this permission notice appear in all copies of
14 the Software and that both the above copyright notice(s) and this
15 permission notice appear in supporting documentation.
17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
20 OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
21 HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
22 INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
23 FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
24 NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
25 WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
27 Except as contained in this notice, the name of a copyright holder
28 shall not be used in advertising or otherwise to promote the sale, use
29 or other dealings in this Software without prior written authorization
30 of the copyright holder.
32 X Window System is a trademark of The Open Group.
37 * Copyright 2004 Oracle and/or its affiliates. All rights reserved.
39 * Permission is hereby granted, free of charge, to any person obtaining a
40 * copy of this software and associated documentation files (the "Software"),
41 * to deal in the Software without restriction, including without limitation
42 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
43 * and/or sell copies of the Software, and to permit persons to whom the
44 * Software is furnished to do so, subject to the following conditions:
46 * The above copyright notice and this permission notice (including the next
47 * paragraph) shall be included in all copies or substantial portions of the
50 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
51 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
52 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
53 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
54 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
55 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
56 * DEALINGS IN THE SOFTWARE.
59 /* This can really be considered an os dependent routine */
66 * can be freed using XFree.
69 XHostAddress *XListHosts (
70 register Display *dpy,
71 int *nhosts, /* RETURN */
72 Bool *enabled) /* RETURN */
74 register XHostAddress *outbuf = NULL, *op;
75 xListHostsReply reply;
77 unsigned char *buf, *bp;
79 register xListHostsReq *req;
80 XServerInterpretedAddress *sip;
84 GetReq (ListHosts, req);
86 if (!_XReply (dpy, (xReply *) &reply, 0, xFalse)) {
89 return (XHostAddress *) NULL;
93 nbytes = reply.length << 2; /* compute number of bytes in reply */
95 op = outbuf = (XHostAddress *)
96 Xmalloc((unsigned) (nbytes +
97 (reply.nHosts * sizeof(XHostAddress)) +
98 (reply.nHosts * sizeof(XServerInterpretedAddress))));
101 _XEatData(dpy, (unsigned long) nbytes);
104 return (XHostAddress *) NULL;
106 sip = (XServerInterpretedAddress *)
107 (((unsigned char *) outbuf) + (reply.nHosts * sizeof(XHostAddress)));
108 bp = buf = ((unsigned char *) sip)
109 + (reply.nHosts * sizeof(XServerInterpretedAddress));
111 _XRead (dpy, (char *) buf, nbytes);
113 for (i = 0; i < reply.nHosts; i++) {
116 memcpy((char *)&xhe, bp, SIZEOF(xHostEntry));
117 op->family = xhe.family;
118 op->length = xhe.length;
120 op->family = ((xHostEntry *) bp)->family;
121 op->length =((xHostEntry *) bp)->length;
123 if (op->family == FamilyServerInterpreted) {
124 char *tp = (char *) (bp + SIZEOF(xHostEntry));
125 char *vp = memchr(tp, 0, op->length);
129 sip->typelength = vp - tp;
131 sip->valuelength = op->length - (sip->typelength + 1);
133 sip->type = sip->value = NULL;
134 sip->typelength = sip->valuelength = 0;
136 op->address = (char *) sip;
139 op->address = (char *) (bp + SIZEOF(xHostEntry));
141 bp += SIZEOF(xHostEntry) + (((op->length + 3) >> 2) << 2);
146 *enabled = reply.enabled;
147 *nhosts = reply.nHosts;