xref: /original-bsd/usr.bin/window/lcmd.c (revision 883fb6be)
1 #ifndef lint
2 static char sccsid[] = "@(#)lcmd.c	3.25 05/18/87";
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_smooth();
29 int l_source();
30 int l_terse();
31 int l_time();
32 int l_unalias();
33 int l_unset();
34 int l_variable();
35 int l_window();
36 int l_write();
37 
38 struct lcmd_arg arg_alias[];
39 struct lcmd_arg arg_cursormodes[];
40 struct lcmd_arg arg_debug[];
41 struct lcmd_arg arg_echo[];
42 struct lcmd_arg arg_escape[];
43 struct lcmd_arg arg_foreground[];
44 struct lcmd_arg arg_label[];
45 struct lcmd_arg arg_nline[];
46 struct lcmd_arg arg_close[];
47 struct lcmd_arg arg_select[];
48 struct lcmd_arg arg_shell[];
49 struct lcmd_arg arg_smooth[];
50 struct lcmd_arg arg_source[];
51 struct lcmd_arg arg_terse[];
52 struct lcmd_arg arg_time[];
53 struct lcmd_arg arg_unalias[];
54 struct lcmd_arg arg_unset[];
55 struct lcmd_arg arg_window[];
56 struct lcmd_arg arg_write[];
57 struct lcmd_arg arg_null[] = 0;
58 
59 struct lcmd_tab lcmd_tab[] = {
60 	"alias",	1,	l_alias,	arg_alias,
61 	"close",	2,	l_close,	arg_close,
62 	"cursormodes",	2,	l_cursormodes,	arg_cursormodes,
63 	"debug",	1,	l_debug,	arg_debug,
64 	"echo",		2,	l_echo,		arg_echo,
65 	"escape",	2,	l_escape,	arg_escape,
66 	"foreground",	1,	l_foreground,	arg_foreground,
67 	"iostat",	1,	l_iostat,	arg_null,
68 	"label",	2,	l_label,	arg_label,
69 	"list",		2,	l_list,		arg_null,
70 	"nlines",	1,	l_nline,	arg_nline,
71 	"select",	2,	l_select,	arg_select,
72 	"shell",	2,	l_shell,	arg_shell,
73 	"smooth",	2,	l_smooth,	arg_smooth,
74 	"source",	2,	l_source,	arg_source,
75 	"terse",	2,	l_terse,	arg_terse,
76 	"time",		2,	l_time,		arg_time,
77 	"unalias",	3,	l_unalias,	arg_unalias,
78 	"unset",	3,	l_unset,	arg_unset,
79 	"variable",	1,	l_variable,	arg_null,
80 	"window",	2,	l_window,	arg_window,
81 	"write",	2,	l_write,	arg_write,
82 	0
83 };
84 
85 struct lcmd_tab *
86 lcmd_lookup(name)
87 char *name;
88 {
89 	register struct lcmd_tab *p;
90 
91 	for (p = lcmd_tab; p->lc_name != 0; p++)
92 		if (str_match(name, p->lc_name, p->lc_minlen))
93 			return p;
94 	return 0;
95 }
96 
97 dosource(filename)
98 char *filename;
99 {
100 	if (cx_beginfile(filename) < 0)
101 		return -1;
102 	p_start();
103 	err_end();
104 	cx_end();
105 	return 0;
106 }
107 
108 dolongcmd(buffer, arg, narg)
109 char *buffer;
110 struct value *arg;
111 int narg;
112 {
113 	if (cx_beginbuf(buffer, arg, narg) < 0)
114 		return -1;
115 	p_start();
116 	err_end();
117 	cx_end();
118 	return 0;
119 }
120