Deleted Added
sdiff udiff text old ( 50479 ) new ( 54587 )
full compact
1/*
2 * The new sysinstall program.
3 *
4 * This is probably the last program in the `sysinstall' line - the next
5 * generation being essentially a complete rewrite.
6 *
7 * $FreeBSD: head/usr.sbin/sade/msg.c 50479 1999-08-28 01:35:59Z peter $
8 *
9 * Copyright (c) 1995
10 * Jordan Hubbard. All rights reserved.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright

--- 163 unchanged lines hidden (view full) ---

179}
180
181/* Put up a message in a popup confirmation box */
182void
183msgConfirm(char *fmt, ...)
184{
185 va_list args;
186 char *errstr;
187
188 errstr = (char *)alloca(FILENAME_MAX);
189 va_start(args, fmt);
190 vsnprintf(errstr, FILENAME_MAX, fmt, args);
191 va_end(args);
192 use_helpline(NULL);
193 use_helpfile(NULL);
194 if (OnVTY) {
195 ioctl(0, VT_ACTIVATE, 1);
196 msgInfo(NULL);
197 }
198 dialog_notify(errstr);
199}
200
201/* Put up a message in a popup information box */
202void
203msgNotify(char *fmt, ...)
204{
205 va_list args;
206 char *errstr;
207
208 errstr = (char *)alloca(FILENAME_MAX);
209 va_start(args, fmt);
210 vsnprintf(errstr, FILENAME_MAX, fmt, args);
211 va_end(args);
212 use_helpline(NULL);
213 use_helpfile(NULL);
214 if (isDebug())
215 msgDebug("Notify: %s\n", errstr);
216 dialog_clear_norefresh();
217 dialog_msgbox(NULL, errstr, -1, -1, 0);
218}
219
220/* Put up a message in a popup yes/no box and return 1 for YES, 0 for NO */
221int
222msgYesNo(char *fmt, ...)
223{
224 va_list args;
225 char *errstr;
226 int ret;
227
228 errstr = (char *)alloca(FILENAME_MAX);
229 va_start(args, fmt);
230 vsnprintf(errstr, FILENAME_MAX, fmt, args);
231 va_end(args);
232 use_helpline(NULL);
233 use_helpfile(NULL);
234 if (OnVTY) {
235 ioctl(0, VT_ACTIVATE, 1); /* Switch back */
236 msgInfo(NULL);
237 }
238 ret = dialog_yesno("User Confirmation Requested", errstr, -1, -1);
239 return ret;
240}
241
242/* Put up a message in an input box and return the value */
243char *
244msgGetInput(char *buf, char *fmt, ...)
245{
246 va_list args;
247 char *errstr;
248 static char input_buffer[256];
249 int rval;
250
251 errstr = (char *)alloca(FILENAME_MAX);
252 va_start(args, fmt);
253 vsnprintf(errstr, FILENAME_MAX, fmt, args);
254 va_end(args);
255 use_helpline(NULL);
256 use_helpfile(NULL);
257 if (buf)
258 SAFE_STRCPY(input_buffer, buf);
259 else
260 input_buffer[0] = '\0';
261 if (OnVTY) {
262 ioctl(0, VT_ACTIVATE, 1); /* Switch back */
263 msgInfo(NULL);
264 }
265 rval = dialog_inputbox("Value Required", errstr, -1, -1, input_buffer);
266 if (!rval)
267 return input_buffer;
268 else
269 return NULL;
270}
271
272/* Write something to the debugging port */
273void

--- 13 unchanged lines hidden (view full) ---

287}
288
289/* Tell the user there's some output to go look at */
290void
291msgWeHaveOutput(char *fmt, ...)
292{
293 va_list args;
294 char *errstr;
295
296 errstr = (char *)alloca(FILENAME_MAX);
297 va_start(args, fmt);
298 vsnprintf(errstr, FILENAME_MAX, fmt, args);
299 va_end(args);
300 use_helpline(NULL);
301 use_helpfile(NULL);
302 msgDebug("Notify: %s\n", errstr);
303 dialog_clear_norefresh();
304 dialog_msgbox(NULL, errstr, -1, -1, 0);
305}
306
307/* Simple versions of msgConfirm() and msgNotify() for calling from scripts */
308int
309msgSimpleConfirm(char *str)
310{
311 msgConfirm(str);
312 return DITEM_SUCCESS;
313}
314
315int
316msgSimpleNotify(char *str)
317{
318 msgNotify(str);
319 return DITEM_SUCCESS;
320}