Ignore:
Timestamp:
Nov 4, 2007, 3:16:40 AM (16 years ago)
Author:
Bruno Cornec
Message:

Update to busybox 1.7.2

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.5/mindi-busybox/util-linux/rdate.c

    r821 r1765  
    99*/
    1010
    11 #include <sys/types.h>
    12 #include <sys/socket.h>
    13 #include <netinet/in.h>
    14 #include <netdb.h>
    15 #include <stdio.h>
    16 #include <string.h>
    17 #include <time.h>
    18 #include <stdlib.h>
    19 #include <unistd.h>
    20 #include <signal.h>
     11#include "libbb.h"
    2112
    22 #include "busybox.h"
    23 
    24 
    25 static const int RFC_868_BIAS = 2208988800UL;
     13enum { RFC_868_BIAS = 2208988800UL };
    2614
    2715static void socket_timeout(int sig)
     
    3220static time_t askremotedate(const char *host)
    3321{
    34     unsigned long nett;
    35     struct sockaddr_in s_in;
     22    uint32_t nett;
    3623    int fd;
    37 
    38     bb_lookup_host(&s_in, host);
    39     s_in.sin_port = bb_lookup_port("time", "tcp", 37);
    4024
    4125    /* Add a timeout for dead or inaccessible servers */
     
    4327    signal(SIGALRM, socket_timeout);
    4428
    45     fd = xconnect(&s_in);
     29    fd = create_and_connect_stream_or_die(host, bb_lookup_port("time", "tcp", 37));
    4630
    4731    if (safe_read(fd, (void *)&nett, 4) != 4)    /* read time from server */
     
    5135    /* convert from network byte order to local byte order.
    5236     * RFC 868 time is the number of seconds
    53      *  since 00:00 (midnight) 1 January 1900 GMT
    54      *  the RFC 868 time 2,208,988,800 corresponds to 00:00  1 Jan 1970 GMT
    55      * Subtract the RFC 868 time  to get Linux epoch
     37     * since 00:00 (midnight) 1 January 1900 GMT
     38     * 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
    5640     */
    5741
    58     return(ntohl(nett) - RFC_868_BIAS);
     42    return ntohl(nett) - RFC_868_BIAS;
    5943}
    6044
     45int rdate_main(int argc, char **argv);
    6146int rdate_main(int argc, char **argv)
    6247{
     
    6449    unsigned long flags;
    6550
    66     bb_opt_complementally = "-1";
    67     flags = bb_getopt_ulflags(argc, argv, "sp");
     51    opt_complementary = "-1";
     52    flags = getopt32(argv, "sp");
    6853
    6954    remote_time = askremotedate(argv[optind]);
     
    7459        time(&current_time);
    7560        if (current_time == remote_time)
    76             bb_error_msg("Current time matches remote time.");
     61            bb_error_msg("current time matches remote time");
    7762        else
    7863            if (stime(&remote_time) < 0)
    79                 bb_perror_msg_and_die("Could not set time of day");
     64                bb_perror_msg_and_die("cannot set time of day");
    8065    }
    8166
Note: See TracChangeset for help on using the changeset viewer.