public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Whois
@ 2001-06-29  5:23 Bob Zimmerman
  2001-07-02 15:03 ` Whois Gerrit P. Haase
  0 siblings, 1 reply; 3+ messages in thread
From: Bob Zimmerman @ 2001-06-29  5:23 UTC (permalink / raw)
  To: cygwin

Is there a port of WHOIS? 

I checked a mirror of the "porters" and couldn't find anything. Thanks.

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Whois
  2001-06-29  5:23 Whois Bob Zimmerman
@ 2001-07-02 15:03 ` Gerrit P. Haase
  0 siblings, 0 replies; 3+ messages in thread
From: Gerrit P. Haase @ 2001-07-02 15:03 UTC (permalink / raw)
  To: Bob Zimmerman; +Cc: cygwin

Bob Zimmerman schrieb am 2001-06-29, 7:23:

> Is there a port of WHOIS? 

I don't know who wrote it, i found it in the cygwin archives:

/*
 * Cygwin whois
 */

#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <errno.h>
#include <netdb.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <getopt.h>

#define	NICHOST		"whois.internic.net"
#define	DNICHOST	"whois.nic.mil"
#define	GNICHOST	"whois.nic.gov"
#define	ANICHOST	"whois.arin.net"
#define	RNICHOST	"whois.ripe.net"
#define	PNICHOST	"whois.apnic.net"
#define RUNICHOST   "whois.ripn.net"
#define DENICHOST   "whois.nic.de"
#define	WHOIS_PORT	43

static void usage (void);

int
main(int argc, char **argv)
{
	register FILE *sfi, *sfo;
	register int ch;
	struct sockaddr_in sin;
	struct hostent *hp;
	struct servent *sp;
	int s;
	char *host;

#ifdef	SOCKS
	SOCKSinit(argv[0]);
#endif

	host = NICHOST;
	while ((ch = getopt(argc, argv, "badgh:prR")) != -1)
		switch((char)ch) {
		case 'b':
			host = DENICHOST;
			break;
		case 'a':
			host = ANICHOST;
			break;
		case 'd':
			host = DNICHOST;
			break;
		case 'g':
			host = GNICHOST;
			break;
		case 'h':
			host = optarg;
			break;
		case 'p':
			host = PNICHOST;
			break;
		case 'r':
			host = RNICHOST;
			break;
		case 'R':
			host = RUNICHOST;
			break;
		case '?':
		default:
			usage();
		}
	argc -= optind;
	argv += optind;

	if (!argc)
		usage();

	s = socket(PF_INET, SOCK_STREAM, 0);
	if (s < 0){
		fprintf(stderr, "%s: %s", "socket", strerror(errno));
		return -1;
	}

	memset(&sin, 0, sizeof sin);
/*	sin.sin_len = sizeof sin; */
	sin.sin_family = AF_INET;
	
	hp = gethostbyname(host);
	if (hp == NULL){
		fprintf(stderr, "%s: %s", host, "gethostbyname() failed\n");
		return -2;
	}
	host = (char *)hp->h_name;
	sin.sin_addr = *(struct in_addr *)hp->h_addr_list[0];

	sp = getservbyname("whois", "tcp");
	if (sp == NULL)
		sin.sin_port = htons(WHOIS_PORT);
	else
		sin.sin_port = sp->s_port;

	if (connect(s, (struct sockaddr *)&sin, sizeof(sin)) < 0){
		fprintf(stderr, "%s: %s", "connect", strerror(errno));
		return -3;
	}

	sfi = fdopen(s, "r");
	sfo = fdopen(s, "w");
	if (sfi == NULL || sfo == NULL){
		fprintf(stderr, "%s: %s", "fdopen", strerror(errno));
		return -5;
	}
	while (argc-- > 1)
		(void)fprintf(sfo, "%s ", *argv++);
	(void)fprintf(sfo, "%s\r\n", *argv);
	(void)fflush(sfo);
	while ((ch = getc(sfi)) != EOF)
		putchar(ch);
	exit(0);
}

static void
usage()
{
	fprintf(stderr, "usage: whois [-badgprR] [-h hostname] name ...\n");
	exit(-5);
}


/* gph */

-- 
=^..^=

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* whois
@ 2000-07-29  6:14 Vladimir Dubrovin
  0 siblings, 0 replies; 3+ messages in thread
From: Vladimir Dubrovin @ 2000-07-29  6:14 UTC (permalink / raw)
  To: cygwin

