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.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.52.33; author rse; state Exp; branches 1.1.1.1; next ; 1.1.1.1 date 96.12.13.20.52.33; author rse; state Exp; branches; next 1.1.1.2; 1.1.1.2 date 97.06.02.18.02.25; author rse; state Exp; branches; next 1.1.1.3; 1.1.1.3 date 99.06.04.18.48.53; author rse; state Exp; branches; next ; desc @@ 1.3 log @Merge in Sfio 1999 changes @ text @#include "sftest.h" int main() { Sfio_t *f1, *f2; char* s; Sfoff_t p; char buf[1024]; int r, w; if(!(f1 = sfopen(NIL(Sfio_t*), Kpv[0], "w")) ) terror("Can't open f1\n"); if(!(f1 = sfopen(f1, Kpv[0], "a+")) ) terror("Can't open f1\n"); if(!(f2 = sfopen(NIL(Sfio_t*), Kpv[0], "a+")) ) terror("Can't open f2\n"); if(sfwrite(f1,"012345678\n",10) != 10 || sfsync(f1) < 0) terror("Writing to f1\n"); if((p = sftell(f1)) != 10) terror("Bad sftell1 %ld\n",p); if(sfwrite(f2,"abcdefghi\n",10) != 10 || sfsync(f2) < 0) terror("Writing to f2\n"); if((p = sftell(f2)) != 20) terror("Bad sftell2\n"); if((p = sfseek(f1,(Sfoff_t)0,0)) != 0) terror("Bad seek\n"); if(!(s = sfgetr(f1,'\n',1)) ) terror("Bad getr1\n"); if(strcmp(s,"012345678") != 0) terror("Bad input1\n"); if((p = sftell(f1)) != 10) terror("Bad sftell3\n"); if(sfwrite(f1,"012345678\n",10) != 10 || sfsync(f1) < 0) terror("Writing to f1\n"); if((p = sftell(f1)) != 30) terror("Bad sftell4\n"); if((p = sfseek(f2,(Sfoff_t)10,0)) != 10) terror("Bad seek\n"); if(!(s = sfgetr(f2,'\n',1)) ) terror("Bad getr2\n"); if(strcmp(s,"abcdefghi") != 0) terror("Bad input2\n"); if(!(s = sfgetr(f2,'\n',1)) ) terror("Bad getr3\n"); if(strcmp(s,"012345678") != 0) terror("Bad input3\n"); if(!(f1 = sfopen(f1, Kpv[0], "w")) ) terror("Can't open file to write\n"); for(r = 0; r < 1024; ++r) buf[r] = 'a'; if((w = sfwrite(f1,buf,1024)) != 1024) terror("writing w=%d\n", w); if(!(f1 = sfopen(f1, Kpv[0], "a")) ) terror("Can't open file to append\n"); sfseek(f1,(Sfoff_t)0,0); if((w = sfwrite(f1,buf,64)) != 64) terror("writing w=%d\n", w); if((r = (int)sftell(f1)) != (1024+64) ) terror("seek position wrong s=%d\n", r); rmkpv(); return 0; } @ 1.2 log @Incorporate stuff from RSE's Sfio98 variant @ text @d8 2 d11 1 a11 1 if(!(f1 = sfopen(NIL(Sfio_t*),"xxx","w")) ) d13 1 a13 1 if(!(f1 = sfopen(f1,"xxx","a+")) ) d16 1 a16 1 if(!(f2 = sfopen(NIL(Sfio_t*),"xxx","a+")) ) d56 16 a71 1 unlink("xxx"); @ 1.1 log @Initial revision @ text @d3 1 a3 1 main() d54 1 a54 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 @d54 1 a54 1 unlink("xxx"); @ 1.1.1.3 log @Import of Sfio1999 @ text @a7 2 char buf[1024]; int r, w; d9 1 a9 1 if(!(f1 = sfopen(NIL(Sfio_t*), Kpv[0], "w")) ) d11 1 a11 1 if(!(f1 = sfopen(f1, Kpv[0], "a+")) ) d14 1 a14 1 if(!(f2 = sfopen(NIL(Sfio_t*), Kpv[0], "a+")) ) d54 1 a54 16 if(!(f1 = sfopen(f1, Kpv[0], "w")) ) terror("Can't open file to write\n"); for(r = 0; r < 1024; ++r) buf[r] = 'a'; if((w = sfwrite(f1,buf,1024)) != 1024) terror("writing w=%d\n", w); if(!(f1 = sfopen(f1, Kpv[0], "a")) ) terror("Can't open file to append\n"); sfseek(f1,(Sfoff_t)0,0); if((w = sfwrite(f1,buf,64)) != 64) terror("writing w=%d\n", w); if((r = (int)sftell(f1)) != (1024+64) ) terror("seek position wrong s=%d\n", r); rmkpv(); @