[3445] in Athena Bugs

home help back first fref pref prev next nref lref last post

patch for hostinfo

daemon@ATHENA.MIT.EDU (John T Kohl)
Wed Oct 18 15:00:28 1989

Date: Wed, 18 Oct 89 15:00:07 EDT
From: John T Kohl <jtkohl@ATHENA.MIT.EDU>
To: bugs@ATHENA.MIT.EDU
I've seen several complaints that 'hostinfo' doesn't interpret the error
codes.  Here's a simple patch to fix that:

*** /tmp/,RCSt1a19251	Wed Oct 18 14:58:59 1989
--- hostinfo.c	Wed Oct 18 14:57:28 1989
***************
*** 55,60 ****
--- 55,61 ----
  {
    extern int getopt();
    extern int optind;
+   extern int h_errno;
  
    char hostname[LINE_LENGTH];	           /* Name of desired host. */
    struct hostent *host_entry = NULL;	   /* Host entry of it. */
***************
*** 96,103 ****
      }
    if (host_entry == NULL)
      {
!       printf("No such host.\n");
!       exit(ERROR);
      }
    bcopy(host_entry->h_addr, &internet_address, host_entry->h_length);
    if (h_flag) printf("%s\n", host_entry->h_name);
--- 97,127 ----
      }
    if (host_entry == NULL)
      {
! 	switch (h_errno) {
! #ifdef ultrix
! 	/* it can return NULL, h_errno == 0 in some cases when
! 	   there is no name */
! 	case 0:
! #endif
! 	case HOST_NOT_FOUND:
! 	    printf("No such host '%s'.\n",hostname);
! 	    exit(ERROR);
! 	    break;
! 	default:
! 	case TRY_AGAIN:
! 	case NO_RECOVERY:
! 	    printf("Cannot resolve name '%s' due to network difficulties.\n",
! 		   hostname);
! 	    exit(ERROR);
! 	    break;
! 	case NO_ADDRESS:
! 	    /* should look up MX record? */
! 	    /* this error return appears if there is some entry for the
! 	       requested name, but no A record (e.g. only an NS record) */
! 	    printf("No address for '%s'.\n", hostname);
! 	    exit(ERROR);
! 	    break;
! 	}
      }
    bcopy(host_entry->h_addr, &internet_address, host_entry->h_length);
    if (h_flag) printf("%s\n", host_entry->h_name);

home help back first fref pref prev next nref lref last post