home *** CD-ROM | disk | FTP | other *** search
- Path: comp-sources-3b1
- From: thad@btr.com (Thaddeus P. Floryan)
- Subject: v02i006: cktime: check realtime clock against battery-backed clock, Part01/01
- Newsgroups: comp.sources.3b1
- Approved: dave@galaxia.network23.com
- X-Checksum-Snefru: 9c644d5d c67fa4d2 83a07244 2c8ec982
-
- Submitted-by: thad@btr.com (Thaddeus P. Floryan)
- Posting-number: Volume 2, Issue 6
- Archive-name: cktime/part01
-
- Here's another l'il program for checking the variance between the
- realtime clock and the battery-backed clock on the 3B1 per:
-
- total 3
- -rw-r--r-- 1 thad users 106 Feb 2 1989 Makefile
- -rw-r--r-- 1 thad users 878 Feb 2 1989 cktime.Cut
-
- Thad Floryan [ thad@btr.com (OR) {decwrl, mips, fernwood}!btr!thad ]
-
- ---- cut Here and feed the following to sh ----
- #!/bin/sh
- # This is a shell archive (produced by shar 3.49)
- # To extract the files from this archive, save it to a file, remove
- # everything above the "!/bin/sh" line above, and type "sh file_name".
- #
- # made 06/15/1992 11:39 UTC by thad@thadlabs
- # Source directory /usr/local/src/cktime
- #
- # existing files will NOT be overwritten unless -c is specified
- #
- # This shar contains:
- # length mode name
- # ------ ---------- ------------------------------------------
- # 106 -rw-r--r-- Makefile
- # 878 -rw-r--r-- cktime.c
- #
- # ============= Makefile ==============
- if test -f 'Makefile' -a X"$1" != X"-c"; then
- echo 'x - skipping Makefile (File already exists)'
- else
- echo 'x - extracting Makefile (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'Makefile' &&
- XSHLIB= /lib/crt0s.o /lib/shlib.ifile
- X
- Xcktime: cktime.c
- X cc -O -c $@.c
- X ld -s $@.o $(SHLIB) -o $@
- X rm $@.o
- SHAR_EOF
- chmod 0644 Makefile ||
- echo 'restore of Makefile failed'
- Wc_c="`wc -c < 'Makefile'`"
- test 106 -eq "$Wc_c" ||
- echo 'Makefile: original size 106, current size' "$Wc_c"
- fi
- # ============= cktime.c ==============
- if test -f 'cktime.c' -a X"$1" != X"-c"; then
- echo 'x - skipping cktime.c (File already exists)'
- else
- echo 'x - extracting cktime.c (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'cktime.c' &&
- X/* cktime
- X *
- X * displays the present date and time from both the time-of-day (TOD) and
- X * the battery-backed (RTC) clocks on the UNIXPC.
- X *
- X * Thad Floryan, 2-Feb-1989
- X */
- X
- X#include <stdio.h>
- X#include <sys/types.h>
- X#include <sys/syslocal.h>
- X#include <sys/rtc.h>
- X#include <time.h>
- X
- Xchar *mth_name[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
- X "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
- X
- Xchar *day_name[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
- X
- Xmain()
- X{
- X struct rtc rval;
- X time_t tval;
- X
- X time(&tval);
- X
- X syslocal(SYSL_RDRTC, &rval); /* read RTC */
- X
- X printf("TOD: %sRTC: %s %s %2d %02d:%02d:%02d 19%02d\n",
- X ctime(&tval),
- X day_name[rval.wkday],
- X mth_name[(rval.mon10 * 10) + rval.mon1 - 1],
- X (rval.day10 * 10) + rval.day1,
- X (rval.hr10 * 10) + rval.hr1,
- X (rval.min10 * 10) + rval.min1,
- X (rval.sec10 * 10) + rval.sec1,
- X (rval.yr10 * 10) + rval.yr1);
- X}
- SHAR_EOF
- chmod 0644 cktime.c ||
- echo 'restore of cktime.c failed'
- Wc_c="`wc -c < 'cktime.c'`"
- test 878 -eq "$Wc_c" ||
- echo 'cktime.c: original size 878, current size' "$Wc_c"
- fi
- exit 0
-
- --
- David H. Brierley
- Home: dave@galaxia.network23.com; Work: dhb@quahog.ssd.ray.com
- Send comp.sources.3b1 submissions to comp-sources-3b1@galaxia.network23.com
- %% Can I be excused, my brain is full. **
-