head 1.3; access; symbols SFIO_1999:1.1.1.2 SFIO_1998: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 97.10.10.18.34.42; author rse; state Exp; branches 1.1.1.1; next ; 1.1.1.1 date 97.10.10.18.34.42; author rse; state Exp; branches; next 1.1.1.2; 1.1.1.2 date 99.06.04.19.24.19; author rse; state Exp; branches; next ; desc @@ 1.3 log @Merge in Sfio 1999 changes @ text @#include "sftest.h" static int Count; static int Size; #if __STD_C static ssize_t writef(Sfio_t* f, const Void_t* buf, size_t n, Sfdisc_t* disc) #else static ssize_t writef(f,buf,n,disc) Sfio_t* f; Void_t* buf; size_t n; Sfdisc_t* disc; #endif { Count += 1; if((n % Size) != 0) terror("Wrong record size\n"); return write(f->file,buf,n); } Sfdisc_t Disc = {(Sfread_f)0, writef, (Sfseek_f)0, (Sfexcept_f)0, (Sfdisc_t*)0}; int main() { Sfio_t* f; char buf[550]; int i; char* s = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; Count = 0; Size = 52; if(!(f = sfopen(NIL(Sfio_t*), Kpv[0], "w")) ) terror("Opening to write\n"); sfsetbuf(f,buf,sizeof(buf)); sfset(f,SF_WHOLE,1); sfdisc(f,&Disc); for(i = 0; i < 100; ++i) if(sfwrite(f,s,52) != 52) terror("sfwrite failed\n"); sfclose(f); if(Count != 10) terror("Wrong number of writes1\n"); Count = 0; Size = 53; if(!(f = sfopen(NIL(Sfio_t*), Kpv[0],"w")) ) terror("Opening to write\n"); sfsetbuf(f,buf,sizeof(buf)); sfset(f,SF_WHOLE,1); sfdisc(f,&Disc); for(i = 0; i < 100; ++i) if(sfputr(f,s,'\n') != 53) terror("sfputr failed\n"); sfclose(f); if(Count != 10) terror("Wrong number of writes2\n"); rmkpv(); return 0; } @ 1.2 log @Incorporate stuff from RSE's Sfio98 variant @ text @d35 1 a35 1 if(!(f = sfopen(NIL(Sfio_t*),"xxx","w")) ) d51 1 a51 1 if(!(f = sfopen(NIL(Sfio_t*),"xxx","w")) ) d64 1 a64 2 system("rm xxx >/dev/null 2>&1"); @ 1.1 log @Initial revision @ text @d8 1 a8 1 ssize_t writef(Sfio_t* f, const Void_t* buf, size_t n, Sfdisc_t* disc) d10 1 a10 1 ssize_t writef(f,buf,n,disc) d25 1 a25 1 main() @ 1.1.1.1 log @Import of Sfio1998 @ text @@ 1.1.1.2 log @Import of Sfio1999 @ text @d35 1 a35 1 if(!(f = sfopen(NIL(Sfio_t*), Kpv[0], "w")) ) d51 1 a51 1 if(!(f = sfopen(NIL(Sfio_t*), Kpv[0],"w")) ) d64 2 a65 1 rmkpv(); @