2 * FreeBSD install - a package for the installation and maintainance
3 * of non-core utilities.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
17 * Miscellaneous message routines.
21 #include <sys/cdefs.h>
22 __FBSDID("$FreeBSD$");
28 /* Die a relatively simple death */
30 upchuck(const char *message
)
33 errx(1, "fatal error during execution: %s", message
);
37 * As a yes/no question, prompting from the varargs string and using
38 * default if user just hits return.
41 y_or_n(Boolean def
, const char *msg
, ...)
49 * Need to open /dev/tty because file collection may have been
52 tty
= fopen(_PATH_TTY
, "r");
55 errx(2, "can't open %s!", _PATH_TTY
);
57 while (ch
!= 'Y' && ch
!= 'N') {
58 vfprintf(stderr
, msg
, args
);
60 fprintf(stderr
, " [yes]? ");
62 fprintf(stderr
, " [no]? ");
65 ch
= (AutoAnswer
== YES
) ? 'Y' : 'N';
66 fprintf(stderr
, "%c\n", ch
);
69 ch
= toupper(fgetc(tty
));
71 ch
= (def
) ? 'Y' : 'N';
74 return (ch
== 'Y') ? TRUE
: FALSE
;