BSD 4_4 release
[unix-history] / usr / src / bin / csh / csh.h
index 93d2135..367b51e 100644 (file)
@@ -1,10 +1,36 @@
 /*-
 /*-
- * Copyright (c) 1980, 1991 The Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1980, 1991, 1993
+ *     The Regents of the University of California.  All rights reserved.
  *
  *
- * %sccs.include.redist.c%
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 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.
  *
  *
- *     @(#)csh.h       5.16 (Berkeley) %G%
+ * 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
+ * SUCH DAMAGE.
+ *
+ *     @(#)csh.h       8.1 (Berkeley) 5/31/93
  */
 
 /*
  */
 
 /*
@@ -45,6 +71,12 @@ typedef char Char;
 #define SAVE(a) (strsave(a))
 #endif
 
 #define SAVE(a) (strsave(a))
 #endif
 
+/*
+ * Make sure a variable is not stored in a register by taking its address
+ * This is used where variables might be clobbered by longjmp.
+ */
+#define UNREGISTER(a)  (void) &a
+
 typedef void *ioctl_t;         /* Third arg of ioctl */
 
 typedef void *ptr_t;
 typedef void *ioctl_t;         /* Third arg of ioctl */
 
 typedef void *ptr_t;
@@ -53,27 +85,16 @@ typedef void *ptr_t;
 #include "char.h"
 #include "err.h"
 
 #include "char.h"
 #include "err.h"
 
-#ifdef SYSMALLOC
 #define xmalloc(i)     Malloc(i)
 #define xrealloc(p, i) Realloc(p, i)
 #define xcalloc(n, s)  Calloc(n, s)
 #define xfree(p)       Free(p)
 #define xmalloc(i)     Malloc(i)
 #define xrealloc(p, i) Realloc(p, i)
 #define xcalloc(n, s)  Calloc(n, s)
 #define xfree(p)       Free(p)
-#else
-#define xmalloc(i)     malloc(i)
-#define xrealloc(p, i) realloc(p, i)
-#define xcalloc(n, s)  calloc(n, s)
-#define xfree(p)       free(p)
-#endif                         /* SYSMALLOC */
 
 #include <stdio.h>
 FILE *cshin, *cshout, *csherr;
 
 #define        isdir(d)        ((d.st_mode & S_IFMT) == S_IFDIR)
 
 
 #include <stdio.h>
 FILE *cshin, *cshout, *csherr;
 
 #define        isdir(d)        ((d.st_mode & S_IFMT) == S_IFDIR)
 
-#define SIGN_EXTEND_CHAR(a) \
-       ((a) & 0x80 ? ((int) (a)) | 0xffffff00 : ((int) a) & 0x000000ff)
-
-
 typedef int bool;
 
 #define        eq(a, b)        (Strcmp(a, b) == 0)
 typedef int bool;
 
 #define        eq(a, b)        (Strcmp(a, b) == 0)
@@ -117,6 +138,7 @@ Char   *ffile;                      /* Name of shell file for $0 */
 char   *seterr;                        /* Error message from scanner/parser */
 Char   *shtemp;                        /* Temp name for << shell files in /tmp */
 
 char   *seterr;                        /* Error message from scanner/parser */
 Char   *shtemp;                        /* Temp name for << shell files in /tmp */
 
+#include <sys/types.h>
 #include <sys/time.h>
 #include <sys/resource.h>
 
 #include <sys/time.h>
 #include <sys/resource.h>
 
@@ -127,8 +149,9 @@ struct rusage ru0;
  * Miscellany
  */
 Char   *doldol;                        /* Character pid for $$ */
  * Miscellany
  */
 Char   *doldol;                        /* Character pid for $$ */
-int     uid;                   /* Invokers uid */
-int     gid;                   /* Invokers gid */
+int    backpid;                /* Pid of the last background process */
+int     uid, euid;             /* Invokers uid */
+int     gid, egid;             /* Invokers gid */
 time_t  chktim;                        /* Time mail last checked */
 int     shpgrp;                        /* Pgrp of shell */
 int     tpgrp;                 /* Terminal process group */
 time_t  chktim;                        /* Time mail last checked */
 int     shpgrp;                        /* Pgrp of shell */
 int     tpgrp;                 /* Terminal process group */
@@ -142,8 +165,7 @@ int     opgrp;                      /* Initial pgrp and tty pgrp */
  * descriptors it uses away from 0,1,2.
  * Ideally these should be in units which are closed across exec's
  * (this saves work) but for version 6, this is not usually possible.
  * descriptors it uses away from 0,1,2.
  * Ideally these should be in units which are closed across exec's
  * (this saves work) but for version 6, this is not usually possible.
- * The desired initial values for these descriptors are defined in
- * local.h.
+ * The desired initial values for these descriptors are F{SHIN,...}.
  */
 int   SHIN;                    /* Current shell input (script) */
 int   SHOUT;                   /* Shell output */
  */
 int   SHIN;                    /* Current shell input (script) */
 int   SHOUT;                   /* Shell output */
