blob: eb336de068583216040448a76fe7995884de8df0 [file] [log] [blame]
Yingdi Yu40cd1c32014-04-17 15:02:17 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
dmcoomescf8d0ed2017-02-21 11:39:01 -06003 * Copyright (c) 2014-2018, The University of Memphis,
Vince Lehman9dce0c92015-02-09 12:53:41 -06004 * Regents of the University of California,
5 * Arizona Board of Regents.
Yingdi Yu40cd1c32014-04-17 15:02:17 -07006 *
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 Afanasyevb669f9c2014-11-14 12:41:54 -080021
Vince Lehmanc57c64b2015-08-10 12:21:31 -050022#include "nlsr-runner.hpp"
Vince Lehmanb722b102014-08-24 16:33:49 -050023#include "version.hpp"
Yingdi Yu40cd1c32014-04-17 15:02:17 -070024
Alexander Afanasyev7decbbf2014-08-24 21:29:01 -070025int
akmhoquefdbddb12014-05-02 18:35:19 -050026main(int32_t argc, char** argv)
Yingdi Yu40cd1c32014-04-17 15:02:17 -070027{
Vince Lehmanc57c64b2015-08-10 12:21:31 -050028 using namespace nlsr;
Vince Lehman7c603292014-09-11 17:48:16 -050029
akmhoquefdbddb12014-05-02 18:35:19 -050030 std::string programName(argv[0]);
Vince Lehmanc57c64b2015-08-10 12:21:31 -050031
32 std::string configFileName = "nlsr.conf";
Vince Lehmanc57c64b2015-08-10 12:21:31 -050033
akmhoquefdbddb12014-05-02 18:35:19 -050034 int32_t opt;
Vince Lehmanb722b102014-08-24 16:33:49 -050035 while ((opt = getopt(argc, argv, "df:hV")) != -1) {
Vince Lehmanc57c64b2015-08-10 12:21:31 -050036 switch (opt) {
Yingdi Yu40cd1c32014-04-17 15:02:17 -070037 case 'f':
Vince Lehmanc57c64b2015-08-10 12:21:31 -050038 configFileName = optarg;
Yingdi Yu40cd1c32014-04-17 15:02:17 -070039 break;
Vince Lehmanb722b102014-08-24 16:33:49 -050040 case 'V':
41 std::cout << NLSR_VERSION_BUILD_STRING << std::endl;
42 return EXIT_SUCCESS;
43 break;
Yingdi Yu40cd1c32014-04-17 15:02:17 -070044 case 'h':
45 default:
Vince Lehmanc57c64b2015-08-10 12:21:31 -050046 NlsrRunner::printUsage(programName);
Yingdi Yu40cd1c32014-04-17 15:02:17 -070047 return EXIT_FAILURE;
Vince Lehmanc57c64b2015-08-10 12:21:31 -050048 }
Yingdi Yu40cd1c32014-04-17 15:02:17 -070049 }
Muktadir R Chowdhurybfa27602014-10-31 10:57:41 -050050
dmcoomescf8d0ed2017-02-21 11:39:01 -060051 NlsrRunner runner(configFileName);
Vince Lehmanc57c64b2015-08-10 12:21:31 -050052
53 try {
54 runner.run();
55 }
56 catch (const std::exception& e) {
57 std::cerr << e.what() << std::endl;
Yingdi Yu40cd1c32014-04-17 15:02:17 -070058 return EXIT_FAILURE;
59 }
Vince Lehmanf99b87f2014-08-26 15:54:27 -050060
Yingdi Yu40cd1c32014-04-17 15:02:17 -070061 return EXIT_SUCCESS;
62}