2 * Copyright (c) 1992, 1993
3 * The Regents of the University of California. All rights reserved.
5 * %sccs.include.redist.c%
7 * $Id: ex.h,v 8.27 1993/11/04 16:16:56 bostic Exp $ (Berkeley) $Date: 1993/11/04 16:16:56 $
12 /* Ex command structure. */
13 typedef struct _excmdlist
{
14 char *name
; /* Command name. */
15 /* Underlying function. */
16 int (*fn
) __P((SCR
*, EXF
*, struct _excmdarg
*));
18 #define E_ADDR1 0x0000001 /* One address. */
19 #define E_ADDR2 0x0000002 /* Two address. */
20 #define E_ADDR2_ALL 0x0000004 /* Zero/two addresses; zero == all. */
21 #define E_ADDR2_NONE 0x0000008 /* Zero/two addresses; zero == none. */
22 #define E_ADDRDEF 0x0000010 /* Default addresses used. */
23 #define E_BUFFER 0x0000020 /* Buffer name supplied. */
24 #define E_COUNT 0x0000040 /* Count supplied. */
25 #define E_FORCE 0x0000080 /* ! */
27 #define E_F_CARAT 0x0000100 /* ^ flag. */
28 #define E_F_DASH 0x0000200 /* - flag. */
29 #define E_F_DOT 0x0000400 /* . flag. */
30 #define E_F_EQUAL 0x0000800 /* = flag. */
31 #define E_F_HASH 0x0001000 /* # flag. */
32 #define E_F_LIST 0x0002000 /* l flag. */
33 #define E_F_PLUS 0x0004000 /* + flag. */
34 #define E_F_PRINT 0x0008000 /* p flag. */
36 #define E_F_PRCLEAR 0x0010000 /* Clear the print (#, l, p) flags. */
37 #define E_MODIFY 0x0020000 /* File name expansion modified arg. */
38 #define E_NOGLOBAL 0x0040000 /* Not in a global. */
39 #define E_NOPERM 0x0080000 /* Permission denied for now. */
40 #define E_NORC 0x0100000 /* Not from a .exrc or EXINIT. */
41 #define E_SETLAST 0x0200000 /* Reset last command. */
42 #define E_ZERO 0x0400000 /* 0 is a legal addr1. */
43 #define E_ZERODEF 0x0800000 /* 0 is default addr1 of empty files. */
45 char *syntax
; /* Syntax script. */
46 char *usage
; /* Usage line. */
47 char *help
; /* Help line. */
49 #define MAXCMDNAMELEN 12 /* Longest command name. */
50 extern EXCMDLIST
const cmds
[]; /* List of ex commands. */
52 /* Structure passed around to functions implementing ex commands. */
53 typedef struct _excmdarg
{
54 EXCMDLIST
const *cmd
; /* Command entry in command table. */
55 CHAR_T buffer
; /* Named buffer. */
56 recno_t lineno
; /* Line number. */
57 u_long count
; /* Specified count. */
58 int addrcnt
; /* Number of addresses (0, 1 or 2). */
59 MARK addr1
; /* 1st address. */
60 MARK addr2
; /* 2nd address. */
61 int argc
; /* Count of file/word arguments. */
62 char **argv
; /* List of file/word arguments. */
63 u_int flags
; /* Selected flags from EXCMDLIST. */
66 /* Macro to set up the structure. */
67 #define SETCMDARG(s, _cmd, _addrcnt, _lno1, _lno2, _force, _arg) { \
68 memset(&s, 0, sizeof(EXCMDARG)); \
69 s.cmd = &cmds[_cmd]; \
70 s.addrcnt = (_addrcnt); \
71 s.addr1.lno = (_lno1); \
72 s.addr2.lno = (_lno2); \
73 s.addr1.cno = s.addr2.cno = 1; \
76 sp->ex_argv[0] = _arg; \
77 s.argc = _arg ? 1 : 0; \
78 s.argv = sp->ex_argv; \
82 * :next, :prev, :rewind, :tag, :tagpush, :tagpop modifications check.
83 * If force is set, the autowrite is skipped.
85 #define MODIFY_CHECK(sp, ep, force) { \
86 if (F_ISSET((ep), F_MODIFIED)) \
87 if (O_ISSET((sp), O_AUTOWRITE)) { \
89 file_write((sp), (ep), NULL, NULL, NULL, \
90 FS_ALL | FS_POSSIBLE)) \
92 } else if (ep->refcnt <= 1 && !(force)) { \
94 "Modified since last write; write or use ! to override."); \
102 * FILTER Filter text through the utility.
103 * FILTER_READ Read from the utility into the file.
104 * FILTER_WRITE Write to the utility, display its output.
106 enum filtertype
{ FILTER
, FILTER_READ
, FILTER_WRITE
};
107 int filtercmd
__P((SCR
*, EXF
*,
108 MARK
*, MARK
*, MARK
*, char *, enum filtertype
));
110 /* Ex function prototypes. */
111 int argv_exp1
__P((SCR
*, EXF
*, EXCMDARG
*, char *, int));
112 int argv_exp2
__P((SCR
*, EXF
*, EXCMDARG
*, char *, int));
113 int argv_exp3
__P((SCR
*, EXF
*, EXCMDARG
*, char *));
114 int argv_free
__P((SCR
*));
115 int ex
__P((SCR
*, EXF
*));
116 int ex_cfile
__P((SCR
*, EXF
*, char *));
117 int ex_cmd
__P((SCR
*, EXF
*, char *, int));
118 int ex_cstring
__P((SCR
*, EXF
*, char *, int));
119 int ex_end
__P((SCR
*));
120 int ex_exec_proc
__P((SCR
*, const u_char
*, const u_char
*, char *));
121 int ex_gb
__P((SCR
*, EXF
*, HDR
*, int, u_int
));
122 int ex_getline
__P((SCR
*, FILE *, size_t *));
123 int ex_init
__P((SCR
*, EXF
*));
124 int ex_print
__P((SCR
*, EXF
*, MARK
*, MARK
*, int));
125 int ex_readfp
__P((SCR
*, EXF
*, char *, FILE *, MARK
*, recno_t
*, int));
126 void ex_refresh
__P((SCR
*, EXF
*));
127 int ex_suspend
__P((SCR
*));
128 int ex_writefp
__P((SCR
*, EXF
*, \
129 char *, FILE *, MARK
*, MARK
*, u_long
*, u_long
*));
130 int proc_wait
__P((SCR
*, long, const char *, int));
131 int sscr_exec
__P((SCR
*, EXF
*, recno_t
));
132 int sscr_end
__P((SCR
*));
133 int sscr_input
__P((SCR
*));
135 #define EXPROTO(type, name) \
136 type name __P((SCR *, EXF *, EXCMDARG *))
138 EXPROTO(int, ex_abbr
);
139 EXPROTO(int, ex_append
);
140 EXPROTO(int, ex_args
);
142 EXPROTO(int, ex_bang
);
143 EXPROTO(int, ex_bdisplay
);
145 EXPROTO(int, ex_change
);
146 EXPROTO(int, ex_color
);
147 EXPROTO(int, ex_copy
);
148 EXPROTO(int, ex_debug
);
149 EXPROTO(int, ex_delete
);
150 EXPROTO(int, ex_digraph
);
151 EXPROTO(int, ex_edit
);
152 EXPROTO(int, ex_equal
);
153 EXPROTO(int, ex_file
);
154 EXPROTO(int, ex_global
);
155 EXPROTO(int, ex_help
);
156 EXPROTO(int, ex_join
);
157 EXPROTO(int, ex_list
);
158 EXPROTO(int, ex_map
);
159 EXPROTO(int, ex_mark
);
160 EXPROTO(int, ex_mkexrc
);
161 EXPROTO(int, ex_move
);
162 EXPROTO(int, ex_next
);
163 EXPROTO(int, ex_number
);
164 EXPROTO(int, ex_open
);
166 EXPROTO(int, ex_preserve
);
167 EXPROTO(int, ex_prev
);
168 EXPROTO(int, ex_put
);
169 EXPROTO(int, ex_quit
);
170 EXPROTO(int, ex_read
);
171 EXPROTO(int, ex_rew
);
172 EXPROTO(int, ex_script
);
173 EXPROTO(int, ex_set
);
174 EXPROTO(int, ex_shell
);
175 EXPROTO(int, ex_shiftl
);
176 EXPROTO(int, ex_shiftr
);
177 EXPROTO(int, ex_source
);
178 EXPROTO(int, ex_split
);
179 EXPROTO(int, ex_stop
);
180 EXPROTO(int, ex_subagain
);
181 EXPROTO(int, ex_substitute
);
182 EXPROTO(int, ex_subtilde
);
183 EXPROTO(int, ex_tagpop
);
184 EXPROTO(int, ex_tagpush
);
185 EXPROTO(int, ex_tagtop
);
186 EXPROTO(int, ex_unabbr
);
187 EXPROTO(int, ex_undo
);
188 EXPROTO(int, ex_undol
);
189 EXPROTO(int, ex_unmap
);
190 EXPROTO(int, ex_usage
);
191 EXPROTO(int, ex_validate
);
192 EXPROTO(int, ex_version
);
193 EXPROTO(int, ex_vglobal
);
194 EXPROTO(int, ex_visual
);
195 EXPROTO(int, ex_viusage
);
197 EXPROTO(int, ex_write
);
198 EXPROTO(int, ex_xit
);
199 EXPROTO(int, ex_yank
);