+\f
+/* Return the time of the last system boot. */
+
+static time_t boot_time;
+
+static time_t
+get_boot_time ()
+{
+#ifdef BOOT_TIME
+ struct utmp ut, *utp;
+
+ if (boot_time)
+ return boot_time;
+
+ utmpname ("/var/log/wtmp");
+ setutent ();
+ boot_time = 1;
+ while (1)
+ {
+ /* Find the next reboot record. */
+ ut.ut_type = BOOT_TIME;
+ utp = getutid (&ut);
+ if (! utp)
+ break;
+ /* Compare reboot times and use the newest one. */
+ if (utp->ut_time > boot_time)
+ boot_time = utp->ut_time;
+ /* Advance on element in the file
+ so that getutid won't repeat the same one. */
+ utp = getutent ();
+ if (! utp)
+ break;
+ }
+ endutent ();
+
+ return boot_time;
+#else
+ return 0;
+#endif
+}