[-- Attachment #1: Type: text/plain, Size: 432 bytes --]

Hello cygwin,

  I  found no "whois" in Cygwin and ported one from FreeBSD with minor
  changes.
  May be you need one, sorry if not.


   Vladimir Dubrovin                  Sandy, ISP
    Sandy CCd chief               Customers Care dept
  http://www.sandy.ru           Nizhny Novgorod, Russia
 
http://www.security.nnov.ru
whois.c
--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com


[-- Attachment #2: whois.c --]
[-- Type: text/x-c, Size: 4247 bytes --]

/*
 * Copyright (c) 1980, 1993
 *	The Regents of the University of California.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *	This product includes software developed by the University of
 *	California, Berkeley and its contributors.
 * 4. Neither the name of the University nor the names of its contributors
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 */

/*
 * Cygwin port by 3APA3A@security.nnov.ru
 */

#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
/*#include <err.h>*/
#include <errno.h>
#include <netdb.h>
#include <stdio.h>
#include <string.h>
/*#include <sysexits.h>*/
#include <unistd.h>
#include <getopt.h>

#define	NICHOST		"whois.internic.net"
#define	DNICHOST	"whois.nic.mil"
#define	GNICHOST	"whois.nic.gov"
#define	ANICHOST	"whois.arin.net"
#define	RNICHOST	"whois.ripe.net"
#define	PNICHOST	"whois.apnic.net"
#define RUNICHOST       "whois.ripn.net"
#define	WHOIS_PORT	43

static void usage (void);

int
main(int argc, char **argv)
{
	register FILE *sfi, *sfo;
	register int ch;
	struct sockaddr_in sin;
	struct hostent *hp;
	struct servent *sp;
	int s;
	char *host;

#ifdef	SOCKS
	SOCKSinit(argv[0]);
#endif

	host = NICHOST;
	while ((ch = getopt(argc, argv, "adgh:prR")) != -1)
		switch((char)ch) {
		case 'a':
			host = ANICHOST;
			break;
		case 'd':
			host = DNICHOST;
			break;
		case 'g':
			host = GNICHOST;
			break;
		case 'h':
			host = optarg;
			break;
		case 'p':
			host = PNICHOST;
			break;
		case 'r':
			host = RNICHOST;
			break;
		case 'R':
			host = RUNICHOST;
			break;
		case '?':
		default:
			usage();
		}
	argc -= optind;
	argv += optind;

	if (!argc)
		usage();

	s = socket(PF_INET, SOCK_STREAM, 0);
	if (s < 0){
		fprintf(stderr, "%s: %s", "socket", strerror(errno));
		return -1;
	}

	memset(&sin, 0, sizeof sin);
/*	sin.sin_len = sizeof sin; */
	sin.sin_family = AF_INET;
	
	hp = gethostbyname(host);
	if (hp == NULL){
		fprintf(stderr, "%s: %s", host, "gethostbyname() failed\n");
		return -2;
	}
	host = (char *)hp->h_name;
	sin.sin_addr = *(struct in_addr *)hp->h_addr_list[0];

	sp = getservbyname("whois", "tcp");
	if (sp == NULL)
		sin.sin_port = htons(WHOIS_PORT);
	else
		sin.sin_port = sp->s_port;

	if (connect(s, (struct sockaddr *)&sin, sizeof(sin)) < 0){
		fprintf(stderr, "%s: %s", "connect", strerror(errno));
		return -3;
	}

	sfi = fdopen(s, "r");
	sfo = fdopen(s, "w");
	if (sfi == NULL || sfo == NULL){
		fprintf(stderr, "%s: %s", "fdopen", strerror(errno));
		return -5;
	}
	while (argc-- > 1)
		(void)fprintf(sfo, "%s ", *argv++);
	(void)fprintf(sfo, "%s\r\n", *argv);
	(void)fflush(sfo);
	while ((ch = getc(sfi)) != EOF)
		putchar(ch);
	exit(0);
}

static void
usage()
{
	fprintf(stderr, "usage: whois [-adgprR] [-h hostname] name ...\n");
	exit(-5);
}

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2001-07-02 15:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-06-29  5:23 Whois Bob Zimmerman
2001-07-02 15:03 ` Whois Gerrit P. Haase
  -- strict thread matches above, loose matches on Subject: below --
2000-07-29  6:14 whois Vladimir Dubrovin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).