Lines 1-358
Link Here
|
1 |
--- Makefile.orig Thu Jan 11 11:55:40 1996 |
|
|
2 |
+++ Makefile Mon Oct 12 17:55:05 1998 |
3 |
@@ -22,31 +22,38 @@ |
4 |
# your linker where to find the libraries it will need, and BINDIR and |
5 |
# MANDIR specify the places to install the binary executable and manpage |
6 |
# files for coolmail when you type `make install'. |
7 |
-CFLAGS = |
8 |
+CFLAGS = -DNO_CUSERID |
9 |
LINK = $(CC) |
10 |
-INCLUDES = -I/usr/X11R5/include |
11 |
-LIB_DIRS = -L/usr/X11R5/lib |
12 |
+INCLUDES = -I$(LOCALBASE)/include |
13 |
+LIB_DIRS = -L$(LOCALBASE)/lib |
14 |
BINDIR = /usr/local/bin |
15 |
MANDIR = /usr/local/man/man1 |
16 |
|
17 |
# Comment these out if you can't or don't want to use the digitized audio |
18 |
# feature. |
19 |
-AUDIO = -DAUDIO |
20 |
-AUDIO_MODULE = audio.o |
21 |
+# AUDIO = -DAUDIO |
22 |
+# AUDIO_MODULE = audio.o |
23 |
+ |
24 |
+# Comment these out if you don't want Maildir support |
25 |
+MAILDIR = -DSUPPORT_MAILDIR |
26 |
+# for debugging: |
27 |
+#MAILDIR = $(MAILDIR) -DSUPPORT_MAILDIR_DEBUG |
28 |
+# normally ignores non-regular files in the Maildir; uncomment to change |
29 |
+#MAILDIR = $(MAILDIR) -DSUPPORT_MAILDIR_STRICTER |
30 |
|
31 |
#### You really don't need to read past this point. #### |
32 |
|
33 |
LIBS = $(LIB_DIRS) -lXt -lX11 -lm -lXext |
34 |
-COPTS = $(CFLAGS) $(AUDIO) |
35 |
+LIBS += -Wl,-rpath,$(LOCALBASE)/lib |
36 |
+COPTS = $(CFLAGS) $(AUDIO) $(MAILDIR) |
37 |
|
38 |
all: coolmail |
39 |
# Done. |
40 |
|
41 |
-new: |
42 |
- rm -f *.o coolmail core |
43 |
+new: clean all |
44 |
|
45 |
clean: |
46 |
- rm -f *.o core |
47 |
+ rm -f *.o core coolmail |
48 |
|
49 |
install: |
50 |
@if [ -w $(BINDIR) ] ; then \ |
51 |
diff -rc coolmail-1.3.org/audio.c coolmail-1.3/audio.c |
52 |
*** coolmail-1.3.org/audio.c Thu Jan 11 18:56:40 1996 |
53 |
--- coolmail-1.3/audio.c Fri Jul 3 08:47:51 1998 |
54 |
*************** |
55 |
*** 128,133 **** |
56 |
--- 128,134 ---- |
57 |
INIT_FD; |
58 |
audiofd = open( "/dev/audio", O_WRONLY | O_NDELAY ); |
59 |
if (audiofd < 0) { |
60 |
+ perror("/dev/audio"); |
61 |
fprintf(stderr, "%s: Problem opening /dev/audio.\n", |
62 |
"Coolmail"); |
63 |
END_FD; |
64 |
diff -rc coolmail-1.3.org/coolmail.c coolmail-1.3/coolmail.c |
65 |
*** coolmail-1.3.org/coolmail.c Thu Jan 11 18:57:24 1996 |
66 |
--- coolmail-1.3/coolmail.c Fri Jul 3 09:01:05 1998 |
67 |
*************** |
68 |
*** 25,32 **** |
69 |
--- 25,34 ---- |
70 |
#include <sys/wait.h> |
71 |
#include <sys/types.h> |
72 |
#include <sys/stat.h> |
73 |
+ #include <dirent.h> |
74 |
#include <fcntl.h> |
75 |
|
76 |
+ |
77 |
#ifdef AUDIO |
78 |
#include <string.h> |
79 |
#endif |
80 |
*************** |
81 |
*** 34,41 **** |
82 |
#include "render1.h" |
83 |
#include "mailbox.h" |
84 |
|
85 |
! #define DEFAULT_MAIL_DIR "/var/spool/mail/" |
86 |
! #define DEFAULT_COMMAND "xterm -n Elm -e mail\0" |
87 |
#define DEFAULT_INTERVAL 30 |
88 |
#define DEFAULT_FRAMES 15 |
89 |
|
90 |
--- 36,44 ---- |
91 |
#include "render1.h" |
92 |
#include "mailbox.h" |
93 |
|
94 |
! #define DEFAULT_MAIL_DIR "/var/mail/" |
95 |
! |
96 |
! #define DEFAULT_COMMAND "xterm -n Elm -e elm\0" |
97 |
#define DEFAULT_INTERVAL 30 |
98 |
#define DEFAULT_FRAMES 15 |
99 |
|
100 |
*************** |
101 |
*** 96,102 **** |
102 |
--- 99,107 ---- |
103 |
int main(int argc, char *argv[]) |
104 |
{ |
105 |
int reason; |
106 |
+ #ifndef NO_CUSERID |
107 |
char username[L_cuserid]; |
108 |
+ #endif |
109 |
|
110 |
/* Quickly scan for the -h option -- if it is present don't do anything |
111 |
* but print out some help and exit. */ |
112 |
*************** |
113 |
*** 104,110 **** |
114 |
return(0); |
115 |
|
116 |
/* Get the username and use it to create a default mailfile name */ |
117 |
! strcat(mailfile_str, cuserid(username)); |
118 |
|
119 |
/* Initialize the renderer */ |
120 |
rend_init(&argc, argv, (float)150.0); |
121 |
--- 109,126 ---- |
122 |
return(0); |
123 |
|
124 |
/* Get the username and use it to create a default mailfile name */ |
125 |
! #ifdef SUPPORT_MAILDIR |
126 |
! if (getenv("MAILDIR") && strlen(getenv("MAILDIR"))) { |
127 |
! strcpy(mailfile_str,getenv("MAILDIR")); |
128 |
! } else if (getenv("MAIL") && strlen(getenv("MAIL"))) { |
129 |
! strcpy(mailfile_str,getenv("MAIL")); |
130 |
! } else |
131 |
! #endif |
132 |
! #ifndef NO_CUSERID |
133 |
! strcat(mailfile_str, cuserid(username)); |
134 |
! #else |
135 |
! strcat(mailfile_str, getlogin()); |
136 |
! #endif |
137 |
|
138 |
/* Initialize the renderer */ |
139 |
rend_init(&argc, argv, (float)150.0); |
140 |
*************** |
141 |
*** 432,438 **** |
142 |
printf(" -e command Specifies a command (usually in quotes) which\n"); |
143 |
printf(" is used to invoke your favorite mail-reading\n"); |
144 |
printf(" program.\n\n"); |
145 |
! printf(" -f filename Watch filename, instead of the default mail\n"); |
146 |
printf(" file, %s<username>.\n\n", DEFAULT_MAIL_DIR); |
147 |
printf(" -fr n Number of frames to generate for each animation.\n"); |
148 |
printf(" Set to an appropriate value for your machine's.\n"); |
149 |
--- 448,454 ---- |
150 |
printf(" -e command Specifies a command (usually in quotes) which\n"); |
151 |
printf(" is used to invoke your favorite mail-reading\n"); |
152 |
printf(" program.\n\n"); |
153 |
! printf(" -f filename Watch filename/maildir, instead of the default mail\n"); |
154 |
printf(" file, %s<username>.\n\n", DEFAULT_MAIL_DIR); |
155 |
printf(" -fr n Number of frames to generate for each animation.\n"); |
156 |
printf(" Set to an appropriate value for your machine's.\n"); |
157 |
*************** |
158 |
*** 626,631 **** |
159 |
--- 642,680 ---- |
160 |
|
161 |
/* Get file modification time */ |
162 |
|
163 |
+ |
164 |
+ /* Maildir notes (aqua@sonoma.net, Sun Jan 18 19:42:27 PST 1998): |
165 |
+ * |
166 |
+ * The maildir mail-storage standard is a replacement for the traditional |
167 |
+ * 'mbox' format, intended to remove problems with file contention, locking, |
168 |
+ * reduce corruption in the case of a program or system crash, etc, etc. |
169 |
+ * Fairly detailed description of it can be had as part of the Qmail MTA |
170 |
+ * documentation, http://www.qmail.org/qmail-manual-html/man5/maildir.html. |
171 |
+ * |
172 |
+ * The general gist of the maildir approach is that mail is stored, one |
173 |
+ # message per file, in a subtree of ~/Maildir. New mail goes in /new, |
174 |
+ * the "spool" goes in /cur, and /tmp is available to MUAs &c. Mail is |
175 |
+ * theoretically supposed to be removed from /new immediately by the |
176 |
+ * MUA, but I've observed that with mutt 0.88, at least, it isn't if |
177 |
+ * the mailfile was generated by an import script (e.g. mbox2maildir) |
178 |
+ * rather than the normal delivery agent, presumably due to naming |
179 |
+ * differences. |
180 |
+ * |
181 |
+ * Checking for new mail mostly entails checking the mtime vs. atime of |
182 |
+ * every file in /new, and the number of messages in /new; if the latter |
183 |
+ * increases, new mail was delivered -- if not, but the files' atimes |
184 |
+ * are all later than their mtimes, the MUA read the /new spool. |
185 |
+ * |
186 |
+ * The specifications suggest skipping over every .file, but reading all |
187 |
+ * the others -- I've extended this to include skipping of all non-regular |
188 |
+ * files, which seemed to make sense -- define SUPPORT_MAILDIR_STRICTER to |
189 |
+ * override this behavior. |
190 |
+ * |
191 |
+ * This process is more resource-intensive than the old scheme of merely |
192 |
+ * calling stat() for a single file -- it's an O(n) rather than O(1) |
193 |
+ * operation. |
194 |
+ * |
195 |
+ */ |
196 |
void cool_get_inboxstatus(char *filename, int *anymail, int *unreadmail, |
197 |
int *newmail) |
198 |
{ |
199 |
*************** |
200 |
*** 633,670 **** |
201 |
off_t newsize; |
202 |
struct stat st; |
203 |
int fd; |
204 |
|
205 |
- fd = open (filename, O_RDONLY, 0); |
206 |
- if (fd < 0) |
207 |
- { |
208 |
- *anymail = 0; |
209 |
- *newmail = 0; |
210 |
- *unreadmail = 0; |
211 |
- newsize = 0; |
212 |
- } |
213 |
- else |
214 |
- { |
215 |
- fstat(fd, &st); |
216 |
- close(fd); |
217 |
- newsize = st.st_size; |
218 |
- |
219 |
- if (newsize > 0) |
220 |
- *anymail = 1; |
221 |
- else |
222 |
- *anymail = 0; |
223 |
- |
224 |
- if (st.st_mtime >= st.st_atime && newsize > 0) |
225 |
- *unreadmail = 1; |
226 |
- else |
227 |
- *unreadmail = 0; |
228 |
|
229 |
! if (newsize > oldsize && *unreadmail) |
230 |
! *newmail = 1; |
231 |
! else |
232 |
! *newmail = 0; |
233 |
! } |
234 |
! |
235 |
! oldsize = newsize; |
236 |
} |
237 |
|
238 |
/*---------------------------------------------------------------------------*/ |
239 |
--- 682,800 ---- |
240 |
off_t newsize; |
241 |
struct stat st; |
242 |
int fd; |
243 |
+ #ifdef SUPPORT_MAILDIR |
244 |
+ DIR *d; |
245 |
+ struct dirent *de; |
246 |
+ char maildir[256],mfn[256]; |
247 |
+ #endif |
248 |
|
249 |
|
250 |
! #ifdef SUPPORT_MAILDIR_DEBUG |
251 |
! printf("B anymail=%d, newmail=%d, unreadmail=%d, oldsize=%d, newsize=%d\n", |
252 |
! *anymail,*newmail,*unreadmail,oldsize,newsize); |
253 |
! #endif |
254 |
! #ifdef SUPPORT_MAILDIR |
255 |
! if (stat(filename,&st)==-1) { |
256 |
! *anymail = *newmail = *unreadmail = 0; |
257 |
! newsize = oldsize = 0; |
258 |
! perror(filename); |
259 |
! return; |
260 |
! } |
261 |
! if (S_ISDIR(st.st_mode)) { |
262 |
! /* likely a maildir */ |
263 |
! strcpy(maildir,filename); |
264 |
! if (maildir[strlen(maildir)-1]!='/') |
265 |
! strcat(maildir,"/"); |
266 |
! strcat(maildir,"new"); |
267 |
! if (stat(maildir,&st)==-1) { |
268 |
! perror(maildir); |
269 |
! printf("%s is not a maildir (missing/inaccessible %s)\n",filename,maildir); |
270 |
! *anymail = *newmail = *unreadmail = 0; |
271 |
! newsize = oldsize = 0; |
272 |
! return; |
273 |
! } |
274 |
! if (!S_ISDIR(st.st_mode)) { |
275 |
! printf("%s is not a directory (mode %d)\n",maildir,st.st_mode); |
276 |
! *anymail = *newmail = *unreadmail = 0; |
277 |
! newsize = oldsize = 0; |
278 |
! return; |
279 |
! } |
280 |
! d=opendir(maildir); |
281 |
! newsize=0; |
282 |
! *unreadmail = 0; |
283 |
! while ((de=readdir(d))) { |
284 |
! if (de->d_name[0]=='.') /* dotfiles ignored per the maildir specs */ |
285 |
! continue; |
286 |
! strcpy(mfn,maildir); |
287 |
! if (mfn[strlen(mfn)-1]!='/') |
288 |
! strcat(mfn,"/"); |
289 |
! strcat(mfn,de->d_name); |
290 |
! if (stat(mfn,&st)==-1) { |
291 |
! perror(mfn); |
292 |
! continue; |
293 |
! } |
294 |
! #ifndef SUPPORT_MAILDIR_STRICTER |
295 |
! if (S_ISREG(st.st_mode)) |
296 |
! #endif |
297 |
! newsize++; |
298 |
! if (st.st_mtime>=st.st_atime) { |
299 |
! #ifdef SUPPORT_MAILDIR_DEBUG |
300 |
! printf("unread: %s mtime = %d, atime = %d\n",de->d_name,st.st_mtime,st.st_atime); |
301 |
! #endif |
302 |
! *unreadmail = 1; |
303 |
! } |
304 |
! } |
305 |
! closedir(d); |
306 |
! if (newsize) { |
307 |
! *anymail = 1; |
308 |
! if (newsize>oldsize && *unreadmail) |
309 |
! *newmail = 1; |
310 |
! else |
311 |
! *newmail = 0; |
312 |
! } else { |
313 |
! *anymail = *newmail = *unreadmail = 0; |
314 |
! newsize = 0; |
315 |
! } |
316 |
! #ifdef SUPPORT_MAILDIR_DEBUG |
317 |
! printf("A anymail=%d, newmail=%d, unreadmail=%d, oldsize=%d, newsize=%d\n", |
318 |
! *anymail,*newmail,*unreadmail,oldsize,newsize); |
319 |
! #endif |
320 |
! oldsize=newsize; |
321 |
! } else { |
322 |
! #endif /* SUPPORT_MAILDIR */ |
323 |
! fd = open (filename, O_RDONLY, 0); |
324 |
! if (fd < 0) |
325 |
! { |
326 |
! *anymail = 0; |
327 |
! *newmail = 0; |
328 |
! *unreadmail = 0; |
329 |
! newsize = 0; |
330 |
! } |
331 |
! else |
332 |
! { |
333 |
! fstat(fd, &st); |
334 |
! close(fd); |
335 |
! newsize = st.st_size; |
336 |
! |
337 |
! if (newsize > 0) |
338 |
! *anymail = 1; |
339 |
! else |
340 |
! *anymail = 0; |
341 |
! |
342 |
! if (st.st_mtime >= st.st_atime && newsize > 0) |
343 |
! *unreadmail = 1; |
344 |
! else |
345 |
! *unreadmail = 0; |
346 |
! |
347 |
! if (newsize > oldsize && *unreadmail) |
348 |
! *newmail = 1; |
349 |
! else |
350 |
! *newmail = 0; |
351 |
! } |
352 |
! #ifdef SUPPORT_MAILDIR |
353 |
! } |
354 |
! #endif |
355 |
! oldsize = newsize; |
356 |
} |
357 |
|
358 |
/*---------------------------------------------------------------------------*/ |