1 /* @(#)lcmd.c 8.1 (Berkeley) 6/6/93 */
2 /* $NetBSD: lcmd.c,v 1.9 2009/04/14 08:50:06 lukem Exp $ */
5 * Copyright (c) 1983, 1993
6 * The Regents of the University of California. All rights reserved.
8 * This code is derived from software contributed to Berkeley by
9 * Edward Wang at The University of California, Berkeley.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. 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.
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
38 #include "window_string.h"
40 extern struct lcmd_arg arg_alias
[];
41 extern struct lcmd_arg arg_cursormodes
[];
42 extern struct lcmd_arg arg_debug
[];
43 extern struct lcmd_arg arg_echo
[];
44 extern struct lcmd_arg arg_escape
[];
45 extern struct lcmd_arg arg_foreground
[];
46 extern struct lcmd_arg arg_label
[];
47 extern struct lcmd_arg arg_def_nline
[];
48 extern struct lcmd_arg arg_def_shell
[];
49 extern struct lcmd_arg arg_def_smooth
[];
50 extern struct lcmd_arg arg_close
[];
51 extern struct lcmd_arg arg_select
[];
52 extern struct lcmd_arg arg_smooth
[];
53 extern struct lcmd_arg arg_source
[];
54 extern struct lcmd_arg arg_terse
[];
55 extern struct lcmd_arg arg_time
[];
56 extern struct lcmd_arg arg_unalias
[];
57 extern struct lcmd_arg arg_unset
[];
58 extern struct lcmd_arg arg_window
[];
59 extern struct lcmd_arg arg_write
[];
60 struct lcmd_arg arg_null
[1] = { { NULL
, 0, 0 } };
62 struct lcmd_tab lcmd_tab
[] = {
63 { "alias", 1, l_alias
, arg_alias
},
64 { "close", 2, l_close
, arg_close
},
65 { "cursormodes", 2, l_cursormodes
, arg_cursormodes
},
66 { "debug", 1, l_debug
, arg_debug
},
67 { "default_nlines", 9, l_def_nline
, arg_def_nline
},
68 { "default_shell", 10, l_def_shell
, arg_def_shell
},
69 { "default_smooth", 10, l_def_smooth
, arg_def_smooth
},
70 { "echo", 2, l_echo
, arg_echo
},
71 { "escape", 2, l_escape
, arg_escape
},
72 { "foreground", 1, l_foreground
, arg_foreground
},
73 { "iostat", 1, l_iostat
, arg_null
},
74 { "label", 2, l_label
, arg_label
},
75 { "list", 2, l_list
, arg_null
},
76 { "nlines", 1, l_def_nline
, arg_def_nline
},
77 { "select", 2, l_select
, arg_select
},
78 { "shell", 2, l_def_shell
, arg_def_shell
},
79 { "smooth", 2, l_smooth
, arg_smooth
},
80 { "source", 2, l_source
, arg_source
},
81 { "terse", 2, l_terse
, arg_terse
},
82 { "time", 2, l_time
, arg_time
},
83 { "unalias", 3, l_unalias
, arg_unalias
},
84 { "unset", 3, l_unset
, arg_unset
},
85 { "variable", 1, l_variable
, arg_null
},
86 { "window", 2, l_window
, arg_window
},
87 { "write", 2, l_write
, arg_write
},
92 lcmd_lookup(const char *name
)
96 for (p
= lcmd_tab
; p
->lc_name
!= 0; p
++)
97 if (str_match(name
, p
->lc_name
, p
->lc_minlen
))
103 dosource(char *filename
)
105 if (cx_beginfile(filename
) < 0)
114 dolongcmd(char *buffer
, struct value
*arg
, int narg
)
116 if (cx_beginbuf(buffer
, arg
, narg
) < 0)