OSDN Git Service

Last portion of libc_hidden_proto removal.
[uclinux-h8/uClibc.git] / libc / sysdeps / linux / common / getdomainname.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 <features.h>
8 #include <stdlib.h>
9 #include <string.h>
10 #include <unistd.h>
11 #include <errno.h>
12 #include <sys/utsname.h>
13
14 #if defined __USE_BSD || (defined __USE_XOPEN && !defined __USE_UNIX98)
15 /* Experimentally off - libc_hidden_proto(strlen) */
16 /* Experimentally off - libc_hidden_proto(strcpy) */
17 /* libc_hidden_proto(uname) */
18
19 #if !defined __UCLIBC_BSD_SPECIFIC__
20 extern int getdomainname (char *__name, size_t __len)
21         __THROW __nonnull ((1)) __wur;
22 #endif
23 extern __typeof(getdomainname) __libc_getdomainname;
24 libc_hidden_proto(__libc_getdomainname)
25 int __libc_getdomainname(char *name, size_t len)
26 {
27   struct utsname uts;
28
29   if (name == NULL) {
30     __set_errno(EINVAL);
31     return -1;
32   }
33
34   if (uname(&uts) == -1) return -1;
35
36 #ifdef __USE_GNU
37   if (strlen(uts.domainname)+1 > len) {
38 #else
39   if (strlen(uts.__domainname)+1 > len) {
40 #endif
41     __set_errno(EINVAL);
42     return -1;
43   }
44 #ifdef __USE_GNU
45   strcpy(name, uts.domainname);
46 #else
47   strcpy(name, uts.__domainname);
48 #endif
49   return 0;
50 }
51 libc_hidden_def(__libc_getdomainname)
52 #if defined __UCLIBC_BSD_SPECIFIC__
53 /* libc_hidden_proto(getdomainname) */
54 weak_alias(__libc_getdomainname,getdomainname)
55 libc_hidden_weak(getdomainname)
56 #endif /* __UCLIBC_BSD_SPECIFIC__ */
57 #endif