diff -urN mcd-0.3g/Makefile mcd-0.3h/Makefile
--- mcd-0.3g/Makefile	Sat Jul 28 22:03:30 2001
+++ mcd-0.3h/Makefile	Sat Apr 13 20:33:47 2002
@@ -5,9 +5,8 @@
 MANDIR	= /usr/share/man
 BINDIR	= /usr/bin
 
-#CC	= gcc
 CC	= diet gcc
-CFLAGS	= -O2 -Wall -pipe -fomit-frame-pointer
+CFLAGS	= -Os -Wall -pipe -fomit-frame-pointer
 LDFLAGS	= 
 
 S_FLAGS	= -R .note -R .comment
@@ -16,7 +15,7 @@
 OBJS	= $(SRC:.c=.o)
 PRGS	= mcd
 
-all: clean $(PRGS)
+all: $(PRGS)
 
 mcd: $(OBJS)
 	strip -x $(S_FLAGS) $(OBJS)
@@ -29,6 +28,11 @@
 install:
 	cp -f mcd $(BINDIR)
 	cp -f mcd.1 $(MANDIR)/man1 && gzip -f9 $(MANDIR)/man1/mcd.1
+	@echo "You may take a look at \"doc/profile-to-add\" ... "
+
+uninstall:
+	rm -f mcd $(BINDIR)
+	rm -f $(MANDIR)/man1/mcd.1.gz
 
 .c.o:
 	$(CC) $(CFLAGS) -c $< -o $@
diff -urN mcd-0.3g/cddb.c mcd-0.3h/cddb.c
--- mcd-0.3g/cddb.c	Mon Oct  8 15:31:06 2001
+++ mcd-0.3h/cddb.c	Sat Apr 13 19:55:48 2002
@@ -1,6 +1,6 @@
 /*
  * Author strongly advices against using this code, or a part of it,
- * in an application designed to run on any Microsoft(tm) platfrom.
+ * in an application designed to run on any Microsoft(tm) platform.
  *
  * See doc/README for more information about COPYING terms.
  */
@@ -36,9 +36,9 @@
   }
   if (p) { /* parse line */
    if (!strncmp(fn, "DTITLE=", 7))
-    strncpy(cd->t[0].name, fn+7, strlen(fn));
+    str_ncpy(cd->t[0].name, fn+7, str_len(fn));
    if (!strncmp(fn, "TTITLE", 6))
-    strncpy(cd->t[++tr].name, fn+8+(int)(tr/10), strlen(fn));
+    str_ncpy(cd->t[++tr].name, fn+8+(int)(tr/10), str_len(fn));
    p=0;
   }
  } /* while() */
@@ -139,15 +139,14 @@
   cd_discid(&cd[0]),cd->title[1]);
  for (i=1;i<=cd->title[1];i++) {
   len+=_snprintf(tmp, 15, "%d ", cd->t[i].cddb);
-  strncat(h.msg,tmp,strlen(tmp));
+  strncat(h.msg,tmp,str_len(tmp));
  }
  len+=_snprintf(tmp, 15, "%d\n", cd->t[0].cddb);
- strncat(h.msg,tmp,strlen(tmp));
+ strncat(h.msg,tmp,str_len(tmp));
  write(h.fd,h.msg,len);
 
  /* 200 rock a90c9d0c Queen / Innuendo */
- if ((len=cddb_readsocket(h.msg, BUFSIZE, &h.fd))<0)
-  return cddb_abort(&h);
+ if ((len=cddb_readsocket(h.msg, BUFSIZE, &h.fd))<0) return cddb_abort(&h);
  if (strncmp("200",h.msg,3)) return cddb_abort(&h);
  for (i=0;h.msg[i+4]!=' ';i++) tmp[i]=h.msg[i+4]; /* 200 foobar' ' */
  tmp[i]='\0';
@@ -156,8 +155,7 @@
  write(h.fd,h.msg,len);
 
  /* 210 rock a90c9d0c CD database entry follows (until terminating `.') */
- if ((len=cddb_readsocket(h.msg, BUFSIZE, &h.fd))<0)
-  return cddb_abort(&h);
+ if ((len=cddb_readsocket(h.msg, BUFSIZE, &h.fd))<0) return cddb_abort(&h);
  if (strncmp("210",h.msg,3)) return cddb_abort(&h);
  len=_snprintf(h.msg,BUFSIZE,"%s/%08x",getenv("CDDB_PATH"),cd_discid(&cd[0]));
 
