1919static int read_targets_from_file (const char * filename , int stream_targets );
2020static void usage (void );
2121static inline bool is_all_ff (const uint8_t * buf , int len );
22+ static inline char * find_dot (char * str );
2223
2324enum operating_mode {
2425 M_SCAN , M_PRINT_HOSTS ,
@@ -75,7 +76,7 @@ int main(int argc, char *argv[])
7576 ip_type = IP_TYPE_TCP ;
7677 interface = NULL ; // automatically picked
7778 outfile = stdout ;
78- outdef = & output_list ;
79+ outdef = NULL ;
7980
8081 srand (time (NULL ) ^ getpid ());
8182 memset (source_mac , 0xff , 6 );
@@ -208,6 +209,18 @@ int main(int argc, char *argv[])
208209 perror ("open output file" );
209210 return 1 ;
210211 }
212+ char * dot = find_dot (optarg );
213+ if (!outdef && dot ) {
214+ const char * suggest = NULL ;
215+ if (!strcmp (dot + 1 , "bin" ))
216+ suggest = "binary" ;
217+ else if (!strcmp (dot + 1 , "json" ))
218+ suggest = "json" ;
219+ if (suggest ) {
220+ log_warning ("It looks like you might want a different "
221+ "output format, try --output-format %s." , suggest );
222+ }
223+ }
211224 outfile = f ;
212225 break ;
213226 }
@@ -226,6 +239,9 @@ int main(int argc, char *argv[])
226239 }
227240 }
228241
242+ if (!outdef )
243+ outdef = & output_list ;
244+
229245 int max_args = 1 ;
230246 if (mode == M_READSCAN ) {
231247 max_args = 0 ;
@@ -553,3 +569,15 @@ static inline bool is_all_ff(const uint8_t *buf, int len)
553569 }
554570 return true;
555571}
572+
573+ static inline char * find_dot (char * str )
574+ {
575+ char * p = str + strlen (str );
576+ do {
577+ if (* p == '/' )
578+ break ;
579+ if (* p == '.' )
580+ return p ;
581+ } while ((p -- ) > str );
582+ return NULL ;
583+ }
0 commit comments