/*
** A "local" function of ProcessRequest().  Searches through the registration
** file for unexpired objects that match #filter#.  Returns a malloc'ed string
** of the matching objects.
*/
static char *
DoSearch(const char *filter) {

  unsigned long expiration;
  char expirationImage[15 + 1];
  unsigned long now;
  const char *object;
  const char *registration;
  char *returnValue;

  now = (unsigned long)CurrentTime();
  returnValue = strdup("");

  for(rewind(registrationFile); (registration = ReadRegistration()) != NULL;) {
    (void)GETWORD(expirationImage, registration, &object);
    expiration = atol(expirationImage);
    if((expiration == ETERNAL) || (expiration > now)) {
      object++; /* Skip space after expiration. */
      if(MatchFilter(object, filter)) {
        returnValue =
          REALLOC(returnValue, strlen(returnValue) + strlen(object) + 1);
        strcat(returnValue, object);
      }
    }
  }

  return returnValue;

}
Ejemplo n.º 2
0
void FileListBox::PopulateFileList(const std::string& path)
{
  new_path = path;
  if (path.compare(path.size()-1, sizeof(PATH_SEPARATOR), PATH_SEPARATOR))
    new_path += PATH_SEPARATOR;
  MSG_DEBUG("file", "Searching in %s\n", new_path.c_str());

  FolderSearch *f = OpenFolder(new_path);

  // Now that we have made use of new_path, it can be freed:
  // clearing the list is now possible
  Clear();

  if (f) {
    bool is_file = list_files;
    const char *name;

    while ((name = FolderSearchNext(f, is_file)) != NULL) {
      if (is_file) {
        // We have a file, check that it validates the list
        if (MatchFilter(name)) {
          std::string* filename = new std::string(new_path);
          *filename += name;
          MSG_DEBUG("file", "Adding file %s\n", name);
          AddLabelItem(false, ANSIToUTF8(new_path, name), filename, Font::FONT_MEDIUM);
        } else {
          MSG_DEBUG("file", "NOT adding file %s, invalid extension\n", name);
        }
      } else if (strcmp(name, ".")) {
        std::string* filename;
        if (!strcmp(name, "..")) {
          // Are we at the root?
          if (!strcmp(name, PATH_SEPARATOR))
            break;
          size_t pos = new_path.find_last_of(PATH_SEPARATOR, new_path.size()-2, sizeof(PATH_SEPARATOR));
          filename = new std::string(new_path.substr(0, pos+1));
        } else
          filename = new std::string(new_path);
        *filename += name;
        MSG_DEBUG("file", "Adding directory %s\n", name);
        AddLabelItem(false, std::string("[") + ANSIToUTF8(new_path, name) + "]", filename,
                     Font::FONT_MEDIUM, Font::FONT_NORMAL, c_yellow);
      } else
        MSG_DEBUG("file", "Rejecting %s\n", name);

      // Prepare again for searching files
      is_file = list_files;
    }

    CloseFolder(f);
    Pack();
    NeedRedrawing();
  } else {
    MSG_DEBUG("file", "Search failed?\n");
  }

  // Store last time to drop fast clicks
  last_time = SDL_GetTicks();
}
Ejemplo n.º 3
0
// 一条记录是否符合要求
BOOL CLogViewDlg::MatchFilter(const stLogUIData& info)
{
    std::vector<CString> vctFilter;
    std::vector<CString> vctLevel;
    ThreadOptionData    vctThread;

    m_FilterPanel.GetOptionsText(vctFilter);
    m_LevelPanel.GetOptionsText(vctLevel);
    m_ProcPanel.GetOptionsThread(vctThread);

    return MatchFilter(info, vctFilter, vctLevel, vctThread);
}
Ejemplo n.º 4
0
// 添加一条日志的时候,按照过滤规则进行添加
BOOL CLogViewDlg::AppendLogWithFilter(const stLogUIData& info)
{
    m_vctLogInfo.push_back(info);

    // 是否符合Fileter要求
    if(MatchFilter(info))
    {
        m_LogResult.push_back(m_vctLogInfo.size() - 1);
        DelayUpdateItemCount();
    }

    return TRUE;
}
Ejemplo n.º 5
0
// 每次发生变化的时候,按照用户选择的Filter对日志进行过滤
void CLogViewDlg::DoFilter()
{
    m_LogResult.clear();

    std::vector<CString> vctFilter;
    std::vector<CString>    vctLevel;
    ThreadOptionData     vctThread;

    m_FilterPanel.GetOptionsText(vctFilter);
    m_LevelPanel.GetOptionsText(vctLevel);
    m_ProcPanel.GetOptionsThread(vctThread);

    size_t uTotalLogCount = m_vctLogInfo.size();
    for(size_t i=0; i<uTotalLogCount; ++ i)
    {
        const stLogUIData& info = m_vctLogInfo[i];
        if(MatchFilter(info, vctFilter, vctLevel, vctThread))
        {
            m_LogResult.push_back(i);
        }
    }

    DelayUpdateItemCount();
}
/*
** A "local" function of ProcessRequest().  Searches through the registration
** file for objects that match #filter# and marks them as expired.
*/
static void
DoUnregister(const char *filter) {

  unsigned long expiration;
  char expirationImage[15 + 1];
  unsigned long now;
  const char *object;
  const char *registration;

  now = (unsigned long)CurrentTime();
  for(rewind(registrationFile); (registration = ReadRegistration()) != NULL;) {
    (void)GETWORD(expirationImage, registration, &object);
    expiration = atol(expirationImage);
    if((expiration == ETERNAL) || (expiration > now)) {
      object++; /* Skip space after expiration. */
      if(MatchFilter(object, filter)) {
        fseek(registrationFile, -strlen(registration) - 1, SEEK_CUR);
        fprintf(registrationFile, EXPIRATION_FORMAT, (long)EXPIRED);
        fseek(registrationFile, strlen(registration) + 1, SEEK_CUR);
      }
    }
  }

}