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