/******************************************************************************/
/*
- * $Id: xmas.c,v 1.20 2005/04/16 16:34:38 tom Exp $
+ * $Id: xmas.c,v 1.25 2009/08/29 18:47:26 tom Exp $
*/
#include <test.priv.h>
static WINDOW *lookdeer4;
static WINDOW *w_holiday;
static WINDOW *w_del_msg;
+static bool *my_pairs;
static int boxit(void);
static int seas(void);
set_color(WINDOW *win, chtype color)
{
if (has_colors()) {
- static bool *pairs;
int n = (color + 1);
- if (pairs == 0)
- pairs = (bool *) calloc((unsigned) (COLORS + 1), sizeof(bool));
- if (!pairs[n]) {
+ if (my_pairs == 0)
+ my_pairs = typeCalloc(bool, COLORS + 1);
+ if (!my_pairs[n]) {
init_pair(n, color, my_bg);
- pairs[n] = TRUE;
+ my_pairs[n] = TRUE;
}
wattroff(win, A_COLOR);
wattron(win, COLOR_PAIR(n));
unset_color(WINDOW *win)
{
if (has_colors())
- wattrset(win, COLOR_PAIR(0));
+ (void) wattrset(win, COLOR_PAIR(0));
}
static void
noecho();
nonl();
refresh();
- signal(SIGINT, done);
- signal(SIGTERM, done);
-#if !defined DOS && !defined OS2
- signal(SIGHUP, done);
- signal(SIGQUIT, done);
-#endif
+
+ CATCHALL(done);
+
if (has_colors()) {
start_color();
#if HAVE_USE_DEFAULT_COLORS
}
curs_set(0);
- treescrn = newwin(16, 27, 3, 53);
- treescrn2 = newwin(16, 27, 3, 53);
- treescrn3 = newwin(16, 27, 3, 53);
- treescrn4 = newwin(16, 27, 3, 53);
- treescrn5 = newwin(16, 27, 3, 53);
- treescrn6 = newwin(16, 27, 3, 53);
- treescrn7 = newwin(16, 27, 3, 53);
- treescrn8 = newwin(16, 27, 3, 53);
-
- dotdeer0 = newwin(3, 71, 0, 8);
-
- stardeer0 = newwin(4, 56, 0, 8);
-
- lildeer0 = newwin(7, 53, 0, 8);
- lildeer1 = newwin(2, 4, 0, 0);
- lildeer2 = newwin(2, 4, 0, 0);
- lildeer3 = newwin(2, 4, 0, 0);
-
- middeer0 = newwin(15, 42, 0, 8);
- middeer1 = newwin(3, 7, 0, 0);
- middeer2 = newwin(3, 7, 0, 0);
- middeer3 = newwin(3, 7, 0, 0);
-
- bigdeer0 = newwin(10, 23, 0, 0);
- bigdeer1 = newwin(10, 23, 0, 0);
- bigdeer2 = newwin(10, 23, 0, 0);
- bigdeer3 = newwin(10, 23, 0, 0);
- bigdeer4 = newwin(10, 23, 0, 0);
-
- lookdeer0 = newwin(10, 25, 0, 0);
- lookdeer1 = newwin(10, 25, 0, 0);
- lookdeer2 = newwin(10, 25, 0, 0);
- lookdeer3 = newwin(10, 25, 0, 0);
- lookdeer4 = newwin(10, 25, 0, 0);
-
- w_holiday = newwin(1, 26, 3, 27);
-
- w_del_msg = newwin(1, 19, 23, 60);
+ if ((treescrn = newwin(16, 27, 3, 53)) == 0 ||
+ (treescrn2 = newwin(16, 27, 3, 53)) == 0 ||
+ (treescrn3 = newwin(16, 27, 3, 53)) == 0 ||
+ (treescrn4 = newwin(16, 27, 3, 53)) == 0 ||
+ (treescrn5 = newwin(16, 27, 3, 53)) == 0 ||
+ (treescrn6 = newwin(16, 27, 3, 53)) == 0 ||
+ (treescrn7 = newwin(16, 27, 3, 53)) == 0 ||
+ (treescrn8 = newwin(16, 27, 3, 53)) == 0 ||
+
+ (dotdeer0 = newwin(3, 71, 0, 8)) == 0 ||
+
+ (stardeer0 = newwin(4, 56, 0, 8)) == 0 ||
+
+ (lildeer0 = newwin(7, 53, 0, 8)) == 0 ||
+ (lildeer1 = newwin(2, 4, 0, 0)) == 0 ||
+ (lildeer2 = newwin(2, 4, 0, 0)) == 0 ||
+ (lildeer3 = newwin(2, 4, 0, 0)) == 0 ||
+
+ (middeer0 = newwin(15, 42, 0, 8)) == 0 ||
+ (middeer1 = newwin(3, 7, 0, 0)) == 0 ||
+ (middeer2 = newwin(3, 7, 0, 0)) == 0 ||
+ (middeer3 = newwin(3, 7, 0, 0)) == 0 ||
+
+ (bigdeer0 = newwin(10, 23, 0, 0)) == 0 ||
+ (bigdeer1 = newwin(10, 23, 0, 0)) == 0 ||
+ (bigdeer2 = newwin(10, 23, 0, 0)) == 0 ||
+ (bigdeer3 = newwin(10, 23, 0, 0)) == 0 ||
+ (bigdeer4 = newwin(10, 23, 0, 0)) == 0 ||
+
+ (lookdeer0 = newwin(10, 25, 0, 0)) == 0 ||
+ (lookdeer1 = newwin(10, 25, 0, 0)) == 0 ||
+ (lookdeer2 = newwin(10, 25, 0, 0)) == 0 ||
+ (lookdeer3 = newwin(10, 25, 0, 0)) == 0 ||
+ (lookdeer4 = newwin(10, 25, 0, 0)) == 0 ||
+
+ (w_holiday = newwin(1, 26, 3, 27)) == 0 ||
+
+ (w_del_msg = newwin(1, 19, 23, 60)) == 0) {
+ endwin();
+ fprintf(stderr, "Cannot create windows - screen too small\n");
+ ExitProgram(EXIT_FAILURE);
+ }
mvwaddstr(w_del_msg, 0, 0, "Hit any key to quit");
mvwaddch(treescrn4, 12, 23, ' ');
/*star */
- wstandout(treescrn4);
+ (void) wstandout(treescrn4);
mvwaddch(treescrn4, 0, 12, '*');
- wstandend(treescrn4);
+ (void) wstandend(treescrn4);
/*strng1 */
mvwaddch(treescrn4, 3, 13, ' ');
mvwaddch(treescrn6, 11, 23, ' ');
/*star */
- wstandout(treescrn6);
+ (void) wstandout(treescrn6);
mvwaddch(treescrn6, 0, 12, '*');
- wstandend(treescrn6);
+ (void) wstandend(treescrn6);
/*strng1 */
static int
star(void)
{
- wattrset(treescrn2, A_BOLD | A_BLINK);
+ (void) wattrset(treescrn2, A_BOLD | A_BLINK);
set_color(treescrn2, COLOR_YELLOW);
mvwaddch(treescrn2, 0, 12, (chtype) '*');
- wstandend(treescrn2);
+ (void) wstandend(treescrn2);
unset_color(treescrn2);
wrefresh(treescrn2);
static int
strng1(void)
{
- wattrset(treescrn2, A_BOLD | A_BLINK);
+ (void) wattrset(treescrn2, A_BOLD | A_BLINK);
set_color(treescrn2, COLOR_WHITE);
mvwaddch(treescrn2, 3, 13, (chtype) '\'');
static int
strng2(void)
{
- wattrset(treescrn2, A_BOLD | A_BLINK);
+ (void) wattrset(treescrn2, A_BOLD | A_BLINK);
set_color(treescrn2, COLOR_WHITE);
mvwaddch(treescrn2, 5, 14, (chtype) '\'');
static int
strng3(void)
{
- wattrset(treescrn2, A_BOLD | A_BLINK);
+ (void) wattrset(treescrn2, A_BOLD | A_BLINK);
set_color(treescrn2, COLOR_WHITE);
mvwaddch(treescrn2, 7, 16, (chtype) '\'');
static int
strng4(void)
{
- wattrset(treescrn2, A_BOLD | A_BLINK);
+ (void) wattrset(treescrn2, A_BOLD | A_BLINK);
set_color(treescrn2, COLOR_WHITE);
mvwaddch(treescrn2, 9, 17, (chtype) '\'');
static int
strng5(void)
{
- wattrset(treescrn2, A_BOLD | A_BLINK);
+ (void) wattrset(treescrn2, A_BOLD | A_BLINK);
set_color(treescrn2, COLOR_WHITE);
mvwaddch(treescrn2, 11, 19, (chtype) '\'');
static RETSIGTYPE
done(int sig GCC_UNUSED)
{
- signal(SIGINT, done);
- signal(SIGTERM, done);
-#if !defined DOS && !defined OS2
- signal(SIGHUP, done);
- signal(SIGQUIT, done);
-#endif
+ CATCHALL(done);
+
move(LINES - 1, 0);
refresh();
endwin();
curs_set(1);
+
+#if NO_LEAKS
+ if (my_pairs != 0)
+ free(my_pairs);
+#endif
+
ExitProgram(EXIT_SUCCESS);
}