source: trunk/src/kash/generated/init.c@ 3459

Last change on this file since 3459 was 3459, checked in by bird, 5 years ago

kash: more sh_destroy work.

  • Property svn:keywords set to Id
File size: 7.1 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#undef SHMEMHDR_MAGIC_FREE
113#define SHMEMHDR_MAGIC_FREE 0xbeeff00d
114#undef SHMEMHDR_MAGIC_USED
115#define SHMEMHDR_MAGIC_USED 0xfeedface
116#undef SHMEMCHUNK_MAGIC
117#define SHMEMCHUNK_MAGIC 0x12345678
118#undef SHHEAP_MIN_CHUNK
119#define SHHEAP_MIN_CHUNK 0x80000 //(1024*1024)
120#undef SHFILE_MAX
121#define SHFILE_MAX 1024
122#undef SHFILE_GROW
123#define SHFILE_GROW 64
124#undef SHFILE_UNIX_MIN_FD
125#define SHFILE_UNIX_MIN_FD 32
126#undef SHFILE_MAX_PATH
127#define SHFILE_MAX_PATH 4096
128#undef YY_NO_UNPUT
129#define YY_NO_UNPUT
130
131
132
133extern void rmaliases(shinstance *psh);
134
135extern void deletefuncs(struct shinstance *);
136extern void hash_special_builtins(struct shinstance *);
137
138
139
140/*
141 * Initialization code.
142 */
143
144void
145init(shinstance *psh) {
146
147 /* from /Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/exec.c: */
148 {
149 hash_special_builtins(psh);
150 }
151
152 /* from /Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/input.c: */
153 {
154 psh->basepf.nextc = psh->basepf.buf = psh->basebuf;
155 }
156
157 /* from /Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/options.c: */
158 {
159 memcpy(&psh->optlist[0], &ro_optlist[0], sizeof(psh->optlist));
160 }
161
162 /* from /Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/var.c: */
163 {
164 char **envp;
165
166 initvar(psh);
167 for (envp = sh_environ(psh) ; *envp ; envp++) {
168 if (strchr(*envp, '=')) {
169 setvareq(psh, *envp, VEXPORT|VTEXTFIXED);
170 }
171 }
172 }
173}
174
175
176
177/*
178 * This routine is called when an error or an interrupt occurs in an
179 * interactive shell and control is returned to the main command loop.
180 */
181
182void
183reset(shinstance *psh) {
184
185 /* from /Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/eval.c: */
186 {
187 psh->evalskip = 0;
188 psh->loopnest = 0;
189 psh->funcnest = 0;
190 }
191
192 /* from /Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/input.c: */
193 {
194 if (psh->exception != EXSHELLPROC)
195 psh->parselleft = psh->parsenleft = 0; /* clear input buffer */
196 popallfiles(psh);
197 }
198
199 /* from /Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/output.c: */
200 {
201 psh->out1 = &psh->output;
202 psh->out2 = &psh->errout;
203 if (psh->memout.buf != NULL) {
204 ckfree(psh, psh->memout.buf);
205 psh->memout.buf = NULL;
206 }
207 }
208
209 /* from /Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/parser.c: */
210 {
211 psh->tokpushback = 0;
212 psh->checkkwd = 0;
213 }
214
215 /* from /Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/redir.c: */
216 {
217 while (psh->redirlist)
218 popredir(psh);
219 }
220}
221
222
223
224/*
225 * This routine is called to initialize the shell to run a shell procedure.
226 */
227
228void
229initshellproc(shinstance *psh) {
230
231 /* from /Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/alias.c: */
232 {
233 rmaliases(psh);
234 }
235
236 /* from /Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/eval.c: */
237 {
238 psh->exitstatus = 0;
239 }
240
241 /* from /Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/exec.c: */
242 {
243 deletefuncs(psh);
244 }
245
246 /* from /Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/input.c: */
247 {
248 popallfiles(psh);
249 }
250
251 /* from /Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/jobs.c: */
252 {
253 psh->backgndpid = -1;
254#if JOBS
255 psh->jobctl = 0;
256#endif
257 }
258
259 /* from /Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/options.c: */
260 {
261 int i;
262
263 for (i = 0; psh->optlist[i].name; i++)
264 psh->optlist[i].val = 0;
265# if DEBUG == 2
266 debug(psh) = 1;
267# endif
268 optschanged(psh);
269 }
270
271 /* from /Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/redir.c: */
272 {
273 clearredir(psh);
274 }
275
276 /* from /Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/trap.c: */
277 {
278 char *sm;
279
280 clear_traps(psh);
281 for (sm = psh->sigmode ; sm < psh->sigmode + NSIG ; sm++) {
282 if (*sm == S_IGN)
283 *sm = S_HARD_IGN;
284 }
285 }
286
287 /* from /Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/var.c: */
288 {
289 shprocvar(psh);
290 }
291}
Note: See TracBrowser for help on using the repository browser.