]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[3508] Changes after review
authorTomek Mrugalski <tomasz@isc.org>
Mon, 11 Aug 2014 20:37:29 +0000 (22:37 +0200)
committerTomek Mrugalski <tomasz@isc.org>
Mon, 11 Aug 2014 20:37:29 +0000 (22:37 +0200)
 - Daemon::getVersion() added
 - exists => exits in docs
 - fixed comment in dhcp_test_lib.sh.in

12 files changed:
doc/guide/ddns.xml
doc/guide/dhcp4-srv.xml
doc/guide/dhcp6-srv.xml
src/bin/d2/d_controller.cc
src/bin/d2/d_controller.h
src/bin/dhcp4/dhcp4_srv.cc
src/bin/dhcp4/main.cc
src/bin/dhcp6/dhcp6_srv.cc
src/bin/dhcp6/main.cc
src/lib/dhcpsrv/daemon.h
src/lib/dhcpsrv/tests/daemon_unittest.cc
src/lib/testutils/dhcp_test_lib.sh.in

index 854220b5fdcc222b879eae8ac6396bda43574faf..d88257ea257a267018edf725a7ac077f48a8a472 100644 (file)
           </listitem>
           <listitem>
             <simpara>
-              <command>-v</command> - prints out Kea version and exists.
+              <command>-v</command> - prints out Kea version and exits.
             </simpara>
           </listitem>
           <listitem>
             <simpara>
               <command>-V</command> - prints out Kea extended version with
-              additional parameters and exists.
+              additional parameters and exits.
             </simpara>
           </listitem>
       </itemizedlist>
index 0eb240a0b5ddc7eaae3328973070421c58f5fce5..3263aa73b6c92e4649c5207d6d2256b6c9916b3d 100644 (file)
           </listitem>
           <listitem>
             <simpara>
-              <command>-v</command> - prints out Kea version and exists.
+              <command>-v</command> - prints out Kea version and exits.
             </simpara>
           </listitem>
           <listitem>
             <simpara>
               <command>-V</command> - prints out Kea extended version with
-              additional parameters and exists.
+              additional parameters and exits.
             </simpara>
           </listitem>
       </itemizedlist>
index 6a0afb82d9ca28eab34c9feb30a9acec7a0fa067..361b8f41818952e61b88975d64e3710454f15e08 100644 (file)
           </listitem>
           <listitem>
             <simpara>
-              <command>-v</command> - prints out Kea version and exists.
+              <command>-v</command> - prints out Kea version and exits.
             </simpara>
           </listitem>
           <listitem>
             <simpara>
               <command>-V</command> - prints out Kea extended version with
-              additional parameters and exists.
+              additional parameters and exits.
             </simpara>
           </listitem>
       </itemizedlist>
index 6e409c9c72a921670cfecc6d2b17f580ccebc890..29e3e288df0e54f645733900c9c246249593cb9b 100644 (file)
@@ -124,20 +124,6 @@ DControllerBase::launch(int argc, char* argv[], const bool test_mode) {
     LOG_INFO(dctl_logger, DHCP_DDNS_SHUTDOWN);
 }
 
-void
-DControllerBase::printVersion(bool extended) const {
-    std::cout << VERSION << std::endl;
-    if (extended) {
-        std::cout << EXTENDED_VERSION << std::endl;
-
-        // @todo print more details (is it Botan or OpenSSL build,
-        // with or without MySQL/Postgres? What compilation options were
-        // used? etc)
-    }
-
-    exit(EXIT_SUCCESS);
-}
-
 void
 DControllerBase::parseArgs(int argc, char* argv[])
 {
@@ -156,12 +142,14 @@ DControllerBase::parseArgs(int argc, char* argv[])
             break;
 
         case 'v':
-            printVersion(false); // print just Kea version and exit
-            break; // break not really needed, print_version never returns
+            // Print just Kea version and exit
+            std::cout << getVersion(false) << std::endl;
+            exit(EXIT_SUCCESS);
 
         case 'V':
-            printVersion(true); // print extended Kea version and exit
-            break; // break not really needed, print_version never returns
+            // Print extended Kea version and exit
+            std::cout << getVersion(true) << std::endl;
+            exit(EXIT_SUCCESS);
             
         case 'c':
             // config file name
@@ -448,3 +436,19 @@ dhcp::Daemon::loggerInit(const char* log_name, bool verbose) {
 }
 
 }; // namespace isc
