[Pkg-wmaker-commits] [wmbiff] 01/14: Initial revision

Doug Torrance dtorrance-guest at moszumanska.debian.org
Thu Aug 20 02:59:54 UTC 2015


This is an automated email from the git hooks/post-receive script.

dtorrance-guest pushed a commit to tag wmbiff_0_3_1
in repository wmbiff.

commit 68c8944462b09c28f521b85c837691589f6711e0
Author: oskuro <oskuro>
Date:   Tue May 1 16:11:37 2001 +0000

    Initial revision
---
 ChangeLog                    | 190 +++++++++++++
 README                       |  88 ++++++
 README.licq                  |  23 ++
 wmbiff/.cvsignore            |   3 +
 wmbiff/Client.h              |  76 ++++++
 wmbiff/Imap4Client.c         | 131 +++++++++
 wmbiff/LicqClient.c          |  94 +++++++
 wmbiff/Makefile              |  70 +++++
 wmbiff/Pop3Client.c          | 240 ++++++++++++++++
 wmbiff/maildirClient.c       | 137 ++++++++++
 wmbiff/mboxClient.c          | 139 ++++++++++
 wmbiff/sample.wmbiffrc       |  68 +++++
 wmbiff/socket.c              |  57 ++++
 wmbiff/wmbiff-master-led.xpm | 118 ++++++++
 wmbiff/wmbiff.1              |  74 +++++
 wmbiff/wmbiff.c              | 631 +++++++++++++++++++++++++++++++++++++++++++
 wmbiff/wmbiffrc.5            | 121 +++++++++
 wmgeneral/list.c             | 169 ++++++++++++
 wmgeneral/list.h             |  59 ++++
 wmgeneral/misc.c             |  37 +++
 wmgeneral/misc.h             |   9 +
 wmgeneral/wmgeneral.c        | 481 +++++++++++++++++++++++++++++++++
 wmgeneral/wmgeneral.h        |  59 ++++
 23 files changed, 3074 insertions(+)

