return indication of whether nameserver found a match
authorEric Allman <eric@ucbvax.Berkeley.EDU>
Sun, 6 Oct 1991 02:07:08 +0000 (18:07 -0800)
committerEric Allman <eric@ucbvax.Berkeley.EDU>
Sun, 6 Oct 1991 02:07:08 +0000 (18:07 -0800)
SCCS-vsn: usr.sbin/sendmail/src/domain.c 5.29
SCCS-vsn: usr.sbin/sendmail/src/daemon.c 5.39

usr/src/usr.sbin/sendmail/src/daemon.c
usr/src/usr.sbin/sendmail/src/domain.c

index 6cd4709..505b1b4 100644 (file)
@@ -12,9 +12,9 @@
 
 #ifndef lint
 #ifdef DAEMON
 
 #ifndef lint
 #ifdef DAEMON
-static char sccsid[] = "@(#)daemon.c   5.38 (Berkeley) %G% (with daemon mode)";
+static char sccsid[] = "@(#)daemon.c   5.39 (Berkeley) %G% (with daemon mode)";
 #else
 #else
-static char sccsid[] = "@(#)daemon.c   5.38 (Berkeley) %G% (without daemon mode)";
+static char sccsid[] = "@(#)daemon.c   5.39 (Berkeley) %G% (without daemon mode)";
 #endif
 #endif /* not lint */
 
 #endif
 #endif /* not lint */
 
@@ -389,8 +389,7 @@ myhostname(hostbuf, size)
        else
                return (NULL);
 }
        else
                return (NULL);
 }
-
-/*
+\f/*
  *  MAPHOSTNAME -- turn a hostname into canonical form
  *
  *     Parameters:
  *  MAPHOSTNAME -- turn a hostname into canonical form
  *
  *     Parameters:
@@ -398,7 +397,8 @@ myhostname(hostbuf, size)
  *             hbsize -- the size of hbuf.
  *
  *     Returns:
  *             hbsize -- the size of hbuf.
  *
  *     Returns:
- *             none.
+ *             TRUE if the host name was mapped.
+ *             FALSE otherwise.
  *
  *     Side Effects:
  *             Looks up the host specified in hbuf.  If it is not
  *
  *     Side Effects:
  *             Looks up the host specified in hbuf.  If it is not
@@ -406,6 +406,8 @@ myhostname(hostbuf, size)
  *             the canonical name.  If the name is unknown, or it
  *             is already the canonical name, leave it unchanged.
  */
  *             the canonical name.  If the name is unknown, or it
  *             is already the canonical name, leave it unchanged.
  */
+
+bool
 maphostname(hbuf, hbsize)
        char *hbuf;
        int hbsize;
 maphostname(hbuf, hbsize)
        char *hbuf;
        int hbsize;
@@ -421,20 +423,19 @@ maphostname(hbuf, hbsize)
         * strip the brackets and to preserve hbuf if address is
         * unknown.
         */
         * strip the brackets and to preserve hbuf if address is
         * unknown.
         */
-       if (*hbuf != '[') {
-               getcanonname(hbuf, hbsize);
-               return;
-       }
+       if (*hbuf != '[')
+               return (getcanonname(hbuf, hbsize));
        if ((cp = index(strcpy(ptr, hbuf), ']')) == NULL)
        if ((cp = index(strcpy(ptr, hbuf), ']')) == NULL)
-               return;
+               return (FALSE);
        *cp = '\0';
        in_addr = inet_addr(&ptr[1]);
        hp = gethostbyaddr((char *)&in_addr, sizeof(struct in_addr), AF_INET);
        if (hp == NULL)
        *cp = '\0';
        in_addr = inet_addr(&ptr[1]);
        hp = gethostbyaddr((char *)&in_addr, sizeof(struct in_addr), AF_INET);
        if (hp == NULL)
-               return;
+               return (FALSE);
        if (strlen(hp->h_name) >= hbsize)
                hp->h_name[hbsize - 1] = '\0';
        (void)strcpy(hbuf, hp->h_name);
        if (strlen(hp->h_name) >= hbsize)
                hp->h_name[hbsize - 1] = '\0';
        (void)strcpy(hbuf, hp->h_name);
+       return (TRUE);
 }
 
 # else DAEMON
 }
 
 # else DAEMON
@@ -473,7 +474,8 @@ myhostname(hostbuf, size)
 **             hbsize -- the size of hbuf.
 **
 **     Returns:
 **             hbsize -- the size of hbuf.
 **
 **     Returns:
-**             none.
+**             TRUE if the hostname was mapped.
+**             FALSE otherwise.
 **
 **     Side Effects:
 **             Looks up the host specified in hbuf.  If it is not
 **
 **     Side Effects:
 **             Looks up the host specified in hbuf.  If it is not
@@ -483,11 +485,12 @@ myhostname(hostbuf, size)
 */
 
 /*ARGSUSED*/
 */
 
 /*ARGSUSED*/
