head 1.3; access; symbols SFIO_1999:1.1.1.3 SFIO_1998:1.1.1.2 SFIO_1997:1.1.1.1 ATT:1.1.1; locks; strict; comment @ * @; 1.3 date 99.09.11.13.20.43; author rse; state Exp; branches; next 1.2; 1.2 date 99.09.11.12.42.11; author rse; state Exp; branches; next 1.1; 1.1 date 96.12.13.20.53.39; author rse; state Exp; branches 1.1.1.1; next ; 1.1.1.1 date 96.12.13.20.53.39; author rse; state Exp; branches; next 1.1.1.2; 1.1.1.2 date 97.06.02.18.04.45; author rse; state Exp; branches; next 1.1.1.3; 1.1.1.3 date 99.06.04.18.56.15; author rse; state Exp; branches; next ; desc @@ 1.3 log @Merge in Sfio 1999 changes @ text @#include "sftest.h" /* Test multiple processes reading/writing from same file ** descriptor. */ #if __STD_C int main(int argc, char** argv) #else int main(argc,argv) int argc; char** argv; #endif { char* s; if(argc > 1) { if(strcmp(argv[1],"-r") == 0) /* doing sfgetr */ { if(!(s = sfgetr(sfstdin,'\n',1)) || strcmp(s,"Line2") != 0) terror("Coprocess getr did not get Line2\n"); if(!(s = sfgetr(sfstdin,'\n',1)) || strcmp(s,"Line3") != 0) terror("Coprocess getr did not get Line3\n"); } else /* doing sfmove */ { Sfio_t* f = sfopen(NIL(Sfio_t*),NIL(char*),"swr"); if(!f) terror("Can't open string stream\n"); if(sfmove(sfstdin,f,(Sfoff_t)2,'\n') != 2) terror("Coprocess sfmove failed\n"); sfseek(f,(Sfoff_t)0,0); if(!(s = sfgetr(f,'\n',1)) || strcmp(s,"Line2") != 0) terror("Coprocess move did not get Line2\n"); if(!(s = sfgetr(f,'\n',1)) || strcmp(s,"Line3") != 0) terror("Coprocess move did not get Line3\n"); } exit(0); } if(sfopen(sfstdout, Kpv[0], "w") != sfstdout ) terror("Opening file\n"); if(sfputr(sfstdout,"Line1",'\n') < 0 || sfputr(sfstdout,"Line2",'\n') < 0 || sfputr(sfstdout,"Line3",'\n') < 0 || sfputr(sfstdout,"Line4",'\n') < 0) terror("Writing data\n"); sfopen(sfstdout,"/dev/null","w"); /* testing coprocess calling sfgetr */ if(sfopen(sfstdin, Kpv[0],"r") != sfstdin) terror("Opening to read\n"); if(!(s = sfgetr(sfstdin,'\n',1)) || strcmp(s,"Line1") != 0) terror("Did not get Line1 for sfgetr\n"); sfsync(sfstdin); system(sfprints("%s -r",argv[0])); sfseek(sfstdin,(Sfoff_t)lseek(sffileno(sfstdin),0L,1),0); if(!(s = sfgetr(sfstdin,'\n',1)) || strcmp(s,"Line4") != 0) terror("Did not get Line4 for sfgetr\n"); /* testing coprocess calling sfmove */ if(sfopen(sfstdin, Kpv[0], "r") != sfstdin) terror("Opening to read\n"); if(!(s = sfgetr(sfstdin,'\n',1)) || strcmp(s,"Line1") != 0) terror("Did not get Line1 for sfmove\n"); sfsync(sfstdin); system(sfprints("%s -m",argv[0])); sfseek(sfstdin,(Sfoff_t)lseek(sffileno(sfstdin),0L,1),0); if(!(s = sfgetr(sfstdin,'\n',1)) || strcmp(s,"Line4") != 0) terror("Did not get Line4 for sfmove\n"); /* testing the head program */ #ifdef HEAD if(sfopen(sfstdin, Kpv[0], "r") != sfstdin) terror("Opening to read\n"); if(!(s = sfgetr(sfstdin,'\n',1)) || strcmp(s,"Line1") != 0) terror("Did not get Line1 for head\n"); sfsync(sfstdin); system("/usr/addon/ast/bin/head -2 > /dev/null"); sfseek(sfstdin,(Sfoff_t)lseek(sffileno(sfstdin),0L,1),0); if(!(s = sfgetr(sfstdin,'\n',1)) || strcmp(s,"Line4") != 0) terror("Did not get Line4 for head\n"); #endif rmkpv(); return 0; } @ 1.2 log @Incorporate stuff from RSE's Sfio98 variant @ text @d39 2 a40 2 if(sfopen(sfstdout,"xxx","w") != sfstdout ) terror("Opening xxx\n"); d49 2 a50 2 if(sfopen(sfstdin,"xxx","r") != sfstdin) terror("Opening xxx to read\n"); d60 2 a61 2 if(sfopen(sfstdin,"xxx","r") != sfstdin) terror("Opening xxx to read\n"); d72 2 a73 2 if(sfopen(sfstdin,"xxx","r") != sfstdin) terror("Opening xxx to read\n"); d83 1 a83 1 unlink("xxx"); @ 1.1 log @Initial revision @ text @d8 1 a8 1 main(int argc, char** argv) d10 1 a10 1 main(argc,argv) d28 1 a28 1 if(sfmove(sfstdin,f,2,'\n') != 2) d83 1 a83 1 system("rm xxx"); @ 1.1.1.1 log @Import of Sfio1997 @ text @@ 1.1.1.2 log @Import of Sfio1998 @ text @d28 1 a28 1 if(sfmove(sfstdin,f,(Sfoff_t)2,'\n') != 2) d83 1 a83 1 unlink("xxx"); @ 1.1.1.3 log @Import of Sfio1999 @ text @d39 2 a40 2 if(sfopen(sfstdout, Kpv[0], "w") != sfstdout ) terror("Opening file\n"); d49 2 a50 2 if(sfopen(sfstdin, Kpv[0],"r") != sfstdin) terror("Opening to read\n"); d60 2 a61 2 if(sfopen(sfstdin, Kpv[0], "r") != sfstdin) terror("Opening to read\n"); d72 2 a73 2 if(sfopen(sfstdin, Kpv[0], "r") != sfstdin) terror("Opening to read\n"); d83 1 a83 1 rmkpv(); @