added "more" command
[unix-history] / usr / src / usr.bin / window / lcmd.c
CommitLineData
6a571c25 1#ifndef lint
60de5df9 2static char sccsid[] = "@(#)lcmd.c 3.24 %G%";
6a571c25
EW
3#endif
4
60de5df9
EW
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
6a571c25 11#include "defs.h"
1c0ca238
EW
12#include "value.h"
13#include "lcmd.h"
6a571c25 14
bb4a0c0b 15int l_alias();
1c0ca238 16int l_close();
7a57b3e2 17int l_cursormodes();
b0640643 18int l_debug();
1b736021 19int l_echo();
6a571c25 20int l_escape();
e1dba5dd 21int l_foreground();
94a746af 22int l_iostat();
6a571c25 23int l_label();
e404c17a 24int l_list();
1f12ea41 25int l_nline();
1c0ca238 26int l_select();
7ecf4dca 27int l_shell();
6a571c25 28int l_source();
1c0ca238 29int l_terse();
94a746af 30int l_time();
bb4a0c0b 31int l_unalias();
b65b69eb 32int l_unset();
e404c17a 33int l_variable();
1c0ca238 34int l_window();
6a571c25
EW
35int l_write();
36
bb4a0c0b 37struct lcmd_arg arg_alias[];
7a57b3e2 38struct lcmd_arg arg_cursormodes[];
b0640643 39struct lcmd_arg arg_debug[];
1b736021 40struct lcmd_arg arg_echo[];
1c0ca238 41struct lcmd_arg arg_escape[];
e1dba5dd 42struct lcmd_arg arg_foreground[];
1c0ca238 43struct lcmd_arg arg_label[];
1f12ea41 44struct lcmd_arg arg_nline[];
855d0f8f 45struct lcmd_arg arg_close[];
1c0ca238 46struct lcmd_arg arg_select[];
7ecf4dca 47struct lcmd_arg arg_shell[];
1c0ca238
EW
48struct lcmd_arg arg_source[];
49struct lcmd_arg arg_terse[];
94a746af 50struct lcmd_arg arg_time[];
bb4a0c0b 51struct lcmd_arg arg_unalias[];
b65b69eb 52struct lcmd_arg arg_unset[];
1c0ca238 53struct lcmd_arg arg_window[];
855d0f8f 54struct lcmd_arg arg_write[];
e404c17a 55struct lcmd_arg arg_null[] = 0;
1c0ca238
EW
56
57struct lcmd_tab lcmd_tab[] = {
bb4a0c0b 58 "alias", 1, l_alias, arg_alias,
855d0f8f 59 "close", 2, l_close, arg_close,
7a57b3e2 60 "cursormodes", 2, l_cursormodes, arg_cursormodes,
b0640643 61 "debug", 1, l_debug, arg_debug,
1b736021
EW
62 "echo", 2, l_echo, arg_echo,
63 "escape", 2, l_escape, arg_escape,
e1dba5dd 64 "foreground", 1, l_foreground, arg_foreground,
e404c17a
EW
65 "iostat", 1, l_iostat, arg_null,
66 "label", 2, l_label, arg_label,
67 "list", 2, l_list, arg_null,
1f12ea41 68 "nlines", 1, l_nline, arg_nline,
1c0ca238 69 "select", 2, l_select, arg_select,
7ecf4dca 70 "shell", 2, l_shell, arg_shell,
1c0ca238 71 "source", 2, l_source, arg_source,
94a746af
EW
72 "terse", 2, l_terse, arg_terse,
73 "time", 2, l_time, arg_time,
bb4a0c0b
EW
74 "unalias", 3, l_unalias, arg_unalias,
75 "unset", 3, l_unset, arg_unset,
e404c17a 76 "variable", 1, l_variable, arg_null,
1c0ca238 77 "window", 2, l_window, arg_window,
855d0f8f 78 "write", 2, l_write, arg_write,
e1dba5dd 79 0
6a571c25
EW
80};
81
1c0ca238
EW
82struct lcmd_tab *
83lcmd_lookup(name)
84char *name;
6a571c25 85{
1c0ca238 86 register struct lcmd_tab *p;
6a571c25 87
1c0ca238
EW
88 for (p = lcmd_tab; p->lc_name != 0; p++)
89 if (str_match(name, p->lc_name, p->lc_minlen))
90 return p;
6a571c25
EW
91 return 0;
92}
93
1c0ca238
EW
94dosource(filename)
95char *filename;
6a571c25 96{
a40a2f9a 97 if (cx_beginfile(filename) < 0)
1c0ca238
EW
98 return -1;
99 p_start();
100 err_end();
101 cx_end();
102 return 0;
6a571c25
EW
103}
104
bb4a0c0b 105dolongcmd(buffer, arg, narg)
1c0ca238 106char *buffer;
bb4a0c0b
EW
107struct value *arg;
108int narg;
6a571c25 109{
bb4a0c0b 110 if (cx_beginbuf(buffer, arg, narg) < 0)
1c0ca238
EW
111 return -1;
112 p_start();
113 err_end();
114 cx_end();
115 return 0;
6a571c25 116}