aboutsummaryrefslogtreecommitdiff
path: root/mail/xpbiff/files/patch-ac
blob: 6e5e244aa39923223ced5661081a1cc03145d0c4 (plain) (blame)
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
--- xpbiff.c.orig	Thu Oct 27 15:42:52 1994
+++ xpbiff.c	Tue Jul 15 13:42:03 1997
@@ -74,6 +74,12 @@
 #endif
 #endif /* SUN_AUDIO */
 
+#ifdef BSD_AUDIO
+#include <machine/soundcard.h>
+#define MAX_SOUND_VOL 95
+#define MIN_SOUND_VOL 05
+#endif
+
 #ifndef X11R3
 #include <X11/Xaw/Box.h>
 #include <X11/Xaw/Label.h>
@@ -116,7 +122,11 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <math.h>
+#ifdef HAVE_GETPWUID
+#include <pwd.h>
+#endif /* HAVE_GETPWUID */
 
 #ifdef YOUBIN
 
@@ -149,11 +159,13 @@
 
 #ifndef YOUBIN
 
+#ifndef SPOOLPATH
 #ifdef USG
 #define SPOOLPATH	"/usr/mail/"
 #else
 #define SPOOLPATH	"/usr/spool/mail/"
 #endif
+#endif
 
 #else /* YOUBIN */
 
@@ -324,7 +336,7 @@
     NULL
 };
 
-#ifdef SUN_AUDIO
+#if (defined(SUN_AUDIO) || defined(BSD_AUDIO))
 String mail_sndfile;
 int volume;
 #endif
@@ -399,7 +411,7 @@
     {"nomailPixmapMask", "NomailPixmapMask", XtRBitmap, sizeof(Pixmap),
 	 (Cardinal)&noPixmapMask, XtRBitmap, None},
 #endif
-#ifdef SUN_AUDIO
+#if (defined(SUN_AUDIO) || defined(BSD_AUDIO))
     {"mailSndFile", "MailSndFile", XtRString, sizeof(String),
      (Cardinal)&mail_sndfile, XtRString, None},
     {"volume", "Volume", XtRInt, sizeof(int),
@@ -445,7 +457,7 @@
     {"-server",		"*server",		XrmoptionSepArg,	NULL},
     {"-preserve",	"*preserve",		XrmoptionNoArg,		"true"},
 #endif /* YOUBIN */
-#ifdef SUN_AUDIO
+#if (defined(SUN_AUDIO) || defined(BSD_AUDIO))
     {"-sndfile",	"*mailSndFile",		XrmoptionSepArg,	NULL},
     {"-volume",		"*volume",		XrmoptionSepArg,	NULL},
 #endif
@@ -485,9 +497,9 @@
     XGCValues		values;
     XtTranslations	newTranslations;
     static XtActionsRec redrawActions[] = {
-	{"expose", (XtCallbackProc) redraw_callback},
-	{"select", (XtCallbackProc) popup_again},
-	{"quit", (XtCallbackProc) quit},
+	{"expose", (XtActionProc) redraw_callback},
+	{"select", (XtActionProc) popup_again},
+	{"quit", (XtActionProc) quit},
     };
 
     static char		*overrideTranslations =
@@ -498,6 +510,9 @@
     int			dummy;
     int			i;
 
+#ifdef HAVE_GETPWUID
+    struct passwd	*pw;
+#endif
 #ifdef JCONVERT
     char		*locale_name;
     Locale_ent		*p;
@@ -514,28 +529,40 @@
 #endif /* !YOUBIN */
 
 #ifdef YOUBIN
-	if ((prog_name = strrchr(argv[0], '/')) != NULL) {
-	    prog_name++;
-	} else {
-	    prog_name = argv[0];
-	}
+    if ((prog_name = strrchr(argv[0], '/')) != NULL) {
+	prog_name++;
+    } else {
+	prog_name = argv[0];
+    }
 #else	/* !YOUBIN */
-    if (spoolPath != NULL && spoolPath[0] != '\0')
+    if (spoolPath != NULL && spoolPath[0] != '\0') {
 	strcpy(spool_path, spoolPath);
-    else
+    } else {
     	strcpy(spool_path, SPOOLPATH);
-    if (spool_path[strlen(spool_path) - 1] != '/')
+    }
+    if (spool_path[strlen(spool_path) - 1] != '/') {
 	strcat(spool_path, "/");
+    }
+
 #ifdef GETENV_MAIL
-    if (getenv("MAIL") != NULL)
+    if (getenv("MAIL") != NULL) {
 	strcpy(spool_path, getenv("MAIL"));
-    else
-#endif
-#ifndef NO_CUSERID
-	strcat(spool_path, cuserid(NULL));
-#else
+    } else {
+#endif /* GETENV_MAIL */
+
+#ifdef HAVE_GETPWUID
+	pw = getpwuid(getuid());
+	strcat(spool_path, pw->pw_name);
+#elif defined(NO_CUSERID)
 	strcat(spool_path, getenv("USER"));
-#endif
+#else
+	strcat(spool_path, (char *)cuserid(NULL));
+#endif /* NO_CUSERID && HAVE_GETPWUID */
+
+#ifdef GETENV_MAIL
+    }
+#endif /* GETENV_MAIL */
+
 #endif /* !YOUBIN */
 
 #ifdef XI18N
@@ -646,7 +673,7 @@
 	    fprintf(stderr, "		[-server host]\n");
 	    fprintf(stderr, "		[-nopreserve]\n");
 #endif
-#ifdef SUN_AUDIO
+#if (defined(SUN_AUDIO) || defined(BSD_AUDIO))
 	    fprintf(stderr, "		[-sndfile audio_file]\n");
 	    fprintf(stderr, "		[-volume percentage]\n");
 #endif
@@ -775,7 +802,7 @@
     /* Interval timer start	 */
 #ifndef YOUBIN
     polling_id = XtAppAddTimeOut(app_con,
-				 (unsigned long) polling_time, Polling, NULL);
+				 (unsigned long) polling_time, (XtTimerCallbackProc) Polling, NULL);
 #else  /* YOUBIN */
     if (server == NULL) {
 	gethostname(serv_name, sizeof(serv_name));
@@ -931,7 +958,7 @@
 		PopupMailHeader(mail_header);
 	    XSync(XtDisplay(toplevel), 0);
 	    if (bell == True)
-		beep(XtDisplay(toplevel), 0);
+		beep(XtDisplay(toplevel));
 	    /*	XBell(XtDisplay(toplevel), 0); */
 	}
 	else if (file_stat.st_size > mail_size) {
@@ -955,7 +982,8 @@
 		PopupMailHeader(mail_header);
 	    XSync(XtDisplay(toplevel), 0);
 	    if (bell == True)
-		XBell(XtDisplay(toplevel), 0);
+		beep(XtDisplay(toplevel));
+	    /*	XBell(XtDisplay(toplevel), 0); */
 	}
 	else {
 	    mail_size = file_stat.st_size;
@@ -982,7 +1010,7 @@
     /* No arrive */
 
     polling_id = XtAppAddTimeOut(XtWidgetToApplicationContext(toplevel),
-				 (unsigned long) polling_time, Polling, NULL);
+				 (unsigned long) polling_time, (XtTimerCallbackProc) Polling, NULL);
 
 }
 #endif /* !YOUBIN */
@@ -1071,7 +1099,7 @@
     if (popdown == True) {
 	popdown_button = XtCreateManagedWidget("popdown_button", commandWidgetClass, info_base, NULL,
 					       ZERO);
-	XtAddCallback(popdown_button, XtNcallback, BreakPopup, (XtPointer) NULL);
+	XtAddCallback(popdown_button, XtNcallback, (XtCallbackProc) BreakPopup, (XtPointer) NULL);
     }
     arg_count = 0;
     XtSetArg(args[arg_count], XtNlabel, head);
@@ -1147,7 +1175,8 @@
 		PopupMailHeader(mail_header);
 	    XSync(XtDisplay(toplevel), 0);
 	    if (bell == True)
-		XBell(XtDisplay(toplevel), 0);
+		beep(XtDisplay(toplevel));
+	    /*	XBell(XtDisplay(toplevel), 0); */
 	}
 	else {
 	    mail_size = file_stat.st_size;
@@ -1169,7 +1198,7 @@
 
     XtRemoveTimeOut(polling_id);
     polling_id = XtAppAddTimeOut(XtWidgetToApplicationContext(toplevel),
-				 (unsigned long) polling_time, Polling, NULL);
+				 (unsigned long) polling_time, (XtTimerCallbackProc) Polling, NULL);
 }
 #endif /* !YOUBIN */
 
@@ -1749,13 +1778,22 @@
 static void beep (display)
     Display *display; 
 {
-#ifdef SUN_AUDIO
+#if defined(SUN_AUDIO) || defined(BSD_AUDIO)
     int		audiofd, filefd;
-    int		rn, wn, len;
+    int		rn;
+#ifdef SUN_AUDIO
+    int		wn, len;
     unsigned char	buf[256];
     Audio_filehdr	*au_hdr;
     audio_info_t 	ais;
-
+#elif defined(BSD_AUDIO)
+    int mixerfd, mixerid, supported;
+    static int bsize;
+    static char *buf;
+    struct stat sbuf;
+    int level, level_tmp;
+#endif
+	
     if (mail_sndfile) {
 	audiofd = open( "/dev/audio", O_WRONLY | O_NDELAY ); 
 	if (audiofd < 0)
@@ -1766,6 +1804,7 @@
 		return;
 	    }
 
+#ifdef SUN_AUDIO
 	if( ioctl( audiofd, AUDIO_GETINFO, &ais ) )
 	    {
 		fprintf(stderr, "%s: Problem retrieving /dev/audio info.\n",
@@ -1782,6 +1821,24 @@
 	    return;
 	}
 
+#elif defined(BSD_AUDIO)
+	/* Open the mixer device */
+	mixerfd = open ("/dev/mixer", O_RDWR, 0);
+	if (mixerfd > 0)
+	    {
+		if (volume > MAX_SOUND_VOL)
+			volume = MAX_SOUND_VOL;
+		else if (volume < MIN_SOUND_VOL)
+			volume = MIN_SOUND_VOL;
+		mixerid = SOUND_MIXER_PCM;
+		    /* storing volume level */
+		ioctl(mixerfd,MIXER_READ(mixerid),&level_tmp);
+
+		level = (volume << 8) | volume;
+		ioctl(mixerfd,MIXER_WRITE(mixerid),&level);
+	}
+#endif
+
 	filefd = open(mail_sndfile, O_RDONLY);
 	if (filefd < 0)
 	    {
@@ -1791,6 +1848,7 @@
 		return;
 	    }
 
+#ifdef SUN_AUDIO
 	/* Read in the audio header */
 	rn = read(filefd, buf, sizeof(Audio_filehdr)); 
 
@@ -1841,12 +1899,28 @@
 		    usleep(1000);
 		}
 	    }
-	close(audiofd);
+#elif defined(BSD_AUDIO)
+	ioctl(audiofd, SNDCTL_DSP_RESET, 0);
+	fstat(filefd, &sbuf);
+	bsize = sbuf.st_size;
+	buf = malloc((u_int)bsize);
+	if ( (rn = read(filefd, buf, bsize)) > 0)
+	    write(audiofd, buf, rn);
+	ioctl(audiofd, SNDCTL_DSP_SYNC, 0);
+	free(buf);
+	if (mixerfd > 0)
+	    {
+		    /* restoring volume level */
+		ioctl(mixerfd,MIXER_WRITE(mixerid),&level_tmp);
+		close(mixerfd);
+	    }
+#endif
+	close(audiofd); 
 	close(filefd);
     }
     else
-    XBell (display, volume);
-#else  /* !SUN_AUDIO */
+    XBell (display, 0);
+#else  /* !SUN_AUDIO && !BSD_AUDIO */
     XBell (display, 0);
 #endif /* SUN_AUDIO */
     return;
@@ -1917,12 +1991,12 @@
 
 		if (popup_time)
 		    XtAppAddTimeOut(XtWidgetToApplicationContext(toplevel),
-				    (unsigned long) popup_time, BreakPopup, NULL);
+				    (unsigned long) popup_time, (XtTimerCallbackProc) BreakPopup, NULL);
 	    }
 	}
 	XSync(XtDisplay(toplevel), 0);
 	if (bell == True) {
-	    beep(XtDisplay(toplevel), 0);
+	    beep(XtDisplay(toplevel));
 	}
     } else if (mail_size < saved_mail_size){
 	/* No mail */
@@ -2031,7 +2105,7 @@
 	    }
 	    if (popup_time)
 		XtAppAddTimeOut(XtWidgetToApplicationContext(toplevel),
-				(unsigned long) popup_time, BreakPopup, NULL);
+				(unsigned long) popup_time, (XtTimerCallbackProc) BreakPopup, NULL);
 	}
 	if (raise == True) {
 	    XRaiseWindow(XtDisplay(toplevel), XtWindow(toplevel));