+bool
 maphostname(hbuf, hbsize)
        char *hbuf;
        int hbsize;
 {
 maphostname(hbuf, hbsize)
        char *hbuf;
        int hbsize;
 {
-       return;
+       return (FALSE);
 }
 
 #endif DAEMON
 }
 
 #endif DAEMON
index 0edc78f..1a528e4 100644 (file)
@@ -10,9 +10,9 @@
 
 #ifndef lint
 #ifdef NAMED_BIND
 
 #ifndef lint
 #ifdef NAMED_BIND
-static char sccsid[] = "@(#)domain.c   5.28 (Berkeley) %G% (with name server)";
+static char sccsid[] = "@(#)domain.c   5.29 (Berkeley) %G% (with name server)";
 #else
 #else
-static char sccsid[] = "@(#)domain.c   5.28 (Berkeley) %G% (without name server)";
+static char sccsid[] = "@(#)domain.c   5.29 (Berkeley) %G% (without name server)";
 #endif
 #endif /* not lint */
 
 #endif
 #endif /* not lint */
 
@@ -159,6 +159,7 @@ punt:               mxhosts[0] = strcpy(hostbuf, host);
        return(nmx);
 }
 
        return(nmx);
 }
 
+bool
 getcanonname(host, hbsize)
        char *host;
        int hbsize;
 getcanonname(host, hbsize)
        char *host;
        int hbsize;
@@ -170,6 +171,7 @@ getcanonname(host, hbsize)
        querybuf answer;
        u_short type;
        int first, ancount, qdcount, loopcnt;
        querybuf answer;
        u_short type;
        int first, ancount, qdcount, loopcnt;
+       bool rval = FALSE;
        char nbuf[PACKETSZ];
 
        loopcnt = 0;
        char nbuf[PACKETSZ];
 
        loopcnt = 0;
@@ -188,7 +190,7 @@ loop:
                if (tTd(8, 1))
                        printf("getcanonname:  res_search failed (errno=%d, h_errno=%d)\n",
                            errno, h_errno);
                if (tTd(8, 1))
                        printf("getcanonname:  res_search failed (errno=%d, h_errno=%d)\n",
                            errno, h_errno);
-               return;
+               return (rval);
        }
 
        /* find first satisfactory answer */
        }
 
        /* find first satisfactory answer */
@@ -199,13 +201,13 @@ loop:
        if (ancount == 0) {
                if (tTd(8, 1))
                        printf("rcode = %d, ancount=%d\n", hp->rcode, ancount);
        if (ancount == 0) {
                if (tTd(8, 1))
                        printf("rcode = %d, ancount=%d\n", hp->rcode, ancount);
-               return;
+               return (rval);
        }
        cp = (u_char *)&answer + sizeof(HEADER);
        eom = (u_char *)&answer + n;
        for (qdcount = ntohs(hp->qdcount); qdcount--; cp += n + QFIXEDSZ)
                if ((n = dn_skipname(cp, eom)) < 0)
        }
        cp = (u_char *)&answer + sizeof(HEADER);
        eom = (u_char *)&answer + n;
        for (qdcount = ntohs(hp->qdcount); qdcount--; cp += n + QFIXEDSZ)
                if ((n = dn_skipname(cp, eom)) < 0)
-                       return;
+                       return (rval);
 
        /*
         * just in case someone puts a CNAME record after another record,
 
        /*
         * just in case someone puts a CNAME record after another record,
@@ -216,6 +218,7 @@ loop:
                if ((n = dn_expand((u_char *)&answer,
                    eom, cp, (u_char *)nbuf, sizeof(nbuf))) < 0)
                        break;
                if ((n = dn_expand((u_char *)&answer,
                    eom, cp, (u_char *)nbuf, sizeof(nbuf))) < 0)
                        break;
+               rval = TRUE;
                if (first) {                    /* XXX */
                        (void)strncpy(host, nbuf, hbsize);
                        host[hbsize - 1] = '\0';
                if (first) {                    /* XXX */
                        (void)strncpy(host, nbuf, hbsize);
                        host[hbsize - 1] = '\0';
@@ -241,12 +244,14 @@ loop:
                        goto loop;
                }
        }
                        goto loop;
                }
        }
+       return (rval);
 }
 
 #else /* not NAMED_BIND */
 
 #include <netdb.h>
 
 }
 
 #else /* not NAMED_BIND */
 
 #include <netdb.h>
 
+bool
 getcanonname(host, hbsize)
        char *host;
        int hbsize;
 getcanonname(host, hbsize)
        char *host;
        int hbsize;
@@ -255,12 +260,13 @@ getcanonname(host, hbsize)
 
        hp = gethostbyname(host);
        if (hp == NULL)
 
        hp = gethostbyname(host);
        if (hp == NULL)
-               return;
+               return (FALSE);
 
        if (strlen(hp->h_name) >= hbsize)
 
        if (strlen(hp->h_name) >= hbsize)
-               return;
+               return (FALSE);
 
        (void) strcpy(host, hp->h_name);
 
        (void) strcpy(host, hp->h_name);
+       return (TRUE);
 }
 
 #endif /* not NAMED_BIND */
 }
 
 #endif /* not NAMED_BIND */