ANSI
[unix-history] / 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 *
87f529ec 8 * %sccs.include.redist.c%
60de5df9
EW
9 */
10
46e9ea25 11#ifndef lint
3dd3a9e5 12static char sccsid[] = "@(#)lcmd.c 3.34 (Berkeley) %G%";
46e9ea25
KB
13#endif /* not lint */
14
6a571c25 15#include "defs.h"
1c0ca238
EW
16#include "value.h"
17#include "lcmd.h"
6a571c25 18
bb4a0c0b 19int l_alias();
1c0ca238 20int l_close();
7a57b3e2 21int l_cursormodes();
b0640643 22int l_debug();
6a1ef78a
EW
23int l_def_nline();
24int l_def_shell();
25int l_def_smooth();
1b736021 26int l_echo();
6a571c25 27int l_escape();
e1dba5dd 28int l_foreground();
94a746af 29int l_iostat();
6a571c25 30int l_label();
e404c17a 31int l_list();
1c0ca238 32int l_select();
2422abab 33int l_smooth();
6a571c25 34int l_source();
1c0ca238 35int l_terse();
94a746af 36int l_time();
bb4a0c0b 37int l_unalias();
b65b69eb 38int l_unset();
e404c17a 39int l_variable();
1c0ca238 40int l_window();
6a571c25
EW
41int l_write();
42
b15b4a3f
EW
43extern struct lcmd_arg arg_alias[];
44extern struct lcmd_arg arg_cursormodes[];
45extern struct lcmd_arg arg_debug[];
46extern struct lcmd_arg arg_echo[];
47extern struct lcmd_arg arg_escape[];
48extern struct lcmd_arg arg_foreground[];
49extern struct lcmd_arg arg_label[];
6a1ef78a
EW
50extern struct lcmd_arg arg_def_nline[];
51extern struct lcmd_arg arg_def_shell[];
52extern struct lcmd_arg arg_def_smooth[];
b15b4a3f
EW
53extern struct lcmd_arg arg_close[];
54extern struct lcmd_arg arg_select[];
b15b4a3f
EW
55extern struct lcmd_arg arg_smooth[];
56extern struct lcmd_arg arg_source[];
57extern struct lcmd_arg arg_terse[];
58extern struct lcmd_arg arg_time[];
59extern struct lcmd_arg arg_unalias[];
60extern struct lcmd_arg arg_unset[];
61extern struct lcmd_arg arg_window[];
62extern struct lcmd_arg arg_write[];
b7f88b16 63struct lcmd_arg arg_null[1] = { { 0 } };
1c0ca238
EW
64
65struct lcmd_tab lcmd_tab[] = {
6a1ef78a
EW
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,
3d30c0a6
EW
71 "default_shell", 10, l_def_shell, arg_def_shell,
72 "default_smooth", 10, l_def_smooth, arg_def_smooth,
6a1ef78a
EW
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,
e1dba5dd 91 0
6a571c25
EW
92};
93
1c0ca238
EW
94struct lcmd_tab *
95lcmd_lookup(name)
96char *name;
6a571c25 97{
1c0ca238 98 register struct lcmd_tab *p;
6a571c25 99
1c0ca238
EW
100 for (p = lcmd_tab; p->lc_name != 0; p++)
101 if (str_match(name, p->lc_name, p->lc_minlen))
102 return p;
6a571c25
EW
103 return 0;
104}
105
1c0ca238
EW
106dosource(filename)
107char *filename;
6a571c25 108{
a40a2f9a 109 if (cx_beginfile(filename) < 0)
1c0ca238
EW
110 return -1;
111 p_start();
112 err_end();
113 cx_end();
114 return 0;
6a571c25
EW
115}
116
bb4a0c0b 117dolongcmd(buffer, arg, narg)
1c0ca238 118char *buffer;
bb4a0c0b
EW
119struct value *arg;
120int narg;
6a571c25 121{
bb4a0c0b 122 if (cx_beginbuf(buffer, arg, narg) < 0)
1c0ca238
EW
123 return -1;
124 p_start();
125 err_end();
126 cx_end();
127 return 0;
6a571c25 128}