| 1 | /* History.h -- the names of functions that you can call in history. */ |
| 2 | |
| 3 | typedef struct _hist_entry { |
| 4 | char *line; |
| 5 | char *data; |
| 6 | } HIST_ENTRY; |
| 7 | |
| 8 | /* For convenience only. You set this when interpreting history commands. |
| 9 | It is the logical offset of the first history element. */ |
| 10 | extern int history_base; |
| 11 | |
| 12 | /* Begin a session in which the history functions might be used. This |
| 13 | just initializes the interactive variables. */ |
| 14 | extern void using_history (); |
| 15 | |
| 16 | /* Place STRING at the end of the history list. |
| 17 | The associated data field (if any) is set to NULL. */ |
| 18 | extern void add_history (); |
| 19 | |
| 20 | /* Returns the number which says what history element we are now |
| 21 | looking at. */ |
| 22 | extern int where_history (); |
| 23 | |
| 24 | /* Set the position in the history list to POS. */ |
| 25 | int history_set_pos (); |
| 26 | |
| 27 | /* Search for STRING in the history list, starting at POS, an |
| 28 | absolute index into the list. DIR, if negative, says to search |
| 29 | backwards from POS, else forwards. |
| 30 | Returns the absolute index of the history element where STRING |
| 31 | was found, or -1 otherwise. */ |
| 32 | extern int history_search_pos (); |
| 33 | |
| 34 | /* A reasonably useless function, only here for completeness. WHICH |
| 35 | is the magic number that tells us which element to delete. The |
| 36 | elements are numbered from 0. */ |
| 37 | extern HIST_ENTRY *remove_history (); |
| 38 | |
| 39 | /* Stifle the history list, remembering only MAX number of entries. */ |
| 40 | extern void stifle_history (); |
| 41 | |
| 42 | /* Stop stifling the history. This returns the previous amount the |
| 43 | history was stifled by. The value is positive if the history was |
| 44 | stifled, negative if it wasn't. */ |
| 45 | extern int unstifle_history (); |
| 46 | |
| 47 | /* Add the contents of FILENAME to the history list, a line at a time. |
| 48 | If FILENAME is NULL, then read from ~/.history. Returns 0 if |
| 49 | successful, or errno if not. */ |
| 50 | extern int read_history (); |
| 51 | |
| 52 | /* Append the current history to FILENAME. If FILENAME is NULL, |
| 53 | then append the history list to ~/.history. Values returned |
| 54 | are as in read_history (). */ |
| 55 | extern int write_history (); |
| 56 | |
| 57 | |
| 58 | /* Make the history entry at WHICH have LINE and DATA. This returns |
| 59 | the old entry so you can dispose of the data. In the case of an |
| 60 | invalid WHICH, a NULL pointer is returned. */ |
| 61 | extern HIST_ENTRY *replace_history_entry (); |
| 62 | |
| 63 | /* Return the history entry at the current position, as determined by |
| 64 | history_offset. If there is no entry there, return a NULL pointer. */ |
| 65 | HIST_ENTRY *current_history (); |
| 66 | |
| 67 | /* Back up history_offset to the previous history entry, and return |
| 68 | a pointer to that entry. If there is no previous entry, return |
| 69 | a NULL pointer. */ |
| 70 | extern HIST_ENTRY *previous_history (); |
| 71 | |
| 72 | /* Move history_offset forward to the next item in the input_history, |
| 73 | and return the a pointer to that entry. If there is no next entry, |
| 74 | return a NULL pointer. */ |
| 75 | extern HIST_ENTRY *next_history (); |
| 76 | |
| 77 | /* Return a NULL terminated array of HIST_ENTRY which is the current input |
| 78 | history. Element 0 of this list is the beginning of time. If there |
| 79 | is no history, return NULL. */ |
| 80 | extern HIST_ENTRY **history_list (); |
| 81 | |
| 82 | /* Search the history for STRING, starting at history_offset. |
| 83 | If DIRECTION < 0, then the search is through previous entries, |
| 84 | else through subsequent. If the string is found, then |
| 85 | current_history () is the history entry, and the value of this function |
| 86 | is the offset in the line of that history entry that the string was |
| 87 | found in. Otherwise, nothing is changed, and a -1 is returned. */ |
| 88 | extern int history_search (); |
| 89 | |
| 90 | /* Expand the string STRING, placing the result into OUTPUT, a pointer |
| 91 | to a string. Returns: |
| 92 | |
| 93 | 0) If no expansions took place (or, if the only change in |
| 94 | the text was the de-slashifying of the history expansion |
| 95 | character) |
| 96 | 1) If expansions did take place |
| 97 | -1) If there was an error in expansion. |
| 98 | |
| 99 | If an error ocurred in expansion, then OUTPUT contains a descriptive |
| 100 | error message. */ |
| 101 | extern int history_expand (); |
| 102 | |
| 103 | /* Extract a string segment consisting of the FIRST through LAST |
| 104 | arguments present in STRING. Arguments are broken up as in |
| 105 | the shell. */ |
| 106 | extern char *history_arg_extract (); |
| 107 | |
| 108 | |