VirtualBox

source: kBuild/trunk/src/ash-messup/var.h@ 881

Last change on this file since 881 was 880, checked in by bird, 18 years ago

hacking...

  • Property svn:eol-style set to native
File size: 5.1 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/*
97 * The following macros access the values of the above variables.
98 * They have to skip over the name. They return the null string
99 * for unset variables.
100 */
101
102#define ifsval(psh) ((psh)->vifs.text + 4)
103#define ifsset(psh) (((psh)->vifs.flags & VUNSET) == 0)
104#define mailval(psh) ((psh)->vmail.text + 5)
105#define mpathval(psh) ((psh)->vmpath.text + 9)
106#ifdef _MSC_VER
107#define pathval(psh) ((psh)->vpath.text[5] ? &(psh)->vpath.text[5] : &(psh)->vpath2.text[5])
108#else
109#define pathval(psh) ((psh)->vpath.text + 5)
110#endif
111#define ps1val(psh) ((psh)->vps1.text + 4)
112#define ps2val(psh) ((psh)->vps2.text + 4)
113#define ps4val(psh) ((psh)->vps4.text + 4)
114#define optindval(psh) ((psh)->voptind.text + 7)
115#ifndef SMALL
116#define histsizeval(psh) ((psh)->vhistsize.text + 9)
117#define termval(psh) ((psh)->vterm.text + 5)
118#endif
119
120#if ATTY
121#define attyset(psh) (((psh)->vatty.flags & VUNSET) == 0)
122#endif
123#define mpathset(psh) (((psh)->vmpath.flags & VUNSET) == 0)
124
125void initvar(struct shinstance *);
126void setvar(struct shinstance *, const char *, const char *, int);
127void setvareq(struct shinstance *, char *, int);
128struct strlist;
129void listsetvar(struct shinstance *, struct strlist *, int);
130char *lookupvar(struct shinstance *, const char *);
131char *bltinlookup(struct shinstance *, const char *, int);
132char **environment(struct shinstance *);
133void shprocvar(struct shinstance *);
134int showvars(struct shinstance *, const char *, int, int);
135int exportcmd(struct shinstance *, int, char **);
136int localcmd(struct shinstance *, int, char **);
137void mklocal(struct shinstance *, const char *, int);
138void listmklocal(struct shinstance *, struct strlist *, int);
139void poplocalvars(struct shinstance *);
140int setvarcmd(struct shinstance *, int, char **);
141int unsetcmd(struct shinstance *, int, char **);
142int unsetvar(struct shinstance *, const char *, int);
143int setvarsafe(struct shinstance *, const char *, const char *, int);
144void print_quoted(struct shinstance *, 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