init.c revision 1.8 1 /* $NetBSD: init.c,v 1.8 2001/09/14 14:04:00 wiz Exp $ */
2
3 /*-
4 * Copyright (c) 1980, 1991, 1993
5 * The Regents of the University of California. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by the University of
18 * California, Berkeley and its contributors.
19 * 4. Neither the name of the University nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
34 */
35
36 #include <sys/cdefs.h>
37 #ifndef lint
38 #if 0
39 static char sccsid[] = "@(#)init.c 8.1 (Berkeley) 5/31/93";
40 #else
41 __RCSID("$NetBSD: init.c,v 1.8 2001/09/14 14:04:00 wiz Exp $");
42 #endif
43 #endif /* not lint */
44
45 #if __STDC__
46 # include <stdarg.h>
47 #else
48 # include <varargs.h>
49 #endif
50
51 #include "csh.h"
52 #include "extern.h"
53
54 #define INF 1000
55
56 struct biltins bfunc[] =
57 {
58 { "@", dolet, 0, INF },
59 { "alias", doalias, 0, INF },
60 { "alloc", showall, 0, 1 },
61 { "bg", dobg, 0, INF },
62 { "break", dobreak, 0, 0 },
63 { "breaksw", doswbrk, 0, 0 },
64 { "case", dozip, 0, 1 },
65 { "cd", dochngd, 0, INF },
66 { "chdir", dochngd, 0, INF },
67 { "continue", docontin, 0, 0 },
68 { "default", dozip, 0, 0 },
69 { "dirs", dodirs, 0, INF },
70 { "echo", doecho, 0, INF },
71 { "else", doelse, 0, INF },
72 { "end", doend, 0, 0 },
73 { "endif", dozip, 0, 0 },
74 { "endsw", dozip, 0, 0 },
75 { "eval", doeval, 0, INF },
76 { "exec", execash, 1, INF },
77 { "exit", doexit, 0, INF },
78 { "fg", dofg, 0, INF },
79 { "foreach", doforeach, 3, INF },
80 { "glob", doglob, 0, INF },
81 { "goto", dogoto, 1, 1 },
82 { "hashstat", hashstat, 0, 0 },
83 { "history", dohist, 0, 2 },
84 { "if", doif, 1, INF },
85 { "jobs", dojobs, 0, 1 },
86 { "kill", dokill, 1, INF },
87 { "limit", dolimit, 0, 3 },
88 { "linedit", doecho, 0, INF },
89 { "login", dologin, 0, 1 },
90 { "logout", dologout, 0, 0 },
91 { "nice", donice, 0, INF },
92 { "nohup", donohup, 0, INF },
93 { "notify", donotify, 0, INF },
94 { "onintr", doonintr, 0, 2 },
95 { "popd", dopopd, 0, INF },
96 { "printf", doprintf, 1, INF },
97 { "pushd", dopushd, 0, INF },
98 { "rehash", dohash, 0, 0 },
99 { "repeat", dorepeat, 2, INF },
100 { "set", doset, 0, INF },
101 { "setenv", dosetenv, 0, 2 },
102 { "shift", shift, 0, 1 },
103 { "source", dosource, 1, 2 },
104 { "stop", dostop, 1, INF },
105 { "suspend", dosuspend, 0, 0 },
106 { "switch", doswitch, 1, INF },
107 { "time", dotime, 0, INF },
108 { "umask", doumask, 0, 1 },
109 { "unalias", unalias, 1, INF },
110 { "unhash", dounhash, 0, 0 },
111 { "unlimit", dounlimit, 0, INF },
112 { "unset", unset, 1, INF },
113 { "unsetenv", dounsetenv, 1, INF },
114 { "wait", dowait, 0, 0 },
115 { "which", dowhich, 1, INF },
116 { "while", dowhile, 1, INF }
117 };
118 int nbfunc = sizeof(bfunc) / sizeof(*bfunc);
119
120 struct srch srchn[] =
121 {
122 { "@", T_LET },
123 { "break", T_BREAK },
124 { "breaksw", T_BRKSW },
125 { "case", T_CASE },
126 { "default", T_DEFAULT },
127 { "else", T_ELSE },
128 { "end", T_END },
129 { "endif", T_ENDIF },
130 { "endsw", T_ENDSW },
131 { "exit", T_EXIT },
132 { "foreach", T_FOREACH },
133 { "goto", T_GOTO },
134 { "if", T_IF },
135 { "label", T_LABEL },
136 { "set", T_SET },
137 { "switch", T_SWITCH },
138 { "while", T_WHILE }
139 };
140 int nsrchn = sizeof(srchn) / sizeof(*srchn);
141