1 /* 2 * Copyright 2002 Sun Microsystems, Inc. All rights reserved. 3 * Use is subject to license terms. 4 */ 5 6 #pragma ident "%Z%%M% %I% %E% SMI" 7 8 /* 9 * Copyright 1993 by OpenVision Technologies, Inc. 10 * 11 * Permission to use, copy, modify, distribute, and sell this software 12 * and its documentation for any purpose is hereby granted without fee, 13 * provided that the above copyright notice appears in all copies and 14 * that both that copyright notice and this permission notice appear in 15 * supporting documentation, and that the name of OpenVision not be used 16 * in advertising or publicity pertaining to distribution of the software 17 * without specific, written prior permission. OpenVision makes no 18 * representations about the suitability of this software for any 19 * purpose. It is provided "as is" without express or implied warranty. 20 * 21 * OPENVISION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 22 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO 23 * EVENT SHALL OPENVISION BE LIABLE FOR ANY SPECIAL, INDIRECT OR 24 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF 25 * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 26 * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 27 * PERFORMANCE OF THIS SOFTWARE. 28 */ 29 30 /* 31 * $Id: util_localhost.c,v 1.1 1996/04/12 00:39:38 marc Exp $ 32 */ 33 34 /* This file could be OS specific */ 35 36 /* 37 * Solaris Kerberos: the MAXHOSTNAMELEN is defined in <netdb.h> not 38 * in <sys/param.h>, and gethostname requires <unistd.h> 39 */ 40 #include <unistd.h> 41 #include <netdb.h> 42 #include <string.h> 43 44 #include <gssapiP_generic.h> 45 46 #ifndef MAXHOSTNAMELEN 47 #define MAXHOSTNAMELEN 64 48 #endif 49 50 char *g_local_host_name() 51 { 52 char buf[MAXHOSTNAMELEN+1], *ptr; 53 54 if (gethostname(buf, sizeof(buf)) < 0) 55 return 0; 56 57 buf[sizeof(buf)-1] = '\0'; 58 59 if (! (ptr = xmalloc(strlen(buf) + 1))) 60 return 0; 61 62 return strcpy(ptr, buf); 63 } 64