Index: trunk/ntripserver/NtripLinuxServer.c
===================================================================
--- trunk/ntripserver/NtripLinuxServer.c	(revision 468)
+++ trunk/ntripserver/NtripLinuxServer.c	(revision 469)
@@ -1,4 +1,4 @@
 /*
- * $Id: NtripLinuxServer.c,v 1.28 2007/06/06 09:44:27 stoecker Exp $
+ * $Id: NtripLinuxServer.c,v 1.29 2007/06/06 12:16:08 stoecker Exp $
  *
  * Copyright (c) 2003...2007
@@ -37,6 +37,6 @@
 
 /* CVS revision and version */
-static char revisionstr[] = "$Revision: 1.28 $";
-static char datestr[]     = "$Date: 2007/06/06 09:44:27 $";
+static char revisionstr[] = "$Revision: 1.29 $";
+static char datestr[]     = "$Date: 2007/06/06 12:16:08 $";
 
 #include <ctype.h>
@@ -71,5 +71,5 @@
 CASTER = 6, LAST };
 
-enum OUTMODE { NTRIPV1, HTTP, RTSP, END };
+enum OUTMODE { HTTP = 1, RTSP = 2, NTRIPV1 = 3, END };
 
 #define AGENTSTRING     "NTRIP NtripServerLinux"
@@ -180,6 +180,6 @@
 
   /*** OUTPUT ***/
-  const char *       casterouthost = 0;
-  unsigned int       casteroutport = 0;
+  const char *       casterouthost = NTRIP_CASTER;
+  unsigned int       casteroutport = NTRIP_PORT;
   const char *       outhost = 0;
   unsigned int       outport = 0;
@@ -352,7 +352,19 @@
       proxyport = atoi(optarg);
       break;
-    case 'O': /* OutputMode - default: Ntrip-Version 2.0 TCP/IP */
-      if     (!strcmp(optarg,"f")) outputmode = NTRIPV1;
-      else if(!strcmp(optarg,"r")) outputmode = RTSP;
+    case 'O': /* OutputMode */
+      outputmode = 0;
+      if (!strcmp(optarg,"n") || !strcmp(optarg,"ntrip1"))
+        outputmode = NTRIPV1;
+      else if(!strcmp(optarg,"h") || !strcmp(optarg,"http"))
+        outputmode = HTTP;
+      else if(!strcmp(optarg,"r") || !strcmp(optarg,"rtsp"))
+        outputmode = RTSP;
+      else outputmode = atoi(optarg);
+      if((outputmode == 0) || (outputmode >= END))
+      {
+        fprintf(stderr, "ERROR: can't convert <%s> to a valid OutputMode\n",
+        optarg);
+        usage(-1, argv[0]);
+      }
       break;
     case 'n': /* Destination caster user ID for stream upload to mountpoint */
@@ -504,5 +516,5 @@
       {
         if(!inport) inport = SERV_TCP_PORT;
-        if(!inhost) inhost = "127.0.0.1";
+        if(!inhost) inhost = SERV_HOST_ADDR;
       }
 
@@ -765,6 +777,7 @@
 
     /* connect to Destination caster or Proxy server*/
-    fprintf(stderr, "caster output: host = %s, port = %d, mountpoint = %s\n",
-    inet_ntoa(caster.sin_addr), outport, mountpoint);
+    fprintf(stderr, "caster output: host = %s, port = %d, mountpoint = %s"
+    ", mode = %s\n", inet_ntoa(caster.sin_addr), outport, mountpoint,
+    outputmode == NTRIPV1 ? "ntrip1" : outputmode == HTTP ? "http" : "rtsp");
 
     if(connect(socket_tcp, (struct sockaddr *) &caster, sizeof(caster)) < 0)
@@ -810,4 +823,5 @@
           break;
         }
+#ifndef NDEBUG
         else
         {
@@ -816,4 +830,5 @@
           szSendBuffer);
         }
+#endif
         send_receive_loop(socket_tcp, gpsfd, outputmode, NULL, 0);
         break;
@@ -823,10 +838,10 @@
           "Host: %s\r\n"
           "Ntrip-Version: Ntrip/2.0\r\n"
-          "User-Agent: NTRIP %s\r\n"
+          "User-Agent: %s/%s\r\n"
           "Authorization: Basic %s\r\n"
           "Ntrip-STR: %s\r\n"
           "Transfer-Encoding: chunked\r\n\r\n",
           post_extension, mountpoint, casterouthost, AGENTSTRING,