+
+std::string
+isc::dhcp::Daemon::getVersion(bool extended) {
+    std::stringstream tmp;
+
+    tmp << VERSION;
+    if (extended) {
+        tmp << std::endl << EXTENDED_VERSION;
+
+        // @todo print more details (is it Botan or OpenSSL build,
+        // with or without MySQL/Postgres? What compilation options were
+        // used? etc)
+    }
+
+    return (tmp.str());
+}
index 3ba5280814f8b8cf1f2990e0af20b47fc73081f4..c1e35c9e0ddc397013f43827da5ab4238fdbe5a7 100644 (file)
@@ -457,12 +457,6 @@ protected:
     /// This is intended to be used for specific usage violation messages.
     void usage(const std::string& text);
 
-    /// @brief Prints version number to stdout and exit.
-    ///
-    /// Note: This method never returns, it terminates the process.
-    /// @param extended print additional information?
-    void printVersion(bool extended) const;
-
 private:
     /// @brief Name of the service under control.
     /// This name is used as the configuration module name and appears in log
index 7f711a19b0a1e5802590e1cdea67e4732429a056..d72f7e0fc3cc1dc0b088e457e9cf86c25ba01c1f 100644 (file)
@@ -2032,5 +2032,21 @@ Dhcpv4Srv::d2ClientErrorHandler(const
     CfgMgr::instance().getD2ClientMgr().suspendUpdates();
 }
 
+std::string
+Daemon::getVersion(bool extended) {
+    std::stringstream tmp;
+
+    tmp << VERSION;
+    if (extended) {
+        tmp << endl << EXTENDED_VERSION;
+
+        // @todo print more details (is it Botan or OpenSSL build,
+        // with or without MySQL/Postgres? What compilation options were
+        // used? etc)
+    }
+
+    return (tmp.str());
+}
+
 }   // namespace dhcp
 }   // namespace isc
index e290f68c840a0ba4697ff4f617688ac83661d2f8..56d9c1c7d527035010f049a203392d0fe223e9da 100644 (file)
@@ -60,24 +60,6 @@ usage() {
 }
 } // end of anonymous namespace
 
-/// @brief Prints Kea version on stdout and exits.
-///
-/// Note: This function never returns. It terminates the process.
-/// @param extended print additional information?
-void
-printVersion(bool extended) {
-    cout << VERSION << endl;
-    if (extended) {
-        cout << EXTENDED_VERSION << endl;
-
-        // @todo print more details (is it Botan or OpenSSL build,
-        // with or without MySQL/Postgres? What compilation options were
-        // used? etc)
-    }
-
-    exit(EXIT_SUCCESS);
-}
-
 int
 main(int argc, char* argv[]) {
     int ch;
@@ -95,12 +77,12 @@ main(int argc, char* argv[]) {
             break;
 
         case 'v':
-            printVersion(false); // print just Kea version and exit
-            break; // break not really needed, print_version never returns
+            cout << Daemon::getVersion(false) << endl;
+            return (EXIT_SUCCESS);
 
         case 'V':
-            printVersion(true); // print extended Kea version and exit
-            break; // break not really needed, print_version never returns
+            cout << Daemon::getVersion(false) << endl;
+            return (EXIT_SUCCESS);
 
         case 'p':
             try {
index 098293b8b7d1200e42992adbe3b3d8e886e7baf5..a84cb35e01ec636814b36044990f2fcaf86841c8 100644 (file)
@@ -2692,5 +2692,21 @@ Dhcpv6Srv::d2ClientErrorHandler(const
     CfgMgr::instance().getD2ClientMgr().suspendUpdates();
 }
 
+std::string
+Daemon::getVersion(bool extended) {
+    std::stringstream tmp;
+
+    tmp << VERSION;
+    if (extended) {
+        tmp << endl << EXTENDED_VERSION;
+
+        // @todo print more details (is it Botan or OpenSSL build,
+        // with or without MySQL/Postgres? What compilation options were
+        // used? etc)
+    }
+
+    return (tmp.str());
+}
+
 };
 };
index 6407061ae42702c1af81371f15a51ee3a8669f96..ca86f6812ea1a735c7985a62dd606dca66fbe1a8 100644 (file)
@@ -60,24 +60,6 @@ usage() {
 }
 } // end of anonymous namespace
 
