+/* SCO OpenServer 5 panic, by Tom Kelly <tom@ancilla.toronto.on.ca>
+ */
+static Bool
+sco (Display *dpy, Window window, int delay)
+{
+ XGCValues gcv;
+ XWindowAttributes xgwa;
+ char *fontname;
+ const char *def_font = "fixed";
+ XFontStruct *font;
+ GC gc;
+ int lines_1 = 0, lines_2 = 0, lines_3 = 0, lines_4 = 0;
+ const char *s;
+
+ const char *sco_panic_1 =
+ ("Unexpected trap in kernel mode:\n"
+ "\n"
+ "cr0 0x80010013 cr2 0x00000014 cr3 0x00000000 tlb 0x00000000\n"
+ "ss 0x00071054 uesp 0x00012055 efl 0x00080888 ipl 0x00000005\n"
+ "cs 0x00092585 eip 0x00544a4b err 0x004d4a47 trap 0x0000000E\n"
+ "eax 0x0045474b ecx 0x0042544b edx 0x57687920 ebx 0x61726520\n"
+ "esp 0x796f7520 ebp 0x72656164 esi 0x696e6720 edi 0x74686973\n"
+ "ds 0x3f000000 es 0x43494c48 fs 0x43525343 gs 0x4f4d4b53\n"
+ "\n"
+ "PANIC: k_trap - kernel mode trap type 0x0000000E\n"
+ "Trying to dump 5023 pages to dumpdev hd (1/41), 63 pages per '.'\n"
+ );
+ const char *sco_panic_2 =
+ ("...............................................................................\n"
+ );
+ const char *sco_panic_3 =
+ ("5023 pages dumped\n"
+ "\n"
+ "\n"
+ );
+ const char *sco_panic_4 =
+ ("** Safe to Power Off **\n"
+ " - or -\n"
+ "** Press Any Key to Reboot **\n"
+ );
+
+ if (!get_boolean_resource("doSCO", "DoSCO"))
+ return False;
+
+ for (s = sco_panic_1; *s; s++) if (*s == '\n') lines_1++;
+ for (s = sco_panic_2; *s; s++) if (*s == '\n') lines_2++;
+ for (s = sco_panic_3; *s; s++) if (*s == '\n') lines_3++;
+ for (s = sco_panic_4; *s; s++) if (*s == '\n') lines_4++;
+
+ XGetWindowAttributes (dpy, window, &xgwa);
+
+ fontname = get_string_resource ((xgwa.height > 600
+ ? "sco.font2"
+ : "sco.font"),
+ "SCO.Font");
+ if (!fontname || !*fontname) fontname = (char *)def_font;
+ font = XLoadQueryFont (dpy, fontname);
+ if (!font) font = XLoadQueryFont (dpy, def_font);
+ if (!font) exit(-1);
+ if (fontname && fontname != def_font)
+ free (fontname);
+
+ gcv.font = font->fid;
+ gcv.foreground = get_pixel_resource(("sco.foreground"),
+ "SCO.Foreground",
+ dpy, xgwa.colormap);
+ gcv.background = get_pixel_resource(("sco.background"),
+ "SCO.Background",
+ dpy, xgwa.colormap);
+ XSetWindowBackground(dpy, window, gcv.background);
+ XClearWindow(dpy, window);
+
+ gc = XCreateGC(dpy, window, GCFont|GCForeground|GCBackground, &gcv);
+
+ draw_string(dpy, window, gc, &gcv, font,
+ 10, xgwa.height - ((lines_1 + lines_2 + lines_3 + lines_4 + 1) *
+ (font->ascent + font->descent + 1)),
+ 10, 10,
+ sco_panic_1, 0);
+ XSync(dpy, False);
+ for (s = sco_panic_2; *s; s++)
+ {
+ char *ss = strdup(sco_panic_2);
+ ss[s - sco_panic_2] = 0;
+ draw_string(dpy, window, gc, &gcv, font,
+ 10, xgwa.height - ((lines_2 + lines_3 + lines_4 + 1) *
+ (font->ascent + font->descent + 1)),
+ 10, 10,
+ ss, 0);
+ XSync(dpy, False);
+ free(ss);
+ if (bsod_sleep (dpy, -1))
+ goto DONE;
+ }
+
+ draw_string(dpy, window, gc, &gcv, font,
+ 10, xgwa.height - ((lines_3 + lines_4 + 1) *
+ (font->ascent + font->descent + 1)),
+ 10, 10,
+ sco_panic_3, 0);
+ XSync(dpy, False);
+ if (bsod_sleep(dpy, 1))
+ goto DONE;
+ draw_string(dpy, window, gc, &gcv, font,
+ 10, xgwa.height - ((lines_4 + 1) *
+ (font->ascent + font->descent + 1)),
+ 10, 10,
+ sco_panic_4, 0);
+ XSync(dpy, False);
+
+ bsod_sleep(dpy, delay);
+ DONE:
+ XClearWindow(dpy, window);
+ XFreeGC(dpy, gc);
+ XFreeFont(dpy, font);
+ return True;
+}
+
+
+/* Linux (sparc) panic, by Tom Kelly <tom@ancilla.toronto.on.ca>
+ */
+static Bool
+sparc_linux (Display *dpy, Window window, int delay)
+{
+ XGCValues gcv;
+ XWindowAttributes xgwa;
+ char *fontname;
+ const char *def_font = "fixed";
+ XFontStruct *font;
+ GC gc;
+ int lines = 1;
+ const char *s;
+
+ const char *linux_panic =
+ ("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
+ "Unable to handle kernel paging request at virtual address f0d4a000\n"
+ "tsk->mm->context = 00000014\n"
+ "tsk->mm->pgd = f26b0000\n"
+ " \\|/ ____ \\|/\n"
+ " \"@'/ ,. \\`@\"\n"
+ " /_| \\__/ |_\\\n"
+ " \\__U_/\n"
+ "gawk(22827): Oops\n"
+ "PSR: 044010c1 PC: f001c2cc NPC: f001c2d0 Y: 00000000\n"
+ "g0: 00001000 g1: fffffff7 g2: 04401086 g3: 0001eaa0\n"
+ "g4: 000207dc g5: f0130400 g6: f0d4a018 g7: 00000001\n"
+ "o0: 00000000 o1: f0d4a298 o2: 00000040 o3: f1380718\n"
+ "o4: f1380718 o5: 00000200 sp: f1b13f08 ret_pc: f001c2a0\n"
+ "l0: efffd880 l1: 00000001 l2: f0d4a230 l3: 00000014\n"
+ "l4: 0000ffff l5: f0131550 l6: f012c000 l7: f0130400\n"
+ "i0: f1b13fb0 i1: 00000001 i2: 00000002 i3: 0007c000\n"
+ "i4: f01457c0 i5: 00000004 i6: f1b13f70 i7: f0015360\n"
+ "Instruction DUMP:\n"
+ );
+
+ if (!get_boolean_resource("doSparcLinux", "DoSparcLinux"))
+ return False;
+
+ for (s = linux_panic; *s; s++) if (*s == '\n') lines++;
+
+ XGetWindowAttributes (dpy, window, &xgwa);
+
+ fontname = get_string_resource ((xgwa.height > 600
+ ? "sparclinux.font2"
+ : "sparclinux.font"),
+ "SparcLinux.Font");
+ if (!fontname || !*fontname) fontname = (char *)def_font;
+ font = XLoadQueryFont (dpy, fontname);
+ if (!font) font = XLoadQueryFont (dpy, def_font);
+ if (!font) exit(-1);
+ if (fontname && fontname != def_font)
+ free (fontname);
+
+ gcv.font = font->fid;
+ gcv.foreground = get_pixel_resource(("sparclinux.foreground"),
+ "SparcLinux.Foreground",
+ dpy, xgwa.colormap);
+ gcv.background = get_pixel_resource(("sparclinux.background"),
+ "SparcLinux.Background",
+ dpy, xgwa.colormap);
+ XSetWindowBackground(dpy, window, gcv.background);
+ XClearWindow(dpy, window);
+
+ gc = XCreateGC(dpy, window, GCFont|GCForeground|GCBackground, &gcv);
+
+ draw_string(dpy, window, gc, &gcv, font,
+ 10, xgwa.height - (lines * (font->ascent + font->descent + 1)),
+ 10, 10,
+ linux_panic, 0);
+ XFreeGC(dpy, gc);
+ XSync(dpy, False);
+ bsod_sleep(dpy, delay);
+ XClearWindow(dpy, window);
+ XFreeFont(dpy, font);
+ return True;
+}
+
+/* BSD Panic by greywolf@starwolf.com - modeled after the Linux panic above.
+ By Grey Wolf <greywolf@siteROCK.com>
+ */
+static Bool
+bsd (Display *dpy, Window window, int delay)
+{
+ XGCValues gcv;
+ XWindowAttributes xgwa;
+ char *fontname;
+ const char *def_font = "fixed";
+ XFontStruct *font;
+ GC gc;
+ int lines = 1;
+ int i, n, b;
+ const char *rbstr, *panicking;
+ char syncing[80], bbuf[5], *bp;
+
+ const char *panicstr[] =
+ {"panic: ifree: freeing free inode",
+ "panic: blkfree: freeing free block",
+ "panic: improbability coefficient below zero",
+ "panic: cgsixmmap",
+ "panic: crazy interrupts",
+ "panic: nmi",
+ "panic: attempted windows install",
+ "panic: don't",
+ "panic: free inode isn't",
+ "panic: cpu_fork: curproc",
+ "panic: malloc: out of space in kmem_map",
+ "panic: vogon starship detected",
+ "panic: teleport chamber: out of order",
+ "panic: Brain fried - core dumped"};
+
+ if (!get_boolean_resource("doBSD", "DoBSD"))
+ return False;
+
+ for (i = 0; i < sizeof(syncing); i++)
+ syncing[i] = 0;
+
+ i = (random() & 0xffff) % (sizeof(panicstr) / sizeof(*panicstr));
+
+ panicking = panicstr[i];
+ strcpy(syncing, "Syncing disks: ");
+
+ b = (random() & 0xff) % 40;
+ for (n = 0; (n < 20) && (b > 0); n++)
+ {
+ if (i)
+ {
+ i = (random() & 0x7);
+ b -= (random() & 0xff) % 20;
+ if (b < 0)
+ b = 0;
+ }
+ sprintf (bbuf, "%d ", b);
+ strcat (syncing, bbuf);
+ }
+
+ if (b)
+ rbstr = "damn!";
+ else
+ rbstr = "sunk!";
+
+ lines = 5;
+
+ XGetWindowAttributes (dpy, window, &xgwa);
+
+ fontname = get_string_resource ((xgwa.height > 600
+ ? "bsd.font2"
+ : "bsd.font"),
+ "BSD.Font");
+ if (!fontname || !*fontname) fontname = (char *)def_font;
+ font = XLoadQueryFont (dpy, fontname);
+ if (!font) font = XLoadQueryFont (dpy, def_font);
+ if (!font) exit(-1);
+ if (fontname && fontname != def_font)
+ free (fontname);
+
+ gcv.font = font->fid;
+ gcv.foreground = get_pixel_resource(("bsd.foreground"),
+ "BSD.Foreground",
+ dpy, xgwa.colormap);
+ gcv.background = get_pixel_resource(("bsd.background"),
+ "BSD.Background",
+ dpy, xgwa.colormap);
+ XSetWindowBackground(dpy, window, gcv.background);
+ XClearWindow(dpy, window);
+
+ gc = XCreateGC(dpy, window, GCFont|GCForeground|GCBackground, &gcv);
+
+ draw_string(dpy, window, gc, &gcv, font,
+ 10, xgwa.height - (lines * (font->ascent + font->descent + 1)),
+ 10, 10,
+ panicking, 0);
+ XSync(dpy, False);
+ lines--;
+
+ for (bp = syncing; *bp;)
+ {
+ char *bsd_bufs, oc = 0;
+ for (;*bp && (*bp != ' '); bp++)
+ ;
+ if (*bp == ' ')
+ {
+ oc = *bp;
+ *bp = 0;
+ }
+ bsd_bufs = strdup(syncing);
+ draw_string(dpy, window, gc, &gcv, font,
+ 10,
+ xgwa.height - (lines * (font->ascent + font->descent + 1)),
+ 10, 10,
+ bsd_bufs, 0);
+ XSync(dpy, False);
+ free(bsd_bufs);
+ if (oc)
+ *bp = oc;
+ if (bsod_sleep(dpy, -1))
+ goto DONE;
+ bp++;
+ }
+
+ lines--;
+
+ draw_string(dpy, window, gc, &gcv, font,
+ 10, xgwa.height - (lines * (font->ascent + font->descent + 1)),
+ 10, 10,
+ rbstr, 0);
+ lines--;
+ draw_string(dpy, window, gc, &gcv, font,
+ 10, xgwa.height - (lines * (font->ascent + font->descent + 1)),
+ 10, 10,
+ "Rebooting", 0);
+
+ XFreeGC(dpy, gc);
+ XSync(dpy, False);
+ bsod_sleep(dpy, delay);
+
+DONE:
+ XClearWindow(dpy, window);
+ XFreeFont(dpy, font);
+ return True;
+}
+
+static Bool