⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sghostname.c

📁 RTEMS (Real-Time Executive for Multiprocessor Systems) is a free open source real-time operating sys
💻 C
字号:
/* * RTEMS versions of hostname functions * FIXME: Not thread-safe * *  $Id: sghostname.c,v 1.3 1999/01/21 22:25:43 joel Exp $ */#include <string.h>#include <errno.h>#include <rtems/rtems_bsdnet.h>#include <sys/param.h>#include <sys/malloc.h>#include <sys/kernel.h>static char *rtems_hostname;intgethostname (char *name, size_t namelen){	char *cp = rtems_hostname;	if (cp == NULL)		cp = "";	strncpy (name, cp, namelen);	return 0;}intsethostname (char *name, size_t namelen){	char *old, *new;	if (namelen >= MAXHOSTNAMELEN) {		errno = EINVAL;		return -1;	}	new = malloc (namelen + 1, M_HTABLE, M_NOWAIT);	if (new == NULL) {		errno = ENOMEM;		return -1;	}	strncpy (new, name, namelen);	new[namelen] = '\0';	old = rtems_hostname;	rtems_hostname = new;	if (old)		free (old, M_HTABLE);	return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -