Fixed includes.
authorBjoern Sikora <bjoern.sikora@intra2net.com>
Fri, 18 Sep 2009 15:51:01 +0000 (17:51 +0200)
committerBjoern Sikora <bjoern.sikora@intra2net.com>
Fri, 18 Sep 2009 15:51:01 +0000 (17:51 +0200)
Fixed BOOST::SERIALIZATION linking error after fixed includes.

30 files changed:
src/config.cpp
src/httphelper.cpp
src/logger.cpp
src/main.cpp
src/serializeservicecontainer.cpp
src/serializeservicecontainer.h
src/service.cpp
src/service.h
src/service_dhs.cpp
src/service_dhs.h
src/service_dyndns.cpp
src/service_dyndns.h
src/service_dyns.cpp
src/service_dyns.h
src/service_easydns.cpp
src/service_easydns.h
src/service_gnudip.cpp
src/service_gnudip.h
src/service_ods.cpp
src/service_ods.h
src/service_tzo.cpp
src/service_tzo.h
src/service_zoneedit.cpp
src/service_zoneedit.h
src/serviceholder.cpp
src/serviceholder.h
src/tcp_service.h
src/updater.cpp
src/util.cpp
src/util.h

index cb9cbf8..8ca4025 100644 (file)
@@ -28,7 +28,6 @@
 #include <boost/algorithm/string.hpp>
 
 
-
 namespace po = boost::program_options;
 namespace fs = boost::filesystem;
 namespace ba = boost::algorithm;
index 890388d..a490520 100644 (file)
@@ -9,6 +9,7 @@
 
 #include "httphelper.h"
 
+using namespace std;
 
 /**
  * Constructor. Use this constructor if HTTP AUTH should be used. Username and password will then be set as HTTP auth options.
index a1fd53c..bf8a58a 100644 (file)
 
 #include "logger.h"
 
+#include <iostream>
 #include <syslog.h>
 #include <sstream>
 
 #include <boost/foreach.hpp>
 
+#define VERSION     0
+#define REVISION    1
+#define RELEASE     0
+
 namespace po = boost::program_options;
 
 typedef boost::shared_ptr<boost::program_options::options_description> Options_descriptionPtr;
index a2a221f..48513ce 100644 (file)
@@ -16,7 +16,6 @@
 #define RELEASE     0
 
 #define PIDFILE "/home/bjoern/intranator/bpdyndnsd/var/run/bpdyndnsd.pid"
-#define OBJECT_FILE "/home/bjoern/intranator/bpdyndnsd/objects.ser"
 
 #include <iostream>
 #include <fstream>
 
 #include "updater.h"
 
-#include "config.cpp"
-#include "logger.cpp"
-#include "serviceholder.cpp"
-#include "updater.cpp"
-#include "ip_addr_helper.cpp"
-#include "net_helper.cpp"
-#include "tcp_service.cpp"
-#include "httphelper.cpp"
-#include "serializeservicecontainer.cpp"
-#include "util.cpp"
-
-#include "service.cpp"
-#include "service_dyndns.cpp"
-#include "service_dyns.cpp"
-#include "service_ods.cpp"
-#include "service_dhs.cpp"
-#include "service_easydns.cpp"
-#include "service_tzo.cpp"
-#include "service_zoneedit.cpp"
-#include "service_gnudip.cpp"
-
-
 using namespace std;
 
 Updater::Ptr updater;
@@ -281,7 +258,9 @@ int init_daemon_mode(bool daemon_mode)
 int main(int argc, char *argv[])
 {
     // initialize Updater
-    Updater::Ptr updater(new Updater);
+    Updater::Ptr _updater(new Updater);
+    updater.swap(_updater);
+    _updater.reset();
 
     // load config and initialize helper classes
     if ( updater->load_config(argc,argv) != 0 )
index 8366a3b..b3857fc 100644 (file)
@@ -9,7 +9,6 @@
 
 #include "serializeservicecontainer.h"
 
-#include <boost/serialization/list.hpp>
 
 SerializeServiceContainer::SerializeServiceContainer()
 {
@@ -26,12 +25,13 @@ SerializeServiceContainer::~SerializeServiceContainer()
  * @param ar Archive
  * @param version Version
  */
