Last modified: Thursday, July 02, 2026

xpbiff-1.27-with-YOUBIN.tar.gzに適用するパッチ

xpbiff, youbin3, FreeBSD, Solaris, SPARC, amd64, 64bit

xpbiffはX11環境でメール着信を通知するxbiffの機能拡張版で, 着信を知らせるだけでなく,差出人やサブジェクトといった情報をポップアップウィンドウで表示する機能を備えます.

また、Youbinプロトコルはメールの着信をクライアントがポーリングするのではなく, サーバからプッシュ通知することを目的としたプロトコルです.

xpbiff-1.27-with-YOUBIN.tar.gzはxpbiffをYoubinプロトコルに対応させたものです.

xpbiff-1.27-with-YOUBIN.tar.gzの配布物にこのパッチを適用することで,以下の点が拡張・修正されます.

xpbiff-1.27-with-YOUBIN3.patch (2008/07/30)



diff -u -r -N xpbiff/Imakefile xpbiff-new/Imakefile
--- xpbiff/Imakefile	1994-10-24 16:06:53.000000000 +0900
+++ xpbiff-new/Imakefile	2003-09-25 11:22:43.000000000 +0900
@@ -49,8 +49,8 @@
 #endif
 
 #ifdef SOLARIS
-   UCBLIBDIR = UcbLibDir
-   UCBLIB = -lucb -lelf
+   UCBLIBDIR = $(UcbLibDir)
+   UCBLIB = -lelf
 #endif
 
        INCLUDES = -I$(TOP)/X11 -I$(AUDIOINCDIR)
diff -u -r -N xpbiff/LocPixmap.c xpbiff-new/LocPixmap.c
--- xpbiff/LocPixmap.c	1994-10-25 09:46:23.000000000 +0900
+++ xpbiff-new/LocPixmap.c	2003-09-24 20:29:17.000000000 +0900
@@ -197,6 +197,7 @@
 	}
 
         /* this if-clause is redundant, but necessary to avoid bus error */
+	attributes.valuemask=0L;
 	if (pixmap == NULL && i!=2 && i!=4 &&
 	    XpmReadFileToPixmap (dpy, root, fn,
 				 &pixmap, &pixmap_mask, &attributes)!= XpmSuccess)
diff -u -r -N xpbiff/config.h xpbiff-new/config.h
--- xpbiff/config.h	1994-10-19 14:56:25.000000000 +0900
+++ xpbiff-new/config.h	2003-09-25 11:43:18.000000000 +0900
@@ -8,7 +8,7 @@
 /*
  *	For X11R6
  */
-#undef X11R6
+#define X11R6
 
 /*
  *	For System V
@@ -19,7 +19,7 @@
  *	For Solaris
  */
 #undef SOLARIS
-#undef UcbLibDir	-L/usr/ucblib
+/* #define UcbLibDir	-L/usr/ucblib */
 
 /*
  *	For slow work station
@@ -42,7 +42,7 @@
  *	For Shape Extension
  */
 
-#undef SHAPE
+#define SHAPE
 
 /*
  *	Check Environment Variable MAIL for check file
@@ -52,45 +52,49 @@
 /*
  *	Set Local Spool pathname
  */
-#undef SPOOLPATH	"/usr/mail"
+#define SPOOLPATH	"/var/mail"
 
 /*
  *	For X pixmap
  */
-#undef XPM
-#undef DepXpmLib	/usr/local/lib/libXpm.a
+#define XPM
+/* #define DepXpmLib	/usr/local/lib/libXpm.a*/
 
 /*
  *	For using I18N Xaw
  */
-#undef XI18N
+#define XI18N
 /* If you use X11R6, these settings below are not necessary */
+/*
 #undef DepXawLib	/usr/local/lib/I18N/libXaw.a
 #undef DepXwcharLib	/usr/local/lib/I18N/libXwchar.a
 #undef Xi18nLibDir	-L/usr/local/lib/I18N \
 			-L/usr/local/lib
 #undef Xi18nIncDir	-I/usr/local/X11/include
+*/
 
 /*
  *	Convert JIS to Japanese EUC
  */
-#undef JCONVERT
+#define JCONVERT
 #undef GUESS_JIS
 
 /*
  *	Process MIME header, charset=ISO-2022-JP, base 64 encoding
  */
-#undef ISO_2022_JP
+#define ISO_2022_JP
 
 /*
  *	For SUN Audio
  */
 #undef SUN_AUDIO
-#undef AudioIncDir /usr/demo/SOUND
+/* #undef AudioIncDir /usr/demo/SOUND */
 
 /* 
  * For YOUBIN Service
 */
-#undef YOUBIN
-#undef YoubinBinDir /usr/local/bin
-#undef YOUBIN_DEFAULT_SERVER_HOST "server"
+#define YOUBIN
+#define YOUBIN3
+#define YoubinBinDir /usr/local/bin
+#define YOUBIN_PROG_NAME	"youbin3"
+#define YOUBIN_DEFAULT_SERVER_HOST "pop"
diff -u -r -N xpbiff/patchlevel.h xpbiff-new/patchlevel.h
--- xpbiff/patchlevel.h	1993-10-25 11:20:17.000000000 +0900
+++ xpbiff-new/patchlevel.h	2007-03-23 18:22:42.000000000 +0900
@@ -1,5 +1,5 @@
 
-#define PATCHLEVEL 0
+#define PATCHLEVEL 1
 
 
 
diff -u -r -N xpbiff/xpbiff.c xpbiff-new/xpbiff.c
--- xpbiff/xpbiff.c	1994-10-27 15:42:52.000000000 +0900
+++ xpbiff-new/xpbiff.c	2008-07-30 12:54:01.000000000 +0900
@@ -115,7 +115,10 @@
 
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <sys/uio.h>
 #include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
 #include <math.h>
 
 #ifdef YOUBIN
@@ -130,6 +133,12 @@
 #include <ctype.h>			/* For isspace() */
 #include <sys/param.h>
 #include <sys/signal.h>
+#include <signal.h>
+#ifdef __FreeBSD__
+#ifndef SIGCLD
+#define SIGCLD SIGCHLD
+#endif
+#endif
 
 #include <errno.h>
 #endif /* YOUBIN */
@@ -157,7 +166,11 @@
 
 #else /* YOUBIN */
 
+#ifdef YOUBIN_PROG_NAME
+#define CHILD_PROGRAM_NAME	YOUBIN_PROG_NAME
+#else
 #define CHILD_PROGRAM_NAME	"youbin"
+#endif
 #define MESS_LEN            	256             /* Max message length. */
 #define HEADER_LEN      	(MESS_LEN + (80 * (3 + 7)))
 
@@ -182,14 +195,14 @@
 %<{subject}\nSubject: %{subject}%>' -file"
 #endif
 
-XtCallbackProc	quit();
+XtCallbackProc	quit(Widget w, XEvent *event, String *params, Cardinal *nparams);
 void		redraw_window();
 #ifdef SHAPE
 void		shape_window();
 #endif
-XtCallbackProc	redraw_callback();
-XtCallbackProc	BreakPopup();
-XtCallbackProc	popup_again();
+XtCallbackProc redraw_callback(Widget w, XEvent *event, String *params, Cardinal *nparams);
+XtCallbackProc	BreakPopup(Widget w, XtPointer client_data, XtPointer call_data);
+XtCallbackProc	popup_again(Widget widget, caddr_t client_data, caddr_t call_data);
 void		PopupMailHeader();
 void		AnimateBiff();
 
@@ -244,9 +257,36 @@
 char            *prog_name;                     /* This program name. */
 char            child_process[MAXPATHLEN + 1];
 static int exit_hundler();
+static void sig_cld();
+
+/* 
+ * Compatibility of non-blocking wait.
+ *
+ * USE_POSIX_WAIT:  waitpid() is available.
+ * Otherwise:       BSD's wait3() available.
+ */
+
+#ifdef _POSIX_SOURCE
+#define USE_POSIX_WAIT
+#endif
+
+#if (defined(SYSV) || defined(sun)) && !defined(USE_POSIX_WAIT)
+#define USE_POSIX_WAIT
+#endif
+
+#if defined(USE_POSIX_WAIT)
+#include <sys/types.h>                  /* For waitpid(). */
+#define WAITPID(pid, status, options)   waitpid((pid), (status), (options))
+#else /* !defined(USE_POSIX_WAIT) */
+/* Note, the first argument of waitpid() which means pid is is always -1. */
+#define WAITPID(pid, status, options)   wait3((status), (options), NULL)
+#endif /* !defined(USE_POSIX_WAIT) */
+
+#include <sys/wait.h>                   /* For wait3(). */
 
 #endif /* YOUBIN */
 
+
 /*
  * widget tree:
  * 
@@ -257,11 +297,8 @@
 
 GC		gcArrive, gcNo, gcAnimate, gcAnimateBack;
 #ifdef XPM
-Pixmap		arrivePixmaps[2], noPixmaps[2];
 #define arrivePixmap	arrivePixmaps[0]
 #define noPixmap	noPixmaps[0]
-#else
-Pixmap		arrivePixmap, noPixmap;
 #endif
 Pixmap		workPixmap;
 int		width, height;
@@ -271,19 +308,10 @@
 #ifndef YOUBIN
 XtIntervalId	polling_id;
 #endif
-Pixel		colors[4];
 #ifndef YOUBIN
 char		spool_path[100];
-int		polling_time;
 #endif
-int		popup_time;
 
-Boolean		raise;
-Boolean		stay_raised;
-Boolean		animate;
-Boolean		popup;
-Boolean		bell;
-Boolean		popdown;
 
 unsigned int	Arrive_pixmap_width, Arrive_pixmap_height;
 unsigned int	Arrive_pixmap_depth;
@@ -291,26 +319,6 @@
 unsigned int	No_pixmap_width, No_pixmap_height;
 unsigned int	No_pixmap_depth;
 
-Boolean		mono;
-String		popupGeometry;
-
-#ifndef YOUBIN
-String		prefers;
-
-String		spoolPath;
-#endif
-
-#ifdef MHSCAN
-Boolean		mhscan;
-String		scanCommand;
-String		scanCommandPath;
-#endif
-
-#ifdef SHAPE
-Boolean		shape;
-Pixmap		noPixmapMask, arrivePixmapMask;
-#endif
-
 static String		fallback_resources[] = {
     "*info_base.hSpace: 0",
     "*info_base.vSpace: 0",
@@ -324,86 +332,122 @@
     NULL
 };
 
-#ifdef SUN_AUDIO
-String mail_sndfile;
-int volume;
+#ifdef YOUBIN
+XtIntervalId	timeout_id;
 #endif
 
+typedef struct _appRes {
+#ifdef XPM
+    Pixmap		arrivePixmaps[2], noPixmaps[2];
+#else 
+    Pixmap		arrivePixmap, noPixmap;
+#endif /* Def: XPM */
+    Pixel		colors[4];
+#ifndef YOUBIN
+    int			polling_time;
+    String		prefers;
+    String		spoolPath;
+#endif /* Not def: YOUBIN */
+    Boolean		mono;
+    String		popupGeometry;
+    int			popup_time;
+    Boolean		xpraise;
+    Boolean		stay_raised;
+    Boolean		animate;
+    Boolean		popup;
+    Boolean		bell;
+    Boolean		popdown;
 #ifdef YOUBIN
