summaryrefslogtreecommitdiffstats
path: root/client/client.c
diff options
context:
space:
mode:
authorMartin Mares <mj@ucw.cz>2000-02-17 23:00:13 +0100
committerMartin Mares <mj@ucw.cz>2000-02-17 23:00:13 +0100
commit0223d4fff11badc03470b4320fa9dfe28afd1bed (patch)
treeb4281ed75395e0f219c3dc7fb2cc97f6282769db /client/client.c
parentc51f132d582632037b4ef064fbd32d785af245fc (diff)
downloadbird-0223d4fff11badc03470b4320fa9dfe28afd1bed.tar
bird-0223d4fff11badc03470b4320fa9dfe28afd1bed.zip
Client: Online help works (Cisco style: just press `?' at the end of a line).
Diffstat (limited to 'client/client.c')
-rw-r--r--client/client.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/client/client.c b/client/client.c
index 50335e4..b9e3ab8 100644
--- a/client/client.c
+++ b/client/client.c
@@ -91,10 +91,43 @@ got_line(char *cmd_buffer)
free(cmd_buffer);
}
+static int
+input_complete(int arg, int key)
+{
+ ding();
+ return 0;
+}
+
+static int
+input_help(int arg, int key)
+{
+ int i = 0;
+
+ if (rl_point != rl_end || arg != 1)
+ return rl_insert(arg, '?');
+ while (i < rl_end)
+ {
+ if (rl_line_buffer[i++] == '"')
+ do
+ {
+ if (i >= rl_end) /* `?' inside quoted string -> insert */
+ return rl_insert(1, '?');
+ }
+ while (rl_line_buffer[i++] != '"');
+ }
+ puts("?");
+ cmd_help(rl_line_buffer, rl_end);
+ rl_on_new_line();
+ rl_redisplay();
+ return 0;
+}
+
static void
input_init(void)
{
rl_readline_name = "birdc";
+ rl_add_defun("bird-complete", input_complete, '\t');
+ rl_add_defun("bird-help", input_help, '?');
rl_callback_handler_install("bird> ", got_line);
input_initialized = 1;
if (fcntl(0, F_SETFL, O_NONBLOCK) < 0)
@@ -282,6 +315,7 @@ main(int argc, char **argv)
#endif
parse_args(argc, argv);
+ cmd_build_tree();
server_connect();
io_loop(0);