]> Pileus Git - ~andy/fetchmail/blobdiff - checkalias.c
Tweak in lexical analysis.
[~andy/fetchmail] / checkalias.c
index 317cd2d1e99f989674db961228ca2c8e7bff4a78..d3d1cb07b18bde7152697ae67028298089cd9b24 100644 (file)
@@ -6,6 +6,7 @@
  */
 #include "config.h"
 #ifdef HAVE_GETHOSTBYNAME
+#include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
 #include <sys/types.h>
@@ -13,6 +14,7 @@
 #include <netinet/in.h>
 #include <arpa/inet.h>
 #include <netdb.h>
+#include "i18n.h"
 #include "mx.h"
 #include "fetchmail.h"
 
@@ -22,7 +24,6 @@ static int is_ip_alias(const char *name1,const char *name2)
 /*
  * Given two hostnames as arguments, returns TRUE if they
  * have at least one IP address in common.
- * It is meant to be called by the is_host_alias() function in driver.c
  * No check is done on errors returned by gethostbyname,
  * the calling function does them.
  */
@@ -34,7 +35,8 @@ static int is_ip_alias(const char *name1,const char *name2)
        address_t address;
     } 
     address_e;
-    address_e *host_a_addr, *host_b_addr,*dummy_addr;
+    address_e *host_a_addr=0, *host_b_addr=0;  /* assignments pacify -Wall */
+    address_e *dummy_addr;
 
     int i;
     struct hostent *hp;
@@ -48,7 +50,7 @@ static int is_ip_alias(const char *name1,const char *name2)
     {
        struct in_addr in;
        (void) memcpy(&in.s_addr, *p, sizeof (in.s_addr));
-       host_a_addr = (address_e *)xmalloc(sizeof( address_e));
+       xalloca(host_a_addr, address_e *, sizeof (address_e));
        memset (host_a_addr,0, sizeof (address_e));
        host_a_addr->next = dummy_addr;
        (void) memcpy(&host_a_addr->address, *p, sizeof (in.s_addr));
@@ -62,7 +64,7 @@ static int is_ip_alias(const char *name1,const char *name2)
     {
        struct in_addr in;
        (void) memcpy(&in.s_addr, *p, sizeof (in.s_addr));
-       host_b_addr = (address_e *)xmalloc(sizeof( address_e));
+       xalloca(host_b_addr, address_e *, sizeof (address_e));
        memset (host_b_addr,0, sizeof (address_e));
        host_b_addr->next = dummy_addr;
        (void) memcpy(&host_b_addr->address, *p, sizeof (in.s_addr));
@@ -84,7 +86,7 @@ static int is_ip_alias(const char *name1,const char *name2)
 }
 
 int is_host_alias(const char *name, struct query *ctl)
-/* determine whether name is a DNS alias of the hostname */
+/* determine whether name is a DNS alias of the mailserver for this query */
 {
     struct hostent     *he,*he_st;
     struct mxentry     *mxp, *mxrecords;
@@ -121,12 +123,12 @@ int is_host_alias(const char *name, struct query *ctl)
 #else
     /*
      * The only code that calls the BIND library is here and in the
-     * start-of-query probe with gethostbyname(3).
+     * start-of-run probe with gethostbyname(3) under ETRN/Kerberos.
      *
-     * We know DNS service was up at the beginning of this poll cycle.
+     * We know DNS service was up at the beginning of the run.
      * If it's down, our nameserver has crashed.  We don't want to try
-     * delivering the current message or anything else from this
-     * mailbox until it's back up.
+     * delivering the current message or anything else from the
+     * current server until it's back up.
      */
     else if ((he = gethostbyname(name)) != (struct hostent *)NULL)
     {
@@ -134,16 +136,16 @@ int is_host_alias(const char *name, struct query *ctl)
            goto match;
         else if (((he_st = gethostbyname(ctl->server.truename)) != (struct hostent *)NULL) && ctl->server.checkalias)
        {
-           if (outlevel == O_VERBOSE)
-               error(0, 0, "Checking if %s is really the same node as %s",ctl->server.truename,name);
+           if (outlevel >= O_DEBUG)
+               report(stdout, _("Checking if %s is really the same node as %s\n"),ctl->server.truename,name);
            if (is_ip_alias(ctl->server.truename,name) == TRUE)
            {
-               if (outlevel == O_VERBOSE)
-                   error(0, 0, "Yes, their IP addresses match");
+               if (outlevel >= O_DEBUG)
+                   report(stdout, _("Yes, their IP addresses match\n"));
                goto match;
            }
-           if (outlevel == O_VERBOSE)
-               error(0, 0, "No, their IP addresses don't match");
+           if (outlevel >= O_DEBUG)
+               report(stdout, _("No, their IP addresses don't match\n"));
        }
        else
            return(FALSE);
@@ -159,9 +161,9 @@ int is_host_alias(const char *name, struct query *ctl)
        case TRY_AGAIN:         /* temporary error on authoritative server */
        default:
            if (outlevel != O_SILENT)
-               putchar('\n');  /* terminate the progress message */
-           error(0, 0,
-               "nameserver failure while looking for `%s' during poll of %s.",
+               report_complete(stdout, "\n");  /* terminate the progress message */
+           report(stderr,
+               _("nameserver failure while looking for `%s' during poll of %s.\n"),
                name, ctl->server.pollname);
            ctl->errcount++;
            break;
@@ -185,8 +187,8 @@ int is_host_alias(const char *name, struct query *ctl)
        case NO_RECOVERY:       /* non-recoverable name server error */
        case TRY_AGAIN:         /* temporary error on authoritative server */
        default:
-           error(0, -1,
-               "nameserver failure while looking for `%s' during poll of %s.",
+           report(stderr,
+               _("nameserver failure while looking for `%s' during poll of %s.\n"),
                name, ctl->server.pollname);
            ctl->errcount++;
            break;