1*9b4856c4Sbostic /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
2*9b4856c4Sbostic /* hack.unix.c - version 1.0.3 */
3*9b4856c4Sbostic
4*9b4856c4Sbostic /* This file collects some Unix dependencies; hack.pager.c contains some more */
5*9b4856c4Sbostic
6*9b4856c4Sbostic /*
7*9b4856c4Sbostic * The time is used for:
8*9b4856c4Sbostic * - seed for random()
9*9b4856c4Sbostic * - year on tombstone and yymmdd in record file
10*9b4856c4Sbostic * - phase of the moon (various monsters react to NEW_MOON or FULL_MOON)
11*9b4856c4Sbostic * - night and midnight (the undead are dangerous at midnight)
12*9b4856c4Sbostic * - determination of what files are "very old"
13*9b4856c4Sbostic */
14*9b4856c4Sbostic
15*9b4856c4Sbostic #include <stdio.h>
16*9b4856c4Sbostic #include <errno.h>
17*9b4856c4Sbostic #include "hack.h" /* mainly for index() which depends on BSD */
18*9b4856c4Sbostic
19*9b4856c4Sbostic #include <sys/types.h> /* for time_t and stat */
20*9b4856c4Sbostic #include <sys/stat.h>
21*9b4856c4Sbostic #ifdef BSD
22*9b4856c4Sbostic #include <sys/time.h>
23*9b4856c4Sbostic #else
24*9b4856c4Sbostic #include <time.h>
25*9b4856c4Sbostic #endif BSD
26*9b4856c4Sbostic
27*9b4856c4Sbostic extern char *getenv();
28*9b4856c4Sbostic extern time_t time();
29*9b4856c4Sbostic
setrandom()30*9b4856c4Sbostic setrandom()
31*9b4856c4Sbostic {
32*9b4856c4Sbostic (void) srandom((int) time ((time_t *) 0));
33*9b4856c4Sbostic }
34*9b4856c4Sbostic
35*9b4856c4Sbostic struct tm *
getlt()36*9b4856c4Sbostic getlt()
37*9b4856c4Sbostic {
38*9b4856c4Sbostic time_t date;
39*9b4856c4Sbostic struct tm *localtime();
40*9b4856c4Sbostic
41*9b4856c4Sbostic (void) time(&date);
42*9b4856c4Sbostic return(localtime(&date));
43*9b4856c4Sbostic }
44*9b4856c4Sbostic
getyear()45*9b4856c4Sbostic getyear()
46*9b4856c4Sbostic {
47*9b4856c4Sbostic return(1900 + getlt()->tm_year);
48*9b4856c4Sbostic }
49*9b4856c4Sbostic
50*9b4856c4Sbostic char *
getdate()51*9b4856c4Sbostic getdate()
52*9b4856c4Sbostic {
53*9b4856c4Sbostic static char datestr[7];
54*9b4856c4Sbostic register struct tm *lt = getlt();
55*9b4856c4Sbostic
56*9b4856c4Sbostic (void) sprintf(datestr, "%2d%2d%2d",
57*9b4856c4Sbostic lt->tm_year, lt->tm_mon + 1, lt->tm_mday);
58*9b4856c4Sbostic if(datestr[2] == ' ') datestr[2] = '0';
59*9b4856c4Sbostic if(datestr[4] == ' ') datestr[4] = '0';
60*9b4856c4Sbostic return(datestr);
61*9b4856c4Sbostic }
62*9b4856c4Sbostic
phase_of_the_moon()63*9b4856c4Sbostic phase_of_the_moon() /* 0-7, with 0: new, 4: full */
64*9b4856c4Sbostic { /* moon period: 29.5306 days */
65*9b4856c4Sbostic /* year: 365.2422 days */
66*9b4856c4Sbostic register struct tm *lt = getlt();
67*9b4856c4Sbostic register int epact, diy, golden;
68*9b4856c4Sbostic
69*9b4856c4Sbostic diy = lt->tm_yday;
70*9b4856c4Sbostic golden = (lt->tm_year % 19) + 1;
71*9b4856c4Sbostic epact = (11 * golden + 18) % 30;
72*9b4856c4Sbostic if ((epact == 25 && golden > 11) || epact == 24)
73*9b4856c4Sbostic epact++;
74*9b4856c4Sbostic
75*9b4856c4Sbostic return( (((((diy + epact) * 6) + 11) % 177) / 22) & 7 );
76*9b4856c4Sbostic }
77*9b4856c4Sbostic
night()78*9b4856c4Sbostic night()
79*9b4856c4Sbostic {
80*9b4856c4Sbostic register int hour = getlt()->tm_hour;
81*9b4856c4Sbostic
82*9b4856c4Sbostic return(hour < 6 || hour > 21);
83*9b4856c4Sbostic }
84*9b4856c4Sbostic
midnight()85*9b4856c4Sbostic midnight()
86*9b4856c4Sbostic {
87*9b4856c4Sbostic return(getlt()->tm_hour == 0);
88*9b4856c4Sbostic }
89*9b4856c4Sbostic
90*9b4856c4Sbostic struct stat buf, hbuf;
91*9b4856c4Sbostic
gethdate(name)92*9b4856c4Sbostic gethdate(name) char *name; {
93*9b4856c4Sbostic /* old version - for people short of space */
94*9b4856c4Sbostic /*
95*9b4856c4Sbostic /* register char *np;
96*9b4856c4Sbostic /* if(stat(name, &hbuf))
97*9b4856c4Sbostic /* error("Cannot get status of %s.",
98*9b4856c4Sbostic /* (np = rindex(name, '/')) ? np+1 : name);
99*9b4856c4Sbostic /*
100*9b4856c4Sbostic /* version using PATH from: seismo!gregc@ucsf-cgl.ARPA (Greg Couch) */
101*9b4856c4Sbostic
102*9b4856c4Sbostic
103*9b4856c4Sbostic /*
104*9b4856c4Sbostic * The problem with #include <sys/param.h> is that this include file
105*9b4856c4Sbostic * does not exist on all systems, and moreover, that it sometimes includes
106*9b4856c4Sbostic * <sys/types.h> again, so that the compiler sees these typedefs twice.
107*9b4856c4Sbostic */
108*9b4856c4Sbostic #define MAXPATHLEN 1024
109*9b4856c4Sbostic
110*9b4856c4Sbostic register char *np, *path;
111*9b4856c4Sbostic char filename[MAXPATHLEN+1];
112*9b4856c4Sbostic if (index(name, '/') != NULL || (path = getenv("PATH")) == NULL)
113*9b4856c4Sbostic path = "";
114*9b4856c4Sbostic
115*9b4856c4Sbostic for (;;) {
116*9b4856c4Sbostic if ((np = index(path, ':')) == NULL)
117*9b4856c4Sbostic np = path + strlen(path); /* point to end str */
118*9b4856c4Sbostic if (np - path <= 1) /* %% */
119*9b4856c4Sbostic (void) strcpy(filename, name);
120*9b4856c4Sbostic else {
121*9b4856c4Sbostic (void) strncpy(filename, path, np - path);
122*9b4856c4Sbostic filename[np - path] = '/';
123*9b4856c4Sbostic (void) strcpy(filename + (np - path) + 1, name);
124*9b4856c4Sbostic }
125*9b4856c4Sbostic if (stat(filename, &hbuf) == 0)
126*9b4856c4Sbostic return;
127*9b4856c4Sbostic if (*np == '\0')
128*9b4856c4Sbostic break;
129*9b4856c4Sbostic path = np + 1;
130*9b4856c4Sbostic }
131*9b4856c4Sbostic error("Cannot get status of %s.",
132*9b4856c4Sbostic (np = rindex(name, '/')) ? np+1 : name);
133*9b4856c4Sbostic }
134*9b4856c4Sbostic
uptodate(fd)135*9b4856c4Sbostic uptodate(fd) {
136*9b4856c4Sbostic if(fstat(fd, &buf)) {
137*9b4856c4Sbostic pline("Cannot get status of saved level? ");
138*9b4856c4Sbostic return(0);
139*9b4856c4Sbostic }
140*9b4856c4Sbostic if(buf.st_mtime < hbuf.st_mtime) {
141*9b4856c4Sbostic pline("Saved level is out of date. ");
142*9b4856c4Sbostic return(0);
143*9b4856c4Sbostic }
144*9b4856c4Sbostic return(1);
145*9b4856c4Sbostic }
146*9b4856c4Sbostic
147*9b4856c4Sbostic /* see whether we should throw away this xlock file */
veryold(fd)148*9b4856c4Sbostic veryold(fd) {
149*9b4856c4Sbostic register int i;
150*9b4856c4Sbostic time_t date;
151*9b4856c4Sbostic
152*9b4856c4Sbostic if(fstat(fd, &buf)) return(0); /* cannot get status */
153*9b4856c4Sbostic if(buf.st_size != sizeof(int)) return(0); /* not an xlock file */
154*9b4856c4Sbostic (void) time(&date);
155*9b4856c4Sbostic if(date - buf.st_mtime < 3L*24L*60L*60L) { /* recent */
156*9b4856c4Sbostic extern int errno;
157*9b4856c4Sbostic int lockedpid; /* should be the same size as hackpid */
158*9b4856c4Sbostic
159*9b4856c4Sbostic if(read(fd, (char *)&lockedpid, sizeof(lockedpid)) !=
160*9b4856c4Sbostic sizeof(lockedpid))
161*9b4856c4Sbostic /* strange ... */
162*9b4856c4Sbostic return(0);
163*9b4856c4Sbostic
164*9b4856c4Sbostic /* From: Rick Adams <seismo!rick>
165*9b4856c4Sbostic /* This will work on 4.1cbsd, 4.2bsd and system 3? & 5.
166*9b4856c4Sbostic /* It will do nothing on V7 or 4.1bsd. */
167*9b4856c4Sbostic if(!(kill(lockedpid, 0) == -1 && errno == ESRCH))
168*9b4856c4Sbostic return(0);
169*9b4856c4Sbostic }
170*9b4856c4Sbostic (void) close(fd);
171*9b4856c4Sbostic for(i = 1; i <= MAXLEVEL; i++) { /* try to remove all */
172*9b4856c4Sbostic glo(i);
173*9b4856c4Sbostic (void) unlink(lock);
174*9b4856c4Sbostic }
175*9b4856c4Sbostic glo(0);
176*9b4856c4Sbostic if(unlink(lock)) return(0); /* cannot remove it */
177*9b4856c4Sbostic return(1); /* success! */
178*9b4856c4Sbostic }
179*9b4856c4Sbostic
getlock()180*9b4856c4Sbostic getlock()
181*9b4856c4Sbostic {
182*9b4856c4Sbostic extern int errno, hackpid, locknum;
183*9b4856c4Sbostic register int i = 0, fd;
184*9b4856c4Sbostic
185*9b4856c4Sbostic (void) fflush(stdout);
186*9b4856c4Sbostic
187*9b4856c4Sbostic /* we ignore QUIT and INT at this point */
188*9b4856c4Sbostic if (link(HLOCK, LLOCK) == -1) {
189*9b4856c4Sbostic register int errnosv = errno;
190*9b4856c4Sbostic
191*9b4856c4Sbostic perror(HLOCK);
192*9b4856c4Sbostic printf("Cannot link %s to %s\n", LLOCK, HLOCK);
193*9b4856c4Sbostic switch(errnosv) {
194*9b4856c4Sbostic case ENOENT:
195*9b4856c4Sbostic printf("Perhaps there is no (empty) file %s ?\n", HLOCK);
196*9b4856c4Sbostic break;
197*9b4856c4Sbostic case EACCES:
198*9b4856c4Sbostic printf("It seems you don't have write permission here.\n");
199*9b4856c4Sbostic break;
200*9b4856c4Sbostic case EEXIST:
201*9b4856c4Sbostic printf("(Try again or rm %s.)\n", LLOCK);
202*9b4856c4Sbostic break;
203*9b4856c4Sbostic default:
204*9b4856c4Sbostic printf("I don't know what is wrong.");
205*9b4856c4Sbostic }
206*9b4856c4Sbostic getret();
207*9b4856c4Sbostic error("");
208*9b4856c4Sbostic /*NOTREACHED*/
209*9b4856c4Sbostic }
210*9b4856c4Sbostic
211*9b4856c4Sbostic regularize(lock);
212*9b4856c4Sbostic glo(0);
213*9b4856c4Sbostic if(locknum > 25) locknum = 25;
214*9b4856c4Sbostic
215*9b4856c4Sbostic do {
216*9b4856c4Sbostic if(locknum) lock[0] = 'a' + i++;
217*9b4856c4Sbostic
218*9b4856c4Sbostic if((fd = open(lock, 0)) == -1) {
219*9b4856c4Sbostic if(errno == ENOENT) goto gotlock; /* no such file */
220*9b4856c4Sbostic perror(lock);
221*9b4856c4Sbostic (void) unlink(LLOCK);
222*9b4856c4Sbostic error("Cannot open %s", lock);
223*9b4856c4Sbostic }
224*9b4856c4Sbostic
225*9b4856c4Sbostic if(veryold(fd)) /* if true, this closes fd and unlinks lock */
226*9b4856c4Sbostic goto gotlock;
227*9b4856c4Sbostic (void) close(fd);
228*9b4856c4Sbostic } while(i < locknum);
229*9b4856c4Sbostic
230*9b4856c4Sbostic (void) unlink(LLOCK);
231*9b4856c4Sbostic error(locknum ? "Too many hacks running now."
232*9b4856c4Sbostic : "There is a game in progress under your name.");
233*9b4856c4Sbostic gotlock:
234*9b4856c4Sbostic fd = creat(lock, FMASK);
235*9b4856c4Sbostic if(unlink(LLOCK) == -1)
236*9b4856c4Sbostic error("Cannot unlink %s.", LLOCK);
237*9b4856c4Sbostic if(fd == -1) {
238*9b4856c4Sbostic error("cannot creat lock file.");
239*9b4856c4Sbostic } else {
240*9b4856c4Sbostic if(write(fd, (char *) &hackpid, sizeof(hackpid))
241*9b4856c4Sbostic != sizeof(hackpid)){
242*9b4856c4Sbostic error("cannot write lock");
243*9b4856c4Sbostic }
244*9b4856c4Sbostic if(close(fd) == -1) {
245*9b4856c4Sbostic error("cannot close lock");
246*9b4856c4Sbostic }
247*9b4856c4Sbostic }
248*9b4856c4Sbostic }
249*9b4856c4Sbostic
250*9b4856c4Sbostic #ifdef MAIL
251*9b4856c4Sbostic
252*9b4856c4Sbostic /*
253*9b4856c4Sbostic * Notify user when new mail has arrived. [Idea from Merlyn Leroy, but
254*9b4856c4Sbostic * I don't know the details of his implementation.]
255*9b4856c4Sbostic * { Later note: he disliked my calling a general mailreader and felt that
256*9b4856c4Sbostic * hack should do the paging itself. But when I get mail, I want to put it
257*9b4856c4Sbostic * in some folder, reply, etc. - it would be unreasonable to put all these
258*9b4856c4Sbostic * functions in hack. }
259*9b4856c4Sbostic * The mail daemon '2' is at present not a real monster, but only a visual
260*9b4856c4Sbostic * effect. Thus, makemon() is superfluous. This might become otherwise,
261*9b4856c4Sbostic * however. The motion of '2' is less restrained than usual: diagonal moves
262*9b4856c4Sbostic * from a DOOR are possible. He might also use SDOOR's. Also, '2' is visible
263*9b4856c4Sbostic * in a ROOM, even when you are Blind.
264*9b4856c4Sbostic * Its path should be longer when you are Telepat-hic and Blind.
265*9b4856c4Sbostic *
266*9b4856c4Sbostic * Interesting side effects:
267*9b4856c4Sbostic * - You can get rich by sending yourself a lot of mail and selling
268*9b4856c4Sbostic * it to the shopkeeper. Unfortunately mail isn't very valuable.
269*9b4856c4Sbostic * - You might die in case '2' comes along at a critical moment during
270*9b4856c4Sbostic * a fight and delivers a scroll the weight of which causes you to
271*9b4856c4Sbostic * collapse.
272*9b4856c4Sbostic *
273*9b4856c4Sbostic * Possible extensions:
274*9b4856c4Sbostic * - Open the file MAIL and do fstat instead of stat for efficiency.
275*9b4856c4Sbostic * (But sh uses stat, so this cannot be too bad.)
276*9b4856c4Sbostic * - Examine the mail and produce a scroll of mail called "From somebody".
277*9b4856c4Sbostic * - Invoke MAILREADER in such a way that only this single letter is read.
278*9b4856c4Sbostic *
279*9b4856c4Sbostic * - Make him lose his mail when a Nymph steals the letter.
280*9b4856c4Sbostic * - Do something to the text when the scroll is enchanted or cancelled.
281*9b4856c4Sbostic */
282*9b4856c4Sbostic #include "def.mkroom.h"
283*9b4856c4Sbostic static struct stat omstat,nmstat;
284*9b4856c4Sbostic static char *mailbox;
285*9b4856c4Sbostic static long laststattime;
286*9b4856c4Sbostic
getmailstatus()287*9b4856c4Sbostic getmailstatus() {
288*9b4856c4Sbostic if(!(mailbox = getenv("MAIL")))
289*9b4856c4Sbostic return;
290*9b4856c4Sbostic if(stat(mailbox, &omstat)){
291*9b4856c4Sbostic #ifdef PERMANENT_MAILBOX
292*9b4856c4Sbostic pline("Cannot get status of MAIL=%s .", mailbox);
293*9b4856c4Sbostic mailbox = 0;
294*9b4856c4Sbostic #else
295*9b4856c4Sbostic omstat.st_mtime = 0;
296*9b4856c4Sbostic #endif PERMANENT_MAILBOX
297*9b4856c4Sbostic }
298*9b4856c4Sbostic }
299*9b4856c4Sbostic
ckmailstatus()300*9b4856c4Sbostic ckmailstatus() {
301*9b4856c4Sbostic if(!mailbox
302*9b4856c4Sbostic #ifdef MAILCKFREQ
303*9b4856c4Sbostic || moves < laststattime + MAILCKFREQ
304*9b4856c4Sbostic #endif MAILCKFREQ
305*9b4856c4Sbostic )
306*9b4856c4Sbostic return;
307*9b4856c4Sbostic laststattime = moves;
308*9b4856c4Sbostic if(stat(mailbox, &nmstat)){
309*9b4856c4Sbostic #ifdef PERMANENT_MAILBOX
310*9b4856c4Sbostic pline("Cannot get status of MAIL=%s anymore.", mailbox);
311*9b4856c4Sbostic mailbox = 0;
312*9b4856c4Sbostic #else
313*9b4856c4Sbostic nmstat.st_mtime = 0;
314*9b4856c4Sbostic #endif PERMANENT_MAILBOX
315*9b4856c4Sbostic } else if(nmstat.st_mtime > omstat.st_mtime) {
316*9b4856c4Sbostic if(nmstat.st_size)
317*9b4856c4Sbostic newmail();
318*9b4856c4Sbostic getmailstatus(); /* might be too late ... */
319*9b4856c4Sbostic }
320*9b4856c4Sbostic }
321*9b4856c4Sbostic
newmail()322*9b4856c4Sbostic newmail() {
323*9b4856c4Sbostic /* produce a scroll of mail */
324*9b4856c4Sbostic register struct obj *obj;
325*9b4856c4Sbostic register struct monst *md;
326*9b4856c4Sbostic extern char plname[];
327*9b4856c4Sbostic extern struct obj *mksobj(), *addinv();
328*9b4856c4Sbostic extern struct monst *makemon();
329*9b4856c4Sbostic extern struct permonst pm_mail_daemon;
330*9b4856c4Sbostic
331*9b4856c4Sbostic obj = mksobj(SCR_MAIL);
332*9b4856c4Sbostic if(md = makemon(&pm_mail_daemon, u.ux, u.uy)) /* always succeeds */
333*9b4856c4Sbostic mdrush(md,0);
334*9b4856c4Sbostic
335*9b4856c4Sbostic pline("\"Hello, %s! I have some mail for you.\"", plname);
336*9b4856c4Sbostic if(md) {
337*9b4856c4Sbostic if(dist(md->mx,md->my) > 2)
338*9b4856c4Sbostic pline("\"Catch!\"");
339*9b4856c4Sbostic more();
340*9b4856c4Sbostic
341*9b4856c4Sbostic /* let him disappear again */
342*9b4856c4Sbostic mdrush(md,1);
343*9b4856c4Sbostic mondead(md);
344*9b4856c4Sbostic }
345*9b4856c4Sbostic
346*9b4856c4Sbostic obj = addinv(obj);
347*9b4856c4Sbostic (void) identify(obj); /* set known and do prinv() */
348*9b4856c4Sbostic }
349*9b4856c4Sbostic
350*9b4856c4Sbostic /* make md run through the cave */
mdrush(md,away)351*9b4856c4Sbostic mdrush(md,away)
352*9b4856c4Sbostic register struct monst *md;
353*9b4856c4Sbostic boolean away;
354*9b4856c4Sbostic {
355*9b4856c4Sbostic register int uroom = inroom(u.ux, u.uy);
356*9b4856c4Sbostic if(uroom >= 0) {
357*9b4856c4Sbostic register int tmp = rooms[uroom].fdoor;
358*9b4856c4Sbostic register int cnt = rooms[uroom].doorct;
359*9b4856c4Sbostic register int fx = u.ux, fy = u.uy;
360*9b4856c4Sbostic while(cnt--) {
361*9b4856c4Sbostic if(dist(fx,fy) < dist(doors[tmp].x, doors[tmp].y)){
362*9b4856c4Sbostic fx = doors[tmp].x;
363*9b4856c4Sbostic fy = doors[tmp].y;
364*9b4856c4Sbostic }
365*9b4856c4Sbostic tmp++;
366*9b4856c4Sbostic }
367*9b4856c4Sbostic tmp_at(-1, md->data->mlet); /* open call */
368*9b4856c4Sbostic if(away) { /* interchange origin and destination */
369*9b4856c4Sbostic unpmon(md);
370*9b4856c4Sbostic tmp = fx; fx = md->mx; md->mx = tmp;
371*9b4856c4Sbostic tmp = fy; fy = md->my; md->my = tmp;
372*9b4856c4Sbostic }
373*9b4856c4Sbostic while(fx != md->mx || fy != md->my) {
374*9b4856c4Sbostic register int dx,dy,nfx = fx,nfy = fy,d1,d2;
375*9b4856c4Sbostic
376*9b4856c4Sbostic tmp_at(fx,fy);
377*9b4856c4Sbostic d1 = DIST(fx,fy,md->mx,md->my);
378*9b4856c4Sbostic for(dx = -1; dx <= 1; dx++) for(dy = -1; dy <= 1; dy++)
379*9b4856c4Sbostic if(dx || dy) {
380*9b4856c4Sbostic d2 = DIST(fx+dx,fy+dy,md->mx,md->my);
381*9b4856c4Sbostic if(d2 < d1) {
382*9b4856c4Sbostic d1 = d2;
383*9b4856c4Sbostic nfx = fx+dx;
384*9b4856c4Sbostic nfy = fy+dy;
385*9b4856c4Sbostic }
386*9b4856c4Sbostic }
387*9b4856c4Sbostic if(nfx != fx || nfy != fy) {
388*9b4856c4Sbostic fx = nfx;
389*9b4856c4Sbostic fy = nfy;
390*9b4856c4Sbostic } else {
391*9b4856c4Sbostic if(!away) {
392*9b4856c4Sbostic md->mx = fx;
393*9b4856c4Sbostic md->my = fy;
394*9b4856c4Sbostic }
395*9b4856c4Sbostic break;
396*9b4856c4Sbostic }
397*9b4856c4Sbostic }
398*9b4856c4Sbostic tmp_at(-1,-1); /* close call */
399*9b4856c4Sbostic }
400*9b4856c4Sbostic if(!away)
401*9b4856c4Sbostic pmon(md);
402*9b4856c4Sbostic }
403*9b4856c4Sbostic
readmail()404*9b4856c4Sbostic readmail() {
405*9b4856c4Sbostic #ifdef DEF_MAILREADER /* This implies that UNIX is defined */
406*9b4856c4Sbostic register char *mr = 0;
407*9b4856c4Sbostic more();
408*9b4856c4Sbostic if(!(mr = getenv("MAILREADER")))
409*9b4856c4Sbostic mr = DEF_MAILREADER;
410*9b4856c4Sbostic if(child(1)){
411*9b4856c4Sbostic execl(mr, mr, (char *) 0);
412*9b4856c4Sbostic exit(1);
413*9b4856c4Sbostic }
414*9b4856c4Sbostic #else DEF_MAILREADER
415*9b4856c4Sbostic (void) page_file(mailbox, FALSE);
416*9b4856c4Sbostic #endif DEF_MAILREADER
417*9b4856c4Sbostic /* get new stat; not entirely correct: there is a small time
418*9b4856c4Sbostic window where we do not see new mail */
419*9b4856c4Sbostic getmailstatus();
420*9b4856c4Sbostic }
421*9b4856c4Sbostic #endif MAIL
422*9b4856c4Sbostic
regularize(s)423*9b4856c4Sbostic regularize(s) /* normalize file name - we don't like ..'s or /'s */
424*9b4856c4Sbostic register char *s;
425*9b4856c4Sbostic {
426*9b4856c4Sbostic register char *lp;
427*9b4856c4Sbostic
428*9b4856c4Sbostic while((lp = index(s, '.')) || (lp = index(s, '/')))
429*9b4856c4Sbostic *lp = '_';
430*9b4856c4Sbostic }
431