Symbol: shf
bin/ksh/c_sh.c
21
static void p_tv(struct shf *, int, struct timeval *, int, char *, char *);
bin/ksh/c_sh.c
22
static void p_ts(struct shf *, int, struct timespec *, int, char *, char *);
bin/ksh/c_sh.c
258
struct shf *shf;
bin/ksh/c_sh.c
298
shf = shf_reopen(fd, SHF_RD | SHF_INTERRUPT | can_seek(fd), shl_spare);
bin/ksh/c_sh.c
332
c = shf_getc(shf);
bin/ksh/c_sh.c
335
if (c == EOF && shf_error(shf) &&
bin/ksh/c_sh.c
336
shf->errno_ == EINTR) {
bin/ksh/c_sh.c
345
shf_clearerr(shf);
bin/ksh/c_sh.c
394
shf_flush(shf);
bin/ksh/c_sh.c
401
shf_flush(shf);
bin/ksh/c_sh.c
406
shf_flush(shf);
bin/ksh/c_sh.c
680
p_tv(struct shf *shf, int posix, struct timeval *tv, int width, char *prefix,
bin/ksh/c_sh.c
686
p_ts(shf, posix, &ts, width, prefix, suffix);
bin/ksh/c_sh.c
690
p_ts(struct shf *shf, int posix, struct timespec *ts, int width, char *prefix,
bin/ksh/c_sh.c
694
shf_fprintf(shf, "%s%*lld.%02ld%s", prefix ? prefix : "",
bin/ksh/c_sh.c
698
shf_fprintf(shf, "%s%*lldm%02lld.%02lds%s", prefix ? prefix : "",
bin/ksh/eval.c
33
struct shf *shf;/* file */
bin/ksh/eval.c
549
if (x.u.shf == NULL) /* $(< ...) failed, fake EOF */
bin/ksh/eval.c
555
while ((c = shf_getc(x.u.shf)) == 0 || c == '\n')
bin/ksh/eval.c
559
shf_ungetc(c, x.u.shf);
bin/ksh/eval.c
566
if (x.u.shf != NULL)
bin/ksh/eval.c
567
shf_close(x.u.shf);
bin/ksh/eval.c
571
subst_exstat = (x.u.shf == NULL);
bin/ksh/eval.c
889
struct shf *shf;
bin/ksh/eval.c
909
shf = shf_open(name = evalstr(io->name, DOTILDE), O_RDONLY, 0,
bin/ksh/eval.c
911
if (shf == NULL)
bin/ksh/eval.c
918
shf = shf_fdopen(pv[0], SHF_RD, NULL);
bin/ksh/eval.c
930
xp->u.shf = shf;
bin/ksh/exec.c
1188
struct shf *volatile shf;
bin/ksh/exec.c
1202
if (!(shf = h->shf) || (fd = open(h->name, O_RDONLY)) == -1) {
bin/ksh/exec.c
1204
!shf ? "create" : "open",
bin/ksh/exec.c
1206
if (shf)
bin/ksh/exec.c
1207
shf_close(shf);
bin/ksh/exec.c
1216
quitenv(shf);
bin/ksh/exec.c
1228
shf_puts(evalstr(yylval.cp, 0), shf);
bin/ksh/exec.c
1230
shf_puts(content, shf);
bin/ksh/exec.c
1234
if (shf_close(shf) == EOF) {
bin/ksh/history.c
217
if (!(shf = tf->shf)) {
bin/ksh/history.c
224
shf_fprintf(shf, "%s\n", *hp);
bin/ksh/history.c
225
if (shf_close(shf) == EOF) {
bin/ksh/history.c
249
if (!(shf = shf_open(tf->name, O_RDONLY, 0, 0))) {
bin/ksh/history.c
254
n = fstat(shf->fd, &statb) == -1 ? 128 :
bin/ksh/history.c
257
while ((n = shf_read(xp, Xnleft(xs, xp), shf)) > 0) {
bin/ksh/history.c
264
tf->name, strerror(shf->errno_));
bin/ksh/history.c
265
shf_close(shf);
bin/ksh/history.c
268
shf_close(shf);
bin/ksh/history.c
55
struct shf *shf;
bin/ksh/io.c
166
static struct shf *kshdebug_shf;
bin/ksh/io.c
229
struct shf shf_iob[3];
bin/ksh/io.c
450
tp->shf = NULL;
bin/ksh/io.c
455
tp->shf = shf_fdopen(fd, SHF_WR, NULL);
bin/ksh/jobs.c
129
static struct shf *shl_j;
bin/ksh/jobs.c
1307
j_print(Job *j, int how, struct shf *shf)
bin/ksh/jobs.c
1323
shf_fprintf(shf, "%d\n", j->pgrp ? j->pgrp :
bin/ksh/jobs.c
1371
shf_fprintf(shf, "[%d] %c ", j->job, jobchar);
bin/ksh/jobs.c
1373
shf_fprintf(shf, "%s", filler);
bin/ksh/jobs.c
1377
shf_fprintf(shf, "%5d ", p->pid);
bin/ksh/jobs.c
1382
shf_fprintf(shf, "%s%s ",
bin/ksh/jobs.c
1387
shf_fprintf(shf, "%-20s %s%s%s", buf, p->command,
bin/ksh/jobs.c
139
static void j_print(Job *, int, struct shf *);
bin/ksh/jobs.c
1397
shf_fprintf(shf, "%s%5d %-20s %s%s", filler, p->pid,
bin/ksh/jobs.c
1400
shf_fprintf(shf, " %s%s", p->command,
bin/ksh/jobs.c
1406
shf_fprintf(shf, "\n");
bin/ksh/lex.c
1111
char *p = shf_getse(xp, Xnleft(s->xs, xp), s->u.shf);
bin/ksh/lex.c
1113
if (!p && shf_error(s->u.shf) &&
bin/ksh/lex.c
1114
s->u.shf->errno_ == EINTR) {
bin/ksh/lex.c
1115
shf_clearerr(s->u.shf);
bin/ksh/lex.c
1134
shf_flush(s->u.shf);
bin/ksh/lex.c
1149
shf_fdclose(s->u.shf);
bin/ksh/lex.h
18
struct shf *shf; /* shell file */
bin/ksh/main.c
353
s->u.shf = shf_open(s->file, O_RDONLY, 0, SHF_MAPHI|SHF_CLEXEC);
bin/ksh/main.c
354
if (s->u.shf == NULL) {
bin/ksh/main.c
363
s->u.shf = shf_fdopen(0, SHF_RD | can_seek(0), NULL);
bin/ksh/main.c
368
s->u.shf->flags |= SHF_INTERRUPT;
bin/ksh/main.c
474
struct shf *shf;
bin/ksh/main.c
479
shf = shf_open(name, O_RDONLY, 0, SHF_MAPHI|SHF_CLEXEC);
bin/ksh/main.c
480
if (shf == NULL)
bin/ksh/main.c
493
quitenv(s ? s->u.shf : NULL);
bin/ksh/main.c
524
s->u.shf = shf;
bin/ksh/main.c
527
quitenv(s->u.shf);
bin/ksh/main.c
724
quitenv(struct shf *shf)
bin/ksh/main.c
764
if (shf)
bin/ksh/main.c
765
shf_close(shf);
bin/ksh/main.c
769
if (shf)
bin/ksh/main.c
770
shf_close(shf);
bin/ksh/misc.c
1008
print_columns(struct shf *shf, int n, char *(*func) (void *, int, char *, int),
bin/ksh/misc.c
1045
shf_fprintf(shf, "%-*s",
bin/ksh/misc.c
1049
shf_fprintf(shf, "%*s", nspace, "");
bin/ksh/misc.c
1052
shf_putchar('\n', shf);
bin/ksh/sh.h
195
struct shf *shf;
bin/ksh/sh.h
527
void quitenv(struct shf *);
bin/ksh/sh.h
551
void print_columns(struct shf *, int, char *(*)(void *, int, char *, int),
bin/ksh/shf.c
1001
shf_putc(c, shf);
bin/ksh/shf.c
1005
return shf_error(shf) ? EOF : nwritten;
bin/ksh/shf.c
105
if (shf) {
bin/ksh/shf.c
107
shf->buf = alloc(bsize, ATEMP);
bin/ksh/shf.c
110
shf->buf = NULL;
bin/ksh/shf.c
112
shf = alloc(sizeof(struct shf) + bsize, ATEMP);
bin/ksh/shf.c
113
shf->buf = (unsigned char *) &shf[1];
bin/ksh/shf.c
116
shf->areap = ATEMP;
bin/ksh/shf.c
117
shf->fd = fd;
bin/ksh/shf.c
118
shf->rp = shf->wp = shf->buf;
bin/ksh/shf.c
119
shf->rnleft = 0;
bin/ksh/shf.c
120
shf->rbsize = bsize;
bin/ksh/shf.c
121
shf->wnleft = 0; /* force call to shf_emptybuf() */
bin/ksh/shf.c
122
shf->wbsize = sflags & SHF_UNBUF ? 0 : bsize;
bin/ksh/shf.c
123
shf->flags = sflags;
bin/ksh/shf.c
124
shf->errno_ = 0;
bin/ksh/shf.c
125
shf->bsize = bsize;
bin/ksh/shf.c
128
return shf;
bin/ksh/shf.c
132
struct shf *
bin/ksh/shf.c
133
shf_reopen(int fd, int sflags, struct shf *shf)
bin/ksh/shf.c
161
if (!shf || !shf->buf || shf->bsize < bsize)
bin/ksh/shf.c
165
shf->fd = fd;
bin/ksh/shf.c
166
shf->rp = shf->wp = shf->buf;
bin/ksh/shf.c
167
shf->rnleft = 0;
bin/ksh/shf.c
168
shf->rbsize = bsize;
bin/ksh/shf.c
169
shf->wnleft = 0; /* force call to shf_emptybuf() */
bin/ksh/shf.c
170
shf->wbsize = sflags & SHF_UNBUF ? 0 : bsize;
bin/ksh/shf.c
171
shf->flags = (shf->flags & (SHF_ALLOCS | SHF_ALLOCB)) | sflags;
bin/ksh/shf.c
172
shf->errno_ = 0;
bin/ksh/shf.c
175
return shf;
bin/ksh/shf.c
186
struct shf *
bin/ksh/shf.c
187
shf_sopen(char *buf, int bsize, int sflags, struct shf *shf)
bin/ksh/shf.c
194
if (!shf) {
bin/ksh/shf.c
195
shf = alloc(sizeof(struct shf), ATEMP);
bin/ksh/shf.c
198
shf->areap = ATEMP;
bin/ksh/shf.c
203
buf = alloc(bsize, shf->areap);
bin/ksh/shf.c
205
shf->fd = -1;
bin/ksh/shf.c
206
shf->buf = shf->rp = shf->wp = (unsigned char *) buf;
bin/ksh/shf.c
207
shf->rnleft = bsize;
bin/ksh/shf.c
208
shf->rbsize = bsize;
bin/ksh/shf.c
209
shf->wnleft = bsize - 1; /* space for a '\0' */
bin/ksh/shf.c
210
shf->wbsize = bsize;
bin/ksh/shf.c
211
shf->flags = sflags | SHF_STRING;
bin/ksh/shf.c
212
shf->errno_ = 0;
bin/ksh/shf.c
213
shf->bsize = bsize;
bin/ksh/shf.c
215
return shf;
bin/ksh/shf.c
220
shf_close(struct shf *shf)
bin/ksh/shf.c
224
if (shf->fd >= 0) {
bin/ksh/shf.c
225
ret = shf_flush(shf);
bin/ksh/shf.c
226
if (close(shf->fd) == -1)
bin/ksh/shf.c
229
if (shf->flags & SHF_ALLOCS)
bin/ksh/shf.c
230
afree(shf, shf->areap);
bin/ksh/shf.c
231
else if (shf->flags & SHF_ALLOCB)
bin/ksh/shf.c
232
afree(shf->buf, shf->areap);
bin/ksh/shf.c
239
shf_fdclose(struct shf *shf)
bin/ksh/shf.c
243
if (shf->fd >= 0) {
bin/ksh/shf.c
244
ret = shf_flush(shf);
bin/ksh/shf.c
245
if (close(shf->fd) == -1)
bin/ksh/shf.c
247
shf->rnleft = 0;
bin/ksh/shf.c
248
shf->rp = shf->buf;
bin/ksh/shf.c
249
shf->wnleft = 0;
bin/ksh/shf.c
250
shf->fd = -1;
bin/ksh/shf.c
261
shf_sclose(struct shf *shf)
bin/ksh/shf.c
263
unsigned char *s = shf->buf;
bin/ksh/shf.c
266
if (shf->flags & SHF_WR) {
bin/ksh/shf.c
267
shf->wnleft++;
bin/ksh/shf.c
268
shf_putc('\0', shf);
bin/ksh/shf.c
270
if (shf->flags & SHF_ALLOCS)
bin/ksh/shf.c
271
afree(shf, shf->areap);
bin/ksh/shf.c
279
shf_flush(struct shf *shf)
bin/ksh/shf.c
281
if (shf->flags & SHF_STRING)
bin/ksh/shf.c
282
return (shf->flags & SHF_WR) ? EOF : 0;
bin/ksh/shf.c
284
if (shf->fd < 0)
bin/ksh/shf.c
287
if (shf->flags & SHF_ERROR) {
bin/ksh/shf.c
288
errno = shf->errno_;
bin/ksh/shf.c
29
static int shf_fillbuf(struct shf *);
bin/ksh/shf.c
292
if (shf->flags & SHF_READING) {
bin/ksh/shf.c
293
shf->flags &= ~(SHF_EOF | SHF_READING);
bin/ksh/shf.c
294
if (shf->rnleft > 0) {
bin/ksh/shf.c
295
lseek(shf->fd, (off_t) -shf->rnleft, SEEK_CUR);
bin/ksh/shf.c
296
shf->rnleft = 0;
bin/ksh/shf.c
297
shf->rp = shf->buf;
bin/ksh/shf.c
30
static int shf_emptybuf(struct shf *, int);
bin/ksh/shf.c
300
} else if (shf->flags & SHF_WRITING)
bin/ksh/shf.c
301
return shf_emptybuf(shf, 0);
bin/ksh/shf.c
310
shf_emptybuf(struct shf *shf, int flags)
bin/ksh/shf.c
314
if (!(shf->flags & SHF_STRING) && shf->fd < 0)
bin/ksh/shf.c
317
if (shf->flags & SHF_ERROR) {
bin/ksh/shf.c
318
errno = shf->errno_;
bin/ksh/shf.c
322
if (shf->flags & SHF_READING) {
bin/ksh/shf.c
325
ret = shf_flush(shf);
bin/ksh/shf.c
326
shf->flags &= ~SHF_READING;
bin/ksh/shf.c
328
if (shf->flags & SHF_STRING) {
bin/ksh/shf.c
334
if (!(flags & EB_GROW) || !(shf->flags & SHF_DYNAMIC) ||
bin/ksh/shf.c
335
!(shf->flags & SHF_ALLOCB))
bin/ksh/shf.c
338
nbuf = areallocarray(shf->buf, 2, shf->wbsize, shf->areap);
bin/ksh/shf.c
339
shf->rp = nbuf + (shf->rp - shf->buf);
bin/ksh/shf.c
340
shf->wp = nbuf + (shf->wp - shf->buf);
bin/ksh/shf.c
341
shf->rbsize += shf->wbsize;
bin/ksh/shf.c
342
shf->wnleft += shf->wbsize;
bin/ksh/shf.c
343
shf->wbsize *= 2;
bin/ksh/shf.c
344
shf->buf = nbuf;
bin/ksh/shf.c
346
if (shf->flags & SHF_WRITING) {
bin/ksh/shf.c
347
int ntowrite = shf->wp - shf->buf;
bin/ksh/shf.c
348
unsigned char *buf = shf->buf;
bin/ksh/shf.c
352
n = write(shf->fd, buf, ntowrite);
bin/ksh/shf.c
355
!(shf->flags & SHF_INTERRUPT))
bin/ksh/shf.c
357
shf->flags |= SHF_ERROR;
bin/ksh/shf.c
358
shf->errno_ = errno;
bin/ksh/shf.c
359
shf->wnleft = 0;
bin/ksh/shf.c
36
struct shf *
bin/ksh/shf.c
360
if (buf != shf->buf) {
bin/ksh/shf.c
363
memmove(shf->buf, buf,
bin/ksh/shf.c
365
shf->wp = shf->buf + ntowrite;
bin/ksh/shf.c
373
shf->wp = shf->buf;
bin/ksh/shf.c
374
shf->wnleft = 0;
bin/ksh/shf.c
375
shf->flags &= ~SHF_WRITING;
bin/ksh/shf.c
379
shf->wp = shf->buf;
bin/ksh/shf.c
380
shf->wnleft = shf->wbsize;
bin/ksh/shf.c
382
shf->flags |= SHF_WRITING;
bin/ksh/shf.c
389
shf_fillbuf(struct shf *shf)
bin/ksh/shf.c
39
struct shf *shf;
bin/ksh/shf.c
391
if (shf->flags & SHF_STRING)
bin/ksh/shf.c
394
if (shf->fd < 0)
bin/ksh/shf.c
397
if (shf->flags & (SHF_EOF | SHF_ERROR)) {
bin/ksh/shf.c
398
if (shf->flags & SHF_ERROR)
bin/ksh/shf.c
399
errno = shf->errno_;
bin/ksh/shf.c
403
if ((shf->flags & SHF_WRITING) && shf_emptybuf(shf, EB_READSW) == EOF)
bin/ksh/shf.c
406
shf->flags |= SHF_READING;
bin/ksh/shf.c
408
shf->rp = shf->buf;
bin/ksh/shf.c
410
shf->rnleft = blocking_read(shf->fd, (char *) shf->buf,
bin/ksh/shf.c
411
shf->rbsize);
bin/ksh/shf.c
412
if (shf->rnleft < 0 && errno == EINTR &&
bin/ksh/shf.c
413
!(shf->flags & SHF_INTERRUPT))
bin/ksh/shf.c
417
if (shf->rnleft <= 0) {
bin/ksh/shf.c
418
if (shf->rnleft < 0) {
bin/ksh/shf.c
419
shf->flags |= SHF_ERROR;
bin/ksh/shf.c
420
shf->errno_ = errno;
bin/ksh/shf.c
421
shf->rnleft = 0;
bin/ksh/shf.c
422
shf->rp = shf->buf;
bin/ksh/shf.c
425
shf->flags |= SHF_EOF;
bin/ksh/shf.c
435
shf_read(char *buf, int bsize, struct shf *shf)
bin/ksh/shf.c
44
shf = alloc(sizeof(struct shf) + bsize, ATEMP);
bin/ksh/shf.c
440
if (!(shf->flags & SHF_RD))
bin/ksh/shf.c
441
internal_errorf("%s: flags %x", __func__, shf->flags);
bin/ksh/shf.c
447
if (shf->rnleft == 0 &&
bin/ksh/shf.c
448
(shf_fillbuf(shf) == EOF || shf->rnleft == 0))
bin/ksh/shf.c
45
shf->areap = ATEMP;
bin/ksh/shf.c
450
ncopy = shf->rnleft;
bin/ksh/shf.c
453
if (memchr((char *)shf->rp, '\0', ncopy) != NULL) {
bin/ksh/shf.c
457
memcpy(buf, shf->rp, ncopy);
bin/ksh/shf.c
46
shf->buf = (unsigned char *) &shf[1];
bin/ksh/shf.c
460
shf->rp += ncopy;
bin/ksh/shf.c
461
shf->rnleft -= ncopy;
bin/ksh/shf.c
464
return orig_bsize == bsize ? (shf_error(shf) ? EOF : 0) :
bin/ksh/shf.c
47
shf->bsize = bsize;
bin/ksh/shf.c
473
shf_getse(char *buf, int bsize, struct shf *shf)
bin/ksh/shf.c
479
if (!(shf->flags & SHF_RD))
bin/ksh/shf.c
48
shf->flags = SHF_ALLOCS;
bin/ksh/shf.c
480
internal_errorf("%s: flags %x", __func__, shf->flags);
bin/ksh/shf.c
487
if (shf->rnleft == 0) {
bin/ksh/shf.c
488
if (shf_fillbuf(shf) == EOF)
bin/ksh/shf.c
490
if (shf->rnleft == 0) {
bin/ksh/shf.c
495
end = (unsigned char *) memchr((char *) shf->rp, '\n',
bin/ksh/shf.c
496
shf->rnleft);
bin/ksh/shf.c
497
ncopy = end ? end - shf->rp + 1 : shf->rnleft;
bin/ksh/shf.c
500
if (memchr((char *)shf->rp, '\0', ncopy) != NULL) {
bin/ksh/shf.c
504
memcpy(buf, (char *) shf->rp, ncopy);
bin/ksh/shf.c
505
shf->rp += ncopy;
bin/ksh/shf.c
506
shf->rnleft -= ncopy;
bin/ksh/shf.c
516
shf_getchar(struct shf *shf)
bin/ksh/shf.c
518
if (!(shf->flags & SHF_RD))
bin/ksh/shf.c
519
internal_errorf("%s: flags %x", __func__, shf->flags);
bin/ksh/shf.c
521
if (shf->rnleft == 0 && (shf_fillbuf(shf) == EOF || shf->rnleft == 0))
bin/ksh/shf.c
523
--shf->rnleft;
bin/ksh/shf.c
524
return *shf->rp++;
bin/ksh/shf.c
53
afree(shf, shf->areap);
bin/ksh/shf.c
531
shf_ungetc(int c, struct shf *shf)
bin/ksh/shf.c
533
if (!(shf->flags & SHF_RD))
bin/ksh/shf.c
534
internal_errorf("%s: flags %x", __func__, shf->flags);
bin/ksh/shf.c
536
if ((shf->flags & SHF_ERROR) || c == EOF ||
bin/ksh/shf.c
537
(shf->rp == shf->buf && shf->rnleft))
bin/ksh/shf.c
540
if ((shf->flags & SHF_WRITING) && shf_emptybuf(shf, EB_READSW) == EOF)
bin/ksh/shf.c
543
if (shf->rp == shf->buf)
bin/ksh/shf.c
544
shf->rp = shf->buf + shf->rbsize;
bin/ksh/shf.c
545
if (shf->flags & SHF_STRING) {
bin/ksh/shf.c
549
if (shf->rp[-1] != c)
bin/ksh/shf.c
551
shf->flags &= ~SHF_EOF;
bin/ksh/shf.c
552
shf->rp--;
bin/ksh/shf.c
553
shf->rnleft++;
bin/ksh/shf.c
556
shf->flags &= ~SHF_EOF;
bin/ksh/shf.c
557
*--(shf->rp) = c;
bin/ksh/shf.c
558
shf->rnleft++;
bin/ksh/shf.c
566
shf_putchar(int c, struct shf *shf)
bin/ksh/shf.c
568
if (!(shf->flags & SHF_WR))
bin/ksh/shf.c
569
internal_errorf("%s: flags %x", __func__, shf->flags);
bin/ksh/shf.c
574
if (shf->flags & SHF_UNBUF) {
bin/ksh/shf.c
578
if (shf->fd < 0)
bin/ksh/shf.c
580
if (shf->flags & SHF_ERROR) {
bin/ksh/shf.c
581
errno = shf->errno_;
bin/ksh/shf.c
584
while ((n = write(shf->fd, &cc, 1)) != 1)
bin/ksh/shf.c
587
!(shf->flags & SHF_INTERRUPT))
bin/ksh/shf.c
589
shf->flags |= SHF_ERROR;
bin/ksh/shf.c
590
shf->errno_ = errno;
bin/ksh/shf.c
595
if (shf->wnleft == 0 && shf_emptybuf(shf, EB_GROW) == EOF)
bin/ksh/shf.c
597
shf->wnleft--;
bin/ksh/shf.c
598
*shf->wp++ = c;
bin/ksh/shf.c
608
shf_puts(const char *s, struct shf *shf)
bin/ksh/shf.c
613
return shf_write(s, strlen(s), shf);
bin/ksh/shf.c
618
shf_write(const char *buf, int nbytes, struct shf *shf)
bin/ksh/shf.c
62
afree(shf, shf->areap);
bin/ksh/shf.c
624
if (!(shf->flags & SHF_WR))
bin/ksh/shf.c
625
internal_errorf("%s: flags %x", __func__, shf->flags);
bin/ksh/shf.c
631
if ((ncopy = shf->wnleft) &&
bin/ksh/shf.c
632
(shf->wp != shf->buf || nbytes < shf->wnleft)) {
bin/ksh/shf.c
635
memcpy(shf->wp, buf, ncopy);
bin/ksh/shf.c
638
shf->wp += ncopy;
bin/ksh/shf.c
639
shf->wnleft -= ncopy;
bin/ksh/shf.c
643
if (shf_emptybuf(shf, EB_GROW) == EOF)
bin/ksh/shf.c
645
if (nbytes > shf->wbsize) {
bin/ksh/shf.c
647
if (shf->wbsize)
bin/ksh/shf.c
648
ncopy -= nbytes % shf->wbsize;
bin/ksh/shf.c
651
n = write(shf->fd, buf, ncopy);
bin/ksh/shf.c
654
!(shf->flags & SHF_INTERRUPT))
bin/ksh/shf.c
656
shf->flags |= SHF_ERROR;
bin/ksh/shf.c
657
shf->errno_ = errno;
bin/ksh/shf.c
658
shf->wnleft = 0;
bin/ksh/shf.c
668
memcpy(shf->wp, buf, nbytes);
bin/ksh/shf.c
669
shf->wp += nbytes;
bin/ksh/shf.c
670
shf->wnleft -= nbytes;
bin/ksh/shf.c
678
shf_fprintf(struct shf *shf, const char *fmt, ...)
bin/ksh/shf.c
684
n = shf_vfprintf(shf, fmt, args);
bin/ksh/shf.c
693
struct shf shf;
bin/ksh/shf.c
701
shf_sopen(buf, bsize, SHF_WR, &shf);
bin/ksh/shf.c
703
n = shf_vfprintf(&shf, fmt, args);
bin/ksh/shf.c
705
shf_sclose(&shf); /* null terminates */
bin/ksh/shf.c
71
return shf_reopen(fd, sflags, shf);
bin/ksh/shf.c
712
struct shf shf;
bin/ksh/shf.c
715
shf_sopen(NULL, 0, SHF_WR|SHF_DYNAMIC, &shf);
bin/ksh/shf.c
717
shf_vfprintf(&shf, fmt, args);
bin/ksh/shf.c
719
return shf_sclose(&shf); /* null terminates */
bin/ksh/shf.c
735
shf_vfprintf(struct shf *shf, const char *fmt, va_list args)
bin/ksh/shf.c
75
struct shf *
bin/ksh/shf.c
753
shf_putc(c, shf);
bin/ksh/shf.c
76
shf_fdopen(int fd, int sflags, struct shf *shf)
bin/ksh/shf.c
964
shf_putc(*s, shf);
bin/ksh/shf.c
969
shf_putc(*s, shf);
bin/ksh/shf.c
974
shf_putc(*s, shf);
bin/ksh/shf.c
986
shf_putc(c, shf);
bin/ksh/shf.c
996
shf_putc(*s, shf);
bin/ksh/shf.h
12
#define shf_getc(shf) ((shf)->rnleft > 0 ? (shf)->rnleft--, *(shf)->rp++ : \
bin/ksh/shf.h
13
shf_getchar(shf))
bin/ksh/shf.h
14
#define shf_putc(c, shf) ((shf)->wnleft == 0 ? shf_putchar((c), (shf)) : \
bin/ksh/shf.h
15
((shf)->wnleft--, *(shf)->wp++ = (c)))
bin/ksh/shf.h
16
#define shf_eof(shf) ((shf)->flags & SHF_EOF)
bin/ksh/shf.h
17
#define shf_error(shf) ((shf)->flags & SHF_ERROR)
bin/ksh/shf.h
18
#define shf_clearerr(shf) ((shf)->flags &= ~(SHF_EOF | SHF_ERROR))
bin/ksh/shf.h
57
extern struct shf shf_iob[];
bin/ksh/shf.h
59
struct shf *shf_open(const char *, int, int, int);
bin/ksh/shf.h
60
struct shf *shf_fdopen(int, int, struct shf *);
bin/ksh/shf.h
61
struct shf *shf_reopen(int, int, struct shf *);
bin/ksh/shf.h
62
struct shf *shf_sopen(char *, int, int, struct shf *);
bin/ksh/shf.h
63
int shf_close(struct shf *);
bin/ksh/shf.h
64
int shf_fdclose(struct shf *);
bin/ksh/shf.h
65
char *shf_sclose(struct shf *);
bin/ksh/shf.h
66
int shf_flush(struct shf *);
bin/ksh/shf.h
67
int shf_read(char *, int, struct shf *);
bin/ksh/shf.h
68
char *shf_getse(char *, int, struct shf *);
bin/ksh/shf.h
69
int shf_getchar(struct shf *s);
bin/ksh/shf.h
70
int shf_ungetc(int, struct shf *);
bin/ksh/shf.h
71
int shf_putchar(int, struct shf *);
bin/ksh/shf.h
72
int shf_puts(const char *, struct shf *);
bin/ksh/shf.h
73
int shf_write(const char *, int, struct shf *);
bin/ksh/shf.h
74
int shf_fprintf(struct shf *, const char *, ...);
bin/ksh/shf.h
77
int shf_vfprintf(struct shf *, const char *, va_list);
bin/ksh/tree.c
100
fptreef(shf, indent, "%N(");
bin/ksh/tree.c
102
fptreef(shf, indent, "%S%c", *w,
bin/ksh/tree.c
104
fptreef(shf, indent + INDENT, "%;%T%N;;", t1->left);
bin/ksh/tree.c
106
fptreef(shf, indent, "%Nesac ");
bin/ksh/tree.c
111
fptreef(shf, indent + 3, "if %T", t->left);
bin/ksh/tree.c
115
fptreef(shf, indent, "%;");
bin/ksh/tree.c
116
fptreef(shf, indent + INDENT, "then%N%T",
bin/ksh/tree.c
122
fptreef(shf, indent, "%;");
bin/ksh/tree.c
124
fptreef(shf, indent + 5, "elif %T", t->left);
bin/ksh/tree.c
127
fptreef(shf, indent, "%;");
bin/ksh/tree.c
128
fptreef(shf, indent + INDENT, "else%;%T", t->right);
bin/ksh/tree.c
13
#define tputc(c, shf) shf_putchar(c, shf);
bin/ksh/tree.c
130
fptreef(shf, indent, "%;fi ");
bin/ksh/tree.c
135
fptreef(shf, indent + 6, "%s %T",
bin/ksh/tree.c
138
fptreef(shf, indent, "%;do");
bin/ksh/tree.c
139
fptreef(shf, indent + INDENT, "%;%T", t->right);
bin/ksh/tree.c
14
static void ptree(struct op *, int, struct shf *);
bin/ksh/tree.c
140
fptreef(shf, indent, "%;done ");
bin/ksh/tree.c
143
fptreef(shf, indent + INDENT, "{%;%T", t->left);
bin/ksh/tree.c
144
fptreef(shf, indent, "%;} ");
bin/ksh/tree.c
147
fptreef(shf, indent, "%T|& ", t->left);
bin/ksh/tree.c
15
static void pioact(struct shf *, int, struct ioword *);
bin/ksh/tree.c
150
fptreef(shf, indent, "%T& ", t->left);
bin/ksh/tree.c
153
fptreef(shf, indent,
bin/ksh/tree.c
158
fptreef(shf, indent, "time %T", t->left);
bin/ksh/tree.c
16
static void tputC(int, struct shf *);
bin/ksh/tree.c
161
fptreef(shf, indent, "<botch>");
bin/ksh/tree.c
168
pioact(shf, indent, *ioact++);
bin/ksh/tree.c
17
static void tputS(char *, struct shf *);
bin/ksh/tree.c
175
tputc('\n', shf);
bin/ksh/tree.c
176
shf_puts(iop->heredoc, shf);
bin/ksh/tree.c
177
fptreef(shf, indent, "%s",
bin/ksh/tree.c
18
static void vfptreef(struct shf *, int, const char *, va_list);
bin/ksh/tree.c
187
tputc('\n', shf);
bin/ksh/tree.c
192
pioact(struct shf *shf, int indent, struct ioword *iop)
bin/ksh/tree.c
203
tputc('0' + iop->unit, shf);
bin/ksh/tree.c
207
fptreef(shf, indent, "< ");
bin/ksh/tree.c
211
fptreef(shf, indent, "<<- ");
bin/ksh/tree.c
213
fptreef(shf, indent, "<< ");
bin/ksh/tree.c
216
fptreef(shf, indent, ">> ");
bin/ksh/tree.c
220
fptreef(shf, indent, ">| ");
bin/ksh/tree.c
222
fptreef(shf, indent, "> ");
bin/ksh/tree.c
225
fptreef(shf, indent, "<> ");
bin/ksh/tree.c
229
fptreef(shf, indent, "<&");
bin/ksh/tree.c
231
fptreef(shf, indent, ">&");
bin/ksh/tree.c
237
fptreef(shf, indent, "%S ", iop->delim);
bin/ksh/tree.c
239
fptreef(shf, indent, (iop->flag & IONAMEXP) ? "%s " : "%S ",
bin/ksh/tree.c
249
tputC(int c, struct shf *shf)
bin/ksh/tree.c
252
tputc((c&0x80) ? '$' : '^', shf);
bin/ksh/tree.c
253
tputc(((c&0x7F)|0x40), shf);
bin/ksh/tree.c
255
tputc((c&0x80) ? '$' : '^', shf);
bin/ksh/tree.c
256
tputc('?', shf);
bin/ksh/tree.c
258
tputc(c, shf);
bin/ksh/tree.c
262
tputS(char *wp, struct shf *shf)
bin/ksh/tree.c
27
ptree(struct op *t, int indent, struct shf *shf)
bin/ksh/tree.c
278
tputC(*wp++, shf);
bin/ksh/tree.c
283
tputc('\\', shf);
bin/ksh/tree.c
284
tputC(c, shf);
bin/ksh/tree.c
287
tputc('$', shf);
bin/ksh/tree.c
288
tputc('(', shf);
bin/ksh/tree.c
290
tputC(*wp++, shf);
bin/ksh/tree.c
291
tputc(')', shf);
bin/ksh/tree.c
295
tputc('$', shf);
bin/ksh/tree.c
296
tputc('(', shf);
bin/ksh/tree.c
297
tputc('(', shf);
bin/ksh/tree.c
299
tputC(*wp++, shf);
bin/ksh/tree.c
300
tputc(')', shf);
bin/ksh/tree.c
301
tputc(')', shf);
bin/ksh/tree.c
306
tputc('"', shf);
bin/ksh/tree.c
310
tputc('"', shf);
bin/ksh/tree.c
313
tputc('$', shf);
bin/ksh/tree.c
315
tputc('{', shf);
bin/ksh/tree.c
317
tputC(c, shf);
bin/ksh/tree.c
321
tputc('}', shf);
bin/ksh/tree.c
324
tputc(*wp++, shf);
bin/ksh/tree.c
325
tputc('(', shf);
bin/ksh/tree.c
328
tputc('|', shf);
bin/ksh/tree.c
331
tputc(')', shf);
bin/ksh/tree.c
337
fptreef(struct shf *shf, int indent, const char *fmt, ...)
bin/ksh/tree.c
342
vfptreef(shf, indent, fmt, va);
bin/ksh/tree.c
350
struct shf shf;
bin/ksh/tree.c
352
shf_sopen(s, n, SHF_WR | (s ? 0 : SHF_DYNAMIC), &shf);
bin/ksh/tree.c
355
vfptreef(&shf, 0, fmt, va);
bin/ksh/tree.c
358
return shf_sclose(&shf); /* null terminates */
bin/ksh/tree.c
362
vfptreef(struct shf *shf, int indent, const char *fmt, va_list va)
bin/ksh/tree.c
374
tputc(va_arg(va, int), shf);
bin/ksh/tree.c
383
tputc(*p++, shf);
bin/ksh/tree.c
388
tputc(*p++, shf);
bin/ksh/tree.c
392
tputS(p, shf);
bin/ksh/tree.c
397
tputc(*p++, shf);
bin/ksh/tree.c
40
fptreef(shf, indent, "%S ", *w++);
bin/ksh/tree.c
400
ptree(va_arg(va, struct op *), indent, shf);
bin/ksh/tree.c
404
if (shf->flags & SHF_STRING) {
bin/ksh/tree.c
406
tputc(';', shf);
bin/ksh/tree.c
407
tputc(' ', shf);
bin/ksh/tree.c
411
tputc('\n', shf);
bin/ksh/tree.c
413
tputc('\t', shf);
bin/ksh/tree.c
415
tputc(' ', shf);
bin/ksh/tree.c
419
pioact(shf, indent, va_arg(va, struct ioword *));
bin/ksh/tree.c
42
fptreef(shf, indent, "#no-vars# ");
bin/ksh/tree.c
422
tputc(c, shf);
bin/ksh/tree.c
426
tputc(c, shf);
bin/ksh/tree.c
45
fptreef(shf, indent, "%S ", *w++);
bin/ksh/tree.c
47
fptreef(shf, indent, "#no-args# ");
bin/ksh/tree.c
53
fptreef(shf, indent + 2, "( %T) ", t->left);
bin/ksh/tree.c
548
struct shf shf;
bin/ksh/tree.c
551
shf_sopen(NULL, 32, SHF_WR | SHF_DYNAMIC, &shf);
bin/ksh/tree.c
56
fptreef(shf, indent, "%T| ", t->left);
bin/ksh/tree.c
561
return shf_sclose(&shf); /* null terminates */
bin/ksh/tree.c
564
shf_putchar(*wp++, &shf);
bin/ksh/tree.c
567
shf_putchar('$', &shf);
bin/ksh/tree.c
568
shf_putchar('(', &shf);
bin/ksh/tree.c
570
shf_putchar(*wp++, &shf);
bin/ksh/tree.c
571
shf_putchar(')', &shf);
bin/ksh/tree.c
574
shf_putchar('$', &shf);
bin/ksh/tree.c
575
shf_putchar('(', &shf);
bin/ksh/tree.c
576
shf_putchar('(', &shf);
bin/ksh/tree.c
578
shf_putchar(*wp++, &shf);
bin/ksh/tree.c
579
shf_putchar(')', &shf);
bin/ksh/tree.c
580
shf_putchar(')', &shf);
bin/ksh/tree.c
587
shf_putchar('$', &shf);
bin/ksh/tree.c
589
shf_putchar('{', &shf);
bin/ksh/tree.c
591
shf_putchar(c, &shf);
bin/ksh/tree.c
595
shf_putchar('}', &shf);
bin/ksh/tree.c
598
shf_putchar(*wp++, &shf);
bin/ksh/tree.c
599
shf_putchar('(', &shf);
bin/ksh/tree.c
60
fptreef(shf, indent, "%T%;", t->left);
bin/ksh/tree.c
602
shf_putchar('|', &shf);
bin/ksh/tree.c
605
shf_putchar(')', &shf);
bin/ksh/tree.c
65
fptreef(shf, indent, "%T%s %T",
bin/ksh/tree.c
69
fptreef(shf, indent, "! ");
bin/ksh/tree.c
76
fptreef(shf, indent, "[[");
bin/ksh/tree.c
78
fptreef(shf, indent, " %S", t->args[i]);
bin/ksh/tree.c
79
fptreef(shf, indent, " ]] ");
bin/ksh/tree.c
83
fptreef(shf, indent, "select %s ", t->str);
bin/ksh/tree.c
87
fptreef(shf, indent, "for %s ", t->str);
bin/ksh/tree.c
89
fptreef(shf, indent, "in ");
bin/ksh/tree.c
91
fptreef(shf, indent, "%S ", *w++);
bin/ksh/tree.c
92
fptreef(shf, indent, "%;");
bin/ksh/tree.c
94
fptreef(shf, indent + INDENT, "do%N%T", t->left);
bin/ksh/tree.c
95
fptreef(shf, indent, "%;done ");
bin/ksh/tree.c
98
fptreef(shf, indent, "case %S in", t->str);
bin/ksh/tree.h
139
void fptreef(struct shf *, int, const char *, ...);