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