-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathex.h
285 lines (255 loc) · 5.5 KB
/
ex.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <time.h>
#include <stdarg.h>
#include <setjmp.h>
#include <termios.h>
int tgetent(char *bp, const char *name);
int tgetflag(char *id);
int tgetnum(char *id);
char *tgetstr(char *id, char **area);
char *tgoto(const char *cap, int col, int row);
int tputs(const char *str, int affcnt, int (*putc)(int));
#define VISUAL
/*
* Ex - text editor
* Bill Joy UCB June 1977
*
* Based on an earlier editor "ex" written by
* William Joy and Charles Haley.
*
* And of course an inestimable debt to "ed"!
*/
#define STATIC static
#define NIL 0
#define QUOTE 0200
#define HUP 1
#define INTR 2
#define QUIT 3
#define FNSIZE 64
#define LBSIZE 512
#ifndef EOF
#define EOF -1
#endif
char ruptible, inglobal, inopen, inconf, listf, endline, laste, intty;
char shudclob, diddle, die;
int chngflag, xchngflag, tchngflag;
char /* savedfile[FNS, */ file[FNSIZE], altfile[FNSIZE];
char linebuf[LBSIZE], genbuf[LBSIZE];
int *address(void);
int *addr1, *addr2;
int *zero, *one, *dot, *dol, *unddol, *endcore, *fendcore;
int *unddel, *undap1, *undap2, *undadot;
char undkind;
#define UNDCHANGE 0
#define UNDMOVE 1
#define UNDALL 2
#define UNDNONE 3
int io, erfile;
extern int tfile;
char *globp;
extern char *erpath;
int names[27];
int outcol;
char home[30];
char *Command;
int getfile(void);
#include "ex_vars.h"
#define eq(a, b) (strcmp(a, b) == 0)
#ifndef CTRL
#define CTRL(c) (c & 037)
#endif
#ifndef ECHO
#define ECHO 010
#endif
#define RAW 040
char normtty;
struct termios normf;
void (*oldhup)(int);
void onhup(int);
void (*oldquit)(int);
void onintr(int);
struct {
time_t Atime;
uid_t Auid;
int Alines;
char Afname[FNSIZE];
int Ablocks[100];
} header;
#define savedfile header.Afname
#define blocks header.Ablocks
int dirtcnt;
char recov;
extern char TTYNAM[];
int TMODE;
extern int lastc;
int peekc;
jmp_buf resetlab; /* For error throws to top level (cmd mode) */
#define CP(a, b) memmove(a, b, strlen(b) + 1)
#define getexit(a) copy((char *)a, (char *)resetlab, sizeof (jmp_buf))
#define lastchar() lastc
#define outchar(c) (*Outchar)(c)
#define pline(no) (*Pline)(no)
#define reset() longjmp(resetlab,1)
#define resexit(a) copy((char *)resetlab, (char *)a, sizeof (jmp_buf))
#define setexit() setjmp(resetlab)
#define setlastchar(c) lastc = c
#define ungetchar(c) peekc = c
char aiflag;
#define setai(i) aiflag = i
int pid, rpid, status;
struct termios tty;
char allredraw, pfast;
extern void (*Putchar)();
void listchar(int);
void normchar(int);
void tabulate(char);
void xpand(void);
void error(char *, ...);
void lprintf(char *, ...);
void lvprintf(char *, va_list);
void ex_printf(char *, ...);
void ex_vprintf(char *, va_list);
void (*setlist(void))();
void (*setnorm(void))();
void setnumb(void);
void setoutt(void);
void ex_newline(void);
void pstop(void);
void pstart(void);
void fgoto(void);
char *cgoto(void);
void putfile(void);
void set(int);
void initoptions(char);
void source(char *, int);
void setall(void);
void setcount(void);
void snote(int, int);
void netchange(int);
void killed(void);
void vappend(int, int, int);
void reverse(int *, int *);
void filename(int);
void ex_sync(void);
int commands(int, char);
void change(void);
void plines(int *, int *, char);
void eol(void);
void resetflav(void);
int endcmd(int);
void fileinit(void);
void cleanup(void);
void clrstats(void);
int iostats(void);
char *plural(int);
char *ex_getline(int);
int putline(void);
void ioerror(void);
void synctmp(void);
void TSYNC(void);
void putch(int);
void rop(int);
void rop2(void);
void rop3(int);
int append(int (*)(), int *);
void appendnone(void);
int substitute(char);
void delete(void);
void deletenone(void);
void join(char);
void setdot(void);
void setdot1(void);
int getnum(void);
void markDOT(void);
void markpr(int *);
void notempty(void);
void setnoaddr(void);
void nonzero(void);
void setCNL(void);
void setNAEOL(void);
int *scanfor(int);
int gTTY(int);
int sTTY(int);
void netchHAD(int);
void noteargs(void);
void move(void);
void move1(char, int *);
void yank(void);
void PUT(void);
void undo(char);
void helpinit(void);
void dingdong(void);
char *mesg(char *);
void normal(void);
void helpthem(void);
void ex_putchar(int);
void flush(void);
void setcol(int);
void partinp(void);
void noteinp(void);
void notech(int);
void putNFL(void);
void termreset(void);
void draino(void);
void ostart(void);
void ostop(void);
void flusho(void);
void putnl(void);
void wop(void);
int skipwh(void);
int letter(int);
int white(int);
int digit(int);
int ucletter(int);
int ex_getchar(void);
int peekchar(void);
int gettty(void);
int backtab(int);
int *setin(int *);
int getsub(void);
int getch(void);
void putmark(int *);
void putmk1(int *, int);
void xop(void (*)(), int);
void global(int);
void save12(void);
void saveall(void);
void zop(char);
void zeq(int);
void xtrey(char);
void setDEL(void);
void setBUF(char *);
void oop(void);
char *vskipwh(char *);
void voinit(void);
void vop(void);
void undiddle(void);
int compile(int, char);
int execute(int, int *);
void copy(char *, char *, int);
char *strend(char *);
char *strcLIN(char *);
int column(char *);
int qcolumn(char *, char *);
char *genindent(int);
char *vpastwh(char *);
int whitecnt(char *);
char *vgetline(int, char *, char *);
void vdoappend(char *);
void shift(int, int);
void dographic(void);
void doulg(void);
int getargs(void);
char *unpack(char *);
void pack(char *);
void ex_unix(void);
void unix2(char *, char, char *);
void recover(void);
void waitfor(void);
void revocer(void);
int preserve(void);
void REset(void);
void ex_rewind(void);
void init(void);