00001 /*- 00002 * Copyright (c) 1991, 1993 00003 * The Regents of the University of California. All rights reserved. 00004 * 00005 * This code is derived from software contributed to Berkeley by 00006 * Kenneth Almquist. 00007 * 00008 * Redistribution and use in source and binary forms, with or without 00009 * modification, are permitted provided that the following conditions 00010 * are met: 00011 * 1. Redistributions of source code must retain the above copyright 00012 * notice, this list of conditions and the following disclaimer. 00013 * 2. Redistributions in binary form must reproduce the above copyright 00014 * notice, this list of conditions and the following disclaimer in the 00015 * documentation and/or other materials provided with the distribution. 00016 * 4. Neither the name of the University nor the names of its contributors 00017 * may be used to endorse or promote products derived from this software 00018 * without specific prior written permission. 00019 * 00020 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 00021 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00022 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00023 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 00024 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00025 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 00026 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00027 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00028 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 00029 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 00030 * SUCH DAMAGE. 00031 * 00032 * @(#)var.h 8.2 (Berkeley) 5/4/95 00033 * $FreeBSD: src/bin/sh/var.h,v 1.12 2004/04/06 20:06:51 markm Exp $ 00034 */ 00035 00036 /* 00037 * Shell variables. 00038 */ 00039 00040 /* flags */ 00041 #define VEXPORT 0x01 /* variable is exported */ 00042 #define VREADONLY 0x02 /* variable cannot be modified */ 00043 #define VSTRFIXED 0x04 /* variable struct is staticly allocated */ 00044 #define VTEXTFIXED 0x08 /* text is staticly allocated */ 00045 #define VSTACK 0x10 /* text is allocated on the stack */ 00046 #define VUNSET 0x20 /* the variable is not set */ 00047 #define VNOFUNC 0x40 /* don't call the callback function */ 00048 00049 00050 struct var { 00051 struct var *next; /* next entry in hash list */ 00052 int flags; /* flags are defined above */ 00053 char *text; /* name=value */ 00054 void (*func)(const char *); 00055 /* function to be called when */ 00056 /* the variable gets set/unset */ 00057 }; 00058 00059 00060 struct localvar { 00061 struct localvar *next; /* next local variable in list */ 00062 struct var *vp; /* the variable that was made local */ 00063 int flags; /* saved flags */ 00064 char *text; /* saved text */ 00065 }; 00066 00067 00068 struct localvar *localvars; 00069 00070 extern struct var vifs; 00071 extern struct var vmail; 00072 extern struct var vmpath; 00073 extern struct var vpath; 00074 extern struct var vppid; 00075 extern struct var vps1; 00076 extern struct var vps2; 00077 extern struct var vpse; 00078 #ifndef NO_HISTORY 00079 extern struct var vhistsize; 00080 #endif 00081 00082 /* 00083 * The following macros access the values of the above variables. 00084 * They have to skip over the name. They return the null string 00085 * for unset variables. 00086 */ 00087 00088 #define ifsval() (vifs.text + 4) 00089 #define ifsset() ((vifs.flags & VUNSET) == 0) 00090 #define mailval() (vmail.text + 5) 00091 #define mpathval() (vmpath.text + 9) 00092 #define pathval() (vpath.text + 5) 00093 #define ps1val() (vps1.text + 4) 00094 #define ps2val() (vps2.text + 4) 00095 #define pseval() (vpse.text + 4) 00096 #define optindval() (voptind.text + 7) 00097 #ifndef NO_HISTORY 00098 #define histsizeval() (vhistsize.text + 9) 00099 #endif 00100 00101 #define mpathset() ((vmpath.flags & VUNSET) == 0) 00102 00103 void initvar(void); 00104 void setvar(char *, char *, int); 00105 void setvareq(char *, int); 00106 struct strlist; 00107 void listsetvar(struct strlist *); 00108 char *lookupvar(char *); 00109 char *bltinlookup(char *, int); 00110 char **environment(void); 00111 void shprocvar(void); 00112 int showvarscmd(int, char **); 00113 int exportcmd(int, char **); 00114 int localcmd(int, char **); 00115 void mklocal(char *); 00116 void poplocalvars(void); 00117 int setvarcmd(int, char **); 00118 int unsetcmd(int, char **); 00119 int unsetvar(char *); 00120 int setvarsafe(char *, char *, int); 00121 00122 /* 00123 * $PchId: var.h,v 1.4 2006/03/29 12:04:45 philip Exp $ 00124 */
1.5.8