diff --git a/usr.bin/whois/Makefile b/usr.bin/whois/Makefile index b7044a53829e..0a99fefe0561 100644 --- a/usr.bin/whois/Makefile +++ b/usr.bin/whois/Makefile @@ -1,6 +1,7 @@ -# $NetBSD: Makefile,v 1.3 1994/11/14 05:13:23 jtc Exp $ +# $NetBSD: Makefile,v 1.4 1999/05/18 22:36:36 tron Exp $ # @(#)Makefile 8.1 (Berkeley) 6/6/93 -PROG= whois +PROG= whois +CPPFLAGS+= -DRIPE .include diff --git a/usr.bin/whois/whois.1 b/usr.bin/whois/whois.1 index 74c39191cfd4..d6d57c206afb 100644 --- a/usr.bin/whois/whois.1 +++ b/usr.bin/whois/whois.1 @@ -1,4 +1,4 @@ -.\" $NetBSD: whois.1,v 1.9 1999/03/22 18:16:47 garbled Exp $ +.\" $NetBSD: whois.1,v 1.10 1999/05/18 22:36:36 tron Exp $ .\" .\" Copyright (c) 1985, 1990, 1993 .\" The Regents of the University of California. All rights reserved. @@ -38,48 +38,176 @@ .Os .Sh NAME .Nm whois -.Nd Internet user name directory service +.Nd TCP/IP Internet directory service, RIPE version .Sh SYNOPSIS -.Nm -.Op Fl h Ar hostname -.Ar name ... +.Nm "" +.Op Fl aFSrR +.Op Fl h Ar host +.Op Fl p Ar port +.Op Fl i Ar attributes +.Op Fl s Ar sources +.Op Fl T Ns Ar \ types +.Op Fl L | m | M +.Ar identifier +.Nm whois +.Fl t Ar type +.Nm whois +.Fl v Ar type .Sh DESCRIPTION -.Nm -looks up records in the Network Information Center -.Pq Tn NIC -database. -.Pp -The options are as follows: -.Bl -tag -width Ds -.It Fl h -Use the specified host instead of the default NIC (whois.internic.net). -To specify a non-standard port number to connect to append it to the -.Ar hostname , -separated by a colon (e.g. rwhois.internic.net:4321). -.El -.Pp -The operands specified to -.Nm -are concatenated together (separated by white-space) and presented to -the -.Nm -server. -.Pp -The default action, unless directed otherwise with a special -.Ar name , -is to do a very broad search, looking for matches to -.Ar name -in all types of records and most fields (name, nicknames, hostname, net -address, etc.) in the database. -For more information as to what -.Ar name -operands have special meaning, and how to guide the search, use -the special name -.Dq Ar help . -.Sh SEE ALSO -RFC 812: Nicname/Whois -.Sh HISTORY -The -.Nm -command appeared in -.Bx 4.3 . +.B whois +searches for an object in the RIPE Network Management database. +The key can be either a name (such as "Karrenberg"),a nic-handle +(such as "DK58"), +a network number ("192.87.45.0/24") or a domain name ("ripe.net"). + +This version of the whois client works with a version of the RIPE +database whois server that supports classless IP addresses. +All IP network numbers are considered classless IP network numbers of +the form prefix/length, like 192.87.45.0/24 for a class C sized network +number and 128.86.0.0/16 for a class B sized network number. Any +length can be given. If no length is given, the server assumes a host +lookup (ie length 32). + +By default, the server will return the first less specific network +number, which can be an exact match if available in the database. +.Sh OPTIONS +.TP 8 +.B \-a +This causes the server to include information from +non-RIPE whois databases in the reply. Currently these are the public +parts of the US NIC and NSFnet databases. Please note that the RIPE +NCC does not maintain these databases. The information is included for +for your convenience only. +.TP 8 +.B \-F +fast output. Force the whois server to not reformat the output. This +can save time for large objects. The output of the RIPE whois server +will be in two letter short form. This option implies -r. +.TP 8 +.B \-h host +Select alternate host to direct the query +.TP 8 +.B \-p port +Connect to port 'port' +.TP 8 +.B \-L +lookup all less specific networks. Has effect only when looking up IP +network numbers. +.TP 8 +.B \-m +lookup first level more specific networks. Has effect only when +looking up IP network numbers. +.TP 8 +.B \-M +lookup all more specific networks. Has effect only when looking up IP +network numbers. +.TP 8 +.B \-r +non-recursive lookup. This will cause the server to not lookup +referenced objects. +.TP 8 +.B \-R +suppress referrals. Forces local copy of a domain object to be shown +even if it contains referral. +.TP 8 +.B \-i attributes +attributes is a comma separated list of attributes. +the whois server will return all objects that match the search keys +in one of these attributes. +.TP 8 +.B \-s sources +sources is a comma separated list of database sources. +The whois server will only search the databases that match the +specified sources. +.TP 8 +.B \-S +requests the server to leave out "syntactic sugar" that may normally +be inserted in some database objects. +.TP 8 +.B \-t type +requests the server to send a template for an object with type "type". +.TP 8 +.B \-v type +requests the server to send a verbose template for an object with type "type". +.TP 8 +.B \-T types +types is a comma separated list of object types. +requests the server to only send back objects that match one of the "types". +.TP 8 +.Lp +.Sh EXAMPLES +.IP +.B example% whois karrenberg +.IP +person: Daniel Karrenberg +.br +address: RIPE Network Coordination Centre +.br +address: Kruislaan 409 +.br +address: NL-1098 SJ Amsterdam +.br +address: Netherlands +.br +phone: +31 20 5925065 +.br +fax-no: +31 20 5925155 +.br +e-mail: dfk@ripe.net +.br +nic-hdl: DK58 +.br +changed: dfk@ripe.net 920407 +.br +changed: ripe-dbm@ripe.net 920407 +.br +source: RIPE +.IP +.B example% whois -h whois.ripe.net -r 192.87.45.0/24 +.IP +inetnum: 192.87.45.0 +.br +netname: RIPE-NCC +.br +descr: RIPE Network Coordination Centre +.br +descr: Amsterdam, Netherlands +.br +country: NL +.br +admin-c: Daniel Karrenberg +.br +tech-c: Marten Terpstra +.br +connect: RIPE NSF WCW +.br +aut-sys: AS3333 +.br +ias-int: 192.87.45.80 AS1104 +.br +ias-int: 192.87.45.6 AS2122 +.br +ias-int: 192.87.45.254 AS2600 +.br +rev-srv: ns.ripe.net +.br +rev-srv: ns.eu.net +.br +notify: ops@ripe.net +.br +changed: tony@ripe.net 940110 +.br +source: RIPE +.Lp +.Sh RIPE VERSION +This is the RIPE version of the whois client program. +For questions refer +to . For more information about the RIPE database please also +refer to . +.Lp +.Sh BUGS +Most of the extra flags are ONLY supported by the RIPE whois server, +or copies of the same version of the software. Usage of these flags +may cause errors on other whois servers. +.\".Sh SEE ALSO +.\"RFC 812: NICNAME/WHOIS diff --git a/usr.bin/whois/whois.c b/usr.bin/whois/whois.c index bb0f17995f59..78cfbe4bdfde 100644 --- a/usr.bin/whois/whois.c +++ b/usr.bin/whois/whois.c @@ -1,8 +1,21 @@ -/* $NetBSD: whois.c,v 1.8 1998/11/24 01:33:47 kim Exp $ */ +/* $NetBSD: whois.c,v 1.9 1999/05/18 22:36:36 tron Exp $ */ /* - * Copyright (c) 1980, 1993 - * The Regents of the University of California. All rights reserved. + * RIPE version marten@ripe.net + * many changes & networkupdate by david@ripe.net + * cosmetics by steven@dante.org.uk -- gcc stopped complaining mostly, + * code is still messy, though. + * + * 1.15 94/09/07 + * + * 1.2 9705/02 + * "-v" option added; ambrose@ripe.net + * "whois.ripe.net" replaced by "bsdbase.ripe.net"; ambrose@ripe.net + * "bsdbase.ripe.net" replaced by "joshua.ripe.net"; marek@ripe.net + * "joshua.ripe.net" replaced by "whois.ripe.net"; roman@ripe.net 981105 + * + * Copyright (c) 1980 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 @@ -34,108 +47,576 @@ */ #include +#if defined(sun) && defined(solaris) +#define SYSV +#endif + #ifndef lint __COPYRIGHT("@(#) Copyright (c) 1980, 1993\n\ The Regents of the University of California. All rights reserved.\n"); #endif /* not lint */ +#ifndef RIPE #ifndef lint #if 0 static char sccsid[] = "@(#)whois.c 8.1 (Berkeley) 6/6/93"; #else -__RCSID("$NetBSD: whois.c,v 1.8 1998/11/24 01:33:47 kim Exp $"); +__RCSID("$NetBSD: whois.c,v 1.9 1999/05/18 22:36:36 tron Exp $"); #endif #endif /* not lint */ +#endif /* not RIPE */ + +#ifdef RIPE +#ifndef lint +char sccsid[] = + "@(#)whois.c 5.11 (Berkeley) 3/2/91 - RIPE 1.15 94/09/07 marten@ripe.net"; +#endif /* not lint */ +#endif /* RIPE */ #include #include +#include #include #include #include #include #include +#include #include +#include #include +#include +#include -#define NICHOST "whois.internic.net" +#if defined(SYSV) +#include +#endif /* SYSV */ + +#ifndef __NetBSD__ +#ifdef __STDC__ +extern int getopt(int argc, char * const *argv, const char *optstring); +extern int kill(pid_t pid, int sig); +extern FILE *fdopen(int fildes, const char *type); +extern int gethostname(char *name, int namelen); +#else /* !__STDC__ */ +extern int gethostname(); +#endif /* __STDC__ */ +#endif /* __NetBSD__ */ + +#if defined(SYSV) || defined(__STDC__) + +#define index(s,c) strchr((const char*)(s),(int)(c)) +#define rindex(s,c) strrchr((const char*)(s),(int)(c)) +#define bzero(s,n) memset((void*)s,0,(size_t)n) + +#ifdef HASMEMMOVE +# define bcopy(s,d,n) memmove((void*)(d),(void*)(s),(size_t)(n)) +#else +# define bcopy(s,d,n) memcpy((void*)(d),(void*)(s),(size_t)(n)) +#endif /* HASMEMMOVE */ + +#endif /* SYSV || __STDC__ */ + +#ifdef GLIBC +typedef __u_short u_short; +typedef __caddr_t caddr_t; +#endif /* GLIBC */ + +/* + +# the following defines can be used but are not fully functional anymore... +# +# CLEVER- Use a educated guess of the whereabouts of the nearest server +# This is done by taking the top-level domain of the current +# machine, and looking for a CNAME record for a server with name +# -whois.ripe.net +# If this machine does not exsist or the current machine's top-level +# domain could not be found,it will fall back to whois.ripe.net +# the default for this RIPE version of whois +# The CLEVER option implies the RIPE option. + +# TOPDOMAIN=\"\" +# - This option will fix the default host to be +# -whois.ripe.net, which may point to a secondary +# server inside your top-level domain. If there is no such secondary +# server, it will point to whois.ripe.net, the default. This option +# overrules the CLEVER option. +# The TOPDOMAIN option implies the RIPE option. + +*/ + +#if defined(TOPDOMAIN) || defined(CLEVER) +#ifndef RIPE +#define RIPE +#endif /* !RIPE */ +#endif /* TOPDOMAIN || CLEVER */ + +#if defined(RIPE) && !defined(__NetBSD__) +#include +#define NICHOST "whois.ripe.net" +#else +#define NICHOST "whois.internic.net" +#endif int main __P((int, char **)); static void usage __P((void)); +static void closesocket __P((int, int)); +static void termhandler __P((int)); -int -main(argc, argv) - int argc; - char **argv; +void usage() { - extern char *optarg; - extern int optind; - FILE *sfi, *sfo; - int ch; - struct sockaddr_in sin; - struct hostent *hp; - struct servent *sp; - int s; - char *host; - int port = 0; - char *p; +#ifdef RIPE +#ifdef NETWORKUPDATE + (void)fprintf(stderr, "\nUsage: networkupdate [-h hostname] [-p port]"); +#else + (void)fprintf(stderr, "\nUsage: whois [-aFLmMrSvR] [-h hostname] [-s sources] [-T types] [-i attr] keys\n"); + (void)fprintf(stderr, " whois -t type"); + (void)fprintf(stderr, " whois -v type"); +#endif +#else + (void)fprintf(stderr, "\nUsage: whois [-h hostname] [-p port] name ..."); +#endif + (void)fprintf(stderr, "\n\nWhere:\n\n"); +#ifdef RIPE +#ifndef NETWORKUPDATE + (void)fprintf(stderr, "-a search all databases\n"); + (void)fprintf(stderr, "-F fast raw output\n"); +#endif +#endif + (void)fprintf(stderr, "-h hostname search alternate server\n"); +#ifdef RIPE +#ifndef NETWORKUPDATE + (void)fprintf(stderr, "-i [attr][[,attr] ... ] do an inverse lookup for specified attributes\n"); + (void)fprintf(stderr, "-L find all Less specific matches\n"); + (void)fprintf(stderr, "-m find first level more specific matches\n"); + (void)fprintf(stderr, "-M find all More specific matches\n"); +#endif +#endif + (void)fprintf(stderr, "-p port port to connect to\n"); +#ifdef RIPE +#ifndef NETWORKUPDATE + (void)fprintf(stderr, "-r turn off recursive lookups\n"); + (void)fprintf(stderr, "-s source[[,source] ... ] search databases with source 'source'\n"); + (void)fprintf(stderr, "-S tell server to leave out 'syntactic sugar'\n"); + (void)fprintf(stderr, "-t type requests template for object of type 'type'\n"); + (void)fprintf(stderr, "-v type requests verbose template for object of type 'type'\n"); + (void)fprintf(stderr, "-R force to show local copy of the domain object even if it contains referral\n"); + (void)fprintf(stderr, "-T type[[,type] ... ] only look for objects of type 'type'\n\n"); + (void)fprintf(stderr, "Please note that most of these flags are NOT understood by\n"); + (void)fprintf(stderr, "non RIPE whois servers\n"); +#endif +#endif + (void)fprintf(stderr, "\n"); - host = NICHOST; - while ((ch = getopt(argc, argv, "h:")) != -1) - switch((char)ch) { - case 'h': - host = optarg; - break; - case '?': - default: - usage(); - } - argc -= optind; - argv += optind; + exit(1); +} - if (!argc) - usage(); +int s; - if ((p = strrchr(host, ':')) != NULL) { - *p++ = '\0'; - port = atoi(p); +void closesocket(s, child) +int s, child; +{ + /* printf("close connection child=%i\n", child); */ + + close(s); + +#ifdef NETWORKUPDATE + if (child==0) { + kill(getppid(), SIGTERM); + } +#endif + + exit(0); + +} + +void termhandler(sig) +int sig; +{ + closesocket(s,1); +} + + +#ifdef RIPE +#if defined(__STDC__) || defined(SYSV) +#define occurs(str,pat) ((int) strstr((str),(pat))) +#else /* !__STDC__ && !SYSV */ +int occurs(str, pat) + char *str, *pat; +{ + register char *point = str; + + while ((point=index(point, *pat))) + { + if (strncmp(point, pat, strlen(pat)) == 0) + return(1); + point++; + } + return(0); +} +#endif +#endif + +int main(argc, argv) + int argc; + char **argv; +{ + extern char *optarg; + extern int optind; + FILE *sfi; + FILE *sfo; + int ch; + struct sockaddr_in sin; + struct hostent *hp; + struct servent *sp; + char *host, *whoishost; + int optp=0, optport=0; +#ifdef RIPE + int verb=0, opthost=0; +#ifndef NETWORKUPDATE + /* normal whois client */ + char *string; + int alldatabases=0; + int optsource=0, optrecur=0, optfast=0, opttempl=0, optverbose=0; + int optobjtype=0, optsugar=0, optinverselookup=0, optgetupdates=0; + int optL=0, optm=0, optM=0, optchanged=0, optnonreferral=0; + char *source=NULL, *templ=NULL, *verbose=NULL, *objtype=NULL, + *inverselookup=NULL, *getupdates=NULL; +#else /* NETWORKUPDATE */ + /* networkupdate client */ + int prev; + char domainname[64]; /* that's what sys/param.h says */ + struct passwd *passwdentry; + int child; +#endif +#ifdef CLEVER + int myerror; + char *mytoplevel; + char *myhost; +#endif +#endif + +#ifdef TOPDOMAIN + host = strcat(TOPDOMAIN, "-whois.ripe.net"); +#else + host = NICHOST; +#endif + +#ifdef RIPE +#ifdef NETWORKUPDATE + while ((ch = getopt(argc, argv, "h:p:")) != EOF) +#else + while ((ch = getopt(argc, argv, "acFg:h:i:LmMp:rs:SRt:T:v:")) != EOF) +#endif +#else + while ((ch = getopt(argc, argv, "h:p:")) != EOF) +#endif + switch((char)ch) { + case 'h': + host = optarg; + opthost = 1; + break; + case 'p': + optport=htons((u_short)atoi(optarg)); + optp =1; + break; +#ifdef RIPE +#ifndef NETWORKUPDATE + case 'a': + alldatabases=1; + break; + case 'c': + optchanged=1; + break; + case 'F': + optfast = 1; + break; + case 'g': + getupdates=optarg; + optgetupdates=1; + break; + case 'i': + inverselookup=optarg; + optinverselookup = 1; + break; + case 'L': + if (optM || optm) { + fprintf(stderr, "Only one of -L, -m or -M allowed\n\n"); + usage(); + } + optL=1; + break; + case 'm': + if (optM || optL) { + fprintf(stderr, "Only one of -L, -m or -M allowed\n\n"); + usage(); } - hp = gethostbyname(host); - if (hp == NULL) - errx(1, "%s: %s", host, hstrerror(h_errno)); - host = hp->h_name; - s = socket(hp->h_addrtype, SOCK_STREAM, 0); - if (s < 0) - err(1, "socket"); - memset((caddr_t)&sin, 0, sizeof (sin)); - sin.sin_family = hp->h_addrtype; - if (bind(s, (struct sockaddr *)&sin, sizeof(sin)) < 0) - err(1, "bind"); - memmove((char *)&sin.sin_addr, hp->h_addr, hp->h_length); - if (port == 0) { - sp = getservbyname("whois", "tcp"); - if (sp == NULL) - errx(1, "whois/tcp: unknown service"); - sin.sin_port = sp->s_port; - } else - sin.sin_port = htons(port); - if (connect(s, (struct sockaddr *)&sin, sizeof(sin)) < 0) - err(1, "connect"); - sfi = fdopen(s, "r"); - sfo = fdopen(s, "w"); - if (sfi == NULL || sfo == NULL) - err(1, "fdopen"); - 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); -} + optm=1; + break; + case 'M': + if (optL || optm) { + fprintf(stderr, "Only one of -L, -m or -M allowed\n\n"); + usage(); + } + optM=1; + break; + + case 's': + source = optarg; + optsource=1; + break; + case 'S': + optsugar=1; + break; + case 'R': + optnonreferral=1; + break; + case 'r': + optrecur=1; + break; + case 't': + templ=optarg; + opttempl=1; + break; + case 'v': + verbose=optarg; + optverbose=1; + break; + case 'T': + objtype=optarg; + optobjtype=1; + break; + +#endif +#endif + case '?': + default: + usage(); + } + argc -= optind; + argv += optind; -static void -usage() -{ - (void)fprintf(stderr, "usage: whois [-h hostname] name ...\n"); +#ifdef RIPE +#ifdef NETWORKUPDATE + if (argc>0) + usage(); +#else + if ((argc<=0) && !opttempl && !optverbose && !optgetupdates && (!(opttempl && optgetupdates))) + usage(); +#endif +#else + if (argc<=0) + usage(); +#endif + + if (!opthost) { + +#ifdef CLEVER + whoishost=(char *)calloc(MAXHOSTNAMELEN, sizeof(char)); + myhost =(char *)calloc(MAXHOSTNAMELEN, sizeof(char)); + myerror = gethostname(myhost, MAXHOSTNAMELEN); + if (myerror >= 0) { + if (occurs(myhost, ".")) { + mytoplevel = rindex(myhost,'.'); + mytoplevel++; + (void) sprintf(whoishost, "%s-whois.ripe.net", mytoplevel); + if (verb) fprintf(stderr, "Clever guess: %s\n", whoishost); + } + } + hp = gethostbyname(whoishost); + if ((hp == NULL) && (verb)) + fprintf(stderr,"No such host: %s\n", whoishost); + + if (hp==NULL) { +#endif + + whoishost=NICHOST; + + if (verb) fprintf(stderr, "Default host: %s\n\n", whoishost); + hp = gethostbyname(whoishost); + + if (hp == NULL) { + fprintf(stderr,"No such host: %s\n", whoishost); + if (verb) fprintf(stderr, "Now I give up ...\n"); + perror("Unknown host"); exit(1); + } + +#ifdef CLEVER + } +#endif + } + else { + if (verb) fprintf(stderr, "Trying: %s\n\n", host); + hp = gethostbyname(host); + if (hp == NULL) { + (void)fprintf(stderr, "whois: %s: ", host); + perror("Unknown host"); + exit(1); + } + } + + host = hp->h_name; + s = socket(hp->h_addrtype, SOCK_STREAM, 0); + if (s < 0) { + perror("whois: socket"); + exit(1); + } + bzero((caddr_t)&sin, sizeof (sin)); + sin.sin_family = hp->h_addrtype; + if (bind(s, (struct sockaddr *)&sin, sizeof(sin)) < 0) { + perror("whois: bind"); + exit(1); + } + bcopy(hp->h_addr, (char *)&sin.sin_addr, hp->h_length); + + if (optp) { + sin.sin_port=optport; + } + else { + + sp=getservbyname("whois", "tcp"); + + if (sp == NULL) { + (void)fprintf(stderr, "whois: whois/tcp: unknown service\n"); + exit(1); + } + + sin.sin_port = sp->s_port; + + } + + /* printf("%i\n", sin.sin_port); */ + + if (connect(s, (struct sockaddr *)&sin, sizeof(sin)) < 0) { + perror("whois: connect"); + exit(1); + } + +#ifndef NETWORKUPDATE + sfi = fdopen(s, "r"); + sfo = fdopen(s, "w"); + if (sfi == NULL || sfo == NULL) { + perror("whois: fdopen"); + (void)close(s); + exit(1); + } +#endif + + signal(SIGTERM, termhandler); + +#ifdef RIPE +#ifdef NETWORKUPDATE + + if ((child=fork())==0) { + + sfo = fdopen(s, "w"); + if (sfo == NULL) { + perror("whois: fdopen"); + (void)close(s); + exit(1); + } + + if (gethostname(domainname, sizeof(domainname))) { + fprintf(stderr, "error when doing gethostname()"); + exit(-1); + } + + passwdentry=getpwuid(getuid()); + + fprintf(sfo, "-Vnc2.0 -U %s %s\n", passwdentry->pw_name, domainname); + fflush(sfo); + + prev='\0'; + + while ((ch=getchar()) != EOF) { + + fputc(ch, sfo); + + if (ch=='\n') fflush(sfo); + if (feof(sfo)) closesocket(s, child); + if ((ch=='.') && (prev=='\n')) closesocket(s, child); + if (!isspace(ch) || ((!isspace(prev)) && (ch=='\n'))) prev=ch; + } + + closesocket(s, child); + + } + + sfi = fdopen(s, "r"); + if (sfi == NULL) { + perror("whois: fdopen"); + (void)close(s); + exit(1); + } + +#else + + if (alldatabases) + (void)fprintf(sfo, "-a "); + if (optchanged) + (void)fprintf(sfo, "-c "); + if (optfast) + (void)fprintf(sfo, "-F "); + if (optgetupdates) + (void)fprintf(sfo, "-g %s ", getupdates); + if (optinverselookup) + (void)fprintf(sfo, "-i %s ", inverselookup); + if (optL) + (void)fprintf(sfo, "-L "); + if (optm) + (void)fprintf(sfo, "-m "); + if (optM) + (void)fprintf(sfo, "-M "); + if (optrecur) + (void)fprintf(sfo, "-r "); + if (optsource) + (void)fprintf(sfo, "-s %s ", source); + if (optsugar) + (void)fprintf(sfo, "-S "); + if (optnonreferral) + (void)fprintf(sfo, "-R "); + if (opttempl) + (void)fprintf(sfo, "-t %s ", templ); + if (optverbose) + (void)fprintf(sfo, "-v %s ", verbose); + if (optobjtype) + (void)fprintf(sfo, "-T %s ", objtype); + + /* we can only send the -V when we are sure that we are dealing with + a RIPE whois server :-( */ + + whoishost=(char *)calloc(strlen(host)+1, sizeof(char)); + strcpy(whoishost, host); + for (string=whoishost;(*string=(char)tolower(*string));string++); + + if (strstr(whoishost, "ripe.net") || + strstr(whoishost, "ra.net") || + strstr(whoishost, "apnic.net") || + strstr(whoishost, "mci.net") || + strstr(whoishost, "isi.edu") || + strstr(whoishost, "garr.it") || + strstr(whoishost, "ans.net") || + alldatabases || optfast || optgetupdates || optinverselookup || + optL || optm || optM || optrecur || optsugar || optsource || + opttempl || optverbose || optobjtype) + (void)fprintf(sfo, "-VwC2.0 "); +#endif +#endif + +#ifndef NETWORKUPDATE + while (argc-- > 1) + (void)fprintf(sfo, "%s ", *argv++); + if (*argv) (void)fputs(*argv, sfo); + (void)fputs("\r\n", sfo); + (void)fflush(sfo); +#endif + + while ((ch = getc(sfi)) != EOF) + putchar(ch); + + closesocket(s, 1); + + exit(0); + }