Esempio n. 1
0
void
_init(void)
{
  DP(("hello world"));

  _socket	= dlwrap("socket");

  _sock.domain	= get_u16("FORCE_BIND_SOCKDOM", AF_INET);
  _sock.type	= get_u16("FORCE_BIND_SOCKTYPE", SOCK_DGRAM);
  _sock.proto	= get_u16("FORCE_BIND_SOCKPROTO", IPPROTO_UDP);

  get_addr(&_saddr, "FORCE_BIND_ADDR", "127.0.0.1\0\0\0\0\0\0");
  get_port(&_saddr, "FORCE_BIND_PORT");
  _saddr.sin_family = _sock.domain;
}
Esempio n. 2
0
    /** 
    * Load a library
    * @param filepath :: The full path to a library as a string
    */
    bool LibraryManagerImpl::loadLibrary(const std::string & filepath)
    {
      // Get the name of the library.
      std::string libName = DllOpen::ConvertToLibName(Poco::Path(filepath).getFileName());
      if( libName.empty() ) return false;
      // The wrapper will unload the library when it is deleted
      boost::shared_ptr<LibraryWrapper> dlwrap(new LibraryWrapper);
      std::string libNameLower = boost::algorithm::to_lower_copy(libName);

      //Check that a libray with this name has not already been loaded
      if (OpenLibs.find(libNameLower) == OpenLibs.end())
      {
        Poco::Path directory(filepath);
        directory.makeParent();
        if (g_log.is(Poco::Message::PRIO_DEBUG))
        {
          g_log.debug() << "Trying to open library: " << libName << " from " << directory.toString() << " ...";
        }
        //Try to open the library
        if (dlwrap->OpenLibrary(libName, directory.toString()))
        {
          //Successfully opened, so add to map
          g_log.debug("Opened library: " + libName + ".\n");
          OpenLibs.insert(std::pair< std::string, boost::shared_ptr<LibraryWrapper> >(libName, dlwrap) );
          return true;
        }
        else
        {
          return false;
        }
      }
      else
      {
        g_log.debug() << libName << " already opened, skipping load\n";
      }
      return false;
    }