Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 5 Dec 1999 17:12:26 -0600
From:      "Bob Madden" <bob@clapton.atgsystems.com>
To:        "Rodney W. Grimes" <freebsd@gndrsh.dnsmgr.net>, "FreeBSD-Stable" <FreeBSD-Stable@FreeBSD.ORG>
Cc:        "Bob Madden" <bob@clapton.atgsystems.com>
Subject:   Re: Little whois patch.
Message-ID:  <005e01bf3f76$32bd2290$01000000@madman>

next in thread | raw e-mail | index | archive | help
Well, the day that Network Solutions turned over authority of Internic.net,
etc, to the DOC, I found this source, and compiled it on FreeBSD just fine,
although I do note that it was originally written for Linux:

***** BEGIN PASTE ****************

/*
 *    whois.c:
 *
 *     whois - Internet user name directory service
 *
 *     whois [ -h server ] name
 *
 *     the -h option specifies the hostname or IP address of a whois server.
 *     (see the README file for details)
 *
 * Copyright (c) 1980 Regents of the University of California.
 * All rights reserved.  The Berkeley software License Agreement
 * specifies the terms and conditions for redistribution.
 */
/* Minor hack to support accessing arin.net by default for
   non-alpha queries */

#ifndef lint
char copyright[] =
"@(#) Copyright (c) 1980 Regents of the University of California.\n\
 All rights reserved.\n";
#endif not lint

#ifndef lint
static char sccsid[] = "@(#)whois.c     5.3 (Berkeley) 2/8/88";
#endif not lint

#include <sys/types.h>
#include <sys/socket.h>

#include <netinet/in.h>

#include <stdio.h>
#include <netdb.h>

#define NICHOST "whois.networksolutions.com"
#define IPHOST "whois.arin.net"

main(argc, argv)
        int argc;
        char *argv[];
{
        int s;
        register FILE *sfi, *sfo;
        register int c;
        char *host = IPHOST;
        struct sockaddr_in sin;
        struct hostent *hp;
        struct servent *sp;
        char *p;

        argc--, argv++;
        if (argc > 2 && strcmp(*argv, "-h") == 0) {
                argv++, argc--;
                host = *argv++;
                argc--;
        }
        if (argc != 1) {
                fprintf(stderr, "usage: whois [ -h host ] name\n");
                exit(1);
        }
        /* Use NICHOST if any character is alpha */
        if(host == IPHOST) {
          p = *argv;
          while(*p) {
            if(isalpha(*p++))
              host = NICHOST;
          }
        }
        hp = gethostbyname(host);
        if (hp == NULL) {
                fprintf(stderr, "whois: ");
                herror(host);
                exit(1);
        }
        host = hp->h_name;
        s = socket(hp->h_addrtype, SOCK_STREAM, 0);
        if (s < 0) {
                perror("whois: socket");
                exit(2);
        }
        bzero((caddr_t)&sin, sizeof (sin));
        sin.sin_family = hp->h_addrtype;
        if (bind(s, &sin, sizeof (sin)) < 0) {
                perror("whois: bind");
                exit(3);
        }
        bcopy(hp->h_addr, &sin.sin_addr, hp->h_length);
        sp = getservbyname("whois", "tcp");
        if (sp == NULL) {
                fprintf(stderr, "whois: whois/tcp: unknown service\n");
                exit(4);
        }
        sin.sin_port = sp->s_port;
        if (connect(s, &sin, sizeof (sin)) < 0) {
                perror("whois: connect");
                exit(5);
        }
        sfi = fdopen(s, "r");
        sfo = fdopen(s, "w");
        if (sfi == NULL || sfo == NULL) {
                perror("fdopen");
                close(s);
                exit(1);
        }
        fprintf(sfo, "%s\r\n", *argv);
        fflush(sfo);
        while ((c = getc(sfi)) != EOF)
                putchar(c);
        exit(0);
}


*********** END PASTE ************

Bob Madden

>,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,<
--This Message Composed By:      Bob Madden
-- bob@CLAPTON.ATGSYSTEMS.COM    Sys Admin /Network Engineer

-----Original Message-----
From: Rodney W. Grimes <freebsd@gndrsh.dnsmgr.net>
To: Ben Smithurst <ben@scientia.demon.co.uk>
Cc: matt <matt@S02.ARPA-CANADA.NET>; FreeBSD-Stable@FreeBSD.ORG
<FreeBSD-Stable@FreeBSD.ORG>
Date: Sunday, December 05, 1999 4:55 PM
Subject: Re: Little whois patch.


>> matt wrote:
>>
>> > I noticed that the Canadian Internic was being left out of the
>> > whois command line opts, so I thought I'd add it to the options. I
really
>> > have no clue who to send this to, or if I should use send-pr maybe, but
>> > it's technically not a problem. Hopefully one of the committers can give
>> > me feedback on where this should go. It's diffed against 3.3-stable,
does
>> > nothing but give 'whois -c' for whois.internic.ca, us Canadians feel
left
>> > out, cheers. =)
>>
>> Can we (the UK) have a -u option too? :-) The host is whois.nic.uk.
>> Anyway, what happens when China want their own option, and find that -c
>> is taken? Wouldn't a more generic option make more sense, something like
>> -c <country>, eg `whois -c ca ...' or `whois -c uk ...' ?
>
>How about a much more elegant solution in that this data should not
>be coded in the program at all.  Use of an external data file that
>maps regex's to whois servers living in /usr/share someplace would
>mean we could stop fussing with the binary and just fix the data
>file such that it DTRT for folks:
>
>.*\.{com,net,org}$ whois.networksolutions.com
>.*\.{mil}$ ???
>.*\.{edu}$ ???
>.*\.{ca}$ whois.internic.ca
>.*\.{uk}$ ???
>
>etc, etc....
>
>And -h would override even looking at this file...
>
>And for folks like me who do lots of rr queries I could locally add
>things like
>^AS[0-9]* whois.ra.net
>^MAINT-.* whois.ra.net
>^RTR-.* whois.ra.net
>^[1-9]*\.[0-9]*\.[0-9]*\.[0-9]* whois.arin.net
>
>Infact you could go one step further and even allow a ~/.whoisrc,
>so my users whouldn't get confused when whois gave them data from
>a routing registry :-)
>
>--
>Rod Grimes - KD7CAX @ CN85sl - (RWG25)
rgrimes@gndrsh.dnsmgr.net
>
>
>To Unsubscribe: send mail to majordomo@FreeBSD.org
>with "unsubscribe freebsd-stable" in the body of the message
>



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-stable" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?005e01bf3f76$32bd2290$01000000>