0.1.3
[kbuild-mirror.git] / src / ash / generated / init.c
blob1de3c3d6b3c0b2b0c85ae349bc58fa8b3dec29c6
1 /*
2 * This file was generated by the mkinit program.
3 */
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"
23 #undef ATABSIZE
24 #define ATABSIZE 39
25 #undef MAXPWD
26 #define MAXPWD 256
27 #undef ALL
28 #define ALL (E_OPEN|E_CREAT|E_EXEC)
29 #undef EV_EXIT
30 #define EV_EXIT 01 /* exit after evaluating tree */
31 #undef EV_TESTED
32 #define EV_TESTED 02 /* exit status is checked; ignore -e flag */
33 #undef EV_BACKCMD
34 #define EV_BACKCMD 04 /* command executing within back quotes */
35 #undef CMDTABLESIZE
36 #define CMDTABLESIZE 31 /* should be prime */
37 #undef ARB
38 #define ARB 1 /* actual size determined at run time */
39 #undef NEWARGS
40 #define NEWARGS 5
41 #undef MAXHISTLOOPS
42 #define MAXHISTLOOPS 4 /* max recursions through fc */
43 #undef DEFEDITOR
44 #define DEFEDITOR "ed" /* default editor *should* be $EDITOR */
45 #undef editing
46 #define editing (Eflag || Vflag)
47 #undef EOF_NLEFT
48 #define EOF_NLEFT -99 /* value of parsenleft when EOF pushed back */
49 #undef MAXMBOXES
50 #define MAXMBOXES 10
51 #undef PROFILE
52 #define PROFILE 0
53 #undef SIGSSIZE
54 #define SIGSSIZE (sizeof(sigs)/sizeof(sigs[0]))
55 #undef MINSIZE
56 #define MINSIZE 504 /* minimum size of a block */
57 #undef DEFINE_OPTIONS
58 #define DEFINE_OPTIONS
59 #undef OUTBUFSIZ
60 #define OUTBUFSIZ BUFSIZ
61 #undef BLOCK_OUT
62 #define BLOCK_OUT -2 /* output to a fixed block of memory */
63 #undef MEM_OUT
64 #define MEM_OUT -3 /* output to dynamically allocated memory */
65 #undef OUTPUT_ERR
66 #define OUTPUT_ERR 01 /* error occurred on output */
67 #undef TEMPSIZE
68 #define TEMPSIZE 24
69 #undef HAVE_VASPRINTF
70 #define HAVE_VASPRINTF 1
71 #undef EOFMARKLEN
72 #define EOFMARKLEN 79
73 #undef OPENBRACE
74 #define OPENBRACE '{'
75 #undef CLOSEBRACE
76 #define CLOSEBRACE '}'
77 #undef EMPTY
78 #define EMPTY -2 /* marks an unused slot in redirtab */
79 #undef S_DFL
80 #define S_DFL 1 /* default signal handling (SIG_DFL) */
81 #undef S_CATCH
82 #define S_CATCH 2 /* signal is caught */
83 #undef S_IGN
84 #define S_IGN 3 /* signal is ignored (SIG_IGN) */
85 #undef S_HARD_IGN
86 #define S_HARD_IGN 4 /* signal is ignored permenantly */
87 #undef S_RESET
88 #define S_RESET 5 /* temporary - to reset a hard ignored sig */
89 #undef INCL_BASE
90 #define INCL_BASE
91 #undef LIBPATHSTRICT
92 #define LIBPATHSTRICT 3
93 #undef QHINF_EXEINFO
94 #define QHINF_EXEINFO 1 /* NE exeinfo. */
95 #undef QHINF_READRSRCTBL
96 #define QHINF_READRSRCTBL 2 /* Reads from the resource table. */
97 #undef QHINF_READFILE
98 #define QHINF_READFILE 3 /* Reads from the executable file. */
99 #undef QHINF_LIBPATHLENGTH
100 #define QHINF_LIBPATHLENGTH 4 /* Gets the libpath length. */
101 #undef QHINF_LIBPATH
102 #define QHINF_LIBPATH 5 /* Gets the entire libpath. */
103 #undef QHINF_FIXENTRY
104 #define QHINF_FIXENTRY 6 /* NE only */
105 #undef QHINF_STE
106 #define QHINF_STE 7 /* NE only */
107 #undef QHINF_MAPSEL
108 #define QHINF_MAPSEL 8 /* NE only */
109 #undef VTABSIZE
110 #define VTABSIZE 39
111 #undef VTABSIZE
112 #define VTABSIZE 517
113 #undef main
114 #define main echocmd
115 #undef main
116 #define main killcmd
120 extern void rmaliases(void);
122 extern int loopnest; /* current loop nesting level */
124 extern void deletefuncs(void);
125 extern void hash_special_builtins(void);
127 struct strpush {
128 struct strpush *prev; /* preceding string on stack */
129 char *prevstring;
130 int prevnleft;
131 int prevlleft;
132 struct alias *ap; /* if push was associated with an alias */
135 struct parsefile {
136 struct parsefile *prev; /* preceding file on stack */
137 int linno; /* current line */
138 int fd; /* file descriptor (or -1 if string) */
139 int nleft; /* number of chars left in this line */
140 int lleft; /* number of chars left in this buffer */
141 char *nextc; /* next char in buffer */
142 char *buf; /* input buffer */
143 struct strpush *strpush; /* for pushing strings at this level */
144 struct strpush basestrpush; /* so pushing one is fast */
147 extern int parselleft; /* copy of parsefile->lleft */
148 extern struct parsefile basepf; /* top level input file */
149 extern char basebuf[BUFSIZ]; /* buffer for top level input file */
151 extern pid_t backgndpid; /* pid of last background process */
152 extern int jobctl;
154 extern int tokpushback; /* last token pushed back */
155 extern int checkkwd; /* 1 == check for kwds, 2 == also eat newlines */
157 struct redirtab {
158 struct redirtab *next;
159 short renamed[10];
162 extern struct redirtab *redirlist;
164 extern char sigmode[NSIG]; /* current value of signal */
166 extern char **environ;
171 * Initialization code.
174 void
175 init() {
177 /* from exec.c: */
179 hash_special_builtins();
182 /* from input.c: */
184 basepf.nextc = basepf.buf = basebuf;
187 /* from var.c: */
189 char **envp;
191 initvar();
192 for (envp = environ ; *envp ; envp++) {
193 if (strchr(*envp, '=')) {
194 setvareq(*envp, VEXPORT|VTEXTFIXED);
203 * This routine is called when an error or an interrupt occurs in an
204 * interactive shell and control is returned to the main command loop.
207 void
208 reset() {
210 /* from eval.c: */
212 evalskip = 0;
213 loopnest = 0;
214 funcnest = 0;
217 /* from input.c: */
219 if (exception != EXSHELLPROC)
220 parselleft = parsenleft = 0; /* clear input buffer */
221 popallfiles();
224 /* from output.c: */
226 out1 = &output;
227 out2 = &errout;
228 if (memout.buf != NULL) {
229 ckfree(memout.buf);
230 memout.buf = NULL;
234 /* from parser.c: */
236 tokpushback = 0;
237 checkkwd = 0;
240 /* from redir.c: */
242 while (redirlist)
243 popredir();
250 * This routine is called to initialize the shell to run a shell procedure.
253 void
254 initshellproc() {
256 /* from alias.c: */
258 rmaliases();
261 /* from eval.c: */
263 exitstatus = 0;
266 /* from exec.c: */
268 deletefuncs();
271 /* from input.c: */
273 popallfiles();
276 /* from jobs.c: */
278 backgndpid = -1;
279 #if JOBS
280 jobctl = 0;
281 #endif
284 /* from options.c: */
286 int i;
288 for (i = 0; optlist[i].name; i++)
289 optlist[i].val = 0;
290 optschanged();
294 /* from redir.c: */
296 clearredir(0);
299 /* from trap.c: */
301 char *sm;
303 clear_traps(0);
304 for (sm = sigmode ; sm < sigmode + NSIG ; sm++) {
305 if (*sm == S_IGN)
306 *sm = S_HARD_IGN;
310 /* from var.c: */
312 shprocvar();