ifupdown: save some 100+ bytes of code in addstr()
[oweals/busybox.git] / util-linux / rdate.c
index 27bd1b48168f5148a6b700ca0a32ffb8bb5156b7..645b0b9291ae12af1be793e431ab02c431b30e52 100644 (file)
@@ -42,7 +42,7 @@ static time_t askremotedate(const char *host)
        alarm(10);
        signal(SIGALRM, socket_timeout);
 
-       fd = xconnect(&s_in);
+       fd = xconnect_tcp_v4(&s_in);
 
        if (safe_read(fd, (void *)&nett, 4) != 4)    /* read time from server */
                bb_error_msg_and_die("%s did not send the complete time", host);
@@ -63,24 +63,24 @@ int rdate_main(int argc, char **argv)
        time_t remote_time;
        unsigned long flags;
 
-       bb_opt_complementally = "-1";
-       flags = bb_getopt_ulflags(argc, argv, "sp");
+       opt_complementary = "-1";
+       flags = getopt32(argc, argv, "sp");
 
        remote_time = askremotedate(argv[optind]);
 
-       if (flags & 1) {
+       if ((flags & 2) == 0) {
                time_t current_time;
 
                time(&current_time);
                if (current_time == remote_time)
-                       bb_error_msg("Current time matches remote time.");
+                       bb_error_msg("current time matches remote time");
                else
                        if (stime(&remote_time) < 0)
-                               bb_perror_msg_and_die("Could not set time of day");
+                               bb_perror_msg_and_die("cannot set time of day");
+       }
 
-       /* No need to check for the -p flag as it's the only option left */
-
-       } else printf("%s", ctime(&remote_time));
+       if ((flags & 1) == 0)
+               printf("%s", ctime(&remote_time));
 
        return EXIT_SUCCESS;
 }