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

Defined struct's

cmd defined in line 100; used 16 times
group defined in line 198; used 12 times
grouphead defined in line 203; used 20 times
header defined in line 165; used 22 times
headline defined in line 143; used 6 times
ignore defined in line 220; used 12 times
ignoretab defined in line 218; used 18 times
message defined in line 63; used 72 times
name defined in line 179; used 108 times
var defined in line 192; used 18 times

Defined macros

APPEND defined in line 49; never used
CANY defined in line 252; used 7 times
CRCV defined in line 253; used 3 times
CSEND defined in line 254; used 3 times
ESCAPE defined in line 51; used 1 times
F defined in line 127; used 5 times
GBCC defined in line 152; used 10 times
GCOMMA defined in line 158; used 6 times
GDEL defined in line 157; used 4 times
GMASK defined in line 153; used 5 times
GNL defined in line 156; used 6 times
HSHSIZE defined in line 54; used 7 times
I defined in line 124; used 11 times
M defined in line 125; used 35 times
MAXARGC defined in line 57; used 1 times
MAXEXP defined in line 59; used 2 times
MDELETED defined in line 76; used 31 times
MMARK defined in line 80; used 5 times
MMNDEL defined in line 136; used 24 times
MMNORM defined in line 135; used 5 times
MODIFY defined in line 81; used 3 times
MSAVED defined in line 77; used 8 times
MSGLIST defined in line 117; used 27 times
MSTATUS defined in line 84; used 6 times
MUSED defined in line 75; used 2 times
NDMLIST defined in line 121; used 1 times
NIL defined in line 209; used 77 times
NMLSIZE defined in line 52; used 1 times
NOGE defined in line 213; used 4 times
NOGRP defined in line 212; used 8 times
NOLIST defined in line 120; used 12 times
NONE defined in line 210; used 2 times
NOSTR defined in line 58; used 199 times
NOVAR defined in line 211; used 7 times
P defined in line 123; used 4 times
PATHSIZE defined in line 53; used 3 times
R defined in line 129; used 7 times
RAWLIST defined in line 119; used 21 times
REGDEP defined in line 244; used 1 times
STRINGLEN defined in line 245; used 2 times
STRINGSIZE defined in line 56; used 4 times
STRLIST defined in line 118; used 6 times
T defined in line 128; used 5 times
TCLOSE defined in line 240; used 1 times
TDASH defined in line 233; used 2 times
TDOLLAR defined in line 237; used 1 times
TDOT defined in line 235; used 1 times
TEOL defined in line 231; used 2 times
TERROR defined in line 242; used 1 times
TNUMBER defined in line 232; used 1 times
TOPEN defined in line 239; used 1 times
TPLUS defined in line 241; used 1 times
TSTAR defined in line 238; used 1 times
TSTRING defined in line 234; used 1 times
TUP defined in line 236; used 1 times
W defined in line 126; used 9 times
blockof defined in line 90; used 2 times
c_maxargs defined in line 111; used 2 times
c_minargs defined in line 110; used 2 times
offstof defined in line 91; used 2 times
positionof defined in line 92; used 1 times
reset defined in line 261; used 8 times
setexit defined in line 260; used 1 times
trunc defined in line 268; used 4 times

Usage of this include

Last modified: 1997-11-01
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 4889
Valid CSS Valid XHTML 1.0 Strict