BSD 4_4 release
[unix-history] / usr / src / contrib / nvi / nvi / ex / excmd.h.stub
CommitLineData
ad787160
C
1/*-
2 * Copyright (c) 1992, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * @(#)excmd.h.stub 8.1 (Berkeley) 6/9/93
34 */
35
36struct _excmdarg;
37
38/* Ex command structure. */
39typedef struct _excmdlist {
40 char *name; /* Command name. */
41 /* Underlying function. */
42 int (*fn) __P((SCR *, EXF *, struct _excmdarg *));
43
44#define E_ADDR1 0x00001 /* One address. */
45#define E_ADDR2 0x00002 /* Two address. */
46#define E_ADDR2_ALL 0x00004 /* Zero/two addresses; zero == all. */
47#define E_ADDR2_NONE 0x00008 /* Zero/two addresses; zero == none. */
48#define E_FORCE 0x00010 /* ! */
49
50#define E_F_CARAT 0x00020 /* ^ flag. */
51#define E_F_DASH 0x00040 /* - flag. */
52#define E_F_DOT 0x00080 /* . flag. */
53#define E_F_HASH 0x00100 /* # flag. */
54#define E_F_LIST 0x00200 /* l flag. */
55#define E_F_PLUS 0x00400 /* + flag. */
56#define E_F_PRINT 0x00800 /* p flag. */
57#define E_F_MASK 0x00fe0 /* Flag mask. */
58#define E_F_PRCLEAR 0x01000 /* Clear the print (#, l, p) flags. */
59
60#define E_NOGLOBAL 0x02000 /* Not in a global. */
61#define E_NOPERM 0x04000 /* Permission denied for now. */
62#define E_NORC 0x08000 /* Not from a .exrc or EXINIT. */
63#define E_SETLAST 0x10000 /* Reset last command. */
64#define E_ZERO 0x20000 /* 0 is a legal addr1. */
65#define E_ZERODEF 0x40000 /* 0 is default addr1 of empty files. */
66 u_int flags;
67 char *syntax; /* Syntax script. */
68 char *usage; /* Usage line. */
69} EXCMDLIST;
70extern EXCMDLIST cmds[]; /* List of ex commands. */
71
72/* Structure passed around to functions implementing ex commands. */
73typedef struct _excmdarg {
74 EXCMDLIST *cmd; /* Command entry in command table. */
75 int addrcnt; /* Number of addresses (0, 1 or 2). */
76 MARK addr1; /* 1st address. */
77 MARK addr2; /* 2nd address. */
78 recno_t lineno; /* Line number. */
79 u_int flags; /* Selected flags from EXCMDLIST. */
80 int argc; /* Count of file/word arguments. */
81 char **argv; /* List of file/word arguments. */
82 char *command; /* Command line, if parse locally. */
83 char *plus; /* '+' command word. */
84 char *string; /* String. */
85 int buffer; /* Named buffer. */
86} EXCMDARG;
87
88extern char *defcmdarg[2]; /* Default array. */
89
90/* Macro to set up the structure. */
91#define SETCMDARG(s, _cmd, _addrcnt, _lno1, _lno2, _force, _arg) { \
92 memset(&s, 0, sizeof(EXCMDARG)); \
93 s.cmd = &cmds[_cmd]; \
94 s.addrcnt = (_addrcnt); \
95 s.addr1.lno = (_lno1); \
96 s.addr2.lno = (_lno2); \
97 s.addr1.cno = s.addr2.cno = 1; \
98 if (_force) \
99 s.flags |= E_FORCE; \
100 s.argc = _arg ? 1 : 0; \
101 s.argv = defcmdarg; \
102 s.string = ""; \
103 defcmdarg[0] = _arg; \
104}
105
106/* Control character. */
107#define ctrl(ch) ((ch) & 0x1f)
108
109#define AUTOWRITE(sp, ep) { \
110 if (F_ISSET((ep), F_MODIFIED) && O_ISSET((sp), O_AUTOWRITE) && \
111 file_write((sp), (ep), NULL, NULL, NULL, FS_ALL)) \
112 return (1); \
113}
114
115#define MODIFY_CHECK(sp, ep, force) { \
116 if (F_ISSET((ep), F_MODIFIED)) \
117 if (O_ISSET((sp), O_AUTOWRITE)) { \
118 if (file_write((sp), (ep), NULL, NULL, NULL, \
119 FS_ALL | force?FS_FORCE:0 | FS_POSSIBLE)) \
120 return (1); \
121 } else if (ep->refcnt <= 1 && !(force)) { \
122 msgq(sp, M_ERR, \
123 "Modified since last write; write or use ! to override."); \
124 return (1); \
125 } \
126}
127
128#define MODIFY_WARN(sp, ep) { \
129 if (F_ISSET(ep, F_MODIFIED) && O_ISSET(sp, O_WARN)) \
130 (void)fprintf(sp->stdfp, \
131 "Modified since last write.\n"); \
132}
133
134/* Ex function prototypes. */
135int buildargv __P((SCR *, EXF *, char *, int, int *, char ***));
136int esystem __P((SCR *, const u_char *, const u_char *));
137int ex_run_process __P((SCR *, char *, size_t *, char *, size_t));
138void set_altfname __P((SCR *, char *));
139
140int ex __P((SCR *, EXF *));
141int ex_cfile __P((SCR *, EXF *, char *, int));
142int ex_cmd __P((SCR *, EXF *, char *));
143int ex_cstring __P((SCR *, EXF *, char *, int));
144int ex_end __P((SCR *));
145int ex_gb __P((SCR *, EXF *, HDR *, int, u_int));
146int ex_getline __P((SCR *, FILE *, size_t *));
147int ex_init __P((SCR *, EXF *));
148int ex_print __P((SCR *, EXF *, MARK *, MARK *, int));
149int ex_readfp __P((SCR *, EXF *, char *, FILE *, MARK *, recno_t *));
150int ex_suspend __P((SCR *));
151int ex_writefp __P((SCR *, EXF *, char *, FILE *, MARK *, MARK *, int));
152void ex_refresh __P((SCR *, EXF *));
153
154#define EXPROTO(type, name) \
155 type name __P((SCR *, EXF *, EXCMDARG *));
156
157EXPROTO(int, ex_abbr);
158EXPROTO(int, ex_append);
159EXPROTO(int, ex_args);
160EXPROTO(int, ex_at);
161EXPROTO(int, ex_bang);
162EXPROTO(int, ex_bdisplay);
163EXPROTO(int, ex_cc);
164EXPROTO(int, ex_cd);
165EXPROTO(int, ex_change);
166EXPROTO(int, ex_color);
167EXPROTO(int, ex_copy);
168EXPROTO(int, ex_debug);
169EXPROTO(int, ex_delete);
170EXPROTO(int, ex_digraph);
171EXPROTO(int, ex_edit);
172EXPROTO(int, ex_equal);
173EXPROTO(int, ex_errlist);
174EXPROTO(int, ex_file);
175EXPROTO(int, ex_global);
176EXPROTO(int, ex_join);
177EXPROTO(int, ex_list);
178EXPROTO(int, ex_make);
179EXPROTO(int, ex_map);
180EXPROTO(int, ex_mark);
181EXPROTO(int, ex_mkexrc);
182EXPROTO(int, ex_move);
183EXPROTO(int, ex_next);
184EXPROTO(int, ex_number);
185EXPROTO(int, ex_pr);
186EXPROTO(int, ex_preserve);
187EXPROTO(int, ex_prev);
188EXPROTO(int, ex_put);
189EXPROTO(int, ex_quit);
190EXPROTO(int, ex_read);
191EXPROTO(int, ex_rew);
192EXPROTO(int, ex_set);
193EXPROTO(int, ex_shell);
194EXPROTO(int, ex_shiftl);
195EXPROTO(int, ex_shiftr);
196EXPROTO(int, ex_source);
197EXPROTO(int, ex_split);
198EXPROTO(int, ex_stop);
199EXPROTO(int, ex_subagain);
200EXPROTO(int, ex_substitute);
201EXPROTO(int, ex_tagpop);
202EXPROTO(int, ex_tagpush);
203EXPROTO(int, ex_tagtop);
204EXPROTO(int, ex_unabbr);
205EXPROTO(int, ex_undo);
206EXPROTO(int, ex_undol);
207EXPROTO(int, ex_unmap);
208EXPROTO(int, ex_usage);
209EXPROTO(int, ex_validate);
210EXPROTO(int, ex_version);
211EXPROTO(int, ex_vglobal);
212EXPROTO(int, ex_visual);
213EXPROTO(int, ex_viusage);
214EXPROTO(int, ex_wq);
215EXPROTO(int, ex_write);
216EXPROTO(int, ex_xit);
217EXPROTO(int, ex_yank);