Commit 322403fe authored by Francis Dupont's avatar Francis Dupont
Browse files

[3513] Added the code for -W, now working on the doc

parent 57303e24
AM_CPPFLAGS = -I$(top_srcdir)/src/bin -I$(top_builddir)/src/bin
# Get rid of generated message files on a clean
CLEANFILES = *.gcno *.gcda
......@@ -7,4 +9,4 @@ DISTCLEANFILES = config_report.cc
# convenience archive
noinst_LTLIBRARIES = libcfgrpt.la
libcfgrpt_la_SOURCES = config_report.h config_report.cc
libcfgrpt_la_SOURCES = config_report.h config_report.cc cfgrpt.cc
// Copyright (C) 2015 Internet Systems Consortium, Inc. ("ISC")
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
#include <sstream>
#include <cfgrpt/config_report.h>
namespace isc {
namespace detail {
// The config_report array finished by an empty line ("")
// Each line before this final one begins by four semicolons (;;;;)
// in order to be easy to extract from binaries.
std::string
getConfigReport() {
std::stringstream tmp;
size_t linenum = 0;
for (;;) {
const char* const line = config_report[linenum++];
if (line[0] == '\0')
break;
tmp << line + 4 << std::endl;
}
return (tmp.str());
}
}
}
......@@ -20,6 +20,11 @@ namespace detail {
extern const char* const config_report[];
// The config_report array finished by an empty line ("")
// Each line before this final one begins by four semicolons (;;;;)
// in order to be easy to extract from binaries.
std::string getConfigReport();
}
}
......
......@@ -134,7 +134,7 @@ DControllerBase::parseArgs(int argc, char* argv[])
int ch;
opterr = 0;
optind = 1;
std::string opts("dvVc:" + getCustomOpts());
std::string opts("dvVWc:" + getCustomOpts());
while ((ch = getopt(argc, argv, opts.c_str())) != -1) {
switch (ch) {
case 'd':
......@@ -154,6 +154,12 @@ DControllerBase::parseArgs(int argc, char* argv[])
isc_throw(VersionMessage, getVersion(true));
break;
case 'W':
// gather Kea config report and throw so main() can catch and
// return rather than calling exit() here which disrupts gtest.
isc_throw(VersionMessage, isc::detail::getConfigReport());
break;
case 'c':
// config file name
if (optarg == NULL) {
......@@ -435,6 +441,8 @@ DControllerBase::usage(const std::string & text)
<< " -d: optional, verbose output " << std::endl
<< " -v: print version number and exit" << std::endl
<< " -V: print extended version information and exit"
<< std::endl
<< " -W: display the configuration report and exit"
<< std::endl;
// add any derivation specific usage
......
......@@ -19,6 +19,7 @@
#include <dhcpsrv/cfgmgr.h>
#include <log/logger_support.h>
#include <log/logger_manager.h>
#include <cfgrpt/config_report.h>
#include <boost/lexical_cast.hpp>
......@@ -48,13 +49,14 @@ usage() {
cerr << "Kea DHCPv4 server, version " << VERSION << endl;
cerr << endl;
cerr << "Usage: " << DHCP4_NAME
<< " [-v] [-V] [-d] [-p number] [-c file]" << endl;
<< " -[v|V|W] [-d] [-p number] [-c file]" << endl;
cerr << " -c file: specify configuration file" << endl;
cerr << " -d: debug mode with extra verbosity (former -v)" << endl;
cerr << " -p number: specify non-standard port number 1-65535 "
<< "(useful for testing only)" << endl;
cerr << " -v: print version number and exit" << endl;
cerr << " -V: print extended version and exit" << endl;
cerr << " -W: display the configuration report and exit" << endl;
exit(EXIT_FAILURE);
}
} // end of anonymous namespace
......@@ -69,7 +71,7 @@ main(int argc, char* argv[]) {
// The standard config file
std::string config_file("");
while ((ch = getopt(argc, argv, "dvVp:c:")) != -1) {
while ((ch = getopt(argc, argv, "dvVWp:c:")) != -1) {
switch (ch) {
case 'd':
verbose_mode = true;
......@@ -83,6 +85,10 @@ main(int argc, char* argv[]) {
cout << Daemon::getVersion(true) << endl;
return (EXIT_SUCCESS);
case 'W':
cout << isc::detail::getConfigReport() << endl;
return (EXIT_SUCCESS);
case 'p':
try {
port_number = boost::lexical_cast<int>(optarg);
......
......@@ -20,6 +20,7 @@
#include <log/logger_support.h>
#include <log/logger_manager.h>
#include <exceptions/exceptions.h>
#include <cfgrpt/config_report.h>
#include <boost/lexical_cast.hpp>
......@@ -50,10 +51,11 @@ usage() {
cerr << "Kea DHCPv6 server, version " << VERSION << endl;
cerr << endl;
cerr << "Usage: " << DHCP6_NAME
<< " [-c cfgfile] [-v] [-V] [-d] [-p port_number]" << endl;
<< " [-c cfgfile] -[v|V|W] [-d] [-p port_number]" << endl;
cerr << " -c file: specify configuration file" << endl;
cerr << " -v: print version number and exit." << endl;
cerr << " -V: print extended version and exit" << endl;
cerr << " -W: display the configuration report and exit" << endl;
cerr << " -d: debug mode with extra verbosity (former -v)" << endl;
cerr << " -p number: specify non-standard port number 1-65535 "
<< "(useful for testing only)" << endl;
......@@ -71,7 +73,7 @@ main(int argc, char* argv[]) {
// The standard config file
std::string config_file("");
while ((ch = getopt(argc, argv, "dvVp:c:")) != -1) {
while ((ch = getopt(argc, argv, "dvVWp:c:")) != -1) {
switch (ch) {
case 'd':
verbose_mode = true;
......@@ -85,6 +87,10 @@ main(int argc, char* argv[]) {
cout << Daemon::getVersion(true) << endl;
return (EXIT_SUCCESS);
case 'W':
cout << isc::detail::getConfigReport() << endl;
return (EXIT_SUCCESS);
case 'p': // port number
try {
port_number = boost::lexical_cast<int>(optarg);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment