/*
** SellaNMS
** $Id: daemon.h,v 1.36 2005/05/15 05:21:17 sella Exp $
** Copyright (c) 2001-2005 Digital Genesis Software, LLC. All Rights Reserved.
** Released under the GPL Version 2 License.
** http://www.digitalgenesis.com
*/

#ifndef __DGS_DAEMON_H
#define __DGS_DAEMON_H

#ifdef HAVE_CONFIG_H
	#include "config.h"
#endif

#include "defaults.h"
#include "modules/module.h"
#include "configuration/configuration.h"
#include <stl/slist>
#include <stl/string>
#include <stl/vector>

#define DEFAULT_SYSLOG_FACILITY  LOG_LOCAL0

class Daemon: public Module {
	public:
		Daemon();
		virtual ~Daemon();

		RESULT start(int argc, char** argv);
		RESULT processSignal(int sig);

	protected:
		virtual RESULT usage();
		virtual RESULT version();
		virtual RESULT about();
		virtual RESULT checkEuidRoot();
		virtual RESULT processCommandLine(int argc, char** argv);
		virtual RESULT processConfig();
		virtual RESULT processDaemonOptions();
		virtual RESULT reloadConfigNode();

		virtual RESULT loadConfigModule();
		virtual RESULT getRootConfigNode();
		virtual RESULT loadSupportLibraries();
		virtual RESULT unloadSupportLibraries();
		virtual RESULT writePidFile();

	private:
		Configuration *config_mod;

		vector<string> storage_v;
		vector<string> daemon_dso_v;

		slist<void*> supportLibs;

		string project;
		string daemon;
		string config_file;
		string config_dso;
		string module;
		string group;
		string user;
		string log;
		string pid_file;
		string stat_file;

		bool test_flag;
		bool usage_flag;
		bool about_flag;
		bool version_flag;
		bool discover_flag;
		bool monitor_flag;
		bool output_flag;
		bool foreground_flag;
		bool daemon_running;

		int nice;
		int facility;
		int severity;
		int major_version;
		int minor_version;
		int revision;
		int debug;

		time_t lastSignal;
};

#endif

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