From 04a32155d857383002ab380d4df3693e396098fe Mon Sep 17 00:00:00 2001 From: peter Date: Sun, 20 Aug 1995 22:22:38 +0000 Subject: Update 4.9.3.beta9p1 -> 4.9.3-beta24 --- usr.bin/dig/dig.c | 59 ++++++++++++++++++++++++++++++++++------------------- usr.bin/host/host.c | 48 ++++++++++++++++++++++++++----------------- 2 files changed, 67 insertions(+), 40 deletions(-) (limited to 'usr.bin') diff --git a/usr.bin/dig/dig.c b/usr.bin/dig/dig.c index 6ac5865..e6978a5 100644 --- a/usr.bin/dig/dig.c +++ b/usr.bin/dig/dig.c @@ -1,5 +1,5 @@ #ifndef lint -static char rcsid[] = "$Id: dig.c,v 4.9.1.17 1994/07/19 22:51:24 vixie Exp $"; +static char rcsid[] = "$Id: dig.c,v 8.4 1995/06/19 08:35:06 vixie Exp $"; #endif /* @@ -197,8 +197,7 @@ jmp_buf env; HostInfo *defaultPtr = NULL; HostInfo curHostInfo, defaultRec; int curHostValid = FALSE; -int queryType = T_A; -int queryClass = C_IN; +int queryType, queryClass; extern int StringToClass(), StringToType(); /* subr.c */ #if defined(BSD) && BSD >= 199006 && !defined(RISCOS_BSD) FILE *yyin = NULL; @@ -221,7 +220,7 @@ stackarg(y, l) case '\t': case ' ': l++; break; - case NULL: + case '\0': case '\n': done++; *y = NULL; @@ -246,7 +245,12 @@ main(argc, argv) { struct hostent *hp; short port = htons(NAMESERVER_PORT); - u_char packet[PACKETSZ]; + /* Wierd stuff for SPARC alignment, hurts nothing else. */ + union { + HEADER header_; + u_char packet_[PACKETSZ]; + } packet_; +#define packet (packet_.packet_) u_char answer[8*1024]; int n; char doping[90]; @@ -260,7 +264,7 @@ main(argc, argv) int anyflag = 0; int sticky = 0; int tmp; - int qtype = 1, qclass = 1; + int qtypeSet; int addrflag = 0; int zone = 0; int bytes_out, bytes_in; @@ -283,6 +287,7 @@ main(argc, argv) res_init(); _res.pfcode = PRF_DEF; + qtypeSet = 0; gethostname(myhostname, (sizeof myhostname)); defsrv = strcat(defbuf, inet_ntoa(_res.nsaddr.sin_addr)); res_x = _res; @@ -296,7 +301,7 @@ main(argc, argv) if ((((afile = (char *) getenv("LOCALDEF")) != (char *) NULL) && ((fp = open(afile, O_RDONLY)) > 0)) || ((fp = open(SAVEENV, O_RDONLY)) > 0)) { - read(fp, &res_x, (sizeof res_x)); + read(fp, (char *)&res_x, (sizeof res_x)); close(fp); _res = res_x; } @@ -362,7 +367,8 @@ main(argc, argv) stackarg(ay, qptr); /* defaults */ - qtype = qclass = 1; + queryType = T_NS; + queryClass = C_IN; zone = 0; *pingstr = 0; srv = NULL; @@ -408,11 +414,11 @@ main(argc, argv) case 'c': if ((tmp = atoi(*++argv)) || *argv[0]=='0') { - qclass = tmp; + queryClass = tmp; } else if (tmp = StringToClass(*argv, 0, NULL) ) { - qclass = tmp; + queryClass = tmp; } else { printf( "; invalid class specified\n" @@ -422,11 +428,13 @@ main(argc, argv) case 't': if ((tmp = atoi(*++argv)) || *argv[0]=='0') { - qtype = tmp; + queryType = tmp; + qtypeSet++; } else if (tmp = StringToType(*argv, 0, NULL) ) { - qtype = tmp; + queryType = tmp; + qtypeSet++; } else { printf( "; invalid type specified\n" @@ -434,8 +442,10 @@ main(argc, argv) } break; case 'x': - if (qtype == T_A) - qtype = T_ANY; + if (!qtypeSet) { + queryType = T_ANY; + qtypeSet++; + } if (!(addrc = *++argv)) { printf( "; no arg for -x?\n" @@ -472,18 +482,19 @@ main(argc, argv) if ((tmp = StringToType(*argv, -1, NULL)) != -1) { if ((T_ANY == tmp) && anyflag++) { - qclass = C_ANY; + queryClass = C_ANY; continue; } if (T_AXFR == tmp) { _res.pfcode = PRF_ZONE; zone++; } else { - qtype = tmp; + queryType = tmp; + qtypeSet++; } } else if ((tmp = StringToClass(*argv, -1, NULL)) != -1) { - qclass = tmp; + queryClass = tmp; } else { bzero(domain, (sizeof domain)); sprintf(domain,"%s",*argv); @@ -518,7 +529,7 @@ main(argc, argv) ((fp = open(SAVEENV, O_WRONLY|O_CREAT|O_TRUNC, S_IREAD|S_IWRITE)) > 0)) { - write(fp, &_res, (sizeof _res)); + write(fp, (char *)&_res, (sizeof _res)); close(fp); } envsave = 0; @@ -622,7 +633,13 @@ main(argc, argv) continue; } - bytes_out = n = res_mkquery(QUERY, domain, qclass, qtype, + if (*domain && !qtypeSet) { + queryType = T_A; + qtypeSet++; + } + + bytes_out = n = res_mkquery(QUERY, domain, + queryClass, queryType, NULL, 0, NULL, packet, sizeof(packet)); if (n < 0) { @@ -1011,7 +1028,7 @@ printZone(zone, sin) __putshort(msglen, (u_char *)&len); if (write(sockFD, (char *)&len, INT16SZ) != INT16SZ || - write(sockFD, (char *) &buf, msglen) != msglen) { + write(sockFD, (char *)&buf, msglen) != msglen) { int e = errno; perror(";; write"); (void) close(sockFD); @@ -1046,7 +1063,7 @@ printZone(zone, sin) * The server sent too much data to fit the existing buffer -- * allocate a new one. */ - if (len > answerLen) { + if (len > (u_int)answerLen) { if (answerLen != 0) { free(answer); } diff --git a/usr.bin/host/host.c b/usr.bin/host/host.c index e041e4e..9efb95b 100644 --- a/usr.bin/host/host.c +++ b/usr.bin/host/host.c @@ -67,7 +67,7 @@ char copyright[] = */ #ifndef lint -static char rcsid[] = "$Id: host.c,v 4.9.1.13 1994/07/19 22:51:24 vixie Exp $"; +static char rcsid[] = "$Id: host.c,v 8.5 1995/06/29 09:26:32 vixie Exp $"; #endif /* not lint */ #include @@ -360,10 +360,10 @@ printanswer(hp) printf("\n\n"); } -hperror(errno) -int errno; +hperror(errnum) +int errnum; { -switch(errno) { +switch(errnum) { case HOST_NOT_FOUND: fprintf(stderr,"Host not found.\n"); break; @@ -459,7 +459,7 @@ gethostinfo(name) char *name; { register char *cp, **domain; - int n; + u_int n; int hp; int nDomain; int asis = 0; @@ -765,15 +765,20 @@ pr_rr(cp, msg, file, filter) case T_HINFO: case T_ISDN: - if (n = *cp++) { - if (doprint) - fprintf(file,"%c%.*s", punc, n, cp); - cp += n; - } - if (n = *cp++) { - if (doprint) - fprintf(file,"%c%.*s", punc, n, cp); - cp += n; + { + u_char *cp2 = cp + dlen; + if (n = *cp++) { + if (doprint) + fprintf(file,"%c%.*s", punc, n, cp); + cp += n; + } + if ((cp < cp2) && (n = *cp++)) { + if (doprint) + fprintf(file,"%c%.*s", punc, n, cp); + cp += n; + } else if (type == T_HINFO) + if (doprint) + fprintf(file,"\n; *** Warning *** OS-type missing"); } break; @@ -805,10 +810,13 @@ pr_rr(cp, msg, file, filter) case T_AFSDB: case T_RT: if (doprint) - if (verbose) - fprintf(file,"\t%ld ",_getshort(cp)); + if (type == T_MX) + fprintf(file," (pri=%d) by ", _getshort(cp)); else - fprintf(file," "); + if (verbose) + fprintf(file,"\t%d ", _getshort(cp)); + else + fprintf(file," "); cp += sizeof(u_short); cp = (u_char *)pr_cdname(cp, msg, name, sizeof(name)); if (doprint) @@ -842,7 +850,7 @@ pr_rr(cp, msg, file, filter) while (cp < end) { if (n = *cp++) { for (j = n; j > 0 && cp < end ; j --) - if (*cp == '\n') { + if ((*cp == '\n') || (*cp == '"')) { if (doprint){ (void) putc('\\', file); (void) putc(*cp++, file); @@ -947,7 +955,7 @@ pr_type(type) case T_MG: /* mail group member */ return("MG"); case T_MX: /* mail routing info */ - return(verbose? "MX" : "mail is handled by"); + return(verbose? "MX" : "mail is handled"); case T_TXT: /* TXT - descriptive info */ return(verbose? "TXT" : "descriptive text"); case T_AFSDB: /* AFS/DCE info */ @@ -1447,7 +1455,9 @@ DecodeError(result) case NXDOMAIN: return("Non-existent domain"); break; case NOTIMP: return("Not implemented"); break; case REFUSED: return("Query refused"); break; +#ifdef NOCHANGE case NOCHANGE: return("No change"); break; +#endif case NO_INFO: return("No information"); break; case ERROR: return("Unspecified error"); break; case TIME_OUT: return("Timed out"); break; -- cgit v1.1