xhost.patch revision 1276
943N/Adiff --git a/xhost.c b/xhost.c
749N/Aindex 08f7c79..4a58a7a 100644
749N/A--- a/xhost.c
919N/A+++ b/xhost.c
919N/A@@ -142,6 +142,11 @@ extern int getdomainname(char *name, size_t len);
919N/A #endif
919N/A #endif
919N/A
749N/A+/* Internationalize messages for bug 4256527... S Swales 5/25/00 */
919N/A+#include <locale.h> /* setlocale() */
919N/A+#include <libintl.h> /* gettext(), textdomain(), etc. */
919N/A+#include <stdlib.h> /* getenv() */
749N/A+
919N/A static int change_host(Display *dpy, char *name, Bool add);
919N/A static const char *get_hostname(XHostAddress *ha);
919N/A static int local_xerror(Display *dpy, XErrorEvent *rep);
919N/A@@ -211,15 +216,30 @@ main(int argc, char *argv[])
919N/A char *cp;
919N/A #endif
919N/A
749N/A+ /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
749N/A+ char *domaindir;
749N/A+ setlocale(LC_ALL,"");
749N/A+ textdomain("xhost");
749N/A+
749N/A+ /* mainly for debugging */
749N/A+ if((domaindir=getenv("TEXTDOMAINDIR")) == NULL) {
749N/A+ domaindir = "/usr/share/locale"; /*XLOCALEDIR;*/
749N/A+ }
749N/A+ bindtextdomain("xhost",domaindir);
749N/A+
749N/A+
749N/A ProgramName = argv[0];
749N/A
749N/A if (argc == 2 && !strcmp(argv[1], "-help")) {
749N/A- fprintf(stderr, "usage: %s [[+-]hostname ...]\n", argv[0]);
749N/A+ /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
749N/A+ fprintf(stderr, gettext("usage: %s [[+-]hostname ...]\n"), argv[0]);
749N/A exit(1);
749N/A }
749N/A
749N/A if ((dpy = XOpenDisplay(NULL)) == NULL) {
749N/A- fprintf(stderr, "%s: unable to open display \"%s\"\n",
749N/A+ /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
749N/A+ fprintf(stderr,
+ gettext("%s: unable to open display \"%s\"\n"),
ProgramName, XDisplayName (NULL));
exit(1);
}
@@ -234,9 +254,11 @@ main(int argc, char *argv[])
sethostent(1); /* don't close the data base each time */
list = XListHosts(dpy, &nhosts, &enabled);
if (enabled)
- printf ("access control enabled, only authorized clients can connect\n");
+ /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
+ printf (gettext("access control enabled, only authorized clients can connect\n"));
else
- printf ("access control disabled, clients can connect from any host\n");
+ /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
+ printf (gettext("access control disabled, clients can connect from any host\n"));
if (nhosts != 0) {
for (i = 0; i < nhosts; i++ ) {
@@ -265,16 +287,18 @@ main(int argc, char *argv[])
printf("SI:");
break;
default:
- printf("<unknown family type %d>:", list[i].family);
+ printf(gettext("<unknown family type %d>:"), list[i].family);
break;
}
printf ("%s", hostname);
} else {
- printf ("<unknown address in family %d>",
+ /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
+ printf (gettext("<unknown address in family %d>"),
list[i].family);
}
if (nameserver_timedout) {
- printf("\t(no nameserver response within %d seconds)\n",
+ /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
+ printf(gettext("\t(no nameserver response within %d seconds)\n"),
NAMESERVER_TIMEOUT);
nameserver_timedout = 0;
} else
@@ -291,26 +315,30 @@ main(int argc, char *argv[])
if (*arg == '-') {
if (!argv[i][1] && ((i+1) == argc)) {
- printf ("access control enabled, only authorized clients can connect\n");
+ /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
+ printf (gettext("access control enabled, only authorized clients can connect\n"));
XEnableAccessControl(dpy);
} else {
arg = argv[i][1]? &argv[i][1] : argv[++i];
if (!change_host (dpy, arg, False)) {
- fprintf (stderr, "%s: bad hostname \"%s\"\n",
+ /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
+ fprintf (stderr, gettext("%s: bad hostname \"%s\"\n"),
ProgramName, arg);
nfailed++;
}
}
} else {
if (*arg == '+' && !argv[i][1] && ((i+1) == argc)) {
- printf ("access control disabled, clients can connect from any host\n");
+ /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
+ printf (gettext("access control disabled, clients can connect from any host\n"));
XDisableAccessControl(dpy);
} else {
if (*arg == '+') {
arg = argv[i][1]? &argv[i][1] : argv[++i];
}
if (!change_host (dpy, arg, True)) {
- fprintf (stderr, "%s: bad hostname \"%s\"\n",
+ /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
+ fprintf (stderr, gettext("%s: bad hostname \"%s\"\n"),
ProgramName, arg);
nfailed++;
}
@@ -355,12 +383,14 @@ change_host(Display *dpy, char *name, Bool add)
struct nodeent *np;
static struct dn_naddr dnaddr;
#endif /* DNETCONN */
- static const char *add_msg = "being added to access control list";
- static const char *remove_msg = "being removed from access control list";
+ const char *add_msg = gettext("being added to access control list");
+ const char *remove_msg = gettext("being removed from access control list");
namelen = strlen(name);
if ((lname = (char *)malloc(namelen+1)) == NULL) {
- fprintf (stderr, "%s: malloc bombed in change_host\n", ProgramName);
+ /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
+ fprintf (stderr, gettext("%s: malloc bombed in change_host\n"),
+ ProgramName);
exit (1);
}
for (i = 0; i < namelen; i++) {
@@ -372,8 +402,8 @@ change_host(Display *dpy, char *name, Bool add)
family = FamilyInternet;
name += 5;
#else
- fprintf (stderr, "%s: not compiled for TCP/IP\n", ProgramName);
- free(lname);
+ /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
+ fprintf (stderr, gettext("%s: not compiled for TCP/IP\n"), ProgramName);
return 0;
#endif
}
@@ -383,8 +413,8 @@ change_host(Display *dpy, char *name, Bool add)
family = FamilyInternet6;
name += 6;
#else
- fprintf (stderr, "%s: not compiled for IPv6\n", ProgramName);
- free(lname);
+ /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
+ fprintf (stderr, gettext("%s: not compiled for IPv6\n"), ProgramName);
return 0;
#endif
}
@@ -396,8 +426,8 @@ change_host(Display *dpy, char *name, Bool add)
family = FamilyInternet6;
name += 7;
#else
- fprintf (stderr, "%s: not compiled for IPv6\n", ProgramName);
- free(lname);
+ /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
+ fprintf (stderr, gettext("%s: not compiled for IPv6\n"), ProgramName);
return 0;
#endif
}
@@ -407,8 +437,8 @@ change_host(Display *dpy, char *name, Bool add)
family = FamilyDECnet;
name += 5;
#else
- fprintf (stderr, "%s: not compiled for DECnet\n", ProgramName);
- free(lname);
+ /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
+ fprintf (stderr, gettext("%s: not compiled for DECnet\n"), ProgramName);
return 0;
#endif
}
@@ -417,8 +447,8 @@ change_host(Display *dpy, char *name, Bool add)
family = FamilyNetname;
name += 4;
#else
- fprintf (stderr, "%s: not compiled for Secure RPC\n", ProgramName);
- free(lname);
+ /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
+ fprintf (stderr, gettext("%s: not compiled for Secure RPC\n"), ProgramName);
return 0;
#endif
}
@@ -427,8 +457,8 @@ change_host(Display *dpy, char *name, Bool add)
family = FamilyKrb5Principal;
name +=4;
#else
- fprintf (stderr, "%s: not compiled for Kerberos 5\n", ProgramName);
- free(lname);
+ /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
+ fprintf (stderr, gettext("%s: not compiled for Kerberos 5\n"), ProgramName);
return 0;
#endif
}
@@ -440,11 +470,21 @@ change_host(Display *dpy, char *name, Bool add)
name += 3;
}
if (family == FamilyWild && (cp = strchr(lname, ':'))) {
- *cp = '\0';
- fprintf (stderr, "%s: unknown address family \"%s\"\n",
- ProgramName, lname);
- free(lname);
- return 0;
+#ifdef IPv6
+ /*
+ * Check to see if inet_pton() can grok it as an IPv6 address
+ */
+ if (inet_pton(AF_INET6, lname, &addr6.s6_addr) == 1) {
+ family = FamilyInternet6;
+ } else
+#endif
+ {
+ *cp = '\0';
+ /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
+ fprintf (stderr, gettext("%s: unknown address family \"%s\"\n"),
+ ProgramName, lname);
+ return 0;
+ }
}
free(lname);
@@ -454,8 +494,8 @@ change_host(Display *dpy, char *name, Bool add)
cp = strchr(name, ':');
if (cp == NULL || cp == name) {
- fprintf(stderr,
- "%s: type must be specified for server interpreted family \"%s\"\n",
+ fprintf(stderr, gettext(
+ "%s: type must be specified for server interpreted family \"%s\"\n"),
ProgramName, name);
return 0;
}
@@ -485,7 +525,8 @@ change_host(Display *dpy, char *name, Bool add)
dnaddr = *dnaddrp;
} else {
if ((np = getnodebyname (name)) == NULL) {
- fprintf (stderr, "%s: unable to get node name for \"%s::\"\n",
+ /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
+ fprintf (stderr, gettext("%s: unable to get node name for \"%s::\"\n"),
ProgramName, name);
return 0;
}
@@ -511,7 +552,8 @@ change_host(Display *dpy, char *name, Bool add)
retval = krb5_parse_name(name, &princ);
if (retval) {
krb5_init_ets(); /* init krb errs for error_message() */
- fprintf(stderr, "%s: cannot parse Kerberos name: %s\n",
+ /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
+ fprintf(stderr, gettext("%s: cannot parse Kerberos name: %s\n"),
ProgramName, error_message(retval));
return 0;
}
@@ -537,7 +579,7 @@ change_host(Display *dpy, char *name, Bool add)
XAddHost(dpy, &ha);
else
XRemoveHost(dpy, &ha);
- printf( "non-network local connections %s\n", add ? add_msg : remove_msg);
+ printf( gettext("non-network local connections %s\n"), add ? add_msg : remove_msg);
return 1;
}
/*
@@ -556,12 +598,14 @@ change_host(Display *dpy, char *name, Bool add)
*cp = '\0';
pwd = getpwnam(name);
if (!pwd) {
- fprintf(stderr, "no such user \"%s\"\n", name);
+ /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
+ fprintf(stderr, gettext("no such user \"%s\"\n"), name);
return 0;
}
getdomainname(domainname, sizeof(domainname));
if (!user2netname(username, pwd->pw_uid, domainname)) {
- fprintf(stderr, "failed to get netname for \"%s\"\n", name);
+ /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
+ fprintf(stderr, gettext("failed to get netname for \"%s\"\n"), name);
return 0;
}
netname = username;
@@ -668,8 +712,11 @@ change_host(Display *dpy, char *name, Bool add)
familyMsg = "inet ";
}
- fprintf(stderr, "%s: unable to get %saddress for \"%s\"\n",
- ProgramName, familyMsg, name);
+ /* L10N_Comments - Parts composed to make full error string
+ 'unable to get' ['inet'|'inetv6'|''] 'address for' <address> */
+ fprintf (stderr, "%s: %s %s%s \"%s\"\n", ProgramName,
+ gettext("unable to get"), familyMsg, gettext("address for"),
+ name);
}
freeaddrinfo(addresses);
return 1;
@@ -947,14 +994,16 @@ static int
local_xerror(Display *dpy, XErrorEvent *rep)
{
if ((rep->error_code == BadAccess) && (rep->request_code == X_ChangeHosts)) {
+ /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
fprintf (stderr,
- "%s: must be on local machine to add or remove hosts.\n",
+ gettext("%s: must be on local machine to add or remove hosts.\n"),
ProgramName);
return 1;
} else if ((rep->error_code == BadAccess) &&
(rep->request_code == X_SetAccessControl)) {
+ /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
fprintf (stderr,
- "%s: must be on local machine to enable or disable access control.\n",
+ gettext("%s: must be on local machine to enable or disable access control.\n"),
ProgramName);
return 1;
} else if ((rep->error_code == BadValue) &&