2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $XConsortium: defs.h /main/3 1995/11/01 16:39:16 rswiston $ */
24 /***************************************************************
26 * AT&T - PROPRIETARY *
28 * THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF *
29 * AT&T BELL LABORATORIES *
30 * AND IS NOT TO BE DISCLOSED OR USED EXCEPT IN *
31 * ACCORDANCE WITH APPLICABLE AGREEMENTS *
33 * Copyright (c) 1995 AT&T Corp. *
34 * Unpublished & Not for Publication *
35 * All Rights Reserved *
37 * The copyright notice above does not evidence any *
38 * actual or intended publication of such source code *
40 * This software was created by the *
41 * Advanced Software Technology Department *
42 * AT&T Bell Laboratories *
44 * For further information contact *
45 * {research,attmail}!dgk *
47 ***************************************************************/
49 /* : : generated by proto : : */
51 #if !defined(__PROTO__)
52 #if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
53 #if defined(__cplusplus)
54 #define __MANGLE__ "C"
59 #define __PROTO__(x) x
61 #define __PARAM__(n,o) n
62 #if !defined(__STDC__) && !defined(__cplusplus)
63 #if !defined(c_plusplus)
74 #define __PROTO__(x) ()
75 #define __OTORP__(x) x
76 #define __PARAM__(n,o) o
84 #if defined(__cplusplus) || defined(c_plusplus)
85 #define __VARARG__ ...
89 #if defined(__STDARG__)
90 #define __VA_START__(p,a) va_start(p,a)
92 #define __VA_START__(p,a) va_start(p)
95 #define mount _AST__mount
100 #include "FEATURE/options"
107 struct slnod *staklist; /* link list of function stacks */
122 char *trap[SH_DEBUGTRAP+1];
126 __V_ *par_tree; /* for calling function */
127 struct sh_scoped *prevst; /* pointer to previous state */
132 int open_max; /* maximum number of file descriptors */
133 int clk_tck; /* number of ticks per second */
134 int child_max; /* maxumum number of children */
135 int ngroups_max; /* maximum number of process groups */
136 unsigned char posix_version; /* posix version number */
137 unsigned char posix_jobcontrol;/* non-zero for job control systems */
138 unsigned char fs3d; /* non-zero for 3-d file system */
141 #define _SH_PRIVATE \
142 struct sh_scoped st; /* scoped information */ \
143 struct limits lim; /* run time limits */ \
144 Hashtab_t *track_tree; /* for tracked aliases*/ \
145 Hashtab_t *bltin_tree; /* for builtin commands */ \
146 Hashtab_t *var_base; /* global level variables */ \
147 History_t *hist_ptr; /* history file pointer */ \
148 Sfio_t *outpool; /* ouput stream pool */ \
149 long timeout; /* read timeout */ \
150 long tmout; /* value for TMOUT */ \
151 int curenv; /* current subshell number */ \
152 int jobenv; /* subshell number for jobs */ \
153 int nextprompt; /* next prompt is PS<nextprompt> */ \
154 Namval_t *bltin_cmds; /* pointer to built-in commands */ \
155 Namval_t *posix_fun; /* points to last name() function */ \
156 int infd; /* input file descriptor */ \
157 char *outbuff; /* pointer to output buffer */ \
158 char *errbuff; /* pointer to stderr buffer */ \
159 char *prompt; /* pointer to prompt string */ \
160 char *shname; /* shell name */ \
161 char *comdiv; /* points to sh -c argument */ \
162 char *prefix; /* prefix for compound assignment */ \
163 sigjmp_buf *jmplist; /* longjmp return stack */ \
164 char **sigmsg; /* points to signal messages */ \
166 uid_t userid,euserid; /* real and effective user id */ \
167 gid_t groupid,egroupid;/* real and effective group id */ \
168 pid_t pid; /* process id of shell */ \
169 pid_t bckpid; /* background process id */ \
171 long ppid; /* parent process id of shell */ \
173 int sigmax; /* maximum number of signals */ \
174 unsigned char *sigflag; /* pointer to signal states */ \
181 char used_pos; /* used postional parameter */\
182 unsigned char lastsig; /* last signal received */ \
183 char *readscript; /* set before reading a script */ \
184 int *inpipe; /* input pipe pointer */ \
185 int *outpipe; /* output pipe pointer */ \
188 struct argnod *envlist; \
189 struct dolnod *arglist; \
198 /* error exits from various parts of shell */
199 #define NIL(type) ((type)0)
201 #define new_of(type,x) ((type*)malloc((unsigned)sizeof(type)+(x)))
203 #define exitset() (sh.savexit=sh.exitval)
207 /* low numbered states are same as options */
208 #define SH_NOFORK 0x1 /* set when fork not necessary, not a state */
209 #define SH_COMPLETE 0x1 /* set for command completion */
210 #define SH_TTYWAIT 0x40 /* waiting for keyboard input */
211 #define SH_FORKED 0x80 /* set when process has been forked */
212 #define SH_PROFILE 0x100 /* set when processing profiles */
213 #define SH_NOALIAS 0x200 /* do not expand non-exported aliases */
214 #define SH_NOTRACK 0x400 /* set to disable sftrack() function */
215 #define SH_STOPOK 0x800 /* set for stopable builtins */
216 #define SH_GRACE 0x1000 /* set for timeout grace period */
217 #define SH_TIMING 0x2000 /* set while timing pipelines */
218 #define SH_DEFPATH 0x4000 /* set when using default path */
219 #define SH_INIT 0x8000 /* set when initializing the shell */
221 extern __MANGLE__ Namval_t *sh_assignok __PROTO__((Namval_t*,int));
222 extern __MANGLE__ int sh_echolist __PROTO__((Sfio_t*, int, char**));
223 extern __MANGLE__ struct argnod *sh_endword __PROTO__((int));
224 extern __MANGLE__ char **sh_envgen __PROTO__((void));
225 extern __MANGLE__ void sh_envnolocal __PROTO__((Namval_t*));
226 extern __MANGLE__ char *sh_etos __PROTO__((double,int));
227 extern __MANGLE__ char *sh_ftos __PROTO__((double,int));
228 extern __MANGLE__ double sh_arith __PROTO__((const char*));
229 extern __MANGLE__ pid_t sh_fork __PROTO__((int,int*));
230 extern __MANGLE__ char *sh_mactrim __PROTO__((char*,int));
231 extern __MANGLE__ int sh_macexpand __PROTO__((struct argnod*,struct argnod**));
232 extern __MANGLE__ void sh_machere __PROTO__((Sfio_t*, Sfio_t*, char*));
233 extern __MANGLE__ char *sh_mactry __PROTO__((char*));
234 extern __MANGLE__ int sh_readline __PROTO__((char**,int,int,long));
235 extern __MANGLE__ void sh_reinit __PROTO__((char*[]));
236 extern __MANGLE__ Sfio_t *sh_sfeval __PROTO__((char*[]));
237 extern __MANGLE__ void sh_subtmpfile __PROTO__((void));
238 extern __MANGLE__ Sfio_t *sh_subshell __PROTO__((union anynode*, int, int));
239 extern __MANGLE__ char *sh_substitute __PROTO__((const char*,const char*,char*));
240 extern __MANGLE__ int sh_tdump __PROTO__((Sfio_t*, const union anynode*));
241 extern __MANGLE__ int sh_trace __PROTO__((char*[],int));
242 extern __MANGLE__ union anynode *sh_trestore __PROTO__((Sfio_t*));
243 extern __MANGLE__ void sh_trim __PROTO__((char*));
244 extern __MANGLE__ void sh_userinit __PROTO__((void));
245 extern __MANGLE__ int sh_whence __PROTO__((char**,int));
248 #define sh_isstate(x) (sh.st.states&((int)(x)))
249 #define sh_onstate(x) (sh.st.states |= ((int)(x)))
250 #define sh_setstate(x) (sh.st.states = ((int)(x)))
251 #define sh_offstate(x) (sh.st.states &= ~((int)(x)))
253 extern __MANGLE__ time_t sh_mailchk;