Symbol: shf
bin/ksh/c_sh.c
254
struct shf *shf;
bin/ksh/c_sh.c
297
shf = shf_reopen(fd, SHF_RD | SHF_INTERRUPT | can_seek(fd), shl_spare);
bin/ksh/c_sh.c
333
c = shf_getc(shf);
bin/ksh/c_sh.c
337
if (c == EOF && shf_error(shf)
bin/ksh/c_sh.c
338
&& shf_errno(shf) == EINTR)
bin/ksh/c_sh.c
348
shf_clearerr(shf);
bin/ksh/c_sh.c
397
shf_flush(shf);
bin/ksh/c_sh.c
404
shf_flush(shf);
bin/ksh/c_sh.c
409
shf_flush(shf);
bin/ksh/eval.c
32
struct shf *shf;/* file */
bin/ksh/eval.c
530
while ((c = shf_getc(x.u.shf)) == 0 || c == '\n')
bin/ksh/eval.c
534
shf_ungetc(c, x.u.shf);
bin/ksh/eval.c
541
shf_close(x.u.shf);
bin/ksh/eval.c
854
struct shf *shf;
bin/ksh/eval.c
874
shf = shf_open(name = evalstr(io->name, DOTILDE), O_RDONLY, 0,
bin/ksh/eval.c
876
if (shf == NULL)
bin/ksh/eval.c
882
shf = shf_fdopen(pv[0], SHF_RD, (struct shf *) 0);
bin/ksh/eval.c
894
xp->u.shf = shf;
bin/ksh/exec.c
1262
struct shf *volatile shf;
bin/ksh/exec.c
1276
if (!(shf = h->shf) || (fd = open(h->name, O_RDONLY, 0)) < 0) {
bin/ksh/exec.c
1278
!shf ? "create" : "open",
bin/ksh/exec.c
1280
if (shf)
bin/ksh/exec.c
1281
shf_close(shf);
bin/ksh/exec.c
1291
shf_close(shf); /* after quitenv */
bin/ksh/exec.c
1303
shf_puts(evalstr(yylval.cp, 0), shf);
bin/ksh/exec.c
1305
shf_puts(content, shf);
bin/ksh/exec.c
1309
if (shf_close(shf) == EOF) {
bin/ksh/history.c
236
if (!(shf = tf->shf)) {
bin/ksh/history.c
243
shf_fprintf(shf, "%s\n", *hp);
bin/ksh/history.c
244
if (shf_close(shf) == EOF) {
bin/ksh/history.c
269
if (!(shf = shf_open(tf->name, O_RDONLY, 0, 0))) {
bin/ksh/history.c
274
n = fstat(shf_fileno(shf), &statb) < 0 ? 128
bin/ksh/history.c
277
while ((n = shf_read(xp, Xnleft(xs, xp), shf)) > 0) {
bin/ksh/history.c
284
tf->name, strerror(shf_errno(shf)));
bin/ksh/history.c
285
shf_close(shf);
bin/ksh/history.c
288
shf_close(shf);
bin/ksh/history.c
82
struct shf *shf;
bin/ksh/io.c
150
static struct shf *kshdebug_shf;
bin/ksh/io.c
217
struct shf shf_iob[3];
bin/ksh/io.c
463
tp->shf = (struct shf *) 0;
bin/ksh/io.c
469
tp->shf = shf_fdopen(fd, SHF_WR, (struct shf *) 0);
bin/ksh/io.c
480
tp->shf = shf_fdopen(fd, SHF_WR, (struct shf *) 0);
bin/ksh/jobs.c
1431
j_print(j, how, shf)
bin/ksh/jobs.c
1434
struct shf *shf;
bin/ksh/jobs.c
1450
shf_fprintf(shf, "%d\n", j->pgrp ? j->pgrp
bin/ksh/jobs.c
1498
shf_fprintf(shf, "[%d] %c ", j->job, jobchar);
bin/ksh/jobs.c
1500
shf_fprintf(shf, "%s", filler);
bin/ksh/jobs.c
1504
shf_fprintf(shf, "%5d ", p->pid);
bin/ksh/jobs.c
1509
shf_fprintf(shf, "%s%s ",
bin/ksh/jobs.c
1514
shf_fprintf(shf, "%-20s %s%s%s", buf, p->command,
bin/ksh/jobs.c
1525
shf_fprintf(shf, "%s%5d %-20s %s%s", filler, p->pid,
bin/ksh/jobs.c
1528
shf_fprintf(shf, " %s%s", p->command,
bin/ksh/jobs.c
1534
shf_fprintf(shf, newline);
bin/ksh/jobs.c
189
static struct shf *shl_j;
bin/ksh/jobs.c
216
static void j_print ARGS((Job *j, int how, struct shf *shf));
bin/ksh/jobs.c
248
shl_j = shf_fdopen(2, SHF_WR, (struct shf *) 0);
bin/ksh/lex.c
1031
char *p = shf_getse(xp, Xnleft(s->xs, xp), s->u.shf);
bin/ksh/lex.c
1033
if (!p && shf_error(s->u.shf)
bin/ksh/lex.c
1034
&& shf_errno(s->u.shf) == EINTR)
bin/ksh/lex.c
1036
shf_clearerr(s->u.shf);
bin/ksh/lex.c
1055
shf_flush(s->u.shf);
bin/ksh/lex.c
1073
shf_fdclose(s->u.shf);
bin/ksh/lex.c
1114
struct shf *shf;
bin/ksh/lex.c
1119
shf = shf_sopen((char *) 0, strlen(ps1) * 2,
bin/ksh/lex.c
1120
SHF_WR | SHF_DYNAMIC, (struct shf *) 0);
bin/ksh/lex.c
1123
shf_putchar(*ps1++, shf);
bin/ksh/lex.c
1125
shf_fprintf(shf, "%d",
bin/ksh/lex.c
1128
ps1 = shf_sclose(shf);
bin/ksh/lex.h
18
struct shf *shf; /* shell file */
bin/ksh/main.c
298
s->u.shf = shf_open(s->file, O_RDONLY, 0, SHF_MAPHI|SHF_CLEXEC);
bin/ksh/main.c
299
if (s->u.shf == NULL) {
bin/ksh/main.c
308
s->u.shf = shf_fdopen(0, SHF_RD | can_seek(0),
bin/ksh/main.c
309
(struct shf *) 0);
bin/ksh/main.c
314
s->u.shf->flags |= SHF_INTERRUPT;
bin/ksh/main.c
425
struct shf *shf;
bin/ksh/main.c
430
shf = shf_open(name, O_RDONLY, 0, SHF_MAPHI|SHF_CLEXEC);
bin/ksh/main.c
431
if (shf == NULL)
bin/ksh/main.c
445
shf_close(s->u.shf);
bin/ksh/main.c
477
s->u.shf = shf;
bin/ksh/main.c
480
shf_close(s->u.shf);
bin/ksh/misc.c
1112
print_columns(shf, n, func, arg, max_width, prefcol)
bin/ksh/misc.c
1113
struct shf *shf;
bin/ksh/misc.c
1150
shf_fprintf(shf, "%-*s",
bin/ksh/misc.c
1154
shf_fprintf(shf, "%*s", nspace, null);
bin/ksh/misc.c
1157
shf_putchar('\n', shf);
bin/ksh/proto.h
199
void print_columns ARGS((struct shf *, int,
bin/ksh/proto.h
246
int fptreef ARGS((struct shf *, int, const char *, ...));
bin/ksh/sh.h
340
struct shf *shf;
bin/ksh/shf.c
105
if (shf) {
bin/ksh/shf.c
107
shf->buf = (unsigned char *) alloc(bsize, ATEMP);
bin/ksh/shf.c
110
shf->buf = (unsigned char *) 0;
bin/ksh/shf.c
112
shf = (struct 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
1232
shf_putc(*s, shf);
bin/ksh/shf.c
1237
shf_putc(*s, shf);
bin/ksh/shf.c
124
shf->errno_ = 0;
bin/ksh/shf.c
1243
shf_putc(*s, shf);
bin/ksh/shf.c
125
shf->bsize = bsize;
bin/ksh/shf.c
1255
shf_putc(c, shf);
bin/ksh/shf.c
1265
shf_putc(*s, shf);
bin/ksh/shf.c
1270
shf_putc(c, shf);
bin/ksh/shf.c
1274
return shf_error(shf) ? EOF : nwritten;
bin/ksh/shf.c
128
return shf;
bin/ksh/shf.c
132
struct shf *
bin/ksh/shf.c
133
shf_reopen(fd, sflags, shf)
bin/ksh/shf.c
136
struct shf *shf;
bin/ksh/shf.c
157
if (!shf || !shf->buf || shf->bsize < bsize)
bin/ksh/shf.c
161
shf->fd = fd;
bin/ksh/shf.c
162
shf->rp = shf->wp = shf->buf;
bin/ksh/shf.c
163
shf->rnleft = 0;
bin/ksh/shf.c
164
shf->rbsize = bsize;
bin/ksh/shf.c
165
shf->wnleft = 0; /* force call to shf_emptybuf() */
bin/ksh/shf.c
166
shf->wbsize = sflags & SHF_UNBUF ? 0 : bsize;
bin/ksh/shf.c
167
shf->flags = (shf->flags & (SHF_ALLOCS | SHF_ALLOCB)) | sflags;
bin/ksh/shf.c
168
shf->errno_ = 0;
bin/ksh/shf.c
171
return shf;
bin/ksh/shf.c
182
struct shf *
bin/ksh/shf.c
183
shf_sopen(buf, bsize, sflags, shf)
bin/ksh/shf.c
187
struct shf *shf;
bin/ksh/shf.c
194
if (!shf) {
bin/ksh/shf.c
195
shf = (struct 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(shf)
bin/ksh/shf.c
221
struct shf *shf;
bin/ksh/shf.c
225
if (shf->fd >= 0) {
bin/ksh/shf.c
226
ret = shf_flush(shf);
bin/ksh/shf.c
227
if (close(shf->fd) < 0)
bin/ksh/shf.c
230
if (shf->flags & SHF_ALLOCS)
bin/ksh/shf.c
231
afree(shf, shf->areap);
bin/ksh/shf.c
232
else if (shf->flags & SHF_ALLOCB)
bin/ksh/shf.c
233
afree(shf->buf, shf->areap);
bin/ksh/shf.c
240
shf_fdclose(shf)
bin/ksh/shf.c
241
struct shf *shf;
bin/ksh/shf.c
245
if (shf->fd >= 0) {
bin/ksh/shf.c
246
ret = shf_flush(shf);
bin/ksh/shf.c
247
if (close(shf->fd) < 0)
bin/ksh/shf.c
249
shf->rnleft = 0;
bin/ksh/shf.c
250
shf->rp = shf->buf;
bin/ksh/shf.c
251
shf->wnleft = 0;
bin/ksh/shf.c
252
shf->fd = -1;
bin/ksh/shf.c
263
shf_sclose(shf)
bin/ksh/shf.c
264
struct shf *shf;
bin/ksh/shf.c
266
unsigned char *s = shf->buf;
bin/ksh/shf.c
269
if (shf->flags & SHF_WR) {
bin/ksh/shf.c
270
shf->wnleft++;
bin/ksh/shf.c
271
shf_putc('\0', shf);
bin/ksh/shf.c
273
if (shf->flags & SHF_ALLOCS)
bin/ksh/shf.c
274
afree(shf, shf->areap);
bin/ksh/shf.c
28
static int shf_fillbuf ARGS((struct shf *shf));
bin/ksh/shf.c
280
shf_finish(shf)
bin/ksh/shf.c
281
struct shf *shf;
bin/ksh/shf.c
285
if (shf->fd >= 0)
bin/ksh/shf.c
286
ret = shf_flush(shf);
bin/ksh/shf.c
287
if (shf->flags & SHF_ALLOCS)
bin/ksh/shf.c
288
afree(shf, shf->areap);
bin/ksh/shf.c
289
else if (shf->flags & SHF_ALLOCB)
bin/ksh/shf.c
29
static int shf_emptybuf ARGS((struct shf *shf, int flags));
bin/ksh/shf.c
290
afree(shf->buf, shf->areap);
bin/ksh/shf.c
299
shf_flush(shf)
bin/ksh/shf.c
300
struct shf *shf;
bin/ksh/shf.c
302
if (shf->flags & SHF_STRING)
bin/ksh/shf.c
303
return (shf->flags & SHF_WR) ? EOF : 0;
bin/ksh/shf.c
305
if (shf->fd < 0)
bin/ksh/shf.c
308
if (shf->flags & SHF_ERROR) {
bin/ksh/shf.c
309
errno = shf->errno_;
bin/ksh/shf.c
313
if (shf->flags & SHF_READING) {
bin/ksh/shf.c
314
shf->flags &= ~(SHF_EOF | SHF_READING);
bin/ksh/shf.c
315
if (shf->rnleft > 0) {
bin/ksh/shf.c
316
lseek(shf->fd, (off_t) -shf->rnleft, 1);
bin/ksh/shf.c
317
shf->rnleft = 0;
bin/ksh/shf.c
318
shf->rp = shf->buf;
bin/ksh/shf.c
321
} else if (shf->flags & SHF_WRITING)
bin/ksh/shf.c
322
return shf_emptybuf(shf, 0);
bin/ksh/shf.c
331
shf_emptybuf(shf, flags)
bin/ksh/shf.c
332
struct shf *shf;
bin/ksh/shf.c
337
if (!(shf->flags & SHF_STRING) && shf->fd < 0)
bin/ksh/shf.c
340
if (shf->flags & SHF_ERROR) {
bin/ksh/shf.c
341
errno = shf->errno_;
bin/ksh/shf.c
345
if (shf->flags & SHF_READING) {
bin/ksh/shf.c
348
ret = shf_flush(shf);
bin/ksh/shf.c
349
shf->flags &= ~SHF_READING;
bin/ksh/shf.c
35
struct shf *
bin/ksh/shf.c
351
if (shf->flags & SHF_STRING) {
bin/ksh/shf.c
357
if (!(flags & EB_GROW) || !(shf->flags & SHF_DYNAMIC)
bin/ksh/shf.c
358
|| !(shf->flags & SHF_ALLOCB))
bin/ksh/shf.c
361
nbuf = (unsigned char *) aresize(shf->buf, shf->wbsize * 2,
bin/ksh/shf.c
362
shf->areap);
bin/ksh/shf.c
363
shf->rp = nbuf + (shf->rp - shf->buf);
bin/ksh/shf.c
364
shf->wp = nbuf + (shf->wp - shf->buf);
bin/ksh/shf.c
365
shf->rbsize += shf->wbsize;
bin/ksh/shf.c
366
shf->wnleft += shf->wbsize;
bin/ksh/shf.c
367
shf->wbsize *= 2;
bin/ksh/shf.c
368
shf->buf = nbuf;
bin/ksh/shf.c
370
if (shf->flags & SHF_WRITING) {
bin/ksh/shf.c
371
int ntowrite = shf->wp - shf->buf;
bin/ksh/shf.c
372
unsigned char *buf = shf->buf;
bin/ksh/shf.c
376
n = write(shf->fd, buf, ntowrite);
bin/ksh/shf.c
379
&& !(shf->flags & SHF_INTERRUPT))
bin/ksh/shf.c
381
shf->flags |= SHF_ERROR;
bin/ksh/shf.c
382
shf->errno_ = errno;
bin/ksh/shf.c
383
shf->wnleft = 0;
bin/ksh/shf.c
384
if (buf != shf->buf) {
bin/ksh/shf.c
387
memmove(shf->buf, buf,
bin/ksh/shf.c
389
shf->wp = shf->buf + ntowrite;
bin/ksh/shf.c
397
shf->wp = shf->buf;
bin/ksh/shf.c
398
shf->wnleft = 0;
bin/ksh/shf.c
399
shf->flags &= ~SHF_WRITING;
bin/ksh/shf.c
403
shf->wp = shf->buf;
bin/ksh/shf.c
404
shf->wnleft = shf->wbsize;
bin/ksh/shf.c
406
shf->flags |= SHF_WRITING;
bin/ksh/shf.c
413
shf_fillbuf(shf)
bin/ksh/shf.c
414
struct shf *shf;
bin/ksh/shf.c
416
if (shf->flags & SHF_STRING)
bin/ksh/shf.c
419
if (shf->fd < 0)
bin/ksh/shf.c
42
struct shf *shf;
bin/ksh/shf.c
422
if (shf->flags & (SHF_EOF | SHF_ERROR)) {
bin/ksh/shf.c
423
if (shf->flags & SHF_ERROR)
bin/ksh/shf.c
424
errno = shf->errno_;
bin/ksh/shf.c
428
if ((shf->flags & SHF_WRITING) && shf_emptybuf(shf, EB_READSW) == EOF)
bin/ksh/shf.c
431
shf->flags |= SHF_READING;
bin/ksh/shf.c
433
shf->rp = shf->buf;
bin/ksh/shf.c
435
shf->rnleft = blocking_read(shf->fd, (char *) shf->buf,
bin/ksh/shf.c
436
shf->rbsize);
bin/ksh/shf.c
437
if (shf->rnleft < 0 && errno == EINTR
bin/ksh/shf.c
438
&& !(shf->flags & SHF_INTERRUPT))
bin/ksh/shf.c
442
if (shf->rnleft <= 0) {
bin/ksh/shf.c
443
if (shf->rnleft < 0) {
bin/ksh/shf.c
444
shf->flags |= SHF_ERROR;
bin/ksh/shf.c
445
shf->errno_ = errno;
bin/ksh/shf.c
446
shf->rnleft = 0;
bin/ksh/shf.c
447
shf->rp = shf->buf;
bin/ksh/shf.c
450
shf->flags |= SHF_EOF;
bin/ksh/shf.c
460
shf_seek(shf, where, from)
bin/ksh/shf.c
461
struct shf *shf;
bin/ksh/shf.c
465
if (shf->fd < 0) {
bin/ksh/shf.c
47
shf = (struct shf *) alloc(sizeof(struct shf) + bsize, ATEMP);
bin/ksh/shf.c
470
if (shf->flags & SHF_ERROR) {
bin/ksh/shf.c
471
errno = shf->errno_;
bin/ksh/shf.c
475
if ((shf->flags & SHF_WRITING) && shf_emptybuf(shf, EB_READSW) == EOF)
bin/ksh/shf.c
478
if (shf->flags & SHF_READING) {
bin/ksh/shf.c
48
shf->areap = ATEMP;
bin/ksh/shf.c
481
-where >= shf->rbsize - shf->rnleft :
bin/ksh/shf.c
482
where < shf->rnleft)) {
bin/ksh/shf.c
483
shf->rnleft -= where;
bin/ksh/shf.c
484
shf->rp += where;
bin/ksh/shf.c
487
shf->rnleft = 0;
bin/ksh/shf.c
488
shf->rp = shf->buf;
bin/ksh/shf.c
49
shf->buf = (unsigned char *) &shf[1];
bin/ksh/shf.c
491
shf->flags &= ~(SHF_EOF | SHF_READING | SHF_WRITING);
bin/ksh/shf.c
493
if (lseek(shf->fd, where, from) < 0) {
bin/ksh/shf.c
494
shf->errno_ = errno;
bin/ksh/shf.c
495
shf->flags |= SHF_ERROR;
bin/ksh/shf.c
50
shf->bsize = bsize;
bin/ksh/shf.c
508
shf_read(buf, bsize, shf)
bin/ksh/shf.c
51
shf->flags = SHF_ALLOCS;
bin/ksh/shf.c
511
struct shf *shf;
bin/ksh/shf.c
516
if (!(shf->flags & SHF_RD))
bin/ksh/shf.c
517
internal_errorf(1, "shf_read: flags %x", shf->flags);
bin/ksh/shf.c
523
if (shf->rnleft == 0
bin/ksh/shf.c
524
&& (shf_fillbuf(shf) == EOF || shf->rnleft == 0))
bin/ksh/shf.c
526
ncopy = shf->rnleft;
bin/ksh/shf.c
529
memcpy(buf, shf->rp, ncopy);
bin/ksh/shf.c
532
shf->rp += ncopy;
bin/ksh/shf.c
533
shf->rnleft -= ncopy;
bin/ksh/shf.c
536
return orig_bsize == bsize ? (shf_error(shf) ? EOF : 0)
bin/ksh/shf.c
545
shf_getse(buf, bsize, shf)
bin/ksh/shf.c
548
struct shf *shf;
bin/ksh/shf.c
554
if (!(shf->flags & SHF_RD))
bin/ksh/shf.c
555
internal_errorf(1, "shf_getse: flags %x", shf->flags);
bin/ksh/shf.c
56
afree(shf, shf->areap);
bin/ksh/shf.c
562
if (shf->rnleft == 0) {
bin/ksh/shf.c
563
if (shf_fillbuf(shf) == EOF)
bin/ksh/shf.c
565
if (shf->rnleft == 0) {
bin/ksh/shf.c
570
end = (unsigned char *) memchr((char *) shf->rp, '\n',
bin/ksh/shf.c
571
shf->rnleft);
bin/ksh/shf.c
572
ncopy = end ? end - shf->rp + 1 : shf->rnleft;
bin/ksh/shf.c
575
memcpy(buf, (char *) shf->rp, ncopy);
bin/ksh/shf.c
576
shf->rp += ncopy;
bin/ksh/shf.c
577
shf->rnleft -= ncopy;
bin/ksh/shf.c
588
shf_getchar(shf)
bin/ksh/shf.c
589
struct shf *shf;
bin/ksh/shf.c
591
if (!(shf->flags & SHF_RD))
bin/ksh/shf.c
592
internal_errorf(1, "shf_getchar: flags %x", shf->flags);
bin/ksh/shf.c
594
if (shf->rnleft == 0 && (shf_fillbuf(shf) == EOF || shf->rnleft == 0))
bin/ksh/shf.c
596
--shf->rnleft;
bin/ksh/shf.c
597
return *shf->rp++;
bin/ksh/shf.c
604
shf_ungetc(c, shf)
bin/ksh/shf.c
606
struct shf *shf;
bin/ksh/shf.c
608
if (!(shf->flags & SHF_RD))
bin/ksh/shf.c
609
internal_errorf(1, "shf_ungetc: flags %x", shf->flags);
bin/ksh/shf.c
611
if ((shf->flags & SHF_ERROR) || c == EOF
bin/ksh/shf.c
612
|| (shf->rp == shf->buf && shf->rnleft))
bin/ksh/shf.c
615
if ((shf->flags & SHF_WRITING) && shf_emptybuf(shf, EB_READSW) == EOF)
bin/ksh/shf.c
618
if (shf->rp == shf->buf)
bin/ksh/shf.c
619
shf->rp = shf->buf + shf->rbsize;
bin/ksh/shf.c
620
if (shf->flags & SHF_STRING) {
bin/ksh/shf.c
624
if (shf->rp[-1] != c)
bin/ksh/shf.c
626
shf->flags &= ~SHF_EOF;
bin/ksh/shf.c
627
shf->rp--;
bin/ksh/shf.c
628
shf->rnleft++;
bin/ksh/shf.c
631
shf->flags &= ~SHF_EOF;
bin/ksh/shf.c
632
*--(shf->rp) = c;
bin/ksh/shf.c
633
shf->rnleft++;
bin/ksh/shf.c
641
shf_putchar(c, shf)
bin/ksh/shf.c
643
struct shf *shf;
bin/ksh/shf.c
645
if (!(shf->flags & SHF_WR))
bin/ksh/shf.c
646
internal_errorf(1, "shf_putchar: flags %x", shf->flags);
bin/ksh/shf.c
65
afree(shf, shf->areap);
bin/ksh/shf.c
651
if (shf->flags & SHF_UNBUF) {
bin/ksh/shf.c
655
if (shf->fd < 0)
bin/ksh/shf.c
657
if (shf->flags & SHF_ERROR) {
bin/ksh/shf.c
658
errno = shf->errno_;
bin/ksh/shf.c
661
while ((n = write(shf->fd, &cc, 1)) != 1)
bin/ksh/shf.c
664
&& !(shf->flags & SHF_INTERRUPT))
bin/ksh/shf.c
666
shf->flags |= SHF_ERROR;
bin/ksh/shf.c
667
shf->errno_ = errno;
bin/ksh/shf.c
672
if (shf->wnleft == 0 && shf_emptybuf(shf, EB_GROW) == EOF)
bin/ksh/shf.c
674
shf->wnleft--;
bin/ksh/shf.c
675
*shf->wp++ = c;
bin/ksh/shf.c
685
shf_puts(s, shf)
bin/ksh/shf.c
687
struct shf *shf;
bin/ksh/shf.c
692
return shf_write(s, strlen(s), shf);
bin/ksh/shf.c
697
shf_write(buf, nbytes, shf)
bin/ksh/shf.c
700
struct shf *shf;
bin/ksh/shf.c
706
if (!(shf->flags & SHF_WR))
bin/ksh/shf.c
707
internal_errorf(1, "shf_write: flags %x", shf->flags);
bin/ksh/shf.c
713
if ((ncopy = shf->wnleft)
bin/ksh/shf.c
714
&& (shf->wp != shf->buf || nbytes < shf->wnleft))
bin/ksh/shf.c
718
memcpy(shf->wp, buf, ncopy);
bin/ksh/shf.c
721
shf->wp += ncopy;
bin/ksh/shf.c
722
shf->wnleft -= ncopy;
bin/ksh/shf.c
726
if (shf_emptybuf(shf, EB_GROW) == EOF)
bin/ksh/shf.c
728
if (nbytes > shf->wbsize) {
bin/ksh/shf.c
730
if (shf->wbsize)
bin/ksh/shf.c
731
ncopy -= nbytes % shf->wbsize;
bin/ksh/shf.c
734
n = write(shf->fd, buf, ncopy);
bin/ksh/shf.c
737
&& !(shf->flags & SHF_INTERRUPT))
bin/ksh/shf.c
739
shf->flags |= SHF_ERROR;
bin/ksh/shf.c
740
shf->errno_ = errno;
bin/ksh/shf.c
741
shf->wnleft = 0;
bin/ksh/shf.c
75
return shf_reopen(fd, sflags, shf);
bin/ksh/shf.c
751
memcpy(shf->wp, buf, nbytes);
bin/ksh/shf.c
752
shf->wp += nbytes;
bin/ksh/shf.c
753
shf->wnleft -= nbytes;
bin/ksh/shf.c
761
shf_fprintf(struct shf *shf, const char *fmt, ...)
bin/ksh/shf.c
767
n = shf_vfprintf(shf, fmt, args);
bin/ksh/shf.c
776
struct shf shf;
bin/ksh/shf.c
784
shf_sopen(buf, bsize, SHF_WR, &shf);
bin/ksh/shf.c
786
n = shf_vfprintf(&shf, fmt, args);
bin/ksh/shf.c
788
shf_sclose(&shf); /* null terminates */
bin/ksh/shf.c
79
struct shf *
bin/ksh/shf.c
795
struct shf shf;
bin/ksh/shf.c
798
shf_sopen((char *) 0, 0, SHF_WR|SHF_DYNAMIC, &shf);
bin/ksh/shf.c
80
shf_fdopen(fd, sflags, shf)
bin/ksh/shf.c
800
shf_vfprintf(&shf, fmt, args);
bin/ksh/shf.c
802
return shf_sclose(&shf); /* null terminates */
bin/ksh/shf.c
83
struct shf *shf;
bin/ksh/shf.c
863
shf_vfprintf(shf, fmt, args)
bin/ksh/shf.c
864
struct shf *shf;
bin/ksh/shf.c
896
shf_putc(c, shf);
bin/ksh/shf.h
13
#define shf_fileno(shf) ((shf)->fd)
bin/ksh/shf.h
14
#define shf_setfileno(shf,nfd) ((shf)->fd = (nfd))
bin/ksh/shf.h
15
#define shf_getc(shf) ((shf)->rnleft > 0 ? (shf)->rnleft--, *(shf)->rp++ : \
bin/ksh/shf.h
16
shf_getchar(shf))
bin/ksh/shf.h
17
#define shf_putc(c, shf) ((shf)->wnleft == 0 ? shf_putchar((c), (shf)) \
bin/ksh/shf.h
18
: ((shf)->wnleft--, *(shf)->wp++ = (c)))
bin/ksh/shf.h
19
#define shf_eof(shf) ((shf)->flags & SHF_EOF)
bin/ksh/shf.h
20
#define shf_error(shf) ((shf)->flags & SHF_ERROR)
bin/ksh/shf.h
21
#define shf_errno(shf) ((shf)->errno_)
bin/ksh/shf.h
22
#define shf_clearerr(shf) ((shf)->flags &= ~(SHF_EOF | SHF_ERROR))
bin/ksh/shf.h
61
extern struct shf shf_iob[];
bin/ksh/shf.h
63
struct shf *shf_open ARGS((const char *name, int oflags, int mode,
bin/ksh/shf.h
65
struct shf *shf_fdopen ARGS((int fd, int sflags, struct shf *shf));
bin/ksh/shf.h
66
struct shf *shf_reopen ARGS((int fd, int sflags, struct shf *shf));
bin/ksh/shf.h
67
struct shf *shf_sopen ARGS((char *buf, int bsize, int sflags,
bin/ksh/shf.h
68
struct shf *shf));
bin/ksh/shf.h
69
int shf_close ARGS((struct shf *shf));
bin/ksh/shf.h
70
int shf_fdclose ARGS((struct shf *shf));
bin/ksh/shf.h
71
char *shf_sclose ARGS((struct shf *shf));
bin/ksh/shf.h
72
int shf_finish ARGS((struct shf *shf));
bin/ksh/shf.h
73
int shf_flush ARGS((struct shf *shf));
bin/ksh/shf.h
74
int shf_seek ARGS((struct shf *shf, off_t where, int from));
bin/ksh/shf.h
75
int shf_read ARGS((char *buf, int bsize, struct shf *shf));
bin/ksh/shf.h
76
char *shf_getse ARGS((char *buf, int bsize, struct shf *shf));
bin/ksh/shf.h
77
int shf_getchar ARGS((struct shf *shf));
bin/ksh/shf.h
78
int shf_ungetc ARGS((int c, struct shf *shf));
bin/ksh/shf.h
79
int shf_putchar ARGS((int c, struct shf *shf));
bin/ksh/shf.h
80
int shf_puts ARGS((const char *s, struct shf *shf));
bin/ksh/shf.h
81
int shf_write ARGS((const char *buf, int nbytes, struct shf *shf));
bin/ksh/shf.h
82
int shf_fprintf ARGS((struct shf *shf, const char *fmt, ...));
bin/ksh/shf.h
85
int shf_vfprintf ARGS((struct shf *, const char *fmt, va_list args));
bin/ksh/tree.c
100
fptreef(shf, indent, "[[");
bin/ksh/tree.c
102
fptreef(shf, indent, " %S", t->args[i]);
bin/ksh/tree.c
103
fptreef(shf, indent, " ]] ");
bin/ksh/tree.c
108
fptreef(shf, indent, "select %s ", t->str);
bin/ksh/tree.c
113
fptreef(shf, indent, "for %s ", t->str);
bin/ksh/tree.c
115
fptreef(shf, indent, "in ");
bin/ksh/tree.c
117
fptreef(shf, indent, "%S ", *w++);
bin/ksh/tree.c
118
fptreef(shf, indent, "%;");
bin/ksh/tree.c
120
fptreef(shf, indent + INDENT, "do%N%T", t->left);
bin/ksh/tree.c
121
fptreef(shf, indent, "%;done ");
bin/ksh/tree.c
124
fptreef(shf, indent, "case %S in", t->str);
bin/ksh/tree.c
126
fptreef(shf, indent, "%N(");
bin/ksh/tree.c
128
fptreef(shf, indent, "%S%c", *w,
bin/ksh/tree.c
130
fptreef(shf, indent + INDENT, "%;%T%N;;", t1->left);
bin/ksh/tree.c
132
fptreef(shf, indent, "%Nesac ");
bin/ksh/tree.c
137
fptreef(shf, indent + 3, "if %T", t->left);
bin/ksh/tree.c
141
fptreef(shf, indent, "%;");
bin/ksh/tree.c
142
fptreef(shf, indent + INDENT, "then%N%T",
bin/ksh/tree.c
148
fptreef(shf, indent, "%;");
bin/ksh/tree.c
150
fptreef(shf, indent + 5, "elif %T", t->left);
bin/ksh/tree.c
153
fptreef(shf, indent, "%;");
bin/ksh/tree.c
154
fptreef(shf, indent + INDENT, "else%;%T", t->right);
bin/ksh/tree.c
156
fptreef(shf, indent, "%;fi ");
bin/ksh/tree.c
161
fptreef(shf, indent + 6, "%s %T",
bin/ksh/tree.c
164
fptreef(shf, indent, "%;do");
bin/ksh/tree.c
165
fptreef(shf, indent + INDENT, "%;%T", t->right);
bin/ksh/tree.c
166
fptreef(shf, indent, "%;done ");
bin/ksh/tree.c
169
fptreef(shf, indent + INDENT, "{%;%T", t->left);
bin/ksh/tree.c
17
#define tputc(c, shf) shf_putchar(c, shf);
bin/ksh/tree.c
170
fptreef(shf, indent, "%;} ");
bin/ksh/tree.c
173
fptreef(shf, indent, "%T|& ", t->left);
bin/ksh/tree.c
176
fptreef(shf, indent, "%T& ", t->left);
bin/ksh/tree.c
179
fptreef(shf, indent,
bin/ksh/tree.c
18
static void ptree ARGS((struct op *t, int indent, struct shf *f));
bin/ksh/tree.c
184
fptreef(shf, indent, "time %T", t->left);
bin/ksh/tree.c
187
fptreef(shf, indent, "<botch>");
bin/ksh/tree.c
19
static void pioact ARGS((struct shf *f, int indent, struct ioword *iop));
bin/ksh/tree.c
194
pioact(shf, indent, *ioact++);
bin/ksh/tree.c
20
static void tputC ARGS((int c, struct shf *shf));
bin/ksh/tree.c
201
tputc('\n', shf);
bin/ksh/tree.c
202
shf_puts(iop->heredoc, shf);
bin/ksh/tree.c
203
fptreef(shf, indent, "%s",
bin/ksh/tree.c
21
static void tputS ARGS((char *wp, struct shf *shf));
bin/ksh/tree.c
213
tputc('\n', shf);
bin/ksh/tree.c
218
pioact(shf, indent, iop)
bin/ksh/tree.c
219
struct shf *shf;
bin/ksh/tree.c
22
static void vfptreef ARGS((struct shf *shf, int indent, const char *fmt, va_list va));
bin/ksh/tree.c
233
tputc('0' + iop->unit, shf);
bin/ksh/tree.c
237
fptreef(shf, indent, "< ");
bin/ksh/tree.c
241
fptreef(shf, indent, "<<- ");
bin/ksh/tree.c
243
fptreef(shf, indent, "<< ");
bin/ksh/tree.c
246
fptreef(shf, indent, ">> ");
bin/ksh/tree.c
250
fptreef(shf, indent, ">| ");
bin/ksh/tree.c
252
fptreef(shf, indent, "> ");
bin/ksh/tree.c
255
fptreef(shf, indent, "<> ");
bin/ksh/tree.c
259
fptreef(shf, indent, "<&");
bin/ksh/tree.c
261
fptreef(shf, indent, ">&");
bin/ksh/tree.c
267
fptreef(shf, indent, "%S ", iop->delim);
bin/ksh/tree.c
269
fptreef(shf, indent, (iop->flag & IONAMEXP) ? "%s " : "%S ",
bin/ksh/tree.c
279
tputC(c, shf)
bin/ksh/tree.c
281
struct shf *shf;
bin/ksh/tree.c
284
tputc((c&0x80) ? '$' : '^', shf);
bin/ksh/tree.c
285
tputc(((c&0x7F)|0x40), shf);
bin/ksh/tree.c
287
tputc((c&0x80) ? '$' : '^', shf);
bin/ksh/tree.c
288
tputc('?', shf);
bin/ksh/tree.c
290
tputc(c, shf);
bin/ksh/tree.c
294
tputS(wp, shf)
bin/ksh/tree.c
296
struct shf *shf;
bin/ksh/tree.c
31
ptree(t, indent, shf)
bin/ksh/tree.c
312
tputC(*wp++, shf);
bin/ksh/tree.c
317
tputc('\\', shf);
bin/ksh/tree.c
318
tputC(c, shf);
bin/ksh/tree.c
321
tputc('$', shf);
bin/ksh/tree.c
322
tputc('(', shf);
bin/ksh/tree.c
324
tputC(*wp++, shf);
bin/ksh/tree.c
325
tputc(')', shf);
bin/ksh/tree.c
329
tputc('$', shf);
bin/ksh/tree.c
330
tputc('(', shf);
bin/ksh/tree.c
331
tputc('(', shf);
bin/ksh/tree.c
333
tputC(*wp++, shf);
bin/ksh/tree.c
334
tputc(')', shf);
bin/ksh/tree.c
335
tputc(')', shf);
bin/ksh/tree.c
34
struct shf *shf;
bin/ksh/tree.c
340
tputc('"', shf);
bin/ksh/tree.c
344
tputc('"', shf);
bin/ksh/tree.c
347
tputc('$', shf);
bin/ksh/tree.c
349
tputc('{', shf);
bin/ksh/tree.c
351
tputC(c, shf);
bin/ksh/tree.c
355
tputc('}', shf);
bin/ksh/tree.c
359
tputc(*wp++, shf);
bin/ksh/tree.c
360
tputc('(', shf);
bin/ksh/tree.c
363
tputc('|', shf);
bin/ksh/tree.c
366
tputc(')', shf);
bin/ksh/tree.c
378
fptreef(struct shf *shf, int indent, const char *fmt, ...)
bin/ksh/tree.c
384
vfptreef(shf, indent, fmt, va);
bin/ksh/tree.c
394
struct shf shf;
bin/ksh/tree.c
396
shf_sopen(s, n, SHF_WR | (s ? 0 : SHF_DYNAMIC), &shf);
bin/ksh/tree.c
399
vfptreef(&shf, 0, fmt, va);
bin/ksh/tree.c
402
return shf_sclose(&shf); /* null terminates */
bin/ksh/tree.c
406
vfptreef(shf, indent, fmt, va)
bin/ksh/tree.c
407
struct shf *shf;
bin/ksh/tree.c
422
tputc(va_arg(va, int), shf);
bin/ksh/tree.c
427
tputc(*p++, shf);
bin/ksh/tree.c
431
tputS(p, shf);
bin/ksh/tree.c
441
tputc(*p++, shf);
bin/ksh/tree.c
444
ptree(va_arg(va, struct op *), indent, shf);
bin/ksh/tree.c
448
if (shf->flags & SHF_STRING) {
bin/ksh/tree.c
450
tputc(';', shf);
bin/ksh/tree.c
451
tputc(' ', shf);
bin/ksh/tree.c
455
tputc('\n', shf);
bin/ksh/tree.c
457
tputc('\t', shf);
bin/ksh/tree.c
459
tputc(' ', shf);
bin/ksh/tree.c
463
pioact(shf, indent, va_arg(va, struct ioword *));
bin/ksh/tree.c
466
tputc(c, shf);
bin/ksh/tree.c
47
fptreef(shf, indent, "%S ", *w++);
bin/ksh/tree.c
470
tputc(c, shf);
bin/ksh/tree.c
49
fptreef(shf, indent, "#no-vars# ");
bin/ksh/tree.c
52
fptreef(shf, indent, "%S ", *w++);
bin/ksh/tree.c
54
fptreef(shf, indent, "#no-args# ");
bin/ksh/tree.c
600
struct shf shf;
bin/ksh/tree.c
603
shf_sopen((char *) 0, 32, SHF_WR | SHF_DYNAMIC, &shf);
bin/ksh/tree.c
61
fptreef(shf, indent, "%S ", *w++);
bin/ksh/tree.c
613
return shf_sclose(&shf); /* null terminates */
bin/ksh/tree.c
616
shf_putchar(*wp++, &shf);
bin/ksh/tree.c
619
shf_putchar('$', &shf);
bin/ksh/tree.c
620
shf_putchar('(', &shf);
bin/ksh/tree.c
622
shf_putchar(*wp++, &shf);
bin/ksh/tree.c
623
shf_putchar(')', &shf);
bin/ksh/tree.c
626
shf_putchar('$', &shf);
bin/ksh/tree.c
627
shf_putchar('(', &shf);
bin/ksh/tree.c
628
shf_putchar('(', &shf);
bin/ksh/tree.c
63
fptreef(shf, indent, "#no-vars# ");
bin/ksh/tree.c
630
shf_putchar(*wp++, &shf);
bin/ksh/tree.c
631
shf_putchar(')', &shf);
bin/ksh/tree.c
632
shf_putchar(')', &shf);
bin/ksh/tree.c
639
shf_putchar('$', &shf);
bin/ksh/tree.c
641
shf_putchar('{', &shf);
bin/ksh/tree.c
643
shf_putchar(c, &shf);
bin/ksh/tree.c
647
shf_putchar('}', &shf);
bin/ksh/tree.c
651
shf_putchar(*wp++, &shf);
bin/ksh/tree.c
652
shf_putchar('(', &shf);
bin/ksh/tree.c
655
shf_putchar('|', &shf);
bin/ksh/tree.c
658
shf_putchar(')', &shf);
bin/ksh/tree.c
67
fptreef(shf, indent, "%s ", *w++);
bin/ksh/tree.c
69
fptreef(shf, indent, "#no-args# ");
bin/ksh/tree.c
77
fptreef(shf, indent + 2, "( %T) ", t->left);
bin/ksh/tree.c
80
fptreef(shf, indent, "%T| ", t->left);
bin/ksh/tree.c
84
fptreef(shf, indent, "%T%;", t->left);
bin/ksh/tree.c
89
fptreef(shf, indent, "%T%s %T",
bin/ksh/tree.c
93
fptreef(shf, indent, "! ");