-Boolean		use_pipe;
-String		server;
-Boolean		preserve;
-XtIntervalId	timeout_id;
+    Boolean		use_pipe;
+    String		server;
+    Boolean		preserve;
 #endif
+#ifdef MHSCAN
+    Boolean		mhscan;
+    String		scanCommand;
+    String		scanCommandPath;
+#endif
+#ifdef SHAPE
+    Boolean		shape;
+    Pixmap		noPixmapMask, arrivePixmapMask;
+#endif
+#ifdef SUN_AUDIO
+    String		mail_sndfile;
+    int			volume;
+#endif
+} AppResourcesRec, *AppResources;
 
+static AppResourcesRec appResources; /* application specific resources */
+
+#define offset(f) XtOffset(struct _appRes *, f)
 static XtResource	resources[] = {
     {"arrivePixmap", "ArrivePixmap", RPixmap2, sizeof(Pixmap2),
-	 (Cardinal)&arrivePixmap, XtRString, "None"},
+     offset(arrivePixmap), XtRString, "None"},
     {"nomailPixmap", "NomailPixmap", RPixmap2, sizeof(Pixmap2),
-	 (Cardinal)&noPixmap, XtRString, "None"},
+     offset(noPixmap), XtRString, "None"},
     {"nomailForeground", "NomailForeground", XtRPixel, sizeof(Pixel),
-	 (Cardinal)&colors[0], XtRString, "black"},
+     offset(colors[0]), XtRString, "black"},
     {"nomailBackground", "NomailBackground", XtRPixel, sizeof(Pixel),
-	 (Cardinal)&colors[1], XtRString, "cyan"},
+     offset(colors[1]), XtRString, "cyan"},
     {"arriveForeground", "ArriveForeground", XtRPixel, sizeof(Pixel),
-	 (Cardinal)&colors[2], XtRString, "yellow"},
+     offset(colors[2]), XtRString, "yellow"},
     {"arriveBackground", "ArriveBackground", XtRPixel, sizeof(Pixel),
-	 (Cardinal)&colors[3], XtRString, "red"},
+     offset(colors[3]), XtRString, "red"},
 #ifndef YOUBIN
     {"pollingTime", "PollingTime", XtRInt, sizeof(int),
-	 (Cardinal)&polling_time, XtRImmediate, (XtPointer)15000},
+     offset(polling_time), XtRImmediate, (XtPointer)15000},
     {"prefer", "Prefer", XtRString, sizeof(String),
-	 (Cardinal)&prefers, XtRString, (XtPointer)"From Subject"},
+     offset(prefers), XtRString, (XtPointer)"From Subject"},
     {"spoolPath", "SpoolPath", XtRString, sizeof(String),
-	 (Cardinal)&spoolPath, XtRString, None},
+     offset(spoolPath), XtRString, None},
 #endif
     {"mono", "Mono", XtRBoolean, sizeof(Boolean),
-	 (Cardinal)&mono, XtRImmediate, (XtPointer)False},
+     offset(mono), XtRImmediate, (XtPointer)False},
     {"popupGeometry", "PopupGeometry", XtRString, sizeof(String),
-	 (Cardinal)&popupGeometry, XtRString, NULL},
-    {"raise", "Raise", XtRBoolean, sizeof(Boolean),
-	 (Cardinal)&raise, XtRImmediate, (XtPointer)True},
+     offset(popupGeometry), XtRString, NULL},
+    {"xpraise", "Raise", XtRBoolean, sizeof(Boolean),
+     offset(xpraise), XtRImmediate, (XtPointer)True},
     {"stayRaised", "StayRaised", XtRBoolean, sizeof(Boolean),
-	 (Cardinal)&stay_raised, XtRImmediate, (XtPointer)False},
+     offset(stay_raised), XtRImmediate, (XtPointer)False},
     {"animate", "Animate", XtRBoolean, sizeof(Boolean),
-	 (Cardinal)&animate, XtRImmediate, (XtPointer)True},
+     offset(animate), XtRImmediate, (XtPointer)True},
     {"popup", "Popup", XtRBoolean, sizeof(Boolean),
-	 (Cardinal)&popup, XtRImmediate, (XtPointer)True},
+     offset(popup), XtRImmediate, (XtPointer)True},
     {"popupTime", "PopupTime", XtRInt, sizeof(int),
-     (Cardinal)&popup_time, XtRImmediate, (XtPointer)15000},
+     offset(popup_time), XtRImmediate, (XtPointer)15000},
     {"bell", "Bell", XtRBoolean, sizeof(Boolean),
-	 (Cardinal)&bell, XtRImmediate, (XtPointer)True},
+     offset(bell), XtRImmediate, (XtPointer)True},
     {"popdown", "Popdown", XtRBoolean, sizeof(Boolean),
-	 (Cardinal)&popdown, XtRImmediate, (XtPointer)True},
+     offset(popdown), XtRImmediate, (XtPointer)True},
 #ifdef YOUBIN
     {"pipe", "Pipe", XtRBoolean, sizeof(Boolean),
-     (Cardinal)&use_pipe, XtRString, "false"},
+     offset(use_pipe), XtRString, "false"},
     {"server", "Server", XtRString, sizeof(String),
-	(Cardinal)&server, XtRString, YOUBIN_DEFAULT_SERVER_HOST},
+     offset(server), XtRString, YOUBIN_DEFAULT_SERVER_HOST},
     {"preserve", "preserve", XtRBoolean, sizeof(Boolean),
-	(Cardinal)&preserve, XtRString, "true"},
+     offset(preserve), XtRString, "true"},
 #endif
 #ifdef MHSCAN
     {"mhscan", "Mhscan", XtRBoolean, sizeof(Boolean),
-	 (Cardinal)&mhscan, XtRImmediate, (XtPointer)False},
+     offset(mhscan), XtRImmediate, (XtPointer)False},
     {"scanCommand", "ScanCommand", XtRString, sizeof(String),
-	 (Cardinal)&scanCommand, XtRString, DEFAULT_SCAN_COMMAND},
+     offset(scanCommand), XtRString, DEFAULT_SCAN_COMMAND},
     {"scanCommandPath", "ScanCommandPath", XtRString, sizeof(String),
-	 (Cardinal)&scanCommandPath, XtRString, DEFAULT_SCAN_COMMAND_PATH},
+     offset(scanCommandPath), XtRString, DEFAULT_SCAN_COMMAND_PATH},
 #endif
 #ifdef SHAPE
     {"shape", "Shape", XtRBoolean, sizeof(Boolean),
-	 (Cardinal)&shape, XtRImmediate, (XtPointer)False},
+     offset(shape), XtRImmediate, (XtPointer)False},
     {"arrivePixmapMask", "ArrivePixmapMask", XtRBitmap, sizeof(Pixmap),
-	 (Cardinal)&arrivePixmapMask, XtRBitmap, None},
+     offset(arrivePixmapMask), XtRBitmap, None},
     {"nomailPixmapMask", "NomailPixmapMask", XtRBitmap, sizeof(Pixmap),
-	 (Cardinal)&noPixmapMask, XtRBitmap, None},
+     offset(noPixmapMask), XtRBitmap, None},
 #endif
 #ifdef SUN_AUDIO
     {"mailSndFile", "MailSndFile", XtRString, sizeof(String),
-     (Cardinal)&mail_sndfile, XtRString, None},
+     offset(mail_sndfile), XtRString, None},
     {"volume", "Volume", XtRInt, sizeof(int),
-     (Cardinal)&volume, XtRString, "33"},
+     offset(volume), XtRString, "33"},
 #endif    
 };
 
