blob: 1b3d75e2083cdd43978c99c194604896c1129c54 [file] [log] [blame]
Zhiyi Zhang440e6a22017-04-14 14:31:37 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
tylerliu182bc532020-09-25 01:54:45 -07003 * Copyright (c) 2017-2020, Regents of the University of California.
Zhiyi Zhang440e6a22017-04-14 14:31:37 -07004 *
5 * This file is part of ndncert, a certificate management system based on NDN.
6 *
7 * ndncert is free software: you can redistribute it and/or modify it under the terms
8 * of the GNU General Public License as published by the Free Software Foundation, either
9 * version 3 of the License, or (at your option) any later version.
10 *
11 * ndncert is distributed in the hope that it will be useful, but WITHOUT ANY
12 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13 * PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 *
15 * You should have received copies of the GNU General Public License along with
16 * ndncert, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * See AUTHORS.md for complete list of ndncert authors and contributors.
19 */
20
21#include "ca-module.hpp"
Zhiyi Zhang8bd8e5b2020-09-29 17:40:40 -070022#include "ca-storage-detail/ca-sqlite.hpp"
Zhiyi Zhangb6fab0f2017-09-21 16:26:27 -070023#include <iostream>
Zhiyi Zhang440e6a22017-04-14 14:31:37 -070024#include <boost/program_options/options_description.hpp>
25#include <boost/program_options/variables_map.hpp>
26#include <boost/program_options/parsers.hpp>
27
28namespace ndn {
29namespace ndncert {
30
Zhiyi Zhang440e6a22017-04-14 14:31:37 -070031int
32main(int argc, char* argv[])
33{
34 namespace po = boost::program_options;
35 std::string caNameString = "";
Zhiyi Zhangd1d9f5a2020-10-05 18:04:23 -070036 po::options_description description("General Usage\n ndncert-ca-status [-h] CA_NAME\n");
Zhiyi Zhang440e6a22017-04-14 14:31:37 -070037 description.add_options()
38 ("help,h", "produce help message")
Zhiyi Zhangd1d9f5a2020-10-05 18:04:23 -070039 ("CA_NAME", po::value<std::string>(&caNameString), "ca name");
Zhiyi Zhang440e6a22017-04-14 14:31:37 -070040 po::positional_options_description p;
41 po::variables_map vm;
42 try {
43 po::store(po::command_line_parser(argc, argv).options(description).positional(p).run(), vm);
44 po::notify(vm);
45 }
46 catch (const std::exception& e) {
47 std::cerr << "ERROR: " << e.what() << std::endl;
48 return 1;
49 }
50 if (vm.count("help") != 0) {
51 std::cerr << description << std::endl;
52 return 0;
53 }
Zhiyi Zhangd1d9f5a2020-10-05 18:04:23 -070054 if (vm.count("CA_NAME") == 0) {
55 std::cerr << "ERROR: you must specify a CA identity." << std::endl;
56 return 2;
57 }
Zhiyi Zhang440e6a22017-04-14 14:31:37 -070058
Zhiyi Zhangd1d9f5a2020-10-05 18:04:23 -070059 CaSqlite storage(Name(caNameString), "");
tylerliu8704d032020-06-23 10:18:15 -070060 std::list<CaState> requestList;
Zhiyi Zhangd1d9f5a2020-10-05 18:04:23 -070061 requestList = storage.listAllRequests();
62 std::cerr << "The pending requests are :" << std::endl;
Zhiyi Zhang440e6a22017-04-14 14:31:37 -070063 for (const auto& entry : requestList) {
Zhiyi Zhanga749f442020-09-29 17:19:51 -070064 std::cerr << entry;
Zhiyi Zhang440e6a22017-04-14 14:31:37 -070065 }
Zhiyi Zhang440e6a22017-04-14 14:31:37 -070066 return 0;
67}
68
69} // namespace ndncert
70} // namespace ndn
71
72int
73main(int argc, char* argv[])
74{
75 return ndn::ndncert::main(argc, argv);
76}