Fixed BOOST::SERIALIZATION linking error after fixed includes.
#include <boost/algorithm/string.hpp>
-
namespace po = boost::program_options;
namespace fs = boost::filesystem;
namespace ba = boost::algorithm;
#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.
#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;
#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;
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 )
#include "serializeservicecontainer.h"
-#include <boost/serialization/list.hpp>
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)
{
#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
{
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:
#include "service.h"
#include <boost/foreach.hpp>
-#include <boost/serialization/list.hpp>
+
+using namespace std;
+
/**
* Default Constructor
* @param ar Archive.
* @param version Version.
*/
+/*
template<class Archive>
void Service::serialize(Archive & ar, const unsigned int version)
{
ar & MaxUpdatesWithinInterval;
ar & DNSCacheTTL;
}
-
+*/
/**
* Setter for member Protocol.
#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
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;
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);
-}
#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
{
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:
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);
-}
#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
{
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;
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);
-}
#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
{
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;
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);
-}
#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
{
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;
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);
-}
#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
{
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;
#include "service_ods.h"
#include "net_helper.h"
+#include "util.h"
#include <time.h>
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);
-}
#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
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;
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);
-}
#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
{
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;
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);
-}
#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
{
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;
#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.
#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
{
#define TCPSERVICE_H
#include "logger.h"
+#include "ip_service.h"
#include <boost/shared_ptr.hpp>
#include <boost/asio.hpp>
#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.
*/
/** @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.
// 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);
// 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());
// 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();
* @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();
}
+};
#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