xref: /original-bsd/usr.bin/window/lcmd.c (revision b72553ae)
1 /*
2  * Copyright (c) 1983, 1993
3  *	The Regents of the University of California.  All rights reserved.
4  *
5  * This code is derived from software contributed to Berkeley by
6  * Edward Wang at The University of California, Berkeley.
7  *
8  * %sccs.include.redist.c%
9  */
10 
11 #ifndef lint
12 static char sccsid[] = "@(#)lcmd.c	8.1 (Berkeley) 06/06/93";
13 #endif /* not lint */
14 
15 #include "defs.h"
16 #include "value.h"
17 #include "lcmd.h"
18 
19 int l_alias();
20 int l_close();
21 int l_cursormodes();
22 int l_debug();
23 int l_def_nline();
24 int l_def_shell();
25 int l_def_smooth();
26 int l_echo();
27 int l_escape();
28 int l_foreground();
29 int l_iostat();
30 int l_label();
31 int l_list();
32 int l_select();
33 int l_smooth();
34 int l_source();
35 int l_terse();
36 int l_time();
37 int l_unalias();
38 int l_unset();
39 int l_variable();
40 int l_window();
41 int l_write();
42 
43 extern struct lcmd_arg arg_alias[];
44 extern struct lcmd_arg arg_cursormodes[];
45 extern struct lcmd_arg arg_debug[];
46 extern struct lcmd_arg arg_echo[];
47 extern struct lcmd_arg arg_escape[];
48 extern struct lcmd_arg arg_foreground[];
49 extern struct lcmd_arg arg_label[];
50 extern struct lcmd_arg arg_def_nline[];
51 extern struct lcmd_arg arg_def_shell[];
52 extern struct lcmd_arg arg_def_smooth[];
53 extern struct lcmd_arg arg_close[];
54 extern struct lcmd_arg arg_select[];
55 extern struct lcmd_arg arg_smooth[];
56 extern struct lcmd_arg arg_source[];
57 extern struct lcmd_arg arg_terse[];
58 extern struct lcmd_arg arg_time[];
59 extern struct lcmd_arg arg_unalias[];
60 extern struct lcmd_arg arg_unset[];
61 extern struct lcmd_arg arg_window[];
62 extern struct lcmd_arg arg_write[];
63 struct lcmd_arg arg_null[1] = { { 0 } };
64 
65 struct lcmd_tab lcmd_tab[] = {
66 	"alias",		1,	l_alias,	arg_alias,
67 	"close",		2,	l_close,	arg_close,
68 	"cursormodes",		2,	l_cursormodes,	arg_cursormodes,
69 	"debug",		1,	l_debug,	arg_debug,
70 	"default_nlines",	9,	l_def_nline,	arg_def_nline,
71 	"default_shell",	10,	l_def_shell,	arg_def_shell,
72 	"default_smooth",	10,	l_def_smooth,	arg_def_smooth,
73 	"echo",			2,	l_echo,		arg_echo,
74 	"escape",		2,	l_escape,	arg_escape,
75 	"foreground",		1,	l_foreground,	arg_foreground,
76 	"iostat",		1,	l_iostat,	arg_null,
77 	"label",		2,	l_label,	arg_label,
78 	"list",			2,	l_list,		arg_null,
79 	"nlines",		1,	l_def_nline,	arg_def_nline,
80 	"select",		2,	l_select,	arg_select,
81 	"shell",		2,	l_def_shell,	arg_def_shell,
82 	"smooth",		2,	l_smooth,	arg_smooth,
83 	"source",		2,	l_source,	arg_source,
84 	"terse",		2,	l_terse,	arg_terse,
85 	"time",			2,	l_time,		arg_time,
86 	"unalias",		3,	l_unalias,	arg_unalias,
87 	"unset",		3,	l_unset,	arg_unset,
88 	"variable",		1,	l_variable,	arg_null,
89 	"window",		2,	l_window,	arg_window,
90 	"write",		2,	l_write,	arg_write,
91 	0
92 };
93 
94 struct lcmd_tab *
lcmd_lookup(name)95 lcmd_lookup(name)
96 char *name;
97 {
98 	register struct lcmd_tab *p;
99 
100 	for (p = lcmd_tab; p->lc_name != 0; p++)
101 		if (str_match(name, p->lc_name, p->lc_minlen))
102 			return p;
103 	return 0;
104 }
105 
dosource(filename)106 dosource(filename)
107 char *filename;
108 {
109 	if (cx_beginfile(filename) < 0)
110 		return -1;
111 	p_start();
112 	err_end();
113 	cx_end();
114 	return 0;
115 }
116 
dolongcmd(buffer,arg,narg)117 dolongcmd(buffer, arg, narg)
118 char *buffer;
119 struct value *arg;
120 int narg;
121 {
122 	if (cx_beginbuf(buffer, arg, narg) < 0)
123 		return -1;
124 	p_start();
125 	err_end();
126 	cx_end();
127 	return 0;
128 }
129