2 * The new sysinstall program.
4 * This is probably the last program in the `sysinstall' line - the next
5 * generation being essentially a complete rewrite.
10 * Jordan Hubbard. All rights reserved.
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer,
17 * verbatim and that no modifications are made prior to this
19 * 2. Redistributions in binary form must reproduce the above copyright
20 * notice, this list of conditions and the following disclaimer in the
21 * documentation and/or other materials provided with the distribution.
23 * THIS SOFTWARE IS PROVIDED BY JORDAN HUBBARD ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL JORDAN HUBBARD OR HIS PETS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, LIFE OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 #include "sysinstall.h"
39 #include <sys/ioctl.h>
40 #include <sys/consio.h>
47 return (cp = variable_get(VAR_DEBUG)) && strcmp(cp, "no");
50 /* Whack up an informational message on the status line, in stand-out */
52 msgYap(char *fmt, ...)
58 errstr = (char *)alloca(FILENAME_MAX);
60 vsnprintf(errstr, FILENAME_MAX, fmt, args);
62 attrs = getattrs(stdscr);
64 mvaddstr(StatusLine, 0, errstr);
69 /* Whack up an informational message on the status line */
71 msgInfo(char *fmt, ...)
78 attrs = getattrs(stdscr);
79 /* NULL is a special convention meaning "erase the old stuff" */
85 errstr = (char *)alloca(FILENAME_MAX);
87 vsnprintf(errstr, FILENAME_MAX, fmt, args);
89 memset(line, ' ', 80);
90 for (i = 0; i < 80; i++) {
98 mvaddstr(StatusLine, 0, line);
100 move(StatusLine, 79);
104 /* Whack up a warning on the status line */
106 msgWarn(char *fmt, ...)
112 errstr = (char *)alloca(FILENAME_MAX);
113 strcpy(errstr, "Warning: ");
115 vsnprintf((char *)(errstr + strlen(errstr)), FILENAME_MAX, fmt, args);
117 attrs = getattrs(stdscr);
120 mvaddstr(StatusLine, 0, errstr);
123 if (OnVTY && isDebug())
124 msgDebug("Warning message `%s'\n", errstr);
127 /* Whack up an error on the status line */
129 msgError(char *fmt, ...)
135 errstr = (char *)alloca(FILENAME_MAX);
136 strcpy(errstr, "Error: ");
138 vsnprintf((char *)(errstr + strlen(errstr)), FILENAME_MAX, fmt, args);
141 attrs = getattrs(stdscr);
143 mvaddstr(StatusLine, 0, errstr);
146 if (OnVTY && isDebug())
147 msgDebug("Error message `%s'\n", errstr);
150 /* Whack up a fatal error on the status line */
152 msgFatal(char *fmt, ...)
158 errstr = (char *)alloca(FILENAME_MAX);
159 strcpy(errstr, "Fatal Error: ");
161 vsnprintf((char *)(errstr + strlen(errstr)), FILENAME_MAX, fmt, args);
164 attrs = getattrs(stdscr);
166 mvaddstr(StatusLine, 0, errstr);
168 addstr("PRESS ANY KEY TO ");
176 msgDebug("Fatal error `%s'!\n", errstr);
181 /* Put up a message in a popup confirmation box */
183 msgConfirm(char *fmt, ...)
187 WINDOW *w = savescr();
189 errstr = (char *)alloca(FILENAME_MAX);
191 vsnprintf(errstr, FILENAME_MAX, fmt, args);
196 ioctl(0, VT_ACTIVATE, 1);
199 dialog_notify(errstr);
203 /* Put up a message in a popup information box */
205 msgNotify(char *fmt, ...)
210 errstr = (char *)alloca(FILENAME_MAX);
212 vsnprintf(errstr, FILENAME_MAX, fmt, args);
217 msgDebug("Notify: %s\n", errstr);
218 dialog_msgbox(NULL, errstr, -1, -1, 0);
221 /* Put up a message in a popup yes/no box and return 0 for YES, 1 for NO */
223 msgYesNo(char *fmt, ...)
228 WINDOW *w = savescr();
230 errstr = (char *)alloca(FILENAME_MAX);
232 vsnprintf(errstr, FILENAME_MAX, fmt, args);
237 ioctl(0, VT_ACTIVATE, 1); /* Switch back */
240 if (variable_get(VAR_NONINTERACTIVE))
241 return 0; /* If non-interactive, return YES all the time */
242 ret = dialog_yesno("User Confirmation Requested", errstr, -1, -1);
247 /* Put up a message in a popup no/yes box and return 0 for YES, 1 for NO */
249 msgNoYes(char *fmt, ...)
254 WINDOW *w = savescr();
256 errstr = (char *)alloca(FILENAME_MAX);
258 vsnprintf(errstr, FILENAME_MAX, fmt, args);
263 ioctl(0, VT_ACTIVATE, 1); /* Switch back */
266 if (variable_get(VAR_NONINTERACTIVE))
267 return 1; /* If non-interactive, return NO all the time */
268 ret = dialog_noyes("User Confirmation Requested", errstr, -1, -1);
273 /* Put up a message in an input box and return the value */
275 msgGetInput(char *buf, char *fmt, ...)
279 static char input_buffer[256];
281 WINDOW *w = savescr();
283 errstr = (char *)alloca(FILENAME_MAX);
285 vsnprintf(errstr, FILENAME_MAX, fmt, args);
290 SAFE_STRCPY(input_buffer, buf);
292 input_buffer[0] = '\0';
294 ioctl(0, VT_ACTIVATE, 1); /* Switch back */
297 rval = dialog_inputbox("Value Required", errstr, -1, -1, input_buffer);
305 /* Write something to the debugging port */
307 msgDebug(char *fmt, ...)
314 dbg = (char *)alloca(FILENAME_MAX);
315 strcpy(dbg, "DEBUG: ");
317 vsnprintf((char *)(dbg + strlen(dbg)), FILENAME_MAX, fmt, args);
319 write(DebugFD, dbg, strlen(dbg));
322 /* Tell the user there's some output to go look at */
324 msgWeHaveOutput(char *fmt, ...)
328 WINDOW *w = savescr();
330 errstr = (char *)alloca(FILENAME_MAX);
332 vsnprintf(errstr, FILENAME_MAX, fmt, args);
336 msgDebug("Notify: %s\n", errstr);
337 dialog_clear_norefresh();
339 dialog_msgbox(NULL, errstr, -1, -1, 0);
343 /* Simple versions of msgConfirm() and msgNotify() for calling from scripts */
345 msgSimpleConfirm(char *str)
347 msgConfirm("%s", str);
348 return DITEM_SUCCESS;
352 msgSimpleNotify(char *str)
354 msgNotify("%s", str);
355 return DITEM_SUCCESS;