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.12; author rse; state Exp; branches; next 1.1; 1.1 date 96.12.13.21.30.03; author rse; state Exp; branches 1.1.1.1; next ; 1.1.1.1 date 96.12.13.21.30.03; author rse; state Exp; branches; next ; desc @@ 1.2 log @Incorporate stuff from RSE's Sfio98 variant @ text @#include "sftest.h" int main() { Sfio_t *f; char *str, *alpha, *s; char buf[128]; int n; str = "0123456789"; alpha = "abcdefghijklmnop"; if(!(f = sfopen((Sfio_t*)0,alpha,"s"))) terror("Opening stream\n"); for(n = 9; n >= 0; --n) if(sfungetc(f,n+'0') != n+'0') terror("Ungetc\n"); if(!(s = sfreserve(f,-1,0)) || sfvalue(f) != 10) terror("Peek stream1\n"); if(strncmp(s,str,10) != 0) terror("Bad data1\n"); if(!(s = sfreserve(f,-1,0)) || sfvalue(f) != (ssize_t)strlen(alpha)) terror("Peek stream2\n"); if(strncmp(s,alpha,strlen(alpha)) != 0) terror("Bad data2\n"); sfseek(f,(Sfoff_t)0,0); for(n = 9; n >= 0; --n) if(sfungetc(f,n+'0') != n+'0') terror("Ungetc2\n"); if(sfgetc(f) != '0') terror("Sfgetc\n"); sfseek(f,(Sfoff_t)0,0); if(!(s = sfreserve(f,-1,0)) || sfvalue(f) != (ssize_t)strlen(alpha)) terror("Peek stream3\n"); if(strncmp(s,alpha,strlen(alpha)) != 0) terror("Bad data2\n"); sfseek(f,(Sfoff_t)0,0); if(sfungetc(f,'0') != '0') terror("Ungetc3\n"); strcpy(buf,"0123456789\n"); if(!(f = sfopen(f,buf,"s+")) ) terror("Reopening string\n"); if(sfungetc(f,'\n') != '\n') terror("Can't unget new-line2\n"); if(sfungetc(f,'d') != 'd') terror("Can't unget d\n"); if(sfungetc(f,'c') != 'c') terror("Can't unget c\n"); if(sfungetc(f,'\n') != '\n') terror("Can't unget new-line\n"); if(sfungetc(f,'b') != 'b') terror("Can't unget b\n"); if(sfungetc(f,'a') != 'a') terror("Can't unget a\n"); if(!(s = sfgetr(f,'\n',1)) || strcmp(s,"ab") != 0) terror("Did not get ab\n"); if(!(s = sfgetr(f,'\n',1)) || strcmp(s,"cd") != 0) terror("Did not get cd\n"); if(!(s = sfgetr(f,'\n',1)) || strcmp(s,"0123456789") != 0) terror("Did not get 0123456789\n"); return 0; } @ 1.1 log @Initial revision @ text @d3 1 a3 1 main() @ 1.1.1.1 log @Import of Sfio1997 @ text @@