17c478bd9Sstevel@tonic-gate /*
2*ab9b2e15Sgtb * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
37c478bd9Sstevel@tonic-gate * Use is subject to license terms.
47c478bd9Sstevel@tonic-gate */
57c478bd9Sstevel@tonic-gate
67c478bd9Sstevel@tonic-gate /*
77c478bd9Sstevel@tonic-gate * Copyright 1993 by OpenVision Technologies, Inc.
87c478bd9Sstevel@tonic-gate *
97c478bd9Sstevel@tonic-gate * Permission to use, copy, modify, distribute, and sell this software
107c478bd9Sstevel@tonic-gate * and its documentation for any purpose is hereby granted without fee,
117c478bd9Sstevel@tonic-gate * provided that the above copyright notice appears in all copies and
127c478bd9Sstevel@tonic-gate * that both that copyright notice and this permission notice appear in
137c478bd9Sstevel@tonic-gate * supporting documentation, and that the name of OpenVision not be used
147c478bd9Sstevel@tonic-gate * in advertising or publicity pertaining to distribution of the software
157c478bd9Sstevel@tonic-gate * without specific, written prior permission. OpenVision makes no
167c478bd9Sstevel@tonic-gate * representations about the suitability of this software for any
177c478bd9Sstevel@tonic-gate * purpose. It is provided "as is" without express or implied warranty.
187c478bd9Sstevel@tonic-gate *
197c478bd9Sstevel@tonic-gate * OPENVISION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
207c478bd9Sstevel@tonic-gate * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
217c478bd9Sstevel@tonic-gate * EVENT SHALL OPENVISION BE LIABLE FOR ANY SPECIAL, INDIRECT OR
227c478bd9Sstevel@tonic-gate * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
237c478bd9Sstevel@tonic-gate * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
247c478bd9Sstevel@tonic-gate * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
257c478bd9Sstevel@tonic-gate * PERFORMANCE OF THIS SOFTWARE.
267c478bd9Sstevel@tonic-gate */
277c478bd9Sstevel@tonic-gate
287c478bd9Sstevel@tonic-gate /*
29*ab9b2e15Sgtb * $Id: util_localhost.c 7797 1996-04-12 00:40:24Z marc $
307c478bd9Sstevel@tonic-gate */
317c478bd9Sstevel@tonic-gate
327c478bd9Sstevel@tonic-gate /* This file could be OS specific */
337c478bd9Sstevel@tonic-gate
34*ab9b2e15Sgtb #include <sys/param.h>
357c478bd9Sstevel@tonic-gate
36*ab9b2e15Sgtb #include "gssapiP_generic.h"
37*ab9b2e15Sgtb #include <strings.h> /* SUNW15resync */
38*ab9b2e15Sgtb #include <unistd.h> /* SUNW15resync */
397c478bd9Sstevel@tonic-gate
407c478bd9Sstevel@tonic-gate #ifndef MAXHOSTNAMELEN
417c478bd9Sstevel@tonic-gate #define MAXHOSTNAMELEN 64
427c478bd9Sstevel@tonic-gate #endif
437c478bd9Sstevel@tonic-gate
g_local_host_name()447c478bd9Sstevel@tonic-gate char *g_local_host_name()
457c478bd9Sstevel@tonic-gate {
467c478bd9Sstevel@tonic-gate char buf[MAXHOSTNAMELEN+1], *ptr;
477c478bd9Sstevel@tonic-gate
487c478bd9Sstevel@tonic-gate if (gethostname(buf, sizeof(buf)) < 0)
497c478bd9Sstevel@tonic-gate return 0;
507c478bd9Sstevel@tonic-gate
517c478bd9Sstevel@tonic-gate buf[sizeof(buf)-1] = '\0';
527c478bd9Sstevel@tonic-gate
537c478bd9Sstevel@tonic-gate if (! (ptr = xmalloc(strlen(buf) + 1)))
547c478bd9Sstevel@tonic-gate return 0;
557c478bd9Sstevel@tonic-gate
567c478bd9Sstevel@tonic-gate return strcpy(ptr, buf);
577c478bd9Sstevel@tonic-gate }
58