* Licensed under GPL v2 or later, see file License for details.
*/
-#include <sys/time.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
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);
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(¤t_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;
}