]> git.ipfire.org Git - thirdparty/glibc.git/blame - misc/getdomain.c
Moved to csu/errno-loc.c.
[thirdparty/glibc.git] / misc / getdomain.c
CommitLineData
7a8bdff0 1/* Copyright (C) 1994,95,97,2000,02 Free Software Foundation, Inc.
478b92f0
UD
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
41bdb6e2
AJ
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
478b92f0
UD
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
41bdb6e2 12 Lesser General Public License for more details.
478b92f0 13
41bdb6e2
AJ
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, write to the Free
16 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
17 02111-1307 USA. */
28f540f4 18
ae1025be
UD
19/* Put the name of the current YP domain in no more than LEN bytes of NAME.
20 The result is null-terminated if LEN is large enough for the full
21 name and the terminator. */
22
439d1d45
RM
23#include <errno.h>
24#include <unistd.h>
04ea3b0f 25#include <sys/param.h>
439d1d45 26#include <sys/utsname.h>
3f33a4ce 27#include <string.h>
28f540f4 28
439d1d45
RM
29#if _UTSNAME_DOMAIN_LENGTH
30/* The `uname' information includes the domain name. */
28f540f4 31
439d1d45 32int
ae1025be
UD
33getdomainname (name, len)
34 char *name;
35 size_t len;
439d1d45
RM
36{
37 struct utsname u;
04ea3b0f 38 size_t u_len;
28f540f4 39
439d1d45
RM
40 if (uname (&u) < 0)
41 return -1;
42
04ea3b0f
UD
43 u_len = strlen (u.domainname);
44 memcpy (name, u.domainname, MIN (u_len + 1, len));
439d1d45
RM
45 return 0;
46}
47
48#else
ae1025be
UD
49
50int
51getdomainname (name, len)
52 char *name;
53 size_t len;
54{
55 __set_errno (ENOSYS);
56 return -1;
57}
58
59stub_warning (getdomainname)
f2ea0f5b 60#include <stub-tag.h>
ae1025be 61
439d1d45 62#endif
7a8bdff0
RM
63
64libc_hidden_def (getdomainname)