diff options
author | Simon J. Gerraty <sjg@FreeBSD.org> | 2014-04-28 07:50:45 +0000 |
---|---|---|
committer | Simon J. Gerraty <sjg@FreeBSD.org> | 2014-04-28 07:50:45 +0000 |
commit | 3b8f08459569bf0faa21473e5cec2491e95c9349 (patch) | |
tree | 80f45dd81ca716bcd7ca9674581e1fc40b93cd34 /usr.bin/whois | |
parent | 9d2ab4a62d6733c45958627ac113bdbd818d1e2a (diff) | |
parent | b2ba55951383498f252746f618d513139da06e8e (diff) | |
download | src-test2-3b8f08459569bf0faa21473e5cec2491e95c9349.tar.gz src-test2-3b8f08459569bf0faa21473e5cec2491e95c9349.zip |
Notes
Diffstat (limited to 'usr.bin/whois')
-rw-r--r-- | usr.bin/whois/whois.1 | 1 | ||||
-rw-r--r-- | usr.bin/whois/whois.c | 18 |
2 files changed, 9 insertions, 10 deletions
diff --git a/usr.bin/whois/whois.1 b/usr.bin/whois/whois.1 index 287a42e5bff9..0f0f17739937 100644 --- a/usr.bin/whois/whois.1 +++ b/usr.bin/whois/whois.1 @@ -62,7 +62,6 @@ nor by .Tn ARIN whois database end with .Qq Li -ARIN . ) -.Pp .It Fl A Use the Asia/Pacific Network Information Center .Pq Tn APNIC diff --git a/usr.bin/whois/whois.c b/usr.bin/whois/whois.c index d76d05a672bc..99926b8e111a 100644 --- a/usr.bin/whois/whois.c +++ b/usr.bin/whois/whois.c @@ -275,7 +275,7 @@ s_asprintf(char **ret, const char *format, ...) static void whois(const char *query, const char *hostname, int flags) { - FILE *sfi, *sfo; + FILE *fp; struct addrinfo *hostres, *res; char *buf, *host, *nhost, *p; int i, s; @@ -295,20 +295,19 @@ whois(const char *query, const char *hostname, int flags) if (res == NULL) err(EX_OSERR, "connect()"); - sfi = fdopen(s, "r"); - sfo = fdopen(s, "w"); - if (sfi == NULL || sfo == NULL) + fp = fdopen(s, "r+"); + if (fp == NULL) err(EX_OSERR, "fdopen()"); if (strcmp(hostname, GERMNICHOST) == 0) { - fprintf(sfo, "-T dn,ace -C US-ASCII %s\r\n", query); + fprintf(fp, "-T dn,ace -C US-ASCII %s\r\n", query); } else if (strcmp(hostname, "dk" QNICHOST_TAIL) == 0) { - fprintf(sfo, "--show-handles %s\r\n", query); + fprintf(fp, "--show-handles %s\r\n", query); } else { - fprintf(sfo, "%s\r\n", query); + fprintf(fp, "%s\r\n", query); } - fflush(sfo); + fflush(fp); nhost = NULL; - while ((buf = fgetln(sfi, &len)) != NULL) { + while ((buf = fgetln(fp, &len)) != NULL) { while (len > 0 && isspace((unsigned char)buf[len - 1])) buf[--len] = '\0'; printf("%.*s\n", (int)len, buf); @@ -350,6 +349,7 @@ whois(const char *query, const char *hostname, int flags) } } } + fclose(fp); if (nhost != NULL) { whois(query, nhost, 0); free(nhost); |