strlist_xti.c

来自「《unix网络编程第二卷》中的源代码」· C语言 代码 · 共 28 行

C
28
字号
#include	"unpxti.h"#include	<stropts.h>intmain(int argc, char *argv[]){	int					fd, i, nmods;	struct str_list		list;	if (argc != 2)		err_quit("usage: a.out <pathname>");	fd = T_open(argv[1], O_RDWR, NULL);	if (isastream(fd) == 0)		err_quit("%s is not a stream", argv[1]);	list.sl_nmods = nmods = Ioctl(fd, I_LIST, (void *) 0);	printf("%d modules\n", nmods);	list.sl_modlist = Calloc(nmods, sizeof(struct str_mlist));	Ioctl(fd, I_LIST, &list);	for (i = 1; i <= nmods; i++)		printf("  %s: %s\n", (i == nmods) ? "driver" : "module",								list.sl_modlist++);	exit(0);}

⌨️ 快捷键说明

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