OSDN Git Service

Last portion of libc_hidden_proto removal.
[uclinux-h8/uClibc.git] / libc / sysdeps / linux / common / gethostname.c
1 /*
2  * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
3  *
4  * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
5  */
6
7 #include <string.h>
8 #include <unistd.h>
9 #include <sys/utsname.h>
10 #include <errno.h>
11
12 /* libc_hidden_proto(gethostname) */
13
14 /* Experimentally off - libc_hidden_proto(strlen) */
15 /* Experimentally off - libc_hidden_proto(strcpy) */
16 /* libc_hidden_proto(uname) */
17
18 int
19 gethostname(char *name, size_t len)
20 {
21   struct utsname uts;
22
23   if (name == NULL) {
24     __set_errno(EINVAL);
25     return -1;
26   }
27
28   if (uname(&uts) == -1) return -1;
29
30   if (strlen(uts.nodename)+1 > len) {
31     __set_errno(EINVAL);
32     return -1;
33   }
34   strcpy(name, uts.nodename);
35   return 0;
36 }
37 libc_hidden_def(gethostname)