static command_def_t *get_cmd(char *name)
{
const char *p;
command_def_t *c, *res = (command_def_t *)NULL;
int len = strlen(name);
int n = 0;
for (c = commands; (p = c->cmd) != NULL; c++)
{
//非交互命令,过滤非比较对象
if ((c->type != MAIN_COM) && (c->type != block_type) &&
(c->type != UNDEF_COM))
{
continue;
}
//比较对象与 name
if (strncmp(p, name, len) == 0)
{
if (n == 0) {res = c};
n++;
};
//
if (strcmp(p, name) == 0)
{
return(c);
}
};
if (n == 1) return(res);
return((command_def_t *)NULL);
}
阅读(1618) | 评论(0) | 转发(0) |