BSD 4_4 release
[unix-history] / usr / src / usr.bin / ex / ex.h
index a295ee3..98d6a83 100644 (file)
@@ -1,5 +1,14 @@
-/* Copyright (c) 1980 Regents of the University of California */
-/* sccs id:    @(#)ex.h        4.2 %G%  */
+/*-
+ * Copyright (c) 1980, 1993
+ *     The Regents of the University of California.  All rights reserved.
+ *
+ * This module is believed to contain source code proprietary to AT&T.
+ * Use and redistribution is subject to the Berkeley Software License
+ * Agreement and your Software Agreement with AT&T (Western Electric).
+ *
+ *     @(#)ex.h        8.1 (Berkeley) 6/9/93
+ */
+
 #ifdef V6
 #include <retrofit.h>
 #endif
 #ifdef V6
 #include <retrofit.h>
 #endif
  * of additional terminal descriptions you add to the termcap data base.
  */
 
  * of additional terminal descriptions you add to the termcap data base.
  */
 
-#include <sys/types.h>
+#ifndef        vms
+#include <sys/param.h>
+#else
+#define        MAXBSIZE        1024    /* Maximum block size */
+#include <types.h>
+#endif
 #include <ctype.h>
 #include <errno.h>
 #include <signal.h>
 #include <setjmp.h>
 #include <ctype.h>
 #include <errno.h>
 #include <signal.h>
 #include <setjmp.h>
+#ifndef        vms
 #include <sys/stat.h>
 #include <sys/stat.h>
+#else
+#include <stat.h>
+#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 following little dance copes with the new USG tty handling.
  *     This stuff has the advantage of considerable flexibility, and
 #include <termio.h>
 #define CBREAK xxxxx
 #else
 #include <termio.h>
 #define CBREAK xxxxx
 #else
+#ifndef        vms
 #include <sgtty.h>
 #include <sgtty.h>
+#else
+#include "vmstty.h"
+#endif
 #endif
 
 extern int errno;
 #endif
 
 extern int errno;
@@ -100,8 +125,13 @@ struct     option {
 #define        value(a)        options[a].ovalue
 #define        svalue(a)       options[a].osvalue
 
 #define        value(a)        options[a].ovalue
 #define        svalue(a)       options[a].osvalue
 
-struct option options[NOPTS + 1];
+extern  struct option options[NOPTS + 1];
 
 
+#ifdef vms
+#define        st_blksize      st_fab_mrs
+#define        _exit(n)        vms_exit(n)
+#define        fork()          vfork()
+#endif
 
 /*
  * The editor does not normally use the standard i/o library.  Because
 
 /*
  * The editor does not normally use the standard i/o library.  Because
@@ -116,20 +146,24 @@ struct    option options[NOPTS + 1];
  * are not debugging.  Such a modified printf exists in "printf.c" here.
  */
 #ifdef TRACE
  * are not debugging.  Such a modified printf exists in "printf.c" here.
  */
 #ifdef TRACE
-#      include <stdio.h>
-       FILE    *trace;
-       bool    trubble;
-       bool    techoin;
-       char    tracbuf[BUFSIZ];
-#      undef   putchar
-#      undef   getchar
+# include <stdio.h>
+       var     FILE    *trace;
+       var     bool    trubble;
+       var     bool    techoin;
+       var     char    tracbuf[BUFSIZ];
 #else
 # ifdef        VMUNIX
 #      define  BUFSIZ  1024
 # else
 #else
 # ifdef        VMUNIX
 #      define  BUFSIZ  1024
 # else
+#  ifdef u370
+#      define  BUFSIZ  4096
+#  else
 #      define  BUFSIZ  512
 #      define  BUFSIZ  512
+#  endif
 # endif
 # endif
+# ifndef NULL
 #      define  NULL    0
 #      define  NULL    0
+# endif
 #      define  EOF     -1
 #endif
 
 #      define  EOF     -1
 #endif
 
@@ -143,74 +177,80 @@ struct    option options[NOPTS + 1];
  */
 #define        QUOTE   0200
 #define        TRIM    0177
  */
 #define        QUOTE   0200
 #define        TRIM    0177
-#define        CTRL(c) ('c' & 037)
-#define        NL      CTRL(j)
-#define        CR      CTRL(m)
+#ifndef vms
+#undef CTRL
+#endif
+#define        CTRL(c) (c & 037)
+#define        NL      CTRL('j')
+#define        CR      CTRL('m')
 #define        DELETE  0177            /* See also ATTN, QUIT in ex_tune.h */
 #define        ESCAPE  033
 
 /*
  * Miscellaneous random variables used in more than one place
  */
 #define        DELETE  0177            /* See also ATTN, QUIT in ex_tune.h */
 #define        ESCAPE  033
 
 /*
  * Miscellaneous random variables used in more than one place
  */
-bool   aiflag;                 /* Append/change/insert with autoindent */
-bool   anymarks;               /* We have used '[a-z] */
-int    chng;                   /* Warn "No write" */
-char   *Command;
-short  defwind;                /* -w# change default window size */
-int    dirtcnt;                /* When >= MAXDIRT, should sync temporary */
+var    bool    aiflag;         /* Append/change/insert with autoindent */
+var    bool    anymarks;       /* We have used '[a-z] */
+var    int     chng;           /* Warn "No write" */
+var    char    *Command;
+var    short   defwind;        /* -w# change default window size */
+var    int     dirtcnt;        /* When >= MAXDIRT, should sync temporary */
 #ifdef TIOCLGET
 #ifdef TIOCLGET
-bool   dosusp;                 /* Do SIGTSTP in visual when ^Z typed */
+var    bool    dosusp;         /* Do SIGTSTP in visual when ^Z typed */
 #endif
 #endif
-bool   edited;                 /* Current file is [Edited] */
-line   *endcore;               /* Last available core location */
-bool   endline;                /* Last cmd mode command ended with \n */
-#ifndef VMUNIX
-short  erfile;                 /* Error message file unit */
+var    bool    edited;         /* Current file is [Edited] */
+var    line    *endcore;       /* Last available core location */
+extern  bool   endline;        /* Last cmd mode command ended with \n */
+#ifdef EXSTRINGS
+var    short   erfile;         /* Error message file unit */
 #endif
 #endif
-line   *fendcore;              /* First address in line pointer space */
-char   file[FNSIZE];           /* Working file name */
-char   genbuf[LBSIZE];         /* Working buffer when manipulating linebuf */
-bool   hush;                   /* Command line option - was given, hush up! */
-char   *globp;                 /* (Untyped) input string to command mode */
-bool   holdcm;                 /* Don't cursor address */
-bool   inappend;               /* in ex command append mode */
-bool   inglobal;               /* Inside g//... or v//... */
-char   *initev;                /* Initial : escape for visual */
-bool   inopen;                 /* Inside open or visual */
-char   *input;                 /* Current position in cmd line input buffer */
-bool   intty;                  /* Input is a tty */
-short  io;                     /* General i/o unit (auto-closed on error!) */
-short  lastc;                  /* Last character ret'd from cmd input */
-bool   laste;                  /* Last command was an "e" (or "rec") */
-char   lastmac;                /* Last macro called for ** */
-char   lasttag[TAGSIZE];       /* Last argument to a tag command */
-char   *linebp;                /* Used in substituting in \n */
-char   linebuf[LBSIZE];        /* The primary line buffer */
-bool   listf;                  /* Command should run in list mode */
-char   *loc1;                  /* Where re began to match (in linebuf) */
-char   *loc2;                  /* First char after re match (") */
-line   names['z'-'a'+2];       /* Mark registers a-z,' */
-int    notecnt;                /* Count for notify (to visual from cmd) */
-bool   numberf;                /* Command should run in number mode */
-char   obuf[BUFSIZ];           /* Buffer for tty output */
-short  oprompt;                /* Saved during source */
-short  ospeed;                 /* Output speed (from gtty) */
-int    otchng;                 /* Backup tchng to find changes in macros */
-short  peekc;                  /* Peek ahead character (cmd mode input) */
-char   *pkill[2];              /* Trim for put with ragged (LISP) delete */
-bool   pfast;                  /* Have stty -nl'ed to go faster */
-int    pid;                    /* Process id of child */
-int    ppid;                   /* Process id of parent (e.g. main ex proc) */
-jmp_buf        resetlab;               /* For error throws to top level (cmd mode) */
-int    rpid;                   /* Pid returned from wait() */
-bool   ruptible;               /* Interruptible is normal state */
-bool   shudclob;               /* Have a prompt to clobber (e.g. on ^D) */
-int    status;                 /* Status returned from wait() */
-int    tchng;                  /* If nonzero, then [Modified] */
-short  tfile;                  /* Temporary file unit */
-bool   vcatch;                 /* Want to catch an error (open/visual) */
-jmp_buf        vreslab;                /* For error throws to a visual catch */
-int    xchng;                  /* Suppresses multiple "No writes" in !cmd */
+var    line    *fendcore;      /* First address in line pointer space */
+var    char    file[FNSIZE];   /* Working file name */
+var    char    genbuf[MAXBSIZE]; /* Working buffer when manipulating linebuf */
+var    bool    hush;           /* Command line option - was given, hush up! */
+var    char    *globp;         /* (Untyped) input string to command mode */
+var    bool    holdcm;         /* Don't cursor address */
+var    bool    inappend;       /* in ex command append mode */
+var    bool    inglobal;       /* Inside g//... or v//... */
+var    char    *initev;        /* Initial : escape for visual */
+var    bool    inopen;         /* Inside open or visual */
+var    char    *input;         /* Current position in cmd line input buffer */
+var    bool    intty;          /* Input is a tty */
+var    short   io;             /* General i/o unit (auto-closed on error!) */
+extern  short  lastc;          /* Last character ret'd from cmd input */
+var    bool    laste;          /* Last command was an "e" (or "rec") */
+var    char    lastmac;        /* Last macro called for ** */
+var    char    lasttag[TAGSIZE];       /* Last argument to a tag command */
+var    char    *linebp;        /* Used in substituting in \n */
+var    char    linebuf[LBSIZE];        /* The primary line buffer */
+var    bool    listf;          /* Command should run in list mode */
+var    char    *loc1;          /* Where re began to match (in linebuf) */
+var    char    *loc2;          /* First char after re match (") */
+var    line    names['z'-'a'+2];       /* Mark registers a-z,' */
+var    int     notecnt;        /* Count for notify (to visual from cmd) */
+var    bool    numberf;        /* Command should run in number mode */
+var    char    obuf[BUFSIZ];   /* Buffer for tty output */
+var    short   oprompt;        /* Saved during source */
+extern short   ospeed;         /* Output speed (from gtty) */
+var    int     otchng;         /* Backup tchng to find changes in macros */
+var    short   peekc;          /* Peek ahead character (cmd mode input) */
+var    char    *pkill[2];      /* Trim for put with ragged (LISP) delete */
+var    bool    pfast;          /* Have stty -nl'ed to go faster */
+var    int     pid;            /* Process id of child */
+var    int     ppid;           /* Process id of parent (e.g. main ex proc) */
+var    jmp_buf resetlab;       /* For error throws to top level (cmd mode) */
+var    int     rpid;           /* Pid returned from wait() */
+var    bool    ruptible;       /* Interruptible is normal state */
+var    bool    seenprompt;     /* 1 if have gotten user input */
+var    bool    shudclob;       /* Have a prompt to clobber (e.g. on ^D) */
+var    int     status;         /* Status returned from wait() */
+var    int     tchng;          /* If nonzero, then [Modified] */
+extern short   tfile;          /* Temporary file unit */
+var    bool    vcatch;         /* Want to catch an error (open/visual) */
+var    jmp_buf vreslab;        /* For error throws to a visual catch */
+var    bool    writing;        /* 1 if in middle of a file write */
+var    int     xchng;          /* Suppresses multiple "No writes" in !cmd */
+var    long    bsize;          /* Block size for disk i/o */
 
 /*
  * Macros
 
 /*
  * Macros
@@ -242,11 +282,11 @@ int       xchng;                  /* Suppresses multiple "No writes" in !cmd */
 /*
  * Environment like memory
  */
 /*
  * Environment like memory
  */
-char   altfile[FNSIZE];        /* Alternate file name */
-char   direct[ONMSZ];          /* Temp file goes here */
-char   shell[ONMSZ];           /* Copied to be settable */
-char   ttytype[ONMSZ];         /* A long and pretty name */
-char   uxb[UXBSIZE + 2];       /* Last !command for !! */
+var    char    altfile[FNSIZE];        /* Alternate file name */
+extern  char   direct[ONMSZ];          /* Temp file goes here */
+extern  char   shell[ONMSZ];           /* Copied to be settable */
+extern  char   ttytype[ONMSZ];         /* A long and pretty name */
+var    char    uxb[UXBSIZE + 2];       /* Last !command for !! */
 
 /*
  * The editor data structure for accessing the current file consists
 
 /*
  * The editor data structure for accessing the current file consists
@@ -261,14 +301,14 @@ char      uxb[UXBSIZE + 2];       /* Last !command for !! */
  * dol and unddol, a copy of the entire, pre-command buffer state
  * is saved between unddol and truedol.
  */
  * dol and unddol, a copy of the entire, pre-command buffer state
  * is saved between unddol and truedol.
  */
-line   *addr1;                 /* First addressed line in a command */
-line   *addr2;                 /* Second addressed line */
-line   *dol;                   /* Last line in buffer */
-line   *dot;                   /* Current line */
-line   *one;                   /* First line */
-line   *truedol;               /* End of all lines, including saves */
-line   *unddol;                /* End of undo saved lines */
-line   *zero;                  /* Points to empty slot before one */
+var    line    *addr1;                 /* First addressed line in a command */
+var    line    *addr2;                 /* Second addressed line */
+var    line    *dol;                   /* Last line in buffer */
+var    line    *dot;                   /* Current line */
+var    line    *one;                   /* First line */
+var    line    *truedol;               /* End of all lines, including saves */
+var    line    *unddol;                /* End of undo saved lines */
+var    line    *zero;                  /* Points to empty slot before one */
 
 /*
  * Undo information
 
 /*
  * Undo information
@@ -284,12 +324,12 @@ line      *zero;                  /* Points to empty slot before one */
  * are lines saved between dol and unddol we don't stick these back
  * into the buffer.
  */
  * are lines saved between dol and unddol we don't stick these back
  * into the buffer.
  */
-short  undkind;
+var    short   undkind;
 
 
-line   *unddel;                /* Saved deleted lines go after here */
-line   *undap1;                /* Beginning of new lines */
-line   *undap2;                /* New lines end before undap2 */
-line   *undadot;               /* If we saved all lines, dot reverts here */
+var    line    *unddel;        /* Saved deleted lines go after here */
+var    line    *undap1;        /* Beginning of new lines */
+var    line    *undap2;        /* New lines end before undap2 */
+var    line    *undadot;       /* If we saved all lines, dot reverts here */
 
 #define        UNDCHANGE       0
 #define        UNDMOVE         1
 
 #define        UNDCHANGE       0
 #define        UNDMOVE         1
@@ -297,19 +337,21 @@ line      *undadot;               /* If we saved all lines, dot reverts here */
 #define        UNDNONE         3
 #define        UNDPUT          4
 
 #define        UNDNONE         3
 #define        UNDPUT          4
 
+#ifdef CRYPT
 /*
  * Various miscellaneous flags and buffers needed by the encryption routines.
  */
 #define        KSIZE   9       /* key size for encryption */
 #define        KEYPROMPT       "Key: "
 /*
  * Various miscellaneous flags and buffers needed by the encryption routines.
  */
 #define        KSIZE   9       /* key size for encryption */
 #define        KEYPROMPT       "Key: "
-int    xflag;          /* True if we are in encryption mode */
-int    xtflag;         /* True if the temp file is being encrypted */
-int    kflag;          /* True if the key has been accepted */
-char   perm[768];
-char   tperm[768];
-char   *key;
-char   crbuf[CRSIZE];
+var    int     xflag;          /* True if we are in encryption mode */
+var    int     xtflag;         /* True if the temp file is being encrypted */
+var    int     kflag;          /* True if the key has been accepted */
+var    char    perm[768];
+var    char    tperm[768];
+var    char    *key;
+var    char    crbuf[CRSIZE];
 char   *getpass();
 char   *getpass();
+#endif
 
 /*
  * Function type definitions
 
 /*
  * Function type definitions
@@ -317,10 +359,10 @@ char      *getpass();
 #define        NOSTR   (char *) 0
 #define        NOLINE  (line *) 0
 
 #define        NOSTR   (char *) 0
 #define        NOLINE  (line *) 0
 
-int    (*Outchar)();
-int    (*Pline)();
-int    (*Putchar)();
-int    (*oldhup)();
+extern int     (*Outchar)();
+extern int     (*Pline)();
+extern int     (*Put_char)();
+sig_t  oldhup;
 int    (*setlist())();
 int    (*setnorm())();
 int    (*setnorm())();
 int    (*setlist())();
 int    (*setnorm())();
 int    (*setnorm())();
@@ -330,6 +372,9 @@ char        *cgoto();
 char   *genindent();
 char   *getblock();
 char   *getenv();
 char   *genindent();
 char   *getblock();
 char   *getenv();
+#ifdef vms
+char   *getlog();
+#endif
 line   *getmark();
 char   *longname();
 char   *mesg();
 line   *getmark();
 char   *longname();
 char   *mesg();
@@ -353,7 +398,7 @@ char        *vskipwh();
 int    put();
 int    putreg();
 int    YANKreg();
 int    put();
 int    putreg();
 int    YANKreg();
-int    delete();
+int    ex_delete();
 int    execl();
 int    filter();
 int    getfile();
 int    execl();
 int    filter();
 int    getfile();
@@ -365,16 +410,16 @@ off_t     lseek();
 int    normchar();
 int    normline();
 int    numbline();
 int    normchar();
 int    normline();
 int    numbline();
-int    (*oldquit)();
-int    onhup();
-int    onintr();
-int    onsusp();
+var    void (*oldquit)();
+void   onhup();
+void   onintr();
+void   onsusp();
 int    putch();
 int    shift();
 int    termchar();
 int    vfilter();
 #ifdef CBREAK
 int    putch();
 int    shift();
 int    termchar();
 int    vfilter();
 #ifdef CBREAK
-int    vintr();
+void   vintr();
 #endif
 int    vputch();
 int    vshftop();
 #endif
 int    vputch();
 int    vshftop();