Binary files mpg123-shoutcast/mpg123 and mpg123-d/mpg123 differ
diff -ru mpg123-shoutcast/mpg123.h mpg123-d/mpg123.h
--- mpg123-shoutcast/mpg123.h	2003-12-09 09:20:52.000000000 +0100
+++ mpg123-d/mpg123.h	2003-12-09 19:22:05.000000000 +0100
@@ -287,6 +287,8 @@
 extern void readers_mark_pos(struct reader *rds);
 extern void readers_goto_mark(struct reader *rds);
 
+extern int dumpfd;
+extern int firstframe;
 
 /* ------ Declarations from "httpget.c" ------ */
 
diff -ru mpg123-shoutcast/readers.c mpg123-d/readers.c
--- mpg123-shoutcast/readers.c	2003-12-09 13:15:43.000000000 +0100
+++ mpg123-d/readers.c	2003-12-09 19:14:13.000000000 +0100
@@ -90,7 +90,7 @@
               }
 
               if((p = strstr(metabuf, "StreamTitle="))) {
-                int plen;
+                int plen = 0;
                 s = strchr(p, ';');
                 if(*(s-1) == '\'')
                   *(s-1)='\0';
@@ -126,6 +126,15 @@
 
 	  ret = read(fd,buf+cnt,toread);
 
+          if(dumpfd > -1) {
+            if(firstframe == 1)
+              write(dumpfd, buf+cnt, ret);
+            else if(count == 4) { 
+                write(dumpfd, buf+cnt, ret);
+                firstframe = 1;
+            }
+          }
+
 	  if(ret < 0)
 	    return ret;
 	  if(ret == 0)
Binary files mpg123-shoutcast/readers.o and mpg123-d/readers.o differ
diff -ru mpg123-shoutcast/term.c mpg123-d/term.c
--- mpg123-shoutcast/term.c	2000-10-30 18:45:14.000000000 +0100
+++ mpg123-d/term.c	2003-12-09 19:19:31.000000000 +0100
@@ -8,7 +8,10 @@
 #include <sys/time.h>
 #include <sys/types.h>
 #include <sys/wait.h>
-
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <time.h>
 
 
 #include "mpg123.h"
@@ -20,6 +23,9 @@
 static struct termios old_tio;
 static void term_quit(void);
 
+int dumpfd = -1;
+int firstframe;
+
 /* initialze terminal */
 void term_init(void)
 {
@@ -181,6 +187,29 @@
 	case FAST_FORWARD_KEY:
 	  offset+=50;
 	  break;
+        case DUMP_KEY:
+          if(dumpfd > -1) {
+            close(dumpfd);
+            dumpfd = -1;
+            firstframe = 0;
+            fprintf(stderr, "end of dump.\n");
+            break;
+          }
+          else {
+            time_t t=time(NULL);
+            struct tm *tt=gmtime(&t);
+            char path[256], timebuf[12];
+            
+            strftime(timebuf, 12, "%d%m%H%m%S",  tt);
+
+            snprintf(path, 255, "mpg123dump-%s.mp3", timebuf);
+            
+            if((dumpfd = open(path, O_CREAT|O_WRONLY)) == -1)
+              fprintf(stderr, "cen't open file %s to save dump: %s\n", path, strerror(errno));
+            else
+              fprintf(stderr, "start dump to file: %s...\n", path);
+          }
+          break;
 	default:
 	  ;
       }
diff -ru mpg123-shoutcast/term.h mpg123-d/term.h
--- mpg123-shoutcast/term.h	2000-10-30 18:45:14.000000000 +0100
+++ mpg123-d/term.h	2003-12-09 18:29:20.000000000 +0100
@@ -12,6 +12,7 @@
 #define PAUSE_KEY	'p'
 #define QUIT_KEY	'q'
 #define STOP_KEY	's'
+#define DUMP_KEY	'd'
 #define REWIND_KEY	','
 #define FORWARD_KEY	'.'
 /* This is convenient on QWERTZ-keyboards. */
Binary files mpg123-shoutcast/term.o and mpg123-d/term.o differ

