View | Details | Raw Unified | Return to bug 133535
Collapse All | Expand All

(-)./Makefile (-1 / +1 lines)
Lines 7-13 Link Here
7
7
8
PORTNAME=	coolmail
8
PORTNAME=	coolmail
9
PORTVERSION=	1.3
9
PORTVERSION=	1.3
10
PORTREVISION=	2
10
PORTREVISION=	3
11
CATEGORIES=	mail
11
CATEGORIES=	mail
12
MASTER_SITES=	${MASTER_SITE_SUNSITE}
12
MASTER_SITES=	${MASTER_SITE_SUNSITE}
13
MASTER_SITE_SUBDIR=system/mail/biffs
13
MASTER_SITE_SUBDIR=system/mail/biffs
(-)./files/patch-Makefile (+50 lines)
Line 0 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 \
(-)./files/patch-aa (-358 lines)
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
  /*---------------------------------------------------------------------------*/
(-)./files/patch-coolmail.c (+287 lines)
Line 0 Link Here
1
--- coolmail.c.orig	1996-01-11 18:57:24.000000000 +0100
2
+++ coolmail.c	2009-04-08 09:14:08.000000000 +0200
3
@@ -25,8 +25,10 @@
4
 #include <sys/wait.h>
5
 #include <sys/types.h>
6
 #include <sys/stat.h>
7
+#include <dirent.h>
8
 #include <fcntl.h>
9
 
10
+
11
 #ifdef AUDIO
12
 #include <string.h>
13
 #endif
14
@@ -34,14 +36,13 @@
15
 #include "render1.h"
16
 #include "mailbox.h"
17
 
18
-#define DEFAULT_MAIL_DIR  "/var/spool/mail/"
19
-#define DEFAULT_COMMAND   "xterm -n Elm -e mail\0"
20
+#define DEFAULT_MAIL_DIR  "/var/mail/"
21
+
22
+#define DEFAULT_COMMAND   "xterm -n Elm -e elm\0"
23
 #define DEFAULT_INTERVAL  30
24
 #define DEFAULT_FRAMES    15
25
 
26
-#ifdef AUDIO
27
 #define DEFAULT_VOLUME    50
28
-#endif
29
 
30
 #ifndef PI
31
 #define PI 3.1415926536
32
@@ -60,9 +61,9 @@
33
 unsigned int  frames             = DEFAULT_FRAMES;
34
 int           verbose            = 0;
35
 
36
+int          cool_vol            = DEFAULT_VOLUME;
37
 #ifdef AUDIO
38
 char         *sndfile            = NULL;   /* default system sound */
39
-int          cool_vol            = DEFAULT_VOLUME;
40
 #endif
41
 
42
 float  flag_angle = 0.0;
43
@@ -96,7 +97,9 @@
44
 int main(int argc, char *argv[])