diff -urN mcd-0.3g/cddev.c mcd-0.3h/cddev.c
--- mcd-0.3g/cddev.c	Sat Jul 28 01:30:39 2001
+++ mcd-0.3h/cddev.c	Sat Apr 13 20:30:28 2002
@@ -1,6 +1,6 @@
 /*
  * Author strongly advices against using this code, or a part of it,
- * in an application designed to run on any Microsoft(tm) platfrom.
+ * in an application designed to run on any Microsoft(tm) platform.
  *
  * See doc/README for more information about COPYING terms.
  */
@@ -97,7 +97,8 @@
  }
  updates[U_TRACKS]=1;
  cd->title[1]=cdth.cdth_trk1; /* init all these stuff */
- return cddb=cddb_getentries(&cd[0]); /* cddb is returned to draw.c */
+ if ((cddb=wmdb_getentries(&cd[0]))) return cddb;
+ return cddb=cddb_getentries(&cd[0]); /* one of them */
 }
 
 
diff -urN mcd-0.3g/doc/CHANGES mcd-0.3h/doc/CHANGES
--- mcd-0.3g/doc/CHANGES	Thu Jan 10 23:29:50 2002
+++ mcd-0.3h/doc/CHANGES	Sat Apr 13 20:17:00 2002
@@ -1,3 +1,9 @@
+0.3h
+ changed some environment variables ... see mcd.1!
+ workman.c: workman entries parsing
+ cddev.c: tries also workman database entries (thanks leo rosa)
+ str.c added
+
 0.3g
  mcd.c: system("man mcd") :P
 
diff -urN mcd-0.3g/doc/README mcd-0.3h/doc/README
--- mcd-0.3g/doc/README	Thu Jan 10 23:35:23 2002
+++ mcd-0.3h/doc/README	Sat Apr 13 20:31:54 2002
@@ -47,8 +47,8 @@
 - term resizing works correct, since version 0.2 (if not started from mc
   (btw: a new small mc will be my next project ...mmc?)
 - maybe some things of the wishlist... (if someone ask me, i will do it)
-- add a buffer for drawing stuff
-- add a buffer for cddb stuff
+- add a buffer for cddb stuff + fix protocol handling (we need FULL cddb!)
+- add a buffer for drawing
 
 
  WISHLIST
diff -urN mcd-0.3g/doc/profile.to-add mcd-0.3h/doc/profile.to-add
--- mcd-0.3g/doc/profile.to-add	Thu Jan  1 01:00:00 1970
+++ mcd-0.3h/doc/profile.to-add	Sat Apr 13 20:21:04 2002
@@ -0,0 +1,12 @@
+# here are some sample entries for your /etc/profile:
+
+# this is the main device for playing audio cd's
+CDROM='/dev/your-default-cdrom-device'
+
+# IP:PORT - i haven't included any dns bloat in the code
+CDDB_SERVER='194.97.4.18:888'
+
+# you need to create this directory for yourself!
+CDDB_PATH="/home/user/.cddb"
+
+export CDROM CDDB_SERVER CDDB_PATH
diff -urN mcd-0.3g/draw.c mcd-0.3h/draw.c
--- mcd-0.3g/draw.c	Mon Aug 27 09:40:02 2001
+++ mcd-0.3h/draw.c	Sat Apr 13 19:30:57 2002
@@ -1,6 +1,6 @@
 /*
  * Author strongly advices against using this code, or a part of it,
- * in an application designed to run on any Microsoft(tm) platfrom.
+ * in an application designed to run on any Microsoft(tm) platform.
  *
  * See doc/README for more information about COPYING terms.
  */
@@ -104,7 +104,7 @@
   if (x) {
    /* we display only current */
    gotoxy(18,7); _printf("%s" C_NORMAL, cd->t[cd->title[0]].name);
-   for (i=strlen(cd->t[cd->title[0]].name)+19;i<=maxx;i++)
+   for (i=str_len(cd->t[cd->title[0]].name)+19;i<=maxx;i++)
     write(1," ",1);  /* clear old titleinfos */
   } else {
    /* we display all title */
diff -urN mcd-0.3g/formats.c mcd-0.3h/formats.c
--- mcd-0.3g/formats.c	Thu Jul 12 01:27:32 2001
+++ mcd-0.3h/formats.c	Sat Apr 13 19:29:51 2002
@@ -134,7 +134,7 @@
 
       case 's':
         pb=va_arg(arg_ptr,char *);
-        bu_len=strlen(pb);
+        bu_len=str_len(pb);
         if (flag_dot && bu_len>preci) bu_len=preci;
         if ((unsigned long)bu_len>size-apos) bu_len=size-apos;
 
@@ -144,7 +144,7 @@
           {
             for (pad=width-bu_len; pad>0; --pad) str[apos++]=padwith;
           }
-          for(i=0;i<(unsigned long)bu_len;++i) { str[apos++]=pb[i]; } /* strncpy */
+          for(i=0;i<(unsigned long)bu_len;++i) { str[apos++]=pb[i]; }
           if (width && (flag_left))
           { /* left pad ALLWAYS with blanks ... */
             for (pad=width-bu_len; pad>0; --pad) str[apos++]=' ';
diff -urN mcd-0.3g/mcd.1 mcd-0.3h/mcd.1
--- mcd-0.3g/mcd.1	Thu Jan 10 23:28:02 2002
+++ mcd-0.3h/mcd.1	Sat Apr 13 20:14:23 2002
@@ -1,5 +1,5 @@
 .\" Tino Reichardt <der@mcmilk.de>
-.TH MCD 1 "2001-08-27" "mcd-0.3g" "User commands"
+.TH MCD 1 "2002-04-13" "mcd-0.3h" "User commands"
 .SH "NAME"
 mcd \- a small cdplayer for linux
 .SH "SYNOPSIS"
@@ -36,7 +36,7 @@
 .TS
 tab (@);
 l l.
-MCD_CDROM@Try this cdrom as default (if unset, CDROM_DEFAULT
+CDROM@Try this cdrom as default (if unset, CDROM_DEFAULT
 @from params.h is used).
 CDDB_PATH@path to your local cddb files (if unset, _no_ cddb titelinfo
 @is displayed)
@@ -49,6 +49,7 @@
 .TS
 tab (@);
 l l.
+$HOME/.workmandb@Is used (first) for reading wmdb entries.
 $CDDB_PATH/*@Is used for reeading/writing cddb entries.
 .TE
 .SH "RETURN VALUES"
@@ -67,7 +68,8 @@
 .PP
 If you haven't direct access to a freedb server, you may use some
 port redirector program ... see freshmeat.
-.SH "AUTHOR"
+.SH "AUTHORS"
 Tino Reichardt <der@mcmilk.de>
+Leo Rosa <leorosa@feq.unicamp.br> (patch for workman db)
 .PP
 Homepage: http://www.mcmilk.de/projects/mcd/
diff -urN mcd-0.3g/mcd.c mcd-0.3h/mcd.c
--- mcd-0.3g/mcd.c	Thu Jan 10 23:28:54 2002
+++ mcd-0.3h/mcd.c	Sat Apr 13 20:16:29 2002
@@ -1,6 +1,6 @@
 /*
  * Author strongly advices against using this code, or a part of it,
- * in an application designed to run on any Microsoft(tm) platfrom.
+ * in an application designed to run on any Microsoft(tm) platform.
  *
  * See doc/README for more information about COPYING terms.
  */
@@ -16,7 +16,7 @@
 
  if (argc>1) quit=cd_init(argv[1],&cd[0]);
  else { /* try default stuff */
-  if ((argv[1]=getenv("MCD_CDROM"))!=NULL) { /* env */
+  if ((argv[1]=getenv("CDROM"))!=NULL) { /* env */
    quit=cd_init(argv[1],&cd[0]);
   } else {
    quit=cd_init(CDROM_DEFAULT,&cd[0]); /* params.h */
@@ -131,15 +131,8 @@
      draw_status("hey, this isn't valid!",1);
      break;
     }
-   case '1':
-   case '2':
-   case '3':
-   case '4':
-   case '5':
-   case '6':
-   case '7':
-   case '8':
-   case '9':
+   case '1': case '2': case '3': case '4': case '5': case '6':
+   case '7': case '8': case '9':
     if ((pluskey*10)+((int)ch-48)>cd->title[1] || (pluskey*10)+((int)ch-48)<1) break;
     else {
      cd->title[0]=((pluskey*10)+((int)ch-48));
diff -urN mcd-0.3g/mcd.h mcd-0.3h/mcd.h
--- mcd-0.3g/mcd.h	Thu Jan 10 23:28:31 2002
+++ mcd-0.3h/mcd.h	Sat Apr 13 20:07:15 2002
@@ -1,6 +1,6 @@
 /*
  * Author strongly advices against using this code, or a part of it,
- * in an application designed to run on any Microsoft(tm) platfrom.
+ * in an application designed to run on any Microsoft(tm) platform.
  *
  * See doc/README for more information about COPYING terms.
  */
@@ -16,6 +16,7 @@
 #include <stdarg.h>
 #include <termios.h>
 #include <signal.h>
+#include <limits.h>
 
 #include <sys/time.h>
 #include <sys/types.h>
@@ -30,7 +31,7 @@
 
 #include "params.h"
 
-#define MCD_VERSION "0.3g"
+#define MCD_VERSION "0.3h"
 
 /* METHODS */
 #define M_PLAY_CD    0 /* play whole cd and stop */
@@ -45,9 +46,10 @@
 #define U_TRACKS 3 /* all tracks are updated */
 #define U_ALL    4 /* really ALL is updated */
 
-#define CDDB_NOENT  0 /* no local cddb, no remote access*/
-#define CDDB_LOCAL  1 /* local entry is used */
-#define CDDB_REMOTE 2 /* can download from CDDB_SERVER */
+#define CDDB_NOENT   0 /* no local cddb, no remote access*/
+#define CDDB_LOCAL   1 /* local entry is used */
+#define CDDB_REMOTE  2 /* can download from CDDB_SERVER */
+#define CDDB_WORKMAN 3 /* local entry .workman format */
 
 /* ***** */
 /* mcd.c */
@@ -84,6 +86,7 @@
 extern char port[6], ip[16];
 
 extern int cddb_getentries(struct mcd *cd); /* fills cd->t[].name, sets cddb variable */
+extern int wmdb_getentries(struct mcd *cd); /* fills also cd->t[].name */
 
 /* ***** */
 /* tty.c */
@@ -131,5 +134,10 @@
 extern int _snprintf(char *str, size_t size, const char *format, ...);
 extern int _vsnprintf(char *str, size_t size, const char *format, va_list ap);
 extern int _ltostr(char *s, int size, unsigned long i, int base, char UpCase);
+
+/* ***** */
+/* str.c */
+extern size_t str_len(const unsigned char *str);
+extern size_t str_ncpy(unsigned char *dst, const unsigned char *src, size_t n);
 
 #endif /* _MCD_H */
diff -urN mcd-0.3g/mcd.lsm mcd-0.3h/mcd.lsm
--- mcd-0.3g/mcd.lsm	Mon Oct  8 15:31:36 2001
+++ mcd-0.3h/mcd.lsm	Sat Apr 13 20:15:04 2002
@@ -1,11 +1,12 @@
 Begin4
 Title:          mcd
-Version:        0.3f
-Entered-date:   2001-08-06
+Version:        0.3h
+Entered-date:   2002-04-13
 Description:    Is a small cd player application with a curses like
                 interface. Has a track database, supports remote/local cddb
                 track data, different play modes and volume control.
-Keywords:       cd, player, audio, sound, curses, dietlibc, cddb, freedb
+Keywords:       cd, player, audio, sound, curses, dietlibc, cddb, freedb,
+		workmandb
 Author:         Tino Reichardt <der@mcmilk.de>
 Maintained-by:  Tino Reichardt <der@mcmilk.de>
 Primary-site:   sunsite.unc.edu /pub/Linux/apps/sound/cdrom
diff -urN mcd-0.3g/misc.c mcd-0.3h/misc.c
--- mcd-0.3g/misc.c	Tue Jul 24 10:00:54 2001
+++ mcd-0.3h/misc.c	Sat Apr 13 19:30:42 2002
@@ -1,6 +1,6 @@
 /*
  * Author strongly advices against using this code, or a part of it,
- * in an application designed to run on any Microsoft(tm) platfrom.
+ * in an application designed to run on any Microsoft(tm) platform.
  *
  * See doc/README for more information about COPYING terms.
  */
@@ -18,5 +18,5 @@
 }
 
 void mesg(int fd, char *msg) {
- write(fd,msg,strlen(msg));
+ write(fd,msg,str_len(msg));
 }
diff -urN mcd-0.3g/params.h mcd-0.3h/params.h
--- mcd-0.3g/params.h	Mon Aug 27 09:52:21 2001
+++ mcd-0.3h/params.h	Sat Apr 13 19:45:07 2002
@@ -6,7 +6,9 @@
 #ifndef _MCD_PARAMS_H
 #define _MCD_PARAMS_H
 
-#define CDROM_DEFAULT   "/dev/cdrom"
+// #define CDROM_DEFAULT   "/dev/cdrom"         /* !devfs */
+#define CDROM_DEFAULT   "/dev/cdroms/cdrom0" /* devfs */
+
 #define CDDB_CREATMODE  0644 /* used, for new entries */
 
 /* max size a titlename may have
diff -urN mcd-0.3g/str.c mcd-0.3h/str.c
--- mcd-0.3g/str.c	Thu Jan  1 01:00:00 1970
+++ mcd-0.3h/str.c	Sat Apr 13 19:42:19 2002
@@ -0,0 +1,21 @@
+/*
+ * Author strongly advices against using this code, or a part of it,
+ * in an application designed to run on any Microsoft(tm) platform.
+ *
+ * See doc/README for more information about COPYING terms.
+ */
+#include "mcd.h"
+
+size_t str_len(const unsigned char *str) {
+ register size_t n=0;
+ if (!str) return 0;
+ for (n=0; *str; ++str) ++n;
+ return n;
+}
+
+size_t str_ncpy(unsigned char *dst, const unsigned char *src, size_t n) {
+ register unsigned char *d=dst;
+ register const unsigned char *s=src;
+ for (n=0;;n++) { if (!(*d=*s)) break; ++d; ++s; }
+ return n;
+}
diff -urN mcd-0.3g/tty.c mcd-0.3h/tty.c
--- mcd-0.3g/tty.c	Sat Jul 28 03:44:07 2001
+++ mcd-0.3h/tty.c	Sat Apr 13 19:30:31 2002
@@ -1,6 +1,6 @@
 /*
  * Author strongly advices against using this code, or a part of it,
- * in an application designed to run on any Microsoft(tm) platfrom.
+ * in an application designed to run on any Microsoft(tm) platform.
  *
  * See doc/README for more information about COPYING terms.
  */
diff -urN mcd-0.3g/workman.c mcd-0.3h/workman.c
--- mcd-0.3g/workman.c	Thu Jan  1 01:00:00 1970
+++ mcd-0.3h/workman.c	Sat Apr 13 20:32:17 2002
@@ -0,0 +1,62 @@
+/*
+ * Author strongly advices against using this code, or a part of it,
+ * in an application designed to run on any Microsoft(tm) platform.
+ *
+ * See doc/README for more information about COPYING terms.
+ */
+#include "mcd.h"
+
+static short wmdb_testdisk(char *fn, struct mcd *cd);
+
+/* test the disk lenght */
+static short wmdb_testdisk(char *fn, struct mcd *cd) {
+register int pos=0,i=0;
+ while(fn[i++]!='\0')
+  if(fn[i]==' ') pos=i; /* jump spaces */
+ if(atoi(fn+pos)==cd->t[0].cddb) return 1;
+ return 0;
+}
+
+int wmdb_getentries(struct mcd *cd) {
+ char *fn=malloc(sizeof(char)*PATH_MAX);
+ int p=0,tr=0,len,fd; /* p=parse;tr=track */
+ char ch;
+/* i know that there must have a global file, but i don't remember where */
+ len=_snprintf(fn,PATH_MAX-1,"%s/%s",getenv("HOME"),".workmandb");
+ fn[len]='\0';
+ if ((fd=open(fn,O_RDONLY))<0) {
+  free(fn); return CDDB_NOENT;
+ }
+ len=0;
+ while (len+=read(fd,&ch,1)>0) {
+  fn[len-1]=ch;
+  if (ch=='\n'||ch=='\r') {
+   p=1;fn[len-1]='\0';len=0;
+  }
+  if (p) {
+   if (!strncmp(fn, "tracks ", 7))
+    if(wmdb_testdisk(fn,&cd[0]))
+     while (len+=read(fd,&ch,1)>0) { /* this is one possible match */
+      fn[len-1]=ch;
+      if (ch=='\n'||ch=='\r') {
+       p=1;fn[len-1]='\0';len=0;
+      }
+      if (p) {
+       if (!strncmp(fn,"cdname ",7)) {
+        str_ncpy(cd->t[0].name, fn+7, str_len(fn));
+       } else if (!strncmp(fn,"artist ",7)) {
+        strncat(cd->t[0].name," >> ",4);
+        strncat(cd->t[0].name, fn+7, str_len(fn));
+       } else if (!strncmp(fn,"track ", 6)) {
+        str_ncpy(cd->t[++tr].name, fn+6, str_len(fn));
+       } else if (!strncmp(fn,"tracks ", 7)) { break; }
+       p=0;
+      }
+     }
+   p=0;
+  }
+ } /* while() */
+ free(fn);
+ if (tr) return CDDB_WORKMAN;
+ return CDDB_NOENT;
+}
