1*57681Sbostic /*- 2*57681Sbostic * Copyright (c) 1992 The Regents of the University of California. 3*57681Sbostic * All rights reserved. 4*57681Sbostic * 5*57681Sbostic * This code is derived from software contributed to Berkeley by 6*57681Sbostic * Rodney Ruddock of the University of Guelph. 7*57681Sbostic * 8*57681Sbostic * %sccs.include.redist.c% 9*57681Sbostic * 10*57681Sbostic * @(#)ed.h 5.1 (Berkeley) 01/23/93 11*57681Sbostic */ 12*57681Sbostic 13*57681Sbostic #include <sys/types.h> 14*57681Sbostic #include <sys/stat.h> 15*57681Sbostic 16*57681Sbostic #include <fcntl.h> 17*57681Sbostic #include <regex.h> 18*57681Sbostic #include <setjmp.h> 19*57681Sbostic #include <signal.h> 20*57681Sbostic #include <stdio.h> 21*57681Sbostic #include <stdlib.h> 22*57681Sbostic 23*57681Sbostic #ifdef DBI 24*57681Sbostic #include <limits.h> 25*57681Sbostic #include <db.h> 26*57681Sbostic #endif 27*57681Sbostic 28*57681Sbostic #define FILENAME_LEN 1023 29*57681Sbostic #define JMP_SET (int)0 30*57681Sbostic #define INTERUPT (int)1 31*57681Sbostic #define HANGUP (int)2 32*57681Sbostic #define SIGINT_ACTION longjmp(ctrl_position, INTERUPT); fflush(stdin) 33*57681Sbostic #define SIGHUP_ACTION longjmp(ctrl_position, HANGUP) 34*57681Sbostic #define NN_MAX_START 510 35*57681Sbostic 36*57681Sbostic typedef struct A { 37*57681Sbostic struct A *above, *below; 38*57681Sbostic #ifdef STDIO 39*57681Sbostic long handle; 40*57681Sbostic #endif 41*57681Sbostic #ifdef DBI 42*57681Sbostic recno_t handle; 43*57681Sbostic #endif 44*57681Sbostic #ifdef MEMORY 45*57681Sbostic char *handle; 46*57681Sbostic #endif 47*57681Sbostic size_t len; 48*57681Sbostic } LINE; 49*57681Sbostic 50*57681Sbostic struct MARK { 51*57681Sbostic LINE *address; 52*57681Sbostic }; 53*57681Sbostic 54*57681Sbostic 55*57681Sbostic struct g_list { 56*57681Sbostic struct g_list *next; 57*57681Sbostic LINE *cell; 58*57681Sbostic }; 59*57681Sbostic 60*57681Sbostic struct u_layer { 61*57681Sbostic LINE *val, **cell; 62*57681Sbostic struct u_layer *below; 63*57681Sbostic }; 64*57681Sbostic 65*57681Sbostic struct d_layer { 66*57681Sbostic LINE *begin, *end; 67*57681Sbostic struct d_layer *next; 68*57681Sbostic }; 69*57681Sbostic 70*57681Sbostic extern void cmd_loop(); 71*57681Sbostic extern void a(); 72*57681Sbostic extern void c(); 73*57681Sbostic extern void d(); 74*57681Sbostic extern void d_add(); 75*57681Sbostic extern void d_do(); 76*57681Sbostic extern void e(); 77*57681Sbostic extern void e2(); 78*57681Sbostic extern void f(); 79*57681Sbostic extern void g(); 80*57681Sbostic extern void i(); 81*57681Sbostic extern void j(); 82*57681Sbostic extern void k(); 83*57681Sbostic extern void ku_chk(); 84*57681Sbostic extern void l(); 85*57681Sbostic extern void m(); 86*57681Sbostic extern void p(); 87*57681Sbostic extern void q(); 88*57681Sbostic extern void r(); 89*57681Sbostic extern void s(); 90*57681Sbostic extern void t(); 91*57681Sbostic extern void u(); 92*57681Sbostic extern void u_add_stk(); 93*57681Sbostic extern void u_clr_stk(); 94*57681Sbostic extern void w(); 95*57681Sbostic extern void z(); 96*57681Sbostic extern void equal(); 97*57681Sbostic extern void bang(); 98*57681Sbostic extern void set_mark(); 99*57681Sbostic extern LINE *get_mark(); 100*57681Sbostic extern LINE *search(); 101*57681Sbostic extern LINE *search_r(); 102*57681Sbostic extern long input_lines(); 103*57681Sbostic #ifdef STDIO 104*57681Sbostic extern long add_line(); 105*57681Sbostic #endif 106*57681Sbostic #ifdef DBI 107*57681Sbostic extern recno_t add_line(); 108*57681Sbostic #endif 109*57681Sbostic #ifdef MEMORY 110*57681Sbostic extern char *add_line(); 111*57681Sbostic #endif 112*57681Sbostic extern void get_line(); 113*57681Sbostic extern int num_dig_conv(); 114*57681Sbostic extern LINE *address_conv(); 115*57681Sbostic extern struct bounds *re_search(); 116*57681Sbostic extern struct re_pattern *re_compile(); 117*57681Sbostic extern void undo(); 118*57681Sbostic extern char *re_replace(); 119*57681Sbostic extern char *get_pattern(); 120*57681Sbostic extern char *filename(); 121*57681Sbostic extern int rol(); 122*57681Sbostic extern void ed_exit(); 123*57681Sbostic 124*57681Sbostic extern int nn_max, nn_max_flag, start_default, End_default, address_flag; 125*57681Sbostic extern LINE *nn_max_start, *nn_max_end, *start, *End, *current; 126*57681Sbostic extern char *text, *prompt_string, help_msg[]; 127*57681Sbostic extern struct MARK mark_matrix[]; 128*57681Sbostic extern char *filename_current, *buf; 129*57681Sbostic extern int zsnum; /* z sticky number */ 130*57681Sbostic extern LINE *top, *bottom; /* ...of the buffer */ 131*57681Sbostic extern int ss, explain_flag, name_set; 132*57681Sbostic extern int filename_flag, add_flag; 133*57681Sbostic extern long change_flag; 134*57681Sbostic extern int pat_err, flag, g_flag, GV_flag, printsfx; 135*57681Sbostic 136*57681Sbostic #ifdef STDIO 137*57681Sbostic extern FILE *fhtmp; 138*57681Sbostic extern int file_seek; 139*57681Sbostic extern char *template; 140*57681Sbostic #endif 141*57681Sbostic 142*57681Sbostic #ifdef DBI 143*57681Sbostic extern DB *dbhtmp; 144*57681Sbostic extern char *template; 145*57681Sbostic #endif 146*57681Sbostic 147*57681Sbostic extern struct u_layer *u_stk; 148*57681Sbostic extern LINE *u_current, *u_top, *u_bottom; 149*57681Sbostic extern int u_set, line_length; 150*57681Sbostic extern struct d_layer *d_stk; 151*57681Sbostic 152*57681Sbostic extern int sigint_flag, sighup_flag; 153*57681Sbostic extern jmp_buf ctrl_position; 154*57681Sbostic 155*57681Sbostic #define RE_SEC 10 156*57681Sbostic extern regex_t RE_comp; 157*57681Sbostic extern regmatch_t RE_match[]; 158*57681Sbostic extern int RE_sol, RE_flag; 159*57681Sbostic extern char *RE_patt; 160