OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [newlib-1.17.0/] [newlib/] [libc/] [sys/] [linux/] [gethostname.c] - Blame information for rev 816

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 148 jeremybenn
/* Copyright 2002, Red Hat Inc. */
2
 
3
#include <errno.h>
4
#include <string.h>
5
#include <unistd.h>
6
#include <sys/utsname.h>
7
#include <machine/weakalias.h>
8
 
9
int
10
__gethostname (char *name, size_t len)
11
{
12
        struct utsname nodebuf;
13
        size_t nodelen;
14
 
15
        if (uname (&nodebuf))
16
                return -1;
17
 
18
        nodelen = strlen (nodebuf.nodename) + 1;
19
        if (len < nodelen)
20
                memcpy (name, nodebuf.nodename, len);
21
        else
22
                memcpy (name, nodebuf.nodename, nodelen);
23
 
24
        if (nodelen > len)
25
        {
26
                errno = ENAMETOOLONG;
27
                return -1;
28
        }
29
        return 0;
30
}
31
weak_alias(__gethostname, gethostname)

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.