iPXE
prompt.h File Reference

Prompt for keypress. More...

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 FILE_SECBOOT (PERMITTED)
int prompt (const char *text, unsigned long timeout, int key)
 Prompt for keypress.

Detailed Description

Prompt for keypress.

Definition in file prompt.h.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )

◆ FILE_SECBOOT()

FILE_SECBOOT ( PERMITTED )

References key, and timeout().

◆ prompt()

int prompt ( const char * text,
unsigned long timeout,
int key )
extern

Prompt for keypress.

Parameters
textPrompt string
timeoutTimeout period, in ticks (0=indefinite)
keyKey to wait for (0=any key)
Return values
rcReturn status code

Returns success if the specified key was pressed within the specified timeout period.

Definition at line 49 of file prompt.c.

49 {
50 int key_pressed;
51
52 /* Display prompt */
53 printf ( "%s", text );
54
55 /* Wait for key */
56 key_pressed = getkey ( timeout );
57
58 /* Clear the prompt line */
59 while ( *(text++) )
60 printf ( "\b \b" );
61
62 /* Check for timeout */
63 if ( key_pressed < 0 )
64 return -ETIMEDOUT;
65
66 /* Check for correct key pressed */
67 if ( key && ( key_pressed != key ) )
68 return -ECANCELED;
69
70 return 0;
71}
union @162305117151260234136356364136041353210355154177 key
Sense key.
Definition scsi.h:3
void timeout(int)
int getkey(unsigned long timeout)
Get single keypress.
Definition getkey.c:72
#define ETIMEDOUT
Connection timed out.
Definition errno.h:670
#define ECANCELED
Operation canceled.
Definition errno.h:344
int printf(const char *fmt,...)
Write a formatted string to the console.
Definition vsprintf.c:465

References ECANCELED, ETIMEDOUT, getkey(), key, printf(), and timeout().

Referenced by COMMAND(), prompt_exec(), readline(), readline_history(), and shell_banner().