mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-24 14:03:55 +01:00
Merge pull request #21505 from derMihai/mir/export_readline
sys/shell: expose readline()
This commit is contained in:
commit
584e14bfce
@ -270,6 +270,31 @@ int shell_handle_input_line(const shell_command_t *commands, char *line);
|
||||
int shell_parse_file(const shell_command_t *commands,
|
||||
const char *filename, unsigned *line_nr);
|
||||
|
||||
/**
|
||||
* @brief Read a single line from standard input into a buffer.
|
||||
*
|
||||
* In addition to copying characters, this routine echoes the line back to
|
||||
* stdout and also supports primitive line editing.
|
||||
*
|
||||
* If the input line is too long, the input will still be consumed until the end
|
||||
* to prevent the next line from containing garbage.
|
||||
*
|
||||
* We allow Unix (`\n`), DOS (`\r\n`), and Mac linebreaks (`\r`).
|
||||
* QEMU transmits only a single `\r` == 13 on hitting enter ("-serial stdio").
|
||||
* DOS newlines are handled like hitting enter twice.
|
||||
*
|
||||
* @param buf Buffer where the input will be placed.
|
||||
* @param size Size of the buffer. The maximum line length will be one less
|
||||
* than size, to accommodate for the null terminator.
|
||||
* The minimum buffer size is 1.
|
||||
*
|
||||
* @return length of the read line, excluding the terminator, if reading was
|
||||
* successful.
|
||||
* @return EOF, if the end of the input stream was reached.
|
||||
* @return -ENOBUFS if the buffer size was exceeded.
|
||||
*/
|
||||
int readline(char *buf, size_t size);
|
||||
|
||||
#ifndef __cplusplus
|
||||
/**
|
||||
* @brief Define shell command
|
||||
|
||||
@ -439,30 +439,7 @@ static inline void new_line(void)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Read a single line from standard input into a buffer.
|
||||
*
|
||||
* In addition to copying characters, this routine echoes the line back to
|
||||
* stdout and also supports primitive line editing.
|
||||
*
|
||||
* If the input line is too long, the input will still be consumed until the end
|
||||
* to prevent the next line from containing garbage.
|
||||
*
|
||||
* We allow Unix (\n), DOS (\r\n), and Mac linebreaks (\r).
|
||||
* QEMU transmits only a single '\r' == 13 on hitting enter ("-serial stdio").
|
||||
* DOS newlines are handled like hitting enter twice.
|
||||
*
|
||||
* @param buf Buffer where the input will be placed.
|
||||
* @param size Size of the buffer. The maximum line length will be one less
|
||||
* than size, to accommodate for the null terminator.
|
||||
* The minimum buffer size is 1.
|
||||
*
|
||||
* @return length of the read line, excluding the terminator, if reading was
|
||||
* successful.
|
||||
* @return EOF, if the end of the input stream was reached.
|
||||
* @return -ENOBUFS if the buffer size was exceeded.
|
||||
*/
|
||||
int readline(char *buf, size_t size) /* needed externally by module shell_lock */
|
||||
int readline(char *buf, size_t size)
|
||||
{
|
||||
int curr_pos = 0;
|
||||
bool length_exceeded = false;
|
||||
|
||||
@ -52,9 +52,6 @@ static bool _shell_is_locked = true;
|
||||
static ztimer_t _shell_auto_lock_ztimer;
|
||||
#endif
|
||||
|
||||
/* defined in shell.c */
|
||||
extern int readline(char *buf, size_t size);
|
||||
|
||||
static int _lock_handler(int argc, char **argv)
|
||||
{
|
||||
(void) argc;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user