tnotify.c

来自「su 的源代码库」· C语言 代码 · 共 54 行

C
54
字号
/* Copyright (c) Colorado School of Mines, 2006.*//* All rights reserved.                       */#include	"sftest.h"static int	Type;#if __STD_Cstatic void notify(Sfio_t* f, int type, int fd)#elsestatic void notify(f, type, fd)Sfio_t*	f;int		type;int		fd;#endif{	switch(Type = type)	{	case SF_NEW:	case SF_CLOSING:	case SF_SETFD:	case SF_READ:	case SF_WRITE:		return;	default:		terror("Unexpected nofity-type: %d\n",type);	}}MAIN(){	Sfio_t*	f;	int	fd;	sfnotify(notify);	if(!(f = sfopen(NIL(Sfio_t*), tstfile(0), "w")) && Type != SF_NEW)		terror("Notify did not announce SF_NEW event\n");	fd = sffileno(f);	close(fd+5);	if(sfsetfd(f,fd+5) != fd+5 || Type != SF_SETFD)		terror("Notify did not announce SF_SETFD event\n");	if(sfclose(f) < 0 || Type != SF_CLOSING)		terror("Notify did not announce SF_CLOSING event\n");		if(sfputc(sfstdin,'a') >= 0 || Type != SF_WRITE)		terror("Notify did not announce SF_WRITE event\n");	if(sfgetc(sfstdout) >= 0 || Type != SF_READ)		terror("Notify did not announce SF_READ event\n");	TSTEXIT(0);}

⌨️ 快捷键说明

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