VirtualBox

source: kBuild/trunk/src/kash/generated/init.c@ 2266

Last change on this file since 2266 was 1239, checked in by bird, 17 years ago

new init code.

  • Property svn:keywords set to Id
File size: 5.7 KB
Line 
1/*
2 * This file was generated by the mkinit program.
3 */
4
5#include "shell.h"
6#include "mystring.h"
7#include "init.h"
8#include "eval.h"
9#include <stdio.h>
10#include "input.h"
11#include "error.h"
12#include <stdlib.h>
13#include "options.h"
14#include "output.h"
15#include "memalloc.h"
16#include "redir.h"
17#include <signal.h>
18#include "trap.h"
19#include "var.h"
20#include "shinstance.h"
21
22
23
24#undef PROFILE
25#define PROFILE 0
26#undef SIGSSIZE
27#define SIGSSIZE (sizeof(sigs)/sizeof(sigs[0]))
28#undef MAXPWD
29#define MAXPWD 256
30#undef ALL
31#define ALL (E_OPEN|E_CREAT|E_EXEC)
32#undef EV_EXIT
33#define EV_EXIT 01 /* exit after evaluating tree */
34#undef EV_TESTED
35#define EV_TESTED 02 /* exit status is checked; ignore -e flag */
36#undef EV_BACKCMD
37#define EV_BACKCMD 04 /* command executing within back quotes */
38#undef NEWARGS
39#define NEWARGS 5
40#undef MAXHISTLOOPS
41#define MAXHISTLOOPS 4 /* max recursions through fc */
42#undef DEFEDITOR
43#define DEFEDITOR "ed" /* default editor *should* be $EDITOR */
44#undef editing
45#define editing (Eflag(psh) || Vflag(psh))
46#undef EOF_NLEFT
47#define EOF_NLEFT -99 /* value of parsenleft when EOF pushed back */
48#undef DEFINE_OPTIONS
49#define DEFINE_OPTIONS
50#undef BLOCK_OUT
51#define BLOCK_OUT -2 /* output to a fixed block of memory */
52#undef OUTPUT_ERR
53#define OUTPUT_ERR 01 /* error occurred on output */
54#undef TEMPSIZE
55#define TEMPSIZE 32
56#undef HAVE_VASPRINTF
57#define HAVE_VASPRINTF 1
58#undef EOFMARKLEN
59#define EOFMARKLEN 79
60#undef OPENBRACE
61#define OPENBRACE '{'
62#undef CLOSEBRACE
63#define CLOSEBRACE '}'
64#undef EMPTY
65#define EMPTY -2 /* marks an unused slot in redirtab */
66#undef S_DFL
67#define S_DFL 1 /* default signal handling (SIG_DFL) */
68#undef S_CATCH
69#define S_CATCH 2 /* signal is caught */
70#undef S_IGN
71#define S_IGN 3 /* signal is ignored (SIG_IGN) */
72#undef S_HARD_IGN
73#define S_HARD_IGN 4 /* signal is ignored permenantly */
74#undef S_RESET
75#define S_RESET 5 /* temporary - to reset a hard ignored sig */
76#undef INCL_BASE
77#define INCL_BASE
78#undef LIBPATHSTRICT
79#define LIBPATHSTRICT 3
80#undef QHINF_EXEINFO
81#define QHINF_EXEINFO 1 /* NE exeinfo. */
82#undef QHINF_READRSRCTBL
83#define QHINF_READRSRCTBL 2 /* Reads from the resource table. */
84#undef QHINF_READFILE
85#define QHINF_READFILE 3 /* Reads from the executable file. */
86#undef QHINF_LIBPATHLENGTH
87#define QHINF_LIBPATHLENGTH 4 /* Gets the libpath length. */
88#undef QHINF_LIBPATH
89#define QHINF_LIBPATH 5 /* Gets the entire libpath. */
90#undef QHINF_FIXENTRY
91#define QHINF_FIXENTRY 6 /* NE only */
92#undef QHINF_STE
93#define QHINF_STE 7 /* NE only */
94#undef QHINF_MAPSEL
95#define QHINF_MAPSEL 8 /* NE only */
96#undef SET_LEN
97#define SET_LEN 6 /* initial # of bitcmd struct to malloc */
98#undef SET_LEN_INCR
99#define SET_LEN_INCR 4 /* # of bitcmd structs to add as needed */
100#undef CMD2_CLR
101#define CMD2_CLR 0x01
102#undef CMD2_SET
103#define CMD2_SET 0x02
104#undef CMD2_GBITS
105#define CMD2_GBITS 0x04
106#undef CMD2_OBITS
107#define CMD2_OBITS 0x08
108#undef CMD2_UBITS
109#define CMD2_UBITS 0x10
110#undef STANDARD_BITS
111#define STANDARD_BITS (S_ISUID|S_ISGID|S_IRWXU|S_IRWXG|S_IRWXO)
112
113
114
115extern void rmaliases(shinstance *psh);
116
117extern void deletefuncs(struct shinstance *);
118extern void hash_special_builtins(struct shinstance *);
119
120struct redirtab {
121 struct redirtab *next;
122 short renamed[10];
123};
124
125
126
127/*
128 * Initialization code.
129 */
130
131void
132init(shinstance *psh) {
133
134 /* from exec.c: */
135 {
136 hash_special_builtins(psh);
137 }
138
139 /* from input.c: */
140 {
141 psh->basepf.nextc = psh->basepf.buf = psh->basebuf;
142 }
143
144 /* from options.c: */
145 {
146 memcpy(&psh->optlist[0], &ro_optlist[0], sizeof(psh->optlist));
147 }
148
149 /* from var.c: */
150 {
151 char **envp;
152
153 initvar(psh);
154 for (envp = sh_environ(psh) ; *envp ; envp++) {
155 if (strchr(*envp, '=')) {
156 setvareq(psh, *envp, VEXPORT|VTEXTFIXED);
157 }
158 }
159 }
160}
161
162
163
164/*
165 * This routine is called when an error or an interrupt occurs in an
166 * interactive shell and control is returned to the main command loop.
167 */
168
169void
170reset(shinstance *psh) {
171
172 /* from eval.c: */
173 {
174 psh->evalskip = 0;
175 psh->loopnest = 0;
176 psh->funcnest = 0;
177 }
178
179 /* from input.c: */
180 {
181 if (psh->exception != EXSHELLPROC)
182 psh->parselleft = psh->parsenleft = 0; /* clear input buffer */
183 popallfiles(psh);
184 }
185
186 /* from output.c: */
187 {
188 psh->out1 = &psh->output;
189 psh->out2 = &psh->errout;
190 if (psh->memout.buf != NULL) {
191 ckfree(psh->memout.buf);
192 psh->memout.buf = NULL;
193 }
194 }
195
196 /* from parser.c: */
197 {
198 psh->tokpushback = 0;
199 psh->checkkwd = 0;
200 }
201
202 /* from redir.c: */
203 {
204 while (psh->redirlist)
205 popredir(psh);
206 }
207}
208
209
210
211/*
212 * This routine is called to initialize the shell to run a shell procedure.
213 */
214
215void
216initshellproc(shinstance *psh) {
217
218 /* from alias.c: */
219 {
220 rmaliases(psh);
221 }
222
223 /* from eval.c: */
224 {
225 psh->exitstatus = 0;
226 }
227
228 /* from exec.c: */
229 {
230 deletefuncs(psh);
231 }
232
233 /* from input.c: */
234 {
235 popallfiles(psh);
236 }
237
238 /* from jobs.c: */
239 {
240 psh->backgndpid = -1;
241#if JOBS
242 psh->jobctl = 0;
243#endif
244 }
245
246 /* from options.c: */
247 {
248 int i;
249
250 for (i = 0; psh->optlist[i].name; i++)
251 psh->optlist[i].val = 0;
252 optschanged(psh);
253
254 }
255
256 /* from redir.c: */
257 {
258 clearredir(psh, 0);
259 }
260
261 /* from trap.c: */
262 {
263 char *sm;
264
265 clear_traps(psh, 0);
266 for (sm = psh->sigmode ; sm < psh->sigmode + NSIG ; sm++) {
267 if (*sm == S_IGN)
268 *sm = S_HARD_IGN;
269 }
270 }
271
272 /* from var.c: */
273 {
274 shprocvar(psh);
275 }
276}
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