|
|
1.1 ! root 1: /* def.h 2.13 83/08/11 */ ! 2: ! 3: #include <sys/types.h> ! 4: #include <signal.h> ! 5: #include <stdio.h> ! 6: #include <sgtty.h> ! 7: #include "local.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 100 /* 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 BUFSIZ /* max readable line width */ ! 39: #define STRINGSIZE ((unsigned) 128)/* Dynamic allocation units */ ! 40: #define MAXARGC 20 /* Maximum list of raw strings */ ! 41: #define NOSTR ((char *) 0) /* Null string pointer */ ! 42: #define MAXEXP 25 /* Maximum expansion of aliases */ ! 43: #define equal(a, b) (strcmp(a,b)==0)/* A nice function to string compare */ ! 44: ! 45: struct message { ! 46: short m_flag; /* flags, see below */ ! 47: short m_block; /* block number of this message */ ! 48: short m_offset; /* offset in block of message */ ! 49: long m_size; /* Bytes in the message */ ! 50: short m_lines; /* Lines in the message */ ! 51: }; ! 52: ! 53: /* ! 54: * flag bits. ! 55: */ ! 56: ! 57: #define MUSED (1<<0) /* entry is used, but this bit isn't */ ! 58: #define MDELETED (1<<1) /* entry has been deleted */ ! 59: #define MSAVED (1<<2) /* entry has been saved */ ! 60: #define MTOUCH (1<<3) /* entry has been noticed */ ! 61: #define MPRESERVE (1<<4) /* keep entry in sys mailbox */ ! 62: #define MMARK (1<<5) /* message is marked! */ ! 63: #define MODIFY (1<<6) /* message has been modified */ ! 64: #define MNEW (1<<7) /* message has never been seen */ ! 65: #define MREAD (1<<8) /* message has been read sometime. */ ! 66: #define MSTATUS (1<<9) /* message status has changed */ ! 67: #define MBOX (1<<10) /* Send this to mbox, regardless */ ! 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 /* Legal from send mode bit */ ! 101: #define W 0400 /* Illegal when read only bit */ ! 102: #define F 01000 /* Is a conditional command */ ! 103: #define T 02000 /* Is a transparent command */ ! 104: #define R 04000 /* Cannot be called from collect */ ! 105: ! 106: /* ! 107: * Oft-used mask values ! 108: */ ! 109: ! 110: #define MMNORM (MDELETED|MSAVED)/* Look at both save and delete bits */ ! 111: #define MMNDEL MDELETED /* Look only at deleted bit */ ! 112: ! 113: /* ! 114: * Structure used to return a break down of a head ! 115: * line (hats off to Bill Joy!) ! 116: */ ! 117: ! 118: struct headline { ! 119: char *l_from; /* The name of the sender */ ! 120: char *l_tty; /* His tty string (if any) */ ! 121: char *l_date; /* The entire date string */ ! 122: }; ! 123: ! 124: #define GTO 1 /* Grab To: line */ ! 125: #define GSUBJECT 2 /* Likewise, Subject: line */ ! 126: #define GCC 4 /* And the Cc: line */ ! 127: #define GBCC 8 /* And also the Bcc: line */ ! 128: #define GMASK (GTO|GSUBJECT|GCC|GBCC) ! 129: /* Mask of places from whence */ ! 130: ! 131: #define GNL 16 /* Print blank line after */ ! 132: #define GDEL 32 /* Entity removed from list */ ! 133: #define GCOMMA 64 /* detract puts in commas */ ! 134: ! 135: /* ! 136: * Structure used to pass about the current ! 137: * state of the user-typed message header. ! 138: */ ! 139: ! 140: struct header { ! 141: char *h_to; /* Dynamic "To:" string */ ! 142: char *h_subject; /* Subject string */ ! 143: char *h_cc; /* Carbon copies string */ ! 144: char *h_bcc; /* Blind carbon copies */ ! 145: int h_seq; /* Sequence for optimization */ ! 146: }; ! 147: ! 148: /* ! 149: * Structure of namelist nodes used in processing ! 150: * the recipients of mail and aliases and all that ! 151: * kind of stuff. ! 152: */ ! 153: ! 154: struct name { ! 155: struct name *n_flink; /* Forward link in list. */ ! 156: struct name *n_blink; /* Backward list link */ ! 157: short n_type; /* From which list it came */ ! 158: char *n_name; /* This fella's name */ ! 159: }; ! 160: ! 161: /* ! 162: * Structure of a variable node. All variables are ! 163: * kept on a singly-linked list of these, rooted by ! 164: * "variables" ! 165: */ ! 166: ! 167: struct var { ! 168: struct var *v_link; /* Forward link to next variable */ ! 169: char *v_name; /* The variable's name */ ! 170: char *v_value; /* And it's current value */ ! 171: }; ! 172: ! 173: struct group { ! 174: struct group *ge_link; /* Next person in this group */ ! 175: char *ge_name; /* This person's user name */ ! 176: }; ! 177: ! 178: struct grouphead { ! 179: struct grouphead *g_link; /* Next grouphead in list */ ! 180: char *g_name; /* Name of this group */ ! 181: struct group *g_list; /* Users in group. */ ! 182: }; ! 183: ! 184: #define NIL ((struct name *) 0) /* The nil pointer for namelists */ ! 185: #define NONE ((struct cmd *) 0) /* The nil pointer to command tab */ ! 186: #define NOVAR ((struct var *) 0) /* The nil pointer to variables */ ! 187: #define NOGRP ((struct grouphead *) 0)/* The nil grouphead pointer */ ! 188: #define NOGE ((struct group *) 0) /* The nil group pointer */ ! 189: ! 190: /* ! 191: * Structure of the hash table of ignored header fields ! 192: */ ! 193: struct ignore { ! 194: struct ignore *i_link; /* Next ignored field in bucket */ ! 195: char *i_field; /* This ignored field */ ! 196: }; ! 197: ! 198: /* ! 199: * Token values returned by the scanner used for argument lists. ! 200: * Also, sizes of scanner-related things. ! 201: */ ! 202: ! 203: #define TEOL 0 /* End of the command line */ ! 204: #define TNUMBER 1 /* A message number */ ! 205: #define TDASH 2 /* A simple dash */ ! 206: #define TSTRING 3 /* A string (possibly containing -) */ ! 207: #define TDOT 4 /* A "." */ ! 208: #define TUP 5 /* An "^" */ ! 209: #define TDOLLAR 6 /* A "$" */ ! 210: #define TSTAR 7 /* A "*" */ ! 211: #define TOPEN 8 /* An '(' */ ! 212: #define TCLOSE 9 /* A ')' */ ! 213: #define TPLUS 10 /* A '+' */ ! 214: ! 215: #define REGDEP 2 /* Maximum regret depth. */ ! 216: #define STRINGLEN 64 /* Maximum length of string token */ ! 217: ! 218: /* ! 219: * Constants for conditional commands. These describe whether ! 220: * we should be executing stuff or not. ! 221: */ ! 222: ! 223: #define CANY 0 /* Execute in send or receive mode */ ! 224: #define CRCV 1 /* Execute in receive mode only */ ! 225: #define CSEND 2 /* Execute in send mode only */ ! 226: ! 227: /* ! 228: * Kludges to handle the change from setexit / reset to setjmp / longjmp ! 229: */ ! 230: ! 231: #define setexit() setjmp(srbuf) ! 232: #define reset(x) longjmp(srbuf, x) ! 233: ! 234: /* ! 235: * VM/UNIX has a vfork system call which is faster than forking. If we ! 236: * don't have it, fork(2) will do . . . ! 237: */ ! 238: ! 239: #ifndef VMUNIX ! 240: #define vfork() fork() ! 241: #endif ! 242: #ifndef SIGRETRO ! 243: #define sigchild() ! 244: #endif ! 245: ! 246: /* ! 247: * 4.2bsd signal interface help... ! 248: */ ! 249: #ifdef VMUNIX ! 250: #define sigset(s, a) signal(s, a) ! 251: #define mask(s) (1 << ((s) - 1)) ! 252: #define sigsys(s, a) signal(s, a) ! 253: #endif ! 254: ! 255: /* ! 256: * Truncate a file to the last character written. This is ! 257: * useful just before closing an old file that was opened ! 258: * for read/write. ! 259: */ ! 260: #define trunc(stream) ftruncate(fileno(stream), (long) ftell(stream)) ! 261: ! 262: /* ! 263: * Forward declarations of routine types to keep lint and cc happy. ! 264: */ ! 265: ! 266: FILE *Fdopen(); ! 267: FILE *collect(); ! 268: FILE *infix(); ! 269: FILE *mesedit(); ! 270: FILE *mespipe(); ! 271: FILE *popen(); ! 272: FILE *setinput(); ! 273: char **unpack(); ! 274: char *addto(); ! 275: char *arpafix(); ! 276: char *calloc(); ! 277: char *copy(); ! 278: char *copyin(); ! 279: char *detract(); ! 280: char *expand(); ! 281: char *gets(); ! 282: char *hfield(); ! 283: char *index(); ! 284: char *name1(); ! 285: char *nameof(); ! 286: char *nextword(); ! 287: char *getenv(); ! 288: char *getfilename(); ! 289: char *hcontents(); ! 290: char *netmap(); ! 291: char *netname(); ! 292: char *readtty(); ! 293: char *reedit(); ! 294: char *rename(); ! 295: char *revarpa(); ! 296: char *rindex(); ! 297: char *rpair(); ! 298: char *salloc(); ! 299: char *savestr(); ! 300: char *skin(); ! 301: char *snarf(); ! 302: char *strcat(); ! 303: char *strcpy(); ! 304: char *value(); ! 305: char *vcopy(); ! 306: char *yankword(); ! 307: off_t fsize(); ! 308: #ifndef VMUNIX ! 309: int (*sigset())(); ! 310: #endif ! 311: struct cmd *lex(); ! 312: struct grouphead *findgroup(); ! 313: struct name *cat(); ! 314: struct name *delname(); ! 315: struct name *elide(); ! 316: struct name *extract(); ! 317: struct name *gexpand(); ! 318: struct name *map(); ! 319: struct name *outof(); ! 320: struct name *put(); ! 321: struct name *usermap(); ! 322: struct name *verify(); ! 323: struct var *lookup(); ! 324: long transmit(); ! 325: int icequal(); ! 326: int cmpdomain();
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.