VirtualBox

source: kBuild/trunk/src/kash/var.h@ 1228

Last change on this file since 1228 was 1218, checked in by bird, 17 years ago

changed eol-style to LF.

  • Property svn:eol-style set to LF
File size: 5.2 KB
Line 
1/* $NetBSD: var.h,v 1.23 2004/10/02 12:16:53 dsl Exp $ */
2
3/*-
4 * Copyright (c) 1991, 1993
5 * The Regents of the University of California. All rights reserved.
6 *
7 * This code is derived from software contributed to Berkeley by
8 * Kenneth Almquist.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. Neither the name of the University nor the names of its contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 *
34 * @(#)var.h 8.2 (Berkeley) 5/4/95
35 */
36
37#ifndef ___var_h___
38#define ___var_h___
39
40/*
41 * Shell variables.
42 */
43
44/* flags */
45#define VEXPORT 0x01 /* variable is exported */
46#define VREADONLY 0x02 /* variable cannot be modified */
47#define VSTRFIXED 0x04 /* variable struct is statically allocated */
48#define VTEXTFIXED 0x08 /* text is statically allocated */
49#define VSTACK 0x10 /* text is allocated on the stack */
50#define VUNSET 0x20 /* the variable is not set */
51#define VNOFUNC 0x40 /* don't call the callback function */
52#define VNOSET 0x80 /* do not set variable - just readonly test */
53#ifdef PC_OS2_LIBPATHS
54#define VOS2LIBPATH 0x8000 /* OS/2 LIBPATH related variable. */
55#endif
56
57
58struct var {
59 struct var *next; /* next entry in hash list */
60 int flags; /* flags are defined above */
61 char *text; /* name=value */
62 int name_len; /* length of name */
63 void (*func)(struct shinstance *, const char *);
64 /* function to be called when */
65 /* the variable gets set/unset */
66};
67
68
69struct localvar {
70 struct localvar *next; /* next local variable in list */
71 struct var *vp; /* the variable that was made local */
72 int flags; /* saved flags */
73 char *text; /* saved text */
74};
75
76/*
77struct localvar *localvars;
78
79#if ATTY
80extern struct var vatty;
81#endif
82extern struct var vifs;
83extern struct var vmail;
84extern struct var vmpath;
85extern struct var vpath;
86#ifdef _MSC_VER
87extern struct var vpath2;
88#endif
89extern struct var vps1;
90extern struct var vps2;
91extern struct var vps4;
92#ifndef SMALL
93extern struct var vterm;
94extern struct var vtermcap;
95extern struct var vhistsize;
96#endif
97*/
98
99/*
100 * The following macros access the values of the above variables.
101 * They have to skip over the name. They return the null string
102 * for unset variables.
103 */
104
105#define ifsval(psh) ((psh)->vifs.text + 4)
106#define ifsset(psh) (((psh)->vifs.flags & VUNSET) == 0)
107#define mailval(psh) ((psh)->vmail.text + 5)
108#define mpathval(psh) ((psh)->vmpath.text + 9)
109#ifdef _MSC_VER
110#define pathval(psh) ((psh)->vpath.text[5] ? &(psh)->vpath.text[5] : &(psh)->vpath2.text[5])
111#else
112#define pathval(psh) ((psh)->vpath.text + 5)
113#endif
114#define ps1val(psh) ((psh)->vps1.text + 4)
115#define ps2val(psh) ((psh)->vps2.text + 4)
116#define ps4val(psh) ((psh)->vps4.text + 4)
117#define optindval(psh) ((psh)->voptind.text + 7)
118#ifndef SMALL
119#define histsizeval(psh) ((psh)->vhistsize.text + 9)
120#define termval(psh) ((psh)->vterm.text + 5)
121#endif
122
123#if ATTY
124#define attyset(psh) (((psh)->vatty.flags & VUNSET) == 0)
125#endif
126#define mpathset(psh) (((psh)->vmpath.flags & VUNSET) == 0)
127
128void initvar(struct shinstance *);
129void setvar(struct shinstance *, const char *, const char *, int);
130void setvareq(struct shinstance *, char *, int);
131struct strlist;
132void listsetvar(struct shinstance *, struct strlist *, int);
133char *lookupvar(struct shinstance *, const char *);
134char *bltinlookup(struct shinstance *, const char *, int);
135char **environment(struct shinstance *);
136void shprocvar(struct shinstance *);
137int showvars(struct shinstance *, const char *, int, int);
138int exportcmd(struct shinstance *, int, char **);
139int localcmd(struct shinstance *, int, char **);
140void mklocal(struct shinstance *, const char *, int);
141void listmklocal(struct shinstance *, struct strlist *, int);
142void poplocalvars(struct shinstance *);
143int setvarcmd(struct shinstance *, int, char **);
144int unsetcmd(struct shinstance *, int, char **);
145int unsetvar(struct shinstance *, const char *, int);
146int setvarsafe(struct shinstance *, const char *, const char *, int);
147void print_quoted(struct shinstance *, const char *);
148
149#endif
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette