GNU Info

Info Node: (history.info)Managing the History File

(history.info)Managing the History File


Next: History Expansion Prev: Searching the History List Up: History Functions
Enter node , (file) or (file)node

Managing the History File
-------------------------

   The History library can read the history from and write it to a file.
This section documents the functions for managing a history file.

 - Function: int read_history (const char *filename)
     Add the contents of FILENAME to the history list, a line at a time.
     If FILENAME is `NULL', then read from `~/.history'.  Returns 0 if
     successful, or `errno' if not.

 - Function: int read_history_range (const char *filename, int from,
          int to)
     Read a range of lines from FILENAME, adding them to the history
     list.  Start reading at line FROM and end at TO.  If FROM is zero,
     start at the beginning.  If TO is less than FROM, then read until
     the end of the file.  If FILENAME is `NULL', then read from
     `~/.history'.  Returns 0 if successful, or `errno' if not.

 - Function: int write_history (const char *filename)
     Write the current history to FILENAME, overwriting FILENAME if
     necessary.  If FILENAME is `NULL', then write the history list to
     `~/.history'.  Returns 0 on success, or `errno' on a read or write
     error.

 - Function: int append_history (int nelements, const char *filename)
     Append the last NELEMENTS of the history list to FILENAME.  If
     FILENAME is `NULL', then append to `~/.history'.  Returns 0 on
     success, or `errno' on a read or write error.

 - Function: int history_truncate_file (const char *filename, int
          nlines)
     Truncate the history file FILENAME, leaving only the last NLINES
     lines.  If FILENAME is `NULL', then `~/.history' is truncated.
     Returns 0 on success, or `errno' on failure.


automatically generated by info2www version 1.2.2.9