5 * Jordan Hubbard. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer,
12 * verbatim and that no modifications are made prior to this
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
18 * THIS SOFTWARE IS PROVIDED BY JORDAN HUBBARD ``AS IS'' AND
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL JORDAN HUBBARD OR HIS PETS BE LIABLE
22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, LIFE OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 #include <sys/signal.h>
34 #include <sys/fcntl.h>
36 const char *StartName; /* Initial contents of argv[0] */
37 const char *ProgName = "sade";
40 main(int argc, char **argv)
42 int choice, scroll, curr, max, status;
44 /* Record name to be able to restart */
47 signal(SIGPIPE, SIG_IGN);
49 /* We don't work too well when running as non-root anymore */
51 fprintf(stderr, "Error: This utility should only be run as root.\n");
58 char *p = getenv("TERM");
59 if (p && strcmp(p, "cons25") == 0)
60 setenv("TERM", "cons25w", 1);
64 /* Set up whatever things need setting up */
65 systemInitialize(argc, argv);
67 /* Set default flag and variable values */
68 installVarDefaults(NULL);
70 if (argc > 1 && !strcmp(argv[1], "-fake")) {
71 variable_set2(VAR_DEBUG, "YES", 0);
73 msgConfirm("I'll be just faking it from here on out, OK?");
75 if (argc > 1 && !strcmp(argv[1], "-restart"))
78 /* Try to preserve our scroll-back buffer */
80 for (curr = 0; curr < 25; curr++)
83 /* Move stderr aside */
87 /* Initialize driver modules, if we haven't already done so (ie,
88 the user hit Ctrl-C -> Restart. */
89 if (!pvariable_get("modulesInitialize")) {
90 pvariable_set("modulesInitialize=1");
93 /* Probe for all relevant devices on the system */
96 /* First, see if we have any arguments to process (and argv[0] counts if it's not "sysinstall") */
98 status = setjmp(BailOut);
100 msgConfirm("A signal %d was caught - I'm saving what I can and shutting\n"
101 "down. If you can reproduce the problem, please turn Debug on\n"
102 "in the Options menu for the extra information it provides\n"
103 "in debugging problems like this.", status);
107 /* Begin user dialog at outer menu */
110 choice = scroll = curr = max = 0;
111 dmenuOpen(&MenuMain, &choice, &scroll, &curr, &max, FALSE);
113 || !msgNoYes("Are you sure you wish to exit?")
118 /* Shut down curses */