1276N/Adiff --git a/xhost.c b/xhost.c
1370N/Aindex a67d136..f43b267 100644
1276N/A--- a/xhost.c
1276N/A+++ b/xhost.c
1370N/A@@ -119,6 +119,11 @@ extern int getdomainname(char *name, size_t len);
294N/A #endif
294N/A #endif
294N/A
294N/A+/* Internationalize messages for bug 4256527... S Swales 5/25/00 */
294N/A+#include <locale.h> /* setlocale() */
294N/A+#include <libintl.h> /* gettext(), textdomain(), etc. */
294N/A+#include <stdlib.h> /* getenv() */
294N/A+
294N/A static int change_host(Display *dpy, char *name, Bool add);
1276N/A static const char *get_hostname(XHostAddress *ha);
294N/A static int local_xerror(Display *dpy, XErrorEvent *rep);
1370N/A@@ -171,15 +176,30 @@ main(int argc, char *argv[])
1370N/A Bool enabled = False;
1370N/A Display *dpy;
294N/A
294N/A+ /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
294N/A+ char *domaindir;
294N/A+ setlocale(LC_ALL,"");
294N/A+ textdomain("xhost");
294N/A+
294N/A+ /* mainly for debugging */
294N/A+ if((domaindir=getenv("TEXTDOMAINDIR")) == NULL) {
851N/A+ domaindir = "/usr/share/locale"; /*XLOCALEDIR;*/
294N/A+ }
294N/A+ bindtextdomain("xhost",domaindir);
294N/A+
294N/A+
294N/A ProgramName = argv[0];
294N/A
1276N/A if (argc == 2 && !strcmp(argv[1], "-help")) {
1276N/A- fprintf(stderr, "usage: %s [[+-]hostname ...]\n", argv[0]);
1276N/A+ /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
1276N/A+ fprintf(stderr, gettext("usage: %s [[+-]hostname ...]\n"), argv[0]);
1276N/A exit(1);
1276N/A }
1276N/A
294N/A if ((dpy = XOpenDisplay(NULL)) == NULL) {
294N/A- fprintf(stderr, "%s: unable to open display \"%s\"\n",
294N/A+ /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
294N/A+ fprintf(stderr,
294N/A+ gettext("%s: unable to open display \"%s\"\n"),
294N/A ProgramName, XDisplayName (NULL));
294N/A exit(1);
294N/A }
1370N/A@@ -191,9 +211,11 @@ main(int argc, char *argv[])
294N/A sethostent(1); /* don't close the data base each time */
294N/A list = XListHosts(dpy, &nhosts, &enabled);
294N/A if (enabled)
294N/A- printf ("access control enabled, only authorized clients can connect\n");
294N/A+ /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
294N/A+ printf (gettext("access control enabled, only authorized clients can connect\n"));
294N/A else
294N/A- printf ("access control disabled, clients can connect from any host\n");
294N/A+ /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
294N/A+ printf (gettext("access control disabled, clients can connect from any host\n"));
294N/A
294N/A if (nhosts != 0) {
294N/A for (i = 0; i < nhosts; i++ ) {
1370N/A@@ -222,16 +244,18 @@ main(int argc, char *argv[])
294N/A printf("SI:");
294N/A break;
294N/A default:
294N/A- printf("<unknown family type %d>:", list[i].family);
294N/A+ printf(gettext("<unknown family type %d>:"), list[i].family);
294N/A break;
294N/A }
294N/A printf ("%s", hostname);
294N/A } else {
294N/A- printf ("<unknown address in family %d>",
294N/A+ /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
294N/A+ printf (gettext("<unknown address in family %d>"),
294N/A list[i].family);
294N/A }
294N/A if (nameserver_timedout) {
294N/A- printf("\t(no nameserver response within %d seconds)\n",
294N/A+ /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
294N/A+ printf(gettext("\t(no nameserver response within %d seconds)\n"),
294N/A NAMESERVER_TIMEOUT);
294N/A nameserver_timedout = 0;
294N/A } else
1370N/A@@ -248,26 +272,30 @@ main(int argc, char *argv[])
294N/A if (*arg == '-') {
294N/A
294N/A if (!argv[i][1] && ((i+1) == argc)) {
294N/A- printf ("access control enabled, only authorized clients can connect\n");
294N/A+ /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
294N/A+ printf (gettext("access control enabled, only authorized clients can connect\n"));
294N/A XEnableAccessControl(dpy);
294N/A } else {
294N/A arg = argv[i][1]? &argv[i][1] : argv[++i];
294N/A if (!change_host (dpy, arg, False)) {
294N/A- fprintf (stderr, "%s: bad hostname \"%s\"\n",
294N/A+ /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
294N/A+ fprintf (stderr, gettext("%s: bad hostname \"%s\"\n"),
294N/A ProgramName, arg);
294N/A nfailed++;
294N/A }
294N/A }
294N/A } else {
294N/A if (*arg == '+' && !argv[i][1] && ((i+1) == argc)) {
294N/A- printf ("access control disabled, clients can connect from any host\n");
294N/A+ /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
294N/A+ printf (gettext("access control disabled, clients can connect from any host\n"));
294N/A XDisableAccessControl(dpy);
294N/A } else {
294N/A if (*arg == '+') {
294N/A arg = argv[i][1]? &argv[i][1] : argv[++i];
294N/A }
294N/A if (!change_host (dpy, arg, True)) {
294N/A- fprintf (stderr, "%s: bad hostname \"%s\"\n",
294N/A+ /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
294N/A+ fprintf (stderr, gettext("%s: bad hostname \"%s\"\n"),
294N/A ProgramName, arg);
294N/A nfailed++;
294N/A }
1370N/A@@ -308,12 +336,14 @@ change_host(Display *dpy, char *name, Bool add)
1370N/A #endif
1370N/A #endif
1370N/A char *cp;
1276N/A- static const char *add_msg = "being added to access control list";
1276N/A- static const char *remove_msg = "being removed from access control list";
294N/A+ const char *add_msg = gettext("being added to access control list");
294N/A+ const char *remove_msg = gettext("being removed from access control list");
294N/A
294N/A namelen = strlen(name);
294N/A if ((lname = (char *)malloc(namelen+1)) == NULL) {
294N/A- fprintf (stderr, "%s: malloc bombed in change_host\n", ProgramName);
294N/A+ /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
294N/A+ fprintf (stderr, gettext("%s: malloc bombed in change_host\n"),
294N/A+ ProgramName);
294N/A exit (1);
294N/A }
294N/A for (i = 0; i < namelen; i++) {
1370N/A@@ -325,8 +355,8 @@ change_host(Display *dpy, char *name, Bool add)
294N/A family = FamilyInternet;
294N/A name += 5;
294N/A #else
294N/A- fprintf (stderr, "%s: not compiled for TCP/IP\n", ProgramName);
294N/A- free(lname);
294N/A+ /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
294N/A+ fprintf (stderr, gettext("%s: not compiled for TCP/IP\n"), ProgramName);
294N/A return 0;
294N/A #endif
294N/A }
1370N/A@@ -335,8 +365,8 @@ change_host(Display *dpy, char *name, Bool add)
294N/A family = FamilyInternet6;
294N/A name += 6;
294N/A #else
294N/A- fprintf (stderr, "%s: not compiled for IPv6\n", ProgramName);
294N/A- free(lname);
294N/A+ /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
294N/A+ fprintf (stderr, gettext("%s: not compiled for IPv6\n"), ProgramName);
294N/A return 0;
294N/A #endif
294N/A }
1370N/A@@ -347,15 +377,15 @@ change_host(Display *dpy, char *name, Bool add)
294N/A family = FamilyInternet6;
294N/A name += 7;
294N/A #else
294N/A- fprintf (stderr, "%s: not compiled for IPv6\n", ProgramName);
294N/A- free(lname);
294N/A+ /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
294N/A+ fprintf (stderr, gettext("%s: not compiled for IPv6\n"), ProgramName);
294N/A return 0;
294N/A #endif
294N/A }
1370N/A #endif /* ACCEPT_INETV6 */
1370N/A else if (!strncmp("dnet:", lname, 5)) {
294N/A- fprintf (stderr, "%s: not compiled for DECnet\n", ProgramName);
294N/A- free(lname);
294N/A+ /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
294N/A+ fprintf (stderr, gettext("%s: not compiled for DECnet\n"), ProgramName);
294N/A return 0;
294N/A }
1370N/A else if (!strncmp("nis:", lname, 4)) {
1370N/A@@ -363,8 +393,8 @@ change_host(Display *dpy, char *name, Bool add)
294N/A family = FamilyNetname;
294N/A name += 4;
294N/A #else
294N/A- fprintf (stderr, "%s: not compiled for Secure RPC\n", ProgramName);
294N/A- free(lname);
294N/A+ /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
294N/A+ fprintf (stderr, gettext("%s: not compiled for Secure RPC\n"), ProgramName);
294N/A return 0;
294N/A #endif
294N/A }
1370N/A@@ -373,8 +403,8 @@ change_host(Display *dpy, char *name, Bool add)
294N/A family = FamilyKrb5Principal;
294N/A name +=4;
294N/A #else
294N/A- fprintf (stderr, "%s: not compiled for Kerberos 5\n", ProgramName);
294N/A- free(lname);
294N/A+ /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
294N/A+ fprintf (stderr, gettext("%s: not compiled for Kerberos 5\n"), ProgramName);
294N/A return 0;
294N/A #endif
294N/A }
1370N/A@@ -386,11 +416,21 @@ change_host(Display *dpy, char *name, Bool add)
294N/A name += 3;
294N/A }
294N/A if (family == FamilyWild && (cp = strchr(lname, ':'))) {
294N/A- *cp = '\0';
294N/A- fprintf (stderr, "%s: unknown address family \"%s\"\n",
294N/A- ProgramName, lname);
294N/A- free(lname);
294N/A- return 0;
294N/A+#ifdef IPv6
294N/A+ /*
294N/A+ * Check to see if inet_pton() can grok it as an IPv6 address
294N/A+ */
294N/A+ if (inet_pton(AF_INET6, lname, &addr6.s6_addr) == 1) {
294N/A+ family = FamilyInternet6;
294N/A+ } else
294N/A+#endif
294N/A+ {
294N/A+ *cp = '\0';
294N/A+ /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
294N/A+ fprintf (stderr, gettext("%s: unknown address family \"%s\"\n"),
294N/A+ ProgramName, lname);
294N/A+ return 0;
294N/A+ }
294N/A }
294N/A free(lname);
294N/A
1370N/A@@ -400,8 +440,8 @@ change_host(Display *dpy, char *name, Bool add)
294N/A
294N/A cp = strchr(name, ':');
294N/A if (cp == NULL || cp == name) {
294N/A- fprintf(stderr,
294N/A- "%s: type must be specified for server interpreted family \"%s\"\n",
294N/A+ fprintf(stderr, gettext(
294N/A+ "%s: type must be specified for server interpreted family \"%s\"\n"),
294N/A ProgramName, name);
294N/A return 0;
294N/A }
1370N/A@@ -429,7 +469,8 @@ change_host(Display *dpy, char *name, Bool add)
294N/A retval = krb5_parse_name(name, &princ);
294N/A if (retval) {
294N/A krb5_init_ets(); /* init krb errs for error_message() */
294N/A- fprintf(stderr, "%s: cannot parse Kerberos name: %s\n",
294N/A+ /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
294N/A+ fprintf(stderr, gettext("%s: cannot parse Kerberos name: %s\n"),
294N/A ProgramName, error_message(retval));
294N/A return 0;
294N/A }
1370N/A@@ -456,7 +497,7 @@ change_host(Display *dpy, char *name, Bool add)
294N/A XAddHost(dpy, &ha);
294N/A else
294N/A XRemoveHost(dpy, &ha);
294N/A- printf( "non-network local connections %s\n", add ? add_msg : remove_msg);
294N/A+ printf( gettext("non-network local connections %s\n"), add ? add_msg : remove_msg);
294N/A return 1;
294N/A }
294N/A /*
1370N/A@@ -475,12 +516,14 @@ change_host(Display *dpy, char *name, Bool add)
294N/A *cp = '\0';
294N/A pwd = getpwnam(name);
294N/A if (!pwd) {
294N/A- fprintf(stderr, "no such user \"%s\"\n", name);
294N/A+ /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
294N/A+ fprintf(stderr, gettext("no such user \"%s\"\n"), name);
294N/A return 0;
294N/A }
294N/A getdomainname(domainname, sizeof(domainname));
294N/A if (!user2netname(username, pwd->pw_uid, domainname)) {
294N/A- fprintf(stderr, "failed to get netname for \"%s\"\n", name);
294N/A+ /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
294N/A+ fprintf(stderr, gettext("failed to get netname for \"%s\"\n"), name);
294N/A return 0;
294N/A }
294N/A netname = username;
1370N/A@@ -587,8 +630,11 @@ change_host(Display *dpy, char *name, Bool add)
294N/A familyMsg = "inet ";
294N/A }
294N/A
294N/A- fprintf(stderr, "%s: unable to get %saddress for \"%s\"\n",
294N/A- ProgramName, familyMsg, name);
294N/A+ /* L10N_Comments - Parts composed to make full error string
294N/A+ 'unable to get' ['inet'|'inetv6'|''] 'address for' <address> */
294N/A+ fprintf (stderr, "%s: %s %s%s \"%s\"\n", ProgramName,
294N/A+ gettext("unable to get"), familyMsg, gettext("address for"),
294N/A+ name);
294N/A }
294N/A freeaddrinfo(addresses);
294N/A return 1;
1370N/A@@ -824,14 +870,16 @@ static int
294N/A local_xerror(Display *dpy, XErrorEvent *rep)
294N/A {
294N/A if ((rep->error_code == BadAccess) && (rep->request_code == X_ChangeHosts)) {
294N/A+ /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
294N/A fprintf (stderr,
294N/A- "%s: must be on local machine to add or remove hosts.\n",
294N/A+ gettext("%s: must be on local machine to add or remove hosts.\n"),
294N/A ProgramName);
294N/A return 1;
294N/A } else if ((rep->error_code == BadAccess) &&
294N/A (rep->request_code == X_SetAccessControl)) {
294N/A+ /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
294N/A fprintf (stderr,
294N/A- "%s: must be on local machine to enable or disable access control.\n",
294N/A+ gettext("%s: must be on local machine to enable or disable access control.\n"),
294N/A ProgramName);
294N/A return 1;
294N/A } else if ((rep->error_code == BadValue) &&