let each sl_func return an int indicate if sl_loop should return or not
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@2428 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
12
lib/sl/sl.c
12
lib/sl/sl.c
@@ -135,6 +135,7 @@ sl_loop (SL_cmd *cmds, char *prompt)
|
||||
{
|
||||
unsigned max_count;
|
||||
char **ptr;
|
||||
int ret;
|
||||
|
||||
max_count = 17;
|
||||
ptr = malloc(max_count * sizeof(*ptr));
|
||||
@@ -149,6 +150,7 @@ sl_loop (SL_cmd *cmds, char *prompt)
|
||||
unsigned count;
|
||||
SL_cmd *c;
|
||||
|
||||
ret = 0;
|
||||
buf = readline(prompt);
|
||||
if(buf == NULL)
|
||||
break;
|
||||
@@ -178,9 +180,13 @@ sl_loop (SL_cmd *cmds, char *prompt)
|
||||
}
|
||||
if (count > 0) {
|
||||
c = sl_match (cmds, ptr[0], 0);
|
||||
if (c)
|
||||
(*c->func)(count, ptr);
|
||||
else
|
||||
if (c) {
|
||||
ret = (*c->func)(count, ptr);
|
||||
if (ret != 0) {
|
||||
free (buf);
|
||||
break;
|
||||
}
|
||||
} else
|
||||
printf ("Unrecognized command: %s\n", ptr[0]);
|
||||
}
|
||||
free(buf);
|
||||
|
@@ -41,7 +41,7 @@
|
||||
#ifndef _SL_H
|
||||
#define _SL_H
|
||||
|
||||
typedef void (*cmd_func)(int, char **);
|
||||
typedef int (*cmd_func)(int, char **);
|
||||
|
||||
struct sl_cmd {
|
||||
char *name;
|
||||
|
Reference in New Issue
Block a user