diff options
Diffstat (limited to 'rdate.c')
-rw-r--r-- | rdate.c | 18 |
1 files changed, 9 insertions, 9 deletions
@@ -40,7 +40,7 @@ static const int RFC_868_BIAS = 2208988800UL; | |||
40 | static time_t askremotedate(const char *host) | 40 | static time_t askremotedate(const char *host) |
41 | { | 41 | { |
42 | struct hostent *h; | 42 | struct hostent *h; |
43 | struct sockaddr_in sin; | 43 | struct sockaddr_in s_in; |
44 | struct servent *tserv; | 44 | struct servent *tserv; |
45 | unsigned long int nett, localt; | 45 | unsigned long int nett, localt; |
46 | int fd; | 46 | int fd; |
@@ -54,11 +54,11 @@ static time_t askremotedate(const char *host) | |||
54 | if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) /* get net connection */ | 54 | if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) /* get net connection */ |
55 | perror_msg_and_die("%s", "socket"); | 55 | perror_msg_and_die("%s", "socket"); |
56 | 56 | ||
57 | memcpy(&sin.sin_addr, h->h_addr, sizeof(sin.sin_addr)); | 57 | memcpy(&s_in.sin_addr, h->h_addr, sizeof(s_in.sin_addr)); |
58 | sin.sin_port= tserv->s_port; | 58 | s_in.sin_port= tserv->s_port; |
59 | sin.sin_family = AF_INET; | 59 | s_in.sin_family = AF_INET; |
60 | 60 | ||
61 | if (connect(fd, (struct sockaddr *)&sin, sizeof(sin)) < 0) /* connect to time server */ | 61 | if (connect(fd, (struct sockaddr *)&s_in, sizeof(s_in)) < 0) /* connect to time server */ |
62 | perror_msg_and_die("%s", host); | 62 | perror_msg_and_die("%s", host); |
63 | 63 | ||
64 | if (read(fd, (void *)&nett, 4) != 4) /* read time from server */ | 64 | if (read(fd, (void *)&nett, 4) != 4) /* read time from server */ |
@@ -79,7 +79,7 @@ static time_t askremotedate(const char *host) | |||
79 | 79 | ||
80 | int rdate_main(int argc, char **argv) | 80 | int rdate_main(int argc, char **argv) |
81 | { | 81 | { |
82 | time_t time; | 82 | time_t remote_time; |
83 | int opt; | 83 | int opt; |
84 | int setdate = 0; | 84 | int setdate = 0; |
85 | int printdate= 0; | 85 | int printdate= 0; |
@@ -111,15 +111,15 @@ int rdate_main(int argc, char **argv) | |||
111 | if (optind == argc) | 111 | if (optind == argc) |
112 | show_usage(); | 112 | show_usage(); |
113 | 113 | ||
114 | time = askremotedate(argv[optind]); | 114 | remote_time = askremotedate(argv[optind]); |
115 | 115 | ||
116 | if (setdate) { | 116 | if (setdate) { |
117 | if (stime(&time) < 0) | 117 | if (stime(&remote_time) < 0) |
118 | perror_msg_and_die("Could not set time of day"); | 118 | perror_msg_and_die("Could not set time of day"); |
119 | } | 119 | } |
120 | 120 | ||
121 | if (printdate) | 121 | if (printdate) |
122 | printf("%s", ctime(&time)); | 122 | printf("%s", ctime(&remote_time)); |
123 | 123 | ||
124 | return EXIT_SUCCESS; | 124 | return EXIT_SUCCESS; |
125 | } | 125 | } |