/* Copyright (c) 1993 Carlos Leandro and Rui Salgueiro
* Dep. Matematica Universidade de Coimbra, Portugal, Europe
* Copyright (c) 1983 Regents of the University of California.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* 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
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid
[] = "@(#)main.c 1.4 (Coimbra) 93/06/03";
#endif /* LIBC_SCCS and not lint */
#include <arpa/nameser.h>
char *use
= "%s [-d] [-a addr | -n name | string] \n";
int name_or_addr
= UNDEF
;
char **ch
, c
, *net_name_or_addr
, *s
;
struct netent
*net_entry
;
register unsigned long net2
, nn
;
while (--argc
> 0 && (*++argv
)[0] == '-') {
for (s
= argv
[0] + 1; *s
!= '\0'; s
++) {
_res
.options
|= RES_DEBUG
;
net_name_or_addr
= *++argv
;
net_name_or_addr
= *++argv
;
if (name_or_addr
== UNDEF
) {
net_name_or_addr
= *argv
++;
fprintf(stderr
, "extra arguments ignored:");
fprintf(stderr
, " %s", *argv
++);
/* fprintf(stderr, "name_or_addr = %d, net_name_or_addr = %s\n",
name_or_addr , net_name_or_addr);
net_entry
= getnetbyaddr(inet_network(net_name_or_addr
),
net_entry
= getnetbyname(net_name_or_addr
);
default: /* can't happen */
printf(" Official name: %s \n", net_entry
->n_name
);
printf(" Net addr. type: %d \n", net_entry
->n_addrtype
);
printf(" Network : %u ----> ", net2
= (unsigned long)net_entry
->n_net
);
for (nn
= 4; net2
; netbr
[--nn
] = net2
& 0xff, net2
>>= 8)
printf("%u.%u.%u.%u", netbr
[0], netbr
[1], netbr
[2], netbr
[3]);
printf("%u.%u.%u", netbr
[1], netbr
[2], netbr
[3]);
printf("%u.%u", netbr
[2], netbr
[3]);
for (ch
= net_entry
->n_aliases
; *ch
!= NULL
; ch
++)
fprintf(stderr
, use
, progname
);
"Unknown host", /* 1 HOST_NOT_FOUND */
"Host name lookup failure", /* 2 TRY_AGAIN */
"Unknown server error", /* 3 NO_RECOVERY */
"No address associated with name", /* 4 NO_ADDRESS */
sizeof(h_errlist
) / sizeof(h_errlist
[0]) };
* print the error indicated by the h_errno value.
fprintf(stderr
, "%s: %s\n", s
,
(u_int
) h_errno
< h_nerr
? h_errlist
[h_errno
] : "Unknown error");