@@ -177,7 +199,7 @@ sig_t parterm;                      /* Parents terminate catch */
  * Lexical definitions.
  *
  * All lexical space is allocated dynamically.
  * Lexical definitions.
  *
  * All lexical space is allocated dynamically.
- * The eighth/sizteenth bit of characters is used to prevent recognition,
+ * The eighth/sixteenth bit of characters is used to prevent recognition,
  * and eventually stripped.
  */
 #define        META            0200
  * and eventually stripped.
  */
 #define        META            0200
@@ -209,6 +231,28 @@ struct Bin {
     Char  **Bfbuf;             /* The array of buffer blocks */
 }       B;
 
     Char  **Bfbuf;             /* The array of buffer blocks */
 }       B;
 
+/*
+ * This structure allows us to seek inside aliases
+ */
+struct Ain {
+    int type;
+#define I_SEEK -1              /* Invalid seek */
+#define A_SEEK 0               /* Alias seek */
+#define F_SEEK 1               /* File seek */
+#define E_SEEK 2               /* Eval seek */
+    union {
+       off_t _f_seek;
+       Char* _c_seek;
+    } fc;
+#define f_seek fc._f_seek
+#define c_seek fc._c_seek
+    Char **a_seek;
+} ;
+extern int aret;               /* What was the last character returned */
+#define SEEKEQ(a, b) ((a)->type == (b)->type && \
+                     (a)->f_seek == (b)->f_seek && \
+                     (a)->a_seek == (b)->a_seek)
+
 #define        fseekp  B.Bfseekp
 #define        fbobp   B.Bfbobp
 #define        feobp   B.Bfeobp
 #define        fseekp  B.Bfseekp
 #define        fbobp   B.Bfbobp
 #define        feobp   B.Bfeobp
@@ -220,7 +264,7 @@ struct Bin {
  * For whiles, in particular, it reseeks to the beginning of the
  * line the while was on; hence the while placement restrictions.
  */
  * For whiles, in particular, it reseeks to the beginning of the
  * line the while was on; hence the while placement restrictions.
  */
-off_t   lineloc;
+struct Ain lineloc;
 
 bool    cantell;               /* Is current source tellable ? */
 
 
 bool    cantell;               /* Is current source tellable ? */
 
@@ -353,8 +397,8 @@ extern int nsrchn;
  * input.  For foreach (fe), the word list is attached here.
  */
 struct whyle {
  * input.  For foreach (fe), the word list is attached here.
  */
 struct whyle {
-    off_t   w_start;           /* Point to restart loop */
-    off_t   w_end;             /* End of loop (0 if unknown) */
+    struct Ain   w_start;      /* Point to restart loop */
+    struct Ain   w_end;                /* End of loop (0 if unknown) */
     Char  **w_fe, **w_fe0;     /* Current/initial wordlist for fe */
     Char   *w_fename;          /* Name for fe */
     struct whyle *w_next;      /* Next (more outer) loop */
     Char  **w_fe, **w_fe0;     /* Current/initial wordlist for fe */
     Char   *w_fename;          /* Name for fe */
     struct whyle *w_next;      /* Next (more outer) loop */
@@ -387,7 +431,7 @@ struct varent *adrof1();
  */
 struct wordent *alhistp;       /* Argument list (first) */
 struct wordent *alhistt;       /* Node after last in arg list */
  */
 struct wordent *alhistp;       /* Argument list (first) */
 struct wordent *alhistt;       /* Node after last in arg list */
-Char  **alvec                /* The (remnants of) alias vector */
+Char  **alvec, *alvecp;                /* The (remnants of) alias vector */
 
 /*
  * Filename/command name expansion variables
 
 /*
  * Filename/command name expansion variables
@@ -458,7 +502,7 @@ Char    HISTSUB;            /* auto-substitute character */
 #define str2short(a)           (a)
 #define blk2short(a)           saveblk(a)
 #define short2blk(a)           saveblk(a)
 #define str2short(a)           (a)
 #define blk2short(a)           saveblk(a)
 #define short2blk(a)           saveblk(a)
-#define short2str(a)           trim(a)
+#define short2str(a)           strip(a)
 #else
 #define Strchr(a, b)           s_strchr(a, b)
 #define Strrchr(a, b)          s_strrchr(a, b)
 #else
 #define Strchr(a, b)           s_strchr(a, b)
 #define Strrchr(a, b)          s_strrchr(a, b)
@@ -491,11 +535,6 @@ char  **Vt;
 Char  **evalvec;
 Char   *evalp;
 
 Char  **evalvec;
 Char   *evalp;
 
-extern struct mesg {
-    char   *iname;             /* name from /usr/include */
-    char   *pname;             /* print name */
-}       mesg[];
-
 /* word_chars is set by default to WORD_CHARS but can be overridden by
    the worchars variable--if unset, reverts to WORD_CHARS */
 
 /* word_chars is set by default to WORD_CHARS but can be overridden by
    the worchars variable--if unset, reverts to WORD_CHARS */