[Pkg-wmaker-commits] [wmbiff] 39/92: Imported Upstream version 0.2

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


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

dtorrance-guest pushed a commit to branch master
in repository wmbiff.

commit 7ae4c21a773b99e4f277eeb67452b1275e75af26
Author: Doug Torrance <dtorrance at monmouthcollege.edu>
Date:   Fri Nov 14 08:19:58 2014 -0600

    Imported Upstream version 0.2
---
 ChangeLog                    |  13 +
 README                       |  81 +++++
 wmbiff/Makefile              |  30 ++
 wmbiff/Pop3Client.c          | 215 +++++++++++++
 wmbiff/Pop3Client.h          |  34 ++
 wmbiff/sample.wmbiffrc       |  54 ++++
 wmbiff/wmbiff-master-led.xpm | 118 +++++++
 wmbiff/wmbiff-master.xpm     |   1 +
 wmbiff/wmbiff.c              | 726 +++++++++++++++++++++++++++++++++++++++++++
 wmgeneral/list.c             | 169 ++++++++++
 wmgeneral/list.h             |  59 ++++
 wmgeneral/misc.c             |  37 +++
 wmgeneral/misc.h             |   9 +
 wmgeneral/wmgeneral.c        | 481 ++++++++++++++++++++++++++++
 wmgeneral/wmgeneral.h        |  59 ++++
 15 files changed, 2086 insertions(+)

