ex.h revision 3a5240e95e08e42ac1fc82775b3d0ba6e072a74c
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/* Copyright (c) 1981 Regents of the University of California */
#ifndef _EX_H
#define _EX_H
#pragma ident "%Z%%M% %I% %E% SMI"
#ifdef __cplusplus
extern "C" {
#endif
/*
* This file contains most of the declarations common to a large number
* of routines. The file ex_vis.h contains declarations
* which are used only inside the screen editor.
* The file ex_tune.h contains parameters which can be diddled per installation.
*
* The declarations relating to the argument list, regular expressions,
* the temporary file data structure used by the editor
* and the data describing terminals are each fairly substantial and
* are kept in the files ex_{argv,re,temp,tty}.h which
* we #include separately.
*
* If you are going to dig into ex, you should look at the outline of the
* Code which is similar to that of ed is lightly or undocumented in spots
* (e.g. the regular expression code). Newer code (e.g. open and visual)
* is much more carefully documented, and still rough in spots.
*
*/
#ifdef UCBV7
#include <whoami.h>
#endif
#include <ctype.h>
#include <errno.h>
#include <signal.h>
#include <setjmp.h>
#include <stdlib.h>
#include <limits.h>
#define MULTI_BYTE_MAX MB_LEN_MAX
#ifdef USG
#include <termio.h>
#else
#include <sgtty.h>
#endif
#ifdef PAVEL
#endif
typedef char bool;
typedef unsigned long chtype;
#include <term.h>
#define bool vi_bool
#ifdef PAVEL
#endif
#ifndef var
#define var extern
#endif
/*
* The following little dance copes with the new USG tty handling.
* This stuff has the advantage of considerable flexibility, and
* the disadvantage of being incompatible with anything else.
* The presence of the symbol USG will indicate the new code:
* in this case, we define CBREAK (because we can simulate it exactly),
* but we won't actually use it, so we set it to a value that will
* probably blow the compilation if we goof up.
*/
#ifdef USG
#endif
#ifndef VMUNIX
typedef short line;
#else
typedef int line;
#endif
typedef short bool;
#include "ex_tune.h"
#include "ex_vars.h"
/*
* Options in the editor are referred to usually by "value(vi_name)" where
* name is all uppercase, i.e. "value(vi_PROMPT)". This is actually a macro
* which expands to a fixed field in a static structure and so generates
* very little code. The offsets for the option names in the structure
* are generated automagically from the structure initializing them in
* ex_data.c... see the shell script "makeoptions".
*/
struct option {
unsigned char *oname;
unsigned char *oabbrev;
short otype; /* Types -- see below */
short odefault; /* Default value */
short ovalue; /* Current value */
unsigned char *osvalue;
};
#define ONOFF 0
#define NUMERIC 1
#define OTERM 3
/*
* The editor does not normally use the standard i/o library. Because
* we expect the editor to be a heavily used program and because it
* when debugging the editor we use the standard i/o library. In any
* case the editor needs a printf which prints through "putchar" ala the
* old version 6 printf. Thus we normally steal a copy of the "printf.c"
* and "strout" code from the standard i/o library and mung it for our
* purposes to avoid dragging in the stdio library headers, etc if we
* are not debugging. Such a modified printf exists in "printf.c" here.
*/
#ifdef TRACE
#include <stdio.h>
#else
/*
* Warning: do not change BUFSIZ without also changing LBSIZE in ex_tune.h
* Running with BUFSIZ set to anything besides what is in <stdio.h> is
* not recommended, if you use stdio.
*/
#ifdef u370
#define BUFSIZE 4096
#else
#endif
#define NULL 0
#define EOF -1
#endif
/*
* Character constants and bits
*
* The editor uses the QUOTE bit as a flag to pass on with characters
* e.g. to the putchar routine. The editor never uses a simple char variable.
* Only arrays of and pointers to characters are used and parameters and
* registers are never declared character.
*/
#define QUOTE 020000000000
#define TRIM 017777777777
#define NL '\n'
#define CR '\r'
#define ESCAPE 033
#define CTRL(c) (c & 037)
/*
* Miscellaneous random variables used in more than one place
*/
#ifdef SIGTSTP
#endif
extern bool endline; /* Last cmd mode command ended with \n */
extern short lastc; /* Last character ret'd from cmd input */
extern short tfile; /* Temporary file unit */
#ifndef PRESUNEUC
#endif /* PRESUNEUC */
extern int termiosflag; /* flag for using termios */
/*
* Macros
*/
/*
* FIXUNDO: do we want to mung undo vars?
* Usually yes unless in a macro or global.
*/
wop(0);\
}
#define setlastchar(c) lastc = c
/*
* Environment like memory
*/
/*
* The editor data structure for accessing the current file consists
* of an incore array of pointers into the temporary file tfile.
* Each pointer is 15 bits (the low bit is used by global) and is
* padded with zeroes to make an index into the temp file where the
* actual text of the line is stored.
*
* To effect undo, copies of affected lines are saved after the last
* line considered to be in the buffer, between dol and unddol.
* During an open or visual, which uses the command mode undo between
* dol and unddol, a copy of the entire, pre-command buffer state
* is saved between unddol and truedol.
*/
/*
* Undo information
*
* For most commands we save lines changed by salting them away between
* dol and unddol before they are changed (i.e. we save the descriptors
* into the temp file tfile which is never garbage collected). The
* lines put here go back after unddel, and to complete the undo
* we delete the lines [undap1,undap2).
*
* Undoing a move is much easier and we treat this as a special case.
* Similarly undoing a "put" is a special case for although there
* are lines saved between dol and unddol we don't stick these back
* into the buffer.
*/
#define UNDCHANGE 0
#define UNDMOVE 1
#define UNDALL 2
#define UNDNONE 3
#define UNDPUT 4
/*
* Various miscellaneous flags and buffers needed by the encryption routines.
*/
being read is ciphertext
*/
char *getpass();
/* editing session (global flag) */
/*
* Function type definitions
*/
#define NOSTR (char *) 0
#define gettmode vigettmode
extern int (*Outchar)();
extern int (*Pline)();
extern int (*Putchar)();
int (*setlist())();
int (*setnorm())();
int (*setnorm())();
int (*setnumb())();
#ifndef PRESUNEUC
#endif /* PRESUNEUC */
unsigned char *cgoto();
unsigned char *genindent();
unsigned char *getblock();
char *getenv();
unsigned char *mesg();
unsigned char *place();
unsigned char *plural();
unsigned char *strend();
unsigned char *tailpath();
char *tgetstr();
char *tgoto();
char *ttyname();
unsigned char *vfindcol();
unsigned char *vgetline();
unsigned char *vinit();
unsigned char *vpastwh();
unsigned char *vskipwh();
int put(void);
int putreg(unsigned char);
int YANKreg(int);
int delete(bool);
int vi_filter();
int getfile();
int getsub();
int gettty();
int join(int);
int normline(void);
int numbline(int);
#ifdef __STDC__
void onhup(int);
void onintr(int);
void onemt(int);
void oncore(int);
#ifdef CBREAK
void vintr(int);
#endif
void onsusp(int);
int putch(char);
int plodput(char);
int vputch(char);
#else
void onhup();
void onintr();
void onemt();
void oncore();
#ifdef CBREAK
void vintr();
#endif
void onsusp();
int putch();
int plodput();
int vputch();
#endif /* __STDC__ */
void shift(int, int);
int vfilter();
int vshftop();
int yank(void);
unsigned char *lastchr();
unsigned char *nextchr();
bool putoctal;
void error();
void error0(void);
void error1(unsigned char *);
void fixol(void);
void resetflav(void);
void serror(unsigned char *, unsigned char *);
void setflav(void);
void tailprim(unsigned char *, int, bool);
void vcontin(bool);
void squish(void);
void pragged(bool);
void zop2(int, int);
void pofix(void);
void undo(bool);
void somechange(void);
void savetag(char *);
void unsavetag(void);
void checkjunk(unsigned char);
void getone(void);
void rop3(int);
void rop2(void);
void putfile(int);
void wrerror(void);
void clrstats(void);
void slobber(int);
void flush(void);
void flush1(void);
void flush2(void);
void fgoto(void);
void flusho(void);
void comprhs(int);
void ugo(int, int);
void dosub(void);
void snote(int, int);
void cerror(unsigned char *);
void unterm(void);
int setend(void);
void prall(void);
void propts(void);
void killcnt(int);
void merror1(unsigned char *);
void notempty(void);
int qcolumn(unsigned char *, unsigned char *);
void netchange(int);
int nqcolumn(unsigned char *, unsigned char *);
void syserror(int);
void cleanup(bool);
void blkio(short, unsigned char *, int (*)());
void tflush(void);
short partreg(unsigned char);
void kshift(void);
void YANKline(void);
void rbflush(void);
void waitfor(void);
void ovbeg(void);
void fixzero(void);
void savevis(void);
void undvis(void);
void setwind(void);
void vsetsiz(int);
void vinslin(int, int, int);
void vopenup(int, bool, int);
void vadjAL(int, int);
void vup1(void);
void vmoveitup(int, bool);
void vscroll(int);
void vscrap(void);
void vredraw(int);
void vdellin(int, int, int);
void vadjDL(int, int);
void vsyncCL(void);
void vsync(int);
void vsync1(int);
void vcloseup(int, int);
void sethard(void);
void vdirty(int, int);
void setBUF(unsigned char *);
void addto(unsigned char *, unsigned char *);
void macpush();
void setalarm(void);
void cancelalarm(void);
void grabtag(void);
void prepapp(void);
void vremote();
void vsave(void);
void vzop(bool, int, int);
void warnf();
int wordof(unsigned char, unsigned char *);
void setpk(void);
void back1(void);
void vdoappend(unsigned char *);
void vclreol(void);
void vsetcurs(unsigned char *);
void vigoto(int, int);
void vcsync(void);
void vgotoCL(int);
void vgoto(int, int);
void vrigid(void);
void vneedpos(int);
void vnpins(int);
void vishft(void);
void godm(void);
void enddm(void);
void goim(void);
void endim(void);
void vup(int, int, bool);
void vdown(int, int, bool);
void vclean(void);
void vreset(bool);
void vroll(int);
void vrollR(int);
void vnline(unsigned char *);
void noerror();
void viprintf();
void gettmode(void);
void setterm(unsigned char *);
void draino(void);
int lfind();
void source();
void commands();
void addmac();
void vmoveto();
void vrepaint();
void getDOT(void);
void vclear(void);
unsigned char *lastchr();
unsigned char *nextchr();
bool putoctal;
void setdot1(void);
#ifdef __cplusplus
}
#endif
#endif /* _EX_H */