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