C-Shell
A simple shell written in C.
Loading...
Searching...
No Matches
history.h File Reference

Data Structures

struct  history_list
 

Macros

#define DEFAULT_HIST_ITEMS   10
 
#define MAX_HISTORY_ITEMS   20
 

Functions

void add_to_history (char *line)
 Adds a line to the history.
 
void clear_history ()
 Clears the history.
 
const struct history_listget_history ()
 Gets the history list.
 
void print_history (int n)
 Prints the last n commands in the history.
 
int read_history_from_file ()
 
int write_history_to_file ()
 

Macro Definition Documentation

◆ DEFAULT_HIST_ITEMS

#define DEFAULT_HIST_ITEMS   10

The default number of items to print when the user does not specify a number.

◆ MAX_HISTORY_ITEMS

#define MAX_HISTORY_ITEMS   20

Function Documentation

◆ add_to_history()

void add_to_history ( char * line)

Adds a line to the history.

Parameters
lineThe command to add.

allocate memory and deep copy

free the memory

allocate memory and deep copy

◆ clear_history()

void clear_history ( )

Clears the history.

free the memory

◆ get_history()

const struct history_list * get_history ( )

Gets the history list.

Returns
Pointer to the history list.

◆ print_history()

void print_history ( int n)

Prints the last n commands in the history.

Parameters
nThe number of commands to print.

◆ read_history_from_file()

int read_history_from_file ( )

◆ write_history_to_file()

int write_history_to_file ( )