head 1.3; access; symbols SFIO_1999:1.1.1.2 SFIO_1998:1.1.1.1 SFIO_1997:1.1.1.1 ATT:1.1.1; locks; strict; comment @ * @; 1.3 date 99.09.11.13.20.42; author rse; state Exp; branches; next 1.2; 1.2 date 99.09.11.12.42.10; author rse; state Exp; branches; next 1.1; 1.1 date 96.12.13.20.56.45; author rse; state Exp; branches 1.1.1.1; next ; 1.1.1.1 date 96.12.13.20.56.45; author rse; state Exp; branches; next 1.1.1.2; 1.1.1.2 date 99.08.04.17.44.18; author rse; state Exp; branches; next ; desc @@ 1.3 log @Merge in Sfio 1999 changes @ text @#include "sftest.h" #include #define HANDLER "Handler" char Buf[16]; int Except; #if __STD_C static void alrmhandler(int sig) #else static void alrmhandler(sig) int sig; #endif { strcpy(Buf,HANDLER); signal(sig,alrmhandler); } #if __STD_C static int exceptf(Sfio_t* f, int type, Void_t* data, Sfdisc_t* disc) #else static int exceptf(f, type, data, disc) Sfio_t* f; int type; Void_t* data; Sfdisc_t* disc; #endif { if(type == SF_ATEXIT) return 0; if(type != SF_READ) terror("Bad Io type\n"); if(errno != EINTR) terror("Bad exception\n"); Except = 1; return -1; } Sfdisc_t Disc = {NIL(Sfread_f), NIL(Sfwrite_f), NIL(Sfseek_f), exceptf}; int main() { int fd[2]; if(pipe(fd) < 0) terror("Can't make pipe\n"); if(sfnew(sfstdin,NIL(char*),(size_t)SF_UNBOUND,fd[0],SF_READ) != sfstdin) terror("Can't renew stdin\n"); sfdisc(sfstdin,&Disc); sfset(sfstdin,SF_SHARE,1); signal(SIGALRM,alrmhandler); alarm(2); if(sfreserve(sfstdin,1,1)) terror("Unexpected data\n"); if(strcmp(Buf,HANDLER) != 0) terror("Handler wasn't called\n"); if(!Except) terror("Exception handler wasn't called1\n"); Buf[0] = 0; Except = 0; signal(SIGALRM,alrmhandler); alarm(2); if(sfgetr(sfstdin,'\n',0)) terror("Unexpected data2\n"); if(strcmp(Buf,HANDLER) != 0) terror("Handler wasn't called2\n"); if(!Except) terror("Exception handler wasn't called2\n"); return 0; } @ 1.2 log @Incorporate stuff from RSE's Sfio98 variant @ text @d29 3 d37 1 @ 1.1 log @Initial revision @ text @d9 1 a9 1 void alrmhandler(int sig) d11 1 a11 1 void alrmhandler(sig) d20 1 a20 1 exceptf(Sfio_t* f, int type, Void_t* data, Sfdisc_t* disc) d22 1 a22 1 exceptf(f, type, data, disc) d39 1 a39 1 main() @ 1.1.1.1 log @Import of Sfio1997 @ text @@ 1.1.1.2 log @Import of Sfio1999 @ text @a28 3 if(type == SF_ATEXIT) return 0; a33 1 @