Updated main() with a few comments to illustrate high level flow.
authorAaron Taylor <ataylor@subgeniuskitty.com>
Mon, 7 Oct 2019 11:23:59 +0000 (04:23 -0700)
committerAaron Taylor <ataylor@subgeniuskitty.com>
Mon, 7 Oct 2019 11:23:59 +0000 (04:23 -0700)
icmpmonitor.c

index f7e4a47..5dd5064 100644 (file)
@@ -432,6 +432,7 @@ parse_params(int argc, char ** argv)
     }
     if (first_host_in_list == NULL) {
         fprintf(stderr, "ERROR: Unable to parse a config file.\n");
     }
     if (first_host_in_list == NULL) {
         fprintf(stderr, "ERROR: Unable to parse a config file.\n");
+        print_usage(argv);
         exit(EXIT_FAILURE);
     }
 }
         exit(EXIT_FAILURE);
     }
 }
@@ -439,14 +440,22 @@ parse_params(int argc, char ** argv)
 int
 main(int argc, char ** argv)
 {
 int
 main(int argc, char ** argv)
 {
+    /* Parse the command line options, load and parse the config file. */
     parse_params(argc, argv);
 
     parse_params(argc, argv);
 
+    /* Process config for each host, generating/verifying any necessary information. */
     init_hosts();
 
     init_hosts();
 
+    /* Make sure initialization left us with something useful. */
+    assert(first_host_in_list);
+
+    /* Pings are sent asynchronously. */
     signal(SIGALRM, pinger);
     alarm(TIMER_RESOLUTION);
 
     signal(SIGALRM, pinger);
     alarm(TIMER_RESOLUTION);
 
+    /* The main program loop listens for ping responses. */
     get_response();
 
     get_response();
 
+    /* Should be unreachable. */
     exit(EXIT_SUCCESS);
 }
     exit(EXIT_SUCCESS);
 }