-
-#include <utmp.h>
-#define SCPYN(a, b) strncpy(a, b, sizeof(a))
-char wtmpf[] = "/usr/adm/wtmp";
-struct utmp wtmp;
-
-markdown()
-{
- register f = open(wtmpf, 1);
- if (f >= 0) {
- lseek(f, 0L, 2);
- SCPYN(wtmp.ut_line, "~");
- SCPYN(wtmp.ut_name, "shutdown");
- time(&wtmp.ut_time);
- write(f, (char *)&wtmp, sizeof(wtmp));
- close(f);
- }
-}
-
-char *days[] = {
- "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
-};
-
-char *months[] = {
- "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep",
- "Oct", "Nov", "Dec"
-};
-
-log_entry()
-{
- FILE *fp;
- struct tm *tm, *localtime();
- time_t now;
-
- time(&now);
- tm = localtime(&now);
- fp = fopen(SHUTDOWNLOG, "a");
- if (fp == 0)
- return;
- fseek(fp, 0L, 2);
- fprintf(fp, "%02d:%02d %s %s %2d, %4d. Halted for reboot.\n", tm->tm_hour,
- tm->tm_min, days[tm->tm_wday], months[tm->tm_mon],
- tm->tm_mday, tm->tm_year + 1900);
- fclose(fp);
-}