diff options
author | Simon Glass <sjg@chromium.org> | 2023-10-01 19:13:13 -0600 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2023-10-11 15:43:54 -0400 |
commit | e5509ce87b29f773b045200735bec2903b72eed4 (patch) | |
tree | 3f3255299b7ebcd526701159bde7a4350ea1fca4 /include/cli.h | |
parent | 8d997aab6e231aa3b442ffe504b24709ff9c7c19 (diff) | |
download | u-boot-e5509ce87b29f773b045200735bec2903b72eed4.zip u-boot-e5509ce87b29f773b045200735bec2903b72eed4.tar.gz u-boot-e5509ce87b29f773b045200735bec2903b72eed4.tar.bz2 |
cli: Create a function to process characters
Move most of the inner loop from cread_line() into a new function. This
will allow using it from other code.
This involves adding a few more members to the state struct.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'include/cli.h')
-rw-r--r-- | include/cli.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/include/cli.h b/include/cli.h index 1bc1ab8..bbc5327 100644 --- a/include/cli.h +++ b/include/cli.h @@ -31,11 +31,16 @@ struct cli_ch_state { * @num: Current cursor position, where 0 is the start * @eol_num: Number of characters in the buffer * @insert: true if in 'insert' mode + * @buf: Buffer containing line + * @prompt: Prompt for the line */ struct cli_line_state { uint num; uint eol_num; + uint len; bool insert; + char *buf; + const char *prompt; }; /** @@ -243,6 +248,16 @@ void cli_ch_init(struct cli_ch_state *cch); */ int cli_ch_process(struct cli_ch_state *cch, int ichar); +/** + * cread_line_process_ch() - Process a character for line input + * + * @cls: CLI line state + * @ichar: Character to process + * Return: 0 if input is complete, with line in cls->buf, -EINTR if input was + * cancelled with Ctrl-C, -EAGAIN if more characters are needed + */ +int cread_line_process_ch(struct cli_line_state *cls, char ichar); + /** cread_print_hist_list() - Print the command-line history list */ void cread_print_hist_list(void); |