/* ed.h: type and constant definitions for the ed editor. */
* Copyright (c) 1993 The Regents of the University of California.
* This code is derived from software contributed to Berkeley by
* Andrew Moore, Talke Studio.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* @(#)ed.h 5.5 (Berkeley) 3/28/93
#if defined(BSD) && BSD >= 199103 || defined(__386BSD__)
# include <sys/param.h> /* for MAXPATHLEN */
#define BITS(type) (BITSPERBYTE * (int)sizeof(type))
#define CHARBITS BITS(char)
#define INTBITS BITS(int)
#define INTHIBIT (unsigned) (1 << (INTBITS - 1))
# define MAXPATHLEN 255 /* _POSIX_PATH_MAX */
#define MAXFNAME MAXPATHLEN /* max file name size */
#define MINBUFSZ 512 /* minimum buffer size - must be > 0 */
#define LINECHARS (INTHIBIT - 1) /* max chars per line */
#define SE_MAX 30 /* max subexpressions in a regular expression */
typedef regex_t pattern_t
;
off_t seek
; /* address of line in scratch buffer */
#define ACTV INTHIBIT /* active bit: high bit of len */
int len
; /* length of line */
int type
; /* command type */
line_t
*h
; /* head of list */
line_t
*t
; /* tail of list */
# define max(a,b) ((a) > (b) ? (a) : (b))
# define min(a,b) ((a) < (b) ? (a) : (b))
/* nextln: return line after l mod k */
#define nextln(l,k) ((l)+1 > (k) ? 0 : (l)+1)
/* nextln: return line before l mod k */
#define prevln(l,k) ((l)-1 < 0 ? (k) : (l)-1)
#define skipblanks() while (isspace(*ibufp) && *ibufp != '\n') ibufp++
/* spl1: disable some interrupts (requires reliable signals) */
/* spl0: enable all interrupts; check sigflags (requires reliable signals) */
if (sigflags & (1 << SIGHUP)) dohup(SIGHUP); \
if (sigflags & (1 << SIGINT)) dointr(SIGINT); \
#if defined(sun) || defined(NO_REALLOC_NULL)
/* CKBUF: assure at least a minimum size for buffer b */
#define CKBUF(b,n,i,err) \
if ((ts = (char *) realloc((b), ti += max((i), MINBUFSZ))) == NULL) { \
fprintf(stderr, "%s\n", strerror(errno)); \
sprintf(errmsg, "out of memory"); \
if ((ts = (char *) malloc(ti += max((i), MINBUFSZ))) == NULL) { \
fprintf(stderr, "%s\n", strerror(errno)); \
sprintf(errmsg, "out of memory"); \
#else /* NO_REALLOC_NULL */
/* CKBUF: assure at least a minimum size for buffer b */
#define CKBUF(b,n,i,err) \
if ((ts = (char *) realloc((b), ti += max((i), MINBUFSZ))) == NULL) { \
fprintf(stderr, "%s\n", strerror(errno)); \
sprintf(errmsg, "out of memory"); \
#endif /* NO_REALLOC_NULL */
/* requeue: link pred before succ */
#define requeue(pred, succ) (pred)->next = (succ), (succ)->prev = (pred)
/* insqueue: insert elem in circular queue after pred */
#define insqueue(elem, pred) \
requeue((elem), (pred)->next); \
/* remqueue: remove elem from circular queue */
#define remqueue(elem) requeue((elem)->prev, (elem)->next);
/* nultonl: overwrite ASCII NULs with newlines */
#define nultonl(s, l) translit(s, l, '\0', '\n')
/* nltonul: overwrite newlines with ASCII NULs */
#define nltonul(s, l) translit(s, l, '\n', '\0')
# define strerror(n) sys_errlist[n]
# define __P(proto) proto
/* local function declarations */
int append
__P((long, int));
int cbcdec
__P((char *, FILE *));
int cbcenc
__P((char *, int, FILE *));
char *ckfn
__P((char *));
int ckrange
__P((long, long));
int desflush
__P((FILE *));
int desgetc
__P((FILE *));
void desinit
__P((void));
int desputc
__P((int, FILE *));
void clrmark
__P((line_t
*));
void cvtkey
__P((char *, char *));
int doprint
__P((long, long, int));
long doread
__P((long, char *));
long dowrite
__P((long, long, char *, char *));
char *esctos
__P((char *));
long patscan
__P((pattern_t
*, int));
long getaddr
__P((line_t
*));
char *getcmdv
__P((int *, int));
line_t
*getlp
__P((long));
int getshcmd
__P((void));
char *gettxt
__P((line_t
*));
void init_buf
__P((void));
int join
__P((long, long));
int lndelete
__P((long, long));
line_t
*lpdup
__P((line_t
*));
void lpqueue
__P((line_t
*));
void makekey
__P((char *));
char *makesub
__P((int));
int move
__P((long, int));
int oddesc
__P((char *, char *));
pattern_t
*optpat
__P((void));
int putmark
__P((int, line_t
*));
void putstr
__P((char *, int, long, int));
char *puttxt
__P((char *));
int regsub
__P((pattern_t
*, line_t
*, int));
int sgetline
__P((FILE *));
int catsub
__P((char *, regmatch_t
*, int));
int subst
__P((pattern_t
*, int));
int tobinhex
__P((int, int));
int transfer
__P((long));
char *translit
__P((char *, int, int, int));
undo_t
*upush
__P((int, long, long));
extern char *sys_errlist
[];