/*
 * Copyright (c) 1989,
 * 	National Center for Atmospheric Research
 *
 */
#if !defined(LINT) && !defined(VX)
static char rcsid[]="$Header: /net/src3/btcl/tclTCP2.0/src/RCS/hostGetByName.c,v 1.1 1994/03/09 18:46:39 vanandel Exp $";
#endif

/* TkWin version 0.3 -- Tk for Windows
 * Copyright (C) 1994 K. K. Kubota
 * Mathematical Sciences Computing Facility, University of Kentucky,
 * Lexington, KY 40506, USA (e-mail: ken@ms.uky.edu)
 *
 * Permission to use, copy, modify, and distribute this software for any
 * purpose is granted without fee, provided that the above copyright notice
 * and the following paragraph appear in all copies of this software
 * and supporting documentation.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY, even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE.  In no event shall the author be
 * liable to any party for direct, indirect, special, incidental, or
 * consequential damages arising out of the use of this software and its
 * documentation.
 */

/*
 * Revision history:
 * $Log: hostGetByName.c,v $
 * Revision 1.1  1994/03/09  18:46:39  vanandel
 * Initial revision
 *
 * Revision 1.1  1993/11/18  16:08:25  vanandel
 * Initial revision
 *
 * Revision 1.3  89/11/04  17:57:06  vanandel
 * fixed rcsid string
 * 
 * Revision 1.2  89/11/04  17:53:51  vanandel
 * added copyright header
 * 
 */
#ifdef TCL_MSDOS_PORT
#include "tkInt.h"
#include "tkPort.h"
#include <winsock.h>
#else
#include <stdio.h>
#include <netdb.h>
#endif

#include "localTypes.h"

/*******************************************************************************
*
* hostGetByName - VxWorks compatible function to return inet address as long
*/

long hostGetByName (hostname)
    char *hostname;

{
    struct hostent *destHost;

    /* get the internet address for the given host */

    if ((destHost = (struct hostent *) gethostbyname (hostname)) == NULL)
#ifdef TCL_MSDOS_PORT
	    return ((long)ERROR_RETURN);
#else
	    return ((long)ERROR);
#endif

    return (*(long *)destHost->h_addr);
}
