1: /*
   2:  * Copyright (c) 1980 Regents of the University of California.
   3:  * All rights reserved.  The Berkeley software License Agreement
   4:  * specifies the terms and conditions for redistribution.
   5:  *
   6:  *	@(#)def.h	5.2 (Berkeley) 11/2/85
   7:  */
   8: 
   9: #include <sys/param.h>      /* includes <sys/types.h> */
  10: #include <signal.h>
  11: #include <stdio.h>
  12: #include <sgtty.h>
  13: #include "local.h"
  14: 
  15: #undef isalpha
  16: #undef isdigit
  17: 
  18: /*
  19:  * Mail -- a mail program
  20:  *
  21:  * Commands are:
  22:  *	t <message list>		print out these messages
  23:  *	r <message list>		reply to messages
  24:  *	m <user list>			mail to users (analogous to send)
  25:  *	e <message list>		edit messages
  26:  *	c [directory]			chdir to dir or home if none
  27:  *	x				exit quickly
  28:  *	w <message list> file		save messages in file
  29:  *	q				quit, save remaining stuff in mbox
  30:  *	d <message list>		delete messages
  31:  *	u <message list>		undelete messages
  32:  *	h				print message headers
  33:  *
  34:  * Author: Kurt Shoens (UCB) March 25, 1978
  35:  */
  36: 
  37: 
  38: #define ESCAPE      '~'     /* Default escape for sending */
  39: #define NMLSIZE     1024        /* max names in a message list */
  40: #define PATHSIZE    1024        /* Size of pathnames throughout */
  41: #define NAMESIZE    32      /* Max size of user name */
  42: #define HSHSIZE     59      /* Hash size for aliases and vars */
  43: #define HDRFIELDS   3       /* Number of header fields */
  44: #define LINESIZE    BUFSIZ      /* max readable line width */
  45: #define STRINGSIZE  ((unsigned) 128)/* Dynamic allocation units */
  46: #define MAXARGC     1024        /* Maximum list of raw strings */
  47: #define NOSTR       ((char *) 0)    /* Null string pointer */
  48: #define MAXEXP      25      /* Maximum expansion of aliases */
  49: #define equal(a, b) (strcmp(a,b)==0)/* A nice function to string compare */
  50: 
  51: struct message {
  52:     short   m_flag;         /* flags, see below */
  53:     short   m_block;        /* block number of this message */
  54:     short   m_offset;       /* offset in block of message */
  55:     long    m_size;         /* Bytes in the message */
  56:     short   m_lines;        /* Lines in the message */
  57: };
  58: 
  59: /*
  60:  * flag bits.
  61:  */
  62: 
  63: #define MUSED       (1<<0)      /* entry is used, but this bit isn't */
  64: #define MDELETED    (1<<1)      /* entry has been deleted */
  65: #define MSAVED      (1<<2)      /* entry has been saved */
  66: #define MTOUCH      (1<<3)      /* entry has been noticed */
  67: #define MPRESERVE   (1<<4)      /* keep entry in sys mailbox */
  68: #define MMARK       (1<<5)      /* message is marked! */
  69: #define MODIFY      (1<<6)      /* message has been modified */
  70: #define MNEW        (1<<7)      /* message has never been seen */
  71: #define MREAD       (1<<8)      /* message has been read sometime. */
  72: #define MSTATUS     (1<<9)      /* message status has changed */
  73: #define MBOX        (1<<10)     /* Send this to mbox, regardless */
  74: 
  75: /*
  76:  * Format of the command description table.
  77:  * The actual table is declared and initialized
  78:  * in lex.c
  79:  */
  80: 
  81: struct cmd {
  82:     char    *c_name;        /* Name of command */
  83:     int (*c_func)();        /* Implementor of the command */
  84:     short   c_argtype;      /* Type of arglist (see below) */
  85:     short   c_msgflag;      /* Required flags of messages */
  86:     short   c_msgmask;      /* Relevant flags of messages */
  87: };
  88: 
  89: /* Yechh, can't initialize unions */
  90: 
  91: #define c_minargs c_msgflag     /* Minimum argcount for RAWLIST */
  92: #define c_maxargs c_msgmask     /* Max argcount for RAWLIST */
  93: 
  94: /*
  95:  * Argument types.
  96:  */
  97: 
  98: #define MSGLIST  0      /* Message list type */
  99: #define STRLIST  1      /* A pure string */
 100: #define RAWLIST  2      /* Shell string list */
 101: #define NOLIST   3      /* Just plain 0 */
 102: #define NDMLIST  4      /* Message list, no defaults */
 103: 
 104: #define P   040     /* Autoprint dot after command */
 105: #define I   0100        /* Interactive command bit */
 106: #define M   0200        /* Legal from send mode bit */
 107: #define W   0400        /* Illegal when read only bit */
 108: #define F   01000       /* Is a conditional command */
 109: #define T   02000       /* Is a transparent command */
 110: #define R   04000       /* Cannot be called from collect */
 111: 
 112: /*
 113:  * Oft-used mask values
 114:  */
 115: 
 116: #define MMNORM      (MDELETED|MSAVED)/* Look at both save and delete bits */
 117: #define MMNDEL      MDELETED    /* Look only at deleted bit */
 118: 
 119: /*
 120:  * Structure used to return a break down of a head
 121:  * line (hats off to Bill Joy!)
 122:  */
 123: 
 124: struct headline {
 125:     char    *l_from;    /* The name of the sender */
 126:     char    *l_tty;     /* His tty string (if any) */
 127:     char    *l_date;    /* The entire date string */
 128: };
 129: 
 130: #define GTO 1       /* Grab To: line */
 131: #define GSUBJECT 2      /* Likewise, Subject: line */
 132: #define GCC 4       /* And the Cc: line */
 133: #define GBCC    8       /* And also the Bcc: line */
 134: #define GMASK   (GTO|GSUBJECT|GCC|GBCC)
 135:                 /* Mask of places from whence */
 136: 
 137: #define GNL 16      /* Print blank line after */
 138: #define GDEL    32      /* Entity removed from list */
 139: #define GCOMMA  64      /* detract puts in commas */
 140: 
 141: /*
 142:  * Structure used to pass about the current
 143:  * state of the user-typed message header.
 144:  */
 145: 
 146: struct header {
 147:     char    *h_to;          /* Dynamic "To:" string */
 148:     char    *h_subject;     /* Subject string */
 149:     char    *h_cc;          /* Carbon copies string */
 150:     char    *h_bcc;         /* Blind carbon copies */
 151:     int h_seq;          /* Sequence for optimization */
 152: };
 153: 
 154: /*
 155:  * Structure of namelist nodes used in processing
 156:  * the recipients of mail and aliases and all that
 157:  * kind of stuff.
 158:  */
 159: 
 160: struct name {
 161:     struct  name *n_flink;      /* Forward link in list. */
 162:     struct  name *n_blink;      /* Backward list link */
 163:     short   n_type;         /* From which list it came */
 164:     char    *n_name;        /* This fella's name */
 165: };
 166: 
 167: /*
 168:  * Structure of a variable node.  All variables are
 169:  * kept on a singly-linked list of these, rooted by
 170:  * "variables"
 171:  */
 172: 
 173: struct var {
 174:     struct  var *v_link;        /* Forward link to next variable */
 175:     char    *v_name;        /* The variable's name */
 176:     char    *v_value;       /* And it's current value */
 177: };
 178: 
 179: struct group {
 180:     struct  group *ge_link;     /* Next person in this group */
 181:     char    *ge_name;       /* This person's user name */
 182: };
 183: 
 184: struct grouphead {
 185:     struct  grouphead *g_link;  /* Next grouphead in list */
 186:     char    *g_name;        /* Name of this group */
 187:     struct  group *g_list;      /* Users in group. */
 188: };
 189: 
 190: #define NIL ((struct name *) 0) /* The nil pointer for namelists */
 191: #define NONE    ((struct cmd *) 0)  /* The nil pointer to command tab */
 192: #define NOVAR   ((struct var *) 0)  /* The nil pointer to variables */
 193: #define NOGRP   ((struct grouphead *) 0)/* The nil grouphead pointer */
 194: #define NOGE    ((struct group *) 0)    /* The nil group pointer */
 195: 
 196: /*
 197:  * Structure of the hash table of ignored header fields
 198:  */
 199: struct ignore {
 200:     struct ignore   *i_link;    /* Next ignored field in bucket */
 201:     char        *i_field;   /* This ignored field */
 202: };
 203: 
 204: /*
 205:  * Token values returned by the scanner used for argument lists.
 206:  * Also, sizes of scanner-related things.
 207:  */
 208: 
 209: #define TEOL    0           /* End of the command line */
 210: #define TNUMBER 1           /* A message number */
 211: #define TDASH   2           /* A simple dash */
 212: #define TSTRING 3           /* A string (possibly containing -) */
 213: #define TDOT    4           /* A "." */
 214: #define TUP 5           /* An "^" */
 215: #define TDOLLAR 6           /* A "$" */
 216: #define TSTAR   7           /* A "*" */
 217: #define TOPEN   8           /* An '(' */
 218: #define TCLOSE  9           /* A ')' */
 219: #define TPLUS   10          /* A '+' */
 220: 
 221: #define REGDEP  2           /* Maximum regret depth. */
 222: #define STRINGLEN   1024        /* Maximum length of string token */
 223: 
 224: /*
 225:  * Constants for conditional commands.  These describe whether
 226:  * we should be executing stuff or not.
 227:  */
 228: 
 229: #define CANY        0       /* Execute in send or receive mode */
 230: #define CRCV        1       /* Execute in receive mode only */
 231: #define CSEND       2       /* Execute in send mode only */
 232: 
 233: /*
 234:  * Kludges to handle the change from setexit / reset to setjmp / longjmp
 235:  */
 236: 
 237: #define setexit()   setjmp(srbuf)
 238: #define reset(x)    longjmp(srbuf, x)
 239: 
 240: /*
 241:  * VM/UNIX has a vfork system call which is faster than forking.  If we
 242:  * don't have it, fork(2) will do . . .
 243:  */
 244: 
 245: #ifndef VMUNIX
 246: #define vfork() fork()
 247: #endif
 248: #ifndef SIGRETRO
 249: #define sigchild()
 250: #endif
 251: 
 252: /*
 253:  * 4.2bsd signal interface help...
 254:  */
 255: #ifdef VMUNIX
 256: #define sigset(s, a)    signal(s, a)
 257: #define sigsys(s, a)    signal(s, a)
 258: #endif
 259: 
 260: /*
 261:  * Truncate a file to the last character written. This is
 262:  * useful just before closing an old file that was opened
 263:  * for read/write.
 264:  */
 265: #define trunc(stream)   ftruncate(fileno(stream), (long) ftell(stream))
 266: 
 267: /*
 268:  * Forward declarations of routine types to keep lint and cc happy.
 269:  */
 270: 
 271: FILE    *Fdopen();
 272: FILE    *collect();
 273: FILE    *infix();
 274: FILE    *mesedit();
 275: FILE    *mespipe();
 276: FILE    *popen();
 277: FILE    *setinput();
 278: char    **unpack();
 279: char    *addto();
 280: char    *arpafix();
 281: char    *calloc();
 282: char    *copy();
 283: char    *copyin();
 284: char    *detract();
 285: char    *expand();
 286: char    *gets();
 287: char    *hfield();
 288: char    *index();
 289: char    *name1();
 290: char    *nameof();
 291: char    *nextword();
 292: char    *getenv();
 293: char    *getfilename();
 294: char    *hcontents();
 295: char    *netmap();
 296: char    *netname();
 297: char    *readtty();
 298: char    *reedit();
 299: char    *rename();
 300: char    *revarpa();
 301: char    *rindex();
 302: char    *rpair();
 303: char    *salloc();
 304: char    *savestr();
 305: char    *skin();
 306: char    *snarf();
 307: char    *strcat();
 308: char    *strcpy();
 309: char    *value();
 310: char    *vcopy();
 311: char    *yankword();
 312: off_t   fsize();
 313: #ifndef VMUNIX
 314: int (*sigset())();
 315: #endif
 316: struct  cmd *lex();
 317: struct  grouphead   *findgroup();
 318: struct  name    *cat();
 319: struct  name    *delname();
 320: struct  name    *elide();
 321: struct  name    *extract();
 322: struct  name    *gexpand();
 323: struct  name    *map();
 324: struct  name    *outof();
 325: struct  name    *put();
 326: struct  name    *usermap();
 327: struct  name    *verify();
 328: struct  var *lookup();
 329: long    transmit();
 330: int icequal();
 331: int cmpdomain();

