tools: delete deprecated ndncatchunks3 and ndnputchunks3
Change-Id: I34a30fe31416ff4207ac40707f0efc0228a4b2b8
Refs: #3700
diff --git a/docs/INSTALL.rst b/docs/INSTALL.rst
index 2faba07..d3cef22 100644
--- a/docs/INSTALL.rst
+++ b/docs/INSTALL.rst
@@ -177,10 +177,6 @@
configured properly (or ``<LIBPATH>/pkgconfig`` is a default path),
``pkgconfig --libs --clflags libndn-cxx`` will return all necessary
compile and link flags for the library.
-- ``<BINPATH>/ndncatchunks3``: a simplified equivalent to ndncatchunks2
- in NDNx package
-- ``<BINPATH>/ndnputchunks3``: a simplified equivalent to ndnputchunks2
- in NDNx package
- ``<BINPATH>/ndnsec``: tool to manage NDN keys and certificates
- ``<BINPATH>/ndnsec-*``: convenience scripts for ``ndnsec`` tools
diff --git a/tools/ndncatchunks3.cpp b/tools/ndncatchunks3.cpp
deleted file mode 100644
index b9a41d2..0000000
--- a/tools/ndncatchunks3.cpp
+++ /dev/null
@@ -1,205 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2013-2016 Regents of the University of California.
- *
- * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
- *
- * ndn-cxx library is free software: you can redistribute it and/or modify it under the
- * terms of the GNU Lesser General Public License as published by the Free Software
- * Foundation, either version 3 of the License, or (at your option) any later version.
- *
- * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- *
- * You should have received copies of the GNU General Public License and GNU Lesser
- * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
- * <http://www.gnu.org/licenses/>.
- *
- * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
- *
- * @author Wentao Shang <http://irl.cs.ucla.edu/~wentao/>
- */
-
-#include "face.hpp"
-
-namespace ndn {
-
-class Consumer
-{
-public:
- Consumer(const std::string& dataName,
- size_t pipeSize, size_t nTotalSegments,
- bool mustBeFresh = true)
- : m_dataName(dataName)
- , m_pipeSize(pipeSize)
- , m_nTotalSegments(nTotalSegments)
- , m_nextSegment(0)
- , m_totalSize(0)
- , m_isOutputEnabled(false)
- , m_mustBeFresh(mustBeFresh)
- {
- }
-
- inline void
- enableOutput()
- {
- m_isOutputEnabled = true;
- }
-
- void
- run();
-
-private:
- void
- onData(Data& data);
-
- void
- onTimeout(const Interest& interest);
-
- Face m_face;
- Name m_dataName;
- size_t m_pipeSize;
- size_t m_nTotalSegments;
- size_t m_nextSegment;
- size_t m_totalSize;
- bool m_isOutputEnabled; // set to false by default
-
- bool m_mustBeFresh;
-};
-
-void
-Consumer::run()
-{
- try
- {
- for (size_t i = 0; i < m_pipeSize; i++)
- {
- Interest interest(Name(m_dataName).appendSegment(m_nextSegment++));
- interest.setInterestLifetime(time::milliseconds(4000));
- interest.setMustBeFresh(m_mustBeFresh);
-
- m_face.expressInterest(interest,
- bind(&Consumer::onData, this, _2),
- bind(&Consumer::onTimeout, this, _1));
- }
-
- // processEvents will block until the requested data received or timeout occurs
- m_face.processEvents();
- }
- catch (std::exception& e)
- {
- std::cerr << "ERROR: " << e.what() << std::endl;
- }
-}
-
-void
-Consumer::onData(Data& data)
-{
- const Block& content = data.getContent();
- const Name& name = data.getName();
-
- if (m_isOutputEnabled)
- {
- std::cout.write(reinterpret_cast<const char*>(content.value()), content.value_size());
- }
-
- m_totalSize += content.value_size();
-
- if (name[-1].toSegment() + 1 == m_nTotalSegments)
- {
- std::cerr << "Last segment received." << std::endl;
- std::cerr << "Total # bytes of content received: " << m_totalSize << std::endl;
- }
- else
- {
- // Send interest for next segment
- Interest interest(Name(m_dataName).appendSegment(m_nextSegment++));
- interest.setInterestLifetime(time::milliseconds(4000));
- interest.setMustBeFresh(m_mustBeFresh);
-
- m_face.expressInterest(interest,
- bind(&Consumer::onData, this, _2),
- bind(&Consumer::onTimeout, this, _1));
- }
-}
-
-
-void
-Consumer::onTimeout(const Interest& interest)
-{
- //XXX: currently no retrans
- std::cerr << "TIMEOUT: last interest sent for segment #" << (m_nextSegment - 1) << std::endl;
-}
-
-
-int
-usage(const std::string &filename)
-{
- std::cerr << "Usage: \n "
- << filename << " [-p pipeSize] [-c nTotalSegmentsment] [-o] /ndn/name\n";
- return 1;
-}
-
-
-int
-main(int argc, char** argv)
-{
- std::string name;
- int pipeSize = 1;
- int nTotalSegments = std::numeric_limits<int>::max();
- bool output = false;
-
- int opt;
- while ((opt = getopt(argc, argv, "op:c:")) != -1)
- {
- switch (opt)
- {
- case 'p':
- pipeSize = atoi(optarg);
- if (pipeSize <= 0)
- pipeSize = 1;
- std::cerr << "main(): set pipe size = " << pipeSize << std::endl;
- break;
- case 'c':
- nTotalSegments = atoi(optarg);
- if (nTotalSegments <= 0)
- nTotalSegments = 1;
- std::cerr << "main(): set total seg = " << nTotalSegments << std::endl;
- break;
- case 'o':
- output = true;
- break;
- default:
- return usage(argv[0]);
- }
- }
-
- if (optind < argc)
- {
- name = argv[optind];
- }
-
- if (name.empty())
- {
- return usage(argv[0]);
- }
-
- Consumer consumer(name, pipeSize, nTotalSegments);
-
- if (output)
- consumer.enableOutput();
-
- consumer.run();
-
- return 0;
-}
-
-} // namespace ndn
-
-int
-main(int argc, char** argv)
-{
- std::cerr << "ndncatchunks3 is deprecated. Use ndncatchunks program from ndn-tools repository.\n" << std::endl;
- return ndn::main(argc, argv);
-}
diff --git a/tools/ndnputchunks3.cpp b/tools/ndnputchunks3.cpp
deleted file mode 100644
index a977322..0000000
--- a/tools/ndnputchunks3.cpp
+++ /dev/null
@@ -1,159 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2013-2016 Regents of the University of California.
- *
- * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
- *
- * ndn-cxx library is free software: you can redistribute it and/or modify it under the
- * terms of the GNU Lesser General Public License as published by the Free Software
- * Foundation, either version 3 of the License, or (at your option) any later version.
- *
- * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- *
- * You should have received copies of the GNU General Public License and GNU Lesser
- * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
- * <http://www.gnu.org/licenses/>.
- *
- * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
- *
- * @author Wentao Shang <http://irl.cs.ucla.edu/~wentao/>
- */
-
-#include "face.hpp"
-#include "security/key-chain.hpp"
-
-namespace ndn {
-
-const size_t MAX_SEG_SIZE = 4096;
-
-class Producer
-{
-public:
- Producer(const char* name)
- : m_name(name)
- , m_isVerbose(false)
- {
- int segnum = 0;
- char* buf = new char[MAX_SEG_SIZE];
- do
- {
- std::cin.read(buf, MAX_SEG_SIZE);
- ssize_t got = std::cin.gcount();
-
- if (got > 0)
- {
- shared_ptr<Data> data =
- make_shared<Data>(Name(m_name).appendSegment(segnum));
-
- data->setFreshnessPeriod(time::milliseconds(10000)); // 10 sec
- data->setContent(reinterpret_cast<const uint8_t*>(buf), got);
-
- m_keychain.sign(*data);
- m_store.push_back(data);
- segnum++;
- }
- }
- while (static_cast<bool>(std::cin));
-
- if (m_isVerbose)
- std::cerr << "Created " << segnum << " chunks for prefix [" << m_name << "]" << std::endl;
- }
-
- void
- onInterest(const Interest& interest)
- {
- if (m_isVerbose)
- std::cerr << "<< I: " << interest << std::endl;
-
- size_t segnum = static_cast<size_t>(interest.getName().rbegin()->toSegment());
-
- if (segnum < m_store.size())
- {
- m_face.put(*m_store[segnum]);
- }
- }
-
- void
- onRegisterFailed(const Name& prefix, const std::string& reason)
- {
- std::cerr << "ERROR: Failed to register prefix '"
- << prefix << "' in local hub's daemon (" << reason << ")"
- << std::endl;
- m_face.shutdown();
- }
-
- void
- run()
- {
- if (m_store.empty())
- {
- std::cerr << "Nothing to serve. Exiting." << std::endl;
- return;
- }
-
- m_face.setInterestFilter(m_name,
- bind(&Producer::onInterest, this, _2),
- RegisterPrefixSuccessCallback(),
- bind(&Producer::onRegisterFailed, this, _1, _2));
- m_face.processEvents();
- }
-
-private:
- Name m_name;
- Face m_face;
- KeyChain m_keychain;
-
- std::vector< shared_ptr<Data> > m_store;
-
- bool m_isVerbose;
-};
-
-int
-main(int argc, char** argv)
-{
- if (argc < 2)
- {
- std::cerr << "Usage: ./ndnputchunks [data_prefix]\n";
- return -1;
- }
-
- try
- {
- time::steady_clock::TimePoint startTime = time::steady_clock::now();
-
- std::cerr << "Preparing the input..." << std::endl;
- Producer producer(argv[1]);
- std::cerr << "Ready... (took " << (time::steady_clock::now() - startTime) << std::endl;
-
- while (true)
- {
- try
- {
- // this will exit when daemon dies... so try to connect again if possible
- producer.run();
- }
- catch (std::exception& e)
- {
- std::cerr << "ERROR: " << e.what() << std::endl;
- // and keep going
- sleep(1);
- }
- }
- }
- catch (std::exception& e)
- {
- std::cerr << "ERROR: " << e.what() << std::endl;
- }
- return 0;
-}
-
-} // namespace ndn
-
-int
-main(int argc, char** argv)
-{
- std::cerr << "ndnputchunks3 is deprecated. Use ndnputchunks program from ndn-tools repository.\n" << std::endl;
- return ndn::main(argc, argv);
-}