|
|
1.1 root 1: #
2:
3: /*
4: * Mail -- a mail program
5: *
6: * Computer Center Unix
7: *
8: * Local routines that are installation dependent.
9: */
10:
11: #include "rcv.h"
12:
13: /*
14: * Locate the user's mailbox file (ie, the place where new, unread
15: * mail is queued). At Computer Center, it is in /usr/mail/name.
16: */
17:
18: findmail()
19: {
20: register char *cp;
21:
22: cp = copy("/usr/mail/", mailname);
23: copy(myname, cp);
24: }
25:
26: /*
27: * Get rid of the queued mail.
28: * This is essentially "mail -n > /dev/null &"
29: */
30:
31: demail()
32: {
33: register int p;
34:
35: if (uid == 0) {
36: remove(mailname);
37: return;
38: }
39: if ((p = fork()) != 0)
40: return;
41: for (p = 0; p < 15; p++)
42: close(p);
43: open("/dev/null", 2);
44: dup(0);
45: dup(0);
46: for (p = SIGHUP; p <= SIGQUIT; p++)
47: signal(p, SIG_IGN);
48: execl(MAIL, "mail", "-n", 0);
49: perror(MAIL);
50: exit(1);
51: }
52:
53: /*
54: * Get the value of an environment variable.
55: */
56:
57: char *
58: getenv(name)
59: char name[];
60: {
61: register int t;
62: static char val[30];
63:
64: t = ttyn(2);
65: hget(t);
66: if (equal(name, "SHELL"))
67: return("/bin/csh");
68: if (!equal(name, "HOME"))
69: return(NOSTR);
70: copy(hgethome(), val);
71: return(val);
72: }
73:
74: /*
75: * Mail file lock / unlock.
76: * Not implemented in this version.
77: */
78:
79: lock(name)
80: char name[];
81: {
82:
83: return(0);
84: }
85:
86: unlock()
87: {
88: return(0);
89: }
90:
91: /*
92: * Discover user login name.
93: */
94:
95: username(uid, namebuf)
96: char namebuf[];
97: {
98:
99: return(getname(uid, namebuf));
100: }
101:
102: /*
103: * Unix routine to do an "fopen" on file descriptor
104: * The mode has to be repeated because you can't query its
105: * status
106: */
107:
108: FILE *
109: fdopen(fd, mode)
110: register char *mode;
111: {
112: extern int errno;
113: register FILE *iop;
114: extern FILE *_lastbuf;
115:
116: for (iop = _iob; iop->_flag&(_IOREAD|_IOWRT); iop++)
117: if (iop >= _lastbuf)
118: return(NULL);
119: iop->_cnt = 0;
120: iop->_file = fd;
121: if (*mode != 'r') {
122: iop->_flag |= _IOWRT;
123: if (*mode == 'a')
124: lseek(fd, 0L, 2);
125: } else
126: iop->_flag |= _IOREAD;
127: return(iop);
128: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.