diff --git a/ChangeLog b/ChangeLog
new file mode 100644
index 0000000..f9693ad
--- /dev/null
+++ b/ChangeLog
@@ -0,0 +1,13 @@
+  *	v 0.1	17-Nov-1999
+  -	Initial release
+
+  *	v 0.1a	18-Nov-1999
+  -	Some fixes with intialization
+
+  *	v 0.2	26-Nov-1999
+  -	POP3 support added with (auto)fetching
+  -	digits blinking on new mail arrival
+  -	resource wasting lowered
+  -	individual rescan interval for differrent mailboxes
+  -	some bugfixes
+
diff --git a/README b/README
new file mode 100644
index 0000000..54e71a7
--- /dev/null
+++ b/README
@@ -0,0 +1,81 @@
+   
+                                  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 Perez (jordi at sindominio.net)
+   Eugene Bobin (gene at utb.ru)
+   Helmut 'Kolbi' Kolb (office at kolbi.net)
+   Vladimir Popov (pva48 at mail.ru)
+   
+     _________________________________________________________________
+   
+   Any suggestions/bug reports please send to
+   
+    Gennady Belyakov gb at ccat.elect.ru
+
diff --git a/wmbiff/Makefile b/wmbiff/Makefile
new file mode 100644
index 0000000..723e97e
--- /dev/null
+++ b/wmbiff/Makefile
@@ -0,0 +1,30 @@
+prefix=
+BIN=/usr/X11R6/bin
+CONF=/etc
+LIBDIR = -L/usr/X11R6/lib
+LIBS   = -lXpm -lXext -lX11
+CFLAGS = -O2 -Wall
+OBJS =	wmbiff.o Pop3Client.o \
+	../wmgeneral/wmgeneral.o \
+	../wmgeneral/misc.o \
+	../wmgeneral/list.o
+
+
+.c.o:
+	cc -I/usr/X11R6/share/include $(CFLAGS) -c -Wall $< -o $*.o
+
+wmbiff: $(OBJS)
+	cc $(CFLAGS) -o wmbiff $^ $(LIBDIR) $(LIBS)
+	strip wmbiff
+
+all:: wmbiff
+
+clean::
+	for i in $(OBJS) ; do \
+		rm -f $$i ; \
+	done
+	rm -f wmbiff *~ tags
+
+install:: wmbiff
+	cp -f wmbiff $(prefix)$(BIN)/
+	chmod 755 $(prefix)$(BIN)/wmbiff
diff --git a/wmbiff/Pop3Client.c b/wmbiff/Pop3Client.c
new file mode 100644
index 0000000..4d737e0
--- /dev/null
+++ b/wmbiff/Pop3Client.c
@@ -0,0 +1,215 @@
+/* Author : Scott Holden ( scotth at thezone.net )
+ * 
+ * Pop3 Email checker.
+ *
+ * Last Updated : Mar 20, 1999
+ *
+ */
+
+
+#include "Pop3Client.h"
+#include <string.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <netdb.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#undef DEBUG_POP3
+/* #define DEBUG_POP3 */
+
+struct pop3_struct{
+        struct sockaddr_in server;
+        struct hostent *hp;
+        enum   {CONNECTED, NOT_CONNECTED} connected;
+        char   inBuf[1024];
+        int    inBufSize;
+        char   outBuf[1024];
+        int    outBufSize;
+        int    s;
+        char   password[256];
+        char   userName[256];
+	char   serverName[256];
+        int    serverPort;
+        int    localPort;
+        int    numOfMessages;
+        int    numOfUnreadMessages;
+
+};
+
+Pop3 pop3Create(char *str)
+{
+  /* POP3 format: pop3:user:password at server[:port] */
+  Pop3 pc;
+  char *tmp;
+  char *p;
+
+#ifdef DEBUG_POP3
+  printf("pop3: str = '%s'\n", str);
+#endif
+
+  pc = (Pop3)malloc( sizeof(*pc) );
+  if( pc == 0)
+        return 0;
+  strcpy(pc->password , "");
+  strcpy(pc->userName , "");
+  strcpy(pc->serverName , "");
+  pc->connected     = NOT_CONNECTED;
+  pc->serverPort    = 110;
+  pc->localPort     = 0;
+  pc->numOfMessages = 0;
+  pc->numOfUnreadMessages = 0;
+  pc->inBufSize     = 0;
+  pc->outBufSize    = 0;
+  tmp = strdup(str);
+  p = strtok(tmp, ":");				/* cut off ``pop3:'' */
+  p = strtok(NULL, ":");			/* p pointed to username */
+  strcpy(pc->userName, p);
+  p = strtok(NULL, "@");			/* p -> password */
+  strcpy(pc->password, p);
+  p = strtok(NULL, ":");			/* p-> server */
+  strcpy(pc->serverName, p);
+  if( (p = strtok(NULL, ":")) != NULL ) {	/* port selected; p -> port */
+    pc->serverPort = atoi(p);
+  }
+  free(tmp);
+#ifdef DEBUG_POP3
+/*  printf("pop3: mbox[%d].path= '%s'\n", item, mbox[item].path); */
+  printf("pop3: userName= '%s'\n", pc->userName);
+  printf("pop3: password= '%s'\n",pc->password);
+  printf("pop3: serverName= '%s'\n", pc->serverName);
+  printf("pop3: serverPort= '%d'\n", pc->serverPort);
+#endif
+
+  return pc;
+}
+
+int pop3MakeConnection(Pop3 pc)
+{
+    pc->s = socket(AF_INET, SOCK_STREAM, 0 );
+    memset( &pc->server, 0 , sizeof(pc->server));
+    pc->server.sin_family = AF_INET;
+    pc->hp = gethostbyname(pc->serverName);
+    if( pc->hp == 0)
+        return -1;
+    memcpy( &pc->server.sin_addr, pc->hp->h_addr, pc->hp->h_length);
+    pc->server.sin_port = htons(pc->serverPort);
+    if ( connect(pc->s, (struct sockaddr *)&pc->server
+                               , sizeof(pc->server)) < 0 )
+        return -1;
+    pc->connected = CONNECTED;
+   return 0;
+}
+
+int pop3IsConnected(Pop3 pc)
+{
+    if( pc->connected == CONNECTED)
+        return 1;
+    return 0;
+}
+
+int pop3Login(Pop3 pc)
+{
+      int size; 
+      char temp[1024];
+
+      if( pc->connected == NOT_CONNECTED ){
+          fprintf(stderr, "Not Connected To Server '%s:%d'\n", pc->serverName, pc->serverPort);
+          return -1;
+      }
+
+      size = recv(pc->s,&pc->inBuf,1024,0);
+      memset(&temp,0,1024);
+      memcpy(&temp,&pc->inBuf,size);
+      if( temp[0] != '+' ){
+          fprintf(stderr, "Error Logging in (server '%s:%d')\n", pc->serverName, pc->serverPort);
+          return -1;
+      }
+
+      sprintf(pc->outBuf,"USER %s\r\n",pc->userName);
+      send(pc->s, &pc->outBuf,strlen(pc->outBuf),0); 
+      size =recv(pc->s,&pc->inBuf,1024,0);
+      memset(&temp,0,1024);
+      memcpy(&temp,&pc->inBuf,size);
+      if( temp[0] != '+' ){
+          fprintf(stderr, "Invalid User Name '%s@%s:%d'\n", pc->userName, pc->serverName, pc->serverPort);
+          return -1;
+      }
+
+      memset(&pc->outBuf,0,1024);
+      sprintf(pc->outBuf,"PASS %s\r\n",pc->password);
+      send(pc->s, pc->outBuf, strlen(pc->outBuf),0 );
+      size =recv(pc->s,&pc->inBuf,1024,0);
+      memset(&temp,0,1024);
+      memcpy(&temp,&pc->inBuf,size);
+      if( temp[0] != '+' ){
+          fprintf(stderr, "Incorrect Password for user '%s@%s:%d'\n", pc->userName, pc->serverName, pc->serverPort);
+          return -1;
+      }
+
+      return 0;
+}
+
+int pop3CheckMail(Pop3 pc){
+    int size;
+    char temp[1024];
+    char *ptr;
+    if( pc->connected == NOT_CONNECTED )
+        return -1;
+
+     /* Find total number of messages in mail box */
+     sprintf(pc->outBuf,"STAT\r\n");
+     send(pc->s, pc->outBuf, strlen(pc->outBuf),0 );
+     size =recv(pc->s,&pc->inBuf,1024,0);
+     memset(&temp,0,1024);
+     memcpy(&temp,&pc->inBuf,size);
+     ptr = strtok(temp, " ");
+     ptr = strtok( 0," ");
+     pc->numOfMessages = atoi(ptr);
+
+     if( temp[0] != '+' ){
+         fprintf(stderr, "Error Receiving Stats '%s@%s:%d'\n", pc->userName, pc->serverName, pc->serverPort);
+         return -1;
+     }
+
+     sprintf(pc->outBuf,"LAST\r\n");
+     send(pc->s, pc->outBuf, strlen(pc->outBuf),0 );
+     size =recv(pc->s,&pc->inBuf,1024,0);
+     memset(&temp,0,1024);
+     memcpy(&temp,&pc->inBuf,size);
+     ptr = strtok(temp, " ");
+     ptr = strtok( 0," ");
+     pc->numOfUnreadMessages = pc->numOfMessages - atoi(ptr);
+
+     if( temp[0] != '+' ){
+         fprintf(stderr, "Error Receiving Stats '%s@%s:%d'\n", pc->userName, pc->serverName, pc->serverPort);
+         return -1;
+     }
+     return 1;
+
+}
+
+int  pop3GetTotalNumberOfMessages( Pop3 pc ){
+     if( pc != 0 )
+         return pc->numOfMessages;
+     return -1;    
+}
+
+int  pop3GetNumberOfUnreadMessages( Pop3 pc ){
+    if( pc != 0)
+        return pc->numOfUnreadMessages;
+    return -1;
+}
+
+int pop3Quit(Pop3 pc){
+    int size;
+    if( pc->connected == NOT_CONNECTED )
+        return -1;
+    send(pc->s, "quit\r\n", 6,0 );
+    size =recv(pc->s,&pc->inBuf,1024,0);
+    pc->connected = NOT_CONNECTED;
+    return 0;
+
+}
diff --git a/wmbiff/Pop3Client.h b/wmbiff/Pop3Client.h
new file mode 100644
index 0000000..829c85c
--- /dev/null
+++ b/wmbiff/Pop3Client.h
@@ -0,0 +1,34 @@
+/* Author : Scott Holden ( scotth at thezone.net )
+ *
+ * Pop3 Email Checker
+ *
+ * Last Updated : Mar 20, 1999
+ *
+ */
+
+
+#ifndef POP3CLIENT
+#define POP3CLIENT
+
+#include <string.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <netdb.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+
+typedef struct pop3_struct *Pop3;
+
+Pop3 pop3Create(char *str);
+int  pop3MakeConnection( Pop3 pc);
+int  pop3IsConnected(Pop3 pc);
+int  pop3Login(Pop3 pc);
+int  pop3Quit(Pop3 pc);
+int  pop3CheckMail(Pop3 pc);
+int  pop3GetTotalNumberOfMessages( Pop3 pc );
+int  pop3GetNumberOfUnreadMessages( Pop3 pc );
+
+#endif
diff --git a/wmbiff/sample.wmbiffrc b/wmbiff/sample.wmbiffrc
new file mode 100644
index 0000000..3d9a066
--- /dev/null
+++ b/wmbiff/sample.wmbiffrc
@@ -0,0 +1,54 @@
+# Global interval -- seconds between check mailboxes
+interval=5
+
+### 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
+
+###
+
+label.1 = KSI
+path.1=/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.2=fmeat
+path.2=/home/gb/mail/20_FreshMeat
+notify.2=my_play /home/gb/sounds/new_mail_has_arrived.wav
+action.2=rxvt -name mutt -e mutt -f /home/gb/mail/20_FreshMeat
+
+label.3=nftp
+# 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
+
+
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-master.xpm b/wmbiff/wmbiff-master.xpm
new file mode 120000
index 0000000..59729ba
--- /dev/null
+++ b/wmbiff/wmbiff-master.xpm
@@ -0,0 +1 @@
+wmbiff-master-led.xpm
\ No newline at end of file
diff --git a/wmbiff/wmbiff.c b/wmbiff/wmbiff.c
new file mode 100644
index 0000000..08652c8
--- /dev/null
+++ b/wmbiff/wmbiff.c
@@ -0,0 +1,726 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <time.h>
+#include <utime.h>
+#include <string.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <ctype.h>
+#include <errno.h>
+#include <signal.h>
+
+#include <sys/wait.h>
+#include <sys/stat.h>
+#include <sys/param.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <sys/socket.h>
+
+#include <X11/Xlib.h>
+#include <X11/xpm.h>
+#include <X11/extensions/shape.h>
+
+#include "../wmgeneral/wmgeneral.h"
+#include "../wmgeneral/misc.h"
+
+#include "Pop3Client.h"
+
+#include "wmbiff-master.xpm"
+char wmbiff_mask_bits[64*64];
+int  wmbiff_mask_width = 64;
+int  wmbiff_mask_height = 64;
+
+#define WMBIFF_VERSION "0.2"
+
+#define CHAR_WIDTH  5
+#define CHAR_HEIGHT 7
+
+#define BUFFER_SIZE 1024
+
+#define BLINK_TIMES 8
+#define DEFAULT_SLEEP_INTERVAL 1000
+#define BLINK_SLEEP_INTERVAL    200
+
+#define FROM_STR   "From "
+#define STATUS_STR "Status: R"
+
+#undef DEBUG
+#undef DEBUG_MAIL_COUNT
+#undef DEBUG_POP3
+
+int loopinterval=5;	/* Default rescan interval, in seconds */
+int Sleep_Interval = DEFAULT_SLEEP_INTERVAL;	/* Default sleep time, in milliseconds */
+int Blink_Mode = 0;	/* Bit mask, digits are ib blinking mode or not. Each bit for separate mailbox */
+
+typedef struct {
+  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 */
+  time_t ctime;
+  time_t mtime;
+  size_t size;
+  Pop3 pc;
+  time_t prevtime;
+  time_t prevfetch_time;
+  int  loopinterval;	/* loop interval for this mailbox */
+} mbox_t;
+
+mbox_t mbox[5];
+
+char uconfig_file[256];
+
+void usage(void);
+void printversion(void);
+void parse_cmd(int argc, char **argv);
+void init_biff(int argc, char **argv);
+void do_biff(int argc, char **argv);
+void displayMsgCounters(int i, int mail_stat);
+int  ReadConfigInt(FILE *fp, char *setting, int *value);
+int  ReadConfigString(FILE *fp, char *setting, char *value);
+int  Read_Config_File( char *filename );
+void parse_mbox_path(int item);
+FILE *open_mailbox_file(char *file);
+int  count_mail(int item, int init);
+void count_messages(FILE *file, 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 BlinkOn(int i);
+void BlinkOff(int i);
+void BlinkToggle(int i);
+void XSleep(int millisec);
+void sigchld_handler(int sig);
+
+
+void init_biff(int argc, char **argv)
+{
+  int	i,j;
+  char	config_file[512];
+  char  *m;
+
+  /* Some defaults, if config file 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);
+  }
+  mbox[0].notify[0]=0;
+  mbox[0].action[0]=0;
+  mbox[0].fetchcmd[0]=0;
+  mbox[0].pc=NULL;
+  mbox[0].loopinterval=loopinterval;
+  mbox[0].OldMsgs = mbox[0].OldUnReadMsgs = -1;
+  for(i=1; 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].pc = NULL;
+    mbox[i].loopinterval=loopinterval;
+    mbox[i].OldMsgs = mbox[i].OldUnReadMsgs = -1;
+  }
+
+  /* Read config file */
+  if (uconfig_file[0] != 0) {
+    /* user-specified config file */
+    fprintf(stderr, "Using user-specified config file '%s'.\n", uconfig_file);
+    Read_Config_File(uconfig_file);
+  }
+  else {
+    sprintf(config_file, "%s/.wmbiffrc", getenv("HOME"));
+    if (!Read_Config_File(config_file) || m == NULL) {
+      fprintf(stderr, "Cannot open '%s' nor use the MAIL environment var.\n", uconfig_file);
+      exit(1);
+    }
+  }
+
+  /* Make labels looks correctly */
+  for(i=0; i<5; i++) {
+    if(mbox[i].label[0] != 0) {
+      for(j=0; j<5; j++)
+	if(mbox[i].label[j] == 0)
+	  mbox[i].label[j] = ' ';
+      mbox[i].label[5]=':';
+      mbox[i].label[6]=0;
+    }
+  }
+}
+
+void do_biff(int argc, char **argv)
+{
+  int	i;
+  XEvent Event;
+  int	but_stat = -1;
+  time_t curtime;
+  int	NeedRedraw = 0;
+  
+  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);
+
+/*  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); */
+
+  /* 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, 1));
+#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, 0));
+#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",curtime, mbox[i].prevtime,mbox[i].loopinterval);
+#endif
+	}
+      }
+      if(mbox[i].blink_stat > 0) {
+	BlinkToggle(i);
+	displayMsgCounters(i, 1);
+	NeedRedraw = 1;
+	/**/printf("i= %d, Sleep_Interval= %d\n", i, Sleep_Interval);
+      }
+      if(Blink_Mode == 0) {
+	BlinkOff(i);
+      }
+      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)
+{
+  switch( mail_stat) {
+  case 2:						/* New mail has arrived */
+    BlinkOn(i);						/* Enter blink-mode for digits */
+    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 */
+    }
+    if(mbox[i].fetchinterval == -1 && mbox[i].fetchcmd[0] != 0)	/* Autofetch on new mail arrival ? */
+      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;
+  }
+}
+
+FILE *open_mailbox_file (char *file)
+{
+  FILE *mailbox;
+
+  if ( (mailbox = fopen(file, "r")) == NULL ) {
+    fprintf(stderr,"wmbiff: Error opening mailbox '%s': %s\n", file, strerror(errno));
+  }
+  return (mailbox);
+}
+                             
+/** counts mail in spool-file
+   if "init" is >0, messages counted even if mailbox isn't changed (for unix-style)
+   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 init)
+{
+  struct stat	  st;
+  struct utimbuf  ut;
+  FILE  *F;
+  int    rc = 0;
+
+#ifdef DEBUG_MAIL_COUNT
+  printf(">Mailbox: '%s'\n",mbox[item].path);
+#endif
+  if(mbox[item].pc == NULL) {		/* ubix-style mailbox */
+    if(stat(mbox[item].path, &st)) {
+/*      if( errno != ENOENT )  */
+	fprintf(stderr,"wmbiff: Can't stat mailbox '%s': %s\n", mbox[item].path, strerror(errno));
+      return -1;			/* Error stating mailbox */
+    }
+
+    if(st.st_mtime != mbox[item].mtime || st.st_size != mbox[item].size || init > 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",
+	     mbox[item].mtime,st.st_mtime,
+	     mbox[item].size,st.st_size);
+#endif
+      ut.actime  = st.st_atime;
+      ut.modtime = st.st_mtime;
+      F = open_mailbox_file(mbox[item].path);
+      count_messages(F, item);					/* No comments :) */
+      fclose(F);
+      utime(mbox[item].path, &ut);				/* Reset atime for MUTT and something others correctly work */
+      mbox[item].mtime = st.st_mtime;				/* Store new mtime */
+      mbox[item].size  = st.st_size;				/* Store new size */
+    }
+  }
+  else {							/* pop3 */
+    if( pop3MakeConnection(mbox[item].pc) == -1 ) {
+      return -1;
+    }
+    if( pop3Login(mbox[item].pc) == -1 ) {
+      pop3Quit(mbox[item].pc);
+      return -1;
+    }
+    if( (pop3CheckMail(mbox[item].pc)) == -1){
+      pop3Quit(mbox[item].pc);
+      return -1;						/* Error connecting to pop3 server */
+    }
+    else{
+      mbox[item].UnReadMsgs = pop3GetNumberOfUnreadMessages(mbox[item].pc);
+      mbox[item].TotalMsgs  = pop3GetTotalNumberOfMessages(mbox[item].pc);
+#ifdef DEBUG_POP3
+      printf("OLD: %d, TOTAL: %d, NEW: %d\n",mbox[item].OldMsgs,mbox[item].TotalMsgs,mbox[item].UnReadMsgs);
+#endif
+      pop3Quit(mbox[item].pc);
+    }
+  }
+  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;
+}
+
+void count_messages(FILE *file, int item)
+{
+  int is_header = 0;
+  int next_from_is_start_of_header = 1;
+  int count_from = 0, count_status = 0;
+  char buf[BUFFER_SIZE];
+  int len_from = strlen(FROM_STR), len_status = strlen(STATUS_STR);
+
+  while(fgets(buf, BUFFER_SIZE, file)) {
+    if (buf[0] == '\n') {	/* a newline on 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 he 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)) {
+#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
+  mbox[item].TotalMsgs = count_from;
+  mbox[item].UnReadMsgs = count_from-count_status;
+  return;
+}
+
+/* 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(39, 84, (3*(CHAR_WIDTH+1)), (CHAR_HEIGHT+1), 39, (11*i) + 5); /* Clear digits */
+}
+
+void BlinkOn(int i)
+{
+  mbox[i].blink_stat = BLINK_TIMES*2;
+  Sleep_Interval = BLINK_SLEEP_INTERVAL;
+  Blink_Mode |= (1<<i);		/* Global blink flag set for this mailbox */
+}
+
+void BlinkOff(int i)
+{
+  mbox[i].blink_stat = 0;
+  Sleep_Interval = DEFAULT_SLEEP_INTERVAL;
+}
+
+void BlinkToggle(int i)
+{
+  if(--mbox[i].blink_stat <= 0) {
+    Blink_Mode &= ~(1<<i);
+    mbox[i].blink_stat = 0;
+  }
+  
+}
+
+/* ReadConfigSetting */
+int ReadConfigString(FILE *fp, char *setting, char *value)
+{
+  char buf[BUFFER_SIZE];
+  char *p=NULL;
+  int  len, slen;
+
+  if (!fp) return 0;
+  
+  fseek(fp, 0, SEEK_SET);
+
+  while( !feof(fp) ) {
+    if( !fgets(buf, BUFFER_SIZE-1, fp) )
+      break;
+    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 */
+    for( p=(char*)buf; (*p == ' ' || *p == '\t') && *p; p++) ;	/* Skip leading spaces */
+    if( !strncmp(p, setting, slen=strlen(setting)) ) {		/* found our setting */
+      p += slen;						/* point to end of keyword+1 */
+      while( (*p == ' ' || *p == '=' || *p == '\t') && *p ) p++;/* Skip spaces and equal sign */
+      strcpy(value, p);
+      return 1;
+    }
+  }
+  return 0;
+}
+
+int ReadConfigInt(FILE *fp, char *setting, int *value)
+{
+  char buf[BUFFER_SIZE];
+
+  if (ReadConfigString(fp, setting, (char *)buf)) {
+    *value = atoi(buf);
+    return 1;
+  }
+
+  return 0;
+}
+
+void parse_mbox_path(int item)
+{
+  if(!strncasecmp(mbox[item].path,"pop3:",5)) {			/* pop3 account */
+    mbox[item].pc = pop3Create(mbox[item].path);
+    *strchr(mbox[item].path, ':')=0;				/* special keyword ``pop3'' */
+  }
+  else if(!strncasecmp(mbox[item].path,"imap:",5)) {
+    fprintf(stderr, "IMAP protocol does not realized yet.\n");
+    *strchr(mbox[item].path, ':')=0;				/* special keyword ``imap'' */
+  }
+}
+
+int Read_Config_File( char *filename )
+{
+  FILE *fp;
+
+  fp = fopen(filename, "r");
+  if (fp) {
+    ReadConfigInt(   fp,    "interval", &loopinterval);
+
+    ReadConfigString(fp, "label.0",     	mbox[0].label);
+    ReadConfigString(fp, "path.0",      	mbox[0].path);
+    ReadConfigString(fp, "notify.0",    	mbox[0].notify);
+    ReadConfigString(fp, "action.0",    	mbox[0].action);
+    ReadConfigInt(   fp, "interval.0", 	       &mbox[0].loopinterval);
+    ReadConfigString(fp, "fetchcmd.0",  	mbox[0].fetchcmd);
+    ReadConfigInt(   fp, "fetchinterval.0",    &mbox[0].fetchinterval);
+    parse_mbox_path(0);
+
+    ReadConfigString(fp, "label.1",		mbox[1].label);
+    ReadConfigString(fp, "path.1",		mbox[1].path);
+    ReadConfigString(fp, "notify.1",		mbox[1].notify);
+    ReadConfigString(fp, "action.1",		mbox[1].action);
+    ReadConfigInt(   fp, "interval.1", 	       &mbox[1].loopinterval);
+    ReadConfigString(fp, "fetchcmd.1",		mbox[1].fetchcmd);
+    ReadConfigInt(   fp, "fetchinterval.1",    &mbox[1].fetchinterval);
+    parse_mbox_path(1);
+
+    ReadConfigString(fp, "label.2",		mbox[2].label);
+    ReadConfigString(fp, "path.2",		mbox[2].path);
+    ReadConfigString(fp, "notify.2",		mbox[2].notify);
+    ReadConfigString(fp, "action.2",		mbox[2].action);
+    ReadConfigInt(   fp, "interval.2",	       &mbox[2].loopinterval);
+    ReadConfigString(fp, "fetchcmd.2",		mbox[2].fetchcmd);
+    ReadConfigInt(   fp, "fetchinterval.2",    &mbox[2].fetchinterval);
+    parse_mbox_path(2);
+
+    ReadConfigString(fp, "label.3",		mbox[3].label);
+    ReadConfigString(fp, "path.3",		mbox[3].path);
+    ReadConfigString(fp, "notify.3",		mbox[3].notify);
+    ReadConfigString(fp, "action.3",		mbox[3].action);
+    ReadConfigInt(   fp, "interval.3",	       &mbox[3].loopinterval);
+    ReadConfigString(fp, "fetchcmd.3",		mbox[3].fetchcmd);
+    ReadConfigInt(   fp, "fetchinterval.3",    &mbox[3].fetchinterval);
+    parse_mbox_path(3);
+    
+    ReadConfigString(fp, "label.4",		mbox[4].label);
+    ReadConfigString(fp, "path.4",		mbox[4].path);
+    ReadConfigString(fp, "notify.4",		mbox[4].notify);
+    ReadConfigString(fp, "action.4",		mbox[4].action);
+    ReadConfigInt(   fp, "interval.4",	       &mbox[4].loopinterval);
+    ReadConfigString(fp, "fetchcmd.4",		mbox[4].fetchcmd);
+    ReadConfigInt(   fp, "fetchinterval.4",    &mbox[4].fetchinterval);
+    parse_mbox_path(4);
+
+    fclose(fp);
+    return 1;
+  }
+  else {
+    perror("Read_Config_File");
+    fprintf(stderr, "Unable to open %s, no settings read.\n", filename);
+    return 0;
+  }
+}
+/*
+ * 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)
+{
+  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);
+}
+
+void sigchld_handler(int sig)
+{
+  waitpid(0, NULL, WNOHANG);
+  signal(SIGCHLD, sigchld_handler);
+}
+
+int main(int argc, char *argv[])
+{
+    
+  parse_cmd(argc, argv);
+
+  init_biff(argc, argv);
+
+  signal(SIGCHLD, sigchld_handler);
+
+  do_biff(argc, argv);
+
+  return 0;
+}
+
+void parse_cmd(int argc, char **argv)
+{
+  int	i;
+
+  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;
+      }
+    }
+  }
+}
+
+void usage(void)
+{
+  fprintf(stderr, "\nwmBiff v"WMBIFF_VERSION"- incoming mail checker\nGennady Belyakov <gb at ccat.elect.ru>\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);
+}
+
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