iPXE
readline.h
Go to the documentation of this file.
1 #ifndef _READLINE_H
2 #define _READLINE_H
3 
4 /** @file
5  *
6  * Minmal readline
7  *
8  */
9 
10 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11 FILE_SECBOOT ( PERMITTED );
12 
13 /** A readline history entry */
15  /** Persistent copy of string */
16  char *string;
17  /** Temporary copy of string
18  *
19  * The temporary copy exists only during the call to
20  * readline().
21  */
22  char *temp;
23 };
24 
25 /** Maximum depth of a readline history buffer
26  *
27  * Must be one less than a power of two.
28  */
29 #define READLINE_HISTORY_MAX_DEPTH ( ( 1 << 3 ) - 1 )
30 
31 /** A readline history buffer */
33  /** History entries
34  *
35  * This is a circular buffer, with entries in chronological
36  * order. The "next" entry is always empty except during a
37  * call to readline().
38  */
40  /** Position of next entry within buffer
41  *
42  * This is incremented monotonically each time an entry is
43  * added to the buffer.
44  */
45  unsigned int next;
46  /** Current depth within history buffer
47  *
48  * This is valid only during the call to readline()
49  */
50  unsigned int depth;
51 };
52 
53 extern void history_free ( struct readline_history *history );
54 extern int readline_history ( const char *prompt, const char *prefill,
55  struct readline_history *history,
56  unsigned long timeout, char **line );
57 extern char * __malloc readline ( const char *prompt );
58 
59 #endif /* _READLINE_H */
FILE_SECBOOT(PERMITTED)
unsigned int depth
Current depth within history buffer.
Definition: readline.h:50
int readline_history(const char *prompt, const char *prefill, struct readline_history *history, unsigned long timeout, char **line)
Read line from console (with history)
Definition: readline.c:258
struct readline_history_entry entries[READLINE_HISTORY_MAX_DEPTH+1]
History entries.
Definition: readline.h:39
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
char * temp
Temporary copy of string.
Definition: readline.h:22
#define READLINE_HISTORY_MAX_DEPTH
Maximum depth of a readline history buffer.
Definition: readline.h:29
char *__malloc readline(const char *prompt)
Read line from console.
Definition: readline.c:350
void history_free(struct readline_history *history)
Free history buffer.
Definition: readline.c:232
unsigned int next
Position of next entry within buffer.
Definition: readline.h:45
A readline history buffer.
Definition: readline.h:32
int prompt(const char *text, unsigned long timeout, int key)
Prompt for keypress.
Definition: prompt.c:49
char * string
Persistent copy of string.
Definition: readline.h:16
#define __malloc
Declare a pointer returned by a function as a unique memory address as returned by malloc-type functi...
Definition: compiler.h:598
void timeout(int)
A readline history entry.
Definition: readline.h:14