Rename translation units containing main() to main.cpp
Also unify style of argv declaration
Change-Id: I1dcb8689b1cd38e042a0b1f05be7f98bd2d487ed
diff --git a/README-dev.md b/README-dev.md
index 3f6fef3..d3b2cec 100644
--- a/README-dev.md
+++ b/README-dev.md
@@ -59,25 +59,29 @@
### Namespace
-Types in each tool SHOULD be declared in a sub-namespace under `namespace ndn`.
+Types in each tool SHOULD be declared in a sub-namespace inside `namespace ndn`.
For example, a tool in `tools/foo` directory has namespace `ndn::foo`.
This allows the tool to reference ndn-cxx types with unqualified name lookup.
This also prevents name conflicts between ndn-cxx and tools.
-Types in `core/` SHOULD be declared directly under `namespace ndn`,
+Types in `core/` SHOULD be declared directly inside `namespace ndn`,
or in a sub-namespace if desired.
-`using namespace` SHOULD NOT be used except within block scope.
+`using namespace` SHOULD NOT be used except in block scope.
### main Function
-The main function of a program SHOULD be declared within its sub-namespace.
-This allows it to reference types in ndn-cxx and the tool with unqualified name lookup.
+The `main` function of a program SHOULD be declared as a static function in
+the namespace of the corresponding tool. This allows referencing types in
+ndn-cxx and the tool via unqualified name lookup.
-Then, another main function in global namespace needs to be defined
-to call the main function in sub-namespace.
+Then, another (non-static) `main` function must be defined in the global
+namespace, and from there call the `main` function in the tool namespace.
-For example:
+These two functions SHOULD appear in a file named `main.cpp` in the tool's
+subdirectory.
+
+Example:
namespace ndn {
namespace foo {
@@ -92,8 +96,8 @@
run();
};
- int
- main(int argc, char** argv)
+ static int
+ main(int argc, char* argv[])
{
Face face;
Bar program(face);
@@ -105,7 +109,7 @@
} // namespace ndn
int
- main(int argc, char** argv)
+ main(int argc, char* argv[])
{
return ndn::foo::main(argc, argv);
}
diff --git a/tools/chunks/catchunks/ndncatchunks.cpp b/tools/chunks/catchunks/main.cpp
similarity index 99%
rename from tools/chunks/catchunks/ndncatchunks.cpp
rename to tools/chunks/catchunks/main.cpp
index 1405b23..737f2aa 100644
--- a/tools/chunks/catchunks/ndncatchunks.cpp
+++ b/tools/chunks/catchunks/main.cpp
@@ -46,7 +46,7 @@
namespace chunks {
static int
-main(int argc, char** argv)
+main(int argc, char* argv[])
{
std::string programName(argv[0]);
Options options;
@@ -305,7 +305,7 @@
} // namespace ndn
int
-main(int argc, char** argv)
+main(int argc, char* argv[])
{
return ndn::chunks::main(argc, argv);
}
diff --git a/tools/chunks/putchunks/ndnputchunks.cpp b/tools/chunks/putchunks/main.cpp
similarity index 97%
rename from tools/chunks/putchunks/ndnputchunks.cpp
rename to tools/chunks/putchunks/main.cpp
index ce3b88e..f5e6a34 100644
--- a/tools/chunks/putchunks/ndnputchunks.cpp
+++ b/tools/chunks/putchunks/main.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2016-2017, Regents of the University of California,
+ * Copyright (c) 2016-2019, Regents of the University of California,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University.
*
@@ -47,7 +47,7 @@
}
static int
-main(int argc, char** argv)
+main(int argc, char* argv[])
{
std::string programName = argv[0];
std::string prefix;
@@ -150,7 +150,7 @@
} // namespace ndn
int
-main(int argc, char** argv)
+main(int argc, char* argv[])
{
return ndn::chunks::main(argc, argv);
}
diff --git a/tools/chunks/wscript b/tools/chunks/wscript
index a6b2ead..417bbf6 100644
--- a/tools/chunks/wscript
+++ b/tools/chunks/wscript
@@ -5,24 +5,24 @@
bld.objects(
target='ndncatchunks-objects',
- source=bld.path.ant_glob('catchunks/*.cpp', excl='catchunks/ndncatchunks.cpp'),
+ source=bld.path.ant_glob('catchunks/*.cpp', excl='catchunks/main.cpp'),
use='core-objects')
bld.program(
target='../../bin/ndncatchunks',
name='ndncatchunks',
- source='catchunks/ndncatchunks.cpp',
+ source='catchunks/main.cpp',
use='ndncatchunks-objects')
bld.objects(
target='ndnputchunks-objects',
- source=bld.path.ant_glob('putchunks/*.cpp', excl='putchunks/ndnputchunks.cpp'),
+ source=bld.path.ant_glob('putchunks/*.cpp', excl='putchunks/main.cpp'),
use='core-objects')
bld.program(
target='../../bin/ndnputchunks',
name='ndnputchunks',
- source='putchunks/ndnputchunks.cpp',
+ source='putchunks/main.cpp',
use='ndnputchunks-objects')
## (for unit tests)
diff --git a/tools/dissect/main.cpp b/tools/dissect/main.cpp
index 30bf6db..a2a7034 100644
--- a/tools/dissect/main.cpp
+++ b/tools/dissect/main.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2017, Regents of the University of California.
+/*
+ * Copyright (c) 2014-2019, Regents of the University of California.
*
* This file is part of ndn-tools (Named Data Networking Essential Tools).
* See AUTHORS.md for complete list of ndn-tools authors and contributors.
@@ -114,7 +114,7 @@
} // namespace ndn
int
-main(int argc, char** argv)
+main(int argc, char* argv[])
{
return ndn::dissect::main(argc, argv);
}
diff --git a/tools/dump/main.cpp b/tools/dump/main.cpp
index 1fe54e6..e6a9898 100644
--- a/tools/dump/main.cpp
+++ b/tools/dump/main.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California.
+ * Copyright (c) 2011-2019, Regents of the University of California.
*
* This file is part of ndn-tools (Named Data Networking Essential Tools).
* See AUTHORS.md for complete list of ndn-tools authors and contributors.
@@ -16,23 +16,6 @@
* You should have received a copy of the GNU General Public License along with
* ndn-tools, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
*/
-/*
- * Copyright (c) 2011-2014, Regents of the University of California,
- *
- * This file is part of ndndump, the packet capture and analysis tool for Named Data
- * Networking (NDN).
- *
- * ndndump is free software: you can redistribute it and/or modify it under the terms
- * of the GNU General Public License as published by the Free Software Foundation,
- * either version 3 of the License, or (at your option) any later version.
- *
- * ndndump is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- * PURPOSE. See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * ndndump, e.g., in COPYING file. If not, see <http://www.gnu.org/licenses/>.
- **/
#include "ndndump.hpp"
#include "core/version.hpp"
@@ -157,7 +140,7 @@
} // namespace ndn
int
-main(int argc, char** argv)
+main(int argc, char* argv[])
{
return ndn::dump::main(argc, argv);
}
diff --git a/tools/peek/ndnpeek/main.cpp b/tools/peek/ndnpeek/main.cpp
index f04cec4..428634a 100644
--- a/tools/peek/ndnpeek/main.cpp
+++ b/tools/peek/ndnpeek/main.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -171,7 +171,7 @@
} // namespace ndn
int
-main(int argc, char** argv)
+main(int argc, char* argv[])
{
return ndn::peek::main(argc, argv);
}
diff --git a/tools/ping/client/ndn-ping.cpp b/tools/ping/client/main.cpp
similarity index 95%
rename from tools/ping/client/ndn-ping.cpp
rename to tools/ping/client/main.cpp
index 19f5bb6..86db7da 100644
--- a/tools/ping/client/ndn-ping.cpp
+++ b/tools/ping/client/main.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2017, Arizona Board of Regents.
+/*
+ * Copyright (c) 2014-2019, Arizona Board of Regents.
*
* This file is part of ndn-tools (Named Data Networking Essential Tools).
* See AUTHORS.md for complete list of ndn-tools authors and contributors.
@@ -136,15 +136,15 @@
usage(const boost::program_options::options_description& options)
{
std::cout << "Usage: ndnping [options] ndn:/name/prefix\n"
- "\n"
- "Ping a NDN name prefix using Interests with name ndn:/name/prefix/ping/number.\n"
- "The numbers in the Interests are randomly generated unless specified.\n"
- "\n";
- std::cout << options;
+ "\n"
+ "Ping a NDN name prefix using Interests with name ndn:/name/prefix/ping/number.\n"
+ "The numbers in the Interests are randomly generated unless specified.\n"
+ "\n"
+ << options;
exit(2);
}
-int
+static int
main(int argc, char* argv[])
{
Options options;
@@ -269,7 +269,7 @@
} // namespace ndn
int
-main(int argc, char** argv)
+main(int argc, char* argv[])
{
return ndn::ping::client::main(argc, argv);
}
diff --git a/tools/ping/server/ndn-ping-server.cpp b/tools/ping/server/main.cpp
similarity index 98%
rename from tools/ping/server/ndn-ping-server.cpp
rename to tools/ping/server/main.cpp
index 28c6871..9aa7261 100644
--- a/tools/ping/server/ndn-ping-server.cpp
+++ b/tools/ping/server/main.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2015-2018, Arizona Board of Regents.
+ * Copyright (c) 2015-2019, Arizona Board of Regents.
*
* This file is part of ndn-tools (Named Data Networking Essential Tools).
* See AUTHORS.md for complete list of ndn-tools authors and contributors.
@@ -187,7 +187,7 @@
} // namespace ndn
int
-main(int argc, char** argv)
+main(int argc, char* argv[])
{
return ndn::ping::server::main(argc, argv);
}
diff --git a/tools/ping/wscript b/tools/ping/wscript
index f0c5f5e..4b66c04 100644
--- a/tools/ping/wscript
+++ b/tools/ping/wscript
@@ -5,24 +5,24 @@
bld.objects(
target='ping-client-objects',
- source=bld.path.ant_glob('client/*.cpp', excl='client/ndn-ping.cpp'),
+ source=bld.path.ant_glob('client/*.cpp', excl='client/main.cpp'),
use='core-objects')
bld.program(
target='../../bin/ndnping',
name='ndnping',
- source='client/ndn-ping.cpp',
+ source='client/main.cpp',
use='ping-client-objects')
bld.objects(
target='ping-server-objects',
- source=bld.path.ant_glob('server/*.cpp', excl='server/ndn-ping-server.cpp'),
+ source=bld.path.ant_glob('server/*.cpp', excl='server/main.cpp'),
use='core-objects')
bld.program(
target='../../bin/ndnpingserver',
name='ndnpingserver',
- source='server/ndn-ping-server.cpp',
+ source='server/main.cpp',
use='ping-server-objects')
## (for unit tests)