nfs: fix real/effective id mismatch in nfs_access
[dragonfly.git] / usr.bin / window / lcmd.c
blob8fecadfff3d714e73bea5e55e65b85e68cf68b21
1 /* $NetBSD: lcmd.c,v 1.9 2009/04/14 08:50:06 lukem Exp $ */
3 /*
4 * Copyright (c) 1983, 1993
5 * The Regents of the University of California. All rights reserved.
7 * This code is derived from software contributed to Berkeley by
8 * Edward Wang at The University of California, Berkeley.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. Neither the name of the University nor the names of its contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
35 #include <sys/cdefs.h>
36 #ifndef lint
37 #if 0
38 static char sccsid[] = "@(#)lcmd.c 8.1 (Berkeley) 6/6/93";
39 #else
40 __RCSID("$NetBSD: lcmd.c,v 1.9 2009/04/14 08:50:06 lukem Exp $");
41 #endif
42 #endif /* not lint */
44 #include "defs.h"
45 #include "lcmd.h"
46 #include "window_string.h"
48 extern struct lcmd_arg arg_alias[];
49 extern struct lcmd_arg arg_cursormodes[];
50 extern struct lcmd_arg arg_debug[];
51 extern struct lcmd_arg arg_echo[];
52 extern struct lcmd_arg arg_escape[];
53 extern struct lcmd_arg arg_foreground[];
54 extern struct lcmd_arg arg_label[];
55 extern struct lcmd_arg arg_def_nline[];
56 extern struct lcmd_arg arg_def_shell[];
57 extern struct lcmd_arg arg_def_smooth[];
58 extern struct lcmd_arg arg_close[];
59 extern struct lcmd_arg arg_select[];
60 extern struct lcmd_arg arg_smooth[];
61 extern struct lcmd_arg arg_source[];
62 extern struct lcmd_arg arg_terse[];
63 extern struct lcmd_arg arg_time[];
64 extern struct lcmd_arg arg_unalias[];
65 extern struct lcmd_arg arg_unset[];
66 extern struct lcmd_arg arg_window[];
67 extern struct lcmd_arg arg_write[];
68 struct lcmd_arg arg_null[1] = { { NULL, 0, 0 } };
70 struct lcmd_tab lcmd_tab[] = {
71 { "alias", 1, l_alias, arg_alias },
72 { "close", 2, l_close, arg_close },
73 { "cursormodes", 2, l_cursormodes, arg_cursormodes },
74 { "debug", 1, l_debug, arg_debug },
75 { "default_nlines", 9, l_def_nline, arg_def_nline },
76 { "default_shell", 10, l_def_shell, arg_def_shell },
77 { "default_smooth", 10, l_def_smooth, arg_def_smooth },
78 { "echo", 2, l_echo, arg_echo },
79 { "escape", 2, l_escape, arg_escape },
80 { "foreground", 1, l_foreground, arg_foreground },
81 { "iostat", 1, l_iostat, arg_null },
82 { "label", 2, l_label, arg_label },
83 { "list", 2, l_list, arg_null },
84 { "nlines", 1, l_def_nline, arg_def_nline },
85 { "select", 2, l_select, arg_select },
86 { "shell", 2, l_def_shell, arg_def_shell },
87 { "smooth", 2, l_smooth, arg_smooth },
88 { "source", 2, l_source, arg_source },
89 { "terse", 2, l_terse, arg_terse },
90 { "time", 2, l_time, arg_time },
91 { "unalias", 3, l_unalias, arg_unalias },
92 { "unset", 3, l_unset, arg_unset },
93 { "variable", 1, l_variable, arg_null },
94 { "window", 2, l_window, arg_window },
95 { "write", 2, l_write, arg_write },
96 { 0, 0, 0, 0 }
99 struct lcmd_tab *
100 lcmd_lookup(const char *name)
102 struct lcmd_tab *p;
104 for (p = lcmd_tab; p->lc_name != 0; p++)
105 if (str_match(name, p->lc_name, p->lc_minlen))
106 return p;
107 return 0;
111 dosource(char *filename)
113 if (cx_beginfile(filename) < 0)
114 return -1;
115 p_start();
116 err_end();
117 cx_end();
118 return 0;
122 dolongcmd(char *buffer, struct value *arg, int narg)
124 if (cx_beginbuf(buffer, arg, narg) < 0)
125 return -1;
126 p_start();
127 err_end();
128 cx_end();
129 return 0;