VirtualBox

source: kBuild/trunk/src/ash/var.h@ 2413

Last change on this file since 2413 was 637, checked in by bird, 18 years ago

Path != PATH. stupid stupid windows idiots.

  • Property svn:eol-style set to native
File size: 4.6 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/*
38 * Shell variables.
39 */
40
41/* flags */
42#define VEXPORT 0x01 /* variable is exported */
43#define VREADONLY 0x02 /* variable cannot be modified */
44#define VSTRFIXED 0x04 /* variable struct is statically allocated */
45#define VTEXTFIXED 0x08 /* text is statically allocated */
46#define VSTACK 0x10 /* text is allocated on the stack */
47#define VUNSET 0x20 /* the variable is not set */
48#define VNOFUNC 0x40 /* don't call the callback function */
49#define VNOSET 0x80 /* do not set variable - just readonly test */
50#ifdef PC_OS2_LIBPATHS
51#define VOS2LIBPATH 0x8000 /* OS/2 LIBPATH related variable. */
52#endif
53
54
55struct var {
56 struct var *next; /* next entry in hash list */
57 int flags; /* flags are defined above */
58 char *text; /* name=value */
59 int name_len; /* length of name */
60 void (*func)(const char *);
61 /* function to be called when */
62 /* the variable gets set/unset */
63};
64
65
66struct localvar {
67 struct localvar *next; /* next local variable in list */
68 struct var *vp; /* the variable that was made local */
69 int flags; /* saved flags */
70 char *text; /* saved text */
71};
72
73
74struct localvar *localvars;
75
76#if ATTY
77extern struct var vatty;
78#endif
79extern struct var vifs;
80extern struct var vmail;
81extern struct var vmpath;
82extern struct var vpath;
83#ifdef _MSC_VER
84extern struct var vpath2;
85#endif
86extern struct var vps1;
87extern struct var vps2;
88extern struct var vps4;
89#ifndef SMALL
90extern struct var vterm;
91extern struct var vtermcap;
92extern struct var vhistsize;
93#endif
94
95/*
96 * The following macros access the values of the above variables.
97 * They have to skip over the name. They return the null string
98 * for unset variables.
99 */
100
101#define ifsval() (vifs.text + 4)
102#define ifsset() ((vifs.flags & VUNSET) == 0)
103#define mailval() (vmail.text + 5)
104#define mpathval() (vmpath.text + 9)
105#ifdef _MSC_VER
106#define pathval() (vpath.text[5] ? &vpath.text[5] : &vpath2.text[5])
107#else
108#define pathval() (vpath.text + 5)
109#endif
110#define ps1val() (vps1.text + 4)
111#define ps2val() (vps2.text + 4)
112#define ps4val() (vps4.text + 4)
113#define optindval() (voptind.text + 7)
114#ifndef SMALL
115#define histsizeval() (vhistsize.text + 9)
116#define termval() (vterm.text + 5)
117#endif
118
119#if ATTY
120#define attyset() ((vatty.flags & VUNSET) == 0)
121#endif
122#define mpathset() ((vmpath.flags & VUNSET) == 0)
123
124void initvar(void);
125void setvar(const char *, const char *, int);
126void setvareq(char *, int);
127struct strlist;
128void listsetvar(struct strlist *, int);
129char *lookupvar(const char *);
130char *bltinlookup(const char *, int);
131char **environment(void);
132void shprocvar(void);
133int showvars(const char *, int, int);
134int exportcmd(int, char **);
135int localcmd(int, char **);
136void mklocal(const char *, int);
137void listmklocal(struct strlist *, int);
138void poplocalvars(void);
139int setvarcmd(int, char **);
140int unsetcmd(int, char **);
141int unsetvar(const char *, int);
142int setvarsafe(const char *, const char *, int);
143void print_quoted(const char *);
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