/*
** SellaNMS
** $Id: sella_nms.cxx,v 1.17 2005/03/31 18:57:12 sella Exp $
** Copyright (c) 2001-2005 Digital Genesis Software, LLC. All Rights Reserved.
** Released under the GPL Version 2 License.
** http://www.digitalgenesis.com
*/

#include "daemon.h"
#include "sella_nms.h"
#include "debug.h"
#include <signal.h>

#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)sella_nms.cxx";
#endif
static char rcsid[] = "$Id: sella_nms.cxx,v 1.17 2005/03/31 18:57:12 sella Exp $";

Daemon big_d;

void sighandler(int sig) {
	switch (sig) {
		case SIGHUP:
			big_d.processSignal(SIGHUP);	
			break;

		case SIGTERM:
			big_d.processSignal(SIGTERM);	
			break;

		case SIGUSR1:
			big_d.processSignal(SIGUSR1);	
			break;

		default:
			big_d.processSignal(sig);	
	}
}

int main(int argc, char** argv) {
	RESULT result;

	/* Install Signal Handlers */
	if (signal(SIGTERM, &sighandler) == SIG_ERR) {
		LMSG("Could not install signal handler for SIGTERM.");
	}
	if (signal(SIGHUP, &sighandler) == SIG_ERR) {
		LMSG("Could not install signal handler for SIGHUP.");
	}
	if (signal(SIGUSR1, &sighandler) == SIG_ERR) {
		LMSG("Could not install signal handler for SIGUSR1.");
	}
	if (signal(SIGUSR2, &sighandler) == SIG_ERR) {
		LMSG("Could not install signal handler for SIGUSR2.");
	}

	/* Kick the Daemon */
	result = big_d.start(argc, argv);

	return (result == SUCCESS ? EXIT_SUCCESS : EXIT_FAILURE);
}

/*
** Local Variables:
** c-basic-offset: 3
** tab-width: 3
** End:
** vim600: fdm=marker
** vim: noet ts=3 sw=3
*/
