BSD 4_3_Net_2 release
[unix-history] / usr / src / usr.bin / mail / def.h
index cc5b9e5..a0bdc79 100644 (file)
@@ -1,56 +1,71 @@
-#
-
-#include "local.h"
-#include <sys/types.h>
-#include <signal.h>
-#include <stdio.h>
-
-#undef isalpha
-#undef isdigit
-
 /*
 /*
- * Sccs Id = "@(#)def.h        1.8 %G%";
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * 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.
+ *
+ *     @(#)def.h       5.22 (Berkeley) 6/25/90
  */
 
  */
 
+#include <sys/param.h>         /* includes <sys/types.h> */
+#include <sys/signal.h>
+#include <stdio.h>
+#include <sgtty.h>
+#include <ctype.h>
+#include <string.h>
+#include "pathnames.h"
+
 /*
  * Mail -- a mail program
  *
 /*
  * Mail -- a mail program
  *
- * Commands are:
- *     t <message list>                print out these messages
- *     r <message list>                reply to messages
- *     m <user list>                   mail to users (analogous to send)
- *     e <message list>                edit messages
- *     c [directory]                   chdir to dir or home if none
- *     x                               exit quickly
- *     w <message list> file           save messages in file
- *     q                               quit, save remaining stuff in mbox
- *     d <message list>                delete messages
- *     u <message list>                undelete messages
- *     h                               print message headers
- *
  * Author: Kurt Shoens (UCB) March 25, 1978
  */
 
  * Author: Kurt Shoens (UCB) March 25, 1978
  */
 
+#define        APPEND                          /* New mail goes to end of mailbox */
 
 #define        ESCAPE          '~'             /* Default escape for sending */
 
 #define        ESCAPE          '~'             /* Default escape for sending */
-#define        NMLSIZE         20              /* max names in a message list */
-#define        PATHSIZE        35              /* Size of pathnames throughout */
-#define        NAMESIZE        20              /* Max size of user name */
-#define        HSHSIZE         19              /* Hash size for aliases and vars */
-#define        HDRFIELDS       3               /* Number of header fields */
-#define        LINESIZE        512             /* max readable line width */
-#define        SCREEN          18              /* screen size in lines (effective) */
+#define        NMLSIZE         1024            /* max names in a message list */
+#define        PATHSIZE        MAXPATHLEN      /* Size of pathnames throughout */
+#define        HSHSIZE         59              /* Hash size for aliases and vars */
+#define        LINESIZE        BUFSIZ          /* max readable line width */
 #define        STRINGSIZE      ((unsigned) 128)/* Dynamic allocation units */
 #define        STRINGSIZE      ((unsigned) 128)/* Dynamic allocation units */
-#define        MAXARGC         20              /* Maximum list of raw strings */
+#define        MAXARGC         1024            /* Maximum list of raw strings */
 #define        NOSTR           ((char *) 0)    /* Null string pointer */
 #define        MAXEXP          25              /* Maximum expansion of aliases */
 #define        NOSTR           ((char *) 0)    /* Null string pointer */
 #define        MAXEXP          25              /* Maximum expansion of aliases */
+
 #define        equal(a, b)     (strcmp(a,b)==0)/* A nice function to string compare */
 
 struct message {
        short   m_flag;                 /* flags, see below */
        short   m_block;                /* block number of this message */
        short   m_offset;               /* offset in block of message */
 #define        equal(a, b)     (strcmp(a,b)==0)/* A nice function to string compare */
 
 struct message {
        short   m_flag;                 /* flags, see below */
        short   m_block;                /* block number of this message */
        short   m_offset;               /* offset in block of message */
-       unsigned        m_size;         /* Bytes in the message */
+       long    m_size;                 /* Bytes in the message */
        short   m_lines;                /* Lines in the message */
 };
 
        short   m_lines;                /* Lines in the message */
 };
 
