Changeset 466 in ntrip
- Timestamp:
- Jun 6, 2007, 11:44:27 AM (18 years ago)
- Location:
- trunk
- Files:
-
- 10 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ntripserver/NtripLinuxServer.c
r439 r466 1 1 /* 2 * NtripServerLinux.c2 * $Id: NtripLinuxClient.c,v 1.27 2007/05/16 14:16:21 stoecker Exp $ 3 3 * 4 4 * Copyright (c) 2003...2007 … … 10 10 * Designed by Informatik Centrum Dortmund http://www.icd.de 11 11 * 12 * NTRIP is currently an experimental technology.13 12 * The BKG disclaims any liability nor responsibility to any person or 14 13 * entity with respect to any loss or damage caused, or alleged to be … … 41 40 */ 42 41 43 /* 44 * Changes - Version 0.7 45 * Sep 22 2003 Steffen Tschirpke <St.Tschirpke@actina.de> 46 * - socket support 47 * - command line option handling 48 * - error handling 49 * - help screen 50 * 51 * Changes - Version 0.9 52 * Feb 15 2005 Dirk Stoecker <soft@dstoecker.de> 53 * - some minor updates, fixed serial baudrate settings 54 * 55 * Changes - Version 0.10 56 * Apr 05 2005 Dirk Stoecker <soft@dstoecker.de> 57 * - some cleanup and miscellaneous fixes 58 * - replaced non-working simulate with file input (stdin) 59 * - TCP sending now somewhat more stable 60 * - cleanup of error handling 61 * - Modes may be symbolic and not only numeric 62 * 63 * Changes - Version 0.11 64 * Jun 02 2005 Dirk Stoecker <soft@dstoecker.de> 65 * - added SISNeT support 66 * - added UDP support 67 * - cleanup of host and port handling 68 * - added inactivity alarm of 60 seconds 69 * 70 * Changes - Version 0.12 71 * Jun 07 2005 Dirk Stoecker <soft@dstoecker.de> 72 * - added UDP bindmode 73 * 74 * Changes - Version 0.13 75 * Apr 25 2006 Andrea Stuerze <andrea.stuerze@bkg.bund.de> 76 * - added stream retrieval from caster 77 * 78 * Changes - Version 0.14 79 * May 16 2006 Andrea Stuerze <andrea.stuerze@bkg.bund.de> 80 * - bug fixed in base64_encode-function 81 * 82 * Changes - Version 0.15 83 * Jun 02 2006 Georg Weber <georg.weber@bkg.bund.de> 84 * - modification for SISNeT 3.1 protocol 85 * 86 * Changes - Version 0.16 87 * Jul 06 2006 Andrea Stuerze <andrea.stuerze@bkg.bund.de> 88 * - more flexible caster's response 89 * 90 * Changes - Version 0.17 91 * Jul 27 2006 Dirk Stoecker <soft@dstoecker.de> 92 * - fixed some problems with caster download 93 * - some minor cosmetic changes 94 * 95 * Changes - Version 0.18 96 * Oct 30 2006 Andrea Stuerze <andrea.stuerze@bkg.bund.de> 97 * - added possibility to send receiver ID with password 98 * restricted to mode UDPSOCKET and TCPSOCKET. 99 * 100 * Changes - Version 0.19 101 * Nov 30 2006 Andrea Stuerze <andrea.stuerze@bkg.bund.de> 102 * - bug fixed in Mode 2 103 * 104 * Changes - Version 0.20 105 * Feb 13 2007 Dirk Stoecker <soft@dstoecker.de> 106 * - default port changed from 80 to 2101 107 * - fixed illegal memory access 108 * - cleanup of no data alarm timer 109 * - fixed zero byte handling in buffers 110 * 111 */ 42 /* CVS revision and version */ 43 static char revisionstr[] = "$Revision: 1.27 $"; 44 static char datestr[] = "$Date: 2007/05/16 14:16:21 $"; 112 45 113 46 #include <ctype.h> … … 141 74 CASTER = 6, LAST}; 142 75 143 #define VERSION "NTRIP NtripServerLinux/0.20"76 #define AGENTSTRING "NTRIP NtripServerLinux" 144 77 #define BUFSZ 1024 145 78 … … 168 101 static int openserial(const char * tty, int blocksz, int baud); 169 102 static void send_receive_loop(int sock, int fd); 170 static void usage(int );103 static void usage(int, char*); 171 104 static int encode(char *buf, int size, const char *user, const char *pwd); 172 105 … … 230 163 struct sockaddr_in addr; 231 164 165 setbuf(stdout, 0); 166 setbuf(stdin, 0); 167 setbuf(stderr, 0); 168 169 char *a; 170 int i = 0; 171 for(a = revisionstr+11; *a && *a != ' '; ++a) 172 revisionstr[i++] = *a; 173 revisionstr[i] = 0; 174 datestr[0] = datestr[7]; 175 datestr[1] = datestr[8]; 176 datestr[2] = datestr[9]; 177 datestr[3] = datestr[10]; 178 datestr[5] = datestr[12]; 179 datestr[6] = datestr[13]; 180 datestr[8] = datestr[15]; 181 datestr[9] = datestr[16]; 182 datestr[4] = datestr[7] = '-'; 183 datestr[10] = 0; 184 232 185 signal(SIGALRM,sighandler_alarm); 233 186 alarm(ALARMTIME); … … 235 188 if(argc <= 1) 236 189 { 237 usage(2 );190 usage(2, argv[0]); 238 191 exit(1); 239 192 } … … 254 207 { 255 208 fprintf(stderr, "ERROR: can't convert %s to a valid mode\n", optarg); 256 usage(-1 );209 usage(-1, argv[0]); 257 210 } 258 211 break; … … 270 223 { 271 224 fprintf(stderr, "ERROR: unknown SISNeT version %s\n", optarg); 272 usage(-2 );225 usage(-2, argv[0]); 273 226 } 274 227 break; … … 279 232 fprintf(stderr, "ERROR: can't convert %s to valid serial speed\n", 280 233 optarg); 281 usage(1 );234 usage(1, argv[0]); 282 235 } 283 236 break; … … 291 244 fprintf(stderr, 292 245 "ERROR: can't convert %s to a valid HTTP server port\n", optarg); 293 usage(1 );246 usage(1, argv[0]); 294 247 } 295 248 break; … … 327 280 fprintf(stderr, "ERROR: can't convert %s to a valid port number\n", 328 281 optarg); 329 usage(1 );282 usage(1, argv[0]); 330 283 } 331 284 break; … … 341 294 case 'h': /* help */ 342 295 case '?': 343 usage(0 );296 usage(0, argv[0]); 344 297 break; 345 298 default: 346 usage(2 );299 usage(2, argv[0]); 347 300 break; 348 301 } … … 360 313 } 361 314 fprintf(stderr, "\n"); 362 usage(1 ); /* never returns */315 usage(1, argv[0]); /* never returns */ 363 316 } 364 317 … … 429 382 { 430 383 fprintf(stderr, "ERROR: host %s unknown\n", inhost); 431 usage(-2 );384 usage(-2, argv[0]); 432 385 } 433 386 … … 480 433 nBufferBytes=snprintf(szSendBuffer, sizeof(szSendBuffer)-40, 481 434 "GET /%s HTTP/1.0\r\n" 482 "User-Agent: %s \r\n"483 "Authorization: Basic ", stream_name, VERSION);435 "User-Agent: %s/%s\r\n" 436 "Authorization: Basic ", stream_name, AGENTSTRING, revisionstr); 484 437 /* second check for old glibc */ 485 438 if(nBufferBytes > (int)sizeof(szSendBuffer)-40 || nBufferBytes < 0) … … 504 457 nBufferBytes = snprintf(szSendBuffer, sizeof(szSendBuffer), 505 458 "GET /%s HTTP/1.0\r\n" 506 "User-Agent: %s \r\n"507 "\r\n", stream_name, VERSION);459 "User-Agent: %s/%s\r\n" 460 "\r\n", stream_name, AGENTSTRING, revisionstr); 508 461 } 509 462 if((send(gpsfd, szSendBuffer, (size_t)nBufferBytes, 0)) … … 635 588 break; 636 589 default: 637 usage(-1 );590 usage(-1, argv[0]); 638 591 break; 639 592 } … … 645 598 { 646 599 fprintf(stderr, "ERROR: host %s unknown\n", outhost); 647 usage(-2 );600 usage(-2, argv[0]); 648 601 } 649 602 … … 676 629 /* send message to caster */ 677 630 nBufferBytes = sprintf(szSendBuffer, "SOURCE %s /%s\r\nSource-Agent: " 678 VERSION "\r\n\r\n", password, mountpoint);631 "%s/%s\r\n\r\n", password, mountpoint, AGENTSTRING, revisionstr); 679 632 if((send(sock_id, szSendBuffer, (size_t)nBufferBytes, 0)) != nBufferBytes) 680 633 { … … 926 879 __attribute__ ((noreturn)) 927 880 #endif /* __GNUC__ */ 928 void usage(int rc )881 void usage(int rc, char *name) 929 882 { 930 fprintf(stderr, "Usage: " VERSION " [OPTIONS]" COMPILEDATE "\n"); 883 fprintf(stderr, "Version %s (%s) GPL" COMPILEDATE "\nUsage:\n%s [OPTIONS]", 884 revisionstr, datestr, name); 931 885 fprintf(stderr, " Options are: [-] \n"); 932 886 fprintf(stderr, " -a DestinationCaster name or address (default: %s)\n",
Note:
See TracChangeset
for help on using the changeset viewer.