blob: 6e80512192c544d47e213743c73e84c6804a675d [file] [log] [blame]
Jiewen Tan870b29b2014-11-17 19:09:49 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (c) 2014, Regents of the University of California.
4 *
5 * This file is part of NDNS (Named Data Networking Domain Name Service).
6 * See AUTHORS.md for complete list of NDNS authors and contributors.
7 *
8 * NDNS is free software: you can redistribute it and/or modify it under the terms
9 * of the GNU General Public License as published by the Free Software Foundation,
10 * either version 3 of the License, or (at your option) any later version.
11 *
12 * NDNS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
13 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along with
17 * NDNS, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#include "mgmt/management-tool.hpp"
21#include "ndns-label.hpp"
22#include "logger.hpp"
23#include <boost/program_options.hpp>
24#include <boost/filesystem.hpp>
25#include <string>
26#include <iostream>
27
28int
29main(int argc, char* argv[])
30{
31 using std::string;
32 using namespace ndn;
33 using namespace ndns;
34
35 ndn::ndns::log::init();
36 string zoneStr;
37 string db;
38 try {
39 namespace po = boost::program_options;
40 po::variables_map vm;
41
42 po::options_description options("Generic Options");
43 options.add_options()
44 ("help,h", "print help message")
45 ("db,b", po::value<std::string>(&db), "Set the path of NDNS server database. "
46 "Default: " DEFAULT_DATABASE_PATH "/ndns.db")
47 ;
48
49 po::positional_options_description postion;
50 postion.add("zone", 1);
51
52 po::options_description cmdline_options;
53 cmdline_options.add(options);
54
55 po::parsed_options parsed =
56 po::command_line_parser(argc, argv).options(cmdline_options).positional(postion).run();
57
58 po::store(parsed, vm);
59 po::notify(vm);
60
61 if (vm.count("help")) {
62 std::cout << "Usage: ndns-list-all-zones [-b db]" << std::endl;
63 std::cout << options << std::endl;
64 return 0;
65 }
66 }
67 catch (const std::exception& ex) {
68 std::cerr << "Parameter Error: " << ex.what() << std::endl;
69 return 1;
70 }
71
72 try {
Alexander Afanasyevd6b3bda2014-11-25 17:33:58 -080073 ndn::KeyChain keyChain;
74 ndn::ndns::ManagementTool tool(db, keyChain);
Jiewen Tan870b29b2014-11-17 19:09:49 -080075 tool.listAllZones(std::cout);
76 }
77 catch (const std::exception& ex) {
78 std::cerr << "Error: " << ex.what() << std::endl;
79 return 1;
80 }
81}