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.10.04.20.21.28; author rse; state Exp; branches 1.1.1.1; next ; 1.1.1.1 date 96.10.04.20.21.28; author rse; state Exp; branches; next ; desc @@ 1.2 log @Incorporate stuff from RSE's Sfio98 variant @ text @#include "sftest.h" #if __STD_C int main(int argc, char** argv) #else int main(argc, argv) int argc; char **argv; #endif { Sfio_t *f; char buf[1024], *s; int n; if(argc > 1) { /* coprocess only */ while((s = sfreserve(sfstdin,-1,0))) sfwrite(sfstdout,s,sfvalue(sfstdin)); return 0; } /* make coprocess */ if(!(f = sfpopen(NIL(Sfio_t*), sfprints("%s -p",argv[0]), "r+"))) terror("Opening for read/write\n"); for(n = 0; n < 10; ++n) { sfsprintf(buf,sizeof(buf),"Line %d",n); sfputr(f,buf,'\n'); if(!(s = sfgetr(f,'\n',1))) terror("Did not read back line\n"); if(strcmp(s,buf) != 0) terror("Input=%s, Expect=%s\n",s,buf); } sfputr(f,"123456789",'\n'); sfsync(f); sleep(1); if(!(s = sfreserve(f,-1,1)) || sfvalue(f) != 10) terror("Did not get data back\n"); if(strncmp(s,"123456789\n",10) != 0) terror("Wrong data\n"); s[0] = s[1] = s[2] = '0'; if(sfwrite(f,s,3) != 3 || sfputc(f,'\n') != '\n') terror("Fail on write\n"); if(!(s = sfgetr(f,'\n',1)) ) terror("Lost data\n"); if(strcmp(s,"456789") != 0) terror("Wrong data2\n"); if(!(s = sfgetr(f,'\n',1)) ) terror("Lost data2\n"); if(strcmp(s,"000") != 0) terror("Wrong data3\n"); return 0; } @ 1.1 log @Initial revision @ text @d4 1 a4 1 main(int argc, char** argv) d6 1 a6 1 main(argc, argv) d17 1 a17 1 while(s = sfreserve(sfstdin,-1,0)) @ 1.1.1.1 log @Import of Sfio1997 @ text @@