You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

readline.h 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #ifndef _READLINE_H
  2. #define _READLINE_H
  3. /** @file
  4. *
  5. * Minmal readline
  6. *
  7. */
  8. FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
  9. /** A readline history entry */
  10. struct readline_history_entry {
  11. /** Persistent copy of string */
  12. char *string;
  13. /** Temporary copy of string
  14. *
  15. * The temporary copy exists only during the call to
  16. * readline().
  17. */
  18. char *temp;
  19. };
  20. /** Maximum depth of a readline history buffer
  21. *
  22. * Must be one less than a power of two.
  23. */
  24. #define READLINE_HISTORY_MAX_DEPTH ( ( 1 << 3 ) - 1 )
  25. /** A readline history buffer */
  26. struct readline_history {
  27. /** History entries
  28. *
  29. * This is a circular buffer, with entries in chronological
  30. * order. The "next" entry is always empty except during a
  31. * call to readline().
  32. */
  33. struct readline_history_entry entries[READLINE_HISTORY_MAX_DEPTH + 1];
  34. /** Position of next entry within buffer
  35. *
  36. * This is incremented monotonically each time an entry is
  37. * added to the buffer.
  38. */
  39. unsigned int next;
  40. /** Current depth within history buffer
  41. *
  42. * This is valid only during the call to readline()
  43. */
  44. unsigned int depth;
  45. };
  46. extern void history_free ( struct readline_history *history );
  47. extern int readline_history ( const char *prompt, const char *prefill,
  48. struct readline_history *history, char **line );
  49. extern char * __malloc readline ( const char *prompt );
  50. #endif /* _READLINE_H */