make it look like kernel driver
[unix-history] / usr / src / bin / csh / init.c
CommitLineData
b79f4fa9
DF
1/*
2 * Copyright (c) 1980 Regents of the University of California.
094e80ed 3 * All rights reserved. The Berkeley Software License Agreement
b79f4fa9
DF
4 * specifies the terms and conditions for redistribution.
5 */
6
35371dec 7#ifndef lint
094e80ed
EW
8static char *sccsid = "@(#)init.c 5.2 (Berkeley) %G%";
9#endif
90503b97
BJ
10
11#include "sh.local.h"
12
13/*
14 * C shell
15 */
16
17extern int doalias();
18extern int dobg();
19extern int dobreak();
20extern int dochngd();
21extern int docontin();
22extern int dodirs();
23extern int doecho();
24extern int doelse();
25extern int doend();
26extern int doendif();
27extern int doendsw();
28extern int doeval();
29extern int doexit();
30extern int dofg();
31extern int doforeach();
32extern int doglob();
33extern int dogoto();
34extern int dohash();
35extern int dohist();
36extern int doif();
37extern int dojobs();
38extern int dokill();
39extern int dolet();
40extern int dolimit();
41extern int dologin();
42extern int dologout();
6ca601c1 43#ifdef NEWGRP
90503b97 44extern int donewgrp();
6ca601c1 45#endif
90503b97
BJ
46extern int donice();
47extern int donotify();
48extern int donohup();
49extern int doonintr();
50extern int dopopd();
51extern int dopushd();
52extern int dorepeat();
53extern int doset();
54extern int dosetenv();
55extern int dosource();
56extern int dostop();
57extern int dosuspend();
58extern int doswbrk();
59extern int doswitch();
60extern int dotime();
61extern int dounlimit();
62extern int doumask();
63extern int dowait();
64extern int dowhile();
65extern int dozip();
66extern int execash();
67extern int goodbye();
68#ifdef VFORK
69extern int hashstat();
70#endif
71extern int shift();
72extern int showall();
73extern int unalias();
74extern int dounhash();
75extern int unset();
76extern int dounsetenv();
77
78#define INF 1000
79
80struct biltins {
81 char *bname;
82 int (*bfunct)();
83 short minargs, maxargs;
84} bfunc[] = {
85 "@", dolet, 0, INF,
86 "alias", doalias, 0, INF,
90503b97 87 "alloc", showall, 0, 1,
90503b97
BJ
88 "bg", dobg, 0, INF,
89 "break", dobreak, 0, 0,
90 "breaksw", doswbrk, 0, 0,
91#ifdef IIASA
92 "bye", goodbye, 0, 0,
93#endif
94 "case", dozip, 0, 1,
95 "cd", dochngd, 0, 1,
96 "chdir", dochngd, 0, 1,
97 "continue", docontin, 0, 0,
98 "default", dozip, 0, 0,
99 "dirs", dodirs, 0, 1,
100 "echo", doecho, 0, INF,
101 "else", doelse, 0, INF,
102 "end", doend, 0, 0,
103 "endif", dozip, 0, 0,
104 "endsw", dozip, 0, 0,
105 "eval", doeval, 0, INF,
106 "exec", execash, 1, INF,
107 "exit", doexit, 0, INF,
108 "fg", dofg, 0, INF,
109 "foreach", doforeach, 3, INF,
110#ifdef IIASA
111 "gd", dopushd, 0, 1,
112#endif
113 "glob", doglob, 0, INF,
114 "goto", dogoto, 1, 1,
115#ifdef VFORK
116 "hashstat", hashstat, 0, 0,
117#endif
118 "history", dohist, 0, 2,
119 "if", doif, 1, INF,
120 "jobs", dojobs, 0, 1,
121 "kill", dokill, 1, INF,
122 "limit", dolimit, 0, 3,
123 "login", dologin, 0, 1,
124 "logout", dologout, 0, 0,
6ca601c1 125#ifdef NEWGRP
90503b97 126 "newgrp", donewgrp, 1, 1,
6ca601c1 127#endif
90503b97
BJ
128 "nice", donice, 0, INF,
129 "nohup", donohup, 0, INF,
130 "notify", donotify, 0, INF,
131 "onintr", doonintr, 0, 2,
132 "popd", dopopd, 0, 1,
133 "pushd", dopushd, 0, 1,
134#ifdef IIASA
135 "rd", dopopd, 0, 1,
136#endif
137 "rehash", dohash, 0, 0,
138 "repeat", dorepeat, 2, INF,
139 "set", doset, 0, INF,
c349da0d 140 "setenv", dosetenv, 0, 2,
90503b97 141 "shift", shift, 0, 1,
3d48fab8 142 "source", dosource, 1, 2,
90503b97
BJ
143 "stop", dostop, 1, INF,
144 "suspend", dosuspend, 0, 0,
145 "switch", doswitch, 1, INF,
146 "time", dotime, 0, INF,
147 "umask", doumask, 0, 1,
148 "unalias", unalias, 1, INF,
149 "unhash", dounhash, 0, 0,
150 "unlimit", dounlimit, 0, INF,
151 "unset", unset, 1, INF,
152 "unsetenv", dounsetenv, 1, INF,
153 "wait", dowait, 0, 0,
154 "while", dowhile, 1, INF,
90503b97 155};
35371dec 156int nbfunc = sizeof bfunc / sizeof *bfunc;
90503b97
BJ
157
158#define ZBREAK 0
159#define ZBRKSW 1
160#define ZCASE 2
161#define ZDEFAULT 3
162#define ZELSE 4
163#define ZEND 5
164#define ZENDIF 6
165#define ZENDSW 7
166#define ZEXIT 8
167#define ZFOREACH 9
168#define ZGOTO 10
169#define ZIF 11
170#define ZLABEL 12
171#define ZLET 13
172#define ZSET 14
173#define ZSWITCH 15
174#define ZTEST 16
175#define ZTHEN 17
176#define ZWHILE 18
177
178struct srch {
179 char *s_name;
180 short s_value;
181} srchn[] = {
182 "@", ZLET,
183 "break", ZBREAK,
184 "breaksw", ZBRKSW,
185 "case", ZCASE,
186 "default", ZDEFAULT,
187 "else", ZELSE,
188 "end", ZEND,
189 "endif", ZENDIF,
190 "endsw", ZENDSW,
191 "exit", ZEXIT,
192 "foreach", ZFOREACH,
193 "goto", ZGOTO,
194 "if", ZIF,
195 "label", ZLABEL,
196 "set", ZSET,
197 "switch", ZSWITCH,
198 "while", ZWHILE,
90503b97 199};
35371dec 200int nsrchn = sizeof srchn / sizeof *srchn;
90503b97
BJ
201
202struct mesg {
203 char *iname;
204 char *pname;
205} mesg[] = {
206 0, 0,
207 "HUP", "Hangup",
208 "INT", "Interrupt",
209 "QUIT", "Quit",
210 "ILL", "Illegal instruction",
211 "TRAP", "Trace/BPT trap",
212 "IOT", "IOT trap",
213 "EMT", "EMT trap",
214 "FPE", "Floating exception",
215 "KILL", "Killed",
216 "BUS", "Bus error",
217 "SEGV", "Segmentation fault",
218 "SYS", "Bad system call",
219 "PIPE", "Broken pipe",
220 "ALRM", "Alarm clock",
221 "TERM", "Terminated",
35371dec 222 "URG", "Urgent I/O condition",
90503b97
BJ
223 "STOP", "Stopped (signal)",
224 "TSTP", "Stopped",
225 "CONT", "Continued",
226 "CHLD", "Child exited",
227 "TTIN", "Stopped (tty input)",
228 "TTOU", "Stopped (tty output)",
35371dec 229 "IO", "I/O possible",
90503b97
BJ
230 "XCPU", "Cputime limit exceeded",
231 "XFSZ", "Filesize limit exceeded",
35371dec
EW
232 "VTALRM","Virtual timer expired",
233 "PROF", "Profiling timer expired",
c65b8cef 234 "WINCH","Window size changed",
90503b97 235 0, "Signal 29",
2ec6024a
KM
236 "USR1", "User defined signal 1",
237 "USR2", "User defined signal 2",
90503b97
BJ
238 0, "Signal 32"
239};