Annotation of 43BSDReno/usr.bin/mail/def.h, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Copyright (c) 1980 Regents of the University of California.
                      3:  * All rights reserved.
                      4:  *
                      5:  * Redistribution and use in source and binary forms are permitted provided
                      6:  * that: (1) source distributions retain this entire copyright notice and
                      7:  * comment, and (2) distributions including binaries display the following
                      8:  * acknowledgement:  ``This product includes software developed by the
                      9:  * University of California, Berkeley and its contributors'' in the
                     10:  * documentation or other materials provided with the distribution and in
                     11:  * all advertising materials mentioning features or use of this software.
                     12:  * Neither the name of the University nor the names of its contributors may
                     13:  * be used to endorse or promote products derived from this software without
                     14:  * specific prior written permission.
                     15:  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
                     16:  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
                     17:  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
                     18:  *
                     19:  *     @(#)def.h       5.22 (Berkeley) 6/25/90
                     20:  */
                     21: 
                     22: #include <sys/param.h>         /* includes <sys/types.h> */
                     23: #include <sys/signal.h>
                     24: #include <stdio.h>
                     25: #include <sgtty.h>
                     26: #include <ctype.h>
                     27: #include <string.h>
                     28: #include "pathnames.h"
                     29: 
                     30: /*
                     31:  * Mail -- a mail program
                     32:  *
                     33:  * Author: Kurt Shoens (UCB) March 25, 1978
                     34:  */
                     35: 
                     36: #define        APPEND                          /* New mail goes to end of mailbox */
                     37: 
                     38: #define        ESCAPE          '~'             /* Default escape for sending */
                     39: #define        NMLSIZE         1024            /* max names in a message list */
                     40: #define        PATHSIZE        MAXPATHLEN      /* Size of pathnames throughout */
                     41: #define        HSHSIZE         59              /* Hash size for aliases and vars */
                     42: #define        LINESIZE        BUFSIZ          /* max readable line width */
                     43: #define        STRINGSIZE      ((unsigned) 128)/* Dynamic allocation units */
                     44: #define        MAXARGC         1024            /* Maximum list of raw strings */
                     45: #define        NOSTR           ((char *) 0)    /* Null string pointer */
                     46: #define        MAXEXP          25              /* Maximum expansion of aliases */
                     47: 
                     48: #define        equal(a, b)     (strcmp(a,b)==0)/* A nice function to string compare */
                     49: 
                     50: struct message {
                     51:        short   m_flag;                 /* flags, see below */
                     52:        short   m_block;                /* block number of this message */
                     53:        short   m_offset;               /* offset in block of message */
                     54:        long    m_size;                 /* Bytes in the message */
                     55:        short   m_lines;                /* Lines in the message */
                     56: };
                     57: 
                     58: /*
                     59:  * flag bits.
                     60:  */
                     61: 
                     62: #define        MUSED           (1<<0)          /* entry is used, but this bit isn't */
                     63: #define        MDELETED        (1<<1)          /* entry has been deleted */
                     64: #define        MSAVED          (1<<2)          /* entry has been saved */
                     65: #define        MTOUCH          (1<<3)          /* entry has been noticed */
                     66: #define        MPRESERVE       (1<<4)          /* keep entry in sys mailbox */
                     67: #define        MMARK           (1<<5)          /* message is marked! */
                     68: #define        MODIFY          (1<<6)          /* message has been modified */
                     69: #define        MNEW            (1<<7)          /* message has never been seen */
                     70: #define        MREAD           (1<<8)          /* message has been read sometime. */
                     71: #define        MSTATUS         (1<<9)          /* message status has changed */
                     72: #define        MBOX            (1<<10)         /* Send this to mbox, regardless */
                     73: 
                     74: /*
                     75:  * Given a file address, determine the block number it represents.
                     76:  */
                     77: #define blockof(off)                   ((int) ((off) / 4096))
                     78: #define offsetof(off)                  ((int) ((off) % 4096))
                     79: #define positionof(block, offset)      ((off_t)(block) * 4096 + (offset))
                     80: 
                     81: /*
                     82:  * Format of the command description table.
                     83:  * The actual table is declared and initialized
                     84:  * in lex.c
                     85:  */
                     86: 
                     87: struct cmd {
                     88:        char    *c_name;                /* Name of command */
                     89:        int     (*c_func)();            /* Implementor of the command */
                     90:        short   c_argtype;              /* Type of arglist (see below) */
                     91:        short   c_msgflag;              /* Required flags of messages */
                     92:        short   c_msgmask;              /* Relevant flags of messages */
                     93: };
                     94: 
                     95: /* Yechh, can't initialize unions */
                     96: 
                     97: #define        c_minargs c_msgflag             /* Minimum argcount for RAWLIST */
                     98: #define        c_maxargs c_msgmask             /* Max argcount for RAWLIST */
                     99: 
                    100: /*
                    101:  * Argument types.
                    102:  */
                    103: 
                    104: #define        MSGLIST  0              /* Message list type */
                    105: #define        STRLIST  1              /* A pure string */
                    106: #define        RAWLIST  2              /* Shell string list */
                    107: #define        NOLIST   3              /* Just plain 0 */
                    108: #define        NDMLIST  4              /* Message list, no defaults */
                    109: 
                    110: #define        P       040             /* Autoprint dot after command */
                    111: #define        I       0100            /* Interactive command bit */
                    112: #define        M       0200            /* Legal from send mode bit */
                    113: #define        W       0400            /* Illegal when read only bit */
                    114: #define        F       01000           /* Is a conditional command */
                    115: #define        T       02000           /* Is a transparent command */
                    116: #define        R       04000           /* Cannot be called from collect */
                    117: 
                    118: /*
                    119:  * Oft-used mask values
                    120:  */
                    121: 
                    122: #define        MMNORM          (MDELETED|MSAVED)/* Look at both save and delete bits */
                    123: #define        MMNDEL          MDELETED        /* Look only at deleted bit */
                    124: 
                    125: /*
                    126:  * Structure used to return a break down of a head
                    127:  * line (hats off to Bill Joy!)
                    128:  */
                    129: 
                    130: struct headline {
                    131:        char    *l_from;        /* The name of the sender */
                    132:        char    *l_tty;         /* His tty string (if any) */
                    133:        char    *l_date;        /* The entire date string */
                    134: };
                    135: 
                    136: #define        GTO     1               /* Grab To: line */
                    137: #define        GSUBJECT 2              /* Likewise, Subject: line */
                    138: #define        GCC     4               /* And the Cc: line */
                    139: #define        GBCC    8               /* And also the Bcc: line */
                    140: #define        GMASK   (GTO|GSUBJECT|GCC|GBCC)
                    141:                                /* Mask of places from whence */
                    142: 
                    143: #define        GNL     16              /* Print blank line after */
                    144: #define        GDEL    32              /* Entity removed from list */
                    145: #define        GCOMMA  64              /* detract puts in commas */
                    146: 
                    147: /*
                    148:  * Structure used to pass about the current
                    149:  * state of the user-typed message header.
                    150:  */
                    151: 
                    152: struct header {
                    153:        struct name *h_to;              /* Dynamic "To:" string */
                    154:        char *h_subject;                /* Subject string */
                    155:        struct name *h_cc;              /* Carbon copies string */
                    156:        struct name *h_bcc;             /* Blind carbon copies */
                    157:        struct name *h_smopts;          /* Sendmail options */
                    158: };
                    159: 
                    160: /*
                    161:  * Structure of namelist nodes used in processing
                    162:  * the recipients of mail and aliases and all that
                    163:  * kind of stuff.
                    164:  */
                    165: 
                    166: struct name {
                    167:        struct  name *n_flink;          /* Forward link in list. */
                    168:        struct  name *n_blink;          /* Backward list link */
                    169:        short   n_type;                 /* From which list it came */
                    170:        char    *n_name;                /* This fella's name */
                    171: };
                    172: 
                    173: /*
                    174:  * Structure of a variable node.  All variables are
                    175:  * kept on a singly-linked list of these, rooted by
                    176:  * "variables"
                    177:  */
                    178: 
                    179: struct var {
                    180:        struct  var *v_link;            /* Forward link to next variable */
                    181:        char    *v_name;                /* The variable's name */
                    182:        char    *v_value;               /* And it's current value */
                    183: };
                    184: 
                    185: struct group {
                    186:        struct  group *ge_link;         /* Next person in this group */
                    187:        char    *ge_name;               /* This person's user name */
                    188: };
                    189: 
                    190: struct grouphead {
                    191:        struct  grouphead *g_link;      /* Next grouphead in list */
                    192:        char    *g_name;                /* Name of this group */
                    193:        struct  group *g_list;          /* Users in group. */
                    194: };
                    195: 
                    196: #define        NIL     ((struct name *) 0)     /* The nil pointer for namelists */
                    197: #define        NONE    ((struct cmd *) 0)      /* The nil pointer to command tab */
                    198: #define        NOVAR   ((struct var *) 0)      /* The nil pointer to variables */
                    199: #define        NOGRP   ((struct grouphead *) 0)/* The nil grouphead pointer */
                    200: #define        NOGE    ((struct group *) 0)    /* The nil group pointer */
                    201: 
                    202: /*
                    203:  * Structure of the hash table of ignored header fields
                    204:  */
                    205: struct ignoretab {
                    206:        int i_count;                    /* Number of entries */
                    207:        struct ignore {
                    208:                struct ignore *i_link;  /* Next ignored field in bucket */
                    209:                char *i_field;          /* This ignored field */
                    210:        } *i_head[HSHSIZE];
                    211: };
                    212: 
                    213: /*
                    214:  * Token values returned by the scanner used for argument lists.
                    215:  * Also, sizes of scanner-related things.
                    216:  */
                    217: 
                    218: #define        TEOL    0                       /* End of the command line */
                    219: #define        TNUMBER 1                       /* A message number */
                    220: #define        TDASH   2                       /* A simple dash */
                    221: #define        TSTRING 3                       /* A string (possibly containing -) */
                    222: #define        TDOT    4                       /* A "." */
                    223: #define        TUP     5                       /* An "^" */
                    224: #define        TDOLLAR 6                       /* A "$" */
                    225: #define        TSTAR   7                       /* A "*" */
                    226: #define        TOPEN   8                       /* An '(' */
                    227: #define        TCLOSE  9                       /* A ')' */
                    228: #define TPLUS  10                      /* A '+' */
                    229: #define TERROR 11                      /* A lexical error */
                    230: 
                    231: #define        REGDEP  2                       /* Maximum regret depth. */
                    232: #define        STRINGLEN       1024            /* Maximum length of string token */
                    233: 
                    234: /*
                    235:  * Constants for conditional commands.  These describe whether
                    236:  * we should be executing stuff or not.
                    237:  */
                    238: 
                    239: #define        CANY            0               /* Execute in send or receive mode */
                    240: #define        CRCV            1               /* Execute in receive mode only */
                    241: #define        CSEND           2               /* Execute in send mode only */
                    242: 
                    243: /*
                    244:  * Kludges to handle the change from setexit / reset to setjmp / longjmp
                    245:  */
                    246: 
                    247: #define        setexit()       setjmp(srbuf)
                    248: #define        reset(x)        longjmp(srbuf, x)
                    249: 
                    250: /*
                    251:  * Truncate a file to the last character written. This is
                    252:  * useful just before closing an old file that was opened
                    253:  * for read/write.
                    254:  */
                    255: #define trunc(stream)  ftruncate(fileno(stream), (long) ftell(stream))
                    256: 
                    257: /*
                    258:  * Forward declarations of routine types to keep lint and cc happy.
                    259:  */
                    260: 
                    261: FILE   *Fopen();
                    262: FILE   *Fdopen();
                    263: FILE   *Popen();
                    264: FILE   *collect();
                    265: FILE   *infix();
                    266: FILE   *run_editor();
                    267: FILE   *setinput();
                    268: char   **unpack();
                    269: char   *calloc();
                    270: char   *copy();
                    271: char   *copyin();
                    272: char   *detract();
                    273: char   *expand();
                    274: char   *getdeadletter();
                    275: char   *gets();
                    276: char   *hfield();
                    277: char   *name1();
                    278: char   *nameof();
                    279: char   *nextword();
                    280: char   *getenv();
                    281: char   *getname();
                    282: char   *fgets();
                    283: char   *ishfield();
                    284: char   *malloc();
                    285: char   *mktemp();
                    286: char   *readtty();
                    287: char   *reedit();
                    288: char   *salloc();
                    289: char   *savestr();
                    290: char   *skin();
                    291: char   *snarf();
                    292: char   *username();
                    293: char   *value();
                    294: char   *vcopy();
                    295: char   *yankword();
                    296: off_t  fsize();
                    297: uid_t  getuid();
                    298: struct cmd     *lex();
                    299: struct grouphead       *findgroup();
                    300: struct name    *nalloc();
                    301: struct name    *cat();
                    302: struct name    *delname();
                    303: struct name    *elide();
                    304: struct name    *extract();
                    305: struct name    *gexpand();
                    306: struct name    *outof();
                    307: struct name    *put();
                    308: struct name    *usermap();
                    309: struct var     *lookup();

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.