File wsh_shell_str.h
FileList > src > wsh_shell_str.h
Go to the source code of this file
Common string operations for user input processing. More...
#include "wsh_shell_cfg.h"#include "wsh_shell_io.h"#include "wsh_shell_option.h"#include "wsh_shell_types.h"
Public Functions
| Type | Name |
|---|---|
| void | WshShellStr_AccessBitsToStr (WshShell_Size_t access, WshShell_Char_t * pOutStr) Converts access permission bits to a human-readable string like "rwx". |
| void | WshShellStr_DecrInterCnt (WshShell_Size_t * pInterCnt) Decrease buffer counter. |
| void | WshShellStr_GroupBitsToStr (WshShell_Size_t group, WshShell_Size_t groupMaxNum, WshShell_Char_t * pOutStr) Converts group bitmask into symbolic group string (e.g. "*--*", "---*", etc). |
| void | WshShellStr_IncrInterCnt (WshShell_Size_t * pInterCnt, WshShell_Size_t buffSize) Increase buffer counter. |
| WshShell_Bool_t | WshShellStr_IsPrintableAscii (WshShell_Char_t ch) Check whether the given character is a printable ASCII symbol. |
| void | WshShellStr_ParseToArgcArgv (WshShell_Char_t * pStr, WshShell_Size_t * pArgNum, const WshShell_Char_t * pArgBuff, WshShell_Size_t maxArgNum) Parse a string into space-separated tokens, handling quoted substrings as single tokens. |
| WshShell_Char_t * | WshShellStr_TrimString (WshShell_Char_t * pString, WshShell_Size_t len) Trim tabulation and spaces from beginning and end of a string. |
Macros
| Type | Name |
|---|---|
| define | WSH_SHELL_PRESS_ENTER_TO_LOG_IN_STR "Press <Enter> to log in..." |
Detailed Description
Author:
Whoosh Embedded Team
Copyright:
Copyright (c) 2024
Public Functions Documentation
function WshShellStr_AccessBitsToStr
Converts access permission bits to a human-readable string like "rwx".
This function translates access bit flags into a POSIX-style permission string. The result is written into the provided buffer.
The output format is:
* 'rifWSH_SHELL_OPT_ACCESS_READis set, otherwise'-'-'w'ifWSH_SHELL_OPT_ACCESS_WRITEis set, otherwise'-'-'x'ifWSH_SHELL_OPT_ACCESS_EXECUTEis set, otherwise'-'-'A'ifaccess == WSH_SHELL_OPT_ACCESS_ANY` (optional fourth character)
Examples:
* 0x00 → "---"
* 0x03 → "rw-"
* 0x07 → "rwx"
* 0xFFFFFFFF→ "rwxA"
Parameters:
accessBitmask of access flags (e.g. WSH_SHELL_OPT_ACCESS_READ).pOutStrBuffer to write result to. Must be at least 5 bytes long.
function WshShellStr_DecrInterCnt
Decrease buffer counter.
Parameters:
pInterCntPointer to a counter.
function WshShellStr_GroupBitsToStr
Converts group bitmask into symbolic group string (e.g. "*--*", "---*", etc).
Produces a fixed-length string of '*' and '-' characters from highest to lowest group index.
Example for 2 groups: * WSH_SHELL_CMD_GROUP_ADMIN = bit 0 → rightmost char * WSH_SHELL_CMD_GROUP_MANUF = bit 3 → leftmost char
Parameters:
groupBitmask of groups.groupMaxNumGroups max number.pOutStrOutput buffer (must be at least WSH_SHELL_GROUP_STR_LEN).
function WshShellStr_IncrInterCnt
Increase buffer counter.
Parameters:
pInterCntPointer to a counter.buffSizeSize of a buffer.
function WshShellStr_IsPrintableAscii
Check whether the given character is a printable ASCII symbol.
This function checks if the character belongs to the range of printable ASCII characters (from 0x20 ' ' to 0x7E '~').
Parameters:
chCharacter to check.
Returns:
true if the character is printable ASCII; false otherwise.
function WshShellStr_ParseToArgcArgv
Parse a string into space-separated tokens, handling quoted substrings as single tokens.
This function splits the input string pStr into tokens by replacing spaces with null terminators (\0). Tokens are written as pointers to the beginning of each token into the pArgBuff array. Quoted substrings (enclosed in double quotes "), if any, are treated as a single token. Quotes themselves are removed during parsing. ч
Note:
This function modifies the input string in-place. Spaces and quotes are replaced with \0. Escaped or nested quotes are not supported.
Example: Input: "arg1 arg2 \"quoted string" arg3"</tt>
Output: <tt>pArgBuff = { "arg1", "arg2", "quoted string", "arg3" }, *pArgNum = 4
Parameters:
pStrPointer to the null-terminated string to be parsed. Will be modified in-place.pArgNumPointer to a counter that will be set to the number of parsed tokens.pArgBuffArray of string pointers (tokens). Must be large enough to hold all tokens.maxArgNumMaximum number of tokens that can be stored inpArgBuff. Excess tokens are discarded.
function WshShellStr_TrimString
Trim tabulation and spaces from beginning and end of a string.
Parameters:
pStringPointer to a string to be trimmed.lenLength of an input string.
Returns:
WshShell_Char_t*: Pointer to a trimmed string.
Macro Definition Documentation
define WSH_SHELL_PRESS_ENTER_TO_LOG_IN_STR
The documentation for this class was generated from the following file src/wsh_shell_str.h