summaryrefslogtreecommitdiffstats
path: root/src/kash/generated/init.c
blob: 5b0f781fd003332fd76aea6d44b1ac26816f8b41 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
/*
 * This file was generated by the mkinit program.
 */

#include "shell.h"
#include "mystring.h"
#include "init.h"
#include "eval.h"
#include <stdio.h>
#include "input.h"
#include "error.h"
#include <stdlib.h>
#include "options.h"
#include "output.h"
#include "memalloc.h"
#include "redir.h"
#include <signal.h>
#include "trap.h"
#include "var.h"
#include "shinstance.h"



#undef  PROFILE
#define PROFILE 0
#undef  SIGSSIZE
#define SIGSSIZE (sizeof(sigs)/sizeof(sigs[0]))
#undef  MAXPWD
#define MAXPWD 256
#undef  ALL
#define ALL (E_OPEN|E_CREAT|E_EXEC)
#undef  EV_EXIT
#define EV_EXIT 01		/* exit after evaluating tree */
#undef  EV_TESTED
#define EV_TESTED 02		/* exit status is checked; ignore -e flag */
#undef  EV_BACKCMD
#define EV_BACKCMD 04		/* command executing within back quotes */
#undef  NEWARGS
#define NEWARGS 5
#undef  MAXHISTLOOPS
#define MAXHISTLOOPS	4	/* max recursions through fc */
#undef  DEFEDITOR
#define DEFEDITOR	"ed"	/* default editor *should* be $EDITOR */
#undef  editing
#define editing (Eflag(psh) || Vflag(psh))
#undef  EOF_NLEFT
#define EOF_NLEFT -99		/* value of parsenleft when EOF pushed back */
#undef  DEFINE_OPTIONS
#define DEFINE_OPTIONS
#undef  BLOCK_OUT
#define BLOCK_OUT -2		/* output to a fixed block of memory */
#undef  OUTPUT_ERR
#define OUTPUT_ERR 01		/* error occurred on output */
#undef  TEMPSIZE
#define TEMPSIZE 32
#undef  HAVE_VASPRINTF
#define HAVE_VASPRINTF 1
#undef  EOFMARKLEN
#define EOFMARKLEN 79
#undef  OPENBRACE
#define OPENBRACE '{'
#undef  CLOSEBRACE
#define CLOSEBRACE '}'
#undef  EMPTY
#define EMPTY -2		/* marks an unused slot in redirtab */
#undef  S_DFL
#define S_DFL 1			/* default signal handling (SIG_DFL) */
#undef  S_CATCH
#define S_CATCH 2		/* signal is caught */
#undef  S_IGN
#define S_IGN 3			/* signal is ignored (SIG_IGN) */
#undef  S_HARD_IGN
#define S_HARD_IGN 4		/* signal is ignored permenantly */
#undef  S_RESET
#define S_RESET 5		/* temporary - to reset a hard ignored sig */
#undef  INCL_BASE
#define INCL_BASE
#undef  LIBPATHSTRICT
#define LIBPATHSTRICT 3
#undef  QHINF_EXEINFO
#define QHINF_EXEINFO       1 /* NE exeinfo. */
#undef  QHINF_READRSRCTBL
#define QHINF_READRSRCTBL   2 /* Reads from the resource table. */
#undef  QHINF_READFILE
#define QHINF_READFILE      3 /* Reads from the executable file. */
#undef  QHINF_LIBPATHLENGTH
#define QHINF_LIBPATHLENGTH 4 /* Gets the libpath length. */
#undef  QHINF_LIBPATH
#define QHINF_LIBPATH       5 /* Gets the entire libpath. */
#undef  QHINF_FIXENTRY
#define QHINF_FIXENTRY      6 /* NE only */
#undef  QHINF_STE
#define QHINF_STE           7 /* NE only */
#undef  QHINF_MAPSEL
#define QHINF_MAPSEL        8 /* NE only */
#undef  SET_LEN
#define	SET_LEN	6		/* initial # of bitcmd struct to malloc */
#undef  SET_LEN_INCR
#define	SET_LEN_INCR 4		/* # of bitcmd structs to add as needed */
#undef  CMD2_CLR
#define	CMD2_CLR	0x01
#undef  CMD2_SET
#define	CMD2_SET	0x02
#undef  CMD2_GBITS
#define	CMD2_GBITS	0x04
#undef  CMD2_OBITS
#define	CMD2_OBITS	0x08
#undef  CMD2_UBITS
#define	CMD2_UBITS	0x10
#undef  STANDARD_BITS
#define	STANDARD_BITS	(S_ISUID|S_ISGID|S_IRWXU|S_IRWXG|S_IRWXO)
#undef  SHMEMHDR_MAGIC_FREE
#define SHMEMHDR_MAGIC_FREE     0xbeeff00d
#undef  SHMEMHDR_MAGIC_USED
#define SHMEMHDR_MAGIC_USED     0xfeedface
#undef  SHMEMCHUNK_MAGIC
#define SHMEMCHUNK_MAGIC        0x12345678
#undef  SHHEAP_MIN_CHUNK
#define SHHEAP_MIN_CHUNK        0x80000 //(1024*1024)
#undef  SHFILE_MAX
#define SHFILE_MAX          1024
#undef  SHFILE_GROW
#define SHFILE_GROW         64
#undef  SHFILE_UNIX_MIN_FD
#define SHFILE_UNIX_MIN_FD  32
#undef  SHFILE_MAX_PATH
#define SHFILE_MAX_PATH     4096
#undef  YY_NO_UNPUT
#define YY_NO_UNPUT



extern void rmaliases(shinstance *psh);

extern void deletefuncs(struct shinstance *);
extern void hash_special_builtins(struct shinstance *);



/*
 * Initialization code.
 */

void
init(shinstance *psh) {

      /* from /Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/exec.c: */
      {
	      hash_special_builtins(psh);
      }

      /* from /Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/input.c: */
      {
	      psh->basepf.nextc = psh->basepf.buf = psh->basebuf;
      }

      /* from /Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/options.c: */
      {
	      memcpy(&psh->optlist[0], &ro_optlist[0], sizeof(psh->optlist));
      }

      /* from /Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/var.c: */
      {
	      char **envp;

	      initvar(psh);
	      for (envp = sh_environ(psh) ; *envp ; envp++) {
		      if (strchr(*envp, '=')) {
			      setvareq(psh, *envp, VEXPORT|VTEXTFIXED);
		      }
	      }
      }
}



/*
 * This routine is called when an error or an interrupt occurs in an
 * interactive shell and control is returned to the main command loop.
 */

void
reset(shinstance *psh) {

      /* from /Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/eval.c: */
      {
	      psh->evalskip = 0;
	      psh->loopnest = 0;
	      psh->funcnest = 0;
      }

      /* from /Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/input.c: */
      {
	      if (psh->exception != EXSHELLPROC)
		      psh->parselleft = psh->parsenleft = 0;	/* clear input buffer */
	      popallfiles(psh);
      }

      /* from /Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/output.c: */
      {
	      psh->out1 = &psh->output;
	      psh->out2 = &psh->errout;
	      if (psh->memout.buf != NULL) {
		      ckfree(psh, psh->memout.buf);
		      psh->memout.buf = NULL;
		      psh->memout.nextc = NULL;
	      }
      }

      /* from /Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/parser.c: */
      {
	      psh->tokpushback = 0;
	      psh->checkkwd = 0;
      }

      /* from /Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/redir.c: */
      {
	      while (psh->redirlist)
		      popredir(psh);
      }
}



/*
 * This routine is called to initialize the shell to run a shell procedure.
 */

void
initshellproc(shinstance *psh) {

      /* from /Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/alias.c: */
      {
	      rmaliases(psh);
      }

      /* from /Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/eval.c: */
      {
	      psh->exitstatus = 0;
      }

      /* from /Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/exec.c: */
      {
	      deletefuncs(psh);
      }

      /* from /Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/input.c: */
      {
	      popallfiles(psh);
      }

      /* from /Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/jobs.c: */
      {
	      psh->backgndpid = -1;
#if JOBS
	      psh->jobctl = 0;
#endif
      }

      /* from /Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/options.c: */
      {
	      int i;

	      for (i = 0; psh->optlist[i].name; i++)
		      psh->optlist[i].val = 0;
# if DEBUG == 2
	      debug(psh) = 1;
# endif
	      optschanged(psh);
      }

      /* from /Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/redir.c: */
      {
	      clearredir(psh);
      }

      /* from /Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/trap.c: */
      {
	      char *sm;

	      clear_traps(psh);
	      for (sm = psh->sigmode ; sm < psh->sigmode + NSIG ; sm++) {
		      if (*sm == S_IGN)
			      *sm = S_HARD_IGN;
	      }
      }

      /* from /Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/var.c: */
      {
	      shprocvar(psh);
      }
}