Defined struct's

cmd defined in line 81; used 16 times
group defined in line 179; used 12 times
grouphead defined in line 184; used 20 times
header defined in line 146; used 24 times
headline defined in line 124; used 6 times
ignore defined in line 199; used 22 times
message defined in line 51; used 82 times
name defined in line 160; used 126 times
var defined in line 173; used 18 times

Defined macros

CANY defined in line 229; used 7 times
CRCV defined in line 230; used 3 times
CSEND defined in line 231; used 3 times
ESCAPE defined in line 38; used 1 times
F defined in line 108; used 5 times
GBCC defined in line 133; used 6 times
GCOMMA defined in line 139; used 4 times
GDEL defined in line 138; used 6 times
GMASK defined in line 134; used 2 times
GNL defined in line 137; used 6 times
HDRFIELDS defined in line 43; never used
HSHSIZE defined in line 42; used 9 times
I defined in line 105; used 11 times
M defined in line 106; used 33 times
MAXARGC defined in line 46; used 1 times
MAXEXP defined in line 48; used 2 times
MMARK defined in line 68; used 5 times
MMNDEL defined in line 117; used 27 times
MMNORM defined in line 116; used 6 times
MODIFY defined in line 69; used 3 times
MSAVED defined in line 65; used 9 times
MSGLIST defined in line 98; used 30 times
MUSED defined in line 63; used 3 times
NAMESIZE defined in line 41; never used
NDMLIST defined in line 102; used 1 times
NIL defined in line 190; used 58 times
NMLSIZE defined in line 39; used 1 times
NOGE defined in line 194; used 4 times
NOGRP defined in line 193; used 8 times
NOLIST defined in line 101; used 11 times
NONE defined in line 191; used 2 times
NOSTR defined in line 47; used 212 times
NOVAR defined in line 192; used 7 times
P defined in line 104; used 4 times
PATHSIZE defined in line 40; used 5 times
R defined in line 110; used 7 times
RAWLIST defined in line 100; used 17 times
REGDEP defined in line 221; used 1 times
STRINGLEN defined in line 222; used 2 times
STRINGSIZE defined in line 45; used 4 times
STRLIST defined in line 99; used 9 times
T defined in line 109; used 5 times
TCLOSE defined in line 218; used 1 times
TDASH defined in line 211; used 2 times
TDOLLAR defined in line 215; used 1 times
TDOT defined in line 213; used 1 times
TEOL defined in line 209; used 2 times
TNUMBER defined in line 210; used 1 times
TOPEN defined in line 217; used 1 times
TPLUS defined in line 219; used 1 times
TSTAR defined in line 216; used 1 times
TSTRING defined in line 212; used 1 times
TUP defined in line 214; used 1 times
W defined in line 107; used 9 times
c_maxargs defined in line 92; used 2 times
c_minargs defined in line 91; used 2 times
reset defined in line 238; used 7 times
setexit defined in line 237; used 2 times
sigset defined in line 256; used 59 times
trunc defined in line 265; used 4 times

Usage of this include

Last modified: 1985-11-03
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 2535
Valid CSS Valid XHTML 1.0 Strict