Exemple #1
0
void KEdit::search(){

  if( replace_dialog && replace_dialog->isVisible() )
  {
    replace_dialog->hide();
  }

  if( !srchdialog )
  {
    srchdialog = new KEdFind( this, "searchdialog", false);
    connect(srchdialog,SIGNAL(search()),this,SLOT(search_slot()));
    connect(srchdialog,SIGNAL(done()),this,SLOT(searchdone_slot()));
  }

  // If we already searched / replaced something before make sure it shows
  // up in the find dialog line-edit.

  QString string;
  string = srchdialog->getText();
  srchdialog->setText(string.isEmpty() ? pattern : string);

  deselect();
  last_search = NONE;

  srchdialog->show();
  srchdialog->result();
}
Exemple #2
0
/* gets the lowest free inode, or 0 if errno.
 * (inode 0 is the root dir, which is never free)
 * not concerned with optimizations at this point in the project.
 */
PUBLIC uint32_t find_free_inode(struct fs_info *fsi) {
	struct key first;
	struct key *key;
	struct path p;
	uint32_t prev_inode;
	int ret;

	set_inode_key(0, &first);
	ret = search_slot(&fsi->fs_root, &first, &p, 0);
	if (ret < 0) {
		errno = -ret;
		return 0;
	}
	key = key_for(p.nodes[0], p.slots[0]);
	while (TRUE) {
		prev_inode = key->objectid;
		ret = step_to_next_slot(&p);
		if (ret < 0) {
			errno = -ret;
			return 0;
		}
		if (ret == KEY_NOT_FOUND) {	/* no more items, and no path to free */
			return prev_inode + 1;
		}
		assert(ret == SUCCESS);
		key = key_for(p.nodes[0], p.slots[0]);
		if (key->objectid - prev_inode > 1) {
			free_path(&p);
			return prev_inode + 1;
		}
	}
}
bool inline dhash_search(dhash_tbl_pt table,_key_t key,elem_t* out_elem){
	ulong tmp;
	slot_pt *p_slot;
	if(!search_slot(table,key,&tmp,&p_slot)){
		return false;
	}
	*out_elem=(*p_slot)->satellite;
	return true;
}
Exemple #4
0
void TextShow::search(){

    if( srchdialog == 0 )
    {
        srchdialog = new KEdFind( this, "searchdialog", false);
        connect(srchdialog,SIGNAL(search()),this,SLOT(search_slot()));
        connect(srchdialog,SIGNAL(done()),this,SLOT(searchdone_slot()));
    }
    srchdialog->show();
    srchdialog->result();
}
Exemple #5
0
/* inserts an empty item into the tree at the given key.
 * (This function's signature is modeled after the one in Btrfs.)
 * r - the root of the tree to insert into
 * key - the key to insert
 * p - path result prepared
 * ins_len - number of bytes needed for the item and its metadata in leaf.
 * returns 0 if inserted, or a negative errno.
 */
PUBLIC int insert_empty_item(struct root *r, struct key *key, struct path *p,
						int ins_len) {
	int ret;
	ret = search_slot(r, key, p, ins_len);
	if (ret == KEY_FOUND) {
		free_path(p);
		return -EEXIST;
	}
	if (ret != KEY_NOT_FOUND) return ret;
	return insert_item_in_leaf(r, p, key, ins_len);
}
Exemple #6
0
void Gutenbrowser::Search() {
    odebug << "Starting search dialog" << oendl;
    searchDlg = new SearchDialog( this, "Etext Search", true);
    searchDlg->setCaption( tr( "Etext Search" ));
    connect( searchDlg,SIGNAL( search_signal()),this,SLOT( search_slot()));
    connect( searchDlg,SIGNAL( search_done_signal()),this,SLOT( searchdone_slot()));

    QString resultString;
    QString string = searchDlg->searchString;
    Lview->deselect();
    searchDlg->show();
}
bool dhash_insert(dhash_tbl_pt table,_key_t key,elem_t satellite){
	ulong hashcode;
	slot_pt* p_slot;
	slot_pt newslot;
	if(search_slot(table,key,&hashcode,&p_slot)){
		return false;
	}
	newslot=new_slot_no_calculate(key,hashcode,satellite);
	newslot->next=*p_slot;
	*p_slot=newslot;
	table->count++;
	return true;
}
Exemple #8
0
bool KEdit::repeatSearch() {

  if(!srchdialog || pattern.isEmpty())
  {
      search();
      return true;
  }

  search_slot();

  setFocus();
  return true;

}
elem_t dhash_delete(dhash_tbl_pt table,_key_t key){
	ulong tmp;
	elem_t elem=NIL;
	slot_pt* p_slot;
	slot_pt del;
	if(!search_slot(table,key,&tmp,&p_slot)){
		return NIL;
	}
	del=*p_slot;
	elem=del->satellite;
	*p_slot=del->next;	//or:*p_slot=*p_slot->next;
	free(del);
	table->count--;
	return elem;
}
Exemple #10
0
PUBLIC int get_inode_metadata(struct fs_info *fsi, uint32_t inode,
								struct inode_metadata *imd) {
	struct path p;
	struct key key;
	int ret;

	set_inode_key(inode, &key);
	ret = search_slot(&fsi->fs_root, &key, &p, 0);
	if (ret == KEY_NOT_FOUND) ret = -ENOENT;
	if (ret == KEY_FOUND) {
		memmove(imd, metadata_for(&p), sizeof(*imd));
	}
	if (ret == KEY_FOUND || ret == KEY_NOT_FOUND) {
		free_path(&p);
	}
	assert(KEY_FOUND == SUCCESS);
	return ret;
}
Exemple #11
0
/* gets the inode of a directory entry, or 0 if errno.
 * (inode 0 is the root dir, which is not an entry in any dir)
 */
PUBLIC uint32_t get_dir_ent_inode(struct fs_info *fsi, uint32_t dir_inode,
									char *name) {
	struct path p;
	struct key key;
	struct dir_ent_metadata *demd;
	int ret;

	set_dir_ent_key(dir_inode, name, &key);
	ret = search_slot(&fsi->fs_root, &key, &p, 0);
	if (ret == KEY_NOT_FOUND) {
		free_path(&p);	/* only for search_slot(), not step_to_next_slot() */
	}
	while (TRUE) {
		if (ret == KEY_NOT_FOUND) {
			errno = ENOENT;
		}
		if (ret < 0) {
			errno = -ret;
		}
		if (ret != KEY_FOUND) {
			return 0;	/* failure, with errno */
		}
		demd = (struct dir_ent_metadata *) metadata_for(&p);
		if (!strcmp(name, demd->name)) {	/* name matches */
			ret = demd->inode;
			free_path(&p);
			return ret;
		}
		ret = step_to_next_slot(&p);
		if (ret == KEY_FOUND && compare_keys(&key, item_key(&p))) {
			errno = ENOENT;
			free_path(&p);
			return 0;	/* failure, with errno */
		}
	}
}
Exemple #12
0
void TextShow::repeatSearch()
{
    if(!srchdialog) return;
    search_slot();
    setFocus();
}
Exemple #13
0
PUBLIC int insert_empty_item_allowing_duplicates(struct root *r,
						struct key *key, struct path *p, int ins_len) {
	int ret = search_slot(r, key, p, ins_len);
	if (ret < 0) return ret;
	return insert_item_in_leaf(r, p, key, ins_len);
}
bool inline dhash_exist(dhash_tbl_pt table,_key_t key){
	ulong tmp1;
	slot_pt *tmp2;
	return search_slot(table,key,&tmp1,&tmp2);
}