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