11ab64890Smrg/* 21ab64890Smrg 31ab64890SmrgCopyright 1986, 1998 The Open Group 41ab64890Smrg 51ab64890SmrgAll rights reserved. 61ab64890Smrg 71ab64890SmrgPermission is hereby granted, free of charge, to any person obtaining a 81ab64890Smrgcopy of this software and associated documentation files (the 91ab64890Smrg"Software"), to deal in the Software without restriction, including 101ab64890Smrgwithout limitation the rights to use, copy, modify, merge, publish, 111ab64890Smrgdistribute, and/or sell copies of the Software, and to permit persons 121ab64890Smrgto whom the Software is furnished to do so, provided that the above 131ab64890Smrgcopyright notice(s) and this permission notice appear in all copies of 141ab64890Smrgthe Software and that both the above copyright notice(s) and this 151ab64890Smrgpermission notice appear in supporting documentation. 161ab64890Smrg 171ab64890SmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 181ab64890SmrgOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 191ab64890SmrgMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 201ab64890SmrgOF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 211ab64890SmrgHOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL 221ab64890SmrgINDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING 231ab64890SmrgFROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 241ab64890SmrgNEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION 251ab64890SmrgWITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 261ab64890Smrg 271ab64890SmrgExcept as contained in this notice, the name of a copyright holder 281ab64890Smrgshall not be used in advertising or otherwise to promote the sale, use 291ab64890Smrgor other dealings in this Software without prior written authorization 301ab64890Smrgof the copyright holder. 311ab64890Smrg 321ab64890SmrgX Window System is a trademark of The Open Group. 331ab64890Smrg 341ab64890Smrg*/ 35b4ee4795Smrg 36b4ee4795Smrg/* 375efbdfc3Smrg * Copyright (c) 2004, Oracle and/or its affiliates. 38b4ee4795Smrg * 39b4ee4795Smrg * Permission is hereby granted, free of charge, to any person obtaining a 40b4ee4795Smrg * copy of this software and associated documentation files (the "Software"), 41b4ee4795Smrg * to deal in the Software without restriction, including without limitation 42b4ee4795Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 43b4ee4795Smrg * and/or sell copies of the Software, and to permit persons to whom the 44b4ee4795Smrg * Software is furnished to do so, subject to the following conditions: 45b4ee4795Smrg * 46b4ee4795Smrg * The above copyright notice and this permission notice (including the next 47b4ee4795Smrg * paragraph) shall be included in all copies or substantial portions of the 48b4ee4795Smrg * Software. 49b4ee4795Smrg * 50b4ee4795Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 51b4ee4795Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 52b4ee4795Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 53b4ee4795Smrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 54b4ee4795Smrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 55b4ee4795Smrg * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 56b4ee4795Smrg * DEALINGS IN THE SOFTWARE. 57b4ee4795Smrg */ 58b4ee4795Smrg 591ab64890Smrg 601ab64890Smrg/* this might be rightly regarded an os dependent file */ 611ab64890Smrg 621ab64890Smrg#ifdef HAVE_CONFIG_H 631ab64890Smrg#include <config.h> 641ab64890Smrg#endif 651ab64890Smrg#include "Xlibint.h" 661ab64890Smrg 67818534a1Smrgstatic inline int 68818534a1Smrgchangehost (Display *dpy, XHostAddress *host, BYTE mode) 691ab64890Smrg{ 70818534a1Smrg xChangeHostsReq *req; 71818534a1Smrg int length; 721ab64890Smrg XServerInterpretedAddress *siAddr; 731ab64890Smrg int addrlen; 741ab64890Smrg 7561b2299dSmrg siAddr = host->family == FamilyServerInterpreted ? 7661b2299dSmrg (XServerInterpretedAddress *)host->address : NULL; 7761b2299dSmrg addrlen = siAddr ? 7861b2299dSmrg siAddr->typelength + siAddr->valuelength + 1 : host->length; 7961b2299dSmrg 801ab64890Smrg length = (addrlen + 3) & ~0x3; /* round up */ 811ab64890Smrg 821ab64890Smrg LockDisplay(dpy); 831ab64890Smrg GetReqExtra (ChangeHosts, length, req); 84818534a1Smrg if (!req) { 85818534a1Smrg UnlockDisplay(dpy); 86818534a1Smrg return 0; 87818534a1Smrg } 88818534a1Smrg req->mode = mode; 891ab64890Smrg req->hostFamily = host->family; 901ab64890Smrg req->hostLength = addrlen; 9161b2299dSmrg if (siAddr) { 921ab64890Smrg char *dest = (char *) NEXTPTR(req,xChangeHostsReq); 939c019ec5Smaya memcpy(dest, siAddr->type, (size_t) siAddr->typelength); 941ab64890Smrg dest[siAddr->typelength] = '\0'; 959c019ec5Smaya memcpy(dest + siAddr->typelength + 1,siAddr->value,(size_t) siAddr->valuelength); 961ab64890Smrg } else { 979c019ec5Smaya memcpy((char *) NEXTPTR(req,xChangeHostsReq), host->address, (size_t) addrlen); 981ab64890Smrg } 991ab64890Smrg UnlockDisplay(dpy); 1001ab64890Smrg SyncHandle(); 1011ab64890Smrg return 1; 1021ab64890Smrg} 1031ab64890Smrg 1041ab64890Smrgint 105818534a1SmrgXAddHost ( 1061ab64890Smrg register Display *dpy, 1071ab64890Smrg XHostAddress *host) 1081ab64890Smrg{ 109818534a1Smrg return changehost(dpy, host, HostInsert); 110818534a1Smrg} 1111ab64890Smrg 112818534a1Smrgint 113818534a1SmrgXRemoveHost ( 114818534a1Smrg register Display *dpy, 115818534a1Smrg XHostAddress *host) 116818534a1Smrg{ 117818534a1Smrg return changehost(dpy, host, HostDelete); 1181ab64890Smrg} 1191ab64890Smrg 1201ab64890Smrgint 1211ab64890SmrgXAddHosts ( 1221ab64890Smrg register Display *dpy, 1231ab64890Smrg XHostAddress *hosts, 1241ab64890Smrg int n) 1251ab64890Smrg{ 1261ab64890Smrg register int i; 1271ab64890Smrg for (i = 0; i < n; i++) { 1281ab64890Smrg (void) XAddHost(dpy, &hosts[i]); 1291ab64890Smrg } 1301ab64890Smrg return 1; 1311ab64890Smrg} 1321ab64890Smrg 1331ab64890Smrgint 1341ab64890SmrgXRemoveHosts ( 1351ab64890Smrg register Display *dpy, 1361ab64890Smrg XHostAddress *hosts, 1371ab64890Smrg int n) 1381ab64890Smrg{ 1391ab64890Smrg register int i; 1401ab64890Smrg for (i = 0; i < n; i++) { 1411ab64890Smrg (void) XRemoveHost(dpy, &hosts[i]); 1421ab64890Smrg } 1431ab64890Smrg return 1; 1441ab64890Smrg} 145