@@ -58,16 +73,24 @@ struct message {
  * flag bits.
  */
 
  * flag bits.
  */
 
-#define        MUSED           1               /* entry is used, but this bit isn't */
-#define        MDELETED        2               /* entry has been deleted */
-#define        MSAVED          4               /* entry has been saved */
-#define        MTOUCH          8               /* entry has been noticed */
-#define        MPRESERVE       16              /* keep entry in sys mailbox */
-#define        MMARK           32              /* message is marked! */
-#define        MODIFY          64              /* message has been modified */
-#define        MNEW            128             /* message has never been seen */
-#define        MREAD           256             /* message has been read sometime. */
-#define        MSTATUS         512             /* message status has changed */
+#define        MUSED           (1<<0)          /* entry is used, but this bit isn't */
+#define        MDELETED        (1<<1)          /* entry has been deleted */
+#define        MSAVED          (1<<2)          /* entry has been saved */
+#define        MTOUCH          (1<<3)          /* entry has been noticed */
+#define        MPRESERVE       (1<<4)          /* keep entry in sys mailbox */
+#define        MMARK           (1<<5)          /* message is marked! */
+#define        MODIFY          (1<<6)          /* message has been modified */
+#define        MNEW            (1<<7)          /* message has never been seen */
+#define        MREAD           (1<<8)          /* message has been read sometime. */
+#define        MSTATUS         (1<<9)          /* message status has changed */
+#define        MBOX            (1<<10)         /* Send this to mbox, regardless */
+
+/*
+ * Given a file address, determine the block number it represents.
+ */
+#define blockof(off)                   ((int) ((off) / 4096))
+#define offsetof(off)                  ((int) ((off) % 4096))
+#define positionof(block, offset)      ((off_t)(block) * 4096 + (offset))
 
 /*
  * Format of the command description table.
 
 /*
  * Format of the command description table.
@@ -100,7 +123,7 @@ struct cmd {
 
 #define        P       040             /* Autoprint dot after command */
 #define        I       0100            /* Interactive command bit */
 
 #define        P       040             /* Autoprint dot after command */
 #define        I       0100            /* Interactive command bit */
-#define        M       0200            /* Illegal from send mode bit */
+#define        M       0200            /* Legal from send mode bit */
 #define        W       0400            /* Illegal when read only bit */
 #define        F       01000           /* Is a conditional command */
 #define        T       02000           /* Is a transparent command */
 #define        W       0400            /* Illegal when read only bit */
 #define        F       01000           /* Is a conditional command */
 #define        T       02000           /* Is a transparent command */
@@ -141,11 +164,11 @@ struct headline {
  */
 
 struct header {
  */
 
 struct header {
-       char    *h_to;                  /* Dynamic "To:" string */
-       char    *h_subject;             /* Subject string */
-       char    *h_cc;                  /* Carbon copies string */
-       char    *h_bcc;                 /* Blind carbon copies */
-       int     h_seq;                  /* Sequence for optimization */
+       struct name *h_to;              /* Dynamic "To:" string */
+       char *h_subject;                /* Subject string */
+       struct name *h_cc;              /* Carbon copies string */
+       struct name *h_bcc;             /* Blind carbon copies */
+       struct name *h_smopts;          /* Sendmail options */
 };
 
 /*
 };
 
 /*
@@ -190,6 +213,17 @@ struct grouphead {
 #define        NOGRP   ((struct grouphead *) 0)/* The nil grouphead pointer */
 #define        NOGE    ((struct group *) 0)    /* The nil group pointer */
 
 #define        NOGRP   ((struct grouphead *) 0)/* The nil grouphead pointer */
 #define        NOGE    ((struct group *) 0)    /* The nil group pointer */
 
+/*
+ * Structure of the hash table of ignored header fields
+ */
+struct ignoretab {
+       int i_count;                    /* Number of entries */
+       struct ignore {
+               struct ignore *i_link;  /* Next ignored field in bucket */
+               char *i_field;          /* This ignored field */
+       } *i_head[HSHSIZE];
+};
+
 /*
  * Token values returned by the scanner used for argument lists.
  * Also, sizes of scanner-related things.
 /*
  * Token values returned by the scanner used for argument lists.
  * Also, sizes of scanner-related things.
@@ -206,9 +240,10 @@ struct grouphead {
 #define        TOPEN   8                       /* An '(' */
 #define        TCLOSE  9                       /* A ')' */
 #define TPLUS  10                      /* A '+' */
 #define        TOPEN   8                       /* An '(' */
 #define        TCLOSE  9                       /* A ')' */
 #define TPLUS  10                      /* A '+' */
+#define TERROR 11                      /* A lexical error */
 
 #define        REGDEP  2                       /* Maximum regret depth. */
 
 #define        REGDEP  2                       /* Maximum regret depth. */
-#define        STRINGLEN       64              /* Maximum length of string token */
+#define        STRINGLEN       1024            /* Maximum length of string token */
 
 /*
  * Constants for conditional commands.  These describe whether
 
 /*
  * Constants for conditional commands.  These describe whether
@@ -227,67 +262,62 @@ struct grouphead {
 #define        reset(x)        longjmp(srbuf, x)
 
 /*
 #define        reset(x)        longjmp(srbuf, x)
 
 /*
- * VM/UNIX has a vfork system call which is faster than forking.  If we
- * don't have it, fork(2) will do . . .
+ * Truncate a file to the last character written. This is
+ * useful just before closing an old file that was opened
+ * for read/write.
  */
  */
-
-#ifndef VMUNIX
-#define        vfork() fork()
-#endif
+#define trunc(stream)  ftruncate(fileno(stream), (long) ftell(stream))
 
 /*
  * Forward declarations of routine types to keep lint and cc happy.
  */
 
 
 /*
  * Forward declarations of routine types to keep lint and cc happy.
  */
 
+FILE   *Fopen();
 FILE   *Fdopen();
 FILE   *Fdopen();
+FILE   *Popen();
 FILE   *collect();
 FILE   *infix();
 FILE   *collect();
 FILE   *infix();
-FILE   *mesedit();
-FILE   *mespipe();
-FILE   *popen();
+FILE   *run_editor();
 FILE   *setinput();
 char   **unpack();
 FILE   *setinput();
 char   **unpack();
-char   *addto();
-char   *arpafix();
 char   *calloc();
 char   *copy();
 char   *copyin();
 char   *detract();
 char   *expand();
 char   *calloc();
 char   *copy();
 char   *copyin();
 char   *detract();
 char   *expand();
+char   *getdeadletter();
 char   *gets();
 char   *hfield();
 char   *gets();
 char   *hfield();
-char   *index();
+char   *name1();
 char   *nameof();
 char   *nextword();
 char   *getenv();
 char   *nameof();
 char   *nextword();
 char   *getenv();
-char   *getfilename();
-char   *hcontents();
-char   *netmap();
-char   *netname();
+char   *getname();
+char   *fgets();
+char   *ishfield();
+char   *malloc();
+char   *mktemp();
 char   *readtty();
 char   *readtty();
-char   *rename();
-char   *revarpa();
-char   *rindex();
-char   *rpair();
+char   *reedit();
 char   *salloc();
 char   *savestr();
 char   *salloc();
 char   *savestr();
-char   *savestr();
+char   *skin();
 char   *snarf();
 char   *snarf();
+char   *username();
 char   *value();
 char   *vcopy();
 char   *yankword();
 off_t  fsize();
 char   *value();
 char   *vcopy();
 char   *yankword();
 off_t  fsize();
+uid_t  getuid();
 struct cmd     *lex();
 struct grouphead       *findgroup();
 struct cmd     *lex();
 struct grouphead       *findgroup();
+struct name    *nalloc();
 struct name    *cat();
 struct name    *delname();
 struct name    *elide();
 struct name    *extract();
 struct name    *gexpand();
 struct name    *cat();
 struct name    *delname();
 struct name    *elide();
 struct name    *extract();
 struct name    *gexpand();
-struct name    *map();
 struct name    *outof();
 struct name    *put();
 struct name    *usermap();
 struct name    *outof();
 struct name    *put();
 struct name    *usermap();
-struct name    *verify();
 struct var     *lookup();
 struct var     *lookup();
-unsigned       int     msize();