summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorPatrik Flykt <patrik.flykt@linux.intel.com>2013-05-06 13:28:32 +0300
committerPatrik Flykt <patrik.flykt@linux.intel.com>2013-05-06 13:45:18 +0300
commitae4bb4a283a508b493818d605459090b8ec11c8a (patch)
tree211bd554ddfb25ad74734b1610af2fdfb72e8335 /client
parentd66d5e118a2c790422d4e08a79f207b28bfbe355 (diff)
downloadconnman-ae4bb4a283a508b493818d605459090b8ec11c8a.tar.gz
connman-ae4bb4a283a508b493818d605459090b8ec11c8a.tar.bz2
connman-ae4bb4a283a508b493818d605459090b8ec11c8a.zip
client: Fix for handling an unset callback
If there is no callback set, don't try to call readline function.
Diffstat (limited to 'client')
-rw-r--r--client/input.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/client/input.c b/client/input.c
index 2e9621f2..a6eb1366 100644
--- a/client/input.c
+++ b/client/input.c
@@ -43,6 +43,8 @@ static bool save_input;
static char *saved_line;
static int saved_point;
+static connmanctl_input_func_t *readline_input_handler;
+
void __connmanctl_quit(void)
{
if (main_loop != NULL)
@@ -124,7 +126,8 @@ static gboolean input_handler(GIOChannel *channel, GIOCondition condition,
return FALSE;
}
- rl_callback_read_char();
+ if (readline_input_handler != NULL)
+ rl_callback_read_char();
return TRUE;
}
@@ -151,17 +154,22 @@ static char **complete_command(const char *text, int start, int end)
void __connmanctl_agent_mode(const char *prompt,
connmanctl_input_func_t input_handler)
{
+ readline_input_handler = input_handler;
+
if (input_handler != NULL)
rl_callback_handler_install(prompt, input_handler);
else {
rl_set_prompt(prompt);
rl_callback_handler_remove();
+ rl_redisplay();
}
rl_attempted_completion_function = complete_agent;
}
void __connmanctl_command_mode(void)
{
+ readline_input_handler = rl_handler;
+
rl_callback_handler_install("connmanctl> ", rl_handler);
rl_attempted_completion_function = complete_command;
}