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.12.13.20.53.43; author rse; state Exp; branches 1.1.1.1; next ; 1.1.1.1 date 96.12.13.20.53.43; author rse; state Exp; branches; next ; desc @@ 1.2 log @Incorporate stuff from RSE's Sfio98 variant @ text @#include "sftest.h" char* buffer; size_t size; size_t count; #if __STD_C static Sfoff_t discseek(Sfio_t* f, Sfoff_t offset, int type, Sfdisc_t* disc) #else static Sfoff_t discseek(f,offset,type,disc) Sfio_t* f; Sfoff_t offset; int type; Sfdisc_t* disc; #endif { return 0; } #if __STD_C static ssize_t discwrite(Sfio_t* f, const Void_t* s, size_t n, Sfdisc_t* disc) #else static ssize_t discwrite(f,s,n,disc) Sfio_t* f; Void_t* s; size_t n; Sfdisc_t* disc; #endif { buffer = (char*)s; size = n; count += 1; return n; } Sfdisc_t seekable = { (Sfread_f)0, discwrite, discseek, (Sfexcept_f)0 }; int main() { char buf[1024]; sfsetbuf(sfstdout,buf,sizeof(buf)); sfset(sfstdout,SF_LINE,0); if(sfdisc(sfstdout,&seekable) != &seekable) terror("Can't set discipline\n"); if(sfseek(sfstdout,(Sfoff_t)0,0) < 0) terror("Sfstdout should be seekable\n"); if(sfwrite(sfstdout,"123\n",4) != 4) terror("Can't write\n"); if(sfwrite(sfstdout,"123\n",4) != 4) terror("Can't write\n"); if(sfdisc(sfstdout,NIL(Sfdisc_t*)) != &seekable) terror("Can't pop discipline\n"); if(buffer != buf || size != 8 || count != 1) terror("Wrong calls to write\n"); return 0; } @ 1.1 log @Initial revision @ text @d8 1 a8 1 Sfoff_t discseek(Sfio_t* f, Sfoff_t offset, int type, Sfdisc_t* disc) d10 1 a10 1 Sfoff_t discseek(f,offset,type,disc) d21 1 a21 1 ssize_t discwrite(Sfio_t* f, const Void_t* s, size_t n, Sfdisc_t* disc) d23 1 a23 1 ssize_t discwrite(f,s,n,disc) d38 1 a38 1 main() @ 1.1.1.1 log @Import of Sfio1997 @ text @@