@@ -49,18 +49,19 @@ static const char *help[]={
4949"" ,
5050" usage: str2str [-in stream] [-out stream [-out stream...]] [options]" ,
5151"" ,
52- " Input data from a stream and divide and output them to multiple streams" ,
52+ " Input data from a stream and divide and output them to multiple streams. " ,
5353" The input stream can be serial, tcp client, tcp server, ntrip client, or" ,
54- " file. The output stream can be serial, tcp client, tcp server, ntrip server," ,
55- " or file. str2str is a resident type application. To stop it, type ctr-c in" ,
56- " console if run foreground or send signal SIGINT for background process." ,
57- " if run foreground or send signal SIGINT for background process." ,
58- " if both of the input stream and the output stream follow #format, the" ,
59- " format of input messages are converted to output. To specify the output" ,
60- " messages, use the -msg option before the respective -out options. If the" ,
61- " option -in or -out omitted, stdin for input or stdout for output is used." ,
62- " If the stream in the option -in or -out is null, stdin or stdout is used as" ,
63- " well. Command options are as follows." ,
54+ " a file. The output stream can be serial, tcp client, tcp server, ntrip" ,
55+ " server, or a file. str2str is a resident type application. To stop it, type" ,
56+ " ctr-c in the console if run in the foreground or send signal SIGINT for a" ,
57+ " background process. If both of the input stream and the output stream have a" ,
58+ " #format then the format of the input messages are converted to the output" ,
59+ " format. To specify the output messages use the -msg option before the" ,
60+ " respective -out options. To specify the log file use the -log option before" ,
61+ " a respective -in or -out option, and the streams should have separate" ,
62+ " log files. If the options -in or -out are omitted then stdin for input or" ,
63+ " stdout for output are used. If the stream for the option -in or -out is null,"
64+ " the stdin or stdout are used. Command options are as follows." ,
6465"" ,
6566" -in stream[#format] input stream path and format" ,
6667" -out stream[#format] output stream path and format" ,
@@ -93,6 +94,7 @@ static const char *help[]={
9394"" ,
9495" -msg \"type[(tint)][,type[(tint)]...]\"" ,
9596" rtcm message types and output intervals (s)" ,
97+ " -log file input log file or output return log file"
9698" -sta sta station id" ,
9799" -opt opt receiver dependent options" ,
98100" -s msec timeout time (ms) [10000]" ,
@@ -285,7 +287,7 @@ int main(int argc, char **argv)
285287 strconv_t * conv [MAXSTR ]= {NULL };
286288 double pos [3 ],stapos [3 ]= {0 },stadel [3 ]= {0 };
287289 static char s1 [MAXSTR ][MAXSTRPATH ]= {{0 }},s2 [MAXSTR ][MAXSTRPATH ]= {{0 }};
288- char * paths [MAXSTR ], * logs [ MAXSTR ] ;
290+ char * paths [MAXSTR ];
289291 char * cmdfile [MAXSTR ]= {"" ,"" ,"" ,"" ,"" },* cmds [MAXSTR ],* cmds_periodic [MAXSTR ];
290292 char * local = "" ,* proxy = "" ,* opt = "" ,buff [256 ],* p ;
291293 char strmsg [MAXSTRMSG ]= "" ,* antinfo = "" ,* rcvinfo = "" ;
@@ -296,6 +298,8 @@ int main(int argc, char **argv)
296298 int deamon = 0 ;
297299 const char * msg = "1004,1019" ; // Current messages.
298300 const char * msgs [MAXSTR ]; // Messages per output stream.
301+ const char * log = NULL ; // Log for the next input or output stream.
302+ const char * logs [MAXSTR ];
299303
300304 for (i = 0 ;i < MAXSTR ;i ++ ) {
301305 paths [i ]= s1 [i ];
@@ -307,14 +311,24 @@ int main(int argc, char **argv)
307311 for (i = 1 ;i < argc ;i ++ ) {
308312 if (!strcmp (argv [i ],"-in" )&& i + 1 < argc ) {
309313 if (!decodepath (argv [++ i ],types ,paths [0 ],fmts )) return EXIT_FAILURE ;
314+ // Use the previous specified log file.
315+ logs [0 ] = log ;
316+ log = NULL ;
310317 }
311318 else if (!strcmp (argv [i ],"-msg" )&& i + 1 < argc ) msg = argv [++ i ];
312319 else if (!strcmp (argv [i ],"-out" )&& i + 1 < argc && n < MAXSTR - 1 ) {
313320 if (!decodepath (argv [++ i ],types + n + 1 ,paths [n + 1 ],fmts + n + 1 )) return EXIT_FAILURE ;
314321 // Capture the current messages for this output stream.
315322 msgs [n + 1 ] = msg ;
323+ // Use the previous specified log file.
324+ logs [n + 1 ] = log ;
325+ log = NULL ;
316326 n ++ ;
317327 }
328+ else if (!strcmp (argv [i ], "-log" ) && i + 1 < argc ) {
329+ if (log != NULL ) fprintf (stderr , "Warning log '%s' ignored.\n" , log );
330+ log = argv [++ i ];
331+ }
318332 else if (!strcmp (argv [i ],"-p" )&& i + 3 < argc ) {
319333 pos [0 ]= atof (argv [++ i ])* D2R ;
320334 pos [1 ]= atof (argv [++ i ])* D2R ;
@@ -357,8 +371,13 @@ int main(int argc, char **argv)
357371 }
358372 else if (* argv [i ]== '-' ) printhelp ();
359373 }
360- if (n <=0 ) n = 1 ; /* stdout */
361-
374+ if (n <= 0 ) {
375+ n = 1 ; // stdout
376+ logs [1 ] = log ;
377+ log = NULL ;
378+ }
379+ if (log != NULL ) fprintf (stderr , "Warning log '%s' ignored.\n" , log );
380+
362381 for (i = 0 ;i < n ;i ++ ) {
363382 if (fmts [i + 1 ]<=0 ) continue ;
364383 if (fmts [i + 1 ]!= STRFMT_RTCM3 ) {
0 commit comments