Changeset 44 in ntrip
- Timestamp:
- Jul 18, 2006, 10:55:30 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ntripclient/NtripLinuxClient.c
r43 r44 1 1 /* 2 2 Easy example NTRIP client for Linux/Unix. 3 $Id: NtripLinuxClient.c,v 1. 19 2006/07/04 08:05:45stoecker Exp $3 $Id: NtripLinuxClient.c,v 1.20 2006/07/04 12:53:43 stoecker Exp $ 4 4 Copyright (C) 2003-2005 by Dirk Stoecker <soft@dstoecker.de> 5 5 … … 32 32 #include <netinet/in.h> 33 33 #include <sys/socket.h> 34 #include <time.h> 34 35 35 36 /* The string, which is send as agent in HTTP request */ … … 40 41 41 42 /* CVS revision and version */ 42 static char revisionstr[] = "$Revision: 1. 19$";43 static char datestr[] = "$Date: 2006/07/04 08:05:45$";43 static char revisionstr[] = "$Revision: 1.20 $"; 44 static char datestr[] = "$Date: 2006/07/04 12:53:43 $"; 44 45 45 46 struct Args … … 50 51 const char *password; 51 52 const char *data; 53 int bitrate; 52 54 }; 53 55 … … 58 60 #define LONG_OPT(a) a 59 61 static struct option opts[] = { 62 { "bitrate", no_argument, 0, 'b'}, 60 63 { "data", required_argument, 0, 'd'}, 61 64 { "server", required_argument, 0, 's'}, … … 66 69 {0,0,0,0}}; 67 70 #endif 68 #define ARGOPT "-d: hp:r:s:u:"71 #define ARGOPT "-d:bhp:r:s:u:" 69 72 70 73 #ifdef __GNUC__ … … 164 167 args->password = ""; 165 168 args->data = 0; 169 args->bitrate = 0; 166 170 help = 0; 167 171 … … 178 182 case 'p': args->password = optarg; break; 179 183 case 'd': args->data = optarg; break; 184 case 'b': args->bitrate = 1; break; 180 185 case 'h': help=1; break; 181 186 case 1: … … 220 225 " -r " LONG_OPT("--port ") "the server port number (default 80)\n" 221 226 " -u " LONG_OPT("--user ") "the user name\n" 227 " -b " LONG_OPT("--bitrate ") "output bitrate\n" 222 228 "or using an URL:\n%s ntrip:mountpoint[/username[:password]][@server[:port]]\n" 223 229 , revisionstr, datestr, argv[0], argv[0]); … … 359 365 { 360 366 int k = 0; 367 int starttime = time(0); 368 int lastout = starttime; 369 int totalbytes = 0; 361 370 362 371 while((numbytes=recv(sockfd, buf, MAXDATASIZE-1, 0)) != -1) … … 379 388 else 380 389 { 390 totalbytes += numbytes; 391 if(totalbytes < 0) /* overflow */ 392 { 393 totalbytes = 0; 394 starttime = time(0); 395 lastout = starttime; 396 } 381 397 fwrite(buf, (size_t)numbytes, 1, stdout); 382 398 fflush(stdout); 399 if(args.bitrate) 400 { 401 int t = time(0); 402 if(t > lastout + 60) 403 { 404 lastout = t; 405 fprintf(stderr, "Bitrate is %d/s (%d seconds accumulated).\n", 406 totalbytes/(t-starttime), t-starttime); 407 } 408 } 383 409 } 384 410 }
Note:
See TracChangeset
for help on using the changeset viewer.