config/configurationoptions.cpp
config/configurationreader.cpp
config/host.cpp
+ config/option/daemonoption.cpp
+ config/option/configfileoption.cpp
config/option/configurationoption.cpp
config/option/hostconfigurationoption.cpp
config/option/hostpingintervaloption.cpp
config/option/pingfaillimitoption.cpp
config/option/sourcenetworkinterfaceoption.cpp
config/option/statusnotifiercmdoption.cpp
+ config/option/versionoption.cpp
dns/dnsresolver.cpp
dns/hostaddress.cpp
dns/timetolive.cpp
--- /dev/null
+/*
+ The software in this package is distributed under the GNU General
+ Public License version 2 (with a special exception described below).
+
+ A copy of GNU General Public License (GPL) is included in this distribution,
+ in the file COPYING.GPL.
+
+ As a special exception, if other files instantiate templates or use macros
+ or inline functions from this file, or you compile this file and link it
+ with other works to produce a work based on this file, this file
+ does not by itself cause the resulting work to be covered
+ by the GNU General Public License.
+
+ However the source code for this file must still be made available
+ in accordance with section (3) of the GNU General Public License.
+
+ This exception does not invalidate any other reasons why a work based
+ on this file might be covered by the GNU General Public License.
+ */
+
+#include "config/option/configfileoption.h"
+
+#include <iostream>
+
+#include <logfunc.hpp>
+
+using namespace std;
+using boost::program_options::value;
+using boost::program_options::variables_map;
+using I2n::Logger::GlobalLogger;
+
+//-----------------------------------------------------------------------------
+// ConfigFileOption
+//-----------------------------------------------------------------------------
+
+/**
+ * @brief Default constructor.
+ */
+ConfigFileOption::ConfigFileOption() :
+ ConfigurationOption(
+ "config-file",
+ value<string>()->default_value( "/etc/pingcheck.conf" ),
+ "Name of the configuration file."
+ )
+{
+}
+
+/**
+ * @brief Destructor.
+ */
+ConfigFileOption::~ConfigFileOption()
+{
+}
+
+bool ConfigFileOption::validate( const variables_map & ) const
+{
+ return true;
+}
+
+bool ConfigFileOption::parse(
+ const variables_map& vm,
+ Configuration *configuration
+)
+{
+ // config-file
+ if ( 1 <= vm.count( get_command_string() ) )
+ {
+ string config_file_name = vm[ get_command_string() ].as<string> ();
+ configuration->set_config_file_name( config_file_name );
+
+ GlobalLogger.info() << get_command_string() << "=" << config_file_name << endl;
+ return true;
+ }
+
+ return false;
+}
--- /dev/null
+/*
+ The software in this package is distributed under the GNU General
+ Public License version 2 (with a special exception described below).
+
+ A copy of GNU General Public License (GPL) is included in this distribution,
+ in the file COPYING.GPL.
+
+ As a special exception, if other files instantiate templates or use macros
+ or inline functions from this file, or you compile this file and link it
+ with other works to produce a work based on this file, this file
+ does not by itself cause the resulting work to be covered
+ by the GNU General Public License.
+
+ However the source code for this file must still be made available
+ in accordance with section (3) of the GNU General Public License.
+
+ This exception does not invalidate any other reasons why a work based
+ on this file might be covered by the GNU General Public License.
+ */
+
+#ifndef CONFIG_FILE_OPTION_H
+#define CONFIG_FILE_OPTION_H
+
+#include <boost/program_options.hpp>
+
+#include "config/option/configurationoption.h"
+
+//-----------------------------------------------------------------------------
+// ConfigFileOption
+//-----------------------------------------------------------------------------
+
+/**
+ * @brief Configuration file name option.
+ */
+class ConfigFileOption : public ConfigurationOption
+{
+public:
+ ConfigFileOption();
+ virtual ~ConfigFileOption();
+
+ virtual bool validate(
+ const boost::program_options::variables_map &vm
+ ) const;
+
+ virtual bool parse(
+ const boost::program_options::variables_map &vm,
+ Configuration *configuration
+ );
+
+};
+
+#endif // CONFIG_FILE_OPTION_H
--- /dev/null
+/*
+ The software in this package is distributed under the GNU General
+ Public License version 2 (with a special exception described below).
+
+ A copy of GNU General Public License (GPL) is included in this distribution,
+ in the file COPYING.GPL.
+
+ As a special exception, if other files instantiate templates or use macros
+ or inline functions from this file, or you compile this file and link it
+ with other works to produce a work based on this file, this file
+ does not by itself cause the resulting work to be covered
+ by the GNU General Public License.
+
+ However the source code for this file must still be made available
+ in accordance with section (3) of the GNU General Public License.
+
+ This exception does not invalidate any other reasons why a work based
+ on this file might be covered by the GNU General Public License.
+ */
+
+#include "config/option/daemonoption.h"
+
+#include <iostream>
+
+#include <logfunc.hpp>
+
+using namespace std;
+using boost::program_options::variables_map;
+using I2n::Logger::GlobalLogger;
+
+//-----------------------------------------------------------------------------
+// DaemonOption
+//-----------------------------------------------------------------------------
+
+/**
+ * @brief Default constructor.
+ */
+DaemonOption::DaemonOption() :
+ ConfigurationOption( "daemon", "Run the evil in background." )
+{
+}
+
+/**
+ * @brief Destructor.
+ */
+DaemonOption::~DaemonOption()
+{
+}
+
+bool DaemonOption::validate( const variables_map & ) const
+{
+ return true;
+}
+
+bool DaemonOption::parse(
+ const variables_map& vm,
+ Configuration *configuration
+)
+{
+ // daemon
+ bool have_daemon = ( 1<= vm.count( get_command_string() ) );
+ configuration->set_daemon( have_daemon );
+ GlobalLogger.info() << get_command_string() << "=" << have_daemon << endl;
+
+ return false;
+}
--- /dev/null
+/*
+ The software in this package is distributed under the GNU General
+ Public License version 2 (with a special exception described below).
+
+ A copy of GNU General Public License (GPL) is included in this distribution,
+ in the file COPYING.GPL.
+
+ As a special exception, if other files instantiate templates or use macros
+ or inline functions from this file, or you compile this file and link it
+ with other works to produce a work based on this file, this file
+ does not by itself cause the resulting work to be covered
+ by the GNU General Public License.
+
+ However the source code for this file must still be made available
+ in accordance with section (3) of the GNU General Public License.
+
+ This exception does not invalidate any other reasons why a work based
+ on this file might be covered by the GNU General Public License.
+ */
+
+#ifndef DAEMON_OPTION_H
+#define DAEMON_OPTION_H
+
+#include <boost/program_options.hpp>
+
+#include "config/option/configurationoption.h"
+
+//-----------------------------------------------------------------------------
+// DaemonOption
+//-----------------------------------------------------------------------------
+
+/**
+ * @brief Daemon option.
+ */
+class DaemonOption : public ConfigurationOption
+{
+public:
+ DaemonOption();
+ virtual ~DaemonOption();
+
+ virtual bool validate(
+ const boost::program_options::variables_map &vm
+ ) const;
+
+ virtual bool parse(
+ const boost::program_options::variables_map &vm,
+ Configuration *configuration
+ );
+
+};
+
+#endif // DAEMON_OPTION_H
--- /dev/null
+/*
+ The software in this package is distributed under the GNU General
+ Public License version 2 (with a special exception described below).
+
+ A copy of GNU General Public License (GPL) is included in this distribution,
+ in the file COPYING.GPL.
+
+ As a special exception, if other files instantiate templates or use macros
+ or inline functions from this file, or you compile this file and link it
+ with other works to produce a work based on this file, this file
+ does not by itself cause the resulting work to be covered
+ by the GNU General Public License.
+
+ However the source code for this file must still be made available
+ in accordance with section (3) of the GNU General Public License.
+
+ This exception does not invalidate any other reasons why a work based
+ on this file might be covered by the GNU General Public License.
+ */
+
+#include "config/option/versionoption.h"
+
+#include <iostream>
+
+#include <logfunc.hpp>
+
+using namespace std;
+using boost::program_options::variables_map;
+using I2n::Logger::GlobalLogger;
+
+//-----------------------------------------------------------------------------
+// VersionOption
+//-----------------------------------------------------------------------------
+
+/**
+ * @brief Default constructor.
+ */
+VersionOption::VersionOption() :
+ ConfigurationOption( "version", "Print the version string and exit." )
+{
+}
+
+/**
+ * @brief Destructor.
+ */
+VersionOption::~VersionOption()
+{
+}
+
+bool VersionOption::validate( const variables_map & ) const
+{
+ return true;
+}
+
+bool VersionOption::parse(
+ const variables_map& vm,
+ Configuration *
+)
+{
+ // version
+ if ( 1 <= vm.count( get_command_string() ) )
+ {
+ // TODO GlobalOutput::print( version )
+ cout << PROJECT_NAME << " version " << VERSION_STRING << endl;
+ return true;
+ }
+
+ return false;
+}
--- /dev/null
+/*
+ The software in this package is distributed under the GNU General
+ Public License version 2 (with a special exception described below).
+
+ A copy of GNU General Public License (GPL) is included in this distribution,
+ in the file COPYING.GPL.
+
+ As a special exception, if other files instantiate templates or use macros
+ or inline functions from this file, or you compile this file and link it
+ with other works to produce a work based on this file, this file
+ does not by itself cause the resulting work to be covered
+ by the GNU General Public License.
+
+ However the source code for this file must still be made available
+ in accordance with section (3) of the GNU General Public License.
+
+ This exception does not invalidate any other reasons why a work based
+ on this file might be covered by the GNU General Public License.
+ */
+
+#ifndef VERSION_OPTION_H
+#define VERSION_OPTION_H
+
+#include <boost/program_options.hpp>
+
+#include "config/option/configurationoption.h"
+
+//-----------------------------------------------------------------------------
+// VersionOption
+//-----------------------------------------------------------------------------
+
+/**
+ * @brief Version option.
+ */
+class VersionOption : public ConfigurationOption
+{
+public:
+ VersionOption();
+ virtual ~VersionOption();
+
+ virtual bool validate(
+ const boost::program_options::variables_map &vm
+ ) const;
+
+ virtual bool parse(
+ const boost::program_options::variables_map &vm,
+ Configuration *configuration
+ );
+
+};
+
+#endif // VERSION_OPTION_H