1
/* vi: set sw=4 ts=4: */
3
* whois - tiny client for the whois directory service
5
* Copyright (c) 2011 Pere Orga <gotrunks@gmail.com>
6
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
14
//config: bool "whois"
17
//config: whois is a client for the whois directory service
19
//applet:IF_WHOIS(APPLET(whois, BB_DIR_USR_BIN, BB_SUID_DROP))
21
//kbuild:lib-$(CONFIG_WHOIS) += whois.o
23
//usage:#define whois_trivial_usage
24
//usage: "[-h SERVER] [-p PORT] NAME..."
25
//usage:#define whois_full_usage "\n\n"
26
//usage: "Query WHOIS info about NAME\n"
27
//usage: "\n -h,-p Server to query"
31
static void pipe_out(int fd)
36
fp = xfdopen_for_read(fd);
37
while (fgets(buf, sizeof(buf), fp)) {
38
char *p = strpbrk(buf, "\r\n");
44
fclose(fp); /* closes fd too */
47
int whois_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
48
int whois_main(int argc UNUSED_PARAM, char **argv)
51
const char *host = "whois-servers.net";
53
opt_complementary = "-1:p+";
54
getopt32(argv, "h:p:", &host, &port);
58
int fd = create_and_connect_stream_or_die(host, port);
59
fdprintf(fd, "%s\r\n", *argv);