Reduce namespace nesting (ndn::ndncert -> ndncert)
Change-Id: I5b69a2c3673cccdf07ea0ba3a0e7181894328f47
diff --git a/tools/ndncert-ca-server.cpp b/tools/ndncert-ca-server.cpp
index 697960f..5f0e3a3 100644
--- a/tools/ndncert-ca-server.cpp
+++ b/tools/ndncert-ca-server.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2017-2020, Regents of the University of California.
+ * Copyright (c) 2017-2021, Regents of the University of California.
*
* This file is part of ndncert, a certificate management system based on NDN.
*
@@ -19,6 +19,7 @@
*/
#include "ca-module.hpp"
+
#include <boost/asio.hpp>
#include <boost/asio/ip/tcp.hpp>
#include <boost/program_options/options_description.hpp>
@@ -27,17 +28,17 @@
#include <iostream>
#include <chrono>
#include <deque>
+
#include <ndn-cxx/face.hpp>
#include <ndn-cxx/security/key-chain.hpp>
-namespace ndn {
namespace ndncert {
namespace ca {
-Face face;
-security::KeyChain keyChain;
-std::string repoHost = "localhost";
-std::string repoPort = "7376";
+static ndn::Face face;
+static ndn::KeyChain keyChain;
+static std::string repoHost = "localhost";
+static std::string repoPort = "7376";
const size_t MAX_CACHED_CERT_NUM = 100;
static bool
@@ -141,8 +142,8 @@
}
});
face.setInterestFilter(
- InterestFilter(ca.getCaConf().caProfile.caPrefix),
- [&](const InterestFilter&, const Interest& interest) {
+ ndn::InterestFilter(ca.getCaConf().caProfile.caPrefix),
+ [&](const auto&, const auto& interest) {
const auto& interestName = interest.getName();
if (interestName.isPrefixOf(profileData.getName())) {
face.put(profileData);
@@ -166,10 +167,9 @@
} // namespace ca
} // namespace ndncert
-} // namespace ndn
int
main(int argc, char* argv[])
{
- return ndn::ndncert::ca::main(argc, argv);
+ return ndncert::ca::main(argc, argv);
}
diff --git a/tools/ndncert-ca-status.cpp b/tools/ndncert-ca-status.cpp
index 0db2353..2d0c0f9 100644
--- a/tools/ndncert-ca-status.cpp
+++ b/tools/ndncert-ca-status.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2017-2020, Regents of the University of California.
+/*
+ * Copyright (c) 2017-2021, Regents of the University of California.
*
* This file is part of ndncert, a certificate management system based on NDN.
*
@@ -20,16 +20,17 @@
#include "ca-module.hpp"
#include "detail/ca-sqlite.hpp"
-#include <iostream>
+
#include <boost/program_options/options_description.hpp>
#include <boost/program_options/variables_map.hpp>
#include <boost/program_options/parsers.hpp>
-namespace ndn {
+#include <iostream>
+
namespace ndncert {
namespace ca {
-int
+static int
main(int argc, char* argv[])
{
namespace po = boost::program_options;
@@ -75,10 +76,9 @@
} // namespace ca
} // namespace ndncert
-} // namespace ndn
int
main(int argc, char* argv[])
{
- return ndn::ndncert::ca::main(argc, argv);
+ return ndncert::ca::main(argc, argv);
}
diff --git a/tools/ndncert-client.cpp b/tools/ndncert-client.cpp
index fec4aa1..30c7454 100644
--- a/tools/ndncert-client.cpp
+++ b/tools/ndncert-client.cpp
@@ -20,6 +20,8 @@
#include "requester-request.hpp"
+#include <ndn-cxx/face.hpp>
+#include <ndn-cxx/security/key-chain.hpp>
#include <ndn-cxx/security/verification-helpers.hpp>
#include <boost/asio.hpp>
@@ -29,7 +31,6 @@
#include <iostream>
-namespace ndn {
namespace ndncert {
namespace requester {
@@ -46,9 +47,9 @@
runChallenge(const std::string& challengeType);
static size_t nStep = 1;
-static Face face;
-static security::KeyChain keyChain;
-static shared_ptr<Request> requesterState;
+static ndn::Face face;
+static ndn::KeyChain keyChain;
+static std::shared_ptr<Request> requesterState;
static void
captureParams(std::multimap<std::string, std::string>& requirement)
@@ -92,7 +93,7 @@
try {
return std::stoul(periodStr);
}
- catch (const std::exception& e) {
+ catch (const std::exception&) {
std::cerr << "Your input is invalid. Try again: " << std::endl;
count++;
}
@@ -183,7 +184,7 @@
try {
challengeIndex = std::stoul(choice);
}
- catch (const std::exception& e) {
+ catch (const std::exception&) {
std::cerr << "Your input is not valid. Try again:" << std::endl;
inputCount++;
continue;
@@ -262,7 +263,8 @@
std::cerr << "\nOr choose another trusted CA suggested by the CA: " << std::endl;
for (const auto& redirect : redirects) {
std::cerr << "> Index: " << count++ << std::endl
- << ">> Suggested CA: " << security::extractIdentityFromCertName(redirect.getPrefix(-1)) << std::endl;
+ << ">> Suggested CA: " << ndn::security::extractIdentityFromCertName(redirect.getPrefix(-1))
+ << std::endl;
}
std::cerr << "Please type in the index of your choice:" << std::endl;
size_t index = 0;
@@ -271,7 +273,7 @@
getline(std::cin, input);
index = std::stoul(input);
}
- catch (const std::exception& e) {
+ catch (const std::exception&) {
std::cerr << "Your input is Invalid. Exit" << std::endl;
exit(1);
}
@@ -293,7 +295,7 @@
std::cerr << "You are applying name: " << selectedName.toUri() << std::endl;
}
}
- catch (const std::exception& e) {
+ catch (const std::exception&) {
std::cerr << "Your input is Invalid. Exit" << std::endl;
exit(1);
}
@@ -302,7 +304,7 @@
else {
//redirects
auto redirectedCaFullName = redirects[index - names.size()];
- auto redirectedCaName = security::extractIdentityFromCertName(redirectedCaFullName.getPrefix(-1));
+ auto redirectedCaName = ndn::security::extractIdentityFromCertName(redirectedCaFullName.getPrefix(-1));
std::cerr << "You selected to be redirected to CA: " << redirectedCaName.toUri() << std::endl;
face.expressInterest(
*Request::genCaProfileDiscoveryInterest(redirectedCaName),
@@ -365,7 +367,7 @@
try {
caIndex = std::stoul(caIndexS);
}
- catch (const std::exception& e) {
+ catch (const std::exception&) {
std::cerr << "Your input is neither NONE nor a valid index. Exit" << std::endl;
return;
}
@@ -532,10 +534,9 @@
} // namespace requester
} // namespace ndncert
-} // namespace ndn
int
main(int argc, char* argv[])
{
- return ndn::ndncert::requester::main(argc, argv);
+ return ndncert::requester::main(argc, argv);
}