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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.18.0/] [newlib/] [libc/] [sys/] [linux/] [gethostname.c] - Rev 258

Go to most recent revision | Compare with Previous | Blame | View Log

/* Copyright 2002, Red Hat Inc. */
 
#include <errno.h>
#include <string.h>
#include <unistd.h>
#include <sys/utsname.h>
#include <machine/weakalias.h>
 
int
__gethostname (char *name, size_t len)
{
	struct utsname nodebuf;
	size_t nodelen;
 
	if (uname (&nodebuf))
		return -1;
 
	nodelen = strlen (nodebuf.nodename) + 1;
	if (len < nodelen)
		memcpy (name, nodebuf.nodename, len);
	else
		memcpy (name, nodebuf.nodename, nodelen);
 
	if (nodelen > len)
	{
		errno = ENAMETOOLONG;
		return -1;
	}
	return 0;
}
weak_alias(__gethostname, gethostname)
 

Go to most recent revision | Compare with Previous | Blame | View Log

powered by: WebSVN 2.1.0

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