aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--networking/whois.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/networking/whois.c b/networking/whois.c
index 5ef83672d..6ba8dfd20 100644
--- a/networking/whois.c
+++ b/networking/whois.c
@@ -21,13 +21,18 @@
21//kbuild:lib-$(CONFIG_WHOIS) += whois.o 21//kbuild:lib-$(CONFIG_WHOIS) += whois.o
22 22
23//usage:#define whois_trivial_usage 23//usage:#define whois_trivial_usage
24//usage: "[-h SERVER] [-p PORT] NAME..." 24//usage: "[-i] [-h SERVER] [-p PORT] NAME..."
25//usage:#define whois_full_usage "\n\n" 25//usage:#define whois_full_usage "\n\n"
26//usage: "Query WHOIS info about NAME\n" 26//usage: "Query WHOIS info about NAME\n"
27//usage: "\n -i Show redirect results too"
27//usage: "\n -h,-p Server to query" 28//usage: "\n -h,-p Server to query"
28 29
29#include "libbb.h" 30#include "libbb.h"
30 31
32enum {
33 OPT_i = (1 << 0),
34};
35
31static char *query(const char *host, int port, const char *domain) 36static char *query(const char *host, int port, const char *domain)
32{ 37{
33 int fd; 38 int fd;
@@ -53,6 +58,7 @@ static char *query(const char *host, int port, const char *domain)
53 buf = xrealloc(buf, bufpos + len + 1); 58 buf = xrealloc(buf, bufpos + len + 1);
54 memcpy(buf + bufpos, linebuf, len); 59 memcpy(buf + bufpos, linebuf, len);
55 bufpos += len; 60 bufpos += len;
61 buf[bufpos] = '\0';
56 62
57 if (!redir || !success) { 63 if (!redir || !success) {
58 trim(linebuf); 64 trim(linebuf);
@@ -73,7 +79,7 @@ static char *query(const char *host, int port, const char *domain)
73 fclose(fp); /* closes fd too */ 79 fclose(fp); /* closes fd too */
74 if (!success && !pfx[0]) { 80 if (!success && !pfx[0]) {
75 /* 81 /*
76 * Looking at jwhois.conf, some whois servers use 82 * Looking at /etc/jwhois.conf, some whois servers use
77 * "domain = DOMAIN", "DOMAIN ID <DOMAIN>" 83 * "domain = DOMAIN", "DOMAIN ID <DOMAIN>"
78 * and "domain=DOMAIN_WITHOUT_LAST_COMPONENT" 84 * and "domain=DOMAIN_WITHOUT_LAST_COMPONENT"
79 * formats, but those are rare. 85 * formats, but those are rare.
@@ -91,11 +97,9 @@ static char *query(const char *host, int port, const char *domain)
91 free(redir); 97 free(redir);
92 redir = NULL; 98 redir = NULL;
93 } 99 }
94 if (!redir) { 100 if (!redir || (option_mask32 & OPT_i)) {
95 /* Output saved text */ 101 /* Output saved text */
96 printf("[%s]\n", host); 102 printf("[%s]\n%s", host, buf ? buf : "");
97 buf[bufpos] = '\0';
98 fputs(buf, stdout);
99 } 103 }
100 free(buf); 104 free(buf);
101 return redir; 105 return redir;
@@ -164,7 +168,7 @@ int whois_main(int argc UNUSED_PARAM, char **argv)
164 const char *host = "whois.iana.org"; 168 const char *host = "whois.iana.org";
165 169
166 opt_complementary = "-1:p+"; 170 opt_complementary = "-1:p+";
167 getopt32(argv, "h:p:", &host, &port); 171 getopt32(argv, "ih:p:", &host, &port);
168 argv += optind; 172 argv += optind;
169 173
170 do { 174 do {