NULL, &setting->setting, &existing );
/* Read new value */
- if ( ( rc = readline_history ( NULL, existing, NULL, value ) ) != 0 )
+ if ( ( rc = readline_history ( NULL, existing, NULL, 0, value ) ) != 0 )
goto err_readline;
err_readline:
* @v prompt Prompt string
* @v prefill Prefill string, or NULL for no prefill
* @v history History buffer, or NULL for no history
+ * @v timeout Timeout period, in ticks (0=indefinite)
* @ret line Line read from console (excluding terminating newline)
* @ret rc Return status code
*
* eventually call free() to release the storage.
*/
int readline_history ( const char *prompt, const char *prefill,
- struct readline_history *history, char **line ) {
+ struct readline_history *history, unsigned long timeout,
+ char **line ) {
char buf[READLINE_MAX];
struct edit_string string;
int key;
}
while ( 1 ) {
+
+ /* Get keypress */
+ key = getkey ( timeout );
+ if ( key < 0 ) {
+ rc = -ETIMEDOUT;
+ goto done;
+ }
+ timeout = 0;
+
/* Handle keypress */
- key = edit_string ( &string, getkey ( 0 ) );
+ key = edit_string ( &string, key );
sync_console ( &string );
move_by = 0;
switch ( key ) {
char * readline ( const char *prompt ) {
char *line;
- readline_history ( prompt, NULL, NULL, &line );
+ readline_history ( prompt, NULL, NULL, 0, &line );
return line;
}
/* Read and execute commands */
do {
- readline_history ( shell_prompt, NULL, &history, &line );
+ readline_history ( shell_prompt, NULL, &history, 0, &line );
if ( line ) {
rc = system ( line );
free ( line );
extern void history_free ( struct readline_history *history );
extern int readline_history ( const char *prompt, const char *prefill,
- struct readline_history *history, char **line );
+ struct readline_history *history,
+ unsigned long timeout, char **line );
extern char * __malloc readline ( const char *prompt );
#endif /* _READLINE_H */