summaryrefslogtreecommitdiffstats
path: root/mdk-stage1/dietlibc/lib/getdomainname.c
blob: 75486b01073b186641c585a2642876249d4fbc44 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#define _GNU_SOURCE

#include <sys/types.h>
#include <sys/utsname.h>
#include <unistd.h>

int getdomainname(char *name,size_t len) {
  struct utsname u;
  int res=uname(&u);
  if (res==0) {
    size_t i;
    if (len>=_UTSNAME_DOMAIN_LENGTH)
      len=_UTSNAME_DOMAIN_LENGTH;
    for (i=0; i<len; i++)
      name[i]=u.domainname[i];
  }
  return res;
}