1*47148Sbostic /*- 2*47148Sbostic * Copyright (c) 1991 The Regents of the University of California. 3*47148Sbostic * All rights reserved. 4*47148Sbostic * 5*47148Sbostic * This code is derived from software contributed to Berkeley by 6*47148Sbostic * Kenneth Almquist. 7*47148Sbostic * 8*47148Sbostic * %sccs.include.redist.c% 9*47148Sbostic * 10*47148Sbostic * @(#)var.h 5.1 (Berkeley) 03/07/91 11*47148Sbostic */ 12*47148Sbostic 13*47148Sbostic /* 14*47148Sbostic * Shell variables. 15*47148Sbostic */ 16*47148Sbostic 17*47148Sbostic /* flags */ 18*47148Sbostic #define VEXPORT 01 /* variable is exported */ 19*47148Sbostic #define VREADONLY 02 /* variable cannot be modified */ 20*47148Sbostic #define VSTRFIXED 04 /* variable struct is staticly allocated */ 21*47148Sbostic #define VTEXTFIXED 010 /* text is staticly allocated */ 22*47148Sbostic #define VSTACK 020 /* text is allocated on the stack */ 23*47148Sbostic #define VUNSET 040 /* the variable is not set */ 24*47148Sbostic 25*47148Sbostic 26*47148Sbostic struct var { 27*47148Sbostic struct var *next; /* next entry in hash list */ 28*47148Sbostic int flags; /* flags are defined above */ 29*47148Sbostic char *text; /* name=value */ 30*47148Sbostic }; 31*47148Sbostic 32*47148Sbostic 33*47148Sbostic struct localvar { 34*47148Sbostic struct localvar *next; /* next local variable in list */ 35*47148Sbostic struct var *vp; /* the variable that was made local */ 36*47148Sbostic int flags; /* saved flags */ 37*47148Sbostic char *text; /* saved text */ 38*47148Sbostic }; 39*47148Sbostic 40*47148Sbostic 41*47148Sbostic struct localvar *localvars; 42*47148Sbostic 43*47148Sbostic #if ATTY 44*47148Sbostic extern struct var vatty; 45*47148Sbostic #endif 46*47148Sbostic extern struct var vifs; 47*47148Sbostic extern struct var vmail; 48*47148Sbostic extern struct var vmpath; 49*47148Sbostic extern struct var vpath; 50*47148Sbostic extern struct var vps1; 51*47148Sbostic extern struct var vps2; 52*47148Sbostic #if ATTY 53*47148Sbostic extern struct var vterm; 54*47148Sbostic #endif 55*47148Sbostic 56*47148Sbostic /* 57*47148Sbostic * The following macros access the values of the above variables. 58*47148Sbostic * They have to skip over the name. They return the null string 59*47148Sbostic * for unset variables. 60*47148Sbostic */ 61*47148Sbostic 62*47148Sbostic #define ifsval() (vifs.text + 4) 63*47148Sbostic #define mailval() (vmail.text + 5) 64*47148Sbostic #define mpathval() (vmpath.text + 9) 65*47148Sbostic #define pathval() (vpath.text + 5) 66*47148Sbostic #define ps1val() (vps1.text + 4) 67*47148Sbostic #define ps2val() (vps2.text + 4) 68*47148Sbostic #if ATTY 69*47148Sbostic #define termval() (vterm.text + 5) 70*47148Sbostic #endif 71*47148Sbostic 72*47148Sbostic #if ATTY 73*47148Sbostic #define attyset() ((vatty.flags & VUNSET) == 0) 74*47148Sbostic #endif 75*47148Sbostic #define mpathset() ((vmpath.flags & VUNSET) == 0) 76*47148Sbostic 77*47148Sbostic 78*47148Sbostic #ifdef __STDC__ 79*47148Sbostic void initvar(); 80*47148Sbostic void setvar(char *, char *, int); 81*47148Sbostic void setvareq(char *, int); 82*47148Sbostic struct strlist; 83*47148Sbostic void listsetvar(struct strlist *); 84*47148Sbostic char *lookupvar(char *); 85*47148Sbostic char *bltinlookup(char *, int); 86*47148Sbostic char **environment(); 87*47148Sbostic int showvarscmd(int, char **); 88*47148Sbostic void mklocal(char *); 89*47148Sbostic void poplocalvars(void); 90*47148Sbostic #else 91*47148Sbostic void initvar(); 92*47148Sbostic void setvar(); 93*47148Sbostic void setvareq(); 94*47148Sbostic void listsetvar(); 95*47148Sbostic char *lookupvar(); 96*47148Sbostic char *bltinlookup(); 97*47148Sbostic char **environment(); 98*47148Sbostic int showvarscmd(); 99*47148Sbostic void mklocal(); 100*47148Sbostic void poplocalvars(); 101*47148Sbostic #endif 102