Ejemplo n.º 1
0
ACE_INET_Addr::ACE_INET_Addr (u_short port_number,
                              const wchar_t host_name[],
                              int address_family)
  : ACE_Addr (this->determine_type(), sizeof (inet_addr_))
{
  ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr");
  ACE_OS::memset (&this->inet_addr_, 0, sizeof (this->inet_addr_));
  if (this->set (port_number,
                 host_name,
                 1,
                 address_family) == -1)
#if defined (ACE_HAS_BROKEN_CONDITIONAL_STRING_CASTS)
    ACE_ERROR ((LM_ERROR,
                (char *)"ACE_INET_Addr::ACE_INET_Addr: %p\n",
                (((char *) host_name == 0) ?
                 ((char *) "<unknown>") :
                 ((char *) (host_name)))));
#else /* ! defined (ACE_HAS_BROKEN_CONDITIONAL_STRING_CASTS) */
    ACE_ERROR ((LM_ERROR,
                ACE_LIB_TEXT ("ACE_INET_Addr::ACE_INET_Addr: %p\n"),
                ACE_TEXT_WCHAR_TO_TCHAR ((host_name == 0) ?
                                         ACE_TEXT_WIDE ("<unknown>") :
                                         host_name)));
#endif /* ! defined (ACE_HAS_BROKEN_CONDITIONAL_STRING_CASTS) */
}
Ejemplo n.º 2
0
ACE_Multihomed_INET_Addr::ACE_Multihomed_INET_Addr(u_short port_number,
                                                   const wchar_t host_name[],
                                                   int encode,
                                                   int address_family,
                                                   const wchar_t *(secondary_host_names[]),
                                                   size_t size){

  // Initialize the primary INET addr
  ACE_INET_Addr::set(port_number, host_name, encode, address_family);

  // check for secondary INET addrs
  if (secondary_host_names && size){
    // we have a non-zero pointer and size
    this->secondaries_.size(size); // size the array

    size_t next_empty_slot = 0;
    for (size_t i = 0; i < size; ++i) {
      int ret = this->secondaries_[next_empty_slot].set(port_number,
                                                       secondary_host_names[i],
                                                       encode,
                                                       address_family);
      if (ret) {
        ACE_DEBUG ((LM_DEBUG,
                    ACE_TEXT ("Invalid INET addr (%s:%u) will be ignored\n"),
                    ACE_TEXT_WCHAR_TO_TCHAR (secondary_host_names[i]), port_number));
        this->secondaries_.size(this->secondaries_.size() - 1);
      }
      else
        ++next_empty_slot;
    }
  }

  return;
}
Ejemplo n.º 3
0
///////////////////////////////////////////////////////////////////////////////
/// \brief
/// Retrieves number of folders and files in the specified folder path
/// pre-condition: assumes dirpath is a valid folder
///
void MgUnmanagedDataManager::GetNumberOfFilesAndSubfolders(CREFSTRING dirpath, INT32& numFolders, INT32& numFiles)
{
    ACE_DIR* directory = ACE_OS::opendir(ACE_TEXT_WCHAR_TO_TCHAR(dirpath.c_str()));
    if (directory != NULL)
    {
        dirent* direntry = NULL;

        // Go through the directory entries
        while ((direntry = ACE_OS::readdir(directory)) != NULL)
        {
            STRING entryName = MG_TCHAR_TO_WCHAR(direntry->d_name);

            STRING fullDataPathname = dirpath;
            if (!MgFileUtil::EndsWithSlash(fullDataPathname))
                MgFileUtil::AppendSlashToEndOfPath(fullDataPathname);

            fullDataPathname += entryName;

            if (MgFileUtil::IsFile(fullDataPathname))
            {
                ++numFiles;
            }
            else if (MgFileUtil::IsDirectory(fullDataPathname)
                && entryName.compare(L"..") != 0 // skip ..
                && entryName.compare(L".") != 0) // skip .
            {
                ++numFolders;
            }
        }
        ACE_OS::closedir(directory);
    }
}
Ejemplo n.º 4
0
///////////////////////////////////////////////////////////////////////////////
/// \brief
/// Recursive method that returns all files and/or folders for a given mapping
/// name
///
void MgUnmanagedDataManager::GetFilesAndFolders(string& list, CREFSTRING mappingName, CREFSTRING rootdir, CREFSTRING subdir, const MgStringCollection* filters, bool storeFolders, bool storeFiles, bool recursive)
{
    STRING fulldir = rootdir;
    if (!MgFileUtil::EndsWithSlash(fulldir))
        MgFileUtil::AppendSlashToEndOfPath(fulldir);

    if (!subdir.empty())
    {
        fulldir += subdir;
        if (!MgFileUtil::EndsWithSlash(fulldir))
            MgFileUtil::AppendSlashToEndOfPath(fulldir);
    }

    // Open the directory
    ACE_DIR* directory = ACE_OS::opendir(ACE_TEXT_WCHAR_TO_TCHAR(fulldir.c_str()));

    if (directory != NULL)
    {
        dirent* direntry = NULL;

        // Go through the directory entries
        while ((direntry = ACE_OS::readdir(directory)) != NULL)
        {
            STRING entryName = MG_TCHAR_TO_WCHAR(direntry->d_name);
            STRING fullDataPathname = fulldir + entryName;

            if (MgFileUtil::IsFile(fullDataPathname)
                && storeFiles
                && FilterFile(entryName, filters))
            {
                INT64 fileSize = MgFileUtil::GetFileSize(fullDataPathname);
                MgDateTime createdDate = MgFileUtil::GetFileCreationTime(fullDataPathname);
                MgDateTime modifiedDate = MgFileUtil::GetFileModificationTime(fullDataPathname);
                AddFile(list, mappingName, subdir, entryName, fileSize, createdDate, modifiedDate);
            }
            else if (MgFileUtil::IsDirectory(fullDataPathname)
                && entryName.compare(L"..") != 0 // skip ..
                && entryName.compare(L".") != 0) // skip .
            {
                if (storeFolders)
                {
                    // Add folders
                    INT32 numFolders = 0;
                    INT32 numFiles = 0;
                    GetNumberOfFilesAndSubfolders(fullDataPathname, numFolders, numFiles);
                    MgDateTime createdDate = MgFileUtil::GetFileCreationTime(fullDataPathname);
                    MgDateTime modifiedDate = MgFileUtil::GetFileModificationTime(fullDataPathname);
                    AddFolder(list, mappingName, subdir, entryName, numFolders, numFiles, createdDate, modifiedDate);
                }

                // recursive call to get files in subfolders
                if (recursive)
                    GetFilesAndFolders(list, mappingName, rootdir, FormatSubdir(subdir) + entryName, filters, storeFolders, storeFiles, recursive);
            }
        }

        ACE_OS::closedir(directory);
    }
}
Ejemplo n.º 5
0
ACE_Auto_Event::ACE_Auto_Event (int initial_state,
                                int type,
                                const wchar_t *name,
                                void *arg)
  : ACE_Event (0,
               initial_state,
               type,
               ACE_TEXT_WCHAR_TO_TCHAR (name),
               arg)
{
}
Ejemplo n.º 6
0
ACE_Auto_Event_T<TIME_POLICY>::ACE_Auto_Event_T (
    int initial_state,
    int type,
    const wchar_t *name,
    void *arg)
  : ACE_Event_T<TIME_POLICY> (0,
                              initial_state,
                              type,
                              ACE_TEXT_WCHAR_TO_TCHAR (name),
                              arg)
{
}
Ejemplo n.º 7
0
ACE_INET_Addr::ACE_INET_Addr (u_short port_number,
                              const wchar_t host_name[],
                              int address_family)
  : ACE_Addr (determine_type (), sizeof (inet_addr_))
{
  ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr");
  ACE_OS::memset (&this->inet_addr_, 0, sizeof (this->inet_addr_));
  if (this->set (port_number,
                 host_name,
                 1,
                 address_family) == -1)
    ACE_ERROR ((LM_ERROR,
                ACE_TEXT ("ACE_INET_Addr::ACE_INET_Addr: %p\n"),
                ACE_TEXT_WCHAR_TO_TCHAR ((host_name == 0) ?
                                         ACE_TEXT_WIDE ("<unknown>") :
                                         host_name)));
}