Lines Matching refs:bsize
43 int bsize = sflags & SHF_UNBUF ? (sflags & SHF_RD ? 1 : 0) : SHF_BSIZE;
47 shf = (struct shf *) alloc(sizeof(struct shf) + bsize, ATEMP);
50 shf->bsize = bsize;
85 int bsize = sflags & SHF_UNBUF ? (sflags & SHF_RD ? 1 : 0) : SHF_BSIZE;
106 if (bsize) {
107 shf->buf = (unsigned char *) alloc(bsize, ATEMP);
112 shf = (struct shf *) alloc(sizeof(struct shf) + bsize, ATEMP);
120 shf->rbsize = bsize;
122 shf->wbsize = sflags & SHF_UNBUF ? 0 : bsize;
125 shf->bsize = bsize;
138 int bsize = sflags & SHF_UNBUF ? (sflags & SHF_RD ? 1 : 0) : SHF_BSIZE;
157 if (!shf || !shf->buf || shf->bsize < bsize)
158 internal_errorf(1, "shf_reopen: bad shf/buf/bsize");
160 /* assumes shf->buf and shf->bsize already set up */
164 shf->rbsize = bsize;
166 shf->wbsize = sflags & SHF_UNBUF ? 0 : bsize;
174 /* Open a string for reading or writing. If reading, bsize is the number
175 * of bytes that can be read. If writing, bsize is the maximum number of
178 * and SHF_DYNAMIC is set, the buffer is allocated (if bsize > 0, it is
183 shf_sopen(buf, bsize, sflags, shf)
185 int bsize;
200 if (bsize <= 0)
201 bsize = 64;
203 buf = alloc(bsize, shf->areap);
207 shf->rnleft = bsize;
208 shf->rbsize = bsize;
209 shf->wnleft = bsize - 1; /* space for a '\0' */
210 shf->wbsize = bsize;
213 shf->bsize = bsize;
508 shf_read(buf, bsize, shf)
510 int bsize;
513 int orig_bsize = bsize;
519 if (bsize <= 0)
520 internal_errorf(1, "shf_read: bsize %d", bsize);
522 while (bsize > 0) {
527 if (ncopy > bsize)
528 ncopy = bsize;
531 bsize -= ncopy;
536 return orig_bsize == bsize ? (shf_error(shf) ? EOF : 0)
537 : orig_bsize - bsize;
545 shf_getse(buf, bsize, shf)
547 int bsize;
557 if (bsize <= 0)
560 --bsize; /* save room for null */
573 if (ncopy > bsize)
574 ncopy = bsize;
579 bsize -= ncopy;
581 } while (!end && bsize);
774 shf_snprintf(char *buf, int bsize, const char *fmt, ...)
780 if (!buf || bsize <= 0)
781 internal_errorf(1, "shf_snprintf: buf %lx, bsize %d",
782 (long) buf, bsize);
784 shf_sopen(buf, bsize, SHF_WR, &shf);