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