msg.c revision 8097
18097Sjkh/*
28097Sjkh * The new sysinstall program.
38097Sjkh *
48097Sjkh * This is probably the last program in the `sysinstall' line - the next
58097Sjkh * generation being essentially a complete rewrite.
68097Sjkh *
78097Sjkh * $Id$
88097Sjkh *
98097Sjkh * Copyright (c) 1995
108097Sjkh *	Jordan Hubbard.  All rights reserved.
118097Sjkh *
128097Sjkh * Redistribution and use in source and binary forms, with or without
138097Sjkh * modification, are permitted provided that the following conditions
148097Sjkh * are met:
158097Sjkh * 1. Redistributions of source code must retain the above copyright
168097Sjkh *    notice, this list of conditions and the following disclaimer,
178097Sjkh *    verbatim and that no modifications are made prior to this
188097Sjkh *    point in the file.
198097Sjkh * 2. Redistributions in binary form must reproduce the above copyright
208097Sjkh *    notice, this list of conditions and the following disclaimer in the
218097Sjkh *    documentation and/or other materials provided with the distribution.
228097Sjkh * 3. All advertising materials mentioning features or use of this software
238097Sjkh *    must display the following acknowledgement:
248097Sjkh *	This product includes software developed by Jordan Hubbard
258097Sjkh *	for the FreeBSD Project.
268097Sjkh * 4. The name of Jordan Hubbard or the FreeBSD project may not be used to
278097Sjkh *    endorse or promote products derived from this software without specific
288097Sjkh *    prior written permission.
298097Sjkh *
308097Sjkh * THIS SOFTWARE IS PROVIDED BY JORDAN HUBBARD ``AS IS'' AND
318097Sjkh * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
328097Sjkh * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
338097Sjkh * ARE DISCLAIMED.  IN NO EVENT SHALL JORDAN HUBBARD OR HIS PETS BE LIABLE
348097Sjkh * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
358097Sjkh * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
368097Sjkh * OR SERVICES; LOSS OF USE, DATA, LIFE OR PROFITS; OR BUSINESS INTERRUPTION)
378097Sjkh * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
388097Sjkh * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
398097Sjkh * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
408097Sjkh * SUCH DAMAGE.
418097Sjkh *
428097Sjkh */
438097Sjkh
448097Sjkh#include "sysinstall.h"
458097Sjkh#include <stdarg.h>
468097Sjkh
478097Sjkh/* Whack up an informational message on the status line */
488097Sjkhvoid
498097SjkhmsgInfo(char *fmt, ...)
508097Sjkh{
518097Sjkh    va_list args;
528097Sjkh    char *errstr;
538097Sjkh
548097Sjkh    errstr = (char *)malloc(FILENAME_MAX);
558097Sjkh    errstr[0] = '\0';
568097Sjkh    va_start(args, fmt);
578097Sjkh    vsnprintf((char *)(errstr + strlen(errstr)), FILENAME_MAX, fmt, args);
588097Sjkh    va_end(args);
598097Sjkh    move(25, 0);
608097Sjkh    addstr(errstr);
618097Sjkh    free(errstr);
628097Sjkh}
638097Sjkh
648097Sjkh/* Whack up a warning on the status line */
658097Sjkhvoid
668097SjkhmsgWarn(char *fmt, ...)
678097Sjkh{
688097Sjkh    va_list args;
698097Sjkh    char *errstr;
708097Sjkh
718097Sjkh    errstr = (char *)malloc(FILENAME_MAX);
728097Sjkh    strcpy(errstr, "Warning: ");
738097Sjkh    va_start(args, fmt);
748097Sjkh    vsnprintf((char *)(errstr + strlen(errstr)), FILENAME_MAX, fmt, args);
758097Sjkh    va_end(args);
768097Sjkh    move(25, 0);
778097Sjkh    beep();
788097Sjkh    standout();
798097Sjkh    addstr(errstr);
808097Sjkh    standend();
818097Sjkh    free(errstr);
828097Sjkh}
838097Sjkh
848097Sjkh/* Whack up an error on the status line */
858097Sjkhvoid
868097SjkhmsgError(char *fmt, ...)
878097Sjkh{
888097Sjkh    va_list args;
898097Sjkh    char *errstr;
908097Sjkh
918097Sjkh    errstr = (char *)malloc(FILENAME_MAX);
928097Sjkh    strcpy(errstr, "Error: ");
938097Sjkh    va_start(args, fmt);
948097Sjkh    vsnprintf((char *)(errstr + strlen(errstr)), FILENAME_MAX, fmt, args);
958097Sjkh    va_end(args);
968097Sjkh    move(25, 0);
978097Sjkh    beep();
988097Sjkh    standout();
998097Sjkh    addstr(errstr);
1008097Sjkh    standend();
1018097Sjkh    free(errstr);
1028097Sjkh}
1038097Sjkh
1048097Sjkh/* Whack up a fatal error on the status line */
1058097Sjkhvoid
1068097SjkhmsgFatal(char *fmt, ...)
1078097Sjkh{
1088097Sjkh    va_list args;
1098097Sjkh    char *errstr;
1108097Sjkh
1118097Sjkh    errstr = (char *)malloc(FILENAME_MAX);
1128097Sjkh    strcpy(errstr, "Fatal Error: ");
1138097Sjkh    va_start(args, fmt);
1148097Sjkh    vsnprintf((char *)(errstr + strlen(errstr)), FILENAME_MAX, fmt, args);
1158097Sjkh    va_end(args);
1168097Sjkh    move(25, 0);
1178097Sjkh    beep();
1188097Sjkh    standout();
1198097Sjkh    addstr(errstr);
1208097Sjkh    addstr(" - ");
1218097Sjkh    addstr("PRESS ANY KEY TO ");
1228097Sjkh    if (getpid() == 1)
1238097Sjkh	addstr("REBOOT");
1248097Sjkh    else
1258097Sjkh	addstr("QUIT");
1268097Sjkh    standend();
1278097Sjkh    free(errstr);
1288097Sjkh    getch();
1298097Sjkh    systemShutdown();
1308097Sjkh}
1318097Sjkh
132