Add xhost 1.0.7 from x-S12
[unleashed-userland.git] / components / x11 / xhost / patches / xhost.patch
blobfc4fe506a823d9708d0f036e1d590609bbbace3e
1 diff --git a/xhost.c b/xhost.c
2 index a67d136..0e867b0 100644
3 --- a/xhost.c
4 +++ b/xhost.c
5 @@ -119,6 +119,11 @@ extern int getdomainname(char *name, size_t len);
6 #endif
7 #endif
9 +/* Internationalize messages for bug 4256527... S Swales 5/25/00 */
10 +#include <locale.h> /* setlocale() */
11 +#include <libintl.h> /* gettext(), textdomain(), etc. */
12 +#include <stdlib.h> /* getenv() */
14 static int change_host(Display *dpy, char *name, Bool add);
15 static const char *get_hostname(XHostAddress *ha);
16 static int local_xerror(Display *dpy, XErrorEvent *rep);
17 @@ -171,15 +176,30 @@ main(int argc, char *argv[])
18 Bool enabled = False;
19 Display *dpy;
21 + /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
22 + char *domaindir;
23 + setlocale(LC_ALL,"");
24 + textdomain("xhost");
26 + /* mainly for debugging */
27 + if((domaindir=getenv("TEXTDOMAINDIR")) == NULL) {
28 + domaindir = "/usr/share/locale"; /*XLOCALEDIR;*/
29 + }
30 + bindtextdomain("xhost",domaindir);
33 ProgramName = argv[0];
35 if (argc == 2 && !strcmp(argv[1], "-help")) {
36 - fprintf(stderr, "usage: %s [[+-]hostname ...]\n", argv[0]);
37 + /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
38 + fprintf(stderr, gettext("usage: %s [[+-]hostname ...]\n"), argv[0]);
39 exit(1);
42 if ((dpy = XOpenDisplay(NULL)) == NULL) {
43 - fprintf(stderr, "%s: unable to open display \"%s\"\n",
44 + /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
45 + fprintf(stderr,
46 + gettext("%s: unable to open display \"%s\"\n"),
47 ProgramName, XDisplayName (NULL));
48 exit(1);
50 @@ -191,9 +211,11 @@ main(int argc, char *argv[])
51 sethostent(1); /* don't close the data base each time */
52 list = XListHosts(dpy, &nhosts, &enabled);
53 if (enabled)
54 - printf ("access control enabled, only authorized clients can connect\n");
55 + /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
56 + printf (gettext("access control enabled, only authorized clients can connect\n"));
57 else
58 - printf ("access control disabled, clients can connect from any host\n");
59 + /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
60 + printf (gettext("access control disabled, clients can connect from any host\n"));
62 if (nhosts != 0) {
63 for (i = 0; i < nhosts; i++ ) {
64 @@ -222,16 +244,18 @@ main(int argc, char *argv[])
65 printf("SI:");
66 break;
67 default:
68 - printf("<unknown family type %d>:", list[i].family);
69 + printf(gettext("<unknown family type %d>:"), list[i].family);
70 break;
72 printf ("%s", hostname);
73 } else {
74 - printf ("<unknown address in family %d>",
75 + /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
76 + printf (gettext("<unknown address in family %d>"),
77 list[i].family);
79 if (nameserver_timedout) {
80 - printf("\t(no nameserver response within %d seconds)\n",
81 + /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
82 + printf(gettext("\t(no nameserver response within %d seconds)\n"),
83 NAMESERVER_TIMEOUT);
84 nameserver_timedout = 0;
85 } else
86 @@ -248,26 +272,30 @@ main(int argc, char *argv[])
87 if (*arg == '-') {
89 if (!argv[i][1] && ((i+1) == argc)) {
90 - printf ("access control enabled, only authorized clients can connect\n");
91 + /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
92 + printf (gettext("access control enabled, only authorized clients can connect\n"));
93 XEnableAccessControl(dpy);
94 } else {
95 arg = argv[i][1]? &argv[i][1] : argv[++i];
96 if (!change_host (dpy, arg, False)) {
97 - fprintf (stderr, "%s: bad hostname \"%s\"\n",
98 + /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
99 + fprintf (stderr, gettext("%s: bad hostname \"%s\"\n"),
100 ProgramName, arg);
101 nfailed++;
104 } else {
105 if (*arg == '+' && !argv[i][1] && ((i+1) == argc)) {
106 - printf ("access control disabled, clients can connect from any host\n");
107 + /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
108 + printf (gettext("access control disabled, clients can connect from any host\n"));
109 XDisableAccessControl(dpy);
110 } else {
111 if (*arg == '+') {
112 arg = argv[i][1]? &argv[i][1] : argv[++i];
114 if (!change_host (dpy, arg, True)) {
115 - fprintf (stderr, "%s: bad hostname \"%s\"\n",
116 + /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
117 + fprintf (stderr, gettext("%s: bad hostname \"%s\"\n"),
118 ProgramName, arg);
119 nfailed++;
121 @@ -308,12 +336,14 @@ change_host(Display *dpy, char *name, Bool add)
122 #endif
123 #endif
124 char *cp;
125 - static const char *add_msg = "being added to access control list";
126 - static const char *remove_msg = "being removed from access control list";
127 + const char *add_msg = gettext("being added to access control list");
128 + const char *remove_msg = gettext("being removed from access control list");
130 namelen = strlen(name);
131 if ((lname = (char *)malloc(namelen+1)) == NULL) {
132 - fprintf (stderr, "%s: malloc bombed in change_host\n", ProgramName);
133 + /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
134 + fprintf (stderr, gettext("%s: malloc bombed in change_host\n"),
135 + ProgramName);
136 exit (1);
138 for (i = 0; i < namelen; i++) {
139 @@ -325,7 +355,8 @@ change_host(Display *dpy, char *name, Bool add)
140 family = FamilyInternet;
141 name += 5;
142 #else
143 - fprintf (stderr, "%s: not compiled for TCP/IP\n", ProgramName);
144 + /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
145 + fprintf (stderr, gettext("%s: not compiled for TCP/IP\n"), ProgramName);
146 free(lname);
147 return 0;
148 #endif
149 @@ -335,7 +366,8 @@ change_host(Display *dpy, char *name, Bool add)
150 family = FamilyInternet6;
151 name += 6;
152 #else
153 - fprintf (stderr, "%s: not compiled for IPv6\n", ProgramName);
154 + /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
155 + fprintf (stderr, gettext("%s: not compiled for IPv6\n"), ProgramName);
156 free(lname);
157 return 0;
158 #endif
159 @@ -347,14 +379,16 @@ change_host(Display *dpy, char *name, Bool add)
160 family = FamilyInternet6;
161 name += 7;
162 #else
163 - fprintf (stderr, "%s: not compiled for IPv6\n", ProgramName);
164 + /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
165 + fprintf (stderr, gettext("%s: not compiled for IPv6\n"), ProgramName);
166 free(lname);
167 return 0;
168 #endif
170 #endif /* ACCEPT_INETV6 */
171 else if (!strncmp("dnet:", lname, 5)) {
172 - fprintf (stderr, "%s: not compiled for DECnet\n", ProgramName);
173 + /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
174 + fprintf (stderr, gettext("%s: not compiled for DECnet\n"), ProgramName);
175 free(lname);
176 return 0;
178 @@ -363,7 +397,8 @@ change_host(Display *dpy, char *name, Bool add)
179 family = FamilyNetname;
180 name += 4;
181 #else
182 - fprintf (stderr, "%s: not compiled for Secure RPC\n", ProgramName);
183 + /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
184 + fprintf (stderr, gettext("%s: not compiled for Secure RPC\n"), ProgramName);
185 free(lname);
186 return 0;
187 #endif
188 @@ -373,7 +408,8 @@ change_host(Display *dpy, char *name, Bool add)
189 family = FamilyKrb5Principal;
190 name +=4;
191 #else
192 - fprintf (stderr, "%s: not compiled for Kerberos 5\n", ProgramName);
193 + /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
194 + fprintf (stderr, gettext("%s: not compiled for Kerberos 5\n"), ProgramName);
195 free(lname);
196 return 0;
197 #endif
198 @@ -386,11 +422,22 @@ change_host(Display *dpy, char *name, Bool add)
199 name += 3;
201 if (family == FamilyWild && (cp = strchr(lname, ':'))) {
202 - *cp = '\0';
203 - fprintf (stderr, "%s: unknown address family \"%s\"\n",
204 - ProgramName, lname);
205 - free(lname);
206 - return 0;
207 +#ifdef IPv6
208 + /*
209 + * Check to see if inet_pton() can grok it as an IPv6 address
210 + */
211 + if (inet_pton(AF_INET6, lname, &addr6.s6_addr) == 1) {
212 + family = FamilyInternet6;
213 + } else
214 +#endif
216 + *cp = '\0';
217 + /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
218 + fprintf (stderr, gettext("%s: unknown address family \"%s\"\n"),
219 + ProgramName, lname);
220 + free(lname);
221 + return 0;
224 free(lname);
226 @@ -400,8 +447,8 @@ change_host(Display *dpy, char *name, Bool add)
228 cp = strchr(name, ':');
229 if (cp == NULL || cp == name) {
230 - fprintf(stderr,
231 - "%s: type must be specified for server interpreted family \"%s\"\n",
232 + fprintf(stderr, gettext(
233 + "%s: type must be specified for server interpreted family \"%s\"\n"),
234 ProgramName, name);
235 return 0;
237 @@ -429,7 +476,8 @@ change_host(Display *dpy, char *name, Bool add)
238 retval = krb5_parse_name(name, &princ);
239 if (retval) {
240 krb5_init_ets(); /* init krb errs for error_message() */
241 - fprintf(stderr, "%s: cannot parse Kerberos name: %s\n",
242 + /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
243 + fprintf(stderr, gettext("%s: cannot parse Kerberos name: %s\n"),
244 ProgramName, error_message(retval));
245 return 0;
247 @@ -456,7 +504,7 @@ change_host(Display *dpy, char *name, Bool add)
248 XAddHost(dpy, &ha);
249 else
250 XRemoveHost(dpy, &ha);
251 - printf( "non-network local connections %s\n", add ? add_msg : remove_msg);
252 + printf( gettext("non-network local connections %s\n"), add ? add_msg : remove_msg);
253 return 1;
256 @@ -475,12 +523,14 @@ change_host(Display *dpy, char *name, Bool add)
257 *cp = '\0';
258 pwd = getpwnam(name);
259 if (!pwd) {
260 - fprintf(stderr, "no such user \"%s\"\n", name);
261 + /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
262 + fprintf(stderr, gettext("no such user \"%s\"\n"), name);
263 return 0;
265 getdomainname(domainname, sizeof(domainname));
266 if (!user2netname(username, pwd->pw_uid, domainname)) {
267 - fprintf(stderr, "failed to get netname for \"%s\"\n", name);
268 + /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
269 + fprintf(stderr, gettext("failed to get netname for \"%s\"\n"), name);
270 return 0;
272 netname = username;
273 @@ -587,8 +637,11 @@ change_host(Display *dpy, char *name, Bool add)
274 familyMsg = "inet ";
277 - fprintf(stderr, "%s: unable to get %saddress for \"%s\"\n",
278 - ProgramName, familyMsg, name);
279 + /* L10N_Comments - Parts composed to make full error string
280 + 'unable to get' ['inet'|'inetv6'|''] 'address for' <address> */
281 + fprintf (stderr, "%s: %s %s%s \"%s\"\n", ProgramName,
282 + gettext("unable to get"), familyMsg, gettext("address for"),
283 + name);
285 freeaddrinfo(addresses);
286 return 1;
287 @@ -824,14 +877,16 @@ static int
288 local_xerror(Display *dpy, XErrorEvent *rep)
290 if ((rep->error_code == BadAccess) && (rep->request_code == X_ChangeHosts)) {
291 + /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
292 fprintf (stderr,
293 - "%s: must be on local machine to add or remove hosts.\n",
294 + gettext("%s: must be on local machine to add or remove hosts.\n"),
295 ProgramName);
296 return 1;
297 } else if ((rep->error_code == BadAccess) &&
298 (rep->request_code == X_SetAccessControl)) {
299 + /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
300 fprintf (stderr,
301 - "%s: must be on local machine to enable or disable access control.\n",
302 + gettext("%s: must be on local machine to enable or disable access control.\n"),
303 ProgramName);
304 return 1;
305 } else if ((rep->error_code == BadValue) &&