1
0
mirror of https://github.com/NevermindZZT/letter-shell.git synced 2025-01-21 10:02:54 +08:00
letter-shell/extensions/shell_enhance/shell_secure_user.h

59 lines
1.5 KiB
C
Raw Permalink Normal View History

2022-03-12 21:37:49 +08:00
/**
* @file shell_secure_user.h
* @author Letter (nevermindzzt@gmail.com)
* @brief shell secure user
* @version 0.1
* @date 2022-03-12
*
* @copyright Copyright (c) 2022 Letter
*
*/
#ifndef __SHELL_SECURE_USER_H__
#define __SHELL_SECURE_USER_H__
#include "shell.h"
/**
* @brief shell secure user
*
* @param name
*
* @return char*
*/
typedef char* (*ShellSecureUserGetPassword)(const char *name);
/**
* @brief shell secure user
*
*/
#define SHELL_SECURE_USER_FUNC_NAME(_name) agency##_name
/**
* @brief shell secure user
*
* @param _name
* @param _attr
* @param _handler
*/
#define SHELL_SECURE_USER_FUNC(_name, _attr, _handler) \
void SHELL_SECURE_USER_FUNC_NAME(_name)(int p1, int p2) \
{ shellSecureUser(shellGetCurrent(), #_name, _attr, _handler); }
/**
* @brief shell secure user
*
* @param _attr
* @param _name
* @param _handler
* @param _desc
*/
#define SHELL_EXPORT_SECURE_USER(_attr, _name, _handler, _desc) \
SHELL_SECURE_USER_FUNC(_name, _attr, _handler) \
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN)|SHELL_CMD_DISABLE_RETURN, \
_name, SHELL_SECURE_USER_FUNC_NAME(_name), _desc)
int shellSecureUser(Shell *shell, const char *name, int attr, ShellSecureUserGetPassword handler);
#endif