]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
edit: Add support for setting prompt string
authorJanusz Dziedzic <janusz.dziedzic@tieto.com>
Sun, 5 Aug 2012 17:46:34 +0000 (20:46 +0300)
committerJouni Malinen <j@w1.fi>
Sun, 5 Aug 2012 17:46:34 +0000 (20:46 +0300)
Signed-hostap: Janusz Dziedzic <janusz.dziedzic@tieto.com>

hostapd/hostapd_cli.c
src/utils/edit.c
src/utils/edit.h
src/utils/edit_readline.c
src/utils/edit_simple.c
wlantest/wlantest_cli.c
wpa_supplicant/wpa_cli.c

index 0c33d5bc6864c6489f39840e06ece02d9b0f113e..cca488ffa083f65276ed915e815a59574d345e96 100644 (file)
@@ -977,7 +977,7 @@ static void hostapd_cli_interactive(void)
 
        eloop_register_signal_terminate(hostapd_cli_eloop_terminate, NULL);
        edit_init(hostapd_cli_edit_cmd_cb, hostapd_cli_edit_eof_cb,
-                 NULL, NULL, NULL);
+                 NULL, NULL, NULL, NULL);
        eloop_register_timeout(ping_interval, 0, hostapd_cli_ping, NULL, NULL);
 
        eloop_run();
index 280d244748e2d2568ab12104746ab0bed36c3c18..4ccef21aab0a1f3007ee336886454ab3df2fd395 100644 (file)
@@ -1112,7 +1112,7 @@ static void edit_read_char(int sock, void *eloop_ctx, void *sock_ctx)
 int edit_init(void (*cmd_cb)(void *ctx, char *cmd),
              void (*eof_cb)(void *ctx),
              char ** (*completion_cb)(void *ctx, const char *cmd, int pos),
-             void *ctx, const char *history_file)
+             void *ctx, const char *history_file, const char *ps)
 {
        currbuf[0] = '\0';
        dl_list_init(&history_list);
index e8d04e7fa564e406e4ee48881781aa483e451a7e..ad27f1c7a4adaf69df976357f398ebd1ca91d782 100644 (file)
@@ -12,7 +12,7 @@
 int edit_init(void (*cmd_cb)(void *ctx, char *cmd),
              void (*eof_cb)(void *ctx),
              char ** (*completion_cb)(void *ctx, const char *cmd, int pos),
-             void *ctx, const char *history_file);
+             void *ctx, const char *history_file, const char *ps);
 void edit_deinit(const char *history_file,
                 int (*filter_cb)(void *ctx, const char *cmd));
 void edit_clear_line(void);
index c9ff0e6dc24ed9274e1f227bf7beb0da841a00e4..9c27d7269441ba385ff9e8eec750ec60219b51de 100644 (file)
@@ -112,7 +112,7 @@ static void readline_cmd_handler(char *cmd)
 int edit_init(void (*cmd_cb)(void *ctx, char *cmd),
              void (*eof_cb)(void *ctx),
              char ** (*completion_cb)(void *ctx, const char *cmd, int pos),
-             void *ctx, const char *history_file)
+             void *ctx, const char *history_file, const char *ps)
 {
        edit_cb_ctx = ctx;
        edit_cmd_cb = cmd_cb;
index 0e3637cbb5ef1cbcb1df8178af4dacd078ae3b97..a095ea6abec5a3d711e138b69d22e86eb7426596 100644 (file)
@@ -16,6 +16,7 @@
 #define CMD_BUF_LEN 256
 static char cmdbuf[CMD_BUF_LEN];
 static int cmdbuf_pos = 0;
+static const char *ps2 = NULL;
 
 static void *edit_cb_ctx;
 static void (*edit_cmd_cb)(void *ctx, char *cmd);
@@ -41,7 +42,7 @@ static void edit_read_char(int sock, void *eloop_ctx, void *sock_ctx)
                cmdbuf[cmdbuf_pos] = '\0';
                cmdbuf_pos = 0;
                edit_cmd_cb(edit_cb_ctx, cmdbuf);
-               printf("");
+               printf("%s> ", ps2 ? ps2 : "");
                fflush(stdout);
                return;
        }
@@ -57,14 +58,15 @@ static void edit_read_char(int sock, void *eloop_ctx, void *sock_ctx)
 int edit_init(void (*cmd_cb)(void *ctx, char *cmd),
              void (*eof_cb)(void *ctx),
              char ** (*completion_cb)(void *ctx, const char *cmd, int pos),
-             void *ctx, const char *history_file)
+             void *ctx, const char *history_file, const char *ps)
 {
        edit_cb_ctx = ctx;
        edit_cmd_cb = cmd_cb;
        edit_eof_cb = eof_cb;
        eloop_register_read_sock(STDIN_FILENO, edit_read_char, NULL, NULL);
+       ps2 = ps;
 
-       printf("");
+       printf("%s> ", ps2 ? ps2 : "");
        fflush(stdout);
 
        return 0;
index ce95081ca5eab8c64f388e2ae3d79e0b18cf2e43..a417b3ccec821bf61346b183b3503b69e5a0ca05 100644 (file)
@@ -1663,7 +1663,7 @@ static void wlantest_cli_interactive(int s)
        cli.s = s;
        eloop_register_signal_terminate(wlantest_cli_eloop_terminate, &cli);
        edit_init(wlantest_cli_edit_cmd_cb, wlantest_cli_edit_eof_cb,
-                 wlantest_cli_edit_completion_cb, &cli, hfile);
+                 wlantest_cli_edit_completion_cb, &cli, hfile, NULL);
 
        eloop_run();
 
index 880aa1381ca7a0bc33485de70b91e7f1695bc436..21f473f89cde1018614e63200f10af6bd0e12517 100644 (file)
@@ -3820,7 +3820,7 @@ static void wpa_cli_interactive(void)
 
        eloop_register_signal_terminate(wpa_cli_eloop_terminate, NULL);
        edit_init(wpa_cli_edit_cmd_cb, wpa_cli_edit_eof_cb,
-                 wpa_cli_edit_completion_cb, NULL, hfile);
+                 wpa_cli_edit_completion_cb, NULL, hfile, NULL);
        eloop_register_timeout(ping_interval, 0, wpa_cli_ping, NULL, NULL);
 
        eloop_run();