+ if (! opt_seed && ! opt_pass) {
+ pr_usage(0);
+ exit(0);
+ }
+ else if (opt_seed && opt_seed != 2)
+ pr_error_exit(1, "seed requires MAC-ADDRESS");
+ else if (! opt_seed && opt_pass && opt_pass != 2)
+ pr_error_exit(1, "password on its own requires a pre-generated seed");
+ else if (opt_seed && opt_pass && opt_pass != 1)
+ pr_error_exit(1, "generating seed and password; cannot also accept pre-generated seed");
+ else if (opt_pass == 2 && opt_ts)
+ pr_error_exit(1, "seed already contains a timestamp; cannot over-ride it");
+ else if (opt_ts == 1 || opt_pass == 2) { // no timestamp provided; use NOW
+ ts = time(NULL);
+ if (ts)
+ snprintf(timestamp, TIMESTAMP_SIZE + 1, "%08lX", ts);
+ }
+
+ if (opt_pass == 2) { // try to figure out the correct date-time from the seed
+ // inherits the most significant 2 characters from the NOW time
+ strncpy(timestamp+2, seed, 6);
+ time_t tmp;
+ if (sscanf(timestamp, "%08lx", &tmp))
+ if (tmp > ts-3600 && tmp < ts+3600) // timestamps are so close they must be for the same date
+ ts = tmp;
+ }
+
+ if(opt_ts) { // ts needs to be valid to be converted to a time string
+ if(! sscanf(timestamp, "%08lx", &ts))
+ pr_error_exit(1, "converting timestamp string ('%s') to number", timestamp);
+ }
+ t = gmtime(&ts);
+ strftime(date_string, DATESTRING_SIZE, "%F %T", t);
+
+ if (opt_seed)
+ if (! generate_seed(MAC_ADDR, timestamp, seed))
+ pr_error_exit(1, "unable to generate seed; aborting");
+ if (opt_pass)
+ if (! generate_pass(seed, password))
+ pr_error_exit(0, "unable to generate password");
+
+ if (opt_seed || opt_pass)
+ printf("MAC address: %s Timestamp: %s (%s) Seed: %s Password: %s\n", MAC_ADDR, timestamp, date_string, seed, password);