File wsh_shell_history.c
FileList > src > wsh_shell_history.c
Go to the source code of this file
#include "wsh_shell_history.h"
Public Functions
| Type | Name |
|---|---|
| void | WshShellHistory_Flush (WshShellHistory_IO_t * pHistIO) Clear the command history buffer. |
| WshShell_Size_t | WshShellHistory_GetNextCmd (WshShellHistory_IO_t * pHistIO, WshShell_Char_t * pOutBuff, WshShell_Size_t outBuffSize) Retrieve the next command from history. |
| WshShell_Size_t | WshShellHistory_GetPrevCmd (WshShellHistory_IO_t * pHistIO, WshShell_Char_t * pOutBuff, WshShell_Size_t outBuffSize) Retrieve the previous command from history. |
| WshShell_Size_t | WshShellHistory_GetTokenByIndex (WshShellHistory_IO_t * pHistIO, WshShell_Char_t * pOutBuff, WshShell_Size_t outBuffSize, WshShell_Size_t index) Retrieve a command from history by its index. |
| WshShell_Size_t | WshShellHistory_GetTokenNum (WshShellHistory_IO_t * pHistIO) Get the total number of commands stored in history. |
| void | WshShellHistory_Init (WshShellHistory_IO_t * pHistIO, WshShellHistory_ReadHandler_t readFn, WshShellHistory_WriteHandler_t writeFn) Initialize the shell history system with custom I/O functions. |
| void | WshShellHistory_SaveCmd (WshShellHistory_IO_t * pHistIO, const WshShell_Char_t * pcCmdStr, WshShell_Size_t cmdStrLen) Save a new command to the history buffer. |
Public Functions Documentation
function WshShellHistory_Flush
Clear the command history buffer.
Parameters:
pHistIOPointer to the I/O structure.
function WshShellHistory_GetNextCmd
Retrieve the next command from history.
Parameters:
pHistIOPointer to the I/O structure.pOutBuffBuffer to store the command string.outBuffSizeSize of the output buffer.
Returns:
Length of the retrieved command.
function WshShellHistory_GetPrevCmd
Retrieve the previous command from history.
Parameters:
pHistIOPointer to the I/O structure.pOutBuffBuffer to store the command string.outBuffSizeSize of the output buffer.
Returns:
Length of the retrieved command.
function WshShellHistory_GetTokenByIndex
Retrieve a command from history by its index.
Index 0 corresponds to the most recently saved command, index 1 to the previous one, and so on.
Parameters:
pHistIOPointer to the I/O structure.pOutBuffBuffer to store the retrieved command.outBuffSizeSize of the output buffer.indexIndex of the command to retrieve (0 = latest).
Returns:
Length of the retrieved command, or 0 if not found or buffer too small.
function WshShellHistory_GetTokenNum
Get the total number of commands stored in history.
Starts from the most recently saved command and iterates backwards through the history buffer to count all stored commands.
Parameters:
pHistIOPointer to the I/O structure.
Returns:
Number of stored commands in history.
function WshShellHistory_Init
Initialize the shell history system with custom I/O functions.
This function sets up the internal history system and loads existing history using the provided read/write callbacks.
Parameters:
pHistIOPointer to the I/O structure used for read/write access.readFnCallback to read saved history data.writeFnCallback to persist current history data.
function WshShellHistory_SaveCmd
Save a new command to the history buffer.
Parameters:
pHistIOPointer to the I/O structure.pcCmdStrPointer to the command string (without EOL).cmdStrLenLength of the command string.
The documentation for this class was generated from the following file src/wsh_shell_history.c