Yingdi Yu | 40cd1c3 | 2014-04-17 15:02:17 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
dmcoomes | cf8d0ed | 2017-02-21 11:39:01 -0600 | [diff] [blame^] | 3 | * Copyright (c) 2014-2018, The University of Memphis, |
Vince Lehman | 9dce0c9 | 2015-02-09 12:53:41 -0600 | [diff] [blame] | 4 | * Regents of the University of California, |
| 5 | * Arizona Board of Regents. |
Yingdi Yu | 40cd1c3 | 2014-04-17 15:02:17 -0700 | [diff] [blame] | 6 | * |
| 7 | * This file is part of NLSR (Named-data Link State Routing). |
| 8 | * See AUTHORS.md for complete list of NLSR authors and contributors. |
| 9 | * |
| 10 | * NLSR is free software: you can redistribute it and/or modify it under the terms |
| 11 | * of the GNU General Public License as published by the Free Software Foundation, |
| 12 | * either version 3 of the License, or (at your option) any later version. |
| 13 | * |
| 14 | * NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
| 15 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 16 | * PURPOSE. See the GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License along with |
| 19 | * NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
| 20 | **/ |
Alexander Afanasyev | b669f9c | 2014-11-14 12:41:54 -0800 | [diff] [blame] | 21 | |
Vince Lehman | c57c64b | 2015-08-10 12:21:31 -0500 | [diff] [blame] | 22 | #include "nlsr-runner.hpp" |
Vince Lehman | b722b10 | 2014-08-24 16:33:49 -0500 | [diff] [blame] | 23 | #include "version.hpp" |
Yingdi Yu | 40cd1c3 | 2014-04-17 15:02:17 -0700 | [diff] [blame] | 24 | |
Alexander Afanasyev | 7decbbf | 2014-08-24 21:29:01 -0700 | [diff] [blame] | 25 | int |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 26 | main(int32_t argc, char** argv) |
Yingdi Yu | 40cd1c3 | 2014-04-17 15:02:17 -0700 | [diff] [blame] | 27 | { |
Vince Lehman | c57c64b | 2015-08-10 12:21:31 -0500 | [diff] [blame] | 28 | using namespace nlsr; |
Vince Lehman | 7c60329 | 2014-09-11 17:48:16 -0500 | [diff] [blame] | 29 | |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 30 | std::string programName(argv[0]); |
Vince Lehman | c57c64b | 2015-08-10 12:21:31 -0500 | [diff] [blame] | 31 | |
| 32 | std::string configFileName = "nlsr.conf"; |
Vince Lehman | c57c64b | 2015-08-10 12:21:31 -0500 | [diff] [blame] | 33 | |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 34 | int32_t opt; |
Vince Lehman | b722b10 | 2014-08-24 16:33:49 -0500 | [diff] [blame] | 35 | while ((opt = getopt(argc, argv, "df:hV")) != -1) { |
Vince Lehman | c57c64b | 2015-08-10 12:21:31 -0500 | [diff] [blame] | 36 | switch (opt) { |
Yingdi Yu | 40cd1c3 | 2014-04-17 15:02:17 -0700 | [diff] [blame] | 37 | case 'f': |
Vince Lehman | c57c64b | 2015-08-10 12:21:31 -0500 | [diff] [blame] | 38 | configFileName = optarg; |
Yingdi Yu | 40cd1c3 | 2014-04-17 15:02:17 -0700 | [diff] [blame] | 39 | break; |
Vince Lehman | b722b10 | 2014-08-24 16:33:49 -0500 | [diff] [blame] | 40 | case 'V': |
| 41 | std::cout << NLSR_VERSION_BUILD_STRING << std::endl; |
| 42 | return EXIT_SUCCESS; |
| 43 | break; |
Yingdi Yu | 40cd1c3 | 2014-04-17 15:02:17 -0700 | [diff] [blame] | 44 | case 'h': |
| 45 | default: |
Vince Lehman | c57c64b | 2015-08-10 12:21:31 -0500 | [diff] [blame] | 46 | NlsrRunner::printUsage(programName); |
Yingdi Yu | 40cd1c3 | 2014-04-17 15:02:17 -0700 | [diff] [blame] | 47 | return EXIT_FAILURE; |
Vince Lehman | c57c64b | 2015-08-10 12:21:31 -0500 | [diff] [blame] | 48 | } |
Yingdi Yu | 40cd1c3 | 2014-04-17 15:02:17 -0700 | [diff] [blame] | 49 | } |
Muktadir R Chowdhury | bfa2760 | 2014-10-31 10:57:41 -0500 | [diff] [blame] | 50 | |
dmcoomes | cf8d0ed | 2017-02-21 11:39:01 -0600 | [diff] [blame^] | 51 | NlsrRunner runner(configFileName); |
Vince Lehman | c57c64b | 2015-08-10 12:21:31 -0500 | [diff] [blame] | 52 | |
| 53 | try { |
| 54 | runner.run(); |
| 55 | } |
| 56 | catch (const std::exception& e) { |
| 57 | std::cerr << e.what() << std::endl; |
Yingdi Yu | 40cd1c3 | 2014-04-17 15:02:17 -0700 | [diff] [blame] | 58 | return EXIT_FAILURE; |
| 59 | } |
Vince Lehman | f99b87f | 2014-08-26 15:54:27 -0500 | [diff] [blame] | 60 | |
Yingdi Yu | 40cd1c3 | 2014-04-17 15:02:17 -0700 | [diff] [blame] | 61 | return EXIT_SUCCESS; |
| 62 | } |