summaryrefslogtreecommitdiffstats
path: root/qemu/roms/ipxe/src/include/readline/readline.h
blob: afafbbdf56febd51ad6034e9e8308c39f979d58b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#ifndef _READLINE_H
#define _READLINE_H

/** @file
 *
 * Minmal readline
 *
 */

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );

/** A readline history entry */
struct readline_history_entry {
	/** Persistent copy of string */
	char *string;
	/** Temporary copy of string
	 *
	 * The temporary copy exists only during the call to
	 * readline().
	 */
	char *temp;
};

/** Maximum depth of a readline history buffer
 *
 * Must be one less than a power of two.
 */
#define READLINE_HISTORY_MAX_DEPTH ( ( 1 << 3 ) - 1 )

/** A readline history buffer */
struct readline_history {
	/** History entries
	 *
	 * This is a circular buffer, with entries in chronological
	 * order.  The "next" entry is always empty except during a
	 * call to readline().
	 */
	struct readline_history_entry entries[READLINE_HISTORY_MAX_DEPTH + 1];
	/** Position of next entry within buffer
	 *
	 * This is incremented monotonically each time an entry is
	 * added to the buffer.
	 */
	unsigned int next;
	/** Current depth within history buffer
	 *
	 * This is valid only during the call to readline()
	 */
	unsigned int depth;
};

extern void history_free ( struct readline_history *history );
extern int readline_history ( const char *prompt, const char *prefill,
			      struct readline_history *history, char **line );
extern char * __malloc readline ( const char *prompt );

#endif /* _READLINE_H */