Skip to content

File wsh_shell_user.h

FileList > src > wsh_shell_user.h

Go to the source code of this file

Shell user management API. More...

  • #include "wsh_shell_cfg.h"
  • #include "wsh_shell_misc.h"
  • #include "wsh_shell_types.h"

Classes

Type Name
struct WshShellUser_Table_t
Table of registered shell users.
struct WshShellUser_t
User object definition.

Public Types

Type Name
typedef void(* WshShellUser_HashFunc_t
Hash function for salt + pass encryption.

Public Functions

Type Name
WSH_SHELL_RET_STATE_t WshShellUser_Attach (WshShellUser_Table_t * pShellUsers, const WshShellUser_t * pcUserTable, WshShell_Size_t userNum, WshShellUser_HashFunc_t extHashFunc)
Initialize the shell user table.
WshShell_Bool_t WshShellUser_CheckCredentials (WshShellUser_Table_t * pShellUsers, WshShell_Size_t UserID, const WshShell_Char_t * pcLogin, const WshShell_Char_t * pcPass)
Verify login credentials of a user.
void WshShellUser_DeAttach (WshShellUser_Table_t * pShellUsers)
Destroy the user table.
const WshShellUser_t * WshShellUser_FindByCredentials (WshShellUser_Table_t * pShellUsers, const WshShell_Char_t * pcLogin, const WshShell_Char_t * pcPass)
Finds a user by login and password credentials.
const WshShellUser_t * WshShellUser_GetUserByIndex (WshShellUser_Table_t * pShellUsers, WshShell_Size_t idx)
Retrieve a user by index.
WshShell_Size_t WshShellUser_GetUsersNum (WshShellUser_Table_t * pShellUsers)
Get the number of users registered in the shell.

Detailed Description

Author:

Whoosh Embedded Team

Copyright:

Copyright (c) 2025

Public Types Documentation

typedef WshShellUser_HashFunc_t

Hash function for salt + pass encryption.

typedef void(* WshShellUser_HashFunc_t) (const WshShell_Char_t *pcSalt, const WshShell_Char_t *pcPass, WshShell_Char_t *pHash);


Public Functions Documentation

function WshShellUser_Attach

Initialize the shell user table.

1
2
3
4
5
6
WSH_SHELL_RET_STATE_t WshShellUser_Attach (
    WshShellUser_Table_t * pShellUsers,
    const WshShellUser_t * pcUserTable,
    WshShell_Size_t userNum,
    WshShellUser_HashFunc_t extHashFunc
) 

Registers a static user table for the shell instance.

Parameters:

  • pShellUsers Pointer to the shell's user table.
  • pcUserTable Pointer to the static array of user records.
  • userNum Number of users in the array.

Return value:

  • WSH_SHELL_RET_STATE_SUCCESS Initialization succeeded.
  • WSH_SHELL_RET_STATE_ERR_PARAM Invalid input arguments.
  • WSH_SHELL_RET_STATE_ERR_BUSY Table was already initialized.

function WshShellUser_CheckCredentials

Verify login credentials of a user.

1
2
3
4
5
6
WshShell_Bool_t WshShellUser_CheckCredentials (
    WshShellUser_Table_t * pShellUsers,
    WshShell_Size_t UserID,
    const WshShell_Char_t * pcLogin,
    const WshShell_Char_t * pcPass
) 

Validates login and password against the given user index.

Parameters:

  • pShellUsers Pointer to the user table.
  • UserID Index of the user to validate.
  • pcLogin Pointer to the login string.
  • pcPass Pointer to the password string.

Return value:

  • true If credentials match.
  • false If mismatch or error.

function WshShellUser_DeAttach

Destroy the user table.

1
2
3
void WshShellUser_DeAttach (
    WshShellUser_Table_t * pShellUsers
) 

Resets the user list and count to zero.

Parameters:

  • pShellUsers Pointer to the user table to reset.

function WshShellUser_FindByCredentials

Finds a user by login and password credentials.

1
2
3
4
5
const WshShellUser_t * WshShellUser_FindByCredentials (
    WshShellUser_Table_t * pShellUsers,
    const WshShell_Char_t * pcLogin,
    const WshShell_Char_t * pcPass
) 

Searches the given user table for a user whose login and password match the provided credentials. Comparison is done using the WshShellUser_CheckCredentials function.

Parameters:

  • pShellUsers Pointer to the user table.
  • pcLogin Pointer to the login string.
  • pcPass Pointer to the password string.

Returns:

Pointer to the matching user object if found; NULL otherwise.

Note:

Returns NULL if any input pointer is NULL or if the user table is empty.


function WshShellUser_GetUserByIndex

Retrieve a user by index.

1
2
3
4
const WshShellUser_t * WshShellUser_GetUserByIndex (
    WshShellUser_Table_t * pShellUsers,
    WshShell_Size_t idx
) 

Parameters:

  • pShellUsers Pointer to the user table.
  • idx Index of the user.

Returns:

Pointer to the user object, or NULL if invalid.


function WshShellUser_GetUsersNum

Get the number of users registered in the shell.

1
2
3
WshShell_Size_t WshShellUser_GetUsersNum (
    WshShellUser_Table_t * pShellUsers
) 

Parameters:

  • pShellUsers Pointer to the user table.

Returns:

Number of users, or 0 if uninitialized or NULL.



The documentation for this class was generated from the following file src/wsh_shell_user.h