From 3b6454727ec6d3f2bf66bec9bcecc7374d1db46c Mon Sep 17 00:00:00 2001 From: Richard Basch Date: Tue, 23 Nov 1993 20:07:47 +0000 Subject: Allow one to specify IP addresses instead of the hostname. --- clients/zstat/zstat.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'clients') diff --git a/clients/zstat/zstat.c b/clients/zstat/zstat.c index 2a31f69..8ea0c04 100644 --- a/clients/zstat/zstat.c +++ b/clients/zstat/zstat.c @@ -178,13 +178,17 @@ hm_stat(host,server) sin.sin_family = AF_INET; - if ((hp = gethostbyname(host)) == NULL) { + if ((sin.sin_addr.s_addr = inet_addr(host)) == (unsigned)(-1)) { + if ((hp = gethostbyname(host)) == NULL) { fprintf(stderr,"Unknown host: %s\n",host); exit(-1); - } - (void) memcpy((char *) &sin.sin_addr, hp->h_addr, hp->h_length); + } + (void) memcpy((char *) &sin.sin_addr, hp->h_addr, hp->h_length); - printf("Hostmanager stats: %s\n",hp->h_name); + printf("Hostmanager stats: %s\n", hp->h_name); + } else { + printf("Hostmanager stats: %s\n", host); + } (void) memset((char *)¬ice, 0, sizeof(notice)); notice.z_kind = STAT; @@ -283,13 +287,17 @@ srv_stat(host) sin.sin_family = AF_INET; - if ((hp = gethostbyname(host)) == NULL) { + if ((sin.sin_addr.s_addr = inet_addr(host)) == (unsigned)(-1)) { + if ((hp = gethostbyname(host)) == NULL) { fprintf(stderr,"Unknown host: %s\n",host); exit(-1); - } - (void) memcpy((char *) &sin.sin_addr, hp->h_addr, hp->h_length); + } + (void) memcpy((char *) &sin.sin_addr, hp->h_addr, hp->h_length); - printf("Server stats: %s\n",hp->h_name); + printf("Server stats: %s\n", hp->h_name); + } else { + printf("Server stats: %s\n", host); + } (void) memset((char *)¬ice, 0, sizeof(notice)); notice.z_kind = UNSAFE; -- cgit v1.2.3