manpagez: man pages & more
info history
Home | html | info | man
[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

2.3.6 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.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]
© manpagez.com 2000-2024
Individual documents may contain additional copyright information.