ex.h revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* 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 (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/* Copyright (c) 1981 Regents of the University of California */
/*
* Copyright (c) 2000 by Sun Microsystems, Inc.
* All rights reserved.
*/
#ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.34 */
/*
* 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
extern int errno;
#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
extern int (*Outchar)();
extern int (*Pline)();
extern int (*Putchar)();
int (*setlist())();
int (*setnorm())();
int (*setnorm())();
int (*setnumb())();
#ifndef PRESUNEUC
#endif /* PRESUNEUC */
char *sbrk();
unsigned char *cgoto();
unsigned char *genindent();
unsigned char *getblock();
char *getenv();
unsigned char *mesg();
unsigned char *place();
unsigned char *plural();
unsigned char *strcat();
unsigned char *strcpy();
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();
int putreg();
int YANKreg();
int delete();
int execlp();
int vi_filter();
int getfile();
int getsub();
int gettty();
int join();
int listchar();
int normchar();
int normline();
int numbline();
#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__ */
int shift();
int termchar();
int vfilter();
int vshftop();
int yank();
unsigned char *lastchr();
unsigned char *nextchr();
bool putoctal;
int shift();
int termchar();
int vfilter();
int vshftop();
int yank();
unsigned char *lastchr();
unsigned char *nextchr();
bool putoctal;