#!/bin/sh # This is a shell archive (produced by GNU sharutils 4.2.1). # To extract the files from this archive, save it to some FILE, remove # everything before the `!/bin/sh' line above, then type `sh FILE'. # # Made on 2003-06-20 01:29 JST by . # Source directory was `/autofs/home/kabe'. # # Existing files will *not* be overwritten unless `-c' is specified. # # This shar contains: # length mode name # ------ ---------- ------------------------------------------ # 1661 -rw-rw-r-- rdate-1.2/COPYING # 728 -rw-rw-r-- rdate-1.2/Makefile # 2316 -rw-rw-r-- rdate-1.2/README # 2522 -rw-rw-r-- rdate-1.2/adjtime.c # 2564 -rw-rw-r-- rdate-1.2/rdate.8 # 6222 -rw-rw-r-- rdate-1.2/rdate.c # 3995 -rw-rw-r-- rdate-1.2/rdate.qpg # echo=echo if touch -am -t 200112312359.59 $$.touch >/dev/null 2>&1 && test ! -f 200112312359.59 -a -f $$.touch; then shar_touch='touch -am -t $1$2$3$4$5$6.$7 "$8"' elif touch -am 123123592001.59 $$.touch >/dev/null 2>&1 && test ! -f 123123592001.59 -a ! -f 123123592001.5 -a -f $$.touch; then shar_touch='touch -am $3$4$5$6$1$2.$7 "$8"' elif touch -am 1231235901 $$.touch >/dev/null 2>&1 && test ! -f 1231235901 -a -f $$.touch; then shar_touch='touch -am $3$4$5$6$2 "$8"' else shar_touch=: echo $echo 'WARNING: not restoring timestamps. Consider getting and' $echo "installing GNU \`touch', distributed in GNU File Utilities..." echo fi rm -f 200112312359.59 123123592001.59 123123592001.5 1231235901 $$.touch # if mkdir _sh04098; then $echo 'x -' 'creating lock directory' else $echo 'failed to create lock directory' exit 1 fi # ============= rdate-1.2/COPYING ============== if test ! -d 'rdate-1.2'; then $echo 'x -' 'creating directory' 'rdate-1.2' mkdir 'rdate-1.2' fi if test -f 'rdate-1.2/COPYING' && test "$first_param" != -c; then $echo 'x -' SKIPPING 'rdate-1.2/COPYING' '(file already exists)' else $echo 'x -' extracting 'rdate-1.2/COPYING' '(text)' sed 's/^X//' << 'SHAR_EOF' > 'rdate-1.2/COPYING' && /* X * Copyright (c) 1994 Christos Zoulas X * All rights reserved. X * X * Redistribution and use in source and binary forms, with or without X * modification, are permitted provided that the following conditions X * are met: X * 1. Redistributions of source code must retain the above copyright X * notice, this list of conditions and the following disclaimer. X * 2. Redistributions in binary form must reproduce the above copyright X * notice, this list of conditions and the following disclaimer in the X * documentation and/or other materials provided with the distribution. X * 3. All advertising materials mentioning features or use of this software X * must display the following acknowledgement: X * This product includes software developed by Christos Zoulas. X * 4. The name of the author may not be used to endorse or promote products X * derived from this software without specific prior written permission. X * X * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR X * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES X * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. X * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, X * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT X * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, X * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY X * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT X * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF X * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. X */ SHAR_EOF (set 20 03 03 14 00 32 15 'rdate-1.2/COPYING'; eval "$shar_touch") && chmod 0664 'rdate-1.2/COPYING' || $echo 'restore of' 'rdate-1.2/COPYING' 'failed' if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \ && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then md5sum -c << SHAR_EOF >/dev/null 2>&1 \ || $echo 'rdate-1.2/COPYING:' 'MD5 check failed' 47202fddd430ddb4f93d4f0bde8f216a rdate-1.2/COPYING SHAR_EOF else shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'rdate-1.2/COPYING'`" test 1661 -eq "$shar_count" || $echo 'rdate-1.2/COPYING:' 'original size' '1661,' 'current size' "$shar_count!" fi fi # ============= rdate-1.2/Makefile ============== if test -f 'rdate-1.2/Makefile' && test "$first_param" != -c; then $echo 'x -' SKIPPING 'rdate-1.2/Makefile' '(file already exists)' else $echo 'x -' extracting 'rdate-1.2/Makefile' '(text)' sed 's/^X//' << 'SHAR_EOF' > 'rdate-1.2/Makefile' && # $Id: Makefile,v 1.13 2003/06/19 15:21:58 kabe Exp $ X PROG= rdate X MAN= rdate.8 X LDLIBS=-lsocket CCLINK=$(CC) X OBJS = rdate.o adjtime.o X $(PROG): $(OBJS) X $(CCLINK) -o $@ $(OBJS) $(LDLIBS) X clean:: X $(RM) $(PROG) X $(RM) *.o a.out core *~ #~ X $(RM) $(PROG).use X $(RM) history.qrs X X BINDIR=/opt/sbin MANDIR=/opt/man install: $(PROG) X mkdir -p $(DESTDIR)$(BINDIR) X cp -p $(PROG) $(DESTDIR)$(BINDIR) X MAN8=`expr $(MAN) : '.*\.\([^.]*\)$$'`; \ X mkdir -p $(DESTDIR)$(MANDIR)/man$$MAN8; \ X cp -p $(MAN) $(DESTDIR)$(MANDIR)/man$$MAN8 X ### QNX package thingies package: $(PROG).qpg X $(MAKE) CFLAGS="-O2 -Wall" X $(MAKE) install DESTDIR=./DIST X packager -u $(PROG).qpg X clean:: X $(RM) -r ./DIST distclean:: clean X $(RM) *.qpr *.qpm *.qpk SHAR_EOF (set 20 03 06 20 00 21 58 'rdate-1.2/Makefile'; eval "$shar_touch") && chmod 0664 'rdate-1.2/Makefile' || $echo 'restore of' 'rdate-1.2/Makefile' 'failed' if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \ && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then md5sum -c << SHAR_EOF >/dev/null 2>&1 \ || $echo 'rdate-1.2/Makefile:' 'MD5 check failed' a101a3f7597051bb732300236e182457 rdate-1.2/Makefile SHAR_EOF else shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'rdate-1.2/Makefile'`" test 728 -eq "$shar_count" || $echo 'rdate-1.2/Makefile:' 'original size' '728,' 'current size' "$shar_count!" fi fi # ============= rdate-1.2/README ============== if test -f 'rdate-1.2/README' && test "$first_param" != -c; then $echo 'x -' SKIPPING 'rdate-1.2/README' '(file already exists)' else $echo 'x -' extracting 'rdate-1.2/README' '(text)' sed 's/^X//' << 'SHAR_EOF' > 'rdate-1.2/README' && README for QNXRTP ported rdate X X This is an QNXRTP/Momentics port of the rdate utility, X which is derived from NetBSD rdate. X CHANGES from original X * Neutrino lacks adjtime() system call, so a custom implementation X wrapping ClockAdjust() NTO call is provided. X You could plop in the adjtime.c for other programs X demanding adjtime(). X * Also sets RTC to the retrieved date. X INSTALL: X make X make install DESTDIR=/usr X PACKAGING: X make package X X Touching rdate.qpg (package generator file) may be needed if you X changed something. X X CREDITS: X Chistos Zoulas: Original NetBSD rdate implementation X kabe@sra-tohoku.co.jp: adjtime.c, QNX packaging X /* X * Copyright (c) 1994 Christos Zoulas X * All rights reserved. X * X * Redistribution and use in source and binary forms, with or without X * modification, are permitted provided that the following conditions X * are met: X * 1. Redistributions of source code must retain the above copyright X * notice, this list of conditions and the following disclaimer. X * 2. Redistributions in binary form must reproduce the above copyright X * notice, this list of conditions and the following disclaimer in the X * documentation and/or other materials provided with the distribution. X * 3. All advertising materials mentioning features or use of this software X * must display the following acknowledgement: X * This product includes software developed by Christos Zoulas. X * 4. The name of the author may not be used to endorse or promote products X * derived from this software without specific prior written permission. X * X * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR X * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES X * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. X * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, X * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT X * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, X * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY X * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT X * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF X * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. X */ SHAR_EOF (set 20 03 06 20 01 10 46 'rdate-1.2/README'; eval "$shar_touch") && chmod 0664 'rdate-1.2/README' || $echo 'restore of' 'rdate-1.2/README' 'failed' if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \ && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then md5sum -c << SHAR_EOF >/dev/null 2>&1 \ || $echo 'rdate-1.2/README:' 'MD5 check failed' e807e883d95bfa4ec6454ee97c9fd573 rdate-1.2/README SHAR_EOF else shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'rdate-1.2/README'`" test 2316 -eq "$shar_count" || $echo 'rdate-1.2/README:' 'original size' '2316,' 'current size' "$shar_count!" fi fi # ============= rdate-1.2/adjtime.c ============== if test -f 'rdate-1.2/adjtime.c' && test "$first_param" != -c; then $echo 'x -' SKIPPING 'rdate-1.2/adjtime.c' '(file already exists)' else $echo 'x -' extracting 'rdate-1.2/adjtime.c' '(text)' sed 's/^X//' << 'SHAR_EOF' > 'rdate-1.2/adjtime.c' && /* X * adjtime() for QNXNTO X * X */ static const char * const _rcsid="$Id: adjtime.c,v 1.12 2002/09/02 01:10:25 kabe Exp $"; X #include #include #include #include X #if __QNXNTO__ #include #define UNSIGNED_TV_SEC #endif X #if defined(__QNXNTO__) && !defined(HAVE_ADJTIME) int adjtime(struct timeval *delta, struct timeval * const olddelta) { X int retval = 0; X struct _clockadjust newadjust; X struct _clockadjust oldadjust; X #ifdef DEBUG X /* in RTP, time_t (uint32) tv_sec, suseconds_t (int32) tv_usec */ X if (delta) fprintf(stderr,"adjtime: %ld:%ld\n", (long)delta->tv_sec, (long)delta->tv_usec); #endif X X if (delta) { X int64_t nto_delta; /* nanosecs */ X struct _clockperiod nto_period; X long tickadj; /*nanosec*/ X X /* XXX typeof(tv.tv_sec)==time_t COULD BE UNSIGNED! */ X nto_delta = #ifdef UNSIGNED_TV_SEC X (int64_t)(signed long)delta->tv_sec * 1000000000LL + #else X (int64_t)delta->tv_sec * 1000000000LL + #endif X (int64_t)delta->tv_usec * 1000LL; X #ifdef DEBUG X fprintf(stderr,"adjtime: delta=%lldns\n", nto_delta); #endif X X /* get current tick length */ X ClockPeriod(CLOCK_REALTIME, NULL, &nto_period, 0); X X /* 10% deviation from standard tick */ X tickadj = nto_period.nsec * 10/*percent*/ / 100; X if (tickadj==0) tickadj=1; X if (-tickadj < nto_delta && nto_delta < tickadj) { X /* lesser than 10% (including zero); X direct bump by one tick */ X tickadj = nto_delta; X newadjust.tick_nsec_inc = tickadj; X newadjust.tick_count = 1; X } else { X if (nto_delta<0) tickadj = -tickadj; X newadjust.tick_nsec_inc = tickadj; X newadjust.tick_count = nto_delta / tickadj; /* possible roundoff error */ X } #ifdef DEBUG X fprintf(stderr, "adjtime: Slewing %ld nsec * %lu ticks (range %ld seconds)\n", X newadjust.tick_nsec_inc, newadjust.tick_count, X (long)((uint64_t)newadjust.tick_count*nto_period.nsec/1000000000L)); #endif X retval = ClockAdjust(CLOCK_REALTIME, &newadjust, &oldadjust); X } X X if (olddelta) { X int64_t d; X if (!delta) X retval = ClockAdjust(CLOCK_REALTIME, NULL, &oldadjust); X /* XXX overflow warning */ X /* but could not if previous adjtime fitted in nto_delta */ X d = (int64_t)oldadjust.tick_nsec_inc * oldadjust.tick_count; X d /= 1000; /* nanosec to usec */ X olddelta->tv_sec = d / 1000000; /* usec to sec */ X /* beware for negative d; X * should -1us be {0,-1} or {-1, 999999}? */ X d -= olddelta->tv_sec * 1000000; X olddelta->tv_usec = d; X } X X return retval; } #endif /* __QNXNTO__ */ SHAR_EOF (set 20 02 09 02 10 10 25 'rdate-1.2/adjtime.c'; eval "$shar_touch") && chmod 0664 'rdate-1.2/adjtime.c' || $echo 'restore of' 'rdate-1.2/adjtime.c' 'failed' if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \ && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then md5sum -c << SHAR_EOF >/dev/null 2>&1 \ || $echo 'rdate-1.2/adjtime.c:' 'MD5 check failed' 72f392a4616179ebc9fa52894965ce17 rdate-1.2/adjtime.c SHAR_EOF else shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'rdate-1.2/adjtime.c'`" test 2522 -eq "$shar_count" || $echo 'rdate-1.2/adjtime.c:' 'original size' '2522,' 'current size' "$shar_count!" fi fi # ============= rdate-1.2/rdate.8 ============== if test -f 'rdate-1.2/rdate.8' && test "$first_param" != -c; then $echo 'x -' SKIPPING 'rdate-1.2/rdate.8' '(file already exists)' else $echo 'x -' extracting 'rdate-1.2/rdate.8' '(text)' sed 's/^X//' << 'SHAR_EOF' > 'rdate-1.2/rdate.8' && X.\" $NetBSD: rdate.8,v 1.9 2002/01/19 11:45:00 wiz Exp $ X.\" X.\" Copyright (c) 1994 Christos Zoulas X.\" All rights reserved. X.\" X.\" Redistribution and use in source and binary forms, with or without X.\" modification, are permitted provided that the following conditions X.\" are met: X.\" 1. Redistributions of source code must retain the above copyright X.\" notice, this list of conditions and the following disclaimer. X.\" 2. Redistributions in binary form must reproduce the above copyright X.\" notice, this list of conditions and the following disclaimer in the X.\" documentation and/or other materials provided with the distribution. X.\" 3. All advertising materials mentioning features or use of this software X.\" must display the following acknowledgement: X.\" This product includes software developed by Christos Zoulas. X.\" 4. The name of the author may not be used to endorse or promote products X.\" derived from this software without specific prior written permission. X.\" X.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR X.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES X.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. X.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, X.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT X.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, X.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY X.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT X.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF X.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. X.\" X.Dd April 30, 1994 X.Dt RDATE 8 X.Os X.Sh NAME X.Nm rdate X.Nd set the system's date from a remote host X.Sh SYNOPSIS X.Nm X.Op Fl psa X.Ar host X.Sh DESCRIPTION X.Nm displays and sets the local date and time from the host name or address given as the argument. It uses the RFC868 protocol which is usually implemented as a built-in service of X.Xr inetd 8 . X.Pp Available options: X.Pp X.Bl -tag -width indent X.It Fl p Do not set, just print the remote time X.It Fl s Do not print the time. X.It Fl a Use the X.Xr adjtime 2 call to gradually skew the local time to the remote time rather than just hopping. X.El X.Sh FILES X.Bl -tag -width /var/log/wtmp -compact X.It Pa /var/log/wtmp A record of date resets and time changes. X.El X.Sh SEE ALSO X.Xr adjtime 2 , X.Xr ClockAdjust 2 , X.Xr gettimeofday 2 , X.Xr utmp 5 , X.Xr inetd 8, X.Xr ntpd 8 SHAR_EOF (set 20 02 09 04 05 37 34 'rdate-1.2/rdate.8'; eval "$shar_touch") && chmod 0664 'rdate-1.2/rdate.8' || $echo 'restore of' 'rdate-1.2/rdate.8' 'failed' if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \ && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then md5sum -c << SHAR_EOF >/dev/null 2>&1 \ || $echo 'rdate-1.2/rdate.8:' 'MD5 check failed' 51da00b0cfb308d367dd1620f5a17cb7 rdate-1.2/rdate.8 SHAR_EOF else shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'rdate-1.2/rdate.8'`" test 2564 -eq "$shar_count" || $echo 'rdate-1.2/rdate.8:' 'original size' '2564,' 'current size' "$shar_count!" fi fi # ============= rdate-1.2/rdate.c ============== if test -f 'rdate-1.2/rdate.c' && test "$first_param" != -c; then $echo 'x -' SKIPPING 'rdate-1.2/rdate.c' '(file already exists)' else $echo 'x -' extracting 'rdate-1.2/rdate.c' '(text)' sed 's/^X//' << 'SHAR_EOF' > 'rdate-1.2/rdate.c' && /* $Id: rdate.c,v 1.11 2003/06/19 16:10:46 kabe Exp $ */ X /* X * Copyright (c) 1994 Christos Zoulas X * All rights reserved. X * X * Redistribution and use in source and binary forms, with or without X * modification, are permitted provided that the following conditions X * are met: X * 1. Redistributions of source code must retain the above copyright X * notice, this list of conditions and the following disclaimer. X * 2. Redistributions in binary form must reproduce the above copyright X * notice, this list of conditions and the following disclaimer in the X * documentation and/or other materials provided with the distribution. X * 3. All advertising materials mentioning features or use of this software X * must display the following acknowledgement: X * This product includes software developed by Christos Zoulas. X * 4. The name of the author may not be used to endorse or promote products X * derived from this software without specific prior written permission. X * X * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR X * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES X * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. X * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, X * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT X * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, X * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY X * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT X * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF X * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. X */ /* Modified for QNXRTP by kabe */ X /* X * rdate.c: Set the date from the specified host X * X * Uses the rfc868 time protocol at socket 37. X * Time is returned as the number of seconds since X * midnight January 1st 1900. X */ X #include #ifndef lint static const char * const _rcsidNetBSD="$NetBSD: rdate.c,v 1.14 2002/07/14 01:01:10 wiz Exp $"; static const char * const _rcsid = "$Id: rdate.c,v 1.11 2003/06/19 16:10:46 kabe Exp $"; #endif /* lint */ X #include #include #include X #include X #include #include #include #include #include #include #include #if __NETBSD #include #endif X /* seconds from midnight Jan 1900 - 1970 */ #define DIFFERENCE 2208988800UL X static char *gProgname = ""; X static const char _usage[] __attribute__((section("QNX_usage"),unused)) = "%C - set system time and date from remote host (time server port 37)\n" "\n" "Options:\n" "%C [\033[1m-psa\033[0m] \033[4mhost\033[0m\n" " \033[1m-p\033[0m just print, don't set\n" " \033[1m-s\033[0m just set, don't print\n" " \033[1m-a\033[0m use adjtime for gradual change instead of instant change\n" " \033[1m-r\033[0m do not set RTC (default is to also set RTC)\n" ""; X int main(int argc, char *argv[]) { X int pr = 0, silent = 0, s; X int slidetime = 0; X int adjustment; X int nosetrtc = 0; X time_t tim; X char *hname, *emsg; X struct addrinfo hints, *res, *res0; X int c; X int error; X X gProgname=strrchr(argv[0], '/'); X if (NULL == gProgname) { X gProgname = argv[0]; X } else { X gProgname++; /* skip '/' */ X } X X adjustment = 0; X while ((c = getopt(argc, argv, "psar")) != -1) X switch (c) { X case 'p': X pr++; X break; X X case 's': X silent++; X break; X X case 'a': X slidetime++; X break; X X case 'r': X nosetrtc++; X break; X X default: X return 1; X } X X if (argc - 1 != optind) { X fprintf(stderr, "Usage: %s [-psa] host\n", gProgname); X return 1; X } X hname = argv[optind]; X X memset(&hints, 0, sizeof (hints)); X hints.ai_family = PF_UNSPEC; X hints.ai_socktype = SOCK_STREAM; X hints.ai_flags = AI_CANONNAME; X error = getaddrinfo(hname, "time", &hints, &res0); X if (error) X errx(1, "%s: %s", gai_strerror(error), hname); X X for (res = res0, s = -1; res != NULL; res = res->ai_next) { X s = socket(res->ai_family, res->ai_socktype, res->ai_protocol); X if (s < 0) { X emsg = "socket"; X continue; X } X X if (connect(s, res->ai_addr, res->ai_addrlen)) { X close(s); X s = -1; X emsg = "connect"; X continue; X } X X break; X } X freeaddrinfo(res0); X if (s < 0) X err(1, "%s", emsg); X X if (read(s, &tim, sizeof(time_t)) != sizeof(time_t)) X err(1, "Could not read data"); X X (void) close(s); X tim = ntohl(tim) - DIFFERENCE; X X if (!pr) { X struct timeval tv; X if (!slidetime) { X void qnx_setrtc(void); X logwtmp("|", "date", ""); X tv.tv_sec = tim; X tv.tv_usec = 0; X if (settimeofday(&tv, NULL) == -1) X err(1, "Could not set time of day"); X if (!nosetrtc) qnx_setrtc(); X logwtmp("{", "date", ""); X } else { X struct timeval tv_current; X if (gettimeofday(&tv_current, NULL) == -1) X err(1, "Could not get local time of day"); X /* XXX typeof(tv.tv_sec)==time_t COULD BE UNSIGNED! */ X adjustment = tv.tv_sec = tim - tv_current.tv_sec; X tv.tv_usec = 0; X if (adjtime(&tv, NULL) == -1) X err(1, "Could not adjust time of day"); X } X } X X if (!silent) { X (void) fputs(ctime(&tim), stdout); X if (slidetime) X (void) fprintf(stdout, X "%s: adjust local clock by %d seconds\n", X gProgname, adjustment); X } X return 0; } X /* X * Set RTC from current system time. X * X * Consults the "rtc -l hw" line in /etc/rc.d/rc.rtc, X * convert it to "rtc -s -l hw" and invoke it. X * (-l indicates RTC is in localtime; missing -l means RTC is GMT) X */ #include void qnx_setrtc(void) { X FILE *fp; X char buf[128]; X X fp = fopen("/etc/rc.d/rc.rtc", "r"); X if (!fp) { X warn("/etc/rc.d/rc.rtc"); X return; X } X while (fgets(buf, sizeof buf, fp)) { X char *p = strtok(buf, " \t"); X if (p[0] == '#') continue; X if (!strcmp(p, "rtc")) { X char *argv[16]; X int argc=0; X argv[argc++] = p; X /* insert "-s" to make it into "rtc -s -l hw" */ X argv[argc++] = "-s"; X for (argc; argc<16-1 && (p = strtok(NULL, " \t\r\n")); ) X argv[argc++] = p; X argv[argc] = NULL; X X spawnvp(P_WAIT, "rtc", argv); X break; X } X } X fclose(fp); } SHAR_EOF (set 20 03 06 20 01 10 46 'rdate-1.2/rdate.c'; eval "$shar_touch") && chmod 0664 'rdate-1.2/rdate.c' || $echo 'restore of' 'rdate-1.2/rdate.c' 'failed' if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \ && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then md5sum -c << SHAR_EOF >/dev/null 2>&1 \ || $echo 'rdate-1.2/rdate.c:' 'MD5 check failed' 2b8f845fb20ff8ce404ec7e86f2e908c rdate-1.2/rdate.c SHAR_EOF else shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'rdate-1.2/rdate.c'`" test 6222 -eq "$shar_count" || $echo 'rdate-1.2/rdate.c:' 'original size' '6222,' 'current size' "$shar_count!" fi fi # ============= rdate-1.2/rdate.qpg ============== if test -f 'rdate-1.2/rdate.qpg' && test "$first_param" != -c; then $echo 'x -' SKIPPING 'rdate-1.2/rdate.qpg' '(file already exists)' else $echo 'x -' extracting 'rdate-1.2/rdate.qpg' '(binary)' sed 's/^X//' << 'SHAR_EOF' | uudecode && begin 600 rdate-1.2/rdate.qpg M/%%01SI'96YE%]P86-K86=E M(B\^"B`@("`@(#Q14$3X*("`@("`@/%%01SI$97!A65E/CPO45!'.D5M<&QO>65E/@H@("`@("`\45!'.D5M86EL061D M7!E/D%P<&QI M8V%T:6]N/"]14$TZ4&%C:V%G951Y<&4^"B`@("`@("`@("`@("`@(#Q14$TZ M4&%C:V%G95)E<&]S:71O2X\+U%033I03Y3=&%B;&4\+U%033I296QE87-E4W1A8FEL:71Y M/@H@("`@("`@("`@("`@("`\45!-.E)E;&5A&-L=61E/CPO M45!-.D-O=6YT&-L=61E/@H@("`@("`@("`@("`@("`\45!-.E)E;&5A M7)I9VAT M/@H@("`@("`@("`@("`\+U%033I296QE87-E1&5S8W)I<'1I;VX^"@H@("`@ M("`@("`@("`\45!-.D-O;G1E;G1$97-C&UL;75L=&EP;&4](G1R=64B/E-Y#8\+U%033I487)G971/4SX*("`@("`@("`@("`@("`@/%%033I(;W-T3U,^ M;F]N93PO45!-.DAO&UL;75L=&EP;&4](G1R=64B/D-O;G-O;&4\+U%033I$ M:7-P;&%Y16YV:7)O;FUE;G0^"B`@("`@("`@("`@("`@(#Q14$TZ5&%R9V5T M075D:65N8V4@>&UL;75L=&EP;&4](G1R=64B/D%D;6EN:7-T&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \ && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then md5sum -c << SHAR_EOF >/dev/null 2>&1 \ || $echo 'rdate-1.2/rdate.qpg:' 'MD5 check failed' 491f7b440dcf646a647ab4b339e3dca1 rdate-1.2/rdate.qpg SHAR_EOF else shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'rdate-1.2/rdate.qpg'`" test 3995 -eq "$shar_count" || $echo 'rdate-1.2/rdate.qpg:' 'original size' '3995,' 'current size' "$shar_count!" fi fi rm -fr _sh04098 exit 0