Lines Matching defs:stream

89 #define stream2stk(stream)	((stream)==stkstd? stkcur:\
90 ((struct stk*)(((char*)(stream))+STK_HDRSIZE)))
92 #define stkleft(stream) ((stream)->_endb-(stream)->_data)
144 static int stkexcept(register Sfio_t *stream, int type, void* val, Sfdisc_t* dp)
152 register struct stk *sp = stream2stk(stream);
158 if(stream==stkstd)
159 stkset(stream,(char*)0,0);
178 stream->_data = stream->_next = 0;
182 free(stream);
189 long size = sfvalue(stream);
193 if(stream!=stkstd)
194 old = stkinstall(stream,NiL);
216 register Sfio_t *stream;
221 if(!(stream=newof((char*)0,Sfio_t, 1, sizeof(*dp)+sizeof(*sp))))
224 count(addsize,sizeof(*stream)+sizeof(*dp)+sizeof(*sp));
225 dp = (Sfdisc_t*)(stream+1);
242 free(stream);
252 if(!sfnew(stream,cp,bsize,-1,SF_STRING|SF_WRITE|SF_STATIC|SF_EOF))
254 sfdisc(stream,dp);
255 return(stream);
260 * if <stream> is not null, it becomes the new current stack
263 Sfio_t *stkinstall(Sfio_t *stream, _stk_overflow_ oflow)
276 if(stream)
278 sp = stream2stk(stream);
280 if(stream!=stkstd)
281 sfstack(stkstd,stream);
297 int stklink(register Sfio_t* stream)
299 register struct stk *sp = stream2stk(stream);
309 int stkclose(Sfio_t* stream)
311 register struct stk *sp = stream2stk(stream);
317 return(sfclose(stream));
323 int stkon(register Sfio_t * stream, register char* loc)
325 register struct stk *sp = stream2stk(stream);
338 char *stkset(register Sfio_t * stream, register char* loc, size_t offset)
340 register struct stk *sp = stream2stk(stream);
365 sfsetbuf(stream,cp,sp->stkend-cp);
366 stream->_data = (unsigned char*)(cp + roundof(loc-cp,STK_ALIGN));
367 stream->_next = (unsigned char*)loc+offset;
383 sfsetbuf(stream,cp,sp->stkend-cp);
385 stream->_data = stream->_next = (unsigned char*)cp;
387 return((char*)stream->_data);
393 char *stkalloc(register Sfio_t *stream, register size_t n)
400 if(stkleft(stream) <= (int)n && !stkgrow(stream,n))
402 old = stream->_data;
403 stream->_data = stream->_next = old+n;
410 char *_stkseek(register Sfio_t *stream, register ssize_t n)
415 if(stkleft(stream) <= n && !stkgrow(stream,n))
417 stream->_next = stream->_data+n;
418 return((char*)stream->_data);
425 char *stkfreeze(register Sfio_t *stream, register size_t extra)
430 old = stream->_data;
431 top = stream->_next;
434 if(extra > (stream->_endb-stream->_next))
436 if (!(top = (unsigned char*)stkgrow(stream,extra)))
438 old = stream->_data;
443 stream->_next = stream->_data += roundof(top-old,STK_ALIGN);
450 char *stkcopy(Sfio_t *stream, const char* str)
454 register int off=stktell(stream);
462 struct stk *sp = stream2stk(stream);
467 memcpy(tp, stream->_data, off);
474 if(stkleft(stream) <= n && !stkgrow(stream,n))
478 strcpy((char*)(cp=stream->_data),str);
479 stream->_data = stream->_next = cp+n;
482 _stkseek(stream,off);
483 memcpy(stream->_data, tp, off);
498 static char *stkgrow(register Sfio_t *stream, size_t size)
501 register struct stk *sp = stream2stk(stream);
504 register size_t m = stktell(stream);
516 if(stkptr(stream,0)==sp->stkbase+sizeof(struct frame))
555 memcpy(cp,(char*)stream->_data,m);
558 sfsetbuf(stream,cp,sp->stkend-cp);
559 return((char*)(stream->_next = stream->_data+m));