45
 {
46
    int reason;
47
+#ifndef NO_CUSERID
48
    char username[L_cuserid];
49
+#endif
50
 
51
    /* Quickly scan for the -h option -- if it is present don't do anything
52
     * but print out some help and exit. */
53
@@ -104,7 +107,18 @@
54
       return(0);
55
 
56
    /* Get the username and use it to create a default mailfile name */
57
-   strcat(mailfile_str, cuserid(username));
58
+#ifdef SUPPORT_MAILDIR
59
+	if (getenv("MAILDIR") && strlen(getenv("MAILDIR"))) {
60
+		strcpy(mailfile_str,getenv("MAILDIR"));
61
+	} else if (getenv("MAIL") && strlen(getenv("MAIL"))) {
62
+   	strcpy(mailfile_str,getenv("MAIL"));
63
+	} else
64
+#endif
65
+#ifndef NO_CUSERID
66
+   	strcat(mailfile_str, cuserid(username));
67
+#else
68
+   	strcat(mailfile_str, getlogin());
69
+#endif
70
 
71
    /* Initialize the renderer */
72
    rend_init(&argc, argv, (float)150.0);
73
@@ -379,7 +393,6 @@
74
       {
75
          verbose++;
76
       }
77
-#ifdef AUDIO
78
       else if (!strcmp(argv[i], "-vol"))
79
       {
80
          i++;
81
@@ -387,6 +400,7 @@
82
          if      (cool_vol < 0)   cool_vol = 0;
83
          else if (cool_vol > 100) cool_vol = 100;
84
       }
85
+#ifdef AUDIO
86
       else if (!strcmp(argv[i], "-af"))
87
       {
88
          i++;
89
@@ -432,7 +446,7 @@
90
    printf("  -e command   Specifies a command (usually in quotes) which\n");
91
    printf("               is used to invoke your favorite mail-reading\n");
92
    printf("               program.\n\n");
93
-   printf("  -f filename  Watch filename, instead of the default mail\n");
94
+   printf("  -f filename  Watch filename/maildir, instead of the default mail\n");
95
    printf("               file, %s<username>.\n\n", DEFAULT_MAIL_DIR);
96
    printf("  -fr n        Number of frames to generate for each animation.\n");
97
    printf("               Set to an appropriate value for your machine's.\n");
98
@@ -626,6 +640,39 @@
99
 
100
 /* Get file modification time */
101
 
102
+
103
+/* Maildir notes (aqua@sonoma.net, Sun Jan 18 19:42:27 PST 1998):
104
+ *
105
+ * The maildir mail-storage standard is a replacement for the traditional
106
+ * 'mbox' format, intended to remove problems with file contention, locking,
107
+ * reduce corruption in the case of a program or system crash, etc, etc.
108
+ * Fairly detailed description of it can be had as part of the Qmail MTA
109
+ * documentation, http://www.qmail.org/qmail-manual-html/man5/maildir.html.
110
+ *
111
+ * The general gist of the maildir approach is that mail is stored, one
112
+ # message per file, in a subtree of ~/Maildir.  New mail goes in /new,
113
+ * the "spool" goes in /cur, and /tmp is available to MUAs &c.  Mail is
114
+ * theoretically supposed to be removed from /new immediately by the
115
+ * MUA, but I've observed that with mutt 0.88, at least, it isn't if
116
+ * the mailfile was generated by an import script (e.g. mbox2maildir)
117
+ * rather than the normal delivery agent, presumably due to naming
118
+ * differences.
119
+ *
120
+ * Checking for new mail mostly entails checking the mtime vs. atime of
121
+ * every file in /new, and the number of messages in /new; if the latter
122
+ * increases, new mail was delivered -- if not, but the files' atimes
123
+ * are all later than their mtimes, the MUA read the /new spool.
124
+ *
125
+ * The specifications suggest skipping over every .file, but reading all
126
+ * the others -- I've extended this to include skipping of all non-regular
127
+ * files, which seemed to make sense -- define SUPPORT_MAILDIR_STRICTER to
128
+ * override this behavior.
129
+ *
130
+ * This process is more resource-intensive than the old scheme of merely
131
+ * calling stat() for a single file -- it's an O(n) rather than O(1)
132
+ * operation.
133
+ *
134
+ */
135
 void cool_get_inboxstatus(char *filename, int *anymail, int *unreadmail,
136
                           int *newmail)
137
 {
138
@@ -633,38 +680,119 @@
139
    off_t  newsize;
140
    struct stat st;
141
    int fd;
142
+#ifdef SUPPORT_MAILDIR
143
+   DIR *d;
144
+   struct dirent *de;
145
+   char maildir[256],mfn[256];
146
+#endif
147
 
148
-   fd = open (filename, O_RDONLY, 0);
149
-   if (fd < 0)
150
-   {
151
-      *anymail    = 0;
152
-      *newmail    = 0;
153
-      *unreadmail = 0;
154
-      newsize = 0;
155
-   }
156
-   else
157
-   {
158
-      fstat(fd, &st);
159
-      close(fd);
160
-      newsize = st.st_size;
161
-
162
-      if (newsize > 0)
163
-         *anymail = 1;
164
-      else
165
-         *anymail = 0;
166
-
167
-      if (st.st_mtime >= st.st_atime && newsize > 0)
168
-         *unreadmail = 1;
169
-      else
170
-         *unreadmail = 0;
171
-
172
-      if (newsize > oldsize && *unreadmail)
173
-         *newmail = 1;
174
-      else
175
-         *newmail = 0;
176
-   }
177
 
178
-   oldsize = newsize;
179
+#ifdef SUPPORT_MAILDIR_DEBUG
180
+   printf("B anymail=%d, newmail=%d, unreadmail=%d, oldsize=%d, newsize=%d\n",
181
+   	*anymail,*newmail,*unreadmail,oldsize,newsize);
182
+#endif
183
+#ifdef SUPPORT_MAILDIR
184
+   if (stat(filename,&st)==-1) {
185
+  	   *anymail = *newmail = *unreadmail = 0;
186
+     	newsize = oldsize = 0;   
187
+      perror(filename);
188
+      return;
189
+   }
190
+   if (S_ISDIR(st.st_mode)) {
191
+      /* likely a maildir */
192
+   	strcpy(maildir,filename);
193
+	   if (maildir[strlen(maildir)-1]!='/')
194
+   	  strcat(maildir,"/");
195
+	   strcat(maildir,"new");
196
+   	if (stat(maildir,&st)==-1) {
197
+      	perror(maildir);
198
+	      printf("%s is not a maildir (missing/inaccessible %s)\n",filename,maildir);
199
+   	   *anymail = *newmail = *unreadmail = 0;
200
+      	newsize = oldsize = 0;
201
+	      return;
202
+   	}
203
+	   if (!S_ISDIR(st.st_mode)) {
204
+   	   printf("%s is not a directory (mode %d)\n",maildir,st.st_mode);
205
+      	*anymail = *newmail = *unreadmail = 0;
206
+	      newsize = oldsize = 0;
207
+   	   return;
208
+	   }   
209
+	   d=opendir(maildir);
210
+	   newsize=0;
211
+   	*unreadmail = 0;
212
+	   while ((de=readdir(d))) {
213
+   	   if (de->d_name[0]=='.') /* dotfiles ignored per the maildir specs */
214
+      	   continue;
215
+	      strcpy(mfn,maildir);
216
+   	   if (mfn[strlen(mfn)-1]!='/')
217
+      	  strcat(mfn,"/");
218
+	      strcat(mfn,de->d_name);
219
+   	   if (stat(mfn,&st)==-1) {
220
+      	  perror(mfn);
221
+	        continue;
222
+   	   }
223
+#ifndef SUPPORT_MAILDIR_STRICTER
224
+      	if (S_ISREG(st.st_mode))
225
+#endif
226
+         	newsize++;
227
+	      if (st.st_mtime>=st.st_atime) {
228
+#ifdef SUPPORT_MAILDIR_DEBUG
229
+   	     printf("unread: %s mtime = %d, atime = %d\n",de->d_name,st.st_mtime,st.st_atime);
230
+#endif
231
+	        *unreadmail = 1;
232
+   	   }
233
+	   }
234
+	   closedir(d);
235
+	   if (newsize) {
236
+	     *anymail = 1;
237
+   	  if (newsize>oldsize && *unreadmail)
238
+      	 *newmail = 1;
239
+	     else
240
+   	    *newmail = 0;
241
+	   } else {
242
+   	  *anymail = *newmail = *unreadmail = 0;
243
+	     newsize = 0;
244
+	   }
245
+#ifdef SUPPORT_MAILDIR_DEBUG
246
+   	printf("A anymail=%d, newmail=%d, unreadmail=%d, oldsize=%d, newsize=%d\n",
247
+		  	*anymail,*newmail,*unreadmail,oldsize,newsize);
248
+#endif
249
+	   oldsize=newsize;
250
+	} else {
251
+#endif /* SUPPORT_MAILDIR */
252
+	   fd = open (filename, O_RDONLY, 0);
253
+   	if (fd < 0)
254
+	   {
255
+   	   *anymail    = 0;
256
+      	*newmail    = 0;
257
+	      *unreadmail = 0;
258
+   	   newsize = 0;
259
+	   }
260
+	   else
261
+	   {
262
+   	   fstat(fd, &st);
263
+	      close(fd);
264
+   	   newsize = st.st_size;
265
+
266
+	      if (newsize > 0)
267
+   	      *anymail = 1;
268
+      	else
269
+	         *anymail = 0;
270
+
271
+   	   if (st.st_mtime >= st.st_atime && newsize > 0)
272
+      	   *unreadmail = 1;
273
+	      else
274
+   	      *unreadmail = 0;
275
+
276
+	      if (newsize > oldsize && *unreadmail)
277
+   	      *newmail = 1;
278
+	      else
279
+   	      *newmail = 0;
280
+	   }
281
+#ifdef SUPPORT_MAILDIR
282
+	}
283
+#endif
284
+	oldsize = newsize;	
285
 }
286
 
287
 /*---------------------------------------------------------------------------*/
(-)./files/patch-coolmail.man (+32 lines)
Line 0 Link Here
1
--- coolmail.man.orig	1996-01-11 18:57:28.000000000 +0100
2
+++ coolmail.man	2009-04-09 09:00:38.000000000 +0200
3
@@ -37,12 +37,9 @@
4
 Ring bell when new mail is first detected, but not when more new mail is
5
 detected.
6
 .TP 8
7
--af filename 
8
-Specifies the audio file to use rather than the standard system beep.
9
-.TP 8
10
 -vol n
11
-Value between 0 and 100 for the volume setting for both the system
12
-beep and the sound file. The default is 50.
13
+Value between 0 and 100 for the volume setting for the system
14
+beep. The default is 50.
15
 .TP 8
16
 -v
17
 Print version and inbox path.
18
@@ -71,12 +68,9 @@
19
 .B monochrome (\fPclass\fB Monochrome)
20
 A Boolean value that enables monochrome mode when true.
21
 .TP 8
22
-.B soundFile (\fPclass \fB SoundFile)
23
-Specifies the audio file to use rather than the standard system beep.
24
-.TP 8
25
 .B volume (\fPclass \fB Volume)
26
-Value between 0 and 100 for the volume setting for both the system
27
-beep and the sound file.
28
+Value between 0 and 100 for the volume setting for the system
29
+beep.
30
 .SH COPYRIGHT
31
 Copyright 1994
32
 
(-)./files/patch-display_list.c (+46 lines)
Line 0 Link Here
1
--- coolmail-1.3/system/X11/display_list.c.orig	1996-01-11 19:14:30.000000000 +0100
2
+++ coolmail-1.3/system/X11/display_list.c	2009-04-08 09:14:08.000000000 +0200
3
@@ -41,9 +41,9 @@
4
 extern char mailfile_str[]; /* to obtain the command and mail file.    */
5
 extern unsigned int frames;
6
 
7
+extern int  cool_vol;	
8
 #ifdef AUDIO
9
 extern char *sndfile; /* same hack as above */
10
-extern int  cool_vol;	
11
 void audio_beep(void);
12
 #endif
13
 
14
@@ -156,9 +156,9 @@
15
 #ifdef AUDIO
16
    XtResource soundfile  = {"soundFile", "SoundFile", XtRString,
17
                             sizeof(str), 0, XtRString, sndfile};
18
+#endif
19
    XtResource volume   = {"volume", "Volume", XtRInt,
20
                           sizeof(cool_vol), 0, XtRInt, &cool_vol};
21
-#endif
22
 
23
    XtGetApplicationResources(toplevel, &str, &mailcmd, 1, NULL, 0);
24
    strcpy(command_str, str);
25
@@ -175,11 +175,11 @@
26
    XtGetApplicationResources(toplevel, &str, &soundfile, 1, NULL, 0);
27
    if(str)
28
       sndfile = (char *)strdup(str);
29
+#endif
30
 
31
    XtGetApplicationResources(toplevel, &cool_vol, &volume, 1, NULL, 0);
32
    if      (cool_vol < 0)   cool_vol = 0;
33
    else if (cool_vol > 100) cool_vol = 100;
34
-#endif
35
 
36
 }
37
 
38
@@ -308,7 +308,7 @@
39
    else	/* no sound file chosen then use system bell */
40
       XBell(XtDisplay(main_gfx_w), cool_vol);
41
 #else
42
-   XBell(XtDisplay(main_gfx_w), 50);
43
+   XBell(XtDisplay(main_gfx_w), cool_vol);
44
 #endif
45
 }
46

Return to bug 133535