hostname.c

来自「操作系统SunOS 4.1.3版本的源码」· C语言 代码 · 共 43 行

C
43
字号
#ifndef lintstatic char sccsid[] = "@(#)hostname.c 1.1 92/07/30 Copyr 1988 Sun Micro";#endif/* * Copyright (c) 1986 by Sun Microsystems, Inc. */#include <nse/param.h>#include <pwd.h>#include <nse/util.h>static char	hostname[NSE_MAXHOSTNAMELEN] = { '\0' };char *_nse_hostname(){	if (!*hostname) {		gethostname(hostname, sizeof(hostname));	}	return hostname;}Nse_err_nse_get_user(user, homedir)	char		*user;	char		*homedir;{	struct passwd	*pwd;	pwd = getpwuid(getuid());	if (pwd == NULL) {		return nse_err_format_msg("Can't determine user name for userid %d", getuid());	}	if (user != NULL) {		strcpy(user, pwd->pw_name);	}	if (homedir != NULL) {		strcpy(homedir, pwd->pw_dir);	}	return (NSE_OK);}

⌨️ 快捷键说明

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