4.4BSD snapshot (revision 8.1); add 1993 to copyright
[unix-history] / usr / src / usr.bin / mail / def.h
index 39f1bf9..758ae71 100644 (file)
@@ -1,56 +1,50 @@
-#
-
-#include <sys/types.h>
-#include <signal.h>
-#include <stdio.h>
-#include <sgtty.h>
-#include "local.h"
-
-#undef isalpha
-#undef isdigit
-
 /*
 /*
- * Sccs Id = "@(#)def.h        2.7 %G%";
+ * Copyright (c) 1980, 1993
+ *     The Regents of the University of California.  All rights reserved.
+ *
+ * %sccs.include.redist.c%
+ *
+ *     @(#)def.h       8.1 (Berkeley) %G%
  */
 
 /*
  * 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
  */
 
+#include <sys/param.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+
+#include <signal.h>
+#include <sgtty.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <ctype.h>
+#include <string.h>
+#include "pathnames.h"
+
+#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        100             /* 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        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        LINESIZE        BUFSIZ          /* max readable line width */
 #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 */
 };
 
@@ -70,12 +64,18 @@ struct message {
 #define        MSTATUS         (1<<9)          /* message status has changed */
 #define        MBOX            (1<<10)         /* Send this to mbox, regardless */
 
 #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.
  * The actual table is declared and initialized
  * in lex.c
  */
 /*
  * Format of the command description table.
  * The actual table is declared and initialized
  * in lex.c
  */
-
 struct cmd {
        char    *c_name;                /* Name of command */
        int     (*c_func)();            /* Implementor of the command */
 struct cmd {
        char    *c_name;                /* Name of command */
        int     (*c_func)();            /* Implementor of the command */
@@ -142,11 +142,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 */
 };
 
 /*
 };
 
 /*
@@ -194,9 +194,12 @@ struct grouphead {
 /*
  * Structure of the hash table of ignored header fields
  */
 /*
  * Structure of the hash table of ignored header fields
  */
-struct ignore {
-       struct ignore   *i_link;        /* Next ignored field in bucket */
-       char            *i_field;       /* This ignored field */
+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];
 };
 
 /*
 };
 
 /*
@@ -215,9 +218,10 @@ struct ignore {
 #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
@@ -236,71 +240,8 @@ struct ignore {
 #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 . . .
- */
-
-#ifndef VMUNIX
-#define        vfork() fork()
-#endif
-
-/*
- * Forward declarations of routine types to keep lint and cc happy.
+ * Truncate a file to the last character written. This is
+ * useful just before closing an old file that was opened
+ * for read/write.
  */
  */
-
-FILE   *Fdopen();
-FILE   *collect();
-FILE   *infix();
-FILE   *mesedit();
-FILE   *mespipe();
-FILE   *popen();
-FILE   *setinput();
-char   **unpack();
-char   *addto();
-char   *arpafix();
-char   *calloc();
-char   *copy();
-char   *copyin();
-char   *detract();
-char   *expand();
-char   *gets();
-char   *hfield();
-char   *index();
-char   *name1();
-char   *nameof();
-char   *nextword();
-char   *getenv();
-char   *getfilename();
-char   *hcontents();
-char   *netmap();
-char   *netname();
-char   *readtty();
-char   *reedit();
-char   *rename();
-char   *revarpa();
-char   *rindex();
-char   *rpair();
-char   *salloc();
-char   *savestr();
-char   *savestr();
-char   *skin();
-char   *snarf();
-char   *value();
-char   *vcopy();
-char   *yankword();
-off_t  fsize();
-int    (*sigset())();
-struct cmd     *lex();
-struct grouphead       *findgroup();
-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    *verify();
-struct var     *lookup();
-unsigned       int     msize();
+#define trunc(stream)  ftruncate(fileno(stream), (long) ftell(stream))