-
Notifications
You must be signed in to change notification settings - Fork 2
/
mail.c
85 lines (72 loc) · 1.52 KB
/
mail.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/*
* oneko - Neko runs Over the windows.
*
* mail.c: mail routines
*/
#ifndef lint
static char rcsid[] = "$Id: mail.c,v 1.3 1992/03/17 14:08:41 kato Exp kato $";
#endif
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "oneko.h"
#ifndef MAILBOX_DIRECTORY
#ifdef i386
#define MAILBOX_DIRECTORY "/var/mail/"
#else /* i386 */
#ifdef SYSV
#ifdef SVR4
#define MAILBOX_DIRECTORY "/var/mail/"
#else /* SVR4 */
#define MAILBOX_DIRECTORY "/usr/mail/"
#endif /* SVR4 */
#else /* SYSV */
#define MAILBOX_DIRECTORY "/usr/spool/mail/"
#endif /* SYSV */
#endif /* i386 */
#endif /* MAILBOX_DIRECTORY */
long MailCount;
long UpdateTime;
Bool MailArrive = False;
char *MailFile;
void
SetMail()
{
static char buf[1024];
if (MailFile == NULL) {
MailFile = buf;
(void) strcpy(MailFile, MAILBOX_DIRECTORY);
#ifndef NO_CUSERID
(void) strcat(MailFile, cuserid(NULL));
#else
(void) strcat(MailFile, getenv("USER"));
#endif
}
MailCount = 0;
MailArrive = False;
SetToyState(&Post, TOY_NO);
}
void
MailCheck()
{
struct stat file_stat;
if (--MailCount > 0) {
return;
}
MailCount = (int) ((UpdateTime * 1000000) / IntervalTime);
if ((stat(MailFile, &file_stat) == 0)
&& (file_stat.st_size != 0)) {
if (MailArrive == False) {
ToyAppear(&Post, Post.x, Post.y);
}
MailArrive = True;
}
else {
if (MailArrive == True) {
ToyDisappear(&Post);
}
MailArrive = False;
}
}