Index: /trunk/ntripclient/NtripLinuxClient.c
===================================================================
--- /trunk/ntripclient/NtripLinuxClient.c	(revision 43)
+++ /trunk/ntripclient/NtripLinuxClient.c	(revision 44)
@@ -1,5 +1,5 @@
 /*
   Easy example NTRIP client for Linux/Unix.
-  $Id: NtripLinuxClient.c,v 1.19 2006/07/04 08:05:45 stoecker Exp $
+  $Id: NtripLinuxClient.c,v 1.20 2006/07/04 12:53:43 stoecker Exp $
   Copyright (C) 2003-2005 by Dirk Stoecker <soft@dstoecker.de>
     
@@ -32,4 +32,5 @@
 #include <netinet/in.h>
 #include <sys/socket.h>
+#include <time.h>
 
 /* The string, which is send as agent in HTTP request */
@@ -40,6 +41,6 @@
 
 /* CVS revision and version */
-static char revisionstr[] = "$Revision: 1.19 $";
-static char datestr[]     = "$Date: 2006/07/04 08:05:45 $";
+static char revisionstr[] = "$Revision: 1.20 $";
+static char datestr[]     = "$Date: 2006/07/04 12:53:43 $";
 
 struct Args
@@ -50,4 +51,5 @@
   const char *password;
   const char *data;
+  int         bitrate;
 };
 
@@ -58,4 +60,5 @@
 #define LONG_OPT(a) a
 static struct option opts[] = {
+{ "bitrate",    no_argument,       0, 'b'},
 { "data",       required_argument, 0, 'd'},
 { "server",     required_argument, 0, 's'},
@@ -66,5 +69,5 @@
 {0,0,0,0}};
 #endif
-#define ARGOPT "-d:hp:r:s:u:"
+#define ARGOPT "-d:bhp:r:s:u:"
 
 #ifdef __GNUC__
@@ -164,4 +167,5 @@
   args->password = "";
   args->data = 0;
+  args->bitrate = 0;
   help = 0;
 
@@ -178,4 +182,5 @@
     case 'p': args->password = optarg; break;
     case 'd': args->data = optarg; break;
+    case 'b': args->bitrate = 1; break;
     case 'h': help=1; break;
     case 1:
@@ -220,4 +225,5 @@
     " -r " LONG_OPT("--port     ") "the server port number (default 80)\n"
     " -u " LONG_OPT("--user     ") "the user name\n"
+    " -b " LONG_OPT("--bitrate  ") "output bitrate\n"
     "or using an URL:\n%s ntrip:mountpoint[/username[:password]][@server[:port]]\n"
     , revisionstr, datestr, argv[0], argv[0]);
@@ -359,4 +365,7 @@
     {
       int k = 0;
+      int starttime = time(0);
+      int lastout = starttime;
+      int totalbytes = 0;
 
       while((numbytes=recv(sockfd, buf, MAXDATASIZE-1, 0)) != -1)
@@ -379,6 +388,23 @@
         else
         {
+          totalbytes += numbytes;
+          if(totalbytes < 0) /* overflow */
+          {
+            totalbytes = 0;
+            starttime = time(0);
+            lastout = starttime;
+          }
           fwrite(buf, (size_t)numbytes, 1, stdout);
           fflush(stdout);
+          if(args.bitrate)
+          {
+            int t = time(0);
+            if(t > lastout + 60)
+            {
+              lastout = t;
+              fprintf(stderr, "Bitrate is %d/s (%d seconds accumulated).\n",
+              totalbytes/(t-starttime), t-starttime);
+            }
+          }
         }
       }
