+
+char *wtmpfile = "/usr/adm/wtmp";
+struct utmp wtmp[2] = {
+ { "|", "", "", 0 },
+ { "{", "", "", 0 }
+};
+
+/*
+ * Rounding doesn't work well because new time is always
+ * truncated, but oldtime is normally distributed.
+ */
+logwtmp(otime, ntime)
+struct timeval otime, ntime;
+{
+ int f;
+
+ if (otime.tv_sec == ntime.tv_sec)
+ return;
+ wtmp[0].ut_time = otime.tv_sec; /* +(otime.tv_usec + 500000)/1000000;*/
+ wtmp[1].ut_time = ntime.tv_sec; /* +(ntime.tv_usec + 500000)/1000000;*/
+ if ((f = open(wtmpfile, O_WRONLY|O_APPEND)) >= 0) {
+ (void) write(f, (char *)wtmp, sizeof(wtmp));
+ (void) close(f);
+ }
+}