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