File wsh_shell_history.h
FileList > src > wsh_shell_history.h
Go to the source code of this file
Shell history management API. More...
#include "wsh_shell_cfg.h"#include "wsh_shell_misc.h"#include "wsh_shell_str.h"#include "wsh_shell_types.h"
Classes
| Type | Name |
|---|---|
| struct | WshShellHistory_Data_t Internal structure for storing command history buffer. |
| struct | WshShellHistory_IO_t Structure holding function pointers for history persistence I/O. |
| struct | WshShellHistory_t Shell history structure with integrity check. |
Public Types
| Type | Name |
|---|---|
| enum | WSH_SHELL_HIST_CMD_DIR_t Direction for history navigation. |
| typedef WshShellHistory_t(* | WshShellHistory_ReadHandler_t Function pointer type for reading shell history from persistent storage. |
| typedef void(* | WshShellHistory_WriteHandler_t Function pointer type for writing shell history to persistent storage. |
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. |
Detailed Description
This module provides functionality for storing, navigating, and persisting command history in an embedded shell environment.
Author:
Whoosh Embedded Team
Copyright:
Copyright (c) 2025
Public Types Documentation
enum WSH_SHELL_HIST_CMD_DIR_t
Direction for history navigation.
typedef WshShellHistory_ReadHandler_t
Function pointer type for reading shell history from persistent storage.
typedef WshShellHistory_WriteHandler_t
Function pointer type for writing shell history to persistent storage.
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.h