diff --git a/ChangeLog b/ChangeLog
new file mode 100644
index 0000000..8164aab
--- /dev/null
+++ b/ChangeLog
@@ -0,0 +1,190 @@
+wmBiff (0.2q1)
+  * wmbiff/Client.h: move DEBUG_* macros to wmbiff/Makefile
+  * wmbiff/Pop3Client.c:
+    + My password contains an  @  character.  This causes
+      the pop3 line to be incorrectly parsed by wmbiff.
+      * Drop all of the ":" after the pop3 and delimit all values with
+        spaces.  This works well, as passwords/user-id's all agree that
+        the space is a non-legit value.
+         
+        Example: assume my password is:  myEmailhasa at init
+         
+        Old way:
+        path.3=pop3:debian4tux:myEmailhasa at init@mail.telocity.com
+
+        New way:
+        path.3=pop3:debian4tux myEmailhasa at init mail.telcoity.com
+        
+        Ahh...before you say it.  "Backward compatibility?" You will
+        also find in the patch, a NEW function.  So that the OLD and
+        NEW way is easily compatible with all ".wmbiffrc" files.
+        
+        Dev. Comments:
+        This was not the cleanest way to implement it, but I had to
+        suffice with a clean/quick implementation.  I originally wrote
+        one function to handle past and new parsing.  However, I
+        thought it would be beneficial to leave them separated, so we
+        could eventually drop the old method?
+        
+        Related Changes:
+        The man page will need to be updated (not provided in patch).
+        We can weed the "old" style out of the example script as well.
+        Still explaining the changes in the man page to leave out
+        confusion in a users mind (as they are likely to find "old"
+        style scripts).
+    + My mail server at Telocity.com is following the RFC's to
+      a "T".  RFC 1725 states that the LAST command be removed.
+      After some searching I have NOT turned up a replacement.
+      Which does make sense, this command is only so useful,
+      and contributes to the popularity of other such remoting
+      such as LDAP?
+      * I've set the Unread messages to the TotalMessages,
+        assuming (as suggested by the RFC) no messages have been
+        read.  I have also suppressed the error printed to
+        stderr, it is correct to return an error, *now*.  ;)
+
+        The only way to keep track of messages which have been
+        read, is to remember the unique number assigned to them.
+        This is what fetchmail does.  However, it does not work
+        correctly if you check and read mail thru other methods
+        (a web mail client).
+  * wmbiff/wmbiff.c:
+        -       for (index = 0; index < 4; index++)
+        +       for (index = 0; index < 5; index++)
+    
+        BUG!  Last postion #4 was not correctly being checked.
+        Now correctly checks each position.
+
+ -- Mark Hurley <debian4tux at telocity.com>  13 Apr 2001 02:47:10 -0400
+
+
+wmBiff (0.2q)
+  * wmbiff/{*.[ch]}: removed unnecesary includes.
+  * wmbiff/wmbiff.c: some cleanups and optimizations. 
+    + init_biff:
+      * show error if user config file does not exists
+      * use of userconfig "interval" (wasn't correctly parsed)
+    + {do_biff, displayMsgCounters}: some changes to make Sleep_Interval
+      and Blink_Mode local
+    + parse_cmd: some changes to make uconfig_file local
+    + {BlinkOn, BlinkOff, BlinkToogle}: Removed (merged by do_biff)
+    + {ReadConfigString, ReadConfigInt}: Removed 
+    + countmail: removed init in header (wasn't used)
+    + ReadLine: Created (new parsing code, extracts pairs of setting
+      and value)
+    + Read_Config_File: now there is only ONE parse not 36!
+  * wmbiff/{IMap4Client.c, Pop3Client.c}: check for correct format line to 
+    avoid "segmentation fault" while parsing.
+
+ -- Jorge Garc�a <Jorge.Garcia at uv.es>  20-Mar-2001 05:32:35+0100
+
+
+wmBiff (0.2p)
+
+  * Added maildir support!  Yay!
+  * Stole the manpages from Debian.
+  * Massive (lack of) coding style cleanup; Standardized coding style using
+    GNU indent.
+  * Reversed order of ChangeLog as suggested by Jordi.
+  * Cleaned up the v0.2o ChangeLog entry.  What a mess!  Added missing credits.
+  * Cleaned up and reformatted the rest of the changelog to an almost-Debian
+    format while I'm at it.  It's much more readable that way.
+  * Moved definition of WMBIFF_VERSION to the Makefile.
+  * All your base are belong to us.
+  * I'm not maintaining wmBiff; I just submitted a big patch.  Send your
+    complaints (or complements) to Yong-iL Joh.
+  
+ -- Dwayne C. Litzenberger <dlitz at dlitz.net>  12-Mar-2001 -0600
+
+
+wmBiff (0.2o)
+
+  * Jordi Mallach <jordi at sindominio.net>, Debian's wmbiff maintainer, sent
+    me an email a couple of days ago which included a patch with man pages.
+    The patch did the following:
+      + Fixed a major upstream bug that renders this new wmbiff unusable.
+        Thanks to Guillaume Morin, J�r�me Marant and Mark Hurley for their
+        help identifying the bug, and Jorge Garc�a <Jorge.Garcia at uv.es> for
+        writing a patch. Basically, the new upstream broke backwards
+        compatibility of wmbiffrc with Gennady's wmbiff, fixed that.
+        This patch also fixes wmbiff not using $MAIL or defaulting to
+        /var/spool/mail/$USER if no ~/.wmbiffrc is found (closes: #87778).
+      + wmbiff/wmbiff.c: updated WMBIFF_VERSION to current.
+      + wmbiff/{socket.c, wmbiff.c}: removed <sys/time.h> includes.
+      + debian/{wmbiff.1, wmbiffrc.5}: updated for IMAP4 and Licq support.
+      + Jorge Garc�a removed the segfault in Jordi's wmbiffrc
+      + An OpenBSD guy (I don't have the name handy) fixed a potential buffer
+        overflow in init_biff() (The "/* Make labels look right */" section)
+      + Jorge Garc�a <Jorge.Garcia at uv.es> fixed a display bug in the
+        number-of- mails display.
+  * use poll() instead of select()
+
+ -- Yong-iL Joh <tolkien at mizi.com>  12-Mar-2001 +0900
+
+
+wmBiff (0.2n)
+  
+  * Nick Clarey <nclarey at 3glab.com> sent me a patch.
+    that enhances the following:
+      + UW Imap server 2000.283rh
+      + Config file now supports IMAP mailbox "paths" rather than
+        just the mailbox name (e.g. mail/foo/blah)
+
+ -- Yong-iL Joh <tolkien at mizi.com>  20-Feb-2001 +0900
+
+
+wmBiff (0.2m)
+
+  * Imap4Client.c did not close when a connection error occurred.  Fixed it.
+
+ -- Yong-iL Joh <tolkien at mizi.com>  05-Feb-2001 +0900
+  
+
+wmBiff (0.2l)
+  
+  * Imap4Client.c had a bug when trying to connect to an imap4 server.  Fixed
+    it.
+
+ -- Yong-iL Joh <tolkien at mizi.com>  11-Jan-2001 +0900
+
+
+wmBiff (0.2j)  
+
+  * Because I can't contact the author, I jumped to version 0.2j
+  * Added imap4-based mail server check component.
+  * Divided wmbiff.c to wmbiff.c, LicqClient.c mboxClient.c
+
+ -- Yong-iL Joh <tolkien at mizi.com>  01-Jan-2001 +0900
+
+
+wmBiff (0.2-licq)
+
+  * I found it from http://www.licq.org/download.html.
+  
+ -- Yong-iL Joh <tolkien at mizi.com>  No Date
+          
+
+wmBiff (0.2)
+  
+  * POP3 support added with (auto)fetching
+  * digits blinking on new mail arrival
+  * resource wasting lowered
+  * individual rescan interval for differrent mailboxes
+  * some bugfixes
+
+ -- Gennady Belyakov <gb at ccat.elect.ru>  26-Nov-1999
+  
+
+wmBiff (0.1a)
+  
+  * Some fixes with intialization
+
+ -- Gennady Belyakov <gb at ccat.elect.ru>  18-Nov-1999
+
+
+wmBiff (0.1)
+
+  * Initial release
+
+ -- Gennady Belyakov <gb at ccat.elect.ru>  17-Nov-1999
+
diff --git a/README b/README
new file mode 100644
index 0000000..8a2ee56
--- /dev/null
+++ b/README
@@ -0,0 +1,88 @@
+   
+                                  Introducing
+                                       
+   wmBiff is an WindowMaker docking utility, that displays number of
+   total messages count or unread mail messages count in differrent
+   mailboxes.
+
+   Green ( cyan? :) ) digits display total number of messages, if there
+   are no unread messages in it.
+   
+   Yellow digits display number of unread messages, with blinking on new
+   mail arrival, if any.
+   
+   At this moment only unix-style and POP3 mailboxes are supported.
+   wmBiff supports up to 5 mailboxes (but you can start 2 or more
+   wmbiff's with differrent configs).
+   
+   Pressing on a 1st (left) mouse button will execute appropriate mail
+   reader (if defined in config file). Right-clicking will exec mail
+   fetching program (if any).
+   
+   It is also possible to execute user-defined command line on new mail
+   arrival (for example, play .WAV file).
+   
+     _________________________________________________________________
+   
+                          Compiling and Installation
+                                       
+Extract the archive:
+        tar -xvzf wmbiff-0.2.tar.gz
+
+Enter the wmbiff directory and edit the Makefile:
+        cd wmbiff-0.2/
+        vi Makefile
+
+Make the binary:
+        make
+
+Install the binary:
+        make install
+
+This will copy the binary to /usr/local/bin
+
+Then you need to copy sample.wmbiffrc into your home directory as
+.wmbiffrc, correct it as you like. Or, you can use the ``-c'' option
+and specify differrent name of config file.
+ Without any config file wmbiff will use only default mailbox
+(from environment variable MAIL), labeled with word SPOOL, at first
+position. All other positions will be empty.
+     _________________________________________________________________
+   
+                                  Copyrights
+                                       
+   This program was written by Gennady Belyakov [8]gb at ccat.elect.ru
+   
+   Exterior appearance was heavily derived from wminet, written by
+   Dave Clark (clarkd at skynet.ca),
+   Antoine Nulle (warp at xs4all.nl),
+   Martijn Pieterse (pieterse at xs4all.nl)
+   
+   Some code (around mailbox checking, with some modifications) was taken
+   from xled, written by
+   Jan Schoenepauck (schoenep at uni-wuppertal.de) and
+   Joachim Gassen (joachim at fb4-1112.uni-muenster.de)
+   
+   POP3 checking code was taken from wmpop3 by
+   Scott Holden (scotth at thezone.net)
+   
+   Many thanks for:
+   Angus Mackay (amackay at gusnet.cx)
+   Jordi Mallach P�rez (jordi at sindominio.net)
+   Eugene Bobin (gene at utb.ru)
+   Helmut 'Kolbi' Kolb (office at kolbi.net)
+   Vladimir Popov (pva48 at mail.ru)
+   Jorge Garc�a (Jorge.Garcia at uv.es)
+   Nick Clarey (nclarey at 3glab.com)
+   An OpenBSD guy (I don't have the name handy)
+   Dwayne C. Litzenberger (dlitz at dlitz.net)
+   
+     _________________________________________________________________
+   
+   Any suggestions/bug reports please send to
+   
+    Yong-iL Joh tolkien at mizi.com
+    
+    or the original author, Gennady Belyakov gb at ccat.elect.ru, if he
+    reappears.
+
diff --git a/README.licq b/README.licq
new file mode 100644
index 0000000..d668e32
--- /dev/null
+++ b/README.licq
@@ -0,0 +1,23 @@
+wmBiff with ICQ arrival notification
+------------------------------------
+
+This is a version of Gennady Belyakov's wmBiff Window Maker doc app hacked
+to show licq message arrivals.
+
+Motivation:
+Ever found the screen space taken up by licq clients to be too much, but
+don't like to have them beeping when messages are arrived, so you can't put
+them in the background? So did I.
+
+Solution:
+wmBiff with ICQ arrival notification.
+Works alongside licq <http://www.licq.com>, and displays the number of messages
+sitting in a licq history file. When a message arrives, this file is updated,
+so wmBiff flashes and (optionally, if you like that sort of thing) makes noises.
+And, it checks regular mailboxes and pop3 servers for mail!
+
+What more could you wish?
+
+Simply add entries in the .wmbiffrc file with licq: prefixing the path.
+
+Enjoy!
diff --git a/wmbiff/.cvsignore b/wmbiff/.cvsignore
new file mode 100644
index 0000000..6e48425
--- /dev/null
+++ b/wmbiff/.cvsignore
@@ -0,0 +1,3 @@
+*~
+*.o
+wmbiff
diff --git a/wmbiff/Client.h b/wmbiff/Client.h
new file mode 100644
index 0000000..0c8aaa1
--- /dev/null
+++ b/wmbiff/Client.h
@@ -0,0 +1,76 @@
+/* Author : Scott Holden ( scotth at thezone.net )
+   Modified : Yong-iL Joh ( tolkien at mizi.com )
+   Modified : Jorge Garc�a ( Jorge.Garcia at uv.es )
+ *
+ * Email Checker Pop3/Imap4/Licq/mbox/maildir
+ *
+ * Last Updated : Mar 20, 05:32:35 CET 2001     
+ *
+ */
+
+#ifndef CLIENT
+#define CLIENT
+
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+typedef struct _mbox_t *Pop3;
+typedef struct _mbox_t {
+	char label[32];				/* Printed at left; max 5 chars */
+	char path[256];				/* Path to mailbox */
+	char notify[256];			/* Program to notify mail arrivation */
+	char action[256];			/* Action to execute on mouse click */
+	char fetchcmd[256];			/* Action for mail fetching for pop3/imap */
+	int fetchinterval;
+	int TotalMsgs;				/* Total messages in mailbox */
+	int UnreadMsgs;				/* New (unread) messages in mailbox */
+	int OldMsgs;
+	int OldUnreadMsgs;
+	int blink_stat;				/* blink digits flag-counter */
+
+	union {
+		struct {
+			time_t ctime;
+			time_t mtime;
+			size_t size;
+		} mbox;
+		struct {
+			time_t ctime_new;
+			time_t mtime_new;
+			size_t size_new;
+			time_t ctime_cur;
+			time_t mtime_cur;
+			size_t size_cur;
+		} maildir;
+		struct {
+			char password[32];
+			char userName[32];
+			char serverName[256];
+			int serverPort;
+			int localPort;
+		} pop;
+	} u;
+
+	FILE *(*open) (Pop3);
+	int (*checkMail) (Pop3);
+
+	time_t prevtime;
+	time_t prevfetch_time;
+	int loopinterval;			/* loop interval for this mailbox */
+} mbox_t;
+
+#define BUF_SIZE 1024
+
+int sock_connect(char *hostname, int port);
+int pop3Create(Pop3 pc, char *str);
+int imap4Create(Pop3 pc, char *str);
+int licqCreate(Pop3 pc, char *str);
+int mboxCreate(Pop3 pc, char *str);
+int maildirCreate(Pop3 pc, char *str);
+FILE *openMailbox(Pop3 pc);
+int parse_old_pop3_path(Pop3 pc, char *str);
+int parse_new_pop3_path(Pop3 pc, char *str);
+
+#endif
+/* vim:set ts=4: */
diff --git a/wmbiff/Imap4Client.c b/wmbiff/Imap4Client.c
new file mode 100644
index 0000000..f558dd1
--- /dev/null
+++ b/wmbiff/Imap4Client.c
@@ -0,0 +1,131 @@
+/* Author : Yong-iL Joh ( tolkien at mizi.com )
+   Modified: Jorge Garc�a ( Jorge.Garcia at uv.es )
+ * 
+ * Imap4 Email checker.
+ *
+ * Last Updated : Mar 20, 05:32:35 CET 2001
+ *
+ */
+
+#include "Client.h"
+
+#define	PCU	(pc->u).pop
+
+FILE *imap4Login(Pop3 pc)
+{
+	int fd;
+	FILE *f;
+	char buf[BUF_SIZE];
+
+	if ((fd = sock_connect(PCU.serverName, PCU.serverPort)) == -1) {
+		fprintf(stderr, "Not Connected To Server '%s:%d'\n",
+				PCU.serverName, PCU.serverPort);
+		return NULL;
+	}
+
+	f = fdopen(fd, "r+");
+	fgets(buf, BUF_SIZE, f);
+
+	/* Login to the server */
+	fflush(f);
+	fprintf(f, "a001 LOGIN %s %s\r\n", PCU.userName, PCU.password);
+
+	/* Ensure that the buffer is not an informational line */
+	do {
+		fflush(f);
+		fgets(buf, BUF_SIZE, f);
+	}
+	while (buf[0] == '*');
+
+	if (buf[5] != 'O') {		/* Looking for "a001 OK" */
+		fprintf(f, "a002 LOGOUT\r\n");
+		fclose(f);
+		return NULL;
+	};
+
+	return f;
+}
+
+int imap4CheckMail(Pop3 pc)
+{
+	FILE *f;
+	char str[128];
+	char buf[BUF_SIZE];
+
+	f = pc->open(pc);
+	if (f == NULL)
+		return -1;
+
+	fflush(f);
+
+	fprintf(f, "a004 LOGOUT\r\n");
+	fclose(f);
+
+	return 0;
+}
+
+int imap4Create(Pop3 pc, char *str)
+{
+	/* IMAP4 format: imap:user:password at server/mailbox[:port] */
+	/* If 'str' line is badly formatted, wmbiff won't display the mailbox. */
+	char *tmp;
+	char *p;
+
+#ifdef DEBUG_IMAP4
+	printf("imap4: str = '%s'\n", str);
+#endif
+
+	strcpy(PCU.password, "");
+	strcpy(PCU.userName, "");
+	strcpy(PCU.serverName, "");
+	PCU.serverPort = 143;
+
+	tmp = strdup(str);
+
+	/* We start with imap:user:password at server[/mailbox][:port] */
+	p = strtok(tmp, ":");		/* cut off ``imap:'' */
+	/* Now, we have user:password at server[/mailbox][:port] */
+	if ((p = strtok(NULL, ":"))) {	/* p pointed to username */
+		strcpy(PCU.userName, p);
+		/* Now, we have password at server[/mailbox][:port] */
+		if ((p = strtok(NULL, "@"))) {	/* p -> password */
+			strcpy(PCU.password, p);
+			/* Now we have server[/mailbox][:port] */
+			if ((p = strtok(NULL, "/"))) {	/* p -> server */
+				strcpy(PCU.serverName, p);
+				/* It should now be [mailbox][:port] */
+				if ((p = strtok(NULL, ":"))) {	/* p -> mailbox */
+					strcpy(pc->path, p);
+				} else {
+					strcpy(pc->path, "INBOX");
+				}
+				/* and finally [port] */
+				if ((p = strtok(NULL, ":"))) {	/* port selected; p -> port */
+					PCU.serverPort = atoi(p);
+				}
+				free(tmp);
+
+#ifdef DEBUG_IMAP4
+				printf("imap4: userName= '%s'\n", PCU.userName);
+				printf("imap4: password= '%s'\n", PCU.password);
+				printf("imap4: serverName= '%s'\n", PCU.serverName);
+				printf("imap4: serverPath= '%s'\n", pc->path);
+				printf("imap4: serverPort= '%d'\n", PCU.serverPort);
+#endif
+				pc->open = imap4Login;
+				pc->checkMail = imap4CheckMail;
+				pc->TotalMsgs = 0;
+				pc->UnreadMsgs = 0;
+				pc->OldMsgs = -1;
+				pc->OldUnreadMsgs = -1;
+				return 0;
+			}
+		}
+	}
+	/* The line is badly formatted, we're not creating the mailbox line */
+	pc->label[0] = 0;
+	fprintf(stderr, "config line with bad format '%s'.\n", str);
+	return -1;
+}
+
+/* vim:set ts=4: */
diff --git a/wmbiff/LicqClient.c b/wmbiff/LicqClient.c
new file mode 100644
index 0000000..6ae7ba6
--- /dev/null
+++ b/wmbiff/LicqClient.c
@@ -0,0 +1,94 @@
+/* Author : Yong-iL Joh ( tolkien at mizi.com )
+   Modified: Jorge Garc�a ( Jorge.Garcia at uv.es )
+ * 
+ * LICQ checker.
+ *
+ * Last Updated : Mar 20, 05:32:35 CET 2001     
+ *
+ */
+
+#include "Client.h"
+#include <sys/stat.h>
+#include <utime.h>
+#include <errno.h>
+
+#define PCM     (pc->u).mbox
+
+int licqCheckHistory(Pop3 pc)
+{
+	struct stat st;
+	struct utimbuf ut;
+	FILE *F;
+	int count_status = 0;
+	char buf[1024];
+
+#ifdef DEBUG_MAIL_COUNT
+	printf(">Mailbox: '%s'\n", pc->path);
+#endif
+
+	/* licq file */
+	if (stat(pc->path, &st)) {
+		fprintf(stderr, "wmbiff: Can't stat mailbox '%s': %s\n",
+				pc->path, strerror(errno));
+		return -1;				/* Error stating mailbox */
+	}
+
+	if (st.st_mtime != PCM.mtime || st.st_size != PCM.size
+		|| pc->OldMsgs < 0) {
+		/* file was changed OR initially read */
+#ifdef DEBUG_MAIL_COUNT
+		printf("  was changed,"
+			   " TIME: old %lu, new %lu"
+			   " SIZE: old %lu, new %lu\n",
+			   PCM.mtime, st.st_mtime, (unsigned long) PCM.size,
+			   st.st_size);
+#endif
+		ut.actime = st.st_atime;
+		ut.modtime = st.st_mtime;
+		F = pc->open(pc);
+
+		/* count message */
+		while (fgets(buf, BUF_SIZE, F)) {
+			if ((buf[0] == '[') || (buf[0] == '-')) {	/* new, or old licq */
+				count_status++;
+			}
+		}
+		pc->TotalMsgs = count_status * 2;
+		pc->UnreadMsgs = pc->TotalMsgs - count_status;
+#ifdef DEBUG_MAIL_COUNT
+		printf("from: %d status: %d\n", pc->TotalMsgs, pc->UnreadMsgs);
+#endif
+
+		fclose(F);
+
+		utime(pc->path, &ut);
+		/* Reset atime for MUTT and something others correctly work */
+		PCM.mtime = st.st_mtime;	/* Store new mtime */
+		PCM.size = st.st_size;	/* Store new size */
+	}
+
+	return 0;
+}
+
+int licqCreate(Pop3 pc, char *str)
+{
+	/* LICQ format: licq:fullpathname */
+
+	pc->TotalMsgs = 0;
+	pc->UnreadMsgs = 0;
+	pc->OldMsgs = -1;
+	pc->OldUnreadMsgs = -1;
+	pc->open = openMailbox;
+	pc->checkMail = licqCheckHistory;
+
+	strcpy(pc->path, str + 5);	/* cut off ``licq:'' */
+
+#ifdef DEBUG_LICQ
+	printf("licq: str = '%s'\n", str);
+	printf("licq: path= '%s'\n", pc->path);
+#endif
+
+	return 0;
+}
+
+/* vim:set ts=4: */
diff --git a/wmbiff/Makefile b/wmbiff/Makefile
new file mode 100644
index 0000000..d684f3a
--- /dev/null
+++ b/wmbiff/Makefile
@@ -0,0 +1,70 @@
+WMBIFF_VERSION="0.2q1"
+DESTDIR=
+prefix=/usr/local
+bindir=${prefix}/bin
+mandir=${prefix}/share/man
+CONF=/etc
+LIBDIR = -L/usr/X11R6/lib
+LIBS   = -lXpm -lXext -lX11
+CFLAGS = -O2 -Wall
+#CFLAGS = -g -Wall -pedantic 
+
+EXTRAFLAGS = -DWMBIFF_VERSION='$(WMBIFF_VERSION)'
+#EXTRAFLAGS += -DDEBUG_POP3 -DDEBUG_IMAP4 -DDEBUG_LICQ \
+#	-DDEBUG_MBOX -DDEBUG_MAILDIR -DDEBUG -DDEBUG_MAIL_COUNT
+
+OBJS =	wmbiff.o socket.o \
+	Pop3Client.o Imap4Client.o LicqClient.o mboxClient.o \
+	maildirClient.o \
+	../wmgeneral/wmgeneral.o \
+	../wmgeneral/misc.o \
+	../wmgeneral/list.o
+
+INSTALL = /usr/bin/install
+INSTALL_DIR	= $(INSTALL) -p -d -o root -g root -m 755
+INSTALL_PROGRAM	= $(INSTALL) -p -o root -g root -m 755
+INSTALL_FILE 	= $(INSTALL) -p -o root -g root -m 644
+
+
+.c.o:
+	gcc  $(CFLAGS) $(EXTRAFLAGS) -c $< -o $*.o
+
+all: wmbiff-master.xpm wmbiff
+
+wmbiff-master.xpm:
+	ln -s wmbiff-master-led.xpm wmbiff-master.xpm
+
+wmbiff:	$(OBJS)
+	gcc $(CFLAGS) $(EXTRAFLAGS) -o wmbiff -lX11 -lnsl $^ $(LIBDIR) $(LIBS)
+
+clean:
+	for i in $(OBJS) ; do \
+		rm -f $$i ; \
+	done
+	rm -f wmbiff *~ tags core
+
+install: wmbiff
+	$(INSTALL_DIR) $(DESTDIR)$(bindir)
+	$(INSTALL_DIR) $(DESTDIR)$(mandir)/man1
+	$(INSTALL_DIR) $(DESTDIR)$(mandir)/man5
+	$(INSTALL_PROGRAM) wmbiff $(DESTDIR)$(bindir)
+	$(INSTALL_FILE) wmbiff.1 $(DESTDIR)$(mandir)/man1
+	$(INSTALL_FILE) wmbiffrc.5 $(DESTDIR)$(mandir)/man5
+
+# CODING STYLE AND INDENTATION [2001-Mar-12]:
+#
+# There have been some problems with coding style in the past.  Many people
+# contributed to wmbiff (thank you!), and the code got really messy.  To help
+# resolve this, I used GNU indent with what I believe to be the most
+# widely-accepted coding style options (K&R style) with 4-space TAB indents
+# (because some of the code is highly nested) to clean up the code.  Not
+# everyone may be happy with this, but has been determined to be necessary for
+# consistency and legibility.
+#
+# In other words, make sure you run "make clean" or "make indent", and do not
+# change the options on the indent command, before you submit patches against
+# wmbiff.  This will make everyone's life easier.
+#
+#	-- Dwayne C. Litzenberger <dlitz at dlitz.net>
+indent:
+	indent -npro -kr -i4 -ts4 *.[ch] || true
diff --git a/wmbiff/Pop3Client.c b/wmbiff/Pop3Client.c
new file mode 100644
index 0000000..e71e605
--- /dev/null
+++ b/wmbiff/Pop3Client.c
@@ -0,0 +1,240 @@
+/* Author : Scott Holden ( scotth at thezone.net )
+   Modified : Yong-iL Joh ( tolkien at mizi.com )
+   Modified : Jorge Garc�a ( Jorge.Garcia at uv.es )
+   Modified ; Mark Hurley ( debian4tux at telocity.com )
+ * 
+ * Pop3 Email checker.
+ *
+ * Last Updated : Apr 29, 23:04:57 EDT 2001     
+ *
+ */
+
+#include "Client.h"
+
+#define	PCU	(pc->u).pop
+
+FILE *pop3Login(Pop3 pc)
+{
+	int fd;
+	FILE *fp;
+	char buf[BUF_SIZE];
+
+	if ((fd = sock_connect(PCU.serverName, PCU.serverPort)) == -1) {
+		fprintf(stderr, "Not Connected To Server '%s:%d'\n",
+				PCU.serverName, PCU.serverPort);
+		return NULL;
+	}
+
+	fp = fdopen(fd, "r+");
+	fgets(buf, BUF_SIZE, fp);
+
+	fflush(fp);
+	fprintf(fp, "USER %s\r\n", PCU.userName);
+	fflush(fp);
+	fgets(buf, BUF_SIZE, fp);
+	if (buf[0] != '+') {
+		fprintf(stderr, "Invalid User Name '%s@%s:%d'\n",
+				PCU.userName, PCU.serverName, PCU.serverPort);
+#ifdef DEBUG_POP3
+		fprintf(stderr, "%s\n", buf);
+#endif
+		fprintf(fp, "QUIT\r\n");
+		fclose(fp);
+		return NULL;
+	};
+
+	fflush(fp);
+	fprintf(fp, "PASS %s\r\n", PCU.password);
+	fflush(fp);
+	fgets(buf, BUF_SIZE, fp);
+	if (buf[0] != '+') {
+		fprintf(stderr, "Incorrect Password for user '%s@%s:%d'\n",
+				PCU.userName, PCU.serverName, PCU.serverPort);
+		fprintf(stderr, "It said %s", buf);
+		fprintf(fp, "QUIT\r\n");
+		fclose(fp);
+		return NULL;
+	};
+
+	return fp;
+}
+
+int pop3CheckMail(Pop3 pc)
+{
+	FILE *f;
+	int read;
+	char buf[BUF_SIZE];
+
+	f = pc->open(pc);
+	if (f == NULL)
+		return -1;
+
+	fflush(f);
+	fprintf(f, "STAT\r\n");
+	fflush(f);
+	fgets(buf, 256, f);
+	if (buf[0] != '+') {
+		fprintf(stderr, "Error Receiving Stats '%s@%s:%d'\n",
+				PCU.userName, PCU.serverName, PCU.serverPort);
+		return -1;
+	} else {
+		sscanf(buf, "+OK %d", &(pc->TotalMsgs));
+	}
+
+	/*  - Updated - Mark Hurley - debian4tux at telocity.com
+	 *  In compliance with RFC 1725
+	 *  which removed the LAST command, any servers
+	 *  which follow this spec will return:
+	 *      -ERR unimplimented
+	 *  We will leave it here for those servers which haven't
+	 *  caught up with the spec.
+	 */
+	fflush(f);
+	fprintf(f, "LAST\r\n");
+	fflush(f);
+	fgets(buf, 256, f);
+	if (buf[0] != '+') {
+		/* it is not an error to receive this according to RFC 1725 */
+		/* no error should be returned */
+		pc->UnreadMsgs = pc->TotalMsgs;
+	} else {
+		sscanf(buf, "+OK %d", &read);
+		pc->UnreadMsgs = pc->TotalMsgs - read;
+	}
+
+	fprintf(f, "QUIT\r\n");
+	fclose(f);
+
+	return 0;
+}
+
+int pop3Create(Pop3 pc, char *str)
+{
+	/* POP3 format: pop3:user:password at server[:port] */
+	/* new POP3 format: pop3:user password server [port] */
+	/* If 'str' line is badly formatted, wmbiff won't display the mailbox. */
+
+	/* old config file style... */
+	if (parse_old_pop3_path(pc, str) != 0)
+
+		/* new config file style... */
+		if (parse_new_pop3_path(pc, str) != 0) {
+
+			/* The line is badly formatted,
+			 * we're not creating the mailbox line */
+			pc->label[0] = 0;
+			fprintf(stderr, "config line with bad format '%s'.\n", str);
+			return -1;
+		}
+
+	return 0;
+}
+
+/* parse the pop3 config line
+ * one simple function with a delimiter won't work,
+ * because of the '@' before server in old style!
+ */
+int parse_old_pop3_path(Pop3 pc, char *str)
+{
+	char *tmp;
+	char *p;
+
+#ifdef DEBUG_POP3
+	printf("pop3: str = '%s'\n", str);
+#endif
+
+	strcpy(PCU.password, "");
+	strcpy(PCU.userName, "");
+	strcpy(PCU.serverName, "");
+	PCU.serverPort = 110;
+
+	tmp = strdup(str);
+
+	p = strtok(tmp, ":");		/* cut off 'pop3:' */
+
+	if ((p = strtok(NULL, ":"))) {	/* p -> username */
+		strcpy(PCU.userName, p);
+		if ((p = strtok(NULL, "@"))) {	/* p -> password */
+			strcpy(PCU.password, p);
+			if ((p = strtok(NULL, ":"))) {	/* p -> server */
+				strcpy(PCU.serverName, p);
+				strcpy(pc->path, "");	/* p -> mailbox */
+				if ((p = strtok(NULL, ":"))) {	/* p -> port */
+					PCU.serverPort = atoi(p);
+				}
+				free(tmp);
+
+#ifdef DEBUG_POP3
+				printf("pop3: userName= '%s'\n", PCU.userName);
+				printf("pop3: password= '%s'\n", PCU.password);
+				printf("pop3: serverName= '%s'\n", PCU.serverName);
+				printf("pop3: serverPort= '%d'\n", PCU.serverPort);
+#endif
+				pc->open = pop3Login;
+				pc->checkMail = pop3CheckMail;
+				pc->TotalMsgs = 0;
+				pc->UnreadMsgs = 0;
+				pc->OldMsgs = -1;
+				pc->OldUnreadMsgs = -1;
+				return 0;
+			}
+		}
+	}
+
+	return 1;
+}
+
+/* delimiter is a "space" */
+int parse_new_pop3_path(Pop3 pc, char *str)
+{
+	char *tmp;
+	char *p;
+	char *delim = " ";
+
+#ifdef DEBUG_POP3
+	printf("pop3: str = '%s'\n", str);
+#endif
+
+	strcpy(PCU.password, "");
+	strcpy(PCU.userName, "");
+	strcpy(PCU.serverName, "");
+	PCU.serverPort = 110;
+
+	tmp = strdup(str);
+
+	p = strtok(tmp, ":");		/* cut off 'pop3:' */
+
+	if ((p = strtok(NULL, delim))) {	/* p -> username */
+		strcpy(PCU.userName, p);
+		if ((p = strtok(NULL, delim))) {	/* p -> password */
+			strcpy(PCU.password, p);
+			if ((p = strtok(NULL, delim))) {	/* p -> server */
+				strcpy(PCU.serverName, p);
+				strcpy(pc->path, "");	/* p -> mailbox */
+				if ((p = strtok(NULL, delim))) {	/* p -> port */
+					PCU.serverPort = atoi(p);
+				}
+				free(tmp);
+
+#ifdef DEBUG_POP3
+				printf("pop3: userName= '%s'\n", PCU.userName);
+				printf("pop3: password= '%s'\n", PCU.password);
+				printf("pop3: serverName= '%s'\n", PCU.serverName);
+				printf("pop3: serverPort= '%d'\n", PCU.serverPort);
+#endif
+				pc->open = pop3Login;
+				pc->checkMail = pop3CheckMail;
+				pc->TotalMsgs = 0;
+				pc->UnreadMsgs = 0;
+				pc->OldMsgs = -1;
+				pc->OldUnreadMsgs = -1;
+				return 0;
+			}
+		}
+	}
+
+	return 1;
+}
+
+
+/* vim:set ts=4: */
diff --git a/wmbiff/maildirClient.c b/wmbiff/maildirClient.c
new file mode 100644
index 0000000..4393e38
--- /dev/null
+++ b/wmbiff/maildirClient.c
@@ -0,0 +1,137 @@
+/* Author : Yong-iL Joh ( tolkien at mizi.com )
+   Modified : Jorge Garc�a ( Jorge.Garcia at uv.es )
+ * 
+ * Maildir checker.
+ *
+ * Last Updated : Mar 20, 05:32:35 CET 2001     
+ *
+ */
+
+#include "Client.h"
+#include <sys/stat.h>
+#include <dirent.h>
+#include <errno.h>
+#include <utime.h>
+
+
+#define PCM	(pc->u).maildir
+
+static int count_msgs(char *path)
+{
+	DIR *D;
+	struct dirent *de;
+	int count = 0;
+
+	D = opendir(path);
+	if (D == NULL) {
+		fprintf(stderr,
+				"wmbiff: Error opening directory '%s': %s\n", path,
+				strerror(errno));
+		return -1;
+	}
+
+	while ((de = readdir(D)) != NULL) {
+		if ((strcmp(de->d_name, ".") & strcmp(de->d_name, "..")) != 0) {
+			count++;
+		}
+	}
+	closedir(D);
+
+	return count;
+}
+
+int maildirCheckHistory(Pop3 pc)
+{
+	struct stat st_new;
+	struct stat st_cur;
+	struct utimbuf ut;
+	char path_new[256], path_cur[256];
+
+	int count_new = 0, count_cur = 0;
+
+#ifdef DEBUG_MAIL_COUNT
+	printf(">Maildir: '%s'\n", pc->path);
+#endif
+
+	strcpy(path_new, pc->path);
+	strcat(path_new, "/new/");
+	strcpy(path_cur, pc->path);
+	strcat(path_cur, "/cur/");
+
+	/* maildir */
+	if (stat(path_new, &st_new)) {
+		fprintf(stderr, "wmbiff: Can't stat mailbox '%s': %s\n",
+				path_new, strerror(errno));
+		return -1;				/* Error stating mailbox */
+	}
+	if (stat(path_cur, &st_cur)) {
+		fprintf(stderr, "wmbiff: Can't stat mailbox '%s': %s\n",
+				path_cur, strerror(errno));
+		return -1;				/* Error stating mailbox */
+	}
+
+
+	/* file was changed OR initially read */
+	if (st_new.st_mtime != PCM.mtime_new
+		|| st_new.st_size != PCM.size_new
+		|| st_cur.st_mtime != PCM.mtime_cur
+		|| st_cur.st_size != PCM.size_cur || pc->OldMsgs < 0) {
+#ifdef DEBUG_MAIL_COUNT
+		printf("  was changed,\n"
+			   " TIME(new): old %lu, new %lu"
+			   " SIZE(new): old %lu, new %lu\n"
+			   " TIME(cur): old %lu, new %lu"
+			   " SIZE(cur): old %lu, new %lu\n",
+			   PCM.mtime_new, st_new.st_mtime,
+			   (unsigned long) PCM.size_new, st_new.st_size,
+			   PCM.mtime_cur, st_cur.st_mtime,
+			   (unsigned long) PCM.size_cur, st_cur.st_size);
+#endif
+
+		count_new = count_msgs(path_new);
+		count_cur = count_msgs(path_cur);
+		if ((count_new | count_cur) == -1) {	/* errors occurred */
+			return -1;
+		}
+
+		pc->TotalMsgs = count_cur + count_new;
+		pc->UnreadMsgs = count_new;
+
+		/* Reset atime for MUTT and something others work correctly */
+		ut.actime = st_new.st_atime;
+		ut.modtime = st_new.st_mtime;
+		utime(path_new, &ut);
+		ut.actime = st_cur.st_atime;
+		ut.modtime = st_cur.st_mtime;
+		utime(path_cur, &ut);
+
+		/* Store new values */
+		PCM.mtime_new = st_new.st_mtime;	/* Store new mtime_new */
+		PCM.size_new = st_new.st_size;	/* Store new size_new */
+		PCM.mtime_cur = st_cur.st_mtime;	/* Store new mtime_cur */
+		PCM.size_cur = st_cur.st_size;	/* Store new size_cur */
+	}
+
+	return 0;
+}
+
+int maildirCreate(Pop3 pc, char *str)
+{
+	/* Maildir format: maildir:fullpathname */
+
+	pc->TotalMsgs = 0;
+	pc->UnreadMsgs = 0;
+	pc->OldMsgs = -1;
+	pc->OldUnreadMsgs = -1;
+	pc->checkMail = maildirCheckHistory;
+	strcpy(pc->path, str + 8);	/* cut off ``maildir:'' */
+
+#ifdef DEBUG_MAILDIR
+	printf("maildir: str = '%s'\n", str);
+	printf("maildir: path= '%s'\n", pc->path);
+#endif
+
+	return 0;
+}
+
+/* vim:set ts=4: */
diff --git a/wmbiff/mboxClient.c b/wmbiff/mboxClient.c
new file mode 100644
index 0000000..1cb48e9
--- /dev/null
+++ b/wmbiff/mboxClient.c
@@ -0,0 +1,139 @@
+/* Author:		Yong-iL Joh <tolkien at mizi.com>
+   Modified:	Jorge Garc�a <Jorge.Garcia at uv.es>
+   			 	Rob Funk <rfunk at funknet.net>
+ * 
+ * MBOX checker.
+ *
+ * Last Updated : Thu Apr 26 03:09:40 CEST 2001
+ *
+ */
+
+#include "Client.h"
+#include <sys/stat.h>
+#include <errno.h>
+#include <utime.h>
+
+#define PCM	(pc->u).mbox
+#define FROM_STR   "From "
+#define STATUS_STR "Status: "
+
+FILE *openMailbox(Pop3 pc)
+{
+	FILE *mailbox;
+
+	if ((mailbox = fopen(pc->path, "r")) == NULL) {
+		fprintf(stderr, "wmbiff: Error opening mailbox '%s': %s\n",
+				pc->path, strerror(errno));
+	}
+	return (mailbox);
+}
+
+int mboxCheckHistory(Pop3 pc)
+{
+	struct stat st;
+	struct utimbuf ut;
+	FILE *F;
+	char buf[BUF_SIZE];
+
+
+	int is_header = 0;
+	int next_from_is_start_of_header = 1;
+	int count_from = 0, count_status = 0;
+	int len_from = strlen(FROM_STR), len_status = strlen(STATUS_STR);
+
+#ifdef DEBUG_MAIL_COUNT
+	printf(">Mailbox: '%s'\n", pc->path);
+#endif
+
+	/* mbox file */
+	if (stat(pc->path, &st)) {
+		fprintf(stderr, "wmbiff: Can't stat mailbox '%s': %s\n",
+				pc->path, strerror(errno));
+		return -1;				/* Error stating mailbox */
+	}
+
+	if (st.st_mtime != PCM.mtime || st.st_size != PCM.size
+		|| pc->OldMsgs < 0) {
+		/* file was changed OR initially read */
+#ifdef DEBUG_MAIL_COUNT
+		printf("  was changed,"
+			   " TIME: old %lu, new %lu"
+			   " SIZE: old %lu, new %lu\n",
+			   PCM.mtime, st.st_mtime, (unsigned long) PCM.size,
+			   st.st_size);
+#endif
+		ut.actime = st.st_atime;
+		ut.modtime = st.st_mtime;
+		F = pc->open(pc);
+
+		/* count message */
+		while (fgets(buf, BUF_SIZE, F)) {
+			if (buf[0] == '\n') {
+				/* a newline by itself terminates the header */
+				if (is_header)
+					is_header = 0;
+				else
+					next_from_is_start_of_header = 1;
+			} else if (!strncmp(buf, FROM_STR, len_from)) {
+				/* A line starting with "From" is the beginning of a new header.
+				   "From" in the text of the mail should get escaped by the MDA.
+				   If your MDA doesn't do that, it is broken.
+				 */
+				if (next_from_is_start_of_header)
+					is_header = 1;
+				if (is_header)
+					count_from++;
+			} else {
+				next_from_is_start_of_header = 0;
+				if (!strncmp(buf, STATUS_STR, len_status)) {
+					if (strrchr(buf, 'R')) {
+#ifdef DEBUG_MAIL_COUNT
+						/*  printf ("Got a status: %s",buf); */
+#endif
+						if (is_header)
+							count_status++;
+					}
+				}
+			}
+		}
+
+#ifdef DEBUG_MAIL_COUNT
+		printf("from: %d status: %d\n", count_from, count_status);
+#endif
+		pc->TotalMsgs = count_from;
+		pc->UnreadMsgs = count_from - count_status;
+		fclose(F);
+
+		utime(pc->path, &ut);
+		/* Reset atime for MUTT and something others correctly work */
+		PCM.mtime = st.st_mtime;	/* Store new mtime */
+		PCM.size = st.st_size;	/* Store new size */
+	}
+
+	return 0;
+}
+
+int mboxCreate(Pop3 pc, char *str)
+{
+	/* MBOX format: mbox:fullpathname */
+
+	pc->TotalMsgs = 0;
+	pc->UnreadMsgs = 0;
+	pc->OldMsgs = -1;
+	pc->OldUnreadMsgs = -1;
+	pc->open = openMailbox;
+	pc->checkMail = mboxCheckHistory;
+
+	/* default boxes are mbox... cut mbox: if it exists */
+	if (!strncasecmp(pc->path, "mbox:", 5))
+		strcpy(pc->path, str + 5);	/* cut off ``mbox:'' */
+
+#ifdef DEBUG_MBOX
+	printf("mbox: str = '%s'\n", str);
+	printf("mbox: path= '%s'\n", pc->path);
+#endif
+
+	return 0;
+}
+
+/* vim:set ts=4: */
diff --git a/wmbiff/sample.wmbiffrc b/wmbiff/sample.wmbiffrc
new file mode 100644
index 0000000..0c88168
--- /dev/null
+++ b/wmbiff/sample.wmbiffrc
@@ -0,0 +1,68 @@
+# Global interval -- seconds between check mailboxes
+interval=60
+
+### First string ###
+
+# Label, that will be displayed
+label.0=Spool
+
+# Path to mailbox for UNIX-style mailboxes,
+# or pop3:user:password at mailserver[:port] for POP3 accounts
+# port are optional, default - 110
+path.0=/var/spool/mail/gb
+
+# Command, which executed on new mail arrival, or special keyword 'beep'
+#notify.0=beep
+notify.0=my_play /home/gb/sounds/new_mail_has_arrived.wav
+
+# Command, which executed on left mouse click on label 
+action.0=rxvt -name mutt -e mutt
+
+# Rescan interval; default to global interval
+# For POP3-accounts bigger values (>60sec) is recommended
+#interval.0=5
+
+# Interval between mail auto-fetching; use 0 for disable (only
+# mouse right-clicking still worked)
+# use -1 for auto-fetching on new mail arrival
+#fetchinterval.0=300
+
+# Command, which used for fetching mail. Leave commented out for full disable
+#fetchcmd.0=/usr/bin/fetchmail
+
+###
+# NOTE: line under this line will not be parsed because the space before equal
+label.1 = MBOX
+# MBOX format: mbox:fullpathname
+path.1=mbox:/home/gb/mail/10_ksi-linux-list
+notify.1=my_play /home/gb/sounds/new_mail_has_arrived.wav
+action.1=rxvt -name mutt -e mutt -f /home/gb/mail/10_ksi-linux-list
+
+# label.1 = MDIR
+# # Maildir format: maildir:fullpathname
+# path.1=maildir:/home/gb/Maildir/
+# notify.1=my_play /home/gb/sounds/new_mail_has_arrived.wav
+# action.1=rxvt -name mutt -e mutt -f /home/gb/Maildir
+
+label.2=LICQ
+# LICQ format: licq:fullpathname
+path.2=licq:/home/person/.licq/history/1111111.history
+notify.2=beep
+action.2=licq&
+
+label.3=POP3
+# pop3 format: pop3:user:password at server[:port]
+path.3=pop3:user:password at server
+notify.3=my_play /home/gb/sounds/new_mail_has_arrived.wav
+action.3=rxvt -name mutt -e mutt -f /home/gb/mail/30_nftp-list
+interval.3=300		# 5 minutes
+fetchinterval.3=-1
+fetchcmd.3=fetchmail
+
+label.4=IMAP4
+# IMAP4 format: imap:user:password at server[/mailbox][:port]
+# mailbox is optional, default - INBOX
+# port is optional, default - 143
+path.4=imap:user:password at server
+interval.4=300		# 5 minutes
+
diff --git a/wmbiff/socket.c b/wmbiff/socket.c
new file mode 100644
index 0000000..e4694cb
--- /dev/null
+++ b/wmbiff/socket.c
@@ -0,0 +1,57 @@
+/* Copyright (C) 1998 Trent Piepho  <xyzzy at u.washington.edu>
+ *           (C) 1999 Trent Piepho  <xyzzy at speakeasy.org>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc., 675
+ * Mass Ave, Cambridge, MA 02139, USA.  */
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <time.h>
+#include <sys/stat.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <netdb.h>
+#include <stdio.h>
+
+
+int sock_connect(char *hostname, int port)
+{
+	struct hostent *host;
+	struct sockaddr_in addr;
+	int fd, i;
+
+	host = gethostbyname(hostname);
+	if (host == NULL) {
+		herror("gethostbyname");
+		return (-1);
+	};
+
+	fd = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
+	if (fd == -1) {
+		perror("Error opening socket");
+		return (-1);
+	};
+
+	addr.sin_family = AF_INET;
+	addr.sin_addr.s_addr = *(u_long *) host->h_addr_list[0];
+	addr.sin_port = htons(port);
+	i = connect(fd, (struct sockaddr *) &addr, sizeof(struct sockaddr));
+	if (i == -1) {
+		perror("Error connecting");
+		close(fd);
+		return (-1);
+	};
+	return (fd);
+}
+
+/* vim:set ts=4: */
diff --git a/wmbiff/wmbiff-master-led.xpm b/wmbiff/wmbiff-master-led.xpm
new file mode 100644
index 0000000..1397475
--- /dev/null
+++ b/wmbiff/wmbiff-master-led.xpm
@@ -0,0 +1,118 @@
+/* XPM */
+static char * wmbiff_master_xpm[] = {
+"160 100 15 1",
+" 	c #00000000FFFF",
+".	c #208120812081",
+"X	c #FFFFFFFF0000",
+"o	c #492441030000",
+"O	c #79E779E70820",
+"+	c #000000000000",
+"@	c #C71BC30BC71B",
+"#	c #000049244103",
+"$	c #2081B2CAAEBA",
+"%	c #00007DF771C6",
+"&	c #B6DA04101861",
+"*	c #0000EBAD0000",
+"=	c #28A23CF338E3",
+"-	c #F7DEF3CEFFFF",
+";	c #71C6E38D71C6",
+"                                                                ................................................................................                ",
+"                                                                ...XXX...oooO.OXXXO.OXXXO.OoooO.OXXXO.OXXXO.OXXXO.OXXXO.OXXXO...................                ",
+"                                                                ..X...X.o...X.o...X.o...X.X...X.X...o.X...o.o...X.X...X.X...X............X......                ",
+"                                                                ..X...X.o...X.o...X.o...X.X...X.X...o.X...o.o...X.X...X.X...X..X....X....X......                ",
+"    ++++++++++++++++++++++++++++++++++++++++++++++++++++++++    ..OoooO..oooO.OXXXO..XXXO.OXXXO.OXXXO.OXXXO..oooO.oXXXo.OXXXO..O....O...X.......                ",
+"    +......................................................@    ..X...X.o...X.X...o.o...X.o...X.o...X.X...X.o...X.X...X.o...X...........X.......                ",
+"    +..###...###...###...###...###.......###...###...###...@    ..X...X.o...X.X...o.o...X.o...X.o...X.X...X.o...X.X...X.o...X..X....X..X........                ",
+"    +.#...#.#...#.#...#.#...#.#...#.....#...#.#...#.#...#..@    ...XXX...oooX.OXXXO.OXXXO..oooO.OXXXO.OXXXO..oooO.OXXXO.OXXXO..O....O..X........                ",
+"    +.#...#.#...#.#...#.#...#.#...#..#..#...#.#...#.#...#..@    ................................................................................                ",
+"    +..###...###...###...###...###...#...###...###...###...@    .                                                                                               ",
+"    +.#...#.#...#.#...#.#...#.#...#.....#...#.#...#.#...#..@    .                                                                                               ",
+"    +.#...#.#...#.#...#.#...#.#...#..#..#...#.#...#.#...#..@    .                                                                                               ",
+"    +..###...###...###...###...###...#...###...###...###...@    .                                                                                               ",
+"    +......................................................@    .                                                                                               ",
+"    +......................................................@    .                                                                                               ",
+"    +......................................................@    .                                                                                               ",
+"    +......................................................@    .                                                                                               ",
+"    +..###...###...###...###...###.......###...###...###...@    .                                                                                               ",
+"    +.#...#.#...#.#...#.#...#.#...#.....#...#.#...#.#...#..@    .                                                                                               ",
+"    +.#...#.#...#.#...#.#...#.#...#..#..#...#.#...#.#...#..@    .                                                                                               ",
+"    +..###...###...###...###...###...#...###...###...###...@    .                                                                                               ",
+"    +.#...#.#...#.#...#.#...#.#...#.....#...#.#...#.#...#..@    .                                                                                               ",
+"    +.#...#.#...#.#...#.#...#.#...#..#..#...#.#...#.#...#..@    .                                                                                               ",
+"    +..###...###...###...###...###...#...###...###...###...@    .                                                                                               ",
+"    +......................................................@    .                                                                                               ",
+"    +......................................................@    .                                                                                               ",
+"    +......................................................@    .                                                                                               ",
+"    +......................................................@    .                                                                                               ",
+"    +..###...###...###...###...###.......###...###...###...@    .                                                                                               ",
+"    +.#...#.#...#.#...#.#...#.#...#.....#...#.#...#.#...#..@    .                                                                                               ",
+"    +.#...#.#...#.#...#.#...#.#...#..#..#...#.#...#.#...#..@    .                                                                                               ",
+"    +..###...###...###...###...###...#...###...###...###...@    .                                                                                               ",
+"    +.#...#.#...#.#...#.#...#.#...#.....#...#.#...#.#...#..@    .                                                                                               ",
+"    +.#...#.#...#.#...#.#...#.#...#..#..#...#.#...#.#...#..@    .                                                                                               ",
+"    +..###...###...###...###...###...#...###...###...###...@    .                                                                                               ",
+"    +......................................................@    .                                                                                               ",
+"    +......................................................@    .                                                                                               ",
+"    +......................................................@    .                                                                                               ",
+"    +......................................................@    .                                                                                               ",
+"    +..###...###...###...###...###.......###...###...###...@    .                                                                                               ",
+"    +.#...#.#...#.#...#.#...#.#...#.....#...#.#...#.#...#..@    .                                                                                               ",
+"    +.#...#.#...#.#...#.#...#.#...#..#..#...#.#...#.#...#..@    .                                                                                               ",
+"    +..###...###...###...###...###...#...###...###...###...@    .                                                                                               ",
+"    +.#...#.#...#.#...#.#...#.#...#.....#...#.#...#.#...#..@    .                                                                                               ",
+"    +.#...#.#...#.#...#.#...#.#...#..#..#...#.#...#.#...#..@    .                                                                                               ",
+"    +..###...###...###...###...###...#...###...###...###...@    .                                                                                               ",
+"    +......................................................@    .                                                                                               ",
+"    +......................................................@    .                                                                                               ",
+"    +......................................................@    .                                                                                               ",
+"    +......................................................@    .                                                                                               ",
+"    +..###...###...###...###...###.......###...###...###...@    .                                                                                               ",
+"    +.#...#.#...#.#...#.#...#.#...#.....#...#.#...#.#...#..@    .                                                                                               ",
+"    +.#...#.#...#.#...#.#...#.#...#..#..#...#.#...#.#...#..@    .                                                                                               ",
+"    +..###...###...###...###...###...#...###...###...###...@    .                                                                                               ",
+"    +.#...#.#...#.#...#.#...#.#...#.....#...#.#...#.#...#..@    .                                                                                               ",
+"    +.#...#.#...#.#...#.#...#.#...#..#..#...#.#...#.#...#..@    .                                                                                               ",
+"    +..###...###...###...###...###...#...###...###...###...@    .                                                                                               ",
+"    +......................................................@    .                                                                                               ",
+"    +......................................................@    .                                                                                               ",
+"    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@    .                                                                                               ",
+"                                                                .                                                                                               ",
+"                                                                .                                                                                               ",
+"                                                                .                                                                                               ",
+"                                                                .                                                                                               ",
+"...............................................................................                                                                                 ",
+"..$$$...###%.%$$$%.%$$$%.%###%.%$$$%.%$$$%.%$$$%.%$$$%.%$$$%...................                                                                                 ",
+".$...$.#...$.#...$.#...$.$...$.$...#.$...#.#...$.$...$.$...$............$......  .&&.  .**.  .==.                                                               ",
+".$...$.#...$.#...$.#...$.$...$.$...#.$...#.#...$.$...$.$...$..$....$....$......  &-&&  *-**  ====                                                               ",
+".%###%..###%.%$$$%..$$$%.%$$$%.%$$$%.%$$$%..###%.#$$$#.%$$$%..%....%...$.......  &&&&  ****  ====   .$#;                                                        ",
+".$...$.#...$.$...#.#...$.#...$.#...$.$...$.#...$.$...$.#...$...........$.......  .&&.  .**.  .==.                                                               ",
+".$...$.#...$.$...#.#...$.#...$.#...$.$...$.#...$.$...$.#...$..$....$..$........                                                                                 ",
+"..$$$...###$.%$$$%.%$$$%..###%.%$$$%.%$$$%..###%.%$$$%.%$$$%..%....%..$........                                                                                 ",
+"...............................................................................                                                                                 ",
+"                                                                                                                                                                ",
+"................................................................................................................................................................",
+".#$$$#.%$$$..%$$$%.%$$$..%$$$%.%$$$%.%$$$%.%###%..###%..###%.%###%.%###..$###$.%$$$..%$$$%.%$$$%.%$$$%.%$$$%.%$$$%.%$$$%.%###%.%###%.%###%.%###%.%###%.%$$$%....",
+".$...$.$...$.$...#.$...$.$...#.$...#.$...#.$...$.#...$.#...$.$...$.$...#.$$.$$.$...$.$...$.$...$.$...$.$...$.$...#.#.$.#.$...$.$...$.$...$.$...$.$...$.#...$....",
+".$...$.$...$.$...#.$...$.$...#.$...#.$...#.$...$.#...$.#...$.$..$#.$...#.$.$.$.$...$.$...$.$...$.$...$.$...$.$...#.#.$.#.$...$.$...$.$...$.#$.$#.$...$.#..$#....",
+".%$$$%.%$$$..%###..%###%.%$$$..%$$$..%#$$%.%$$$%..###%..###%.%$$#..%###..%###%.%###%.%###%.%$$$%.%$##%.%$$$..%$$$%..#%#..%###%.%###%.%###%..#$#..%$$$%..#$#.....",
+".$...$.$...$.$...#.$...$.$...#.$...#.$...$.$...$.#...$.#...$.$..$#.$...#.$...$.$...$.$...$.$...#.$.$.$.$...$.#...$.#.$.#.$...$.$...$.$.$.$.#$.$#.#...$.#$..#....",
+".$...$.$...$.$...#.$...$.$...#.$...#.$...$.$...$.#...$.#...$.$...$.$...#.$...$.$...$.$...$.$...#.$..$$.$...$.#...$.#.$.#.$...$.$...$.$$.$$.$...$.#...$.$...#....",
+".%###%.%$$$..%$$$%.$$$$..%$$$%.$###..%$$$%.%###%..###$.%$$$%.%###%.%$$$#.%###%.$###$.%$$$%.%###..%$$$%.%###%.%$$$%..#%#..#$$$$..$$$..$###$.%###$%%$$$%.%$$$%....",
+"................................................................................................................................................................",
+"                                                                                                                                                                ",
+"    +......................................................@    .                                                                                               ",
+"     ..###...###...###...###...###.......###...###...###...                                                                                                     ",
+"     .#...#.#...#.#...#.#...#.#...#.....#...#.#...#.#...#..                                                                                                     ",
+"     .#...#.#...#.#...#.#...#.#...#..#..#...#.#...#.#...#..                                                                                                     ",
+"     ..###...###...###...###...###...#...###...###...###...                                                                                                     ",
+"     .#...#.#...#.#...#.#...#.#...#.....#...#.#...#.#...#..                                                                                                     ",
+"     .#...#.#...#.#...#.#...#.#...#..#..#...#.#...#.#...#..                                                                                                     ",
+"     ..###...###...###...###...###...#...###...###...###...                                                                                                     ",
+"     ......................................................                                                                                                     ",
+"     ......................................................                                                                                                     ",
+"                                                                                                                                                                ",
+"                                                                                                                                                                ",
+"                                                                                                                                                                ",
+"                                                                                                                                                                ",
+"                                                                                                                                                                ",
+"                                                                                                                                                                "};
diff --git a/wmbiff/wmbiff.1 b/wmbiff/wmbiff.1
new file mode 100644
index 0000000..27462cf
--- /dev/null
+++ b/wmbiff/wmbiff.1
@@ -0,0 +1,74 @@
+.\" Hey, Emacs!  This is an -*- nroff -*- source file.
+.\" wmbiff.1 and wmbiffrc.5 are copyright 1999-2001 by
+.\" Jordi Mallach <jordi at debian.org>
+.\"
+.\" This is free documentation, see the latest version of the GNU
+.\" General Public License for copying conditions. There is NO warranty.
+.TH WMBIFF 1 "March 12, 2001" "wmbiff"
+
+.SH NAME
+WMBiff \- A dockable Mailbox Monitor
+
+.SH SYNOPSIS
+.B wmbiff
+[-display <display name>] [-geometry +XPOS+YPOS] [-c <filename>] [-h] [-v]
+.br
+
+.SH DESCRIPTION
+WMbiff displays the status of up to five mailboxes. It gives information
+about new mail, if any, or total number of messages. It also has mail
+retrieval capabilies, and can be configured to do this automatically. At the
+moment, UNIX-style, POP3 and IMAP4 mailboxes are supported. WMbiff also
+supports Licq history files, displaying the number of new messages in your
+running Licq session, as if they were mail.
+
+The mailboxes are displayed in 5 different lines, each one with its own
+description of up to five chars. If no mail is present in a given mailbox,
+WMbiff will display the total number of mails in cyan. If there's new mail
+in the box, the number of new messages will be displayed in yellow. When new
+mail arrives, this number will optionally flash for a small period of time,
+and also optionally, a command can be executed on mail arrival (for example,
+opening your mail reader or playing a sound file).
+
+Pressing mouse button 1 will execute a command, defined in the user's config
+file. Mouse button 3 will execute a command to fetch mail, if defined.
+.PP
+
+.SH OPTIONS
+.TP
+.B \-h
+Show summary of options.
+.TP
+.B \-v
+Show version of program.
+.TP
+.B \-display <display name>
+Use an alternate X Display.
+.TP
+.B \-geometry <geometry>
+Initial window position.
+.TP
+.B \-c <filename>
+Use specified config file.
+
+.SH BUGS
+Please send any bug reports or suggestions to Gennady Belyakov
+<gb at ccat.elect.ru>.
+.br
+
+.SH FILES
+.TP
+.I ~/.wmbiffrc
+peruser wmbiff configuration file.
+
+.SH AUTHOR
+This manual page was written by Jordi Mallach <jordi at sindominio.net>,
+originally for the Debian GNU/Linux system (but may be used by others).
+
+.SH SEE ALSO
+.PD 0
+.TP
+\fBwmbiffrc\fP(5)
+.PP
+\fI/usr/share/doc/wmbiff/examples/sample.wmbiffrc\fP
+(or equivalent for your system)
diff --git a/wmbiff/wmbiff.c b/wmbiff/wmbiff.c
new file mode 100644
index 0000000..d2713cd
--- /dev/null
+++ b/wmbiff/wmbiff.c
@@ -0,0 +1,631 @@
+
+#define	USE_POLL
+
+#include <time.h>
+#include <ctype.h>
+
+#ifdef USE_POLL
+#include <poll.h>
+#else
+#include <sys/time.h>
+#endif
+
+#include <sys/wait.h>
+#include <sys/types.h>
+#include <signal.h>
+
+#include <X11/Xlib.h>
+#include <X11/xpm.h>
+
+#include "../wmgeneral/wmgeneral.h"
+#include "../wmgeneral/misc.h"
+
+#include "Client.h"
+
+#include "wmbiff-master.xpm"
+char wmbiff_mask_bits[64 * 64];
+int wmbiff_mask_width = 64;
+int wmbiff_mask_height = 64;
+
+#define CHAR_WIDTH  5
+#define CHAR_HEIGHT 7
+
+#define BLINK_TIMES 8
+#define DEFAULT_SLEEP_INTERVAL 1000
+#define BLINK_SLEEP_INTERVAL    200
+#define DEFAULT_LOOP 5
+
+mbox_t mbox[5];
+
+int ReadLine(FILE *, char *, char *, int *);
+int Read_Config_File(char *, int *);
+int count_mail(int);
+void parse_cmd(int, char **, char *);
+void init_biff(char *);
+void displayMsgCounters(int, int, int *, int *);
+
+void usage(void);
+void printversion(void);
+void do_biff(int argc, char **argv);
+void parse_mbox_path(int item);
+void BlitString(char *name, int x, int y, int new);
+void BlitNum(int num, int x, int y, int new);
+void ClearDigits(int i);
+void XSleep(int millisec);
+void sigchld_handler(int sig);
+
+
+void init_biff(char *uconfig_file)
+{
+	int i, j, loopinterval = DEFAULT_LOOP;
+	char config_file[256];
+	char *m;
+
+	for (i = 0; i < 5; i++) {
+		mbox[i].label[0] = 0;
+		mbox[i].path[0] = 0;
+		mbox[i].notify[0] = 0;
+		mbox[i].action[0] = 0;
+		mbox[i].fetchcmd[0] = 0;
+		mbox[i].loopinterval = 0;
+	}
+
+	/* Some defaults, if config file is unavailable */
+	strcpy(mbox[0].label, "Spool");
+	if ((m = getenv("MAIL")) != NULL) {
+		strcpy(mbox[0].path, m);
+	} else if ((m = getenv("USER")) != NULL) {
+		strcpy(mbox[0].path, "/var/spool/mail/");
+		strcat(mbox[0].path, m);
+	}
+
+	/* Read config file */
+	if (uconfig_file[0] != 0) {
+		/* user-specified config file */
+		fprintf(stderr, "Using user-specified config file '%s'.\n",
+				uconfig_file);
+		strcpy(config_file, uconfig_file);
+	} else
+		sprintf(config_file, "%s/.wmbiffrc", getenv("HOME"));
+
+#ifdef DEBUG
+	printf("config_file = %s.\n", config_file);
+#endif
+
+	if (!Read_Config_File(config_file, &loopinterval)) {
+		if (m == NULL) {
+			fprintf(stderr, "Cannot open '%s' nor use the "
+					"MAIL environment var.\n", uconfig_file);
+			exit(1);
+		}
+		/* we are using MAIL environment var. type mbox */
+		fprintf(stderr, "Using MAIL environment var '%s'.\n", m);
+		mboxCreate((&mbox[0]), mbox[0].path);
+	}
+
+	/* Make labels look right */
+	for (i = 0; i < 5; i++) {
+		if (mbox[i].label[0] != 0) {
+			j = strlen(mbox[i].label);
+			if (j < 5) {
+				memset(mbox[i].label + j, ' ', 5 - j);
+			}
+			mbox[i].label[5] = ':';
+			mbox[i].label[6] = 0;
+			/* set global loopinterval to boxes with 0 loop */
+			if (!mbox[i].loopinterval) {
+				mbox[i].loopinterval = loopinterval;
+			}
+		}
+	}
+}
+
+void do_biff(int argc, char **argv)
+{
+	int i;
+	XEvent Event;
+	int but_stat = -1;
+	time_t curtime;
+	int NeedRedraw = 0;
+	int Sleep_Interval = DEFAULT_SLEEP_INTERVAL;	/* Default sleep time (in msec) */
+	int Blink_Mode = 0;			/* Bit mask, digits are in blinking mode or not.
+								   Each bit for separate mailbox */
+
+
+	createXBMfromXPM(wmbiff_mask_bits, wmbiff_master_xpm,
+					 wmbiff_mask_width, wmbiff_mask_height);
+
+	openXwindow(argc, argv, wmbiff_master_xpm, wmbiff_mask_bits,
+				wmbiff_mask_width, wmbiff_mask_height);
+
+	AddMouseRegion(0, 5, 6, 58, 16);
+	AddMouseRegion(1, 5, 16, 58, 26);
+	AddMouseRegion(2, 5, 26, 58, 36);
+	AddMouseRegion(3, 5, 36, 58, 46);
+	AddMouseRegion(4, 5, 46, 58, 56);
+
+#if 0
+	copyXPMArea(39, 84, (3 * CHAR_WIDTH), 8, 39, 5);
+	copyXPMArea(39, 84, (3 * CHAR_WIDTH), 8, 39, 16);
+	copyXPMArea(39, 84, (3 * CHAR_WIDTH), 8, 39, 27);
+	copyXPMArea(39, 84, (3 * CHAR_WIDTH), 8, 39, 38);
+	copyXPMArea(39, 84, (3 * CHAR_WIDTH), 8, 39, 49);
+
+	BlitString("XX", 45, 5, 0);
+	BlitString("XX", 45, 16, 0);
+	BlitString("XX", 45, 27, 0);
+	BlitString("XX", 45, 38, 0);
+	BlitString("XX", 45, 49, 0);
+#endif
+
+	/* Initially read mail counters and resets,
+	   and initially draw labels and counters */
+	curtime = time(0);
+	for (i = 0; i < 5; i++) {
+		if (mbox[i].label[0] != 0) {
+			mbox[i].prevtime = mbox[i].prevfetch_time = curtime;
+			BlitString(mbox[i].label, 5, (11 * i) + 5, 0);
+			displayMsgCounters(i, count_mail(i), &Sleep_Interval,
+							   &Blink_Mode);
+#ifdef DEBUG
+			printf("[%d].label=>%s<\n[%d].path=>%s<\n\n", i,
+				   mbox[i].label, i, mbox[i].path);
+#endif
+		}
+	}
+
+	RedrawWindow();
+
+	NeedRedraw = 0;
+	while (1) {
+		/* waitpid(0, NULL, WNOHANG); */
+
+		for (i = 0; i < 5; i++) {
+			if (mbox[i].label[0] != 0) {
+				curtime = time(0);
+				if (curtime >= mbox[i].prevtime + mbox[i].loopinterval) {
+					NeedRedraw = 1;
+					mbox[i].prevtime = curtime;
+					displayMsgCounters(i, count_mail(i), &Sleep_Interval,
+									   &Blink_Mode);
+#ifdef DEBUG
+					printf("[%d].label=>%s<\n[%d].path=>%s<\n\n",
+						   i, mbox[i].label, i, mbox[i].path);
+					printf("curtime=%d, prevtime=%d, interval=%d\n",
+						   (int) curtime,
+						   (int) mbox[i].prevtime, mbox[i].loopinterval);
+#endif
+				}
+			}
+			if (mbox[i].blink_stat > 0) {
+				if (--mbox[i].blink_stat <= 0) {
+					Blink_Mode &= ~(1 << i);
+					mbox[i].blink_stat = 0;
+				}
+				displayMsgCounters(i, 1, &Sleep_Interval, &Blink_Mode);
+				NeedRedraw = 1;
+#ifdef DEBUG
+				/*printf("i= %d, Sleep_Interval= %d\n", i, Sleep_Interval); */
+#endif
+			}
+			if (Blink_Mode == 0) {
+				mbox[i].blink_stat = 0;
+				Sleep_Interval = DEFAULT_SLEEP_INTERVAL;
+			}
+			if (mbox[i].fetchinterval > 0 && mbox[i].fetchcmd[0] != 0
+				&& curtime >=
+				mbox[i].prevfetch_time + mbox[i].fetchinterval) {
+				execCommand(mbox[i].fetchcmd);
+				mbox[i].prevfetch_time = curtime;
+			}
+		}
+		if (NeedRedraw) {
+			NeedRedraw = 0;
+			RedrawWindow();
+		}
+
+		/* X Events */
+		while (XPending(display)) {
+			XNextEvent(display, &Event);
+			switch (Event.type) {
+			case Expose:
+				RedrawWindow();
+				break;
+			case DestroyNotify:
+				XCloseDisplay(display);
+				exit(0);
+				break;
+			case ButtonPress:
+				i = CheckMouseRegion(Event.xbutton.x, Event.xbutton.y);
+				but_stat = i;
+				break;
+			case ButtonRelease:
+				i = CheckMouseRegion(Event.xbutton.x, Event.xbutton.y);
+				if (but_stat == i && but_stat >= 0) {
+					switch (Event.xbutton.button) {
+					case 1:	/* Left mouse-click */
+						if (mbox[but_stat].action[0] != 0) {
+							execCommand(mbox[but_stat].action);
+						}
+						break;
+					case 3:	/* Right mouse-click */
+						if (mbox[but_stat].fetchcmd[0] != 0) {
+							execCommand(mbox[but_stat].fetchcmd);
+						}
+						break;
+					}
+				}
+				but_stat = -1;
+				/* RedrawWindow(); */
+				break;
+			}
+		}
+		XSleep(Sleep_Interval);
+	}
+}
+
+void displayMsgCounters(int i, int mail_stat, int *Sleep_Interval,
+						int *Blink_Mode)
+{
+	switch (mail_stat) {
+	case 2:					/* New mail has arrived */
+		/* Enter blink-mode for digits */
+		mbox[i].blink_stat = BLINK_TIMES * 2;
+		*Sleep_Interval = BLINK_SLEEP_INTERVAL;
+		*Blink_Mode |= (1 << i);	/* Global blink flag set for this mailbox */
+		ClearDigits(i);			/* Clear digits */
+		if ((mbox[i].blink_stat & 0x01) == 0) {
+			BlitNum(mbox[i].UnreadMsgs, 45, (11 * i) + 5, 1);	/* Yellow digits */
+		}
+		if (mbox[i].notify[0] != 0) {	/* need to call notify() ? */
+			if (!strcasecmp(mbox[i].notify, "beep")) {	/* Internal keyword ? */
+				XBell(display, 100);	/* Yes, bell */
+			} else {
+				execCommand(mbox[i].notify);	/* Else call external notifyer */
+			}
+		}
+
+		/* Autofetch on new mail arrival? */
+		if (mbox[i].fetchinterval == -1 && mbox[i].fetchcmd[0] != 0) {
+			execCommand(mbox[i].fetchcmd);	/* yes */
+		}
+		break;
+	case 1:					/* mailbox has been rescanned/changed */
+		ClearDigits(i);			/* Clear digits */
+		if ((mbox[i].blink_stat & 0x01) == 0) {
+			if (mbox[i].UnreadMsgs > 0) {	/* New mail arrived */
+				BlitNum(mbox[i].UnreadMsgs, 45, (11 * i) + 5, 1);	/* Yellow digits */
+			} else {
+				BlitNum(mbox[i].TotalMsgs, 45, (11 * i) + 5, 0);	/* Cyan digits */
+			}
+		}
+		break;
+	case 0:
+		break;
+	case -1:					/* Error was detected */
+		ClearDigits(i);			/* Clear digits */
+		BlitString("XX", 45, (11 * i) + 5, 0);
+		break;
+	}
+}
+
+/** counts mail in spool-file
+   Returned value:
+   -1 : Error was encountered
+   0  : mailbox status wasn't changed
+   1  : mailbox was changed (NO new mail)
+   2  : mailbox was changed AND new mail has arrived
+**/
+int count_mail(int item)
+{
+	int rc = 0;
+
+	if (!mbox[item].checkMail) {
+		return -1;
+	}
+
+	if (mbox[item].checkMail(&(mbox[item])) < 0) {
+			/* we failed to obtain any numbers
+			 * therefore set them to -1's
+			 * ensuring the next pass (even if zero)
+			 * will be captured correctly
+			 */
+			mbox[item].TotalMsgs = -1;
+			mbox[item].UnreadMsgs = -1;
+			mbox[item].OldMsgs = -1;
+			mbox[item].OldUnreadMsgs = -1;
+			return -1;
+	}
+
+	if (mbox[item].UnreadMsgs > mbox[item].OldUnreadMsgs &&
+		mbox[item].UnreadMsgs > 0) {
+		rc = 2;					/* New mail detected */
+	} else if (mbox[item].UnreadMsgs < mbox[item].OldUnreadMsgs ||
+			   mbox[item].TotalMsgs != mbox[item].OldMsgs) {
+		rc = 1;					/* mailbox was changed - NO new mail */
+	} else {
+		rc = 0;					/* mailbox wasn't changed */
+	}
+	mbox[item].OldMsgs = mbox[item].TotalMsgs;
+	mbox[item].OldUnreadMsgs = mbox[item].UnreadMsgs;
+	return rc;
+}
+
+/* Blits a string at given co-ordinates
+   If a ``new'' parameter is given, all digits will be yellow
+*/
+void BlitString(char *name, int x, int y, int new)
+{
+	int i, c, k = x;
+
+	for (i = 0; name[i]; i++) {
+		c = toupper(name[i]);
+		if (c >= 'A' && c <= 'Z') {	/* it's a letter */
+			c -= 'A';
+			copyXPMArea(c * (CHAR_WIDTH + 1), 74,
+						(CHAR_WIDTH + 1), (CHAR_HEIGHT + 1), k, y);
+			k += (CHAR_WIDTH + 1);
+		} else {				/* it's a number or symbol */
+			c -= '0';
+			if (new) {
+				copyXPMArea((c * (CHAR_WIDTH + 1)) + 65, 0,
+							(CHAR_WIDTH + 1), (CHAR_HEIGHT + 1), k, y);
+			} else {
+				copyXPMArea((c * (CHAR_WIDTH + 1)), 64,
+							(CHAR_WIDTH + 1), (CHAR_HEIGHT + 1), k, y);
+			}
+			k += (CHAR_WIDTH + 1);
+		}
+	}
+}
+
+/* Blits number to give coordinates.. two 0's, right justified */
+void BlitNum(int num, int x, int y, int new)
+{
+	char buf[32];
+	int newx = x;
+
+	if (num > 99)
+		newx -= (CHAR_WIDTH + 1);
+	if (num > 999)
+		newx -= (CHAR_WIDTH + 1);
+
+	sprintf(buf, "%02i", num);
+
+	BlitString(buf, newx, y, new);
+}
+
+void ClearDigits(int i)
+{
+	copyXPMArea((10 * (CHAR_WIDTH + 1)), 64, (CHAR_WIDTH + 1),
+				(CHAR_HEIGHT + 1), 35, (11 * i) + 5);
+	copyXPMArea(39, 84, (3 * (CHAR_WIDTH + 1)), (CHAR_HEIGHT + 1), 39, (11 * i) + 5);	/* Clear digits */
+}
+
+/* 	Read a line from a file to obtain a pair setting=value 
+	skips # and leading spaces
+	NOTE: if setting finish with 0, 1, 2, 3 or 4 last char are deleted and
+	index takes its value... if not index will get -1 
+	Returns -1 if no setting=value
+*/
+int ReadLine(FILE * fp, char *setting, char *value, int *index)
+{
+	char buf[BUF_SIZE];
+	char *p, *q;
+	int len, aux;
+
+	*setting = 0;
+	*value = 0;
+
+	if (!fp || feof(fp) || !fgets(buf, BUF_SIZE - 1, fp))
+		return -1;
+
+	len = strlen(buf);
+
+	if (buf[len - 1] == '\n') {
+		buf[len - 1] = 0;		/* strip linefeed */
+	}
+	for (p = (char *) buf; *p != '#' && *p; p++);
+	*p = 0;						/* Strip comments */
+	if (!(p = strtok(buf, "=")))
+		return -1;
+	if (!(q = strtok(NULL, "\n")))
+		return -1;
+	for (; (*p == ' ' || *p == '\t') && *p; p++);	/* Skip leading spaces */
+	for (; (*q == ' ' || *q == '\t') && *q; q++);	/* Skip leading spaces */
+	strcpy(setting, p);
+	strcpy(value, q);
+
+	len = strlen(setting) - 1;
+	if (len > 0) {
+		aux = setting[len] - 48;
+		if (aux > -1 && aux < 5) {
+			setting[len] = 0;
+			*index = aux;
+		}
+	} else
+		*index = -1;
+
+#ifdef DEBUG
+	printf("@%s.%d=%s@\n", setting, *index, value);
+#endif
+	return 1;
+}
+
+void parse_mbox_path(int item)
+{
+	if (!strncasecmp(mbox[item].path, "pop3:", 5)) {	/* pop3 account */
+		pop3Create((&mbox[item]), mbox[item].path);
+	} else if (!strncasecmp(mbox[item].path, "licq:", 5)) {	/* licq history file */
+		licqCreate((&mbox[item]), mbox[item].path);
+	} else if (!strncasecmp(mbox[item].path, "imap:", 5)) {	/* imap4 account */
+		imap4Create((&mbox[item]), mbox[item].path);
+	} else if (!strncasecmp(mbox[item].path, "maildir:", 8)) {	/* maildir */
+		maildirCreate((&mbox[item]), mbox[item].path);
+	} else
+		mboxCreate((&mbox[item]), mbox[item].path);	/* default are mbox */
+}
+
+int Read_Config_File(char *filename, int *loopinterval)
+{
+	FILE *fp;
+	char setting[17], value[250];
+	int index;
+
+	if (!(fp = fopen(filename, "r"))) {
+		perror("Read_Config_File");
+		fprintf(stderr, "Unable to open %s, no settings read.\n",
+				filename);
+		return 0;
+	}
+	while (!feof(fp)) {
+		if (ReadLine(fp, setting, value, &index) == -1)
+			continue;
+		if (!strcmp(setting, "interval")) {
+			*loopinterval = atoi(value);
+		} else if (index == -1)
+			continue;			/* Didn't read any setting.[0-5] value */
+		if (!strcmp(setting, "label.")) {
+			strcpy(mbox[index].label, value);
+		} else if (!strcmp(setting, "path.")) {
+			strcpy(mbox[index].path, value);
+		} else if (!strcmp(setting, "notify.")) {
+			strcpy(mbox[index].notify, value);
+		} else if (!strcmp(setting, "action.")) {
+			strcpy(mbox[index].action, value);
+		} else if (!strcmp(setting, "interval.")) {
+			mbox[index].loopinterval = atoi(value);
+		} else if (!strcmp(setting, "fetchcmd.")) {
+			strcpy(mbox[index].fetchcmd, value);
+		} else if (!strcmp(setting, "fetchinterval.")) {
+			mbox[index].fetchinterval = atoi(value);
+		}
+	}
+	for (index = 0; index < 5; index++)
+		if (mbox[index].label[0] != 0)
+			parse_mbox_path(index);
+	fclose(fp);
+	return 1;
+}
+
+/*
+ * NOTE: this function assumes that the ConnectionNumber() macro
+ *       will return the file descriptor of the Display struct
+ *       (it does under XFree86 and solaris' openwin X)
+ */
+void XSleep(int millisec)
+{
+#ifdef USE_POLL
+	struct pollfd timeout;
+
+	timeout.fd = ConnectionNumber(display);
+	timeout.events = POLLIN;
+
+	poll(&timeout, 1, millisec);
+#else
+	struct timeval to;
+	struct timeval *timeout = NULL;
+	fd_set readfds;
+	int max_fd;
+
+	if (millisec >= 0) {
+		timeout = &to;
+		to.tv_sec = millisec / 1000;
+		to.tv_usec = (millisec % 1000) * 1000;
+	}
+	FD_ZERO(&readfds);
+	FD_SET(ConnectionNumber(display), &readfds);
+	max_fd = ConnectionNumber(display);
+
+	select(max_fd + 1, &readfds, NULL, NULL, timeout);
+#endif
+}
+
+void sigchld_handler(int sig)
+{
+	waitpid(0, NULL, WNOHANG);
+	signal(SIGCHLD, sigchld_handler);
+}
+
+int main(int argc, char *argv[])
+{
+	char uconfig_file[256];
+
+	parse_cmd(argc, argv, uconfig_file);
+	init_biff(uconfig_file);
+	signal(SIGCHLD, sigchld_handler);
+	do_biff(argc, argv);
+	return 0;
+}
+
+void parse_cmd(int argc, char **argv, char *config_file)
+{
+	int i;
+
+	char uconfig_file[256];
+
+	uconfig_file[0] = 0;
+	/* Parse Command Line */
+
+	for (i = 1; i < argc; i++) {
+		char *arg = argv[i];
+
+		if (*arg == '-') {
+			switch (arg[1]) {
+			case 'd':
+				if (strcmp(arg + 1, "display")) {
+					usage();
+					exit(1);
+				}
+				break;
+			case 'g':
+				if (strcmp(arg + 1, "geometry")) {
+					usage();
+					exit(1);
+				}
+				break;
+			case 'v':
+				printversion();
+				exit(0);
+				break;
+			case 'c':
+				if (argc > (i + 1)) {
+					strcpy(uconfig_file, argv[i + 1]);
+					i++;
+				}
+				break;
+			default:
+				usage();
+				exit(0);
+				break;
+			}
+		}
+	}
+	strcpy(config_file, uconfig_file);
+}
+
+void usage(void)
+{
+	fprintf(stderr,
+			"\nwmBiff v" WMBIFF_VERSION
+			" - incoming mail checker\n"
+			"Gennady Belyakov <gb at ccat.elect.ru> and others (see the README file)\n"
+			"\n");
+	fprintf(stderr, "usage:\n");
+	fprintf(stderr, "    -display <display name>\n");
+	fprintf(stderr,
+			"    -geometry +XPOS+YPOS      initial window position\n");
+	fprintf(stderr,
+			"    -c <filename>             use specified config file\n");
+	fprintf(stderr, "    -h                        this help screen\n");
+	fprintf(stderr,
+			"    -v                        print the version number\n");
+	fprintf(stderr, "\n");
+}
+
+void printversion(void)
+{
+	fprintf(stderr, "wmbiff v%s\n", WMBIFF_VERSION);
+}
+
+/* vim:set ts=4: */
diff --git a/wmbiff/wmbiffrc.5 b/wmbiff/wmbiffrc.5
new file mode 100644
index 0000000..d299ad7
--- /dev/null
+++ b/wmbiff/wmbiffrc.5
@@ -0,0 +1,121 @@
+.\" Hey, Emacs!  This is an -*- nroff -*- source file.
+.\" wmbiff.1 and wmbiffrc.5 are copyright 1999-2001 by 
+.\" Jordi Mallach <jordi at debian.org>
+.\"
+.\" This is free documentation, see the latest version of the GNU
+.\" General Public License for copying conditions. There is NO warranty.
+.TH WMBIFFRC 5 "March 12, 2001" "wmbiff"
+
+.SH NAME
+wmbiffrc \- configuration file for
+.BR wmbiff (1)
+
+.SH DESCRIPTION
+\fBWMbiff\fP is a mail notification tool for the WindowMaker and AfterStep
+window managers. It can handle up to 5 mailboxes, and you can define actions
+on mouse clicks for the different mailboxes. This manpage explains the
+different options which can be specified in a user's wmbiffrc.
+
+.SH OPTIONS
+Each option takes the form
+.IR option[.mbox] " = " value .
+Comment must be preceeded by pound signs (#).
+
+The supported configuration options are:
+
+.TP
+\fBinterval\fP
+Global interval between mailbox checking. Value is the number of seconds, 5
+is the default.
+.TP
+\fBlabel.n\fP
+Specifies the displayed label for a mailbox. It can be up to five characters
+long.
+.TP
+\fBpath.n\fP
+Path to the mailbox, local or remote one. Path lines start with a prefix,
+which specifies the type of wmbiff box you're setting up. The following types
+are supported:
+.RS
+.TP
+.I mbox
+This is a local mbox mailbox. After the prefix, you only need to put the
+path to the mailbox wmbiff needs to read.  This is also the default.
+.RS
+mbox:/path/to/mail/debian-devel
+.RS
+- or -
+.RE
+/path/to/mail/debian-devel
+.RE
+.TP
+.I maildir
+\fBMaildir mailboxes are now supported!\fP
+This works just like \fImbox\fP above.  After the prefix, you need to put
+the path to the maildir wmbiff will read.
+.RS
+maildir:/path/to/mail/bugtraq/
+.RE
+.TP
+.I pop3
+Using this type, wmbiff will fetch mail from a pop3 server, using the
+specified username, password, host and an optional port number (defaulting
+to 110). If your passwd contained special character, eg. '@' or ':',
+use another path format.
+.RS
+pop3:user:password at server[:port]
+pop3:user password server[ port] (another format)
+.RE
+.TP
+.I imap
+These are IMAP4 boxes. As with pop3, wmbiff will read a imap4 mbox using
+the given values and will display info about the remote mail. This type
+accepts user, password, host and optional path to mailbox and port number.
+.RS
+imap:user:password at server[/mailbox][:port]
+.RE
+.TP
+.I licq
+With this box type, wmbiff will read the given history file and track the
+number of messages in it. It just needs a path to a given licq history file.
+.RS
+licq:/path/to/.licq/history/file.history
+.RE
+.RE
+.TP
+\fBnotify.n\fP
+Command to be executed on new mail arrival in the given mailbox. Accepts
+the special keyword "beep" to use the pc speaker.
+.TP
+\fBaction.n\fP
+Command to be executed on left mouse click on a mailbox label.
+.TP
+\fBinterval.n\fP
+Per mailbox check interval. Value is the amount of seconds between
+checkings, default is the global interval.
+.TP
+\fBfetchinterval.n\fP
+Interval between mail auto-fetching. Values accept 0 to disable, -1 for
+autofetching on new mail arrival, and positive values for a given interval
+in seconds.
+.TP
+\fBfetchcmd.n\fP
+Command to be executed to fetch mail. If not specified, fetching through
+wmbiff is disabled completely.
+
+.SH FILES
+.TP
+.I ~/.wmbiffrc
+peruser wmbiff configuration file.
+
+.SH AUTHOR
+This manual page was written by Jordi Mallach <jordi at debian.org>,
+originally for the Debian GNU/Linux system (but may be used by others).
+
+.SH SEE ALSO
+.PD 0
+.TP
+\fBwmbiff\fP(1)
+.PP
+\fI/usr/share/doc/wmbiff/examples/sample.wmbiffrc\fP
+(or equivalent on your system)
diff --git a/wmgeneral/list.c b/wmgeneral/list.c
new file mode 100644
index 0000000..f804b2c
--- /dev/null
+++ b/wmgeneral/list.c
@@ -0,0 +1,169 @@
+/* Generic single linked list to keep various information 
+   Copyright (C) 1993, 1994 Free Software Foundation, Inc.
+
+
+Author: Kresten Krab Thorup
+
+Many modifications by Alfredo K. Kojima
+ 
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.  */
+
+/* As a special exception, if you link this library with files compiled with
+   GCC to produce an executable, this does not cause the resulting executable
+   to be covered by the GNU General Public License. This exception does not
+   however invalidate any other reasons why the executable file might be
+   covered by the GNU General Public License.  */
+
+#include "list.h"
+#ifdef HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#include <stdlib.h>
+
+/* Return a cons cell produced from (head . tail) */
+
+INLINE LinkedList* 
+list_cons(void* head, LinkedList* tail)
+{
+  LinkedList* cell;
+
+  cell = (LinkedList*)malloc(sizeof(LinkedList));
+  cell->head = head;
+  cell->tail = tail;
+  return cell;
+}
+
+/* Return the length of a list, list_length(NULL) returns zero */
+
+INLINE int
+list_length(LinkedList* list)
+{
+  int i = 0;
+  while(list)
+    {
+      i += 1;
+      list = list->tail;
+    }
+  return i;
+}
+
+/* Return the Nth element of LIST, where N count from zero.  If N 
+   larger than the list length, NULL is returned  */
+
+INLINE void*
+list_nth(int index, LinkedList* list)
+{
+  while(index-- != 0)
+    {
+      if(list->tail)
+	list = list->tail;
+      else
+	return 0;
+    }
+  return list->head;
+}
+
+/* Remove the element at the head by replacing it by its successor */
+
+INLINE void
+list_remove_head(LinkedList** list)
+{
+  if (!*list) return;  
+  if ((*list)->tail)
+    {
+      LinkedList* tail = (*list)->tail; /* fetch next */
+      *(*list) = *tail;		/* copy next to list head */
+      free(tail);			/* free next */
+    }
+  else				/* only one element in list */
+    {
+      free(*list);
+      (*list) = 0;
+    }
+}
+
+
+/* Remove the element with `car' set to ELEMENT */
+/*
+INLINE void
+list_remove_elem(LinkedList** list, void* elem)
+{
+  while (*list)
+    {
+      if ((*list)->head == elem)
+        list_remove_head(list);
+      *list = (*list ? (*list)->tail : NULL);
+    }
+}*/
+
+INLINE LinkedList *
+list_remove_elem(LinkedList* list, void* elem)
+{
+    LinkedList *tmp;
+    
+    if (list) {
+	if (list->head == elem) {
+	    tmp = list->tail;
+	    free(list);
+	    return tmp;
+	}
+	list->tail = list_remove_elem(list->tail, elem);
+	return list;
+    }
+    return NULL;
+}
+
+
+/* Return element that has ELEM as car */
+
+INLINE LinkedList*
+list_find(LinkedList* list, void* elem)
+{
+  while(list)
+    {
+    if (list->head == elem)
+      return list;
+    list = list->tail;
+    }
+  return NULL;
+}
+
+/* Free list (backwards recursive) */
+
+INLINE void
+list_free(LinkedList* list)
+{
+  if(list)
+    {
+      list_free(list->tail);
+      free(list);
+    }
+}
+
+/* Map FUNCTION over all elements in LIST */
+
+INLINE void
+list_mapcar(LinkedList* list, void(*function)(void*))
+{
+  while(list)
+    {
+      (*function)(list->head);
+      list = list->tail;
+    }
+}
diff --git a/wmgeneral/list.h b/wmgeneral/list.h
new file mode 100644
index 0000000..af0f22c
--- /dev/null
+++ b/wmgeneral/list.h
@@ -0,0 +1,59 @@
+/* Generic single linked list to keep various information 
+   Copyright (C) 1993, 1994 Free Software Foundation, Inc.
+
+Author: Kresten Krab Thorup
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.  */
+
+/* As a special exception, if you link this library with files compiled with
+   GCC to produce an executable, this does not cause the resulting executable
+   to be covered by the GNU General Public License. This exception does not
+   however invalidate any other reasons why the executable file might be
+   covered by the GNU General Public License.  */
+
+#ifndef __LIST_H_
+#define __LIST_H_
+
+#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
+# define INLINE inline
+#else
+# define INLINE
+#endif
+
+typedef struct LinkedList {
+  void *head;
+  struct LinkedList *tail;
+} LinkedList;
+
+INLINE LinkedList* list_cons(void* head, LinkedList* tail);
+
+INLINE int list_length(LinkedList* list);
+
+INLINE void* list_nth(int index, LinkedList* list);
+
+INLINE void list_remove_head(LinkedList** list);
+
+INLINE LinkedList *list_remove_elem(LinkedList* list, void* elem);
+
+INLINE void list_mapcar(LinkedList* list, void(*function)(void*));
+
+INLINE LinkedList*list_find(LinkedList* list, void* elem);
+
+INLINE void list_free(LinkedList* list);
+
+#endif
diff --git a/wmgeneral/misc.c b/wmgeneral/misc.c
new file mode 100644
index 0000000..489c350
--- /dev/null
+++ b/wmgeneral/misc.c
@@ -0,0 +1,37 @@
+/* dock.c- built-in Dock module for WindowMaker
+ * 
+ *  WindowMaker window manager
+ * 
+ *  Copyright (c) 1997 Alfredo K. Kojima
+ * 
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include "list.h"
+#include "misc.h"
+
+extern pid_t
+execCommand(char *command)
+{
+    pid_t pid;
+
+    if ((pid=fork())==0)
+    {
+        execl("/bin/sh", "sh", "-c", command, (char *)0);
+    }
+    return pid;
+}
diff --git a/wmgeneral/misc.h b/wmgeneral/misc.h
new file mode 100644
index 0000000..602e1b7
--- /dev/null
+++ b/wmgeneral/misc.h
@@ -0,0 +1,9 @@
+#ifndef __MISC_H
+#define __MISC_H
+
+#include <unistd.h>
+
+extern void parse_command(char *, char ***, int *);
+
+extern pid_t execCommand(char *);
+#endif /* __MISC_H */
diff --git a/wmgeneral/wmgeneral.c b/wmgeneral/wmgeneral.c
new file mode 100644
index 0000000..56b7bd6
--- /dev/null
+++ b/wmgeneral/wmgeneral.c
@@ -0,0 +1,481 @@
+/*
+	Best viewed with vim5, using ts=4
+
+	wmgeneral was taken from wmppp.
+
+	It has a lot of routines which most of the wm* programs use.
+
+	------------------------------------------------------------
+
+	Author: Martijn Pieterse (pieterse at xs4all.nl)
+
+	---
+	CHANGES:
+    ---
+    14/09/1998 (Dave Clark, clarkd at skyia.com)
+        * Updated createXBMfromXPM routine
+        * Now supports >256 colors
+	11/09/1998 (Martijn Pieterse, pieterse at xs4all.nl)
+		* Removed a bug from parse_rcfile. You could
+		  not use "start" in a command if a label was 
+		  also start.
+		* Changed the needed geometry string.
+		  We don't use window size, and don't support
+		  negative positions.
+	03/09/1998 (Martijn Pieterse, pieterse at xs4all.nl)
+		* Added parse_rcfile2
+	02/09/1998 (Martijn Pieterse, pieterse at xs4all.nl)
+		* Added -geometry support (untested)
+	28/08/1998 (Martijn Pieterse, pieterse at xs4all.nl)
+		* Added createXBMfromXPM routine
+		* Saves a lot of work with changing xpm's.
+	02/05/1998 (Martijn Pieterse, pieterse at xs4all.nl)
+		* changed the read_rc_file to parse_rcfile, as suggested by Marcelo E. Magallon
+		* debugged the parse_rc file.
+	30/04/1998 (Martijn Pieterse, pieterse at xs4all.nl)
+		* Ripped similar code from all the wm* programs,
+		  and put them in a single file.
+
+*/
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <ctype.h>
+#include <stdarg.h>
+
+#include <X11/Xlib.h>
+#include <X11/xpm.h>
+#include <X11/extensions/shape.h>
+
+#include "wmgeneral.h"
+
+  /*****************/
+ /* X11 Variables */
+/*****************/
+
+Window		Root;
+int			screen;
+int			x_fd;
+int			d_depth;
+XSizeHints	mysizehints;
+XWMHints	mywmhints;
+Pixel		back_pix, fore_pix;
+char		*Geometry = "";
+Window		iconwin, win;
+GC			NormalGC;
+XpmIcon		wmgen;
+Pixmap		pixmask;
+
+  /*****************/
+ /* Mouse Regions */
+/*****************/
+
+typedef struct {
+	int		enable;
+	int		top;
+	int		bottom;
+	int		left;
+	int		right;
+} MOUSE_REGION;
+
+MOUSE_REGION	mouse_region[MAX_MOUSE_REGION];
+
+  /***********************/
+ /* Function Prototypes */
+/***********************/
+
+static void GetXPM(XpmIcon *, char **);
+static Pixel GetColor(char *);
+void RedrawWindow(void);
+void AddMouseRegion(int, int, int, int, int);
+int CheckMouseRegion(int, int);
+
+/*******************************************************************************\
+|* parse_rcfile																   *|
+\*******************************************************************************/
+
+void parse_rcfile(const char *filename, rckeys *keys) {
+
+	char	*p,*q;
+	char	temp[128];
+	char	*tokens = " :\t\n";
+	FILE	*fp;
+	int		i,key;
+
+	fp = fopen(filename, "r");
+	if (fp) {
+		while (fgets(temp, 128, fp)) {
+			key = 0;
+			q = strdup(temp);
+			q = strtok(q, tokens);
+			while (key >= 0 && keys[key].label) {
+				if ((!strcmp(q, keys[key].label))) {
+					p = strstr(temp, keys[key].label);
+					p += strlen(keys[key].label);
+					p += strspn(p, tokens);
+					if ((i = strcspn(p, "#\n"))) p[i] = 0;
+					free(*keys[key].var);
+					*keys[key].var = strdup(p);
+					key = -1;
+				} else key++;
+			}
+			free(q);
+		}
+		fclose(fp);
+	}
+}
+
+/*******************************************************************************\
+|* parse_rcfile2															   *|
+\*******************************************************************************/
+
+void parse_rcfile2(const char *filename, rckeys2 *keys) {
+
+	char	*p;
+	char	temp[128];
+	char	*tokens = " :\t\n";
+	FILE	*fp;
+	int		i,key;
+	char	*family = NULL;
+
+	fp = fopen(filename, "r");
+	if (fp) {
+		while (fgets(temp, 128, fp)) {
+			key = 0;
+			while (key >= 0 && keys[key].label) {
+				if ((p = strstr(temp, keys[key].label))) {
+					p += strlen(keys[key].label);
+					p += strspn(p, tokens);
+					if ((i = strcspn(p, "#\n"))) p[i] = 0;
+					free(*keys[key].var);
+					*keys[key].var = strdup(p);
+					key = -1;
+				} else key++;
+			}
+		}
+		fclose(fp);
+	}
+	free(family);
+}
+
+
+/*******************************************************************************\
+|* GetXPM																	   *|
+\*******************************************************************************/
+
+static void GetXPM(XpmIcon *wmgen, char *pixmap_bytes[]) {
+
+	XWindowAttributes	attributes;
+	int					err;
+
+	/* For the colormap */
+	XGetWindowAttributes(display, Root, &attributes);
+
+	wmgen->attributes.valuemask |= (XpmReturnPixels | XpmReturnExtensions);
+
+	err = XpmCreatePixmapFromData(display, Root, pixmap_bytes, &(wmgen->pixmap),
+					&(wmgen->mask), &(wmgen->attributes));
+	
+	if (err != XpmSuccess) {
+		fprintf(stderr, "Not enough free colorcells.\n");
+		exit(1);
+	}
+}
+
+/*******************************************************************************\
+|* GetColor																	   *|
+\*******************************************************************************/
+
+static Pixel GetColor(char *name) {
+
+	XColor				color;
+	XWindowAttributes	attributes;
+
+	XGetWindowAttributes(display, Root, &attributes);
+
+	color.pixel = 0;
+	if (!XParseColor(display, attributes.colormap, name, &color)) {
+		fprintf(stderr, "wm.app: can't parse %s.\n", name);
+	} else if (!XAllocColor(display, attributes.colormap, &color)) {
+		fprintf(stderr, "wm.app: can't allocate %s.\n", name);
+	}
+	return color.pixel;
+}
+
+/*******************************************************************************\
+|* flush_expose																   *|
+\*******************************************************************************/
+
+static int flush_expose(Window w) {
+
+	XEvent 		dummy;
+	int			i=0;
+
+	while (XCheckTypedWindowEvent(display, w, Expose, &dummy))
+		i++;
+
+	return i;
+}
+
+/*******************************************************************************\
+|* RedrawWindow																   *|
+\*******************************************************************************/
+
+void RedrawWindow(void) {
+	
+	flush_expose(iconwin);
+	XCopyArea(display, wmgen.pixmap, iconwin, NormalGC, 
+				0,0, wmgen.attributes.width, wmgen.attributes.height, 0,0);
+	flush_expose(win);
+	XCopyArea(display, wmgen.pixmap, win, NormalGC,
+				0,0, wmgen.attributes.width, wmgen.attributes.height, 0,0);
+}
+
+/*******************************************************************************\
+|* RedrawWindowXY															   *|
+\*******************************************************************************/
+
+void RedrawWindowXY(int x, int y) {
+	
+	flush_expose(iconwin);
+	XCopyArea(display, wmgen.pixmap, iconwin, NormalGC, 
+				x,y, wmgen.attributes.width, wmgen.attributes.height, 0,0);
+	flush_expose(win);
+	XCopyArea(display, wmgen.pixmap, win, NormalGC,
+				x,y, wmgen.attributes.width, wmgen.attributes.height, 0,0);
+}
+
+/*******************************************************************************\
+|* AddMouseRegion															   *|
+\*******************************************************************************/
+
+void AddMouseRegion(int index, int left, int top, int right, int bottom) {
+
+	if (index < MAX_MOUSE_REGION) {
+		mouse_region[index].enable = 1;
+		mouse_region[index].top = top;
+		mouse_region[index].left = left;
+		mouse_region[index].bottom = bottom;
+		mouse_region[index].right = right;
+	}
+}
+
+/*******************************************************************************\
+|* CheckMouseRegion															   *|
+\*******************************************************************************/
+
+int CheckMouseRegion(int x, int y) {
+
+	int		i;
+	int		found;
+
+	found = 0;
+
+	for (i=0; i<MAX_MOUSE_REGION && !found; i++) {
+		if (mouse_region[i].enable &&
+			x <= mouse_region[i].right &&
+			x >= mouse_region[i].left &&
+			y <= mouse_region[i].bottom &&
+			y >= mouse_region[i].top)
+			found = 1;
+	}
+	if (!found) return -1;
+	return (i-1);
+}
+
+/*******************************************************************************\
+|* createXBMfromXPM															   *|
+\*******************************************************************************/
+void createXBMfromXPM(char *xbm, char **xpm, int sx, int sy) {
+
+	int		i,j,k;
+	int		width, height, numcol, depth;
+    int 	zero=0;
+	unsigned char	bwrite;
+    int		bcount;
+    int     curpixel;
+	
+	sscanf(*xpm, "%d %d %d %d", &width, &height, &numcol, &depth);
+
+
+    for (k=0; k!=depth; k++)
+    {
+        zero <<=8;
+        zero |= xpm[1][k];
+    }
+        
+	for (i=numcol+1; i < numcol+sy+1; i++) {
+		bcount = 0;
+		bwrite = 0;
+		for (j=0; j<sx*depth; j+=depth) {
+            bwrite >>= 1;
+
+            curpixel=0;
+            for (k=0; k!=depth; k++)
+            {
+                curpixel <<=8;
+                curpixel |= xpm[i][j+k];
+            }
+                
+            if ( curpixel != zero ) {
+				bwrite += 128;
+			}
+			bcount++;
+			if (bcount == 8) {
+				*xbm = bwrite;
+				xbm++;
+				bcount = 0;
+				bwrite = 0;
+			}
+		}
+	}
+}
+
+/*******************************************************************************\
+|* copyXPMArea																   *|
+\*******************************************************************************/
+
+void copyXPMArea(int x, int y, int sx, int sy, int dx, int dy) {
+
+	XCopyArea(display, wmgen.pixmap, wmgen.pixmap, NormalGC, x, y, sx, sy, dx, dy);
+
+}
+
+/*******************************************************************************\
+|* copyXBMArea																   *|
+\*******************************************************************************/
+
+void copyXBMArea(int x, int y, int sx, int sy, int dx, int dy) {
+
+	XCopyArea(display, wmgen.mask, wmgen.pixmap, NormalGC, x, y, sx, sy, dx, dy);
+}
+
+
+/*******************************************************************************\
+|* setMaskXY																   *|
+\*******************************************************************************/
+
+void setMaskXY(int x, int y) {
+
+	 XShapeCombineMask(display, win, ShapeBounding, x, y, pixmask, ShapeSet);
+	 XShapeCombineMask(display, iconwin, ShapeBounding, x, y, pixmask, ShapeSet);
+}
+
+/*******************************************************************************\
+|* openXwindow																   *|
+\*******************************************************************************/
+void openXwindow(int argc, char *argv[], char *pixmap_bytes[], char *pixmask_bits, int pixmask_width, int pixmask_height) {
+
+	unsigned int	borderwidth = 1;
+	XClassHint		classHint;
+	char			*display_name = NULL;
+	char			*wname = argv[0];
+	XTextProperty	name;
+
+	XGCValues		gcv;
+	unsigned long	gcm;
+
+	char			*geometry = NULL;
+
+	int				dummy=0;
+	int				i, wx, wy;
+
+	for (i=1; argv[i]; i++) {
+		if (!strcmp(argv[i], "-display")) {
+			display_name = argv[i+1];
+			i++;
+		}
+		if (!strcmp(argv[i], "-geometry")) {
+			geometry = argv[i+1];
+			i++;
+		}
+	}
+
+	if (!(display = XOpenDisplay(display_name))) {
+		fprintf(stderr, "%s: can't open display %s\n", 
+						wname, XDisplayName(display_name));
+		exit(1);
+	}
+	screen  = DefaultScreen(display);
+	Root    = RootWindow(display, screen);
+	d_depth = DefaultDepth(display, screen);
+	x_fd    = XConnectionNumber(display);
+
+	/* Convert XPM to XImage */
+	GetXPM(&wmgen, pixmap_bytes);
+
+	/* Create a window to hold the stuff */
+	mysizehints.flags = USSize | USPosition;
+	mysizehints.x = 0;
+	mysizehints.y = 0;
+
+	back_pix = GetColor("white");
+	fore_pix = GetColor("black");
+
+	XWMGeometry(display, screen, Geometry, NULL, borderwidth, &mysizehints,
+				&mysizehints.x, &mysizehints.y,&mysizehints.width,&mysizehints.height, &dummy);
+
+	mysizehints.width = 64;
+	mysizehints.height = 64;
+		
+	win = XCreateSimpleWindow(display, Root, mysizehints.x, mysizehints.y,
+				mysizehints.width, mysizehints.height, borderwidth, fore_pix, back_pix);
+	
+	iconwin = XCreateSimpleWindow(display, win, mysizehints.x, mysizehints.y,
+				mysizehints.width, mysizehints.height, borderwidth, fore_pix, back_pix);
+
+	/* Activate hints */
+	XSetWMNormalHints(display, win, &mysizehints);
+	classHint.res_name = wname;
+	classHint.res_class = wname;
+	XSetClassHint(display, win, &classHint);
+
+	XSelectInput(display, win, ButtonPressMask | ExposureMask | ButtonReleaseMask | PointerMotionMask | StructureNotifyMask);
+	XSelectInput(display, iconwin, ButtonPressMask | ExposureMask | ButtonReleaseMask | PointerMotionMask | StructureNotifyMask);
+
+	if (XStringListToTextProperty(&wname, 1, &name) == 0) {
+		fprintf(stderr, "%s: can't allocate window name\n", wname);
+		exit(1);
+	}
+
+	XSetWMName(display, win, &name);
+
+	/* Create GC for drawing */
+	
+	gcm = GCForeground | GCBackground | GCGraphicsExposures;
+	gcv.foreground = fore_pix;
+	gcv.background = back_pix;
+	gcv.graphics_exposures = 0;
+	NormalGC = XCreateGC(display, Root, gcm, &gcv);
+
+	/* ONLYSHAPE ON */
+
+	pixmask = XCreateBitmapFromData(display, win, pixmask_bits, pixmask_width, pixmask_height);
+
+	XShapeCombineMask(display, win, ShapeBounding, 0, 0, pixmask, ShapeSet);
+	XShapeCombineMask(display, iconwin, ShapeBounding, 0, 0, pixmask, ShapeSet);
+
+	/* ONLYSHAPE OFF */
+
+	mywmhints.initial_state = WithdrawnState;
+	mywmhints.icon_window = iconwin;
+	mywmhints.icon_x = mysizehints.x;
+	mywmhints.icon_y = mysizehints.y;
+	mywmhints.window_group = win;
+	mywmhints.flags = StateHint | IconWindowHint | IconPositionHint | WindowGroupHint;
+
+	XSetWMHints(display, win, &mywmhints);
+
+	XSetCommand(display, win, argv, argc);
+	XMapWindow(display, win);
+
+	if (geometry) {
+		if (sscanf(geometry, "+%d+%d", &wx, &wy) != 2) {
+			fprintf(stderr, "Bad geometry string.\n");
+			exit(1);
+		}
+		XMoveWindow(display, win, wx, wy);
+	}
+}
diff --git a/wmgeneral/wmgeneral.h b/wmgeneral/wmgeneral.h
new file mode 100644
index 0000000..e9d6ca6
--- /dev/null
+++ b/wmgeneral/wmgeneral.h
@@ -0,0 +1,59 @@
+#ifndef WMGENERAL_H_INCLUDED
+#define WMGENERAL_H_INCLUDED
+
+  /***********/
+ /* Defines */
+/***********/
+
+#define MAX_MOUSE_REGION (16)
+
+  /************/
+ /* Typedefs */
+/************/
+
+typedef struct _rckeys rckeys;
+
+struct _rckeys {
+	const char	*label;
+	char		**var;
+};
+
+typedef struct _rckeys2 rckeys2;
+
+struct _rckeys2 {
+	const char	*family;
+	const char	*label;
+	char		**var;
+};
+
+typedef struct {
+	Pixmap			pixmap;
+	Pixmap			mask;
+	XpmAttributes	attributes;
+} XpmIcon;
+
+  /*******************/
+ /* Global variable */
+/*******************/
+
+Display		*display;
+
+  /***********************/
+ /* Function Prototypes */
+/***********************/
+
+void AddMouseRegion(int index, int left, int top, int right, int bottom);
+int CheckMouseRegion(int x, int y);
+
+void openXwindow(int argc, char *argv[], char **, char *, int, int);
+void RedrawWindow(void);
+void RedrawWindowXY(int x, int y);
+
+void createXBMfromXPM(char *, char **, int, int);
+void copyXPMArea(int, int, int, int, int, int);
+void copyXBMArea(int, int, int, int, int, int);
+void setMaskXY(int, int);
+
+void parse_rcfile(const char *, rckeys *);
+
+#endif

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-wmaker/wmbiff.git



More information about the Pkg-wmaker-commits mailing list