BSD 4_4 development
[unix-history] / .ref-BSD-4_3_Reno / usr / src / usr.bin / window / lcmd.c
CommitLineData
60de5df9 1/*
46e9ea25
KB
2 * Copyright (c) 1983 Regents of the University of California.
3 * All rights reserved.
4 *
3dd3a9e5
KB
5 * This code is derived from software contributed to Berkeley by
6 * Edward Wang at The University of California, Berkeley.
7 *
1c15e888
C
8 * Redistribution and use in source and binary forms are permitted provided
9 * that: (1) source distributions retain this entire copyright notice and
10 * comment, and (2) distributions including binaries display the following
11 * acknowledgement: ``This product includes software developed by the
12 * University of California, Berkeley and its contributors'' in the
13 * documentation or other materials provided with the distribution and in
14 * all advertising materials mentioning features or use of this software.
15 * Neither the name of the University nor the names of its contributors may
16 * be used to endorse or promote products derived from this software without
17 * specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
19 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
20 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
60de5df9
EW
21 */
22
46e9ea25 23#ifndef lint
1c15e888 24static char sccsid[] = "@(#)lcmd.c 3.34 (Berkeley) 6/6/90";
46e9ea25
KB
25#endif /* not lint */
26
6a571c25 27#include "defs.h"
1c0ca238
EW
28#include "value.h"
29#include "lcmd.h"
6a571c25 30
bb4a0c0b 31int l_alias();
1c0ca238 32int l_close();
7a57b3e2 33int l_cursormodes();
b0640643 34int l_debug();
6a1ef78a
EW
35int l_def_nline();
36int l_def_shell();
37int l_def_smooth();
1b736021 38int l_echo();
6a571c25 39int l_escape();
e1dba5dd 40int l_foreground();
94a746af 41int l_iostat();
6a571c25 42int l_label();
e404c17a 43int l_list();
1c0ca238 44int l_select();
2422abab 45int l_smooth();
6a571c25 46int l_source();
1c0ca238 47int l_terse();
94a746af 48int l_time();
bb4a0c0b 49int l_unalias();
b65b69eb 50int l_unset();
e404c17a 51int l_variable();
1c0ca238 52int l_window();
6a571c25
EW
53int l_write();
54
b15b4a3f
EW
55extern struct lcmd_arg arg_alias[];
56extern struct lcmd_arg arg_cursormodes[];
57extern struct lcmd_arg arg_debug[];
58extern struct lcmd_arg arg_echo[];
59extern struct lcmd_arg arg_escape[];
60extern struct lcmd_arg arg_foreground[];
61extern struct lcmd_arg arg_label[];
6a1ef78a
EW
62extern struct lcmd_arg arg_def_nline[];
63extern struct lcmd_arg arg_def_shell[];
64extern struct lcmd_arg arg_def_smooth[];
b15b4a3f
EW
65extern struct lcmd_arg arg_close[];
66extern struct lcmd_arg arg_select[];
b15b4a3f
EW
67extern struct lcmd_arg arg_smooth[];
68extern struct lcmd_arg arg_source[];
69extern struct lcmd_arg arg_terse[];
70extern struct lcmd_arg arg_time[];
71extern struct lcmd_arg arg_unalias[];
72extern struct lcmd_arg arg_unset[];
73extern struct lcmd_arg arg_window[];
74extern struct lcmd_arg arg_write[];
b7f88b16 75struct lcmd_arg arg_null[1] = { { 0 } };
1c0ca238
EW
76
77struct lcmd_tab lcmd_tab[] = {
6a1ef78a
EW
78 "alias", 1, l_alias, arg_alias,
79 "close", 2, l_close, arg_close,
80 "cursormodes", 2, l_cursormodes, arg_cursormodes,
81 "debug", 1, l_debug, arg_debug,
82 "default_nlines", 9, l_def_nline, arg_def_nline,
3d30c0a6
EW
83 "default_shell", 10, l_def_shell, arg_def_shell,
84 "default_smooth", 10, l_def_smooth, arg_def_smooth,
6a1ef78a
EW
85 "echo", 2, l_echo, arg_echo,
86 "escape", 2, l_escape, arg_escape,
87 "foreground", 1, l_foreground, arg_foreground,
88 "iostat", 1, l_iostat, arg_null,
89 "label", 2, l_label, arg_label,
90 "list", 2, l_list, arg_null,
91 "nlines", 1, l_def_nline, arg_def_nline,
92 "select", 2, l_select, arg_select,
93 "shell", 2, l_def_shell, arg_def_shell,
94 "smooth", 2, l_smooth, arg_smooth,
95 "source", 2, l_source, arg_source,
96 "terse", 2, l_terse, arg_terse,
97 "time", 2, l_time, arg_time,
98 "unalias", 3, l_unalias, arg_unalias,
99 "unset", 3, l_unset, arg_unset,
100 "variable", 1, l_variable, arg_null,
101 "window", 2, l_window, arg_window,
102 "write", 2, l_write, arg_write,
e1dba5dd 103 0
6a571c25
EW
104};
105
1c0ca238
EW
106struct lcmd_tab *
107lcmd_lookup(name)
108char *name;
6a571c25 109{
1c0ca238 110 register struct lcmd_tab *p;
6a571c25 111
1c0ca238
EW
112 for (p = lcmd_tab; p->lc_name != 0; p++)
113 if (str_match(name, p->lc_name, p->lc_minlen))
114 return p;
6a571c25
EW
115 return 0;
116}
117
1c0ca238
EW
118dosource(filename)
119char *filename;
6a571c25 120{
a40a2f9a 121 if (cx_beginfile(filename) < 0)
1c0ca238
EW
122 return -1;
123 p_start();
124 err_end();
125 cx_end();
126 return 0;
6a571c25
EW
127}
128
bb4a0c0b 129dolongcmd(buffer, arg, narg)
1c0ca238 130char *buffer;
bb4a0c0b
EW
131struct value *arg;
132int narg;
6a571c25 133{
bb4a0c0b 134 if (cx_beginbuf(buffer, arg, narg) < 0)
1c0ca238
EW
135 return -1;
136 p_start();
137 err_end();
138 cx_end();
139 return 0;
6a571c25 140}