head 1.2; access; symbols SFIO_1999:1.1.1.1 SFIO_1998:1.1.1.1 SFIO_1997:1.1.1.1 ATT:1.1.1; locks; strict; comment @ * @; 1.2 date 99.09.11.12.42.11; author rse; state Exp; branches; next 1.1; 1.1 date 96.12.13.21.24.36; author rse; state Exp; branches 1.1.1.1; next ; 1.1.1.1 date 96.12.13.21.24.36; author rse; state Exp; branches; next ; desc @@ 1.2 log @Incorporate stuff from RSE's Sfio98 variant @ text @#include "sftest.h" #if __STD_C static ssize_t myread(Sfio_t* f, Void_t* buf, size_t n, Sfdisc_t* disc) #else static ssize_t myread(f, buf, n, disc) Sfio_t* f; Void_t* buf; size_t n; Sfdisc_t* disc; #endif { return sfrd(f,buf,n,disc); } Sfdisc_t Disc = {myread, NIL(Sfwrite_f), NIL(Sfseek_f), NIL(Sfexcept_f)}; int main() { int fd[2]; if(pipe(fd) < 0) terror("Can't open pipe\n"); if(sfnew(sfstdin,NIL(Void_t*),(size_t)SF_UNBOUND,fd[0],SF_READ) != sfstdin) terror("Can't initialize sfstdin\n"); sfset(sfstdin,SF_SHARE,1); sfdisc(sfstdin,&Disc); if(sfnew(sfstdout,NIL(Void_t*),0,fd[1],SF_WRITE) != sfstdout) terror("Can't initialize sfstdout\n"); sfputr(sfstdout,"111\n222\n333\n",-1); sfsync(sfstdout); if(strcmp(sfgetr(sfstdin,'\n',1),"111") != 0) terror("sfgetr failed1\n"); if(sfstdin->endb > sfstdin->next) terror("sfgetr reads too much1\n"); if(strcmp(sfgetr(sfstdin,'\n',1),"222") != 0) terror("sfgetr failed2\n"); if(sfstdin->endb > sfstdin->next) terror("sfgetr reads too much2\n"); return 0; } @ 1.1 log @Initial revision @ text @d4 1 a4 1 ssize_t myread(Sfio_t* f, Void_t* buf, size_t n, Sfdisc_t* disc) d6 1 a6 1 ssize_t myread(f, buf, n, disc) d18 1 a18 1 main() @ 1.1.1.1 log @Import of Sfio1997 @ text @@