history.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /**
  2. \ingroup tinyrl
  3. \defgroup tinyrl_history history
  4. @{
  5. \brief This class handles the maintenance of a historical list of command lines.
  6. */
  7. #ifndef _tinyrl_history_h
  8. #define _tinyrl_history_h
  9. #include "lub/c_decl.h"
  10. #include "lub/types.h"
  11. _BEGIN_C_DECL
  12. /**************************************
  13. * tinyrl_history_entry class interface
  14. ************************************** */
  15. typedef struct _tinyrl_history_entry tinyrl_history_entry_t;
  16. extern const char *
  17. tinyrl_history_entry__get_line(const tinyrl_history_entry_t *instance);
  18. extern unsigned
  19. tinyrl_history_entry__get_index(const tinyrl_history_entry_t *instance);
  20. /**************************************
  21. * tinyrl_history class interface
  22. ************************************** */
  23. typedef struct _tinyrl_history tinyrl_history_t;
  24. /**
  25. * This type is used for the iteration of history entries
  26. */
  27. typedef struct _tinyrl_history_iterator tinyrl_history_iterator_t;
  28. /**
  29. * CLIENTS MUST NOT USE THESE FIELDS DIRECTLY
  30. */
  31. struct _tinyrl_history_iterator
  32. {
  33. const tinyrl_history_t *history;
  34. unsigned offset;
  35. };
  36. extern tinyrl_history_t *
  37. tinyrl_history_new(unsigned stifle);
  38. extern void
  39. tinyrl_history_delete(tinyrl_history_t *instance);
  40. extern void
  41. tinyrl_history_add (tinyrl_history_t *instance,
  42. const char *line);
  43. extern tinyrl_history_entry_t *
  44. tinyrl_history_getfirst (const tinyrl_history_t *instance,
  45. tinyrl_history_iterator_t *iter);
  46. extern tinyrl_history_entry_t *
  47. tinyrl_history_getlast (const tinyrl_history_t *instance,
  48. tinyrl_history_iterator_t *iter);
  49. extern tinyrl_history_entry_t *
  50. tinyrl_history_getnext(tinyrl_history_iterator_t *iter);
  51. extern tinyrl_history_entry_t *
  52. tinyrl_history_getprevious(tinyrl_history_iterator_t *iter);
  53. /*
  54. HISTORY LIST MANAGEMENT
  55. */
  56. extern tinyrl_history_entry_t *
  57. tinyrl_history_remove(tinyrl_history_t *instance,
  58. unsigned offset);
  59. extern void
  60. tinyrl_history_clear(tinyrl_history_t *instance);
  61. extern void
  62. tinyrl_history_stifle(tinyrl_history_t *instance,
  63. unsigned stifle);
  64. extern unsigned
  65. tinyrl_history_unstifle(tinyrl_history_t *instance);
  66. extern bool_t
  67. tinyrl_history_is_stifled(const tinyrl_history_t *instance);
  68. /*
  69. INFORMATION ABOUT THE HISTORY LIST
  70. */
  71. extern tinyrl_history_entry_t **
  72. tinyrl_history_list(const tinyrl_history_t *instance);
  73. extern tinyrl_history_entry_t *
  74. tinyrl_history_get(const tinyrl_history_t *instance,
  75. unsigned offset);
  76. /*
  77. * HISTORY EXPANSION
  78. */
  79. typedef enum
  80. {
  81. tinyrl_history_NO_EXPANSION,
  82. tinyrl_history_EXPANDED
  83. } tinyrl_history_expand_t;
  84. extern tinyrl_history_expand_t
  85. tinyrl_history_expand(const tinyrl_history_t *instance,
  86. const char *string,
  87. char **output);
  88. _END_C_DECL
  89. #endif /* _tinyrl_history_h */
  90. /** @} tinyrl_history */