summaryrefslogtreecommitdiffstats
path: root/src/include/readline
diff options
context:
space:
mode:
authorMichael Brown2011-03-29 19:00:30 +0200
committerMichael Brown2011-03-30 20:43:14 +0200
commit5a064dd2c4330cae7a83aa94049bd2b649f4a71c (patch)
tree46dd9e72558b4d9d66b9b4ff33f73259efd45538 /src/include/readline
parent[readline] Add replace_string() (diff)
downloadipxe-5a064dd2c4330cae7a83aa94049bd2b649f4a71c.tar.gz
ipxe-5a064dd2c4330cae7a83aa94049bd2b649f4a71c.tar.xz
ipxe-5a064dd2c4330cae7a83aa94049bd2b649f4a71c.zip
[readline] Add history support
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/include/readline')
-rw-r--r--src/include/readline/readline.h43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/include/readline/readline.h b/src/include/readline/readline.h
index 700b7aa2..42dfd8c4 100644
--- a/src/include/readline/readline.h
+++ b/src/include/readline/readline.h
@@ -9,6 +9,49 @@
FILE_LICENCE ( GPL2_OR_LATER );
+/** 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 char * __malloc readline_history ( const char *prompt,
+ struct readline_history *history );
extern char * __malloc readline ( const char *prompt );
#endif /* _READLINE_H */