@@ -270,6 +270,31 @@ int shell_handle_input_line(const shell_command_t *commands, char *line);
270270int shell_parse_file (const shell_command_t * commands ,
271271 const char * filename , unsigned * line_nr );
272272
273+ /**
274+ * @brief Read a single line from standard input into a buffer.
275+ *
276+ * In addition to copying characters, this routine echoes the line back to
277+ * stdout and also supports primitive line editing.
278+ *
279+ * If the input line is too long, the input will still be consumed until the end
280+ * to prevent the next line from containing garbage.
281+ *
282+ * We allow Unix (`\n`), DOS (`\r\n`), and Mac linebreaks (`\r`).
283+ * QEMU transmits only a single `\r` == 13 on hitting enter ("-serial stdio").
284+ * DOS newlines are handled like hitting enter twice.
285+ *
286+ * @param buf Buffer where the input will be placed.
287+ * @param size Size of the buffer. The maximum line length will be one less
288+ * than size, to accommodate for the null terminator.
289+ * The minimum buffer size is 1.
290+ *
291+ * @return length of the read line, excluding the terminator, if reading was
292+ * successful.
293+ * @return EOF, if the end of the input stream was reached.
294+ * @return -ENOBUFS if the buffer size was exceeded.
295+ */
296+ int readline (char * buf , size_t size );
297+
273298#ifndef __cplusplus
274299/**
275300 * @brief Define shell command
0 commit comments