Must distinguish between "ambiguous" and "unknown" commands.
[unix-history] / usr / src / usr.bin / ex / ex.h
index bb48d3e..85c37be 100644 (file)
@@ -1,5 +1,11 @@
-/* Copyright (c) 1981 Regents of the University of California */
-/* sccs id:    @(#)ex.h        7.1     %G%  */
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved.  The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ *     @(#)ex.h        7.8 (Berkeley) %G%
+ */
+
 #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 +122,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
 
-extern 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,18 +143,20 @@ extern 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>
-       extern FILE     *trace;
-       extern bool     trubble;
-       extern bool     techoin;
-       extern 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
 #      define  NULL    0
 #      define  EOF     -1
 # endif
 #      define  NULL    0
 #      define  EOF     -1
@@ -143,6 +172,9 @@ extern struct       option options[NOPTS + 1];
  */
 #define        QUOTE   0200
 #define        TRIM    0177
  */
 #define        QUOTE   0200
 #define        TRIM    0177
+#ifndef vms
+#undef CTRL
+#endif
 #define        CTRL(c) ('c' & 037)
 #define        NL      CTRL(j)
 #define        CR      CTRL(m)
 #define        CTRL(c) ('c' & 037)
 #define        NL      CTRL(j)
 #define        CR      CTRL(m)
@@ -152,67 +184,68 @@ extern struct     option options[NOPTS + 1];
 /*
  * Miscellaneous random variables used in more than one place
  */
 /*
  * Miscellaneous random variables used in more than one place
  */
-extern bool    aiflag;         /* Append/change/insert with autoindent */
-extern bool    anymarks;       /* We have used '[a-z] */
-extern int     chng;           /* Warn "No write" */
-extern char    *Command;
-extern short   defwind;        /* -w# change default window size */
-extern 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
-extern bool    dosusp;         /* Do SIGTSTP in visual when ^Z typed */
+var    bool    dosusp;         /* Do SIGTSTP in visual when ^Z typed */
 #endif
 #endif
-extern bool    edited;         /* Current file is [Edited] */
-extern line    *endcore;       /* Last available core location */
-extern bool    endline;        /* Last cmd mode command ended with \n */
-#ifndef VMUNIX
-extern 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
-extern line    *fendcore;      /* First address in line pointer space */
-extern char    file[FNSIZE];   /* Working file name */
-extern char    genbuf[LBSIZE]; /* Working buffer when manipulating linebuf */
-extern bool    hush;           /* Command line option - was given, hush up! */
-extern char    *globp;         /* (Untyped) input string to command mode */
-extern bool    holdcm;         /* Don't cursor address */
-extern bool    inappend;       /* in ex command append mode */
-extern bool    inglobal;       /* Inside g//... or v//... */
-extern char    *initev;        /* Initial : escape for visual */
-extern bool    inopen;         /* Inside open or visual */
-extern char    *input;         /* Current position in cmd line input buffer */
-extern bool    intty;          /* Input is a tty */
-extern short   io;             /* General i/o unit (auto-closed on error!) */
-extern short   lastc;          /* Last character ret'd from cmd input */
-extern bool    laste;          /* Last command was an "e" (or "rec") */
-extern char    lastmac;        /* Last macro called for ** */
-extern char    lasttag[TAGSIZE];       /* Last argument to a tag command */
-extern char    *linebp;        /* Used in substituting in \n */
-extern char    linebuf[LBSIZE];        /* The primary line buffer */
-extern bool    listf;          /* Command should run in list mode */
-extern char    *loc1;          /* Where re began to match (in linebuf) */
-extern char    *loc2;          /* First char after re match (") */
-extern line    names['z'-'a'+2];       /* Mark registers a-z,' */
-extern int     notecnt;        /* Count for notify (to visual from cmd) */
-extern bool    numberf;        /* Command should run in number mode */
-extern char    obuf[BUFSIZ];   /* Buffer for tty output */
-extern short   oprompt;        /* Saved during source */
-extern short   ospeed;         /* Output speed (from gtty) */
-extern int     otchng;         /* Backup tchng to find changes in macros */
-extern short   peekc;          /* Peek ahead character (cmd mode input) */
-extern char    *pkill[2];      /* Trim for put with ragged (LISP) delete */
-extern bool    pfast;          /* Have stty -nl'ed to go faster */
-extern int     pid;            /* Process id of child */
-extern int     ppid;           /* Process id of parent (e.g. main ex proc) */
-extern jmp_buf resetlab;       /* For error throws to top level (cmd mode) */
-extern int     rpid;           /* Pid returned from wait() */
-extern bool    ruptible;       /* Interruptible is normal state */
-extern bool    seenprompt;     /* 1 if have gotten user input */
-extern bool    shudclob;       /* Have a prompt to clobber (e.g. on ^D) */
-extern int     status;         /* Status returned from wait() */
-extern int     tchng;          /* If nonzero, then [Modified] */
-extern short   tfile;          /* Temporary file unit */
-extern bool    vcatch;         /* Want to catch an error (open/visual) */
-extern jmp_buf vreslab;        /* For error throws to a visual catch */
-extern bool    writing;        /* 1 if in middle of a file write */
-extern 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
@@ -244,11 +277,11 @@ extern int        xchng;          /* Suppresses multiple "No writes" in !cmd */
 /*
  * Environment like memory
  */
 /*
  * Environment like memory
  */
-extern 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 */
-extern 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
@@ -263,14 +296,14 @@ extern 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.
  */
-extern line    *addr1;                 /* First addressed line in a command */
-extern line    *addr2;                 /* Second addressed line */
-extern line    *dol;                   /* Last line in buffer */
-extern line    *dot;                   /* Current line */
-extern line    *one;                   /* First line */
-extern line    *truedol;               /* End of all lines, including saves */
-extern line    *unddol;                /* End of undo saved lines */
-extern 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
@@ -286,12 +319,12 @@ extern 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.
  */
-extern short   undkind;
+var    short   undkind;
 
 
-extern line    *unddel;        /* Saved deleted lines go after here */
-extern line    *undap1;        /* Beginning of new lines */
-extern line    *undap2;        /* New lines end before undap2 */
-extern 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
@@ -299,21 +332,6 @@ extern 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: "
-extern int     xflag;          /* True if we are in encryption mode */
-extern int     xtflag;         /* True if the temp file is being encrypted */
-extern int     kflag;          /* True if the key has been accepted */
-extern char    perm[768];
-extern char    tperm[768];
-extern char    *key;
-extern char    crbuf[CRSIZE];
-char   *getpass();
-#endif
 
 /*
  * Function type definitions
 
 /*
  * Function type definitions
@@ -321,10 +339,10 @@ char      *getpass();
 #define        NOSTR   (char *) 0
 #define        NOLINE  (line *) 0
 
 #define        NOSTR   (char *) 0
 #define        NOLINE  (line *) 0
 
-extern int     (*Outchar)();
-extern int     (*Pline)();
-extern int     (*Putchar)();
-extern int     (*oldhup)();
+extern int     (*Outchar)();
+extern int     (*Pline)();
+extern int     (*Put_char)();
+var    int     (*oldhup)();
 int    (*setlist())();
 int    (*setnorm())();
 int    (*setnorm())();
 int    (*setlist())();
 int    (*setnorm())();
 int    (*setnorm())();
@@ -334,6 +352,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();
@@ -357,7 +378,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();
@@ -369,7 +390,7 @@ off_t       lseek();
 int    normchar();
 int    normline();
 int    numbline();
 int    normchar();
 int    normline();
 int    numbline();
-extern int     (*oldquit)();
+var    int     (*oldquit)();
 int    onhup();
 int    onintr();
 int    onsusp();
 int    onhup();
 int    onintr();
 int    onsusp();