/*
 * joshua.c
 *
 * Copyright (C) 2007, 2008 Erik Scharwaechter <erik@diozaka.org>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <signal.h>

#define VERSION "0.19"

void print_banner(void)
{
	printf("%s", "joshua " VERSION " \n"
	             "Copyright (c) 2007, 2008 Erik Scharwaechter <erik@diozaka.org>\n"
	             "     _ _               _\n"
	             "  __| (_) ___ ______ _| | ____ _   ___  _ __ __ _ \n"
	             " / _` | |/ _ \\_  / _` | |/ / _` | / _ \\| '__/ _` |\n"
	             "| (_| | | (_) / / (_| |   < (_| || (_) | | | (_| |\n"
	             " \\__,_|_|\\___/___\\__,_|_|\\_\\__,_(_)___/|_|  \\__, |\n"
	             "                                            |___/ \n\n");
}

void die_happy()
{
	printf("%s", "\nA STRANGE GAME. THE ONLY WINNING MOVE IS NOT TO PLAY.\n");
	exit(0);
}

int wait_for_input(void)
{
	printf("%s", "GREETINGS PROFESSOR FALKEN.\n\n"
	             "> ");
	return getchar();
}

void sighandler(int signal)
{
	if (signal == SIGINT
	        || signal == SIGTERM) {
	        die_happy();
	}
}

int main(void)
{
	signal(SIGINT, sighandler);
	signal(SIGTERM, sighandler);

	print_banner();

	if (wait_for_input() == EOF)
		die_happy();

	/* why? oh, why...? */
	*(int *)NULL = 0xDEADBEEF;

	return -1; /* not rly */
}

