@@ -154,30 +154,42 @@ static bool validate_log_path(const char* path) {
154154}
155155
156156static void print_help (const char * prog_name ) {
157- LOG_INFO ("Usage: %s --config <file>" , prog_name );
157+ LOG_INFO ("Usage: %s --config <file> [options] " , prog_name );
158158 LOG_INFO ("Options:" );
159- LOG_INFO (" -C, --config <file> JSON config file (required)" );
160- LOG_INFO (" -v, --version Show version" );
161- LOG_INFO (" --help Show this help" );
159+ LOG_INFO (" -C, --config <file> JSON config file (required)" );
160+ LOG_INFO (" -t, --test-time <secs> Transmit for N seconds then exit (1..86400)" );
161+ LOG_INFO (" -v, --version Show version" );
162+ LOG_INFO (" --help Show this help" );
162163}
163164
164165static int parse_args (struct dvledtx_context * ctx , int argc , char * * argv ) {
165166 static struct option long_options [] = {
166- {"config" , required_argument , 0 , 'C' },
167- {"version" , no_argument , 0 , 'v' },
168- {"help" , no_argument , 0 , '?' },
167+ {"config" , required_argument , 0 , 'C' },
168+ {"test-time" , required_argument , 0 , 't' },
169+ {"version" , no_argument , 0 , 'v' },
170+ {"help" , no_argument , 0 , '?' },
169171 {0 , 0 , 0 , 0 }
170172 };
171173
172174 ctx -> config_file [0 ] = '\0' ;
173175
174176 int c = 0 , option_index = 0 ;
175- while ((c = getopt_long (argc , argv , "C:v?" , long_options , & option_index )) != -1 ) {
177+ while ((c = getopt_long (argc , argv , "C:t: v?" , long_options , & option_index )) != -1 ) { /* flawfinder: ignore */
176178 switch (c ) {
177179 case 'C' :
178180 strncpy (ctx -> config_file , optarg , sizeof (ctx -> config_file ) - 1 );
179181 ctx -> config_file [sizeof (ctx -> config_file ) - 1 ] = '\0' ;
180182 break ;
183+ case 't' : {
184+ char * endptr = NULL ;
185+ long val = strtol (optarg , & endptr , 10 );
186+ if (endptr == optarg || * endptr != '\0' || val <= 0 || val > 86400 ) {
187+ LOG_ERROR ("Invalid --test-time value '%s' (expected 1..86400)" , optarg );
188+ return -1 ;
189+ }
190+ ctx -> test_time_s = (int )val ;
191+ break ;
192+ }
181193 case 'v' :
182194 printf ("dvledtx version %s\n" , DVLEDTX_VERSION );
183195 exit (0 );
0 commit comments