version 1.4, 2002/08/09 02:23:48 |
version 1.5, 2003/10/31 08:47:31 |
|
|
cmdinit(struct clit *cmds, int ncmds) |
cmdinit(struct clit *cmds, int ncmds) |
{ |
{ |
struct clitenv *env; |
struct clitenv *env; |
#ifdef __NetBSD__ |
|
HistEvent ev; |
HistEvent ev; |
#endif |
|
|
|
if ((env = malloc(sizeof(*env))) == NULL) |
if ((env = malloc(sizeof(*env))) == NULL) |
err(1, "Can't init cmd interpreter."); |
err(1, "Can't init cmd interpreter."); |
|
|
env->ncmds = ncmds; |
env->ncmds = ncmds; |
|
|
env->hist = history_init(); |
env->hist = history_init(); |
#ifdef __NetBSD__ |
|
history(env->hist, &ev, H_SETSIZE, 100); |
history(env->hist, &ev, H_SETSIZE, 100); |
#else |
|
history(env->hist, H_EVENT, 100); |
|
#endif |
|
|
|
#ifdef __NetBSD__ |
|
env->el = el_init(__progname, stdin, stdout, stderr); |
env->el = el_init(__progname, stdin, stdout, stderr); |
#else |
|
env->el = el_init(__progname, stdin, stdout); |
|
#endif |
|
el_set(env->el, EL_EDITOR, "emacs"); |
el_set(env->el, EL_EDITOR, "emacs"); |
el_set(env->el, EL_PROMPT, prompt); |
el_set(env->el, EL_PROMPT, prompt); |
el_set(env->el, EL_HIST, history, env->hist); |
el_set(env->el, EL_HIST, history, env->hist); |
|
|
struct clit *cmdp; |
struct clit *cmdp; |
char **ap; |
char **ap; |
int argc, res; |
int argc, res; |
#ifdef __NetBSD__ |
|
HistEvent ev; |
HistEvent ev; |
#endif |
|
|
|
memset(argv, 0, sizeof(char *) * maxargs); |
memset(argv, 0, sizeof(char *) * maxargs); |
|
|
#ifdef __NetBSD__ |
|
history(hist, &ev, H_ENTER, elline); |
history(hist, &ev, H_ENTER, elline); |
#else |
|
history(hist, H_ENTER, elline); |
|
#endif |
|
|
|
orgline = line = strdup(elline); |
orgline = line = strdup(elline); |
if (line == NULL) |
if (line == NULL) |
|
|
/* |
/* |
* Editline commands. |
* Editline commands. |
*/ |
*/ |
if (el_parse(el, argc, argv) != -1) |
if (el_parse(el, argc, (const char **)argv) != -1) |
goto cmdout; |
goto cmdout; |
|
|
if ((res = name_to_cmd(argv[0], env->cmds, env->ncmds, |
if ((res = name_to_cmd(argv[0], env->cmds, env->ncmds, |