Lines Matching refs:bsize
51 ssize_t bsize =
57 shf = alloc(sizeof(struct shf) + bsize, ATEMP);
60 shf->bsize = bsize;
124 ssize_t bsize =
130 if (bsize) {
131 shf->buf = alloc(bsize, ATEMP);
136 shf = alloc(sizeof(struct shf) + bsize, ATEMP);
144 shf->rbsize = bsize;
146 shf->wbsize = sflags & SHF_UNBUF ? 0 : bsize;
149 shf->bsize = bsize;
159 ssize_t bsize =
164 if (!shf || !shf->buf || shf->bsize < bsize)
165 internal_errorf("%s: %s", "shf_reopen", "bad shf/buf/bsize");
167 /* assumes shf->buf and shf->bsize already set up */
171 shf->rbsize = bsize;
173 shf->wbsize = sflags & SHF_UNBUF ? 0 : bsize;
182 * Open a string for reading or writing. If reading, bsize is the number
183 * of bytes that can be read. If writing, bsize is the maximum number of
186 * and SHF_DYNAMIC is set, the buffer is allocated (if bsize > 0, it is
191 shf_sopen(char *buf, ssize_t bsize, int sflags, struct shf *shf)
203 if (bsize <= 0)
204 bsize = 64;
206 buf = alloc(bsize, shf->areap);
210 shf->rnleft = bsize;
211 shf->rbsize = bsize;
212 shf->wnleft = bsize - 1; /* space for a '\0' */
213 shf->wbsize = bsize;
216 shf->bsize = bsize;
445 shf_read(char *buf, ssize_t bsize, struct shf *shf)
447 ssize_t ncopy, orig_bsize = bsize;
452 if (bsize <= 0)
453 internal_errorf("%s: %s %zd", "shf_write", "bsize", bsize);
455 while (bsize > 0) {
460 if (ncopy > bsize)
461 ncopy = bsize;
464 bsize -= ncopy;
469 return (orig_bsize == bsize ? (shf_error(shf) ? EOF : 0) :
470 orig_bsize - bsize);
480 shf_getse(char *buf, ssize_t bsize, struct shf *shf)
489 if (bsize <= 0)
493 --bsize;
506 if (ncopy > bsize)
507 ncopy = bsize;
512 bsize -= ncopy;
513 } while (!end && bsize);
710 shf_snprintf(char *buf, ssize_t bsize, const char *fmt, ...)
716 if (!buf || bsize <= 0)
717 internal_errorf("shf_snprintf: buf %zX, bsize %zd",
718 (size_t)buf, bsize);
720 shf_sopen(buf, bsize, SHF_WR, &shf);