Fix the pwd and group functions. The bb_ stuff was a leftover from
[oweals/busybox.git] / rdate.c
diff --git a/rdate.c b/rdate.c
index 915c4bdd4cff3f10de2cbe561709856da6ab9670..0ad339be8aa370de44135182d8f59db9a9db764c 100644 (file)
--- a/rdate.c
+++ b/rdate.c
 #include <netdb.h>
 #include <stdio.h>
 #include <getopt.h>
+#include <stdlib.h>
+#include <unistd.h>
 
 
-#define RFC_868_BIAS   2208988800UL
+static const int RFC_868_BIAS = 2208988800UL;
 
 int setdate= 0;
 int printdate= 0;
@@ -47,15 +49,15 @@ time_t askremotedate(char *host)
        int fd;
 
        if (!(h = gethostbyname(host))) {       /* get the IP addr */
-               errorMsg("%s: %s\n", host, strerror(errno));
+               perror_msg("%s", host);
                return(-1);
        }
        if ((tserv = getservbyname("time", "tcp")) == NULL) { /* find port # */
-               errorMsg("%s: %s\n", "time", strerror(errno));
+               perror_msg("%s", "time");
                return(-1);
        }
        if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {  /* get net connection */
-               errorMsg("%s: %s\n", "socket", strerror(errno));
+               perror_msg("%s", "socket");
                return(-1);
        }
 
@@ -64,13 +66,13 @@ time_t askremotedate(char *host)
        sin.sin_family = AF_INET;
 
        if (connect(fd, (struct sockaddr *)&sin, sizeof(sin)) < 0) {    /* connect to time server */
-               errorMsg("%s: %s\n", host, strerror(errno));
+               perror_msg("%s", host);
                close(fd);
                return(-1);
        }
-       if (read(fd, &nett, 4) != 4) {  /* read time from server */
+       if (read(fd, (void *)&nett, 4) != 4) {  /* read time from server */
                close(fd);
-               errorMsg("%s did not send the complete time\n", host);
+               error_msg("%s did not send the complete time\n", host);
        }
        close(fd);
 
@@ -101,7 +103,6 @@ int rdate_main(int argc, char **argv)
                        default:
                        case 'H':
                                usage(rdate_usage);
-                               return(FALSE);
                                break;
                        case 's':
                                setdate++;
@@ -117,19 +118,18 @@ int rdate_main(int argc, char **argv)
 
        if (optind == argc) {
                usage(rdate_usage);
-               return(FALSE);
        }
 
        if ((time= askremotedate(argv[optind])) == (time_t)-1) {
-               return(FALSE);
+               return EXIT_FAILURE;
        }
        if (setdate) {
                if (stime(&time) < 0)
-                       fatalError("Could not set time of day: %s\n", strerror(errno));
+                       perror_msg_and_die("Could not set time of day");
        }
        if (printdate) {
-               fprintf(stdout, "%s", ctime(&time));
+               printf("%s", ctime(&time));
        }
 
-       return(TRUE);
+       return EXIT_SUCCESS;
 }