2 /* : : generated by proto : : */
3 /***********************************************************************
5 * This software is part of the ast package *
6 * Copyright (c) 1982-2010 AT&T Intellectual Property *
7 * and is licensed under the *
8 * Common Public License, Version 1.0 *
9 * by AT&T Intellectual Property *
11 * A copy of the License is available at *
12 * http://www.opensource.org/licenses/cpl1.0.txt *
13 * (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
15 * Information and Software Systems Research *
19 * David Korn <dgk@research.att.com> *
21 ***********************************************************************/
23 #ifndef SH_INTERACTIVE
24 #if !defined(__PROTO__)
25 #include <prototyped.h>
27 #if !defined(__LINKAGE__)
28 #define __LINKAGE__ /* 2004-08-11 transition */
35 * Interface definitions for shell command language
45 #endif /* _SH_PRIVATE */
47 #define SH_VERSION 20071012
50 #define NOT_USED(x) (&x,1)
59 typedef struct Shell_s Shell_t
;
61 typedef void (*Shinit_f
) __PROTO__((Shell_t
*, int));
62 typedef int (*Shwait_f
) __PROTO__((int, long, int));
65 typedef union Shnode_u Shnode_t
;
68 #define SH_HISTORY 1 /* used also as a state */
69 #define SH_ERREXIT 2 /* used also as a state */
70 #define SH_VERBOSE 3 /* used also as a state */
71 #define SH_MONITOR 4 /* used also as a state */
72 #define SH_INTERACTIVE 5 /* used also as a state */
73 #define SH_RESTRICTED 6
78 #define SH_ALLEXPORT 11
80 #define SH_IGNOREEOF 13
81 #define SH_NOCLOBBER 14
82 #define SH_MARKDIRS 15
87 #define SH_TRACKALL 20
92 #define SH_PRIVILEGED 26
93 #define SH_SUBSHARE 27 /* subshell shares state with parent */
96 #define SH_DICTIONARY 30
97 #define SH_PIPEFAIL 32
98 #define SH_GLOBSTARS 33
104 * passed as flags to builtins in Nambltin_t struct when BLT_OPTIM is on
106 #define SH_BEGIN_OPTIM 0x1
107 #define SH_END_OPTIM 0x2
109 /* The following type is used for error messages */
112 extern __MANGLE__
const char e_defpath
[];
113 extern __MANGLE__
const char e_found
[];
114 extern __MANGLE__
const char e_nospace
[];
115 extern __MANGLE__
const char e_format
[];
116 extern __MANGLE__
const char e_number
[];
117 extern __MANGLE__
const char e_restricted
[];
118 extern __MANGLE__
const char e_recursive
[];
119 extern __MANGLE__
char e_version
[];
121 typedef struct sh_scope
123 struct sh_scope
*par_scope
;
131 struct sh_scope
*self
;
135 * Saves the state of the shell
140 Shopt_t options
; /* set -o options */
141 Dt_t
*var_tree
; /* for shell variables */
142 Dt_t
*fun_tree
; /* for shell functions */
143 Dt_t
*alias_tree
; /* for alias names */
144 Dt_t
*bltin_tree
; /* for builtin commands */
145 Shscope_t
*topscope
; /* pointer to top-level scope */
146 int inlineno
; /* line number of current input file */
147 int exitval
; /* most recent exit value */
148 unsigned char trapnote
; /* set when trap/signal is pending */
149 char shcomp
; /* set when runing shcomp */
150 short subshell
; /* set for virtual subshell */
153 #endif /* _SH_PRIVATE */
156 /* flags for sh_parse */
157 #define SH_NL 1 /* Treat new-lines as ; */
158 #define SH_EOF 2 /* EOF causes syntax error */
160 /* symbolic values for sh_iogetiop */
161 #define SH_IOCOPROCESS (-2)
162 #define SH_IOHISTFILE (-3)
166 /* symbolic value for sh_fdnotify */
167 #define SH_FDCLOSE (-1)
169 #undef getenv /* -lshell provides its own */
171 #if defined(__EXPORT__) && defined(_DLL)
174 #define __MANGLE__ __LINKAGE__ __EXPORT__
175 # endif /* _BLD_shell */
178 extern __MANGLE__ Dt_t
*sh_bltin_tree
__PROTO__((void));
179 extern __MANGLE__
void sh_subfork
__PROTO__((void));
180 extern __MANGLE__ Shell_t
*sh_init
__PROTO__((int,char*[],Shinit_f
));
181 extern __MANGLE__
int sh_reinit
__PROTO__((char*[]));
182 extern __MANGLE__
int sh_eval
__PROTO__((Sfio_t
*,int));
183 extern __MANGLE__
void sh_delay
__PROTO__((double));
184 extern __MANGLE__ __V_
*sh_parse
__PROTO__((Shell_t
*, Sfio_t
*,int));
185 extern __MANGLE__
int sh_trap
__PROTO__((const char*,int));
186 extern __MANGLE__
int sh_fun
__PROTO__((Namval_t
*,Namval_t
*, char*[]));
187 extern __MANGLE__
int sh_funscope
__PROTO__((int,char*[],int(*)(__V_
*),__V_
*,int));
188 extern __MANGLE__ Sfio_t
*sh_iogetiop
__PROTO__((int,int));
189 extern __MANGLE__
int sh_main
__PROTO__((int, char*[], Shinit_f
));
190 extern __MANGLE__
int sh_run
__PROTO__((int, char*[]));
191 extern __MANGLE__
void sh_menu
__PROTO__((Sfio_t
*, int, char*[]));
192 extern __MANGLE__ Namval_t
*sh_addbuiltin
__PROTO__((const char*, int(*)(int, char*[],__V_
*), __V_
*));
193 extern __MANGLE__
char *sh_fmtq
__PROTO__((const char*));
194 extern __MANGLE__
char *sh_fmtqf
__PROTO__((const char*, int, int));
195 extern __MANGLE__ Sfdouble_t sh_strnum
__PROTO__((const char*, char**, int));
196 extern __MANGLE__
int sh_access
__PROTO__((const char*,int));
197 extern __MANGLE__
int sh_close
__PROTO__((int));
198 extern __MANGLE__
int sh_dup
__PROTO__((int));
199 extern __MANGLE__
void sh_exit
__PROTO__((int));
200 extern __MANGLE__
int sh_fcntl
__PROTO__((int, int, ...));
201 extern __MANGLE__ Sfio_t
*sh_fd2sfio
__PROTO__((int));
202 extern __MANGLE__
int (*sh_fdnotify
__PROTO__((int(*)(int,int)))) __PROTO__((int,int));
203 extern __MANGLE__ Shell_t
*sh_getinterp
__PROTO__((void));
204 extern __MANGLE__
int sh_open
__PROTO__((const char*, int, ...));
205 extern __MANGLE__
int sh_openmax
__PROTO__((void));
206 extern __MANGLE__ Sfio_t
*sh_pathopen
__PROTO__((const char*));
207 extern __MANGLE__ ssize_t sh_read
__PROTO__((int, __V_
*, size_t));
208 extern __MANGLE__ ssize_t sh_write
__PROTO__((int, const __V_
*, size_t));
209 extern __MANGLE__ off_t sh_seek
__PROTO__((int, off_t
, int));
210 extern __MANGLE__
int sh_pipe
__PROTO__((int[]));
211 extern __MANGLE__ mode_t sh_umask
__PROTO__((mode_t
));
212 extern __MANGLE__ __V_
*sh_waitnotify
__PROTO__((Shwait_f
));
213 extern __MANGLE__ Shscope_t
*sh_getscope
__PROTO__((int,int));
214 extern __MANGLE__ Shscope_t
*sh_setscope
__PROTO__((Shscope_t
*));
215 extern __MANGLE__
void sh_sigcheck
__PROTO__((void));
216 extern __MANGLE__
unsigned long sh_isoption
__PROTO__((int));
217 extern __MANGLE__
unsigned long sh_onoption
__PROTO__((int));
218 extern __MANGLE__
unsigned long sh_offoption
__PROTO__((int));
219 extern __MANGLE__
int sh_waitsafe
__PROTO__((void));
220 extern __MANGLE__
int sh_exec
__PROTO__((const Shnode_t
*,int));
223 extern __MANGLE__ __V_
**sh_getliblist
__PROTO__((void));
224 #endif /* SHOPT_DYNAMIC */
227 * direct access to sh is obsolete, use sh_getinterp() instead
229 #if !defined(_SH_PRIVATE) && defined(__IMPORT__) && !defined(_BLD_shell)
230 extern __MANGLE__ __IMPORT__ Shell_t sh
;
232 extern __MANGLE__ Shell_t sh
;
237 #define __MANGLE__ __LINKAGE__
241 # define access(a,b) sh_access(a,b)
242 # define close(a) sh_close(a)
243 # define exit(a) sh_exit(a)
244 # define fcntl(a,b,c) sh_fcntl(a,b,c)
245 # define pipe(a) sh_pipe(a)
246 # define read(a,b,c) sh_read(a,b,c)
247 # define write(a,b,c) sh_write(a,b,c)
248 # define umask(a) sh_umask(a)
251 # define open64 sh_open
252 # define lseek64 sh_seek
254 # define open sh_open
255 # define lseek sh_seek
257 #endif /* !_SH_PRIVATE */
260 #define SH_EXITSIG 0400 /* signal exit bit */
261 #define SH_EXITMASK (SH_EXITSIG-1) /* normal exit status bits */
262 #define SH_RUNPROG -1022 /* needs to be negative and < 256 */
264 #endif /* SH_INTERACTIVE */