1
/* gethostname.c: minimal substitute for missing gethostname() function
2
* created 2000-Mar-02 jmk
3
* requires SVR4 uname() and -lc
5
* by Jim Knoble <jmknoble@pobox.com>
6
* Copyright ? 2000 Jim Knoble
8
* Permission to use, copy, modify, distribute, and sell this software
9
* and its documentation for any purpose is hereby granted without fee,
10
* provided that the above copyright notice appear in all copies and
11
* that both that copyright notice and this permission notice appear in
12
* supporting documentation.
14
* This software is provided "as is", without warranty of any kind,
15
* express or implied, including but not limited to the warranties of
16
* merchantability, fitness for a particular purpose and
17
* noninfringement. In no event shall the author(s) be liable for any
18
* claim, damages or other liability, whether in an action of contract,
19
* tort or otherwise, arising from, out of or in connection with the
20
* software or the use or other dealings in the software.
24
#include <sys/utsname.h>
26
int gethostname(char *name, size_t len)
29
int status = uname(&u);
31
strncpy(name, u.nodename, len);