示例#1
0
文件: vdir.c 项目: laochailan/taisei
static void vfs_vdir_iter_stop(VFSNode *vdir, void **opaque) {
	if(*opaque) {
		ht_iter_end((ht_str2ptr_iter_t*)*opaque);
		free(*opaque);
		*opaque = NULL;
	}
}
示例#2
0
static ResultCode cmd_help(void)
{
#ifdef _DEBUG

	// FIXME: There is no way at the moment to access the serial port. Dump
	//  this through JTAG for now
	for (HashIterator iter = ht_iter_begin(&commands);
		!ht_iter_cmp(iter, ht_iter_end(&commands));
		iter = ht_iter_next(iter))
	{
		struct CmdTemplate* cmd = (struct CmdTemplate*)ht_iter_get(iter);
		kprintf("%-20s", cmd->name);
		for (unsigned j = 0; cmd->arg_fmt[j]; ++j)
			kprintf("%c ", 'a' + j);
		kprintf("\r\n");
	}
#endif

	return RC_OK;
}
示例#3
0
文件: vdir.c 项目: laochailan/taisei
static VFSInfo vfs_vdir_query(VFSNode *vdir) {
	return (VFSInfo) {
		.exists = true,
		.is_dir = true,
	};
}

static void vfs_vdir_free(VFSNode *vdir) {
	ht_str2ptr_t *ht = VDIR_TABLE(vdir);
	ht_str2ptr_iter_t iter;

	ht_iter_begin(ht, &iter);

	for(; iter.has_data; ht_iter_next(&iter)) {
		vfs_decref(iter.value);
	}

	ht_iter_end(&iter);
	ht_destroy(ht);
	free(ht);
}
示例#4
0
/// Hook provided by the parser for matching of command names (TAB completion) for readline
const char* parser_rl_match(UNUSED_ARG(void *,dummy), const char *word, int word_len)
{
	HashIterator cur;
	HashIterator end = ht_iter_end(&commands);
	const char *found = NULL;

	for (cur = ht_iter_begin(&commands);
	     !ht_iter_cmp(cur, end);
	     cur = ht_iter_next(cur))
	{
		const struct CmdTemplate* cmdp = (const struct CmdTemplate*)ht_iter_get(cur);
		if (strncmp(cmdp->name, word, word_len) == 0)
		{
			// If there was another matching word, it means that we have a multiple
			//  match: then return NULL.
			if (found)
				return NULL;

			found = cmdp->name;
		}
	}

	return found;
}