Annotation of src/usr.bin/window/lcmd.c, Revision 1.4
1.4 ! mpech 1: /* $OpenBSD: lcmd.c,v 1.3 1997/02/25 00:04:05 downsj Exp $ */
1.1 deraadt 2: /* $NetBSD: lcmd.c,v 1.3 1995/09/28 10:34:21 tls Exp $ */
3:
4: /*
5: * Copyright (c) 1983, 1993
6: * The Regents of the University of California. All rights reserved.
7: *
8: * This code is derived from software contributed to Berkeley by
9: * Edward Wang at The University of California, Berkeley.
10: *
11: * Redistribution and use in source and binary forms, with or without
12: * modification, are permitted provided that the following conditions
13: * are met:
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. All advertising materials mentioning features or use of this software
20: * must display the following acknowledgement:
21: * This product includes software developed by the University of
22: * California, Berkeley and its contributors.
23: * 4. Neither the name of the University nor the names of its contributors
24: * may be used to endorse or promote products derived from this software
25: * without specific prior written permission.
26: *
27: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
28: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
31: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
33: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
36: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37: * SUCH DAMAGE.
38: */
39:
40: #ifndef lint
41: #if 0
42: static char sccsid[] = "@(#)lcmd.c 8.1 (Berkeley) 6/6/93";
43: #else
1.4 ! mpech 44: static char rcsid[] = "$OpenBSD: lcmd.c,v 1.3 1997/02/25 00:04:05 downsj Exp $";
1.1 deraadt 45: #endif
46: #endif /* not lint */
47:
48: #include "defs.h"
49: #include "value.h"
50: #include "lcmd.h"
51:
52: int l_alias();
53: int l_close();
54: int l_cursormodes();
55: int l_debug();
56: int l_def_nline();
57: int l_def_shell();
58: int l_def_smooth();
59: int l_echo();
60: int l_escape();
61: int l_foreground();
62: int l_iostat();
63: int l_label();
64: int l_list();
65: int l_select();
66: int l_smooth();
67: int l_source();
68: int l_terse();
69: int l_time();
70: int l_unalias();
71: int l_unset();
72: int l_variable();
73: int l_window();
74: int l_write();
75:
76: extern struct lcmd_arg arg_alias[];
77: extern struct lcmd_arg arg_cursormodes[];
78: extern struct lcmd_arg arg_debug[];
79: extern struct lcmd_arg arg_echo[];
80: extern struct lcmd_arg arg_escape[];
81: extern struct lcmd_arg arg_foreground[];
82: extern struct lcmd_arg arg_label[];
83: extern struct lcmd_arg arg_def_nline[];
84: extern struct lcmd_arg arg_def_shell[];
85: extern struct lcmd_arg arg_def_smooth[];
86: extern struct lcmd_arg arg_close[];
87: extern struct lcmd_arg arg_select[];
88: extern struct lcmd_arg arg_smooth[];
89: extern struct lcmd_arg arg_source[];
90: extern struct lcmd_arg arg_terse[];
91: extern struct lcmd_arg arg_time[];
92: extern struct lcmd_arg arg_unalias[];
93: extern struct lcmd_arg arg_unset[];
94: extern struct lcmd_arg arg_window[];
95: extern struct lcmd_arg arg_write[];
96: struct lcmd_arg arg_null[1] = { { 0 } };
97:
98: struct lcmd_tab lcmd_tab[] = {
99: "alias", 1, l_alias, arg_alias,
100: "close", 2, l_close, arg_close,
101: "cursormodes", 2, l_cursormodes, arg_cursormodes,
102: "debug", 1, l_debug, arg_debug,
103: "default_nlines", 9, l_def_nline, arg_def_nline,
104: "default_shell", 10, l_def_shell, arg_def_shell,
105: "default_smooth", 10, l_def_smooth, arg_def_smooth,
106: "echo", 2, l_echo, arg_echo,
107: "escape", 2, l_escape, arg_escape,
108: "foreground", 1, l_foreground, arg_foreground,
109: "iostat", 1, l_iostat, arg_null,
110: "label", 2, l_label, arg_label,
111: "list", 2, l_list, arg_null,
112: "nlines", 1, l_def_nline, arg_def_nline,
113: "select", 2, l_select, arg_select,
114: "shell", 2, l_def_shell, arg_def_shell,
115: "smooth", 2, l_smooth, arg_smooth,
116: "source", 2, l_source, arg_source,
117: "terse", 2, l_terse, arg_terse,
118: "time", 2, l_time, arg_time,
119: "unalias", 3, l_unalias, arg_unalias,
120: "unset", 3, l_unset, arg_unset,
121: "variable", 1, l_variable, arg_null,
122: "window", 2, l_window, arg_window,
123: "write", 2, l_write, arg_write,
124: 0
125: };
126:
127: struct lcmd_tab *
128: lcmd_lookup(name)
129: char *name;
130: {
1.4 ! mpech 131: struct lcmd_tab *p;
1.1 deraadt 132:
133: for (p = lcmd_tab; p->lc_name != 0; p++)
134: if (str_match(name, p->lc_name, p->lc_minlen))
135: return p;
136: return 0;
137: }
138:
139: dosource(filename)
140: char *filename;
141: {
142: if (cx_beginfile(filename) < 0)
143: return -1;
144: p_start();
145: err_end();
146: cx_end();
147: return 0;
148: }
149:
150: dolongcmd(buffer, arg, narg)
151: char *buffer;
152: struct value *arg;
153: int narg;
154: {
155: if (cx_beginbuf(buffer, arg, narg) < 0)
156: return -1;
157: p_start();
158: err_end();
159: cx_end();
160: return 0;
161: }