Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 17 Nov 1997 18:20:03 -0800 (PST)
From:      Sean Eric Fagan <sef@kithrup.com>
To:        freebsd-bugs
Subject:   Re: bin/5073
Message-ID:  <199711180220.SAA06470@hub.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/5073; it has been noted by GNATS.

From: Sean Eric Fagan <sef@kithrup.com>
To: freebsd-gnats-submit@freebsd.org
Cc:  Subject: Re: bin/5073
Date: Mon, 17 Nov 1997 18:10:33 -0800 (PST)

 This patch should fix it; I've submitted it to Paul Vixie, so hopefully
 it'll be incorporated.
 
 Remember, kids:  getopt(3) is your friend.
 
 Index: host.c
 ===================================================================
 RCS file: /usr/cvs/src/contrib/bind/tools/host.c,v
 retrieving revision 1.1.1.1.2.1
 diff -u -r1.1.1.1.2.1 host.c
 --- host.c	1997/06/28 07:36:45	1.1.1.1.2.1
 +++ host.c	1997/11/18 01:59:45
 @@ -79,6 +79,7 @@
  #include <arpa/nameser.h>
  
  #include <stdio.h>
 +#include <stdlib.h>
  #include <netdb.h>
  #include <resolv.h>
  #include <ctype.h>
 @@ -135,63 +136,52 @@
  	register waitmode = 0;
  	char *oldcname;
  	int ncnames;
 +	int o;
  
  	res_init();
  	_res.retrans = 5;
  
 -	if (c < 2) {
 -		fprintf(stderr, "Usage: host [-w] [-v] [-r] [-d] [-t querytype] [-c class] [-a] host [server]\n  -w to wait forever until reply\n  -v for verbose output\n  -r to disable recursive processing\n  -d to turn on debugging output\n  -t querytype to look fo r a specific type of information\n  -c class to look for non-Internet data\n  -a is equivalent to '-v -t *'\n");
 -		exit(1);
 +	while ((o = getopt(c, v, "wvrdt:c:a")) != EOF) {
 +	  switch (o) {
 +	  default:
 +	    fprintf(stderr, "Usage: host [-w] [-v] [-r] [-d] [-t querytype] "
 +		    "[-c class] [-a] host [server]\n  -w to wait forever "
 +		    "until reply\n  -v for verbose output\n  -r to disable "
 +		    "recursive processing\n  -d to turn on debugging output"
 +		    "\n  -t querytype to look for a specific type of infor"
 +		    "mation\n  -c class to look for non-Internet data\n  "
 +		    "-a is equivalent to '-v -t *'\n");
 +	    exit(1);
 +	  case 'w':
 +	    _res.retry = 1; _res.retrans = 15;
 +	    waitmode = 1;
 +	    break;
 +	  case 'r':
 +	    _res.options &= ~RES_RECURSE;
 +	    break;
 +	  case 'd':
 +	    _res.options |= RES_DEBUG;
 +	    break;
 +	  case 'v':
 +	    verbose = 1;
 +	    break;
 +	  case 'l':
 +	    list = 1;
 +	    break ;
 +	  case 't':
 +	    gettype = parsetype(optarg);
 +	    break;
 +	  case 'c':
 +	    getclass = parseclass(optarg);
 +	    break;
 +	  case 'a':
 +	    verbose = 1;
 +	    gettype = T_ANY;
 +	    break;
 +	  }
  	}
 -	while (c > 2 && v[1][0] == '-') {
 -		if (strcmp (v[1], "-w") == 0) {
 -			_res.retry = 1;
 -			_res.retrans = 15;
 -			waitmode = 1;
 -			v++;
 -			c--;
 -		}
 -		else if (strcmp (v[1], "-r") == 0) {
 -			_res.options &= ~RES_RECURSE;
 -			v++;
 -			c--;
 -		}
 -		else if (strcmp (v[1], "-d") == 0) {
 -			_res.options |= RES_DEBUG;
 -			v++;
 -			c--;
 -		}
 -		else if (strcmp (v[1], "-v") == 0) {
 -			verbose = 1;
 -			v++;
 -			c--;
 -		}
 -		else if (strcmp (v[1], "-l") == 0) {
 -			list = 1;
 -			v++;
 -			c--;
 -		}
 -		else if (strncmp (v[1], "-t", 2) == 0) {
 -			v++;
 -			c--;
 -			gettype = parsetype(v[1]);
 -			v++;
 -			c--;
 -		}
 -		else if (strncmp (v[1], "-c", 2) == 0) {
 -			v++;
 -			c--;
 -			getclass = parseclass(v[1]);
 -			v++;
 -			c--;
 -		}
 -		else if (strcmp (v[1], "-a") == 0) {
 -			verbose = 1;
 -			gettype = T_ANY;
 -			v++;
 -			c--;
 -		}		
 -        }
 +	c -= optind;
 +	v += optind;
  	if (c > 2) {
  		s = v[2];
  		server_specified++;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199711180220.SAA06470>