-/// @brief Prints Kea version on stdout and exits.
-///
-/// Note: This function never returns. It terminates the process.
-/// @param extended print additional information?
-void
-printVersion(bool extended) {
-    cout << VERSION << endl;
-    if (extended) {
-        cout << EXTENDED_VERSION << endl;
-
-        // @todo print more details (is it Botan or OpenSSL build,
-        // with or without MySQL/Postgres? What compilation options were
-        // used? etc)
-    }
-
-    exit(EXIT_SUCCESS);
-}
-
 int
 main(int argc, char* argv[]) {
     int ch;
@@ -95,12 +77,12 @@ main(int argc, char* argv[]) {
             break;
 
         case 'v':
-            printVersion(false); // print just Kea version and exit
-            break; // break not really needed, print_version never returns
+            cout << Daemon::getVersion(false) << endl;
+            return (EXIT_SUCCESS);
 
         case 'V':
-            printVersion(true); // print extended Kea version and exit
-            break; // break not really needed, print_version never returns
+            cout << Daemon::getVersion(true) << endl;
+            return (EXIT_SUCCESS);
 
         case 'p': // port number
             try {
index af518b5a44ba024949d2352cd2b8dd7ca073555d..c9939a77b2e9f3dfbefcc8a3f1c58b4f0372be5d 100644 (file)
@@ -151,6 +151,17 @@ public:
         return (verbose_);
     }
 
+    /// @brief returns Kea version on stdout and exits.
+    ///
+    /// With extended == false, this method returns a simple string
+    /// containing version number. With extended == true, it returns
+    /// also additional information about sources. It is expected to
+    /// return extra information about dependencies and used DB backends.
+    ///
+    /// @param extended print additional information?
+    /// @return text string
+    static std::string getVersion(bool extended);
+
 protected:
 
     /// @brief Invokes handler for the next received signal.
index 7e805e5b7a0d4dce39066430b11a7bdc1656bc98..572812d3f16767878371fe7f5cd49b6f6083d1d4 100644 (file)
@@ -23,8 +23,17 @@ using namespace isc;
 using namespace isc::dhcp;
 using namespace isc::data;
 
+std::string isc::dhcp::Daemon::getVersion(bool extended) {
+    if (extended) {
+        return (std::string("EXTENDED"));
+    } else {
+        return (std::string("BASIC"));
+    }
+}
+
 namespace {
 
+
 // Very simple test. Checks whether Daemon can be instantiated and its
 // default parameters are sane
 TEST(DaemonTest, constructor) {
index 39ef7ff77402d7352072c57512ccb26c82c5f699..b63f7d48b571c57388b13f0ce25632d29ef2ea09 100644 (file)
@@ -402,7 +402,7 @@ must be a number"
     kill -${sig} ${_GET_PIDS}
 }
 
-# This test verifies that DHCPv4 server is reporting its version properly.
+# This test verifies that the binary is reporting its version properly.
 version_test() {
     test_name=${1}  # Test name