]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
edit: Add support for prompt string with readline
authorJouni Malinen <j@w1.fi>
Sun, 5 Aug 2012 17:48:54 +0000 (20:48 +0300)
committerJouni Malinen <j@w1.fi>
Sun, 5 Aug 2012 17:48:54 +0000 (20:48 +0300)
Signed-hostap: Jouni Malinen <j@w1.fi>

src/utils/edit_readline.c

index 9c27d7269441ba385ff9e8eec750ec60219b51de..9a6f642cd98dab1ca3ffa262486958a321e44bae 100644 (file)
@@ -127,6 +127,17 @@ int edit_init(void (*cmd_cb)(void *ctx, char *cmd),
 
        eloop_register_read_sock(STDIN_FILENO, edit_read_char, NULL, NULL);
 
+       if (ps) {
+               size_t blen = os_strlen(ps) + 3;
+               char *ps2 = os_malloc(blen);
+               if (ps2) {
+                       os_snprintf(ps2, blen, "%s> ", ps);
+                       rl_callback_handler_install(ps2, readline_cmd_handler);
+                       os_free(ps2);
+                       return 0;
+               }
+       }
+
        rl_callback_handler_install("> ", readline_cmd_handler);
 
        return 0;