00001 /* clib/include/readline/able_history.h 00002 * 00003 * History routines for ABLE applications. 00004 * 00005 * Copyright 2007 Simtec Electronics 00006 * 00007 * Permission is hereby granted, free of charge, to any person 00008 * obtaining a copy of this software and associated documentation 00009 * files (the "Software"), to deal in the Software without 00010 * restriction, including without limitation the rights to use, copy, 00011 * modify, merge, publish, distribute, sublicense, and/or sell copies 00012 * of the Software, and to permit persons to whom the Software is 00013 * furnished to do so, subject to the following conditions: 00014 * 00015 * The above copyright notice and this permission notice shall be 00016 * included in all copies or substantial portions of the Software. 00017 * 00018 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 00019 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00020 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 00021 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 00022 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 00023 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 00024 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 00025 * SOFTWARE. 00026 * 00027 */ 00028 00029 #ifndef _ABLE_CLIB_ABLE_HISTORY_H 00030 #define _ABLE_CLIB_ABLE_HISTORY_H 1 00031 00033 typedef void * histdata_t; 00034 00036 typedef struct able_history_s able_history_t; 00037 00043 struct able_history_s 00044 { 00045 struct line_hist_s *entries; 00046 int max_entries; 00051 }; 00052 00054 typedef struct line_hist_s line_hist_t; 00055 00060 struct line_hist_s { 00061 struct line_hist_s* next; 00062 char *line; 00063 char *timestamp; 00064 histdata_t data; 00065 }; 00066 00078 extern able_history_t *able_history_init(int max_entries); 00079 00086 extern void able_history_free(able_history_t *history); 00087 00088 00098 extern line_hist_t *able_history_add(able_history_t *history, const char *line); 00099 00108 extern void able_history_limit(able_history_t *history, int age); 00109 00120 extern line_hist_t *able_history_next(able_history_t *history, line_hist_t *cur); 00121 00132 extern line_hist_t *able_history_prev(able_history_t *history, line_hist_t *cur); 00133 00134 00135 #endif /* _ABLE_CLIB_ABLE_HISTORY_H */