OSDN Git Service

(split) LDP: Update original to LDP v3.65
[linuxjm/LDP_man-pages.git] / original / man3 / rtime.3
index e19429e..4ecbcca 100644 (file)
@@ -1,11 +1,15 @@
 .\" Copyright 2003 walter harms (walter.harms@informatik.uni-oldenburg.de)
+.\"
+.\" %%%LICENSE_START(GPL_NOVERSION_ONELINE)
 .\" Distributed under GPL
+.\" %%%LICENSE_END
+.\"
 .\" Modified 2003-04-04 Walter Harms
 .\" <walter.harms@informatik.uni-oldenburg.de>
 .\"
 .\" Slightly polished, aeb, 2003-04-06
 .\"
-.TH RTIME 3 2010-02-25 "GNU" "Linux Programmer's Manual"
+.TH RTIME 3 2014-01-05 "GNU" "Linux Programmer's Manual"
 .SH NAME
 rtime \- get time from a remote machine
 .SH SYNOPSIS
@@ -29,7 +33,7 @@ When
 .I timeout
 is non-NULL, the udp/time socket (port 37) is used.
 Otherwise, the tcp/time socket (port 37) is used.
-.SH "RETURN VALUE"
+.SH RETURN VALUE
 On success, 0 is returned, and the obtained 32-bit time value is stored in
 .IR timep\->tv_sec .
 In case of error \-1 is returned, and
@@ -50,34 +54,36 @@ The number of returned bytes is not 4.
 .TP
 .B ETIMEDOUT
 The waiting time as defined in timeout has expired.
-.SH "NOTES"
+.SH NOTES
 Only IPv4 is supported.
 .LP
 Some
 .I in.timed
-versions only support TCP.
+versions support only TCP.
 Try the example program with
 .I use_tcp
 set to 1.
 .LP
 Libc5 uses the prototype
-.br
-int rtime(struct sockaddr_in *, struct timeval *, struct timeval *);
-.br
+.nf
+
+    int rtime(struct sockaddr_in *, struct timeval *, struct timeval *);
+
+.fi
 and requires
 .I <sys/time.h>
 instead of
 .IR <rpc/auth_des.h> .
-.SH "BUGS"
+.SH BUGS
 .BR rtime ()
 in glibc 2.2.5 and earlier does not work properly on 64-bit machines.
-.SH "EXAMPLE"
+.SH EXAMPLE
 This example requires that port 37 is up and open.
 You may check
 that the time entry within
 .I /etc/inetd.conf
 is not commented out.
-.br
+
 The program connects to a computer called "linux".
 Using "localhost" does not work.
 The result is the localtime of the computer "linux".
@@ -91,8 +97,8 @@ The result is the localtime of the computer "linux".
 #include <rpc/auth_des.h>
 #include <netdb.h>
 
-int use_tcp = 0;
-char *servername = "linux";
+static int use_tcp = 0;
+static char *servername = "linux";
 
 int
 main(void)
@@ -103,22 +109,32 @@ main(void)
     struct hostent *hent;
     int ret;
 
-    memset((char *) &name, 0, sizeof(name));
+    memset(&name, 0, sizeof(name));
     sethostent(1);
     hent = gethostbyname(servername);
-    memcpy((char *) &name.sin_addr, hent\->h_addr, hent\->h_length);
+    memcpy(&name.sin_addr, hent\->h_addr, hent\->h_length);
 
     ret = rtime(&name, &time1, use_tcp ? NULL : &timeout);
     if (ret < 0)
         perror("rtime error");
-    else
-        printf("%s\\n", ctime((time_t *) &time1.tv_sec));
+    else {
+        time_t t = time1.tv_sec;
+        printf("%s\\n", ctime(&t));
+    }
 
     exit(EXIT_SUCCESS);
 }
 .fi
-.SH "SEE ALSO"
+.SH SEE ALSO
 .\" .BR netdate (1),
 .BR ntpdate (1),
 .\" .BR rdate (1),
 .BR inetd (8)
+.SH COLOPHON
+This page is part of release 3.65 of the Linux
+.I man-pages
+project.
+A description of the project,
+and information about reporting bugs,
+can be found at
+\%http://www.kernel.org/doc/man\-pages/.