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.12; 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 1.1.1.2; 1.1.1.2 date 98.03.24.18.47.32; author rse; state Exp; branches; next 1.1.1.3; 1.1.1.3 date 99.07.06.19.15.04; author rse; state Exp; branches; next ; desc @@ 1.3 log @Merge in Sfio 1999 changes @ text @#include "sftest.h" int main() { Sfio_t *f, *sf; char *ss, *s; int n, i; char zero[SF_BUFSIZE*2]; char buf[SF_BUFSIZE], small[512]; Sfoff_t one, two; s = "123456789\n"; n = strlen(s); if(!(f = sfopen((Sfio_t*)0, Kpv[0],"w"))) terror("Opening file to write\n"); for(i = 0; i < 1000; ++i) if(sfwrite(f,s,n) != n) terror("Writing data\n"); if(!(f = sfopen(f, Kpv[0],"r"))) terror("Opening file to read\n"); if(sfseek(f,(Sfoff_t)128,0) != (Sfoff_t)128) terror("Bad seek to 128\n"); if(sfseek(f,(Sfoff_t)0,1) != (Sfoff_t)128) terror("Bad seek(0,1) to 128\n"); if(sfseek(f,(Sfoff_t)0,2) != (i*n)) terror("Bad file length\n"); if(sftell(f) != (i*n)) terror("sftell\n"); for(; i > 0; --i) { sfseek(f,(Sfoff_t)(-i*n),2); if(!(ss = sfgetr(f,'\n',1))) terror("sfgetr\n"); if(strncmp(ss,s,sfvalue(f)-1) != 0) terror("Expect=%s\n",s); } if(!(f = sfopen(f,Kpv[0],"w")) ) terror("Open to write\n"); for(n = sizeof(zero)-1; n >= 0; --n) zero[n] = 0; if(sfwrite(f,zero,sizeof(zero)) != sizeof(zero)) terror("Writing data\n"); one = sfseek(f,(Sfoff_t)0,2); two = (Sfoff_t)lseek(sffileno(f),0L,2); if(one != two) terror("seeking1\n"); if(sfseek(f,(Sfoff_t)(-1),2) != (Sfoff_t)lseek(sffileno(f),-1L,2)) terror("seeking2\n"); if(!(f = sfopen(f,Kpv[0],"w"))) terror("Open to write2\n"); for(n = 0; n < sizeof(buf); n++) buf[n] = n; for(n = 0; n < 256; n++) if(sfwrite(f,buf,sizeof(buf)) != sizeof(buf)) terror("Writing data 2\n"); if(!(f = sfopen(f,Kpv[0],"r"))) terror("Open to read2\n"); if(sfgetc(f) != 0 && sfgetc(f) != 1) terror("Get first 2 bytes\n"); if(sfseek(f,(Sfoff_t)(128*sizeof(buf)),0) != (Sfoff_t)128*sizeof(buf) ) terror("Seeking \n"); for(n = 0; n < 128; ++n) if(sfread(f,buf,sizeof(buf)) != sizeof(buf)) terror("Reading data\n"); if(!(f = sfopen(f,Kpv[0],"r"))) terror("Open to read3\n"); sfsetbuf(f,small,sizeof(small)); if(sfread(f, buf, 10) != 10) terror("sfread failed\n"); if(sftell(f) != (Sfoff_t)10) terror("sftell failed\n"); if(sfseek(f, (Sfoff_t)10, SEEK_CUR|SF_PUBLIC) != (Sfoff_t)20) terror("sfseek failed\n"); sfseek(f, (Sfoff_t)0, SEEK_SET); if(!(sf = sfnew((Sfio_t*)0, small, sizeof(small), sffileno(f), SF_READ)) ) terror("sfnew failed\n"); if(sfread(f, buf, 10) != 10) terror("sfread failed2\n"); if(sftell(f) != 10) terror("sftell failed2\n"); if(sfseek(sf, (Sfoff_t)4000, SEEK_SET) != (Sfoff_t)4000) terror("sfseek failed on sf\n"); sfsync(sf); if(sfseek(f, (Sfoff_t)10, SEEK_CUR|SF_PUBLIC) != (Sfoff_t)4010) terror("sfseek public failed\n"); rmkpv(); return 0; } @ 1.2 log @Incorporate stuff from RSE's Sfio98 variant @ text @d5 1 a5 1 Sfio_t *f; d9 1 a9 1 char buf[SF_BUFSIZE]; d14 1 a14 1 if(!(f = sfopen((Sfio_t*)0,"xxx","w"))) d20 1 a20 1 if(!(f = sfopen(f,"xxx","r"))) d40 1 a40 1 if(!(f = sfopen(f,"xxx","w")) ) d53 1 a53 1 if(!(f = sfopen(f,"xxx","w"))) d60 1 a60 1 if(!(f = sfopen(f,"xxx","r"))) d71 26 a96 1 unlink("xxx"); @ 1.1 log @Initial revision @ text @d3 1 a3 1 main() d10 1 d22 6 d33 1 a33 1 { sfseek(f,-i*n,2); d46 3 a48 1 if(sfseek(f,(Sfoff_t)0,2) != (Sfoff_t)lseek(sffileno(f),0L,2)) d65 1 a65 1 if(sfseek(f,128*sizeof(buf),0) != 128*sizeof(buf) ) d71 1 a71 1 system("rm xxx >/dev/null 2>&1"); @ 1.1.1.1 log @Import of Sfio1997 @ text @@ 1.1.1.2 log @Import of Sfio1998 @ text @a9 1 Sfoff_t one, two; a20 6 if(sfseek(f,(Sfoff_t)128,0) != (Sfoff_t)128) terror("Bad seek to 128\n"); if(sfseek(f,(Sfoff_t)0,1) != (Sfoff_t)128) terror("Bad seek(0,1) to 128\n"); d26 1 a26 1 { sfseek(f,(Sfoff_t)(-i*n),2); d39 1 a39 3 one = sfseek(f,(Sfoff_t)0,2); two = (Sfoff_t)lseek(sffileno(f),0L,2); if(one != two) d56 1 a56 1 if(sfseek(f,(Sfoff_t)(128*sizeof(buf)),0) != (Sfoff_t)128*sizeof(buf) ) d62 1 a62 1 unlink("xxx"); @ 1.1.1.3 log @Import of Sfio1999 @ text @d5 1 a5 1 Sfio_t *f, *sf; d9 1 a9 1 char buf[SF_BUFSIZE], small[512]; d14 1 a14 1 if(!(f = sfopen((Sfio_t*)0, Kpv[0],"w"))) d20 1 a20 1 if(!(f = sfopen(f, Kpv[0],"r"))) d40 1 a40 1 if(!(f = sfopen(f,Kpv[0],"w")) ) d53 1 a53 1 if(!(f = sfopen(f,Kpv[0],"w"))) d60 1 a60 1 if(!(f = sfopen(f,Kpv[0],"r"))) d71 1 a71 26 if(!(f = sfopen(f,Kpv[0],"r"))) terror("Open to read3\n"); sfsetbuf(f,small,sizeof(small)); if(sfread(f, buf, 10) != 10) terror("sfread failed\n"); if(sftell(f) != (Sfoff_t)10) terror("sftell failed\n"); if(sfseek(f, (Sfoff_t)10, SEEK_CUR|SF_PUBLIC) != (Sfoff_t)20) terror("sfseek failed\n"); sfseek(f, (Sfoff_t)0, SEEK_SET); if(!(sf = sfnew((Sfio_t*)0, small, sizeof(small), sffileno(f), SF_READ)) ) terror("sfnew failed\n"); if(sfread(f, buf, 10) != 10) terror("sfread failed2\n"); if(sftell(f) != 10) terror("sftell failed2\n"); if(sfseek(sf, (Sfoff_t)4000, SEEK_SET) != (Sfoff_t)4000) terror("sfseek failed on sf\n"); sfsync(sf); if(sfseek(f, (Sfoff_t)10, SEEK_CUR|SF_PUBLIC) != (Sfoff_t)4010) terror("sfseek public failed\n"); rmkpv(); @