/*
 * 5799-WZQ (C) COPYRIGHT = NONE
 * LICENSED MATERIALS - PROPERTY OF IBM
 */
/* $Header:hostid.c 12.0$ */
/* $ACIS:hostid.c 12.0$ */
/* $Source: /ibm/acis/usr/src/ibm/rvd/lib/RCS/hostid.c,v $ */

#ifndef lint
static char *rcsid = "$Header:hostid.c 12.0$";
#endif


#ifndef lint
static char rcsid_hostid_c[] = "$Header:hostid.c 12.0$";
#endif lint

/* Copyright 1984 by the Massachusetts Institute of Technology */
/* See permission and disclaimer notice in the file "notice.h" */
#include "notice.h"


#include <stdio.h>
#include <sys/types.h>
#include <errno.h>
#include <signal.h>
#include <sys/socket.h>
#include <netdb.h>
#include <netinet/in.h>

#define MAXHOSTNAME 32

/*
 * pickup the hostid (via gethostid if set, or via gethostbyname if
 * not).
 */

int
hostid()
{
int id = gethostid();
register struct hostent *h;
char hostname[MAXHOSTNAME];

	if (id == 0) {
		if (gethostname(hostname, MAXHOSTNAME) == 0 &&
				(h = gethostbyname(hostname)))
			bcopy(h->h_addr, (caddr_t)&id, h->h_length);
	}
return(id);
}

