home *** CD-ROM | disk | FTP | other *** search
/ minnie.tuhs.org / unixen.tar / unixen / PDP-11 / Distributions / ucb / spencer_2bsd.tar.gz / 2bsd.tar / src / Mail / def.h < prev    next >
C/C++ Source or Header  |  1980-02-17  |  6KB  |  231 lines

  1. /* Copyright (c) 1979 Regents of the University of California */
  2. #
  3.  
  4. #include <local.h>
  5. #include <sys/types.h>
  6. #include <signal.h>
  7. #include <stdio.h>
  8.  
  9. #undef isalpha
  10. #undef isdigit
  11.  
  12. /*
  13.  * Mail -- a mail program
  14.  *
  15.  * Commands are:
  16.  *    t <message list>        print out these messages
  17.  *    r <message list>        reply to messages
  18.  *    m <user list>            mail to users (analogous to send)
  19.  *    e <message list>        edit messages
  20.  *    c [directory]            chdir to dir or home if none
  21.  *    x                exit quickly
  22.  *    w <message list> file        save messages in file
  23.  *    q                quit, save remaining stuff in mbox
  24.  *    d <message list>        delete messages
  25.  *    u <message list>        undelete messages
  26.  *    h                print message headers
  27.  *
  28.  * Author: Kurt Shoens (UCB) March 25, 1978
  29.  */
  30.  
  31.  
  32. #define    ESCAPE        '~'        /* Default escape for sending */
  33. #define    NMLSIZE        20        /* max names in a message list */
  34. #define    PATHSIZE    35        /* Size of pathnames throughout */
  35. #define    NAMESIZE    20        /* Max size of user name */
  36. #define    HSHSIZE        19        /* Hash size for aliases and vars */
  37. #define    HDRFIELDS    3        /* Number of header fields */
  38. #define    LINESIZE    512        /* max readable line width */
  39. #define    SCREEN        18        /* screen size in lines (effective) */
  40. #define    STRINGSIZE    ((unsigned) 128)/* Dynamic allocation units */
  41. #define    MAXARGC        20        /* Maximum list of raw strings */
  42. #define    NOSTR        ((char *) 0)    /* Null string pointer */
  43. #define    equal(a, b)    (strcmp(a,b)==0)/* A nice function to string compare */
  44.  
  45. struct message {
  46.     flag_t    m_flag;            /* flags, see below */
  47.     int    m_block;        /* block number of this message */
  48.     int    m_offset;        /* offset in block of message */
  49.     unsigned    m_size;        /* Bytes in the message */
  50.     int    m_lines;        /* Lines in the message */
  51. };
  52.  
  53. /*
  54.  * flag bits.
  55.  */
  56.  
  57. #define    MUSED        1        /* entry is used, but this bit isn't */
  58. #define    MDELETED    2        /* entry has been deleted */
  59. #define    MSAVED        4        /* entry has been saved */
  60. #define    MTOUCH        8        /* entry has been noticed */
  61. #define    MPRESERVE    16        /* keep entry in sys mailbox */
  62. #define    MMARK        32        /* message is marked! */
  63. #define    MODIFY        64        /* message has been modified */
  64.  
  65. /*
  66.  * Format of the command description table.
  67.  * The actual table is declared and initialized
  68.  * in lex.c
  69.  */
  70.  
  71. struct cmd {
  72.     char    *c_name;        /* Name of command */
  73.     int    (*c_func)();        /* Implementor of the command */
  74.     flag_t    c_argtype;        /* Type of arglist (see below) */
  75.     flag_t    c_msgflag;        /* Required flags of messages */
  76.     flag_t    c_msgmask;        /* Relevant flags of messages */
  77. };
  78.  
  79. /* Yechh, can't initialize unions */
  80.  
  81. #define    c_minargs c_msgflag        /* Minimum argcount for RAWLIST */
  82. #define    c_maxargs c_msgmask        /* Max argcount for RAWLIST */
  83.  
  84. /*
  85.  * Argument types.
  86.  */
  87.  
  88. #define    MSGLIST     0        /* Message list type */
  89. #define    STRLIST     1        /* A pure string */
  90. #define    RAWLIST     2        /* Shell string list */
  91. #define    NOLIST     3        /* Just plain 0 */
  92. #define    NDMLIST     4        /* Message list, no defaults */
  93.  
  94. #define    P    040        /* Autoprint dot after command */
  95. #define    I    0100        /* Interactive command bit */
  96. #define    M    0200        /* Illegal from send mode bit */
  97.  
  98. /*
  99.  * Oft-used mask values
  100.  */
  101.  
  102. #define    MMNORM        (MDELETED|MSAVED)/* Look at both save and delete bits */
  103. #define    MMNDEL        MDELETED    /* Look only at deleted bit */
  104.  
  105. /*
  106.  * Structure used to return a break down of a head
  107.  * line (hats off to Bill Joy!)
  108.  */
  109.  
  110. struct headline {
  111.     char    *l_from;    /* The name of the sender */
  112.     char    *l_tty;        /* His tty string (if any) */
  113.     char    *l_date;    /* The entire date string */
  114. };
  115.  
  116. #define    GTO    1        /* Grab To: line */
  117. #define    GSUBJ    2        /* Likewise, Subj: line */
  118. #define    GCC    4        /* And the Cc: line */
  119.  
  120. /*
  121.  * Structure used to pass about the current
  122.  * state of the user-typed message header.
  123.  */
  124.  
  125. struct header {
  126.     char    *h_to;            /* Dynamic "To:" string */
  127.     char    *h_subj;        /* Subject string */
  128.     char    *h_cc;            /* Carbon copies string */
  129.     int    h_seq;            /* Sequence for optimization */
  130. };
  131.  
  132. /*
  133.  * Structure of namelist nodes used in processing
  134.  * the recipients of mail and aliases and all that
  135.  * kind of stuff.
  136.  */
  137.  
  138. struct name {
  139.     struct    name *n_flink;        /* Forward link in list. */
  140.     struct    name *n_blink;        /* Backward list link */
  141.     char    *n_name;        /* This fella's name */
  142. };
  143.  
  144. /*
  145.  * Structure of a variable node.  All variables are
  146.  * kept on a singly-linked list of these, rooted by
  147.  * "variables"
  148.  */
  149.  
  150. struct var {
  151.     struct    var *v_link;        /* Forward link to next variable */
  152.     char    *v_name;        /* The variable's name */
  153.     char    *v_value;        /* And it's current value */
  154. };
  155.  
  156. struct group {
  157.     struct    group *ge_link;        /* Next person in this group */
  158.     char    *ge_name;        /* This person's user name */
  159. };
  160.  
  161. struct grouphead {
  162.     struct    grouphead *g_link;    /* Next grouphead in list */
  163.     char    *g_name;        /* Name of this group */
  164.     struct    group *g_list;        /* Users in group. */
  165. };
  166.  
  167. #define    NIL    ((struct name *) 0)    /* The nil pointer for namelists */
  168. #define    NONE    ((struct cmd *) 0)    /* The nil pointer to command tab */
  169. #define    NOVAR    ((struct var *) 0)    /* The nil pointer to variables */
  170. #define    NOGRP    ((struct grouphead *) 0)/* The nil grouphead pointer */
  171. #define    NOGE    ((struct group *) 0)    /* The nil group pointer */
  172.  
  173. /*
  174.  * Token values returned by the scanner used for argument lists.
  175.  * Also, sizes of scanner-related things.
  176.  */
  177.  
  178. #define    TEOL    0            /* End of the command line */
  179. #define    TNUMBER    1            /* A message number */
  180. #define    TDASH    2            /* A simple dash */
  181. #define    TSTRING    3            /* A string (possibly containing -) */
  182. #define    TDOT    4            /* A "." */
  183. #define    TUP    5            /* An "^" */
  184. #define    TDOLLAR    6            /* A "$" */
  185. #define    TSTAR    7            /* A "*" */
  186. #define    TOPEN    8            /* An '(' */
  187. #define    TCLOSE    9            /* A ')' */
  188.  
  189. #define    REGDEP    2            /* Maximum regret depth. */
  190. #define    STRINGLEN    16        /* Maximum length of string token */
  191.  
  192. /*
  193.  * Forward declarations of routine types to keep lint and cc happy.
  194.  */
  195.  
  196. FILE    *collect();
  197. FILE    *infix();
  198. FILE    *mesedit();
  199. FILE    *mespipe();
  200. FILE    *setinput();
  201. char    **unpack();
  202. char    *addto();
  203. char    *calloc();
  204. char    *copy();
  205. char    *gets();
  206. char    *hfield();
  207. char    *nameof();
  208. char    *nextword();
  209. char    *getenv();
  210. char    *readtty();
  211. char    *salloc();
  212. char    *savestr();
  213. char    *savestr();
  214. char    *snarf();
  215. char    *value();
  216. char    *vcopy();
  217. char    *yankword();
  218. off_t    fsize();
  219. struct    cmd    *lex();
  220. struct    grouphead    *findgroup();
  221. struct    name    *cat();
  222. struct    name    *elide();
  223. struct    name    *extract();
  224. struct    name    *map();
  225. struct    name    *outof();
  226. struct    name    *put();
  227. struct    name    *usermap();
  228. struct    name    *verify();
  229. struct    var    *lookup();
  230. unsigned    int    msize();
  231.