VirtualBox

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

最後變更 在這個檔案從3569是 3569,由 bird 提交於 3 年 前

kash: Some variable handling fixes that showed up when using 'local' on stuff in a shell function (RemoveDirFromPath in vbox' tools/env.sh).

  • 屬性 svn:eol-style 設為 LF
  • 屬性 svn:keywords 設為 Id
檔案大小: 5.4 KB
 
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#define VSTRFIXED2 0x4000 /* variable struct is in the shinstance, cannot be freed. (VSTRFIXED is mixed up in local vars) */
54#ifdef PC_OS2_LIBPATHS
55#define VOS2LIBPATH 0x8000 /* OS/2 LIBPATH related variable. */
56#endif
57
58
59struct var {
60 struct var *next; /* next entry in hash list */
61 int flags; /* flags are defined above */
62 char *text; /* name=value */
63 int name_len; /* length of name */
64 void (*func)(struct shinstance *, const char *);
65 /* function to be called when */
66 /* the variable gets set/unset */
67};
68
69
70struct localvar {
71 struct localvar *next; /* next local variable in list */
72 struct var *vp; /* the variable that was made local */
73 int flags; /* saved flags */
74 char *text; /* saved text */
75};
76
77/*
78struct localvar *localvars;
79
80#if ATTY
81extern struct var vatty;
82#endif
83extern struct var vifs;
84extern struct var vmail;
85extern struct var vmpath;
86extern struct var vpath;
87#ifdef _MSC_VER
88extern struct var vpath2;
89#endif
90extern struct var vps1;
91extern struct var vps2;
92extern struct var vps4;
93#ifndef SMALL
94extern struct var vterm;
95extern struct var vtermcap;
96extern struct var vhistsize;
97#endif
98*/
99
100/*
101 * The following macros access the values of the above variables.
102 * They have to skip over the name. They return the null string
103 * for unset variables.
104 */
105
106#define ifsval(psh) ((psh)->vifs.text + 4)
107#define ifsset(psh) (((psh)->vifs.flags & VUNSET) == 0)
108#define mailval(psh) ((psh)->vmail.text + 5)
109#define mpathval(psh) ((psh)->vmpath.text + 9)
110#ifdef _MSC_VER
111# define pathval(psh) ((psh)->vpath.text[5] || !(psh)->vpath2.text ? &(psh)->vpath.text[5] : &(psh)->vpath2.text[5])
112#else
113# define pathval(psh) ((psh)->vpath.text + 5)
114#endif
115#define ps1val(psh) ((psh)->vps1.text + 4)
116#define ps2val(psh) ((psh)->vps2.text + 4)
117#define ps4val(psh) ((psh)->vps4.text + 4)
118#define optindval(psh) ((psh)->voptind.text + 7)
119#ifndef SMALL
120#define histsizeval(psh) ((psh)->vhistsize.text + 9)
121#define termval(psh) ((psh)->vterm.text + 5)
122#endif
123
124#if ATTY
125#define attyset(psh) (((psh)->vatty.flags & VUNSET) == 0)
126#endif
127#define mpathset(psh) (((psh)->vmpath.flags & VUNSET) == 0)
128
129void initvar(struct shinstance *);
130#ifndef SH_FORKED_MODE
131void subshellinitvar(shinstance *, shinstance *);
132#endif
133void setvar(struct shinstance *, const char *, const char *, int);
134void setvareq(struct shinstance *, char *, int);
135struct strlist;
136void listsetvar(struct shinstance *, struct strlist *, int);
137char *lookupvar(struct shinstance *, const char *);
138char *bltinlookup(struct shinstance *, const char *, int);
139char **environment(struct shinstance *);
140void shprocvar(struct shinstance *);
141int showvars(struct shinstance *, const char *, int, int);
142int exportcmd(struct shinstance *, int, char **);
143int localcmd(struct shinstance *, int, char **);
144void mklocal(struct shinstance *, const char *, int);
145void listmklocal(struct shinstance *, struct strlist *, int);
146void poplocalvars(struct shinstance *);
147int setvarcmd(struct shinstance *, int, char **);
148int unsetcmd(struct shinstance *, int, char **);
149int unsetvar(struct shinstance *, const char *, int);
150int setvarsafe(struct shinstance *, const char *, const char *, int);
151void print_quoted(struct shinstance *, const char *);
152
153#endif
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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