Lines Matching refs:bsize
54 ssize_t bsize =
60 shf = alloc(sizeof(struct shf) + bsize, ATEMP);
63 shf->bsize = bsize;
131 ssize_t bsize =
137 if (bsize) {
138 shf->buf = alloc(bsize, ATEMP);
143 shf = alloc(sizeof(struct shf) + bsize, ATEMP);
151 shf->rbsize = bsize;
153 shf->wbsize = sflags & SHF_UNBUF ? 0 : bsize;
156 shf->bsize = bsize;
166 ssize_t bsize =
171 if (!shf || !shf->buf || shf->bsize < bsize)
174 /* assumes shf->buf and shf->bsize already set up */
178 shf->rbsize = bsize;
180 shf->wbsize = sflags & SHF_UNBUF ? 0 : bsize;
189 * Open a string for reading or writing. If reading, bsize is the number
190 * of bytes that can be read. If writing, bsize is the maximum number of
193 * and SHF_DYNAMIC is set, the buffer is allocated (if bsize > 0, it is
198 shf_sopen(char *buf, ssize_t bsize, int sflags, struct shf *shf)
211 if (bsize <= 0)
212 bsize = 64;
214 buf = alloc(bsize, shf->areap);
218 shf->rnleft = bsize;
219 shf->rbsize = bsize;
220 shf->wnleft = bsize - 1; /* space for a '\0' */
221 shf->wbsize = bsize;
224 shf->bsize = bsize;
455 shf_read(char *buf, ssize_t bsize, struct shf *shf)
457 ssize_t ncopy, orig_bsize = bsize;
463 if (bsize <= 0)
464 internal_errorf(Tf_szs, Tshf_read, bsize, Tbsize);
466 while (bsize > 0) {
471 if (ncopy > bsize)
472 ncopy = bsize;
475 bsize -= ncopy;
480 return (orig_bsize == bsize ? (shf_error(shf) ? -1 : 0) :
481 orig_bsize - bsize);
491 shf_getse(char *buf, ssize_t bsize, struct shf *shf)
501 if (bsize <= 0)
505 --bsize;
518 if (ncopy > bsize)
519 ncopy = bsize;
524 bsize -= ncopy;
529 bsize++;
533 } while (!end && bsize);
535 if (!bsize && ord(buf[-1]) == ORD('\r')) {
743 shf_snprintf(char *buf, ssize_t bsize, const char *fmt, ...)
749 if (!buf || bsize <= 0)
750 internal_errorf("shf_snprintf: buf %zX, bsize %zd",
751 (size_t)buf, bsize);
753 shf_sopen(buf, bsize, SHF_WR, &shf);