summaryrefslogtreecommitdiff
path: root/clients
diff options
context:
space:
mode:
authorGravatar Richard Basch <probe@mit.edu>1993-11-23 20:07:47 +0000
committerGravatar Richard Basch <probe@mit.edu>1993-11-23 20:07:47 +0000
commit3b6454727ec6d3f2bf66bec9bcecc7374d1db46c (patch)
treedfa93036d446e39339298b514f991a5712dc95c6 /clients
parentab325ceee552607838f2428b8bc4711943aa8492 (diff)
Allow one to specify IP addresses instead of the hostname.
Diffstat (limited to 'clients')
-rw-r--r--clients/zstat/zstat.c24
1 files changed, 16 insertions, 8 deletions
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 *)&notice, 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 *)&notice, 0, sizeof(notice));
notice.z_kind = UNSAFE;