var.h

Go to the documentation of this file.
00001 /*-
00002  * Copyright (c) 1991 The Regents of the University of California.
00003  * 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  * 3. All advertising materials mentioning features or use of this software
00017  *    must display the following acknowledgement:
00018  *      This product includes software developed by the University of
00019  *      California, Berkeley and its contributors.
00020  * 4. Neither the name of the University nor the names of its contributors
00021  *    may be used to endorse or promote products derived from this software
00022  *    without specific prior written permission.
00023  *
00024  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
00025  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00026  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00027  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
00028  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00029  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00030  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00031  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00032  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00033  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00034  * SUCH DAMAGE.
00035  *
00036  *      @(#)var.h       5.1 (Berkeley) 3/7/91
00037  */
00038 
00039 /*
00040  * Shell variables.
00041  */
00042 
00043 /* flags */
00044 #define VEXPORT         01      /* variable is exported */
00045 #define VREADONLY       02      /* variable cannot be modified */
00046 #define VSTRFIXED       04      /* variable struct is staticly allocated */
00047 #define VTEXTFIXED      010     /* text is staticly allocated */
00048 #define VSTACK          020     /* text is allocated on the stack */
00049 #define VUNSET          040     /* the variable is not set */
00050 
00051 
00052 struct var {
00053         struct var *next;               /* next entry in hash list */
00054         int flags;              /* flags are defined above */
00055         char *text;             /* name=value */
00056 };
00057 
00058 
00059 struct localvar {
00060         struct localvar *next;  /* next local variable in list */
00061         struct var *vp;         /* the variable that was made local */
00062         int flags;              /* saved flags */
00063         char *text;             /* saved text */
00064 };
00065 
00066 
00067 struct localvar *localvars;
00068 
00069 #if ATTY
00070 extern struct var vatty;
00071 #endif
00072 extern struct var vifs;
00073 extern struct var vmail;
00074 extern struct var vmpath;
00075 extern struct var vpath;
00076 extern struct var vps1;
00077 extern struct var vps2;
00078 extern struct var vpse;
00079 #if ATTY
00080 extern struct var vterm;
00081 #endif
00082 
00083 /*
00084  * The following macros access the values of the above variables.
00085  * They have to skip over the name.  They return the null string
00086  * for unset variables.
00087  */
00088 
00089 #define ifsval()        (vifs.text + 4)
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 #if ATTY
00097 #define termval()       (vterm.text + 5)
00098 #endif
00099 
00100 #if ATTY
00101 #define attyset()       ((vatty.flags & VUNSET) == 0)
00102 #endif
00103 #define mpathset()      ((vmpath.flags & VUNSET) == 0)
00104 
00105 
00106 #ifdef __STDC__
00107 void initvar();
00108 void setvar(char *, char *, int);
00109 void setvareq(char *, int);
00110 struct strlist;
00111 void listsetvar(struct strlist *);
00112 char *lookupvar(char *);
00113 char *bltinlookup(char *, int);
00114 char **environment();
00115 int showvarscmd(int, char **);
00116 void mklocal(char *);
00117 void poplocalvars(void);
00118 #else
00119 void initvar();
00120 void setvar();
00121 void setvareq();
00122 void listsetvar();
00123 char *lookupvar();
00124 char *bltinlookup();
00125 char **environment();
00126 int showvarscmd();
00127 void mklocal();
00128 void poplocalvars();
00129 #endif

Generated on Fri Apr 14 22:56:41 2006 for minix by  doxygen 1.4.6