The line handlers of all three users of the i9e API (play, client
and audioc) return immediately if the passed line is NULL or the
empty string. Hence we may call the line handler only if there is a
non-empty line to dispatch.
Moving the check for a non-empty line to generic i9e code simplifies
the three line handlers a bit and avoids code duplication.
{
char *args = NULL;
int ret;
{
char *args = NULL;
int ret;
- if (!line || !*line)
- return 0;
PARA_DEBUG_LOG("line: %s\n", line);
ret = create_argv(line, " ", &conf.inputs);
PARA_DEBUG_LOG("line: %s\n", line);
ret = create_argv(line, " ", &conf.inputs);
int ret;
client_disconnect(ct);
int ret;
client_disconnect(ct);
- if (!line || !*line)
- return 0;
- PARA_DEBUG_LOG("line handler: %s\n", line);
+ PARA_DEBUG_LOG("line: %s\n", line);
ret = make_client_argv(line);
if (ret < 0)
return ret;
ret = make_client_argv(line);
if (ret < 0)
return ret;
static void i9e_line_handler(char *line)
{
int ret;
static void i9e_line_handler(char *line)
{
int ret;
- struct btr_node *dummy = btr_new_node(&(struct btr_node_description)
+ struct btr_node *dummy;
+
+ if (!line) {
+ i9ep->input_eof = true;
+ return;
+ }
+ if (!*line)
+ goto free_line;
+ rl_set_prompt("");
+ dummy = btr_new_node(&(struct btr_node_description)
EMBRACE(.name = "dummy line handler"));
i9e_attach_to_stdout(dummy);
EMBRACE(.name = "dummy line handler"));
i9e_attach_to_stdout(dummy);
ret = i9ep->ici->line_handler(line);
if (ret < 0)
PARA_WARNING_LOG("%s\n", para_strerror(-ret));
ret = i9ep->ici->line_handler(line);
if (ret < 0)
PARA_WARNING_LOG("%s\n", para_strerror(-ret));
- rl_set_prompt("");
- if (line) {
- if (*line)
- add_history(line);
- free(line);
- } else
- i9ep->input_eof = true;
+free_line:
+ free(line);
}
static int i9e_post_select(__a_unused struct sched *s, __a_unused struct task *t)
}
static int i9e_post_select(__a_unused struct sched *s, __a_unused struct task *t)
static int play_i9e_line_handler(char *line)
{
static int play_i9e_line_handler(char *line)
{
- struct play_task *pt = &play_task;
- int ret;
-
- if (line == NULL || !*line)
- return 0;
- ret = run_command(line, pt);
- if (ret < 0)
- return ret;
- return 0;
+ return run_command(line, &play_task);
}
static int play_i9e_key_handler(int key)
}
static int play_i9e_key_handler(int key)