|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T h
Length: 1423 (0x58f) Types: TextFile Names: »host.c«
└─⟦9ae75bfbd⟧ Bits:30007242 EUUGD3: Starter Kit └─⟦925ee6880⟧ »EurOpenD3/network/snmp/mit-snmp.900225.tar.Z« └─⟦a4bfa469c⟧ └─⟦this⟧ »./bsd/host.c«
/* * $Header: host.c,v 1.3 89/07/11 13:00:23 jrd Exp $ * Author: J. Davin * Copyright 1988, 1989, Massachusetts Institute of Technology * See permission and disclaimer notice in file "notice.h" */ #include <notice.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <netdb.h> #include <stdio.h> #include <local.h> #include <host.h> long hostAddress (string) char *string; { struct hostent *hp; long host; host = (long) inet_addr (string); if (host == -1L) { hp = gethostbyname (string); if (hp == NULL) { return (-1); } else if (hp->h_addrtype != AF_INET) { return (-1); } else { host = 0L; bcopy (hp->h_addr, (char *) & host, sizeof (host)); } } return (host); } int hostString (result, n, host) char *result; int n; long host; { struct hostent *hp; struct in_addr in; int k; char *cp; hp = gethostbyaddr ((char *) & host, (int) sizeof (host), (int) AF_INET); if (hp != NULL) { k = strlen (hp->h_name); if (k > n) { return (0); } else { (void) strcpy (result, hp->h_name); return (k); } } else { (void) bzero ((char *) & in, (int) sizeof (in)); in.s_addr = (u_long) host; cp = inet_ntoa (in); if (cp == (char *) NULL) { return (0); } else if ((k = strlen (cp)) > n) { return (0); } else { (void) strcpy (result, cp); return (k); } } }