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/rc.h | 92 +++++++++++++++++++++++++++++++++------------------------ 1 file changed, 54 insertions(+), 38 deletions(-) (limited to 'sys/cmd/rc/rc.h') diff --git a/sys/cmd/rc/rc.h b/sys/cmd/rc/rc.h index 1f73f11..c91bdd4 100644 --- a/sys/cmd/rc/rc.h +++ b/sys/cmd/rc/rc.h @@ -10,48 +10,60 @@ #undef pipe /* so that /dev/fd works */ #define searchpath rcsearchpath /* avoid new libc function */ -typedef struct tree tree; -typedef struct word word; -typedef struct io io; -typedef union code code; -typedef struct var var; -typedef struct list list; -typedef struct redir redir; -typedef struct thread thread; -typedef struct builtin builtin; - -struct tree{ - int type; - int rtype, fd0, fd1; /* details of REDIR PIPE DUP tokens */ - char *str; - int quoted; - int iskw; - tree *child[3]; - tree *next; +typedef struct Tree Tree; +typedef struct Word Word; +typedef struct Io Io; +typedef union Code Code; +typedef struct Var Var; +typedef struct Words Words; +typedef struct Redir Redir; +typedef struct Thread Thread; +typedef struct Builtin Builtin; + +struct Tree +{ + int type; + int rtype, fd0, fd1; /* details of REDIR PIPE DUP tokens */ + char *str; + int quoted; + int iskw; + Tree *child[3]; + Tree *next; }; -tree *newtree(void); -tree *token(char*, int), *klook(char*), *tree1(int, tree*); -tree *tree2(int, tree*, tree*), *tree3(int, tree*, tree*, tree*); -tree *mung1(tree*, tree*), *mung2(tree*, tree*, tree*); -tree *mung3(tree*, tree*, tree*, tree*), *epimung(tree*, tree*); -tree *simplemung(tree*), *heredoc(tree*); -void freetree(tree*); -extern tree *cmdtree; +Tree *newtree(void); +void freetree(Tree*); + +Tree *token(char*, int); +Tree *klook(char*); + +Tree *tree1(int, Tree*); +Tree *tree2(int, Tree*, Tree*); +Tree *tree3(int, Tree*, Tree*, Tree*); + +Tree *mung1(Tree*, Tree*); +Tree *mung2(Tree*, Tree*, Tree*); +Tree *mung3(Tree*, Tree*, Tree*, Tree*); +Tree *epimung(Tree*, Tree*); +Tree *simplemung(Tree*); +Tree *heredoc(Tree*); + +extern Tree *cmdtree; /* * The first word of any code vector is a reference count. * Always create a new reference to a code vector by calling codecopy(.). * Always call codefree(.) when deleting a reference. */ -union code{ +union Code +{ void (*f)(void); int i; char *s; }; extern char *promptstr; -extern int doprompt; +extern int doprompt; #define NTOK 8192 extern char tok[NTOK]; @@ -63,30 +75,34 @@ extern char tok[NTOK]; #define DUPFD 5 #define CLOSE 6 #define RDWR 7 -struct var{ + +struct Var +{ char *name; /* ascii name */ - word *val; /* value */ + Word *val; /* value */ int changed; - code *fn; /* pointer to function's code vector */ + Code *fn; /* pointer to function's code vector */ int fnchanged; int pc; /* pc of start of function */ - var *next; /* next on hash or local list */ - void (*changefn)(var*); + Var *next; /* next on hash or local list */ + void (*changefn)(Var*); }; -var *vlook(char*), *gvlook(char*), *newvar(char*, var*); +Var *vlook(char*), *gvlook(char*), *newvar(char*, Var*); #define NVAR 521 -extern var *gvar[NVAR]; /* hash for globals */ +extern Var *gvar[NVAR]; /* hash for globals */ #define new(type) ((type *)emalloc(sizeof(type))) void *emalloc(long); void *Malloc(ulong); void efree(void*); #define NOFILE 128 /* should come from */ -struct here{ - tree *tag; + +struct Here +{ + Tree *tag; char *name; - struct here *next; + struct Here *next; }; /* * Glob character escape in strings: -- cgit v1.2.1