1 diff --git a/xhost.c b/xhost.c
2 index a67d136..0e867b0 100644
5 @@ -119,6 +119,11 @@ extern int getdomainname(char *name, size_t len);
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[])
21 + /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
23 + setlocale(LC_ALL,"");
24 + textdomain("xhost");
26 + /* mainly for debugging */
27 + if((domaindir=getenv("TEXTDOMAINDIR")) == NULL) {
28 + domaindir = "/usr/share/locale"; /*XLOCALEDIR;*/
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]);
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 */
46 + gettext("%s: unable to open display \"%s\"\n"),
47 ProgramName, XDisplayName (NULL));
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);
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"));
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"));
63 for (i = 0; i < nhosts; i++ ) {
64 @@ -222,16 +244,18 @@ main(int argc, char *argv[])
68 - printf("<unknown family type %d>:", list[i].family);
69 + printf(gettext("<unknown family type %d>:"), list[i].family);
72 printf ("%s", hostname);
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>"),
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"),
84 nameserver_timedout = 0;
86 @@ -248,26 +272,30 @@ main(int argc, char *argv[])
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);
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"),
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);
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"),
121 @@ -308,12 +336,14 @@ change_host(Display *dpy, char *name, Bool add)
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"),
138 for (i = 0; i < namelen; i++) {
139 @@ -325,7 +355,8 @@ change_host(Display *dpy, char *name, Bool add)
140 family = FamilyInternet;
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);
149 @@ -335,7 +366,8 @@ change_host(Display *dpy, char *name, Bool add)
150 family = FamilyInternet6;
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);
159 @@ -347,14 +379,16 @@ change_host(Display *dpy, char *name, Bool add)
160 family = FamilyInternet6;
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);
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);
178 @@ -363,7 +397,8 @@ change_host(Display *dpy, char *name, Bool add)
179 family = FamilyNetname;
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);
188 @@ -373,7 +408,8 @@ change_host(Display *dpy, char *name, Bool add)
189 family = FamilyKrb5Principal;
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);
198 @@ -386,11 +422,22 @@ change_host(Display *dpy, char *name, Bool add)
201 if (family == FamilyWild && (cp = strchr(lname, ':'))) {
203 - fprintf (stderr, "%s: unknown address family \"%s\"\n",
204 - ProgramName, lname);
209 + * Check to see if inet_pton() can grok it as an IPv6 address
211 + if (inet_pton(AF_INET6, lname, &addr6.s6_addr) == 1) {
212 + family = FamilyInternet6;
217 + /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
218 + fprintf (stderr, gettext("%s: unknown address family \"%s\"\n"),
219 + ProgramName, lname);
226 @@ -400,8 +447,8 @@ change_host(Display *dpy, char *name, Bool add)
228 cp = strchr(name, ':');
229 if (cp == NULL || cp == name) {
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"),
237 @@ -429,7 +476,8 @@ change_host(Display *dpy, char *name, Bool add)
238 retval = krb5_parse_name(name, &princ);
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));
247 @@ -456,7 +504,7 @@ change_host(Display *dpy, char *name, Bool add)
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);
256 @@ -475,12 +523,14 @@ change_host(Display *dpy, char *name, Bool add)
258 pwd = getpwnam(name);
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);
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);
273 @@ -587,8 +637,11 @@ change_host(Display *dpy, char *name, Bool add)
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"),
285 freeaddrinfo(addresses);
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 */
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"),
297 } else if ((rep->error_code == BadAccess) &&
298 (rep->request_code == X_SetAccessControl)) {
299 + /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
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"),
305 } else if ((rep->error_code == BadValue) &&