From f2efbb46ef89c7c1693400f7209113c50c959f02 Mon Sep 17 00:00:00 2001 From: Nicholas Noll Date: Wed, 13 Oct 2021 10:51:54 -0700 Subject: Feat(rc): working(ish) version of rc shell Removed compile commands --- sys/cmd/rc/io.c | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) (limited to 'sys/cmd/rc/io.c') diff --git a/sys/cmd/rc/io.c b/sys/cmd/rc/io.c index 3e17369..c06137c 100644 --- a/sys/cmd/rc/io.c +++ b/sys/cmd/rc/io.c @@ -4,11 +4,11 @@ #include "io.h" #include "fns.h" -io *err; +Io *err; int pfmtnest = 0; void -pfmt(io *f, char *fmt, ...) +pfmt(Io *f, char *fmt, ...) { va_list ap; char err[ERRMAX]; @@ -46,10 +46,10 @@ pfmt(io *f, char *fmt, ...) pstr(f, va_arg(ap, char *)); break; case 't': - pcmd(f, va_arg(ap, struct tree *)); + pcmd(f, va_arg(ap, struct Tree *)); break; case 'v': - pval(f, va_arg(ap, struct word *)); + pval(f, va_arg(ap, struct Word *)); break; default: pchr(f, *fmt); @@ -61,7 +61,7 @@ pfmt(io *f, char *fmt, ...) } void -pchr(io *b, int c) +pchr(Io *b, int c) { if(b->bufp==b->ebuf) fullbuf(b, c); @@ -69,7 +69,7 @@ pchr(io *b, int c) } int -rchr(io *b) +rchr(Io *b) { if(b->bufp==b->ebuf) return emptybuf(b); @@ -77,7 +77,7 @@ rchr(io *b) } void -pquo(io *f, char *s) +pquo(Io *f, char *s) { pchr(f, '\''); for(;*s;s++) @@ -88,7 +88,7 @@ pquo(io *f, char *s) } void -pwrd(io *f, char *s) +pwrd(Io *f, char *s) { char *t; for(t = s;*t;t++) if(!wordchr(*t)) break; @@ -98,7 +98,7 @@ pwrd(io *f, char *s) } void -pptr(io *f, void *v) +pptr(Io *f, void *v) { int n; uintptr p; @@ -111,7 +111,7 @@ pptr(io *f, void *v) } void -pstr(io *f, char *s) +pstr(Io *f, char *s) { if(s==0) s="(null)"; @@ -119,7 +119,7 @@ pstr(io *f, char *s) } void -pdec(io *f, int n) +pdec(Io *f, int n) { if(n<0){ if(n!=INT_MIN){ @@ -140,7 +140,7 @@ pdec(io *f, int n) } void -poct(io *f, unsigned n) +poct(Io *f, unsigned n) { if(n>7) poct(f, n>>3); @@ -148,7 +148,7 @@ poct(io *f, unsigned n) } void -pval(io *f, word *a) +pval(Io *f, Word *a) { if(a){ while(a->next && a->next->word){ @@ -161,14 +161,14 @@ pval(io *f, word *a) } int -fullbuf(io *f, int c) +fullbuf(Io *f, int c) { flush(f); return *f->bufp++=c; } void -flush(io *f) +flush(Io *f) { int n; char *s; @@ -193,20 +193,20 @@ flush(io *f) } } -io* +Io* openfd(int fd) { - io *f = new(struct io); + Io *f = new(struct Io); f->fd = fd; f->bufp = f->ebuf = f->buf; f->strp = 0; return f; } -io* +Io* openstr(void) { - io *f = new(struct io); + Io *f = new(struct Io); char *s; f->fd=-1; f->bufp = f->strp = emalloc(101); @@ -219,10 +219,10 @@ openstr(void) * characters from buf. */ -io* +Io* opencore(char *s, int len) { - io *f = new(struct io); + Io *f = new(struct Io); char *buf = emalloc(len); f->fd= -1 /*open("/dev/null", 0)*/; f->bufp = f->strp = buf; @@ -232,7 +232,7 @@ opencore(char *s, int len) } void -iorewind(io *io) +iorewind(Io *io) { if(io->fd==-1) io->bufp = io->strp; @@ -243,7 +243,7 @@ iorewind(io *io) } void -closeio(io *io) +closeio(Io *io) { if(io->fd>=0) close(io->fd); @@ -253,7 +253,7 @@ closeio(io *io) } int -emptybuf(io *f) +emptybuf(Io *f) { int n; if(f->fd==-1 || (n = Read(f->fd, f->buf, NBUF))<=0) return EOF; -- cgit v1.2.1