/* directory callback */ static int dircb(wagon_t * id_list, attr_set_t * attr_list, unsigned int entry_count, void * dummy ) { /* retrieve child entries for all directories */ int i, rc; for (i = 0; i < entry_count; i++) { wagon_t * chids = NULL; attr_set_t * chattrs = NULL; unsigned int chcount = 0; int j; /* match condition on dirs parent */ if (!is_expr || (EntryMatches(&id_list[i].id, &attr_list[i], &match_expr, NULL) == POLICY_MATCH)) { /* don't display dirs if no_dir is specified */ if (! (prog_options.no_dir && ATTR_MASK_TEST(&attr_list[i], type) && !strcasecmp(ATTR(&attr_list[i], type), STR_TYPE_DIR)) ) print_entry(&id_list[i], &attr_list[i]); } if (!prog_options.dir_only) { rc = ListMgr_GetChild( &lmgr, &entry_filter, id_list+i, 1, disp_mask | query_mask, &chids, &chattrs, &chcount); if (rc) { DisplayLog(LVL_MAJOR, FIND_TAG, "ListMgr_GetChild() failed with error %d", rc); return rc; } for (j = 0; j < chcount; j++) { if (!is_expr || (EntryMatches(&chids[j].id, &chattrs[j], &match_expr, NULL) == POLICY_MATCH)) print_entry(&chids[j], &chattrs[j]); ListMgr_FreeAttrs(&chattrs[j]); } free_wagon(chids, 0, chcount); MemFree(chids); MemFree(chattrs); } } return 0; }
/** * Bulk filtering in the DB. */ static int list_bulk(void) { attr_set_t root_attrs, attrs; entry_id_t root_id, id; int rc; struct stat st; struct lmgr_iterator_t *it; /* no tranvsersal => no wagon * so we need the path from the DB. */ query_mask |= ATTR_MASK_fullpath; ATTR_MASK_INIT(&root_attrs); rc = retrieve_root_id(&root_id); if (rc) return rc; /* root is not a part of the DB: print it now */ ATTR_MASK_SET(&root_attrs, fullpath); strcpy(ATTR(&root_attrs, fullpath), config.global_config.fs_path); if (lstat(ATTR(&root_attrs, fullpath), &st) == 0) { PosixStat2EntryAttr(&st, &root_attrs, TRUE); ListMgr_GenerateFields(&root_attrs, disp_mask | query_mask); } /* root has no name... */ ATTR_MASK_SET(&root_attrs, name); ATTR(&root_attrs, name)[0] = '\0'; /* match condition on dirs parent */ if (!is_expr || (EntryMatches(&root_id, &root_attrs, &match_expr, NULL) == POLICY_MATCH)) { /* don't display dirs if no_dir is specified */ if (! (prog_options.no_dir && ATTR_MASK_TEST(&root_attrs, type) && !strcasecmp(ATTR(&root_attrs, type), STR_TYPE_DIR))) { wagon_t w; w.id = root_id; w.fullname = ATTR(&root_attrs, fullpath); print_entry(&w, &root_attrs); } } /* list all, including dirs */ it = ListMgr_Iterator(&lmgr, &entry_filter, NULL, NULL); if (!it) { DisplayLog(LVL_MAJOR, FIND_TAG, "ERROR: cannot retrieve entry list from database"); return -1; } attrs.attr_mask = disp_mask | query_mask; while ((rc = ListMgr_GetNext(it, &id, &attrs)) == DB_SUCCESS) { if (!is_expr || (EntryMatches(&id, &attrs, &match_expr, NULL) == POLICY_MATCH)) { /* don't display dirs if no_dir is specified */ if (! (prog_options.no_dir && ATTR_MASK_TEST(&attrs, type) && !strcasecmp(ATTR(&attrs, type), STR_TYPE_DIR))) { wagon_t w; w.id = id; w.fullname = ATTR(&attrs, fullpath); print_entry(&w, &attrs); } /* don't display non dirs is dir_only is specified */ else if (! (prog_options.dir_only && ATTR_MASK_TEST(&attrs, type) && strcasecmp(ATTR(&attrs, type), STR_TYPE_DIR))) { wagon_t w; w.id = id; w.fullname = ATTR(&attrs, fullpath); print_entry(&w, &attrs); } else /* return entry don't match? */ DisplayLog(LVL_DEBUG, FIND_TAG, "Warning: returned DB entry doesn't match filter: %s", ATTR(&attrs, fullpath)); } ListMgr_FreeAttrs(&attrs); /* prepare next call */ attrs.attr_mask = disp_mask | query_mask; } ListMgr_CloseIterator(it); return 0; }
BOOL CTableFormatRule::RuleMatches(CPoint cpCell, CPoint cpMax) const { return EntryMatches(m_nColumn, cpCell.x, cpMax.x) && EntryMatches(m_nRow, cpCell.y, cpMax.y); }