#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "Xlibint.h"
int
XAddHost (
register Display *dpy,
XHostAddress *host)
{
register xChangeHostsReq *req;
register int length;
XServerInterpretedAddress *siAddr;
int addrlen;
if (host->family == FamilyServerInterpreted) {
siAddr = (XServerInterpretedAddress *) host->address;
addrlen = siAddr->typelength + siAddr->valuelength + 1;
} else {
addrlen = host->length;
}
length = (addrlen + 3) & ~0x3;
LockDisplay(dpy);
GetReqExtra (ChangeHosts, length, req);
req->mode = HostInsert;
req->hostFamily = host->family;
req->hostLength = addrlen;
if (host->family == FamilyServerInterpreted) {
char *dest = (char *) NEXTPTR(req,xChangeHostsReq);
memcpy(dest, siAddr->type, siAddr->typelength);
dest[siAddr->typelength] = '\0';
memcpy(dest + siAddr->typelength + 1,siAddr->value,siAddr->valuelength);
} else {
memcpy((char *) NEXTPTR(req,xChangeHostsReq), host->address, addrlen);
}
UnlockDisplay(dpy);
SyncHandle();
return 1;
}
int
XRemoveHost (
register Display *dpy,
XHostAddress *host)
{
register xChangeHostsReq *req;
register int length;
XServerInterpretedAddress *siAddr;
int addrlen;
if (host->family == FamilyServerInterpreted) {
siAddr = (XServerInterpretedAddress *) host->address;
addrlen = siAddr->typelength + siAddr->valuelength + 1;
} else {
addrlen = host->length;
}
length = (addrlen + 3) & ~0x3;
LockDisplay(dpy);
GetReqExtra (ChangeHosts, length, req);
req->mode = HostDelete;
req->hostFamily = host->family;
req->hostLength = addrlen;
if (host->family == FamilyServerInterpreted) {
char *dest = (char *) NEXTPTR(req,xChangeHostsReq);
memcpy(dest, siAddr->type, siAddr->typelength);
dest[siAddr->typelength] = '\0';
memcpy(dest + siAddr->typelength + 1,siAddr->value,siAddr->valuelength);
} else {
memcpy((char *) NEXTPTR(req,xChangeHostsReq), host->address, addrlen);
}
UnlockDisplay(dpy);
SyncHandle();
return 1;
}
int
XAddHosts (
register Display *dpy,
XHostAddress *hosts,
int n)
{
register int i;
for (i = 0; i < n; i++) {
(void) XAddHost(dpy, &hosts[i]);
}
return 1;
}
int
XRemoveHosts (
register Display *dpy,
XHostAddress *hosts,
int n)
{
register int i;
for (i = 0; i < n; i++) {
(void) XRemoveHost(dpy, &hosts[i]);
}
return 1;
}