iPXE
readline.h
Go to the documentation of this file.
00001 #ifndef _READLINE_H
00002 #define _READLINE_H
00003 
00004 /** @file
00005  *
00006  * Minmal readline
00007  *
00008  */
00009 
00010 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
00011 
00012 /** A readline history entry */
00013 struct readline_history_entry {
00014         /** Persistent copy of string */
00015         char *string;
00016         /** Temporary copy of string
00017          *
00018          * The temporary copy exists only during the call to
00019          * readline().
00020          */
00021         char *temp;
00022 };
00023 
00024 /** Maximum depth of a readline history buffer
00025  *
00026  * Must be one less than a power of two.
00027  */
00028 #define READLINE_HISTORY_MAX_DEPTH ( ( 1 << 3 ) - 1 )
00029 
00030 /** A readline history buffer */
00031 struct readline_history {
00032         /** History entries
00033          *
00034          * This is a circular buffer, with entries in chronological
00035          * order.  The "next" entry is always empty except during a
00036          * call to readline().
00037          */
00038         struct readline_history_entry entries[READLINE_HISTORY_MAX_DEPTH + 1];
00039         /** Position of next entry within buffer
00040          *
00041          * This is incremented monotonically each time an entry is
00042          * added to the buffer.
00043          */
00044         unsigned int next;
00045         /** Current depth within history buffer
00046          *
00047          * This is valid only during the call to readline()
00048          */
00049         unsigned int depth;
00050 };
00051 
00052 extern void history_free ( struct readline_history *history );
00053 extern int readline_history ( const char *prompt, const char *prefill,
00054                               struct readline_history *history, char **line );
00055 extern char * __malloc readline ( const char *prompt );
00056 
00057 #endif /* _READLINE_H */