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:
Assar Westerlund
1997-07-18 01:04:57 +00:00
parent 9e42607eaa
commit 4381cacb0e
2 changed files with 10 additions and 4 deletions

View File

@@ -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);

View File

@@ -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;