Index: /trunk/ntripclient/ntripclient.c
===================================================================
--- /trunk/ntripclient/ntripclient.c	(revision 500)
+++ /trunk/ntripclient/ntripclient.c	(revision 501)
@@ -1,5 +1,5 @@
 /*
   Easy example NTRIP client for POSIX.
-  $Id: ntripclient.c,v 1.32 2007/09/18 10:39:19 stoecker Exp $
+  $Id: ntripclient.c,v 1.33 2007/10/05 15:40:24 stuerze Exp $
   Copyright (C) 2003-2005 by Dirk Stoecker <soft@dstoecker.de>
     
@@ -45,6 +45,6 @@
 
 /* CVS revision and version */
-static char revisionstr[] = "$Revision: 1.32 $";
-static char datestr[]     = "$Date: 2007/09/18 10:39:19 $";
+static char revisionstr[] = "$Revision: 1.33 $";
+static char datestr[]     = "$Date: 2007/10/05 15:40:24 $";
 
 enum MODE { HTTP = 1, RTSP = 2, NTRIP1 = 3, AUTO = 4, END };
@@ -81,4 +81,5 @@
 { "user",       required_argument, 0, 'u'},
 { "nmea",       required_argument, 0, 'n'},
+{ "mode",       required_argument, 0, 'M'},
 { "help",       no_argument,       0, 'h'},
 {0,0,0,0}};
@@ -113,7 +114,7 @@
   static char buf[128];
   char *urlenc = buf;
-  char *bufend = buf + sizeof(buf);
-
-  while(*req && urlenc != bufend)
+  char *bufend = buf + sizeof(buf) - 3;
+
+  while(*req && urlenc < bufend)
   {
     if(isalnum(*req) 
@@ -127,5 +128,6 @@
       *req++;
     }
-  } 
+  }
+  *urlenc = 0;
   return buf;
 }
@@ -292,5 +294,5 @@
     case 'p': args->password = optarg; break;
     case 'd':
-       if(*optarg == '?') 
+       if(optarg && *optarg == '?') 
          args->data = encodeurl(optarg);
        else 
