Change th_get_size() macro to return unsigned int
[libtar.git] / compat / gethostname.c
blob1abaae1241f8b270a21ff9382b8498f0378c1586
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.
23 #include <string.h>
24 #include <sys/utsname.h>
26 int gethostname(char *name, size_t len)
28 struct utsname u;
29 int status = uname(&u);
30 if (-1 != status) {
31 strncpy(name, u.nodename, len);
32 name[len - 1] = '\0';
34 return(status);