Change default database path and configuration directory
Now respectively ${LOCALSTATEDIR}/lib/ndn/ndns/ndns.db
and ${SYSCONFDIR}/ndn/ndns
Refs: #4810
Change-Id: I351a6a15f8daa0a032845cb26d5d76179faa7b27
diff --git a/docs/doxygen.conf.in b/docs/doxygen.conf.in
index 06122a5..5ba77c2 100644
--- a/docs/doxygen.conf.in
+++ b/docs/doxygen.conf.in
@@ -2024,19 +2024,12 @@
PREDEFINED = DOXYGEN=1 \
NDNS_LOG_INIT(x)= \
- NDNS_LOG_INCLASS_DEFINE(a,b)= \
- NDNS_LOG_INCLASS_TEMPLATE_SPECIALIZATION_DEFINE(a,b,c)= \
- NDNS_LOG_INCLASS_2TEMPLATE_SPECIALIZATION_DEFINE(a,b,c,d)= \
- BOOST_STATIC_ASSERT(x)= \
BOOST_CONCEPT_ASSERT(x)= \
BOOST_CONCEPT_REQUIRES(x)= \
- DECL_OVERRIDE=override \
- NDNS_VIRTUAL_WITH_TESTS=virtual \
- NDNS_PUBLIC_WITH_TESTS_ELSE_PROTECTED=public \
- NDNS_PUBLIC_WITH_TESTS_ELSE_PRIVATE=public \
- NDNS_PROTECTED_WITH_TESTS_ELSE_PRIVATE=protected \
- DECL_CLASS_FINAL=final \
- DECL_FINAL=final
+ NDNS_PUBLIC_WITH_TESTS_ELSE_PROTECTED=protected \
+ NDNS_PUBLIC_WITH_TESTS_ELSE_PRIVATE=private \
+ NDNS_PROTECTED_WITH_TESTS_ELSE_PRIVATE=private \
+ NDNS_VIRTUAL_WITH_TESTS=
# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this
# tag can be used to specify a list of macro names that should be expanded. The
diff --git a/docs/ndns-db-manage.rst b/docs/ndns-db-manage.rst
index 84c5abb..3518684 100644
--- a/docs/ndns-db-manage.rst
+++ b/docs/ndns-db-manage.rst
@@ -6,12 +6,12 @@
``sqlite3`` installed
-
Create the database
-------------------
-Set the attribute ``dbfile`` in the NDNS configuration file, e.g., ``${SYSCONFDIR}/ndn/ndns.conf`` (``/etc/ndn/ndns.conf``), to the desired path of the database file.
-By default, ``dbfile`` is assigned to ``${LOCALSTATEDIR}/lib/ndns/ndns.db`` (``/var/lib/ndns/ndns.db``).
+Set the attribute ``dbFile`` in the NDNS configuration file, e.g., ``${SYSCONFDIR}/ndn/ndns/ndns.conf``
+(``/etc/ndn/ndns/ndns.conf``), to the desired path of the database file. By default, ``dbFile`` is equal
+to ``${LOCALSTATEDIR}/lib/ndn/ndns/ndns.db`` (``/var/lib/ndn/ndns/ndns.db``).
When NDNS started, an empty database will be automatically created.
diff --git a/ndns.conf.sample.in b/ndns.conf.sample.in
index e595004..09521a3 100644
--- a/ndns.conf.sample.in
+++ b/ndns.conf.sample.in
@@ -1,7 +1,7 @@
zones
{
- ; dbFile @DEFAULT_DATABASE_PATH@/ndns.db
- ; validatorConfigFile @DEFAULT_CONFIG_PATH@/validator.conf
+ ; dbFile @DEFAULT_DBFILE@
+ ; validatorConfigFile @CONFDIR@/validator.conf
zone
{
diff --git a/src/daemon/db-mgr.cpp b/src/daemon/db-mgr.cpp
index ef5f23c..da40d58 100644
--- a/src/daemon/db-mgr.cpp
+++ b/src/daemon/db-mgr.cpp
@@ -20,6 +20,7 @@
#include "db-mgr.hpp"
#include "logger.hpp"
#include "clients/response.hpp"
+#include "util/util.hpp"
namespace ndn {
namespace ndns {
@@ -53,12 +54,12 @@
ON rrsets (zone_id, label, type, version);
)VALUE";
-DbMgr::DbMgr(const std::string& dbFile/* = DEFAULT_CONFIG_PATH "/" "ndns.db"*/)
+DbMgr::DbMgr(const std::string& dbFile)
: m_dbFile(dbFile)
, m_conn(nullptr)
{
- if (dbFile.empty())
- m_dbFile = DEFAULT_DATABASE_PATH "/" "ndns.db";
+ if (m_dbFile.empty())
+ m_dbFile = getDefaultDatabaseFile();
open();
diff --git a/src/daemon/db-mgr.hpp b/src/daemon/db-mgr.hpp
index c21b3e0..a41380a 100644
--- a/src/daemon/db-mgr.hpp
+++ b/src/daemon/db-mgr.hpp
@@ -65,7 +65,7 @@
public:
explicit
- DbMgr(const std::string& dbFile = DEFAULT_DATABASE_PATH "/" "ndns.db");
+ DbMgr(const std::string& dbFile = "");
~DbMgr();
diff --git a/src/util/util.cpp b/src/util/util.cpp
index 47fbc52..7d350a5 100644
--- a/src/util/util.cpp
+++ b/src/util/util.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2017, Regents of the University of California.
+ * Copyright (c) 2014-2019, Regents of the University of California.
*
* This file is part of NDNS (Named Data Networking Domain Name Service).
* See AUTHORS.md for complete list of NDNS authors and contributors.
@@ -18,15 +18,20 @@
*/
#include "util.hpp"
+#include "config.hpp"
-#include <ndn-cxx/security/transform.hpp>
+#include <ndn-cxx/security/transform/base64-encode.hpp>
+#include <ndn-cxx/security/transform/buffer-source.hpp>
+#include <ndn-cxx/security/transform/stream-sink.hpp>
namespace ndn {
namespace ndns {
-using security::transform::base64Encode;
-using security::transform::streamSink;
-using security::transform::bufferSource;
+std::string
+getDefaultDatabaseFile()
+{
+ return NDNS_DEFAULT_DBFILE;
+}
NdnsContentType
toNdnsContentType(const std::string& str)
@@ -48,8 +53,12 @@
}
void
-output(const Data& data, std::ostream& os, const bool isPretty)
+output(const Data& data, std::ostream& os, bool isPretty)
{
+ using security::transform::base64Encode;
+ using security::transform::bufferSource;
+ using security::transform::streamSink;
+
const Block& block = data.wireEncode();
if (!isPretty) {
bufferSource(block.wire(), block.size()) >> base64Encode() >> streamSink(os);
diff --git a/src/util/util.hpp b/src/util/util.hpp
index 24aa179..56515e8 100644
--- a/src/util/util.hpp
+++ b/src/util/util.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2016, Regents of the University of California.
+/*
+ * Copyright (c) 2014-2019, Regents of the University of California.
*
* This file is part of NDNS (Named Data Networking Domain Name Service).
* See AUTHORS.md for complete list of NDNS authors and contributors.
@@ -21,11 +21,15 @@
#define NDNS_UTIL_UTIL_HPP
#include "ndns-enum.hpp"
+
#include <ndn-cxx/data.hpp>
namespace ndn {
namespace ndns {
+std::string
+getDefaultDatabaseFile();
+
NdnsContentType
toNdnsContentType(const std::string& str);
@@ -36,7 +40,7 @@
* @param isPretty whether to use pretty way
*/
void
-output(const Data& data, std::ostream& os, const bool isPretty);
+output(const Data& data, std::ostream& os, bool isPretty);
} // namespace ndns
} // namespace ndn
diff --git a/src/validator/validator.cpp b/src/validator/validator.cpp
index 6c6e53a..1e14f92 100644
--- a/src/validator/validator.cpp
+++ b/src/validator/validator.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California.
+ * Copyright (c) 2014-2019, Regents of the University of California.
*
* This file is part of NDNS (Named Data Networking Domain Name Service).
* See AUTHORS.md for complete list of NDNS authors and contributors.
@@ -29,7 +29,7 @@
NDNS_LOG_INIT(Validator);
-std::string NdnsValidatorBuilder::VALIDATOR_CONF_FILE = DEFAULT_CONFIG_PATH "/" "validator.conf";
+std::string NdnsValidatorBuilder::VALIDATOR_CONF_FILE(NDNS_CONFDIR "/validator.conf");
unique_ptr<security::v2::Validator>
NdnsValidatorBuilder::create(Face& face,
@@ -41,7 +41,7 @@
make_unique<CertificateFetcherNdnsCert>(face,
nsCacheSize,
startComponentIndex));
- security::v2::ValidationPolicyConfig& policy = dynamic_cast<security::v2::ValidationPolicyConfig&>(validator->getPolicy());
+ auto& policy = dynamic_cast<security::v2::ValidationPolicyConfig&>(validator->getPolicy());
policy.load(confFile);
NDNS_LOG_TRACE("Validator loads configuration: " << confFile);
diff --git a/tests/wscript b/tests/wscript
index 3b48571..6f3ddb3 100644
--- a/tests/wscript
+++ b/tests/wscript
@@ -16,10 +16,7 @@
name='test-validator-conf',
source='../validator.conf.sample.in',
target=tmp_folder.make_node('validator.conf'),
- use='validator-sample',
- ANCHORPATH='\"anchors/root.cert\"',
- RELATION='is-prefix-of',
- )
+ ANCHORPATH='\"anchors/root.cert\"')
bld.objects(
target='unit-tests-main',
diff --git a/tools/ndns-add-rr.cpp b/tools/ndns-add-rr.cpp
index 0e664b6..605a355 100644
--- a/tools/ndns-add-rr.cpp
+++ b/tools/ndns-add-rr.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California.
+ * Copyright (c) 2014-2019, Regents of the University of California.
*
* This file is part of NDNS (Named Data Networking Domain Name Service).
* See AUTHORS.md for complete list of NDNS authors and contributors.
@@ -17,11 +17,11 @@
* NDNS, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "mgmt/management-tool.hpp"
-#include "ndns-label.hpp"
#include "logger.hpp"
-#include "util/util.hpp"
+#include "ndns-label.hpp"
#include "daemon/rrset-factory.hpp"
+#include "mgmt/management-tool.hpp"
+#include "util/util.hpp"
#include <boost/program_options.hpp>
#include <boost/filesystem.hpp>
@@ -37,13 +37,12 @@
{
using std::string;
using namespace ndn;
- using namespace ndns;
int ttlInt = -1;
int versionInt = -1;
string zoneStr;
Name dsk;
- string db;
+ string db = ndns::getDefaultDatabaseFile();
string rrLabelStr;
string rrTypeStr;
std::vector<std::string> content;
@@ -57,9 +56,8 @@
po::options_description options("Generic Options");
options.add_options()
- ("help,h", "print help message")
- ("db,b", po::value<std::string>(&db), "Set the path of NDNS server database. "
- "Default: " DEFAULT_DATABASE_PATH "/ndns.db")
+ ("help,h", "print this help message and exit")
+ ("db,b", po::value<std::string>(&db)->default_value(db), "path to NDNS database file")
;
po::options_description config("Record Options");
@@ -174,11 +172,11 @@
tool.addRrsetFromFile(zoneName, file, ttl, dsk, ioEncoding, needResign);
}
else {
- RrsetFactory rrsetFactory(db, zoneName, keyChain, dsk);
+ ndns::RrsetFactory rrsetFactory(db, zoneName, keyChain, dsk);
rrsetFactory.checkZoneKey();
- Rrset rrset;
+ ndns::Rrset rrset;
- if (type == label::NS_RR_TYPE) {
+ if (type == ndns::label::NS_RR_TYPE) {
ndn::DelegationList delegations;
for (const auto& i : content) {
std::vector<string> data;
@@ -190,7 +188,7 @@
rrset = rrsetFactory.generateNsRrset(label,
version, ttl, delegations);
}
- else if (type == label::TXT_RR_TYPE) {
+ else if (type == ndns::label::TXT_RR_TYPE) {
rrset = rrsetFactory.generateTxtRrset(label,
version, ttl, content);
}
diff --git a/tools/ndns-create-zone.cpp b/tools/ndns-create-zone.cpp
index d477d4b..eaea7ee 100644
--- a/tools/ndns-create-zone.cpp
+++ b/tools/ndns-create-zone.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California.
+ * Copyright (c) 2014-2019, Regents of the University of California.
*
* This file is part of NDNS (Named Data Networking Domain Name Service).
* See AUTHORS.md for complete list of NDNS authors and contributors.
@@ -17,10 +17,10 @@
* NDNS, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "mgmt/management-tool.hpp"
-#include "ndns-label.hpp"
#include "logger.hpp"
-#include "config.hpp"
+#include "ndns-label.hpp"
+#include "mgmt/management-tool.hpp"
+#include "util/util.hpp"
#include <boost/program_options.hpp>
#include <boost/filesystem.hpp>
@@ -40,16 +40,15 @@
string dskStr;
string kskStr;
string dkeyStr;
- string db;
+ string db = ndns::getDefaultDatabaseFile();
try {
namespace po = boost::program_options;
po::variables_map vm;
po::options_description options("Generic Options");
options.add_options()
- ("help,h", "print help message")
- ("db,b", po::value<std::string>(&db), "Set the path of NDNS server database. "
- "Default: " DEFAULT_DATABASE_PATH "/ndns.db")
+ ("help,h", "print this help message and exit")
+ ("db,b", po::value<std::string>(&db)->default_value(db), "path to NDNS database file")
;
po::options_description config("Zone Options");
diff --git a/tools/ndns-daemon.cpp b/tools/ndns-daemon.cpp
index 34315b8..0414e1f 100644
--- a/tools/ndns-daemon.cpp
+++ b/tools/ndns-daemon.cpp
@@ -17,11 +17,11 @@
* NDNS, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "config.hpp"
#include "logger.hpp"
#include "daemon/config-file.hpp"
#include "daemon/name-server.hpp"
#include "util/cert-helper.hpp"
+#include "util/util.hpp"
#include <ndn-cxx/face.hpp>
#include <ndn-cxx/security/key-chain.hpp>
@@ -62,7 +62,7 @@
BOOST_THROW_EXCEPTION(Error("zones section is empty"));
}
- std::string dbFile = DEFAULT_DATABASE_PATH "/" "ndns.db";
+ std::string dbFile = getDefaultDatabaseFile();
auto item = section.find("dbFile");
if (item != section.not_found()) {
dbFile = item->second.get_value<std::string>();
@@ -70,7 +70,7 @@
NDNS_LOG_INFO("DbFile = " << dbFile);
m_dbMgr = make_unique<DbMgr>(dbFile);
- std::string validatorConfigFile = DEFAULT_CONFIG_PATH "/" "validator.conf";
+ std::string validatorConfigFile(NDNS_CONFDIR "/validator.conf");
item = section.find("validatorConfigFile");
if (item != section.not_found()) {
validatorConfigFile = item->second.get_value<std::string>();
@@ -136,7 +136,7 @@
int
main(int argc, char* argv[])
{
- std::string configFile(DEFAULT_CONFIG_PATH "/ndns.conf");
+ std::string configFile(NDNS_CONFDIR "/ndns.conf");
namespace po = boost::program_options;
po::options_description optsDesc("Options");
diff --git a/tools/ndns-delete-zone.cpp b/tools/ndns-delete-zone.cpp
index f08d020..2cefccc 100644
--- a/tools/ndns-delete-zone.cpp
+++ b/tools/ndns-delete-zone.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California.
+ * Copyright (c) 2014-2019, Regents of the University of California.
*
* This file is part of NDNS (Named Data Networking Domain Name Service).
* See AUTHORS.md for complete list of NDNS authors and contributors.
@@ -17,9 +17,11 @@
* NDNS, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "mgmt/management-tool.hpp"
-#include "ndns-label.hpp"
#include "logger.hpp"
+#include "ndns-label.hpp"
+#include "mgmt/management-tool.hpp"
+#include "util/util.hpp"
+
#include <boost/program_options.hpp>
#include <boost/filesystem.hpp>
#include <string>
@@ -30,16 +32,15 @@
using std::string;
using namespace ndn;
string zoneStr;
- string db;
+ string db = ndns::getDefaultDatabaseFile();
try {
namespace po = boost::program_options;
po::variables_map vm;
po::options_description options("Generic Options");
options.add_options()
- ("help,h", "print help message")
- ("db,b", po::value<std::string>(&db), "Set the path of NDNS server database."
- "Default: " DEFAULT_DATABASE_PATH "/ndns.db")
+ ("help,h", "print this help message and exit")
+ ("db,b", po::value<std::string>(&db)->default_value(db), "path to NDNS database file")
;
po::options_description hidden("Hidden Options");
diff --git a/tools/ndns-export-certificate.cpp b/tools/ndns-export-certificate.cpp
index 6e49328..f3d7b8e 100644
--- a/tools/ndns-export-certificate.cpp
+++ b/tools/ndns-export-certificate.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California.
+ * Copyright (c) 2014-2019, Regents of the University of California.
*
* This file is part of NDNS (Named Data Networking Domain Name Service).
* See AUTHORS.md for complete list of NDNS authors and contributors.
@@ -17,9 +17,11 @@
* NDNS, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "mgmt/management-tool.hpp"
-#include "ndns-label.hpp"
#include "logger.hpp"
+#include "ndns-label.hpp"
+#include "mgmt/management-tool.hpp"
+#include "util/util.hpp"
+
#include <boost/program_options.hpp>
#include <boost/filesystem.hpp>
#include <string>
@@ -29,10 +31,9 @@
{
using std::string;
using namespace ndn;
- using namespace ndns;
string certStr;
- string db;
+ string db = ndns::getDefaultDatabaseFile();
string output = "-";
try {
namespace po = boost::program_options;
@@ -40,9 +41,9 @@
po::options_description options("Generic Options");
options.add_options()
- ("help,h", "print help message")
- ("db,b", po::value<std::string>(&db), "Set the path of NDNS server database. "
- "Default: " DEFAULT_DATABASE_PATH "/ndns.db");
+ ("help,h", "print this help message and exit")
+ ("db,b", po::value<std::string>(&db)->default_value(db), "path to NDNS database file")
+ ;
po::options_description config("Output Options");
config.add_options()
diff --git a/tools/ndns-get-rr.cpp b/tools/ndns-get-rr.cpp
index 1cdbdbd..dc40c37 100644
--- a/tools/ndns-get-rr.cpp
+++ b/tools/ndns-get-rr.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California.
+ * Copyright (c) 2014-2019, Regents of the University of California.
*
* This file is part of NDNS (Named Data Networking Domain Name Service).
* See AUTHORS.md for complete list of NDNS authors and contributors.
@@ -17,9 +17,11 @@
* NDNS, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "mgmt/management-tool.hpp"
-#include "ndns-label.hpp"
#include "logger.hpp"
+#include "ndns-label.hpp"
+#include "mgmt/management-tool.hpp"
+#include "util/util.hpp"
+
#include <boost/program_options.hpp>
#include <boost/filesystem.hpp>
#include <string>
@@ -29,10 +31,9 @@
{
using std::string;
using namespace ndn;
- using namespace ndns;
string zoneStr;
- string db;
+ string db = ndns::getDefaultDatabaseFile();
string rrLabelStr;
string rrTypeStr;
try {
@@ -41,9 +42,8 @@
po::options_description options("Generic Options");
options.add_options()
- ("help,h", "print help message")
- ("db,b", po::value<std::string>(&db), "Set the path of NDNS server database. "
- "Default: " DEFAULT_DATABASE_PATH "/ndns.db")
+ ("help,h", "print this help message and exit")
+ ("db,b", po::value<std::string>(&db)->default_value(db), "path to NDNS database file")
;
po::options_description hidden("Hidden Options");
diff --git a/tools/ndns-list-all-zones.cpp b/tools/ndns-list-all-zones.cpp
index 126cbed..676815d 100644
--- a/tools/ndns-list-all-zones.cpp
+++ b/tools/ndns-list-all-zones.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California.
+ * Copyright (c) 2014-2019, Regents of the University of California.
*
* This file is part of NDNS (Named Data Networking Domain Name Service).
* See AUTHORS.md for complete list of NDNS authors and contributors.
@@ -17,9 +17,11 @@
* NDNS, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "mgmt/management-tool.hpp"
-#include "ndns-label.hpp"
#include "logger.hpp"
+#include "ndns-label.hpp"
+#include "mgmt/management-tool.hpp"
+#include "util/util.hpp"
+
#include <boost/program_options.hpp>
#include <boost/filesystem.hpp>
#include <string>
@@ -30,19 +32,17 @@
{
using std::string;
using namespace ndn;
- using namespace ndns;
string zoneStr;
- string db;
+ string db = ndns::getDefaultDatabaseFile();
try {
namespace po = boost::program_options;
po::variables_map vm;
po::options_description options("Generic Options");
options.add_options()
- ("help,h", "print help message")
- ("db,b", po::value<std::string>(&db), "Set the path of NDNS server database. "
- "Default: " DEFAULT_DATABASE_PATH "/ndns.db")
+ ("help,h", "print this help message and exit")
+ ("db,b", po::value<std::string>(&db)->default_value(db), "path to NDNS database file")
;
po::positional_options_description postion;
diff --git a/tools/ndns-list-zone.cpp b/tools/ndns-list-zone.cpp
index d6738f5..840997e 100644
--- a/tools/ndns-list-zone.cpp
+++ b/tools/ndns-list-zone.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California.
+ * Copyright (c) 2014-2019, Regents of the University of California.
*
* This file is part of NDNS (Named Data Networking Domain Name Service).
* See AUTHORS.md for complete list of NDNS authors and contributors.
@@ -17,9 +17,11 @@
* NDNS, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "mgmt/management-tool.hpp"
-#include "ndns-label.hpp"
#include "logger.hpp"
+#include "ndns-label.hpp"
+#include "mgmt/management-tool.hpp"
+#include "util/util.hpp"
+
#include <boost/program_options.hpp>
#include <boost/filesystem.hpp>
#include <string>
@@ -30,10 +32,9 @@
{
using std::string;
using namespace ndn;
- using namespace ndns;
string zoneStr;
- string db;
+ string db = ndns::getDefaultDatabaseFile();
bool printRaw = false;
try {
namespace po = boost::program_options;
@@ -41,9 +42,9 @@
po::options_description options("Generic Options");
options.add_options()
- ("help,h", "print help message")
- ("db,b", po::value<std::string>(&db), "Set the path of NDNS server database. "
- "Default: " DEFAULT_DATABASE_PATH "/ndns.db");
+ ("help,h", "print this help message and exit")
+ ("db,b", po::value<std::string>(&db)->default_value(db), "path to NDNS database file")
+ ;
po::options_description config("Output Options");
config.add_options()
diff --git a/tools/ndns-remove-rr.cpp b/tools/ndns-remove-rr.cpp
index cdaf846..dfb072c 100644
--- a/tools/ndns-remove-rr.cpp
+++ b/tools/ndns-remove-rr.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California.
+ * Copyright (c) 2014-2019, Regents of the University of California.
*
* This file is part of NDNS (Named Data Networking Domain Name Service).
* See AUTHORS.md for complete list of NDNS authors and contributors.
@@ -17,9 +17,11 @@
* NDNS, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "mgmt/management-tool.hpp"
-#include "ndns-label.hpp"
#include "logger.hpp"
+#include "ndns-label.hpp"
+#include "mgmt/management-tool.hpp"
+#include "util/util.hpp"
+
#include <boost/program_options.hpp>
#include <boost/filesystem.hpp>
#include <string>
@@ -29,10 +31,9 @@
{
using std::string;
using namespace ndn;
- using namespace ndns;
string zoneStr;
- string db;
+ string db = ndns::getDefaultDatabaseFile();
string rrLabelStr;
string rrTypeStr;
try {
@@ -41,9 +42,9 @@
po::options_description options("Generic Options");
options.add_options()
- ("help,h", "print help message")
- ("db,b", po::value<std::string>(&db), "Set the path of NDNS server database. "
- "Default: " DEFAULT_DATABASE_PATH "/ndns.db");
+ ("help,h", "print this help message and exit")
+ ("db,b", po::value<std::string>(&db)->default_value(db), "path to NDNS database file")
+ ;
po::options_description hidden("Hidden Options");
hidden.add_options()
diff --git a/wscript b/wscript
index 31fa6a7..728ec8a 100644
--- a/wscript
+++ b/wscript
@@ -1,10 +1,10 @@
# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
-VERSION='0.1.0'
-APPNAME="ndns"
-BUGREPORT = "http://redmine.named-data.net/projects/ndns"
-URL = "http://named-data.net/doc/ndns/"
-GIT_TAG_PREFIX = "ndns-"
+VERSION = '0.1.0'
+APPNAME = 'ndns'
+BUGREPORT = 'https://redmine.named-data.net/projects/ndns'
+URL = 'http://named-data.net/doc/ndns/'
+GIT_TAG_PREFIX = 'ndns-'
from waflib import Logs, Utils, Context
import os, subprocess
@@ -22,18 +22,15 @@
'boost', 'default-compiler-flags', 'doxygen', 'sphinx_build',
'sqlite3'])
+ conf.env['WITH_TESTS'] = conf.options.with_tests
+
if 'PKG_CONFIG_PATH' not in os.environ:
os.environ['PKG_CONFIG_PATH'] = Utils.subst_vars('${LIBDIR}/pkgconfig', conf.env)
-
conf.check_cfg(package='libndn-cxx', args=['--cflags', '--libs'],
uselib_store='NDN_CXX', mandatory=True)
conf.check_sqlite3(mandatory=True)
- if conf.options.with_tests:
- conf.env['WITH_TESTS'] = True
- conf.define('NDNS_HAVE_TESTS', 1)
-
USED_BOOST_LIBS = ['system', 'filesystem', 'thread', 'log', 'log_setup']
if conf.env['WITH_TESTS']:
USED_BOOST_LIBS += ['unit_test_framework']
@@ -46,10 +43,10 @@
conf.load('sanitizers')
- conf.define('DEFAULT_CONFIG_PATH', '%s/ndns' % conf.env['SYSCONFDIR'])
- conf.define('DEFAULT_DATABASE_PATH', '%s/ndns' % conf.env['LOCALSTATEDIR'])
-
- conf.write_config_header('src/config.hpp')
+ conf.define_cond('HAVE_TESTS', conf.env['WITH_TESTS'])
+ conf.define('CONFDIR', '%s/ndn/ndns' % conf.env['SYSCONFDIR'])
+ conf.define('DEFAULT_DBFILE', '%s/lib/ndn/ndns/ndns.db' % conf.env['LOCALSTATEDIR'])
+ conf.write_config_header('src/config.hpp', define_prefix='NDNS_')
def build (bld):
version(bld)
@@ -81,11 +78,10 @@
name='conf-samples',
source=['validator.conf.sample.in', 'ndns.conf.sample.in'],
target=['validator.conf.sample', 'ndns.conf.sample'],
- install_path='${SYSCONFDIR}/ndns',
+ install_path='${SYSCONFDIR}/ndn/ndns',
ANCHORPATH='anchors/root.cert',
- RELATION='is-prefix-of',
- DEFAULT_CONFIG_PATH='%s/ndns' % bld.env['SYSCONFDIR'],
- DEFAULT_DATABASE_PATH='%s/ndns' % bld.env['LOCALSTATEDIR'])
+ CONFDIR='%s/ndn/ndns' % bld.env['SYSCONFDIR'],
+ DEFAULT_DBFILE='%s/lib/ndn/ndns/ndns.db' % bld.env['LOCALSTATEDIR'])
if Utils.unversioned_sys_platform() == 'linux':
bld(features='subst',