1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | |
10 | |
11 | |
12 | |
13 | |
14 | |
15 | |
16 | |
17 | |
18 | |
19 | |
20 | |
21 | |
22 | |
23 | |
24 | |
25 | |
26 | |
27 | |
28 | |
29 | |
30 | |
31 | |
32 | |
33 | |
34 | |
35 | |
36 | |
37 | |
38 | |
39 | |
40 | |
41 | |
42 | |
43 | |
44 | |
45 | |
46 | |
47 | |
48 | |
49 | |
50 | |
51 | |
52 | |
53 | |
54 | |
55 | |
56 | |
57 | |
58 | |
59 | |
60 | |
61 | |
62 | #ifdef HAVE_CONFIG_H1 |
63 | #include <config.h> |
64 | #endif |
65 | #include "Xlibint.h" |
66 | |
67 | int |
68 | XAddHost ( |
69 | register Display *dpy, |
70 | XHostAddress *host) |
71 | { |
72 | register xChangeHostsReq *req; |
73 | register int length; |
74 | XServerInterpretedAddress *siAddr; |
75 | int addrlen; |
76 | |
77 | siAddr = host->family == FamilyServerInterpreted5 ? |
| |
78 | (XServerInterpretedAddress *)host->address : NULL((void*)0); |
79 | addrlen = siAddr ? |
| 2 | Assuming 'siAddr' is null |
|
| |
80 | siAddr->typelength + siAddr->valuelength + 1 : host->length; |
81 | |
82 | length = (addrlen + 3) & ~0x3; |
83 | |
84 | LockDisplay(dpy)if ((dpy)->lock_fns) (*(dpy)->lock_fns->lock_display )(dpy); |
85 | GetReqExtra (ChangeHosts, length, req)req = (xChangeHostsReq *) _XGetRequest(dpy, 109, 8 + length); |
86 | req->mode = HostInsert0; |
87 | req->hostFamily = host->family; |
88 | req->hostLength = addrlen; |
89 | if (siAddr) { |
| |
90 | char *dest = (char *) NEXTPTR(req,xChangeHostsReq)(((xChangeHostsReq *)(req)) + 1); |
91 | memcpy(dest, siAddr->type, siAddr->typelength); |
92 | dest[siAddr->typelength] = '\0'; |
93 | memcpy(dest + siAddr->typelength + 1,siAddr->value,siAddr->valuelength); |
94 | } else { |
95 | memcpy((char *) NEXTPTR(req,xChangeHostsReq)(((xChangeHostsReq *)(req)) + 1), host->address, addrlen); |
| 5 | Null pointer passed as an argument to a 'nonnull' parameter |
|
96 | } |
97 | UnlockDisplay(dpy)if ((dpy)->lock_fns) (*(dpy)->lock_fns->unlock_display )(dpy); |
98 | SyncHandle()if (dpy->synchandler) (*dpy->synchandler)(dpy); |
99 | return 1; |
100 | } |
101 | |
102 | int |
103 | XRemoveHost ( |
104 | register Display *dpy, |
105 | XHostAddress *host) |
106 | { |
107 | register xChangeHostsReq *req; |
108 | register int length; |
109 | XServerInterpretedAddress *siAddr; |
110 | int addrlen; |
111 | |
112 | siAddr = host->family == FamilyServerInterpreted5 ? |
113 | (XServerInterpretedAddress *)host->address : NULL((void*)0); |
114 | addrlen = siAddr ? |
115 | siAddr->typelength + siAddr->valuelength + 1 : host->length; |
116 | |
117 | length = (addrlen + 3) & ~0x3; |
118 | |
119 | LockDisplay(dpy)if ((dpy)->lock_fns) (*(dpy)->lock_fns->lock_display )(dpy); |
120 | GetReqExtra (ChangeHosts, length, req)req = (xChangeHostsReq *) _XGetRequest(dpy, 109, 8 + length); |
121 | req->mode = HostDelete1; |
122 | req->hostFamily = host->family; |
123 | req->hostLength = addrlen; |
124 | if (siAddr) { |
125 | char *dest = (char *) NEXTPTR(req,xChangeHostsReq)(((xChangeHostsReq *)(req)) + 1); |
126 | memcpy(dest, siAddr->type, siAddr->typelength); |
127 | dest[siAddr->typelength] = '\0'; |
128 | memcpy(dest + siAddr->typelength + 1,siAddr->value,siAddr->valuelength); |
129 | } else { |
130 | memcpy((char *) NEXTPTR(req,xChangeHostsReq)(((xChangeHostsReq *)(req)) + 1), host->address, addrlen); |
131 | } |
132 | UnlockDisplay(dpy)if ((dpy)->lock_fns) (*(dpy)->lock_fns->unlock_display )(dpy); |
133 | SyncHandle()if (dpy->synchandler) (*dpy->synchandler)(dpy); |
134 | return 1; |
135 | } |
136 | |
137 | int |
138 | XAddHosts ( |
139 | register Display *dpy, |
140 | XHostAddress *hosts, |
141 | int n) |
142 | { |
143 | register int i; |
144 | for (i = 0; i < n; i++) { |
145 | (void) XAddHost(dpy, &hosts[i]); |
146 | } |
147 | return 1; |
148 | } |
149 | |
150 | int |
151 | XRemoveHosts ( |
152 | register Display *dpy, |
153 | XHostAddress *hosts, |
154 | int n) |
155 | { |
156 | register int i; |
157 | for (i = 0; i < n; i++) { |
158 | (void) XRemoveHost(dpy, &hosts[i]); |
159 | } |
160 | return 1; |
161 | } |