Changeset 3232 in MondoRescue for branches/3.2/mindi-busybox/util-linux/rdate.c
- Timestamp:
- Jan 1, 2014, 12:47:38 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.2/mindi-busybox/util-linux/rdate.c
r2725 r3232 2 2 /* 3 3 * The Rdate command will ask a time server for the RFC 868 time 4 * 4 * and optionally set the system time. 5 5 * 6 6 * by Sterling Huxley <sterling@europa.com> … … 8 8 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 9 9 */ 10 11 //usage:#define rdate_trivial_usage 12 //usage: "[-sp] HOST" 13 //usage:#define rdate_full_usage "\n\n" 14 //usage: "Get and possibly set the system date/time from a remote HOST\n" 15 //usage: "\n -s Set the system date/time (default)" 16 //usage: "\n -p Print the date/time" 10 17 11 18 #include "libbb.h" … … 29 36 fd = create_and_connect_stream_or_die(host, bb_lookup_port("time", "tcp", 37)); 30 37 31 if (safe_read(fd, (void *)&nett, 4) != 4) /* read time from server */38 if (safe_read(fd, &nett, 4) != 4) /* read time from server */ 32 39 bb_error_msg_and_die("%s did not send the complete time", host); 33 close(fd); 40 if (ENABLE_FEATURE_CLEAN_UP) 41 close(fd); 34 42 35 /* convert from network byte order to local byte order.43 /* Convert from network byte order to local byte order. 36 44 * RFC 868 time is the number of seconds 37 45 * since 00:00 (midnight) 1 January 1900 GMT 38 46 * the RFC 868 time 2,208,988,800 corresponds to 00:00 1 Jan 1970 GMT 39 * Subtract the RFC 868 time to get Linux epoch 47 * Subtract the RFC 868 time to get Linux epoch. 40 48 */ 41 49 … … 47 55 { 48 56 time_t remote_time; 49 unsigned longflags;57 unsigned flags; 50 58 51 59 opt_complementary = "-1"; … … 54 62 remote_time = askremotedate(argv[optind]); 55 63 56 if ( (flags & 2) == 0) {64 if (!(flags & 2)) { /* no -p (-s may be present) */ 57 65 time_t current_time; 58 66 … … 65 73 } 66 74 67 if ( (flags & 1) == 0)75 if (flags != 1) /* not lone -s */ 68 76 printf("%s", ctime(&remote_time)); 69 77
Note:
See TracChangeset
for help on using the changeset viewer.