+/*
 template<class Archive>
 void SerializeServiceContainer::serialize(Archive & ar, const unsigned int version)
 {
     ar & ContainingServices;
 }
-
+*/
 
 void SerializeServiceContainer::add_service(Service::Ptr service)
 {
index ab450d9..b890865 100644 (file)
 #ifndef SERIALIZESERVICECONTAINER_H
 #define SERIALIZESERVICECONTAINER_H
 
-#include <list>
-
 #include "service.h"
 #include "logger.h"
 
-#include <boost/serialization/array.hpp>
+#include <boost/serialization/list.hpp>
+#include <boost/serialization/shared_ptr.hpp>
+#include <boost/serialization/export.hpp>
+
 #include <boost/shared_ptr.hpp>
+#include <list>
+
+#include "service_dhs.h"
+#include "service_ods.h"
+#include "service_dyndns.h"
+#include "service_dyns.h"
+#include "service_easydns.h"
+#include "service_tzo.h"
+#include "service_zoneedit.h"
+#include "service_gnudip.h"
+
+// Following boost macros are needed for serialization of derived classes through a base class pointer (Service *).
+BOOST_CLASS_EXPORT_GUID(ServiceOds, "ServiceOds")
+BOOST_CLASS_EXPORT_GUID(ServiceDhs, "ServiceDhs")
+BOOST_CLASS_EXPORT_GUID(ServiceDyns, "ServiceDyns")
+BOOST_CLASS_EXPORT_GUID(ServiceDyndns, "ServiceDyndns")
+BOOST_CLASS_EXPORT_GUID(ServiceEasydns, "ServiceEasydns")
+BOOST_CLASS_EXPORT_GUID(ServiceTzo, "ServiceTzo")
+BOOST_CLASS_EXPORT_GUID(ServiceZoneedit, "ServiceZoneedit")
+BOOST_CLASS_EXPORT_GUID(ServiceGnudip, "ServiceGnudip")
+
 
 class SerializeServiceContainer
 {
@@ -27,7 +49,10 @@ private:
 
     friend class boost::serialization::access;
     template<class Archive>
-    void serialize(Archive & ar, const unsigned int version);
+    void serialize(Archive & ar, const unsigned int version)
+    {
+        ar & ContainingServices;
+    }
 
 public:
 
index a9869e0..7dc10e8 100644 (file)
@@ -9,7 +9,9 @@
 
 #include "service.h"
 #include <boost/foreach.hpp>
-#include <boost/serialization/list.hpp>
+
+using namespace std;
+
 
 /**
  * Default Constructor
@@ -39,6 +41,7 @@ Service::~Service()
  * @param ar Archive.
  * @param version Version.
  */
+/*
 template<class Archive>
 void Service::serialize(Archive & ar, const unsigned int version)
 {
@@ -52,7 +55,7 @@ void Service::serialize(Archive & ar, const unsigned int version)
     ar & MaxUpdatesWithinInterval;
     ar & DNSCacheTTL;
 }
-
+*/
 
 /**
  * Setter for member Protocol.
index ca204d6..572a600 100644 (file)
 
 #include "logger.h"
 
-#include <string>
+#include <boost/archive/text_oarchive.hpp>
+#include <boost/archive/text_iarchive.hpp>
 
-#include <boost/serialization/array.hpp>
 #include <boost/shared_ptr.hpp>
+#include <string>
+#include <list>
 
 
 class Service
@@ -39,7 +41,18 @@ private:
 
     friend class boost::serialization::access;
     template<class Archive>
-    void serialize(Archive & ar, const unsigned int version);
+    void serialize(Archive & ar, const unsigned int version)
+    {
+        // protocol and hostname are the unique identifier for each service.
+        ar & Protocol;
+        ar & Hostname;
+        // lastupdated and actual_ip must also be serialized, cause these are essential infos of each service.
+        ar & LastUpdates;
+        ar & ActualIP;
+        ar & UpdateInterval;
+        ar & MaxUpdatesWithinInterval;
+        ar & DNSCacheTTL;
+    }
 
     Logger::Ptr Log;
 
index e98d864..df107a7 100644 (file)
@@ -173,15 +173,3 @@ int ServiceDhs::perform_update(const std::string& ip)
 
     return -1;
 }
-
-
-/**
- * Serialize function needed by boost/serialization to define which members should be stored as the object state.
- * @param ar Archive
- * @param version Version
- */
-template<class Archive>
-void ServiceDhs::serialize(Archive & ar, const unsigned int version)
-{
-    ar & boost::serialization::base_object<Service>(*this);
-}
index cb7f46a..283c8af 100644 (file)
 #ifndef ServiceDhs_H
 #define ServiceDhs_H
 
-#include <string>
-
 #include "service.h"
 #include "logger.h"
+#include "httphelper.h"
 
-#include <boost/serialization/array.hpp>
 #include <boost/shared_ptr.hpp>
+#include <string>
 #include <list>
 
+
 class ServiceDhs : public Service
 {
 
@@ -26,14 +26,16 @@ private:
 
     friend class boost::serialization::access;
     template<class Archive>
-    void serialize(Archive & ar, const unsigned int version);
+    void serialize(Archive & ar, const unsigned int version)
+    {
+        ar & boost::serialization::base_object<Service>(*this);
+    }
 
     std::string BaseUrl;
 
     HTTPHelper::Ptr HTTPHelp;
 
     std::list<std::string> separate_domain_and_host_part(const std::string& str) const;
-
     std::string assemble_base_url(const std::string& hostname, const std::string& domain_part) const;
 
 public:
index dd6fee0..a867211 100644 (file)
@@ -133,15 +133,3 @@ int ServiceDyndns::perform_update(const std::string& ip)
 
     return -1;
 }
-
-
-/**
- * Serialize function needed by boost/serialization to define which members should be stored as the object state.
- * @param ar Archive
- * @param version Version
- */
-template<class Archive>
-void ServiceDyndns::serialize(Archive & ar, const unsigned int version)
-{
-    ar & boost::serialization::base_object<Service>(*this);
-}
index 8373b71..1e18db7 100644 (file)
 #ifndef ServiceDyndns_H
 #define ServiceDyndns_H
 
-#include <string>
-
 #include "service.h"
 #include "logger.h"
+#include "httphelper.h"
 
-#include <boost/serialization/array.hpp>
 #include <boost/shared_ptr.hpp>
-#include <list>
+#include <string>
+
 
 class ServiceDyndns : public Service
 {
@@ -26,7 +25,10 @@ private:
 
     friend class boost::serialization::access;
     template<class Archive>
-    void serialize(Archive & ar, const unsigned int version);
+    void serialize(Archive & ar, const unsigned int version)
+    {
+        ar & boost::serialization::base_object<Service>(*this);
+    }
 
     std::string BaseUrl;
 
index d8e9eb8..b3a68cd 100644 (file)
@@ -139,15 +139,3 @@ int ServiceDyns::perform_update(const std::string& ip)
 
     return -1;
 }
-
-
-/**
- * Serialize function needed by boost/serialization to define which members should be stored as the object state.
- * @param ar Archive
- * @param version Version
- */
-template<class Archive>
-void ServiceDyns::serialize(Archive & ar, const unsigned int version)
-{
-    ar & boost::serialization::base_object<Service>(*this);
-}
index 2fc868a..14caf3d 100644 (file)
 #ifndef ServiceDyns_H
 #define ServiceDyns_H
 
-#include <string>
-
 #include "service.h"
 #include "logger.h"
+#include "httphelper.h"
 
-#include <boost/serialization/array.hpp>
 #include <boost/shared_ptr.hpp>
-#include <list>
+#include <string>
+
 
 class ServiceDyns : public Service
 {
@@ -26,7 +25,10 @@ private:
 
     friend class boost::serialization::access;
     template<class Archive>
-    void serialize(Archive & ar, const unsigned int version);
+    void serialize(Archive & ar, const unsigned int version)
+    {
+        ar & boost::serialization::base_object<Service>(*this);
+    }
 
     std::string BaseUrl;
 
index 75ce7ac..70d33c2 100644 (file)
@@ -215,15 +215,3 @@ int ServiceEasydns::perform_update(const std::string& ip)
 
     return -1;
 }
-
-
-/**
- * Serialize function needed by boost/serialization to define which members should be stored as the object state.
- * @param ar Archive
- * @param version Version
- */
-template<class Archive>
-void ServiceEasydns::serialize(Archive & ar, const unsigned int version)
-{
-    ar & boost::serialization::base_object<Service>(*this);
-}
index 777a942..b018665 100644 (file)
 #ifndef ServiceEasydns_H
 #define ServiceEasydns_H
 
-#include <string>
-
 #include "service.h"
 #include "logger.h"
+#include "httphelper.h"
 
-#include <boost/serialization/array.hpp>
 #include <boost/shared_ptr.hpp>
-#include <list>
+#include <string>
+
 
 class ServiceEasydns : public Service
 {
@@ -26,7 +25,10 @@ private:
 
     friend class boost::serialization::access;
     template<class Archive>
-    void serialize(Archive & ar, const unsigned int version);
+    void serialize(Archive & ar, const unsigned int version)
+    {
+        ar & boost::serialization::base_object<Service>(*this);
+    }
 
     std::string BaseUrl;
 
index 6c2a517..aaba8e5 100644 (file)
@@ -291,15 +291,3 @@ int ServiceGnudip::perform_update(const std::string& ip)
 
     return -1;
 }
-
-
-/**
- * Serialize function needed by boost/serialization to define which members should be stored as the object state.
- * @param ar Archive
- * @param version Version
- */
-template<class Archive>
-void ServiceGnudip::serialize(Archive & ar, const unsigned int version)
-{
-    ar & boost::serialization::base_object<Service>(*this);
-}
index 8e6306f..b58e6ff 100644 (file)
 #ifndef ServiceGnudip_H
 #define ServiceGnudip_H
 
-#include <string>
-
 #include "service.h"
 #include "logger.h"
+#include "httphelper.h"
 
-#include <boost/serialization/array.hpp>
 #include <boost/shared_ptr.hpp>
-#include <list>
 #include <map>
+#include <string>
+
 
 class ServiceGnudip : public Service
 {
@@ -27,7 +26,10 @@ private:
 
     friend class boost::serialization::access;
     template<class Archive>
-    void serialize(Archive & ar, const unsigned int version);
+    void serialize(Archive & ar, const unsigned int version)
+    {
+        ar & boost::serialization::base_object<Service>(*this);
+    }
 
     std::string GnudipServer;
     std::string BaseUrl;
index a586c0b..26d862d 100644 (file)
@@ -9,6 +9,7 @@
 
 #include "service_ods.h"
 #include "net_helper.h"
+#include "util.h"
 
 #include <time.h>
 
@@ -160,15 +161,3 @@ int ServiceOds::perform_update(const std::string& ip)
     connection->close_connection();
     return 0;
 }
-
-
-/**
- * Serialize function needed by boost/serialization to define which members should be stored as the object state.
- * @param ar Archive
- * @param version Version
- */
-template<class Archive>
-void ServiceOds::serialize(Archive & ar, const unsigned int version)
-{
-    ar & boost::serialization::base_object<Service>(*this);
-}
index b832daf..5e9ffff 100644 (file)
 #ifndef ServiceOds_H
 #define ServiceOds_H
 
-#include <string>
-
 #include "service.h"
 #include "logger.h"
 
-#include <boost/serialization/array.hpp>
 #include <boost/shared_ptr.hpp>
+#include <string>
 
 
 class ServiceOds : public Service
@@ -26,7 +24,10 @@ private:
 
     friend class boost::serialization::access;
     template<class Archive>
-    void serialize(Archive & ar, const unsigned int version);
+    void serialize(Archive & ar, const unsigned int version)
+    {
+        ar & boost::serialization::base_object<Service>(*this);
+    }
 
     std::string UpdateServer;
     std::string Port;
index 71a76c3..895e816 100644 (file)
@@ -139,15 +139,3 @@ int ServiceTzo::perform_update(const std::string& ip)
 
     return -1;
 }
-
-
-/**
- * Serialize function needed by boost/serialization to define which members should be stored as the object state.
- * @param ar Archive
- * @param version Version
- */
-template<class Archive>
-void ServiceTzo::serialize(Archive & ar, const unsigned int version)
-{
-    ar & boost::serialization::base_object<Service>(*this);
-}
index 7e58f9d..0e8da5a 100644 (file)
 #ifndef ServiceTzo_H
 #define ServiceTzo_H
 
-#include <string>
-
 #include "service.h"
 #include "logger.h"
+#include "httphelper.h"
 
-#include <boost/serialization/array.hpp>
 #include <boost/shared_ptr.hpp>
-#include <list>
+#include <string>
+
 
 class ServiceTzo : public Service
 {
@@ -26,7 +25,10 @@ private:
 
     friend class boost::serialization::access;
     template<class Archive>
-    void serialize(Archive & ar, const unsigned int version);
+    void serialize(Archive & ar, const unsigned int version)
+    {
+        ar & boost::serialization::base_object<Service>(*this);
+    }
 
     std::string BaseUrl;
 
index 9365529..75ef63a 100644 (file)
@@ -133,15 +133,3 @@ int ServiceZoneedit::perform_update(const std::string& ip)
 
     return -1;
 }
-
-
-/**
- * Serialize function needed by boost/serialization to define which members should be stored as the object state.
- * @param ar Archive
- * @param version Version
- */
-template<class Archive>
-void ServiceZoneedit::serialize(Archive & ar, const unsigned int version)
-{
-    ar & boost::serialization::base_object<Service>(*this);
-}
index 7e5dc5b..bd58161 100644 (file)
 #ifndef ServiceZoneedit_H
 #define ServiceZoneedit_H
 
-#include <string>
-
 #include "service.h"
 #include "logger.h"
+#include "httphelper.h"
 
-#include <boost/serialization/array.hpp>
 #include <boost/shared_ptr.hpp>
-#include <list>
+#include <string>
+
 
 class ServiceZoneedit : public Service
 {
@@ -26,7 +25,10 @@ private:
 
     friend class boost::serialization::access;
     template<class Archive>
-    void serialize(Archive & ar, const unsigned int version);
+    void serialize(Archive & ar, const unsigned int version)
+    {
+        ar & boost::serialization::base_object<Service>(*this);
+    }
 
     std::string BaseUrl;
 
index e07f84e..7dfbd3f 100644 (file)
@@ -9,17 +9,17 @@
 
 #include "serviceholder.h"
 
-#include "serializeservicecontainer.h"
+#include <fstream>
 
+#include <boost/foreach.hpp>
 #include <boost/filesystem.hpp>
-#include <boost/archive/text_oarchive.hpp>
-#include <boost/archive/text_iarchive.hpp>
-#include <boost/archive/archive_exception.hpp>
-#include <boost/serialization/export.hpp>
-#include <boost/serialization/shared_ptr.hpp>
+
+#define OBJECT_FILE "/home/bjoern/intranator/bpdyndnsd/objects.ser"
 
 using namespace std;
 
+namespace fs = boost::filesystem;
+
 
 /**
  * Default constructor with Logger object.
index a103cf2..2653783 100644 (file)
 #ifndef SERVICEHOLDER_H
 #define SERVICEHOLDER_H
 
-#include <list>
-
 #include "service.h"
+#include "serializeservicecontainer.h"
 #include "logger.h"
 
 #include <boost/shared_ptr.hpp>
+#include <list>
+
 
 class Serviceholder
 {
index ef5bdd6..74cdb3f 100644 (file)
@@ -11,6 +11,7 @@
 #define TCPSERVICE_H
 
 #include "logger.h"
+#include "ip_service.h"
 
 #include <boost/shared_ptr.hpp>
 #include <boost/asio.hpp>
index 4a62541..9d055f2 100644 (file)
 #include "updater.h"
 
 #include "serviceholder.h"
-#include "service_dhs.h"
-#include "service_ods.h"
-#include "service_dyndns.h"
-#include "service_dyns.h"
-#include "service_easydns.h"
-#include "service_tzo.h"
-#include "service_zoneedit.h"
-#include "service_gnudip.h"
 
-#include <boost/foreach.hpp>
-
-
-// Following boost macros are needed for serialization of derived classes through a base class pointer (Service *).
-BOOST_CLASS_EXPORT_GUID(ServiceOds, "ServiceOds")
-BOOST_CLASS_EXPORT_GUID(ServiceDhs, "ServiceDhs")
-BOOST_CLASS_EXPORT_GUID(ServiceDyns, "ServiceDyns")
-BOOST_CLASS_EXPORT_GUID(ServiceDyndns, "ServiceDyndns")
-BOOST_CLASS_EXPORT_GUID(ServiceEasydns, "ServiceEasydns")
-BOOST_CLASS_EXPORT_GUID(ServiceTzo, "ServiceTzo")
-BOOST_CLASS_EXPORT_GUID(ServiceZoneedit, "ServiceZoneedit")
-BOOST_CLASS_EXPORT_GUID(ServiceGnudip, "ServiceGnudip")
 
+#include <boost/foreach.hpp>
+#include <boost/serialization/export.hpp>
 
-namespace fs = boost::filesystem;
 
 using namespace std;
 
+
 /**
  * Default constructor which initializes the member Conf.
  */
index 18ad24c..96cd7e7 100644 (file)
@@ -1,5 +1,5 @@
 /** @file
- * @brief Util namespace implementation.
+ * @brief Util namespace header.
  *
  *
  *
 
 #include <sstream>
 #include <openssl/evp.h>
+#include <boost/algorithm/string.hpp>
 
-using namespace std;
-
+namespace Util
+{
 /**
  * Computes a MD5 Digest from the given string and returns the HEX representation
  * @param data The string to compute the md5 for
  * @return The computed md5 in hex
  */
-string Util::compute_md5_digest(string data) throw (invalid_argument)
+std::string compute_md5_digest(std::string data) throw (std::invalid_argument)
 {
     // compute an MD5 digest.
 
@@ -36,7 +37,7 @@ string Util::compute_md5_digest(string data) throw (invalid_argument)
 
     // Test if md is initialized.
     if ( (md == NULL) || (EVP_MD_size(md) == 0) )
-        throw invalid_argument("NULL pointer: md");
+        throw std::invalid_argument("NULL pointer: md");
 
     // Initalize digest content mdctx.
     EVP_MD_CTX_init(&mdctx);
@@ -46,7 +47,7 @@ string Util::compute_md5_digest(string data) throw (invalid_argument)
 
     // Test if data is empty.
     if ( data.empty() )
-        throw invalid_argument("Passed data is empty");
+        throw std::invalid_argument("Passed data is empty");
 
     // Hash the data. At this point data is not empty and &mdctx is initialized.
     EVP_DigestUpdate(&mdctx, data.c_str(), data.size());
@@ -56,19 +57,19 @@ string Util::compute_md5_digest(string data) throw (invalid_argument)
 
     // Test if md_value is filled correctly and md_len is not zero.
     if ( (md_len == 0) || (md_value == NULL) || (EVP_MD_CTX_size(&mdctx) == 0) )
-        throw invalid_argument("Retrieved invalid digest value");
+        throw std::invalid_argument("Retrieved invalid digest value");
 
     // Internal cleanup of the digest content.
     EVP_MD_CTX_cleanup(&mdctx);
     EVP_cleanup();
 
     // Convert md5 digest C string to hex.
-    ostringstream oss_digest_md5_hex;
+    std::ostringstream oss_digest_md5_hex;
     for(unsigned int i = 0; i < md_len; ++i)
     {
         // We have to do a static cast to an decimal representation, cause otherwise ostringstream would interpret
         // the stream as a character and output the character representation of the hex value.
-        oss_digest_md5_hex << hex << static_cast<unsigned short>(md_value[i]);
+        oss_digest_md5_hex << std::hex << static_cast<unsigned short>(md_value[i]);
     }
 
     return oss_digest_md5_hex.str();
@@ -80,9 +81,10 @@ string Util::compute_md5_digest(string data) throw (invalid_argument)
  * @param data The data containing the status code at front, limited by " ".
  * @return The parsed status code.
  */
-string Util::parse_status_code(string data)
+std::string parse_status_code(std::string data)
 {
-    list<string> tokens;
-    ba::split(tokens,data,boost::is_any_of(" "));
+    std::list<std::string> tokens;
+    boost::algorithm::split(tokens,data,boost::is_any_of(" "));
     return tokens.front();
 }
+};
index cf8299b..1d470d0 100644 (file)
 #ifndef UTIL_H
 #define UTIL_H
 
+#include <string>
+#include <stdexcept>
+#include <list>
+
 
 namespace Util
 {
-    static std::string compute_md5_digest(std::string data) throw (std::invalid_argument);
-    static std::string parse_status_code(std::string data);
+    std::string compute_md5_digest(std::string data) throw (std::invalid_argument);
+    std::string parse_status_code(std::string data);
 };
 
 #endif