@@ -461,6 +505,7 @@
 #ifdef JCONVERT
 static Locale_ent	locale_list[] = {
     {"ja_JP.EUC",	EUC},
+    {"ja_JP.eucJP",     EUC},
     {"ja_JP.SJIS",	SJIS},
     {"ja_JP.jis7",	JIS},
     {"ja_JP.jis8",	JIS},
@@ -659,12 +704,12 @@
 		      convertArgs, XtNumber(convertArgs));
 #endif
 
-    XtGetApplicationResources(toplevel, (caddr_t) NULL,
+    XtGetApplicationResources(toplevel, (XtPointer)&appResources,
 			      resources, XtNumber(resources), NULL, 0);
 
-    if (mono == True) {
-	colors[0] = colors[3] = BlackPixelOfScreen(XtScreen(toplevel));
-	colors[1] = colors[2] = WhitePixelOfScreen(XtScreen(toplevel));
+    if (appResources.mono == True) {
+	appResources.colors[0] = appResources.colors[3] = BlackPixelOfScreen(XtScreen(toplevel));
+	appResources.colors[1] = appResources.colors[2] = WhitePixelOfScreen(XtScreen(toplevel));
     }
 
 #ifndef YOUBIN
@@ -672,20 +717,20 @@
 #endif
 
 #ifdef XPM
-    if (arrivePixmapMask == None)
-	arrivePixmapMask = arrivePixmaps[1];
-    if (noPixmapMask == None)
-	noPixmapMask = noPixmaps[1];
+    if (appResources.arrivePixmapMask == None)
+	appResources.arrivePixmapMask = appResources.arrivePixmaps[1];
+    if (appResources.noPixmapMask == None)
+	appResources.noPixmapMask = appResources.noPixmaps[1];
 #endif
 
 #ifdef SHAPE
-    if (shape == True
+    if (appResources.shape == True
        && !XShapeQueryExtension(XtDisplay(toplevel), &dummy, &dummy))
-	shape = False;
+	appResources.shape = False;
 #endif
 
-    if (noPixmap == None) {
-	noPixmap = XCreatePixmapFromBitmapData
+    if (appResources.noPixmap == None) {
+	appResources.noPixmap = XCreatePixmapFromBitmapData
 	    (XtDisplay(toplevel), RootWindowOfScreen(XtScreen(toplevel)),
 	     no_bits, no_width, no_height, 1, 0, 1);
 	No_pixmap_width = no_width;
@@ -695,14 +740,14 @@
     else {
 	Window r;
 	unsigned int x, y, bw;
-	XGetGeometry(XtDisplay(toplevel), noPixmap,
+	XGetGeometry(XtDisplay(toplevel), appResources.noPixmap,
 		     &r, &x, &y,
 		     &No_pixmap_width, &No_pixmap_height,
 		     &bw, &No_pixmap_depth);
     }
 
-    if (arrivePixmap == None) {
-	arrivePixmap = XCreatePixmapFromBitmapData
+    if (appResources.arrivePixmap == None) {
+	appResources.arrivePixmap = XCreatePixmapFromBitmapData
 	    (XtDisplay(toplevel), RootWindowOfScreen(XtScreen(toplevel)),
 	     arrive_bits, arrive_width, arrive_height,
 	     1, 0, 1);
@@ -713,7 +758,7 @@
     else {
 	Window r;
 	unsigned int x, y, bw;
-	XGetGeometry(XtDisplay(toplevel), arrivePixmap,
+	XGetGeometry(XtDisplay(toplevel), appResources.arrivePixmap,
 		     &r, &x, &y,
 		     &Arrive_pixmap_width, &Arrive_pixmap_height,
 		     &bw, &Arrive_pixmap_depth);
@@ -741,14 +786,14 @@
 
     /* Get graphic context	 */
 
-    values.foreground	= colors[0];
-    values.background	= colors[1];
+    values.foreground	= appResources.colors[0];
+    values.background	= appResources.colors[1];
     values.graphics_exposures = False;
     gcNo = XtGetGC(toplevel,
 		   GCForeground | GCBackground | GCGraphicsExposures,
 		   &values);
-    values.foreground	= colors[2];
-    values.background	= colors[3];
+    values.foreground	= appResources.colors[2];
+    values.background	= appResources.colors[3];
     values.graphics_exposures = False;
     gcArrive = XtGetGC(toplevel,
 		       GCForeground | GCBackground | GCGraphicsExposures,
@@ -760,13 +805,13 @@
 			       Arrive_pixmap_width, Arrive_pixmap_height,
 			       DefaultDepthOfScreen(XtScreen(toplevel)));
 
-    values.foreground	= colors[2];
+    values.foreground	= appResources.colors[2];
     values.graphics_exposures = False;
     gcAnimate = XtGetGC(toplevel,
 			GCForeground | GCGraphicsExposures,
 			&values);
 
-    values.foreground	= colors[3];
+    values.foreground	= appResources.colors[3];
     values.graphics_exposures = False;
     gcAnimateBack = XtGetGC(toplevel,
 			    GCForeground | GCGraphicsExposures,
@@ -777,9 +822,9 @@
     polling_id = XtAppAddTimeOut(app_con,
 				 (unsigned long) polling_time, Polling, NULL);
 #else  /* YOUBIN */
-    if (server == NULL) {
+    if (appResources.server == NULL) {
 	gethostname(serv_name, sizeof(serv_name));
-	server = serv_name;
+	appResources.server = serv_name;
     }
 
     /* make new process group */
@@ -789,9 +834,15 @@
 	    exit(EXIT_FAILURE);
 	}
 
-    if (use_pipe == False) {
+    if (appResources.use_pipe == False) {
+        signal(SIGCLD, sig_cld);
+#ifdef YOUBIN3
+        sprintf(child_process, "%s/%s -o5 -b From:,Subject: -s %s",
+		BINDIR, CHILD_PROGRAM_NAME, appResources.server);
+#else
 	sprintf(child_process, "%s/%s -b -s %s",
 		BINDIR, CHILD_PROGRAM_NAME, server);
+#endif
 	if ((pfile = popen(child_process, "r")) == NULL) {
 	    perror("popen");
 	    exit(EXIT_FAILURE);
@@ -831,21 +882,21 @@
 {
     if (current_status == ARRIVE) {
 	if (Arrive_pixmap_depth == 1)
-	    XCopyPlane(XtDisplay(toplevel), arrivePixmap, XtWindow(biff),
+	    XCopyPlane(XtDisplay(toplevel), appResources.arrivePixmap, XtWindow(biff),
 		       gcArrive,
 		       0, 0, Arrive_pixmap_width, Arrive_pixmap_height, 0, 0, 1);
 	else
-	    XCopyArea(XtDisplay(toplevel), arrivePixmap, XtWindow(biff),
+	    XCopyArea(XtDisplay(toplevel), appResources.arrivePixmap, XtWindow(biff),
 		      gcArrive,
 		      0, 0, Arrive_pixmap_width, Arrive_pixmap_height, 0, 0);
     }
     else {
 	if (No_pixmap_depth == 1)
-	    XCopyPlane(XtDisplay(toplevel), noPixmap, XtWindow(biff),
+	    XCopyPlane(XtDisplay(toplevel), appResources.noPixmap, XtWindow(biff),
 		       gcNo,
 		       0, 0, No_pixmap_width, No_pixmap_height, 0, 0, 1);
 	else
-	    XCopyArea(XtDisplay(toplevel), noPixmap, XtWindow(biff),
+	    XCopyArea(XtDisplay(toplevel), appResources.noPixmap, XtWindow(biff),
 		      gcNo, 0, 0, No_pixmap_width, No_pixmap_height, 0, 0);
     }
 }
@@ -853,9 +904,9 @@
 #ifdef SHAPE
 void shape_window()
 {
-    if (shape == True) {
+    if (appResources.shape == True) {
 	if (current_status == ARRIVE) {
-	    if (arrivePixmapMask == None) {
+	    if (appResources.arrivePixmapMask == None) {
 		XRectangle	rect;
 		rect.x = rect.y = 0;
 		rect.width = Arrive_pixmap_width;
@@ -866,11 +917,11 @@
 	    }
 	    else
 		XShapeCombineMask(XtDisplay(toplevel), XtWindow(toplevel),
-				  ShapeBounding, 0, 0, arrivePixmapMask,
+				  ShapeBounding, 0, 0, appResources.arrivePixmapMask,
 				  ShapeSet);
 	}
 	else {
-	    if (noPixmapMask == None) {
+	    if (appResources.noPixmapMask == None) {
 		XRectangle	rect;
 		rect.x = rect.y = 0;
 		rect.width = No_pixmap_width;
@@ -881,7 +932,7 @@
 	    }
 	    else
 		XShapeCombineMask(XtDisplay(toplevel), XtWindow(toplevel),
-				  ShapeBounding, 0, 0, noPixmapMask,
+				  ShapeBounding, 0, 0, appResources.noPixmapMask,
 				  ShapeSet);
 	}
     }
@@ -919,7 +970,7 @@
 		mail_header = GetMailHeader();
 	    XtResizeWidget(toplevel, Arrive_pixmap_width, Arrive_pixmap_height, 1);
 	    XtResizeWidget(biff,  Arrive_pixmap_width, Arrive_pixmap_height, 0);
-	    if (raise == True)
+	    if (xpraise == True)
 		XRaiseWindow(XtDisplay(toplevel), XtWindow(toplevel));
 	    if (animate == True)
 		AnimateBiff();
@@ -943,7 +994,7 @@
 		BreakPopup(toplevel, (XtPointer) NULL, (XtPointer) NULL);
 	    XtResizeWidget(toplevel,  Arrive_pixmap_width, Arrive_pixmap_height, 1);
 	    XtResizeWidget(biff,  Arrive_pixmap_width, Arrive_pixmap_height, 0);
-	    if (raise == True)
+	    if (xpraise == True)
 		XRaiseWindow(XtDisplay(toplevel), XtWindow(toplevel));
 	    if (animate == True)
 		AnimateBiff();
@@ -959,7 +1010,7 @@
 	}
 	else {
 	    mail_size = file_stat.st_size;
-	    if (raise == True && stay_raised == False)
+	    if (xpraise == True && stay_raised == False)
 		XLowerWindow(XtDisplay(toplevel), XtWindow(toplevel));
 	    if (popup == True)
 		BreakPopup(toplevel, (XtPointer) NULL, (XtPointer) NULL);
@@ -974,7 +1025,7 @@
 #ifdef SHAPE
 	    shape_window();
 #endif
-	    if (raise == True && stay_raised == False)
+	    if (xpraise == True && stay_raised == False)
 		XLowerWindow(XtDisplay(toplevel), XtWindow(toplevel));
 	    if (popup == True)
 		BreakPopup(toplevel, (XtPointer) NULL, (XtPointer) NULL);
@@ -995,7 +1046,7 @@
     double	    r, angle, t1, t2, t3, t4;
 
 #ifdef SHAPE
-    if(shape == True) {
+    if(appResources.shape == True) {
 	XRectangle	rect;
 	rect.x = rect.y = 0;
 	rect.width = Arrive_pixmap_width;
@@ -1038,9 +1089,9 @@
 
     /* Create Popup Shell */
 
-    if (popupGeometry != NULL) {
+    if (appResources.popupGeometry != NULL) {
 	arg_count = 0;
-	XtSetArg(args[arg_count], XtNgeometry, popupGeometry);
+	XtSetArg(args[arg_count], XtNgeometry, appResources.popupGeometry);
 	arg_count++;
     }
     else {
@@ -1068,10 +1119,10 @@
     info_base = XtCreateManagedWidget("info_base", boxWidgetClass, header, args,
 				      arg_count);
 
-    if (popdown == True) {
+    if (appResources.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);
@@ -1092,7 +1143,7 @@
     char	*p;
 
 #ifdef MHSCAN
-    if (mhscan && (p = mh_scan()) != NULL)
+    if (appResources.mhscan && (p = mh_scan()) != NULL)
 	return p;
 #endif
     return read_headers();
@@ -1135,7 +1186,7 @@
 		mail_header = GetMailHeader();
 	    XtResizeWidget(toplevel, Arrive_pixmap_width, Arrive_pixmap_height, 1);
 	    XtResizeWidget(biff, Arrive_pixmap_width, Arrive_pixmap_height, 0);
-	    if (raise == True)
+	    if (xpraise == True)
 		XRaiseWindow(XtDisplay(toplevel), XtWindow(toplevel));
 	    if (animate == True)
 		AnimateBiff();
@@ -1155,7 +1206,7 @@
 		mail_header = GetMailHeader();
 	    if (popup == True && showing_header)
 		BreakPopup(toplevel, (XtPointer) NULL, (XtPointer) NULL);
-	    if (raise == True)
+	    if (xpraise == True)
 		XRaiseWindow(XtDisplay(toplevel), XtWindow(toplevel));
 	    redraw_window();
 #ifdef SHAPE
@@ -1422,9 +1473,11 @@
 {
     char	kanji = False, kana = False;
     char	*dst = src;
+    char	*lim;
 
     if (src) {
-	while(*src) {
+	lim = src + strlen(src);
+	while(*src && dst < lim) {
 	    if (*src == 27) {
 		if (*(src+1) == '$' && (*(src+2) == '@' || *(src+2) == 'B')) {
 		    src += 3;
@@ -1469,8 +1522,11 @@
 		*dst++ = (*src++ | 128);
 	    }
 	    else if ((kana == True) || (*src & 128)) {
-		*dst++ = 142;
-		*dst++ = (*src++ | 128);
+		if(dst + 1 < lim) {
+		    *dst++ = 142;
+		    *dst++ = (*src++ | 128);
+		} else
+		    break;
 	    }
 	    else
 		*dst++ = *src++;
@@ -1697,29 +1753,29 @@
 	hbuf = hbufp = NULL;
 	hbuf_size = hbuf_rest = 0;
     }
-    if (scanCommand != NULL && scanCommand[0] != '\0'
+    if (appResources.scanCommand != NULL && appResources.scanCommand[0] != '\0'
 	&& scan_command == NULL) {
 	char*	p;
 	p = scan_command = (char*) malloc(sizeof(spool_path) + 10
-					  + (scanCommandPath != NULL ? strlen(scanCommandPath) : 0)
-					  + strlen(scanCommand));
-	if (scanCommand[0] != '/'
-	    && scanCommandPath != NULL && scanCommandPath[0] != '\0') {
-	    strcpy(p, scanCommandPath);
+					  + (appResources.scanCommandPath != NULL ? strlen(appResources.scanCommandPath) : 0)
+					  + strlen(appResources.scanCommand));
+	if (appResources.scanCommand[0] != '/'
+	    && appResources.scanCommandPath != NULL && appResources.scanCommandPath[0] != '\0') {
+	    strcpy(p, appResources.scanCommandPath);
 	    p += strlen(p) - 1;
 	    if (*p ++ != '/') {
 		*p ++ = '/';
 		*p = '\0';
 	    }
 	}
-	strcat(p, scanCommand);
+	strcat(p, appResources.scanCommand);
 	strcat(p, " ");
 	strcat(p, spool_path);
     }
     else {
-	mhscan = False;
+	appResources.mhscan = False;
     }
-    if (mhscan && (fp = popen(scan_command, "r")) != NULL) {
+    if (appResources.mhscan && (fp = popen(scan_command, "r")) != NULL) {
 	while ((c = getc(fp)) != EOF)
 	    put_in(c);
 	put_in('\0');
@@ -1741,7 +1797,7 @@
 	    return hbuf;
 	}
     }
-    mhscan = False;
+    appResources.mhscan = False;
     return NULL;
 }
 #endif
@@ -1756,7 +1812,7 @@
     Audio_filehdr	*au_hdr;
     audio_info_t 	ais;
 
-    if (mail_sndfile) {
+    if (appResources.mail_sndfile) {
 	audiofd = open( "/dev/audio", O_WRONLY | O_NDELAY ); 
 	if (audiofd < 0)
 	    {
@@ -1774,7 +1830,7 @@
 	    }
 	/* re-initialize */
 	AUDIO_INITINFO(&ais);
-	ais.play.gain = volume;
+	ais.play.gain = appResources.volume;
 	if( ioctl( audiofd, AUDIO_SETINFO, &ais ) ) {
 	    fprintf(stderr, "%s: Problem setting /dev/audio info.\n",
 		    "Mailbox widget");
@@ -1782,11 +1838,11 @@
 	    return;
 	}
 
-	filefd = open(mail_sndfile, O_RDONLY);
+	filefd = open(appResources.mail_sndfile, O_RDONLY);
 	if (filefd < 0)
 	    {
 		fprintf(stderr, "%s: Couldn't play file \"%s\"\n", 
-			"Mailbox widget", mail_sndfile);
+			"Mailbox widget", appResources.mail_sndfile);
 		close(audiofd);
 		return;
 	    }
@@ -1818,7 +1874,7 @@
 		if (rn < 0)
 		    {
 			fprintf(stderr, "%s: Error reading from file \"%s\"\n", 
-				"Mailbox widget", mail_sndfile);
+				"Mailbox widget", appResources.mail_sndfile);
 			close(audiofd);
 			close(filefd);
 			return;
@@ -1845,7 +1901,7 @@
 	close(filefd);
     }
     else
-    XBell (display, volume);
+    XBell (display, appResources.volume);
 #else  /* !SUN_AUDIO */
     XBell (display, 0);
 #endif /* SUN_AUDIO */
@@ -1869,9 +1925,8 @@
     struct stat		file_stat;
     int			len;
     long		date;	/* unused */
-    static char        	buff[HEADER_LEN];
+    static char        	buff[HEADER_LEN+1];
     char		*cp, *cp2;
-    long		strtol();
 
     if ((len = read(*fid, buff, HEADER_LEN)) == 0) {
         /* Erros occurs in child process. */
@@ -1883,12 +1938,12 @@
                 prog_name, child_process);
         exit(EXIT_FAILURE);
     }
-  
+    buff[len] = '\0';
     mail_size = (int)strtol(buff, &cp, 10);
 
     if (mail_size > saved_mail_size) {
 	/* NEW mail */
-	if (popup == True || *cp == ' ') {
+	if (appResources.popup == True || *cp == ' ') {
 	    date = strtol(cp, &cp2, 10);
 	    if (*cp2 == '\0' || isspace(*cp2)) {
 		get_mail_header((*cp2 == '\0') ? NULL : (cp2 + 1));
@@ -1898,30 +1953,31 @@
 	current_status = ARRIVE;
 	XtResizeWidget(toplevel, Arrive_pixmap_width, Arrive_pixmap_height, 1);
 	XtResizeWidget(biff, Arrive_pixmap_width, Arrive_pixmap_height, 0);
-	if (popup == True) {
+	if (appResources.popup == True) {
 	    BreakPopup(toplevel, (XtPointer) NULL, (XtPointer) NULL);
 	}
-	if (raise == True) {
+	if (appResources.xpraise == True) {
 	    XRaiseWindow(XtDisplay(toplevel), XtWindow(toplevel));
 	}
-	if (animate == True && mail_header != NULL) {
+	if (appResources.animate == True && mail_header != NULL) {
 	    AnimateBiff();
 	}
 	redraw_window();
 #ifdef SHAPE
 	shape_window();
 #endif
-	if (popup == True) {
+	if (appResources.popup == True) {
 	    if (mail_header != NULL) {
 		PopupMailHeader(mail_header);
 
-		if (popup_time)
+		if (appResources.popup_time)
 		    XtAppAddTimeOut(XtWidgetToApplicationContext(toplevel),
-				    (unsigned long) popup_time, BreakPopup, NULL);
+				    (unsigned long) appResources.popup_time,
+                                    (XtTimerCallbackProc) BreakPopup, NULL);
 	    }
 	}
 	XSync(XtDisplay(toplevel), 0);
-	if (bell == True) {
+	if (appResources.bell == True) {
 	    beep(XtDisplay(toplevel), 0);
 	}
     } else if (mail_size < saved_mail_size){
@@ -1934,10 +1990,10 @@
 #ifdef SHAPE
 	shape_window();
 #endif
-	if (popup == True) {
+	if (appResources.popup == True) {
 	    BreakPopup(toplevel, (XtPointer) NULL, (XtPointer) NULL);
 	}
-	if (raise == True && stay_raised == False) {
+	if (appResources.xpraise == True && appResources.stay_raised == False) {
 	    XLowerWindow(XtDisplay(toplevel), XtWindow(toplevel));
 	}
 	free(mail_header);
@@ -1957,24 +2013,29 @@
     char	*cp;
     int		header_count = 0;
     char	tmp[HEADER_LEN];
-    char	*strtok();
     char	*new_header;
 
     if (buf == NULL)	return;
     strcpy(tmp, buf);
     cp = strtok(tmp, "\n");
     while(cp != NULL) {
-	if (strncmp("From:", cp, strlen("From:")) == 0) {
+	if (strncmp("From:", cp, 5) == 0) {
 	    from = cp;
+		if (from[strlen(from)-1] == '\r') {
+			from[strlen(from)-1] = '\0';
+		}
 	    header_count++;
-	} else if (strncmp("Subject:", cp, strlen("Subject:")) == 0) {
+	} else if (strncmp("Subject:", cp, 8) == 0) {
 	    subject = cp;
+		if (subject[strlen(subject)-1] == '\r') {
+			subject[strlen(subject)-1] = '\0';
+		}
 	    header_count++;
 	}
 	if (header_count > 1 || *cp == '\0')	break;
 	cp = strtok(NULL, "\n");
     }
-    if (preserve == False) {
+    if (appResources.preserve == False) {
 	free(mail_header);
 	mail_header = NULL;
     }
@@ -2024,16 +2085,17 @@
     if (current_status == ARRIVE) {
 	redraw_window();
 
-	if (popup == True) {
+	if (appResources.popup == True) {
 	    BreakPopup(toplevel, (XtPointer) NULL, (XtPointer) NULL);
 	    if (mail_header != NULL) {
 		PopupMailHeader(mail_header);
 	    }
-	    if (popup_time)
+	    if (appResources.popup_time)
 		XtAppAddTimeOut(XtWidgetToApplicationContext(toplevel),
-				(unsigned long) popup_time, BreakPopup, NULL);
+				(unsigned long) appResources.popup_time,
+                                (XtTimerCallbackProc) BreakPopup, NULL);
 	}
-	if (raise == True) {
+	if (appResources.xpraise == True) {
 	    XRaiseWindow(XtDisplay(toplevel), XtWindow(toplevel));
 	}
 #ifdef SHAPE
@@ -2049,4 +2111,27 @@
 {
     kill(0, SIGTERM);		/* kill all the children */
 }
+
+static void
+sig_cld()
+{
+    pid_t       pid;
+
+#ifdef USE_POSIX_WAIT
+    int         status;
+#elif defined(__FreeBSD__)
+    int         status;
+#else /* not USE_POSIX_WAIT */
+    union wait  status;
+#endif /* not USE_POSIX_WAIT */
+
+    pid = WAITPID(-1, &status, WNOHANG);
+    fprintf(stderr, "%s: Catch signal CLD\n", prog_name);
+
+    if (0 < pid) {
+        exit(EXIT_FAILURE);                 /* Should print child status? */
+    }
+    signal(SIGCLD, sig_cld);
+}
+
 #endif /* YOUBIN */


布目 淳@京都工芸繊維大学コンピュータシステム研究室 (nunome@kit.ac.jp)