Home | History | Annotate | Line # | Download | only in csh
init.c revision 1.1
      1 /*-
      2  * Copyright (c) 1980, 1991 The Regents of the University of California.
      3  * All rights reserved.
      4  *
      5  * Redistribution and use in source and binary forms, with or without
      6  * modification, are permitted provided that the following conditions
      7  * are met:
      8  * 1. Redistributions of source code must retain the above copyright
      9  *    notice, this list of conditions and the following disclaimer.
     10  * 2. Redistributions in binary form must reproduce the above copyright
     11  *    notice, this list of conditions and the following disclaimer in the
     12  *    documentation and/or other materials provided with the distribution.
     13  * 3. All advertising materials mentioning features or use of this software
     14  *    must display the following acknowledgement:
     15  *	This product includes software developed by the University of
     16  *	California, Berkeley and its contributors.
     17  * 4. Neither the name of the University nor the names of its contributors
     18  *    may be used to endorse or promote products derived from this software
     19  *    without specific prior written permission.
     20  *
     21  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     22  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     24  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     25  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     26  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     27  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     28  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     29  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     30  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     31  * SUCH DAMAGE.
     32  */
     33 
     34 #ifndef lint
     35 static char sccsid[] = "@(#)init.c	5.12 (Berkeley) 6/27/91";
     36 #endif /* not lint */
     37 
     38 #if __STDC__
     39 # include <stdarg.h>
     40 #else
     41 # include <varargs.h>
     42 #endif
     43 
     44 #include "csh.h"
     45 #include "extern.h"
     46 
     47 #define	INF	1000
     48 
     49 struct biltins bfunc[] =
     50 {
     51     "@", 	dolet, 		0, INF,
     52     "alias", 	doalias, 	0, INF,
     53     "alloc", 	showall, 	0, 1,
     54     "bg", 	dobg, 		0, INF,
     55     "break", 	dobreak, 	0, 0,
     56     "breaksw", 	doswbrk, 	0, 0,
     57     "case", 	dozip, 		0, 1,
     58     "cd", 	dochngd, 	0, INF,
     59     "chdir", 	dochngd, 	0, INF,
     60     "continue", docontin, 	0, 0,
     61     "default", 	dozip, 		0, 0,
     62     "dirs", 	dodirs,		0, INF,
     63     "echo", 	doecho,		0, INF,
     64     "else", 	doelse,		0, INF,
     65     "end", 	doend, 		0, 0,
     66     "endif", 	dozip, 		0, 0,
     67     "endsw", 	dozip, 		0, 0,
     68     "eval", 	doeval, 	0, INF,
     69     "exec", 	execash, 	1, INF,
     70     "exit", 	doexit, 	0, INF,
     71     "fg", 	dofg, 		0, INF,
     72     "foreach", 	doforeach, 	3, INF,
     73     "glob", 	doglob, 	0, INF,
     74     "goto", 	dogoto, 	1, 1,
     75     "hashstat", hashstat, 	0, 0,
     76     "history", 	dohist, 	0, 2,
     77     "if", 	doif, 		1, INF,
     78     "jobs", 	dojobs, 	0, 1,
     79     "kill", 	dokill, 	1, INF,
     80     "limit", 	dolimit, 	0, 3,
     81     "linedit", 	doecho, 	0, INF,
     82     "login", 	dologin, 	0, 1,
     83     "logout", 	dologout, 	0, 0,
     84     "nice", 	donice, 	0, INF,
     85     "nohup", 	donohup, 	0, INF,
     86     "notify", 	donotify, 	0, INF,
     87     "onintr", 	doonintr, 	0, 2,
     88     "popd", 	dopopd, 	0, INF,
     89     "pushd", 	dopushd, 	0, INF,
     90     "rehash", 	dohash, 	0, 0,
     91     "repeat", 	dorepeat, 	2, INF,
     92     "set", 	doset, 		0, INF,
     93     "setenv", 	dosetenv, 	0, 2,
     94     "shift", 	shift, 		0, 1,
     95     "source", 	dosource, 	1, 2,
     96     "stop", 	dostop, 	1, INF,
     97     "suspend", 	dosuspend, 	0, 0,
     98     "switch", 	doswitch, 	1, INF,
     99     "time", 	dotime, 	0, INF,
    100     "umask", 	doumask, 	0, 1,
    101     "unalias", 	unalias, 	1, INF,
    102     "unhash", 	dounhash, 	0, 0,
    103     "unlimit", 	dounlimit, 	0, INF,
    104     "unset", 	unset, 		1, INF,
    105     "unsetenv", dounsetenv, 	1, INF,
    106     "wait", 	dowait, 	0, 0,
    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 struct mesg mesg[] =
    134 {
    135      /*  0 */ 	0, 		"",
    136      /*  1 */ 	"HUP", 		"Hangup",
    137      /*  2 */ 	"INT", 		"Interrupt",
    138      /*  3 */ 	"QUIT", 	"Quit",
    139      /*  4 */ 	"ILL", 		"Illegal instruction",
    140      /*  5 */ 	"TRAP", 	"Trace/BPT trap",
    141      /*  6 */ 	"IOT", 		"IOT trap",
    142      /*  7 */ 	"EMT", 		"EMT trap",
    143      /*  8 */ 	"FPE", 		"Floating exception",
    144      /*  9 */ 	"KILL", 	"Killed",
    145      /* 10 */ 	"BUS", 		"Bus error",
    146      /* 11 */ 	"SEGV", 	"Segmentation fault",
    147      /* 12 */ 	"SYS", 		"Bad system call",
    148      /* 13 */ 	"PIPE", 	"Broken pipe",
    149      /* 14 */ 	"ALRM", 	"Alarm clock",
    150      /* 15 */ 	"TERM", 	"Terminated",
    151      /* 16 */ 	"URG", 		"Urgent condition on IO channel",
    152      /* 17 */ 	"STOP", 	"Suspended (signal)",
    153      /* 18 */ 	"TSTP", 	"Suspended",
    154      /* 19 */ 	"CONT", 	"Continued",
    155      /* 20 */ 	"CHLD", 	"Child exited",
    156      /* 21 */ 	"TTIN", 	"Suspended (tty input)",
    157      /* 22 */ 	"TTOU", 	"Suspended (tty output)",
    158      /* 23 */ 	"IO", 		"IO possible interrupt",
    159      /* 24 */ 	"XCPU", 	"Cputime limit exceeded",
    160      /* 25 */ 	"XFSZ", 	"Filesize limit exceeded",
    161      /* 26 */ 	"VTALRM", 	"Virtual time alarm",
    162      /* 27 */ 	"PROF", 	"Profiling time alarm",
    163      /* 28 */ 	"WINCH", 	"Window changed",
    164      /* 29 */ 	"INFO", 	"Information request",
    165      /* 30 */ 	"USR1", 	"User signal 1",
    166      /* 31 */ 	"USR2", 	"User signal 2",
    167      /* 32 */ 	0, 		"Signal 32",
    168 };
    169