home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / 3b1 / volume02 / cktime / part01 < prev    next >
Encoding:
Internet Message Format  |  1992-06-22  |  3.3 KB

  1. Path: comp-sources-3b1
  2. From: thad@btr.com (Thaddeus P. Floryan)
  3. Subject:  v02i006:  cktime: check realtime clock against battery-backed clock, Part01/01
  4. Newsgroups: comp.sources.3b1
  5. Approved: dave@galaxia.network23.com
  6. X-Checksum-Snefru: 9c644d5d c67fa4d2 83a07244 2c8ec982
  7.  
  8. Submitted-by: thad@btr.com (Thaddeus P. Floryan)
  9. Posting-number: Volume 2, Issue 6
  10. Archive-name: cktime/part01
  11.  
  12. Here's another l'il program for checking the variance between the
  13. realtime clock and the battery-backed clock on the 3B1 per:
  14.  
  15.     total 3
  16.     -rw-r--r--  1 thad    users       106 Feb  2  1989 Makefile
  17.     -rw-r--r--  1 thad    users       878 Feb  2  1989 cktime.Cut
  18.  
  19. Thad Floryan [ thad@btr.com (OR) {decwrl, mips, fernwood}!btr!thad ]
  20.  
  21. ---- cut Here and feed the following to sh ----
  22. #!/bin/sh
  23. # This is a shell archive (produced by shar 3.49)
  24. # To extract the files from this archive, save it to a file, remove
  25. # everything above the "!/bin/sh" line above, and type "sh file_name".
  26. #
  27. # made 06/15/1992 11:39 UTC by thad@thadlabs
  28. # Source directory /usr/local/src/cktime
  29. #
  30. # existing files will NOT be overwritten unless -c is specified
  31. #
  32. # This shar contains:
  33. # length  mode       name
  34. # ------ ---------- ------------------------------------------
  35. #    106 -rw-r--r-- Makefile
  36. #    878 -rw-r--r-- cktime.c
  37. #
  38. # ============= Makefile ==============
  39. if test -f 'Makefile' -a X"$1" != X"-c"; then
  40.     echo 'x - skipping Makefile (File already exists)'
  41. else
  42. echo 'x - extracting Makefile (Text)'
  43. sed 's/^X//' << 'SHAR_EOF' > 'Makefile' &&
  44. XSHLIB= /lib/crt0s.o /lib/shlib.ifile
  45. X
  46. Xcktime:    cktime.c
  47. X    cc -O -c $@.c
  48. X    ld -s $@.o $(SHLIB) -o $@
  49. X    rm $@.o
  50. SHAR_EOF
  51. chmod 0644 Makefile ||
  52. echo 'restore of Makefile failed'
  53. Wc_c="`wc -c < 'Makefile'`"
  54. test 106 -eq "$Wc_c" ||
  55.     echo 'Makefile: original size 106, current size' "$Wc_c"
  56. fi
  57. # ============= cktime.c ==============
  58. if test -f 'cktime.c' -a X"$1" != X"-c"; then
  59.     echo 'x - skipping cktime.c (File already exists)'
  60. else
  61. echo 'x - extracting cktime.c (Text)'
  62. sed 's/^X//' << 'SHAR_EOF' > 'cktime.c' &&
  63. X/*    cktime
  64. X *
  65. X *    displays the present date and time from both the time-of-day (TOD) and
  66. X *    the battery-backed (RTC) clocks on the UNIXPC.
  67. X *
  68. X *    Thad Floryan, 2-Feb-1989
  69. X */
  70. X
  71. X#include <stdio.h>
  72. X#include <sys/types.h>
  73. X#include <sys/syslocal.h>
  74. X#include <sys/rtc.h>
  75. X#include <time.h>
  76. X
  77. Xchar *mth_name[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
  78. X            "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
  79. X
  80. Xchar *day_name[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
  81. X
  82. Xmain()
  83. X{
  84. X    struct rtc    rval;
  85. X    time_t        tval;
  86. X
  87. X    time(&tval);
  88. X
  89. X    syslocal(SYSL_RDRTC, &rval);    /* read RTC */
  90. X
  91. X    printf("TOD: %sRTC: %s %s %2d %02d:%02d:%02d 19%02d\n",
  92. X        ctime(&tval),
  93. X        day_name[rval.wkday],
  94. X        mth_name[(rval.mon10 * 10) + rval.mon1 - 1],
  95. X        (rval.day10 * 10) + rval.day1,
  96. X        (rval.hr10  * 10) + rval.hr1,
  97. X        (rval.min10 * 10) + rval.min1,
  98. X        (rval.sec10 * 10) + rval.sec1,
  99. X        (rval.yr10  * 10) + rval.yr1);
  100. X}
  101. SHAR_EOF
  102. chmod 0644 cktime.c ||
  103. echo 'restore of cktime.c failed'
  104. Wc_c="`wc -c < 'cktime.c'`"
  105. test 878 -eq "$Wc_c" ||
  106.     echo 'cktime.c: original size 878, current size' "$Wc_c"
  107. fi
  108. exit 0
  109.  
  110. -- 
  111. David H. Brierley
  112. Home: dave@galaxia.network23.com; Work: dhb@quahog.ssd.ray.com
  113. Send comp.sources.3b1 submissions to comp-sources-3b1@galaxia.network23.com
  114. %% Can I be excused, my brain is full. **
  115.