changed paths of DNS cache (now in /var/cache) and dumped packets; dump only if ...
[pingcheck] / src / config / option / dnscachefileoption.cpp
1 /*
2  The software in this package is distributed under the GNU General
3  Public License version 2 (with a special exception described below).
4
5  A copy of GNU General Public License (GPL) is included in this distribution,
6  in the file COPYING.GPL.
7
8  As a special exception, if other files instantiate templates or use macros
9  or inline functions from this file, or you compile this file and link it
10  with other works to produce a work based on this file, this file
11  does not by itself cause the resulting work to be covered
12  by the GNU General Public License.
13
14  However the source code for this file must still be made available
15  in accordance with section (3) of the GNU General Public License.
16
17  This exception does not invalidate any other reasons why a work based
18  on this file might be covered by the GNU General Public License.
19  */
20
21 #include "config/option/dnscachefileoption.h"
22
23 #include <iostream>
24
25 #include <logfunc.hpp>
26
27 using namespace std;
28 using boost::program_options::value;
29 using boost::program_options::variables_map;
30 using I2n::Logger::GlobalLogger;
31
32 //-----------------------------------------------------------------------------
33 // DnsCacheFileOption
34 //-----------------------------------------------------------------------------
35
36 /**
37  * @brief Default constructor.
38  */
39 DnsCacheFileOption::DnsCacheFileOption() :
40     ConfigurationOption(
41         "dns-cache-file",
42         value<string>()->default_value( "/var/cache/pingcheck_dns_cache.xml" ),
43         "Name of the DNS cache file."
44     )
45 {
46 }
47
48 /**
49  * @brief Destructor.
50  */
51 DnsCacheFileOption::~DnsCacheFileOption()
52 {
53 }
54
55 bool DnsCacheFileOption::parse(
56         const variables_map& vm,
57         Configuration *configuration
58 )
59 {
60     // dns-cache-file
61     if ( 1 <= vm.count( get_command_string() ) )
62     {
63         string dns_cache_file = vm[ get_command_string() ].as<string> ();
64         configuration->set_dns_cache_file( dns_cache_file );
65
66         GlobalLogger.info() << get_command_string() << "=" << dns_cache_file
67                             << endl;
68         return true;
69     }
70
71     return false;
72 }