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

📄 ether_~1.c

📁 操作系统源代码
💻 C
字号:
/***  ETHER_LINE****	This routine parses the array pointed to by "line" (which should be**	from a file in the format of /etc/ethers) and returns in "eaddr" the**	ethernet address at the start of the line and the corresponding host**	name in "hostname".  It assumes either tabs or spaces separate the**	two.  The buffer pointed to by "hostname" must be big enough to hold**	the host name plus a NULL byte.**	The function returns 0 on success and 1 on failure.**	Arguments are assumed sensible.  Null pointers will probably cause**	exceptions.**	Author: Gregory J. Sharp, July 1990**	Adapted to MINIX: Philip Homburg, May 1992*/#include <sys/types.h>#include <ctype.h>#include <stdlib.h>#include <net/gen/ether.h>#include <net/gen/if_ether.h>intether_line(line, eaddr, hostname)char *			line;struct ether_addr *	eaddr;char *			hostname;{    register int i;    register unsigned long val;/* skip leading white space */    while (*line != '\n' && (*line == ' ' || *line == '\t'))	line++;/* read the ethernet address */    for (i = 0; i < 5; i++)    {	val = (unsigned long) strtol(line, &line, 16);	if (val > 255 || *line++ != ':')	    return 1;	eaddr->ea_addr[i] = val & 0xff;    }    val = (unsigned long) strtol(line, &line, 16);    if (val > 255 || (*line != ' ' && *line != '\t'))	return 1;    eaddr->ea_addr[i] = val & 0xff;/* skip leading white space */    while (*line != '\n' && (*line == ' ' || *line == '\t'))	line++;/* read in the hostname */    while (!isspace(*line))	*hostname++ = *line++;    *hostname = '\0';    return 0;}

⌨️ 快捷键说明

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