BSD 4 release
[unix-history] / usr / src / cmd / ex / ex.h
index 9493541..0a7cbb6 100644 (file)
@@ -1,10 +1,11 @@
-/* Copyright (c) 1979 Regents of the University of California */
+/* Copyright (c) 1980 Regents of the University of California */
+/* sccs id:    @(#)ex.h        6.1 10/18/80  */
 #ifdef V6
 #include <retrofit.h>
 #endif
 
 /*
 #ifdef V6
 #include <retrofit.h>
 #endif
 
 /*
- * Ex version 3.1
+ * Ex version 3 (see exact version in ex_cmds.c, search for /Version/)
  *
  * Mark Horton, UC Berkeley
  * Bill Joy, UC Berkeley
  *
  * Mark Horton, UC Berkeley
  * Bill Joy, UC Berkeley
  *
  * Please forward bug reports to
  *
  *
  * Please forward bug reports to
  *
- *     Bill Joy
+ *     Mark Horton
  *     Computer Science Division, EECS
  *     EVANS HALL
  *     U.C. Berkeley 94704
  *     (415) 642-4948
  *     (415) 642-1024 (dept. office)
  *
  *     Computer Science Division, EECS
  *     EVANS HALL
  *     U.C. Berkeley 94704
  *     (415) 642-4948
  *     (415) 642-1024 (dept. office)
  *
- * or to wnj@mit-mc on the ARPA-net.  I would particularly like to hear
+ * or to csvax.mark@berkeley on the ARPA-net.  I would particularly like to hear
  * of additional terminal descriptions you add to the termcap data base.
  */
 
 #include <sys/types.h>
 #include <ctype.h>
 #include <errno.h>
  * of additional terminal descriptions you add to the termcap data base.
  */
 
 #include <sys/types.h>
 #include <ctype.h>
 #include <errno.h>
-#include <sgtty.h>
 #include <signal.h>
 #include <setjmp.h>
 #include <sys/stat.h>
 
 #include <signal.h>
 #include <setjmp.h>
 #include <sys/stat.h>
 
+/*
+ *     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 USG3TTY 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 USG3TTY
+#include <termio.h>
+#define CBREAK xxxxx
+#else
+#include <sgtty.h>
+#endif
+
 extern int errno;
 
 #ifndef VMUNIX
 extern int errno;
 
 #ifndef VMUNIX
@@ -108,11 +124,11 @@ struct    option options[NOPTS + 1];
 #      undef   putchar
 #      undef   getchar
 #else
 #      undef   putchar
 #      undef   getchar
 #else
-#ifdef VMUNIX
+# ifdef        VMUNIX
 #      define  BUFSIZ  1024
 #      define  BUFSIZ  1024
-#else
+# else
 #      define  BUFSIZ  512
 #      define  BUFSIZ  512
-#endif
+# endif
 #      define  NULL    0
 #      define  EOF     -1
 #endif
 #      define  NULL    0
 #      define  EOF     -1
 #endif
@@ -142,6 +158,9 @@ int chng;                   /* Warn "No write" */
 char   *Command;
 short  defwind;                /* -w# change default window size */
 int    dirtcnt;                /* When >= MAXDIRT, should sync temporary */
 char   *Command;
 short  defwind;                /* -w# change default window size */
 int    dirtcnt;                /* When >= MAXDIRT, should sync temporary */
+#ifdef TIOCLGET
+bool   dosusp;                 /* Do SIGTSTP in visual when ^Z typed */
+#endif
 bool   edited;                 /* Current file is [Edited] */
 line   *endcore;               /* Last available core location */
 bool   endline;                /* Last cmd mode command ended with \n */
 bool   edited;                 /* Current file is [Edited] */
 line   *endcore;               /* Last available core location */
 bool   endline;                /* Last cmd mode command ended with \n */
@@ -154,6 +173,7 @@ 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   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 */
 bool   inglobal;               /* Inside g//... or v//... */
 char   *initev;                /* Initial : escape for visual */
 bool   inopen;                 /* Inside open or visual */
@@ -173,6 +193,7 @@ 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 */
 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) */
 short  ospeed;                 /* Output speed (from gtty) */
 int    otchng;                 /* Backup tchng to find changes in macros */
 short  peekc;                  /* Peek ahead character (cmd mode input) */
@@ -183,18 +204,25 @@ 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 */
 jmp_buf        resetlab;               /* For error throws to top level (cmd mode) */
 int    rpid;                   /* Pid returned from wait() */
 bool   ruptible;               /* Interruptible is normal state */
+bool   seenprompt;             /* 1 if have gotten user input */
 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 */
 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 */
+bool   writing;                /* 1 if in middle of a file write */
 int    xchng;                  /* Suppresses multiple "No writes" in !cmd */
 
 /*
  * Macros
  */
 #define        CP(a, b)        (ignore(strcpy(a, b)))
 int    xchng;                  /* Suppresses multiple "No writes" in !cmd */
 
 /*
  * Macros
  */
 #define        CP(a, b)        (ignore(strcpy(a, b)))
+                       /*
+                        * FIXUNDO: do we want to mung undo vars?
+                        * Usually yes unless in a macro or global.
+                        */
+#define FIXUNDO                (inopen >= 0 && (inopen || !inglobal))
 #define ckaw()         {if (chng && value(AUTOWRITE)) wop(0);}
 #define        copy(a,b,c)     Copy((char *) a, (char *) b, c)
 #define        eq(a, b)        ((a) && (b) && strcmp(a, b) == 0)
 #define ckaw()         {if (chng && value(AUTOWRITE)) wop(0);}
 #define        copy(a,b,c)     Copy((char *) a, (char *) b, c)
 #define        eq(a, b)        ((a) && (b) && strcmp(a, b) == 0)
@@ -217,9 +245,9 @@ int xchng;                  /* Suppresses multiple "No writes" in !cmd */
  * Environment like memory
  */
 char   altfile[FNSIZE];        /* Alternate file name */
  * Environment like memory
  */
 char   altfile[FNSIZE];        /* Alternate file name */
-char   direct[32];             /* Temp file goes here */
-char   shell[32];              /* Copied to be settable */
-char   ttytype[16];            /* A long and pretty 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 !! */
 
 /*
 char   uxb[UXBSIZE + 2];       /* Last !command for !! */
 
 /*
@@ -271,6 +299,22 @@ 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: "
+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];
+char   *getpass();
+#endif
+
 /*
  * Function type definitions
  */
 /*
  * Function type definitions
  */
@@ -328,6 +372,7 @@ int numbline();
 int    (*oldquit)();
 int    onhup();
 int    onintr();
 int    (*oldquit)();
 int    onhup();
 int    onintr();
+int    onsusp();
 int    putch();
 int    shift();
 int    termchar();
 int    putch();
 int    shift();
 int    termchar();