Lines Matching refs:f
35 int _sffilbuf(Sfio_t* f, reg int n) in _sffilbuf() argument
37 int _sffilbuf(f,n) in _sffilbuf()
38 Sfio_t* f; /* fill the read buffer of this stream */ in _sffilbuf()
44 SFMTXDECL(f);
46 SFMTXENTER(f,-1);
48 GETLOCAL(f,local);
51 rcrv = f->mode&(SF_RC|SF_RV|SF_LOCK);
52 rc = f->getr;
54 justseek = f->bits&SF_JUSTSEEK; f->bits &= ~SF_JUSTSEEK;
56 for(first = 1;; first = 0, (f->mode &= ~SF_LOCK) )
58 if(SFMODE(f,local) != SF_READ && _sfmode(f,SF_READ,local) < 0)
59 SFMTXRETURN(f,-1);
60 SFLOCK(f,local);
63 if((r = f->endb-f->next) > 0)
67 (f->flags&SF_STRING))
71 if(!(f->bits&SF_MMAP) && f->next > f->data &&
72 n > (f->size - (f->endb-f->data)) )
76 if(f->blksz > 0 && (f->here%f->blksz) == 0 )
77 { s = ((r + f->blksz-1)/f->blksz)*f->blksz;
78 if(s+n > f->size)
82 memcpy(f->data, f->endb-s, s);
83 f->next = f->data + (s-r);
84 f->endb = f->data + s;
87 else if(!(f->flags&SF_STRING) && !(f->bits&SF_MMAP) )
88 f->next = f->endb = f->endr = f->data;
90 if(f->bits&SF_MMAP)
91 r = n > 0 ? n : f->size;
92 else if(!(f->flags&SF_STRING) )
93 { r = f->size - (f->endb - f->data); /* available buffer */
95 { if(r > n && f->extent < 0 && (f->flags&SF_SHARE) )
97 else if(justseek && n <= f->iosz && f->iosz <= f->size)
98 r = f->iosz; /* limit buffer filling */
103 f->mode |= rcrv;
104 f->getr = rc;
105 if((r = SFRD(f,f->endb,r,f->disc)) >= 0)
106 { r = f->endb - f->next;
111 SFOPEN(f,local);
113 rcrv = (n == 0) ? (r > 0 ? (int)(*f->next++) : EOF) : (int)r;
115 SFMTXRETURN(f,rcrv);