| /** |
| * Generates a predefined link object and outputs it to a file |
| * |
| * Author: Eric Newberry <enewberry@email.arizona.edu> |
| */ |
| |
| #include <ndn-cxx/link.hpp> |
| #include <ndn-cxx/security/key-chain.hpp> |
| #include <ndn-cxx/util/io.hpp> |
| |
| #include <iostream> |
| |
| int |
| main(int argc, char* argv[]) |
| { |
| if (argc < 5 || argc % 2 != 1) { |
| std::cout << "Usage: " << argv[0] << " [outfile] [name] [pref-1] [delegation-1] ... [pref-n] [delegation-n]" << std::endl; |
| return -1; |
| } |
| |
| // Create initial link object |
| ndn::Link link(argv[2]); |
| |
| // Load delegations into object |
| for (int i = 0; i < (argc - 3) / 2; i++) { |
| link.addDelegation(std::stoi(argv[2 * i + 3]), argv[2 * i + 4]); |
| } |
| |
| // Sign and save object |
| ndn::KeyChain keyChain; |
| keyChain.sign(link); |
| link.wireEncode(); |
| ndn::io::save(link, argv[1]); |
| return 0; |
| } |