-          authorization, ntrip_str);
+          revisionstr, authorization, ntrip_str);
         if((nBufferBytes > (int)sizeof(szSendBuffer)) || (nBufferBytes < 0))
         {
@@ -847,5 +862,6 @@
           char *a;
           fprintf(stderr,
-          "ERROR: Destination caster's or Proxy's reply is not OK: ");
+          "ERROR: Destination caster's%s reply is not OK: ",
+          *proxyhost ? " or Proxy's" : "");
           for(a = szSendBuffer; *a && *a != '\n' && *a != '\r'; ++a)
           {
@@ -857,10 +873,10 @@
           {
             fprintf(stderr,
-            " - Ntrip Version 2.0 not implemented at Destination caster"
-            " <%s> or Proxy <%s> or\n"
-            " - HTTP/1.1 not implemented at Proxy or\n"
-            " - RTSP/1.0 not implemented at Destination caster or Proxy\n\n"
-            "caster fallback: Fallback to Ntrip Version 1.0\n\n",
-            casterouthost, proxyhost);
+            " Ntrip Version 2.0 not implemented at Destination caster"
+            " <%s>%s%s%s\n%s\n"
+            "caster fallback: Fallback to Ntrip Version 1.0\n",
+            casterouthost,
+            *proxyhost ? " or Proxy <" : "", proxyhost, *proxyhost ? ">" : "",
+            *proxyhost ? " or HTTP/1.1 not implemented at Proxy\n" : "");
             outputmode = NTRIPV1;
             break;
@@ -910,10 +926,10 @@
           "Ntrip-Version: Ntrip/2.0\r\n"
           "Ntrip-Component: Ntripserver\r\n"
-          "User-Agent: NTRIP %s \r\n"
+          "User-Agent: %s/%s\r\n"
           "Transport: RTP/GNSS;unicast;client_port=%u\r\n"
           "Authorization: Basic %s\r\n"
           "Ntrip-STR: %s\r\n\r\n",
-          casterouthost, rtsp_extension, mountpoint, AGENTSTRING, client_port,
-          authorization, ntrip_str);
+          casterouthost, rtsp_extension, mountpoint, AGENTSTRING, revisionstr,
+          client_port, authorization, ntrip_str);
         if((nBufferBytes > (int)sizeof(szSendBuffer)) || (nBufferBytes < 0))
         {
@@ -936,5 +952,6 @@
             char *a;
             fprintf(stderr,
-            "ERROR: Destination caster's or Proxy's reply is not OK: ");
+            "ERROR: Destination caster's%s reply is not OK: ",
+            *proxyhost ? " or Proxy's" : "");
             for(a = szSendBuffer; *a && *a != '\n' && *a != '\r'; ++a)
             {
@@ -948,8 +965,8 @@
               {
                 fprintf(stderr,
-                " - RTSP not implemented at Destination caster <%s> or"
-                " Proxy <%s>\n\n"
+                " - RTSP not implemented at Destination caster <%s>%s%s%s\n\n"
                 "caster fallback: Fallback to Ntrip Version 2.0 in TCP/IP"
-                " mode\n\n", casterouthost, proxyhost);
+                " mode\n\n", casterouthost,
+                *proxyhost ? " or Proxy <" :"", proxyhost, *proxyhost ? ">":"");
                 outputmode = HTTP;
                 break;
@@ -958,10 +975,12 @@
               {
                 fprintf(stderr,
-                " - Ntrip-Version 2.0 not implemented at Destination caster"
-                "<%s> or Proxy <%s> or\n"
-                " - HTTP/1.1 not implemented at Proxy or\n"
-                " - RTSP/1.0 not implemented at Destination caster or Proxy\n\n"
-                "caster fallback: Fallback to Ntrip Version 1.0\n\n",
-                casterouthost, proxyhost);
+                " Ntrip-Version 2.0 not implemented at Destination caster"
+                "<%s>%s%s%s\n%s"
+                " or RTSP/1.0 not implemented at Destination caster%s\n\n"
+                "caster fallback: Fallback to Ntrip Version 1.0\n",
+                casterouthost, *proxyhost ? " or Proxy <" :"", proxyhost,
+                *proxyhost ? ">":"",
+                *proxyhost ? " or HTTP/1.1 not implemented at Proxy\n" : "",
+                *proxyhost ? " or Proxy" :"");
                 outputmode = NTRIPV1;
                 break;
@@ -974,8 +993,10 @@
             }
           }
+#ifndef NDEBUG
           else
           {
             fprintf(stderr, "Destination caster response:\n%s\n",szSendBuffer);
           }
+#endif
           if((strstr(szSendBuffer,"RTSP/1.0 200 OK\r\n"))
           && (strstr(szSendBuffer,"CSeq: 1\r\n")))
@@ -1175,5 +1196,5 @@
       if(signal_was_caught())
       {
-        fprintf(stderr, "NtripLinuxServer exits send-receive mode \n");
+        fprintf(stderr, "NtripLinuxServer exits send-receive mode\n");
         break;
       }
@@ -1440,7 +1461,8 @@
   fprintf(stderr, "       -W <SourcePass>   Source caster password for input stream access, mandatory\n");
   fprintf(stderr, "                         for protected streams if <InputMode> = 6\n\n");
-  fprintf(stderr, "    -O <OutputMode> Sets the output mode for communatation with the destination\n");
-  fprintf(stderr, "       caster (r = NTRIP Version 2.0 Caster in RTSP/RTP mode, t = Ntrip Version 2.0\n");
-  fprintf(stderr, "       Caster in TCP/IP mode, f = NTRIP Version 1.0 Caster)\n\n");
+  fprintf(stderr, "    -O <OutputMode> Sets output mode for communatation with destination caster\n");
+  fprintf(stderr, "       0 = h = http: Ntrip Version 2.0 Caster in TCP/IP mode\n");
+  fprintf(stderr, "       1 = r = rtsp: NTRIP Version 2.0 Caster in RTSP/RTP mode\n");
+  fprintf(stderr, "       2 = n = ntrip1: NTRIP Version 1.0 Caster\n\n");
   fprintf(stderr, "       Defaults to NTRIP1.0, but wil change to 2.0 in future versions\n");
   fprintf(stderr, "       Note that the program automatically falls back from mode r to mode t and\n");
@@ -1492,5 +1514,5 @@
   fflush(stdout);
   if(sigint_received)
-    fprintf(stderr, "\nSIGINT received: ");
+    fprintf(stderr, "SIGINT received: ");
 
   return (sigint_received);
@@ -1556,5 +1578,5 @@
 static int send_to_caster(char *input, int socket, int input_size)
 {
-int send_error = 1;
+ int send_error = 1;
 
   if((send(socket, input, (size_t)input_size, 0)) != input_size)
@@ -1562,8 +1584,12 @@
     fprintf(stderr, "ERROR: could not send full header to Destination caster\n");
     send_error = 0;
-  }else{
+  }
+#ifndef NDEBUG
+  else
+  {
     fprintf(stderr, "\nDestination caster request:\n");
     fprintf(stderr, "%s", input);
   }
+#endif
   return send_error;
 }/* send_to_caster */
@@ -1587,8 +1613,10 @@
       exit(0);
     }
+#ifndef NDEBUG
     else
     {
       fprintf(stderr, "\nclose input device: successful\n");
     }
+#endif
   }
 
@@ -1611,5 +1639,7 @@
       size_send_buf = recv(sock_tcp, send_buf, sizeof(send_buf), 0);
       send_buf[size_send_buf] = '\0';
+#ifndef NDEBUG
       fprintf(stderr, "Destination caster response:\n%s", send_buf);
+#endif
     }
     if(close(sock_udp)==-1)
@@ -1618,8 +1648,10 @@
       exit(0);
     }
+#ifndef NDEBUG
     else
     {
       fprintf(stderr, "close udp socket:   successful\n");
     }
+#endif
   }
 
@@ -1629,7 +1661,9 @@
     exit(0);
   }
+#ifndef NDEBUG
   else
   {
     fprintf(stderr, "close tcp socket:   successful\n\n");
   }
+#endif
 } /* close_session */
Index: trunk/ntripserver/makefile
===================================================================
--- trunk/ntripserver/makefile	(revision 468)
+++ trunk/ntripserver/makefile	(revision 469)
@@ -2,5 +2,8 @@
 
 NtripServerLinux: NtripLinuxServer.c
-	$(CC) -Wall -W -O3 $? -o $@
+	$(CC) -Wall -W -O3 $? -DNDEBUG -o $@
+
+debug: NtripLinuxServer.c
+	$(CC) -Wall -W -O3 $? -o NtripServerLinux
 
 clean:
