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

Last change on this file was 3570, checked in by bird, 3 years ago

kash: Must NULL nextc when freeing an output buffer.

  • Property svn:keywords set to Id
File size: 7.2 KB
RevLine 
[631]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"
[1222]20#include "shinstance.h"
[631]21
22
23
[1222]24#undef PROFILE
25#define PROFILE 0
26#undef SIGSSIZE
27#define SIGSSIZE (sizeof(sigs)/sizeof(sigs[0]))
[631]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
[1198]45#define editing (Eflag(psh) || Vflag(psh))
[631]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
[1222]55#define TEMPSIZE 32
[631]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 */
[1222]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)
[2415]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
[631]130
131
132
[1222]133extern void rmaliases(shinstance *psh);
[631]134
[1200]135extern void deletefuncs(struct shinstance *);
136extern void hash_special_builtins(struct shinstance *);
[631]137
138
139
140/*
141 * Initialization code.
142 */
143
144void
[1201]145init(shinstance *psh) {
[631]146
[2415]147 /* from /Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/exec.c: */
[631]148 {
[1222]149 hash_special_builtins(psh);
[631]150 }
151
[2415]152 /* from /Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/input.c: */
[631]153 {
[1222]154 psh->basepf.nextc = psh->basepf.buf = psh->basebuf;
[631]155 }
156
[2415]157 /* from /Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/options.c: */
[1239]158 {
159 memcpy(&psh->optlist[0], &ro_optlist[0], sizeof(psh->optlist));
160 }
161
[2415]162 /* from /Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/var.c: */
[631]163 {
164 char **envp;
165
[1202]166 initvar(psh);
[1222]167 for (envp = sh_environ(psh) ; *envp ; envp++) {
[631]168 if (strchr(*envp, '=')) {
[1202]169 setvareq(psh, *envp, VEXPORT|VTEXTFIXED);
[631]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
[1201]183reset(shinstance *psh) {
[631]184
[2415]185 /* from /Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/eval.c: */
[631]186 {
[1203]187 psh->evalskip = 0;
188 psh->loopnest = 0;
189 psh->funcnest = 0;
[631]190 }
191
[2415]192 /* from /Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/input.c: */
[631]193 {
[1203]194 if (psh->exception != EXSHELLPROC)
195 psh->parselleft = psh->parsenleft = 0; /* clear input buffer */
[1201]196 popallfiles(psh);
[631]197 }
198
[2415]199 /* from /Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/output.c: */
[631]200 {
[1201]201 psh->out1 = &psh->output;
202 psh->out2 = &psh->errout;
[1222]203 if (psh->memout.buf != NULL) {
[2290]204 ckfree(psh, psh->memout.buf);
[1222]205 psh->memout.buf = NULL;
[3570]206 psh->memout.nextc = NULL;
[631]207 }
208 }
209
[2415]210 /* from /Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/parser.c: */
[631]211 {
[1203]212 psh->tokpushback = 0;
213 psh->checkkwd = 0;
[631]214 }
215
[2415]216 /* from /Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/redir.c: */
[631]217 {
[1203]218 while (psh->redirlist)
[1202]219 popredir(psh);
[631]220 }
221}
222
223
224
225/*
226 * This routine is called to initialize the shell to run a shell procedure.
227 */
228
229void
[1201]230initshellproc(shinstance *psh) {
[631]231
[2415]232 /* from /Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/alias.c: */
[631]233 {
[1199]234 rmaliases(psh);
[631]235 }
236
[2415]237 /* from /Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/eval.c: */
[631]238 {
[1203]239 psh->exitstatus = 0;
[631]240 }
241
[2415]242 /* from /Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/exec.c: */
[631]243 {
[1200]244 deletefuncs(psh);
[631]245 }
246
[2415]247 /* from /Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/input.c: */
[631]248 {
[1201]249 popallfiles(psh);
[631]250 }
251
[2415]252 /* from /Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/jobs.c: */
[631]253 {
[1203]254 psh->backgndpid = -1;
[631]255#if JOBS
[1222]256 psh->jobctl = 0;
[631]257#endif
258 }
259
[2415]260 /* from /Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/options.c: */
[631]261 {
262 int i;
263
[1222]264 for (i = 0; psh->optlist[i].name; i++)
265 psh->optlist[i].val = 0;
[2652]266# if DEBUG == 2
267 debug(psh) = 1;
268# endif
[1202]269 optschanged(psh);
[631]270 }
271
[2415]272 /* from /Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/redir.c: */
[631]273 {
[3435]274 clearredir(psh);
[631]275 }
276
[2415]277 /* from /Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/trap.c: */
[631]278 {
279 char *sm;
280
[3435]281 clear_traps(psh);
[1208]282 for (sm = psh->sigmode ; sm < psh->sigmode + NSIG ; sm++) {
[631]283 if (*sm == S_IGN)
284 *sm = S_HARD_IGN;
285 }
286 }
287
[2415]288 /* from /Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/var.c: */
[631]289 {
[1202]290 shprocvar(psh);
[631]291 }
292}
Note: See TracBrowser for help on using the repository browser.