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_passthrough.h

62 lines
1.7 KiB
C
Raw Normal View History

2021-05-31 22:39:11 +08:00
/**
* @file shell_passthrough.h
* @author Letter(nevermindzzt@gmail.com)
* @brief shell passthrough mode
* @version 0.1
* @date 2021-05-31
*
* @copyright (c) 2021 Letter
*
*/
#ifndef __SHELL_PASSTHROUGH_H__
#define __SHELL_PASSTHROUGH_H__
#include "shell.h"
/**
* @brief 退 passthrough
*/
#define SHELL_PASSTHROUGH_EXIT_KEY 0x04 // Ctrl + D
/**
* @brief passthrough handler
*
* @param data
* @param len
*
* @return int
*/
typedef int (*ShellPassthrough)(char *data, unsigned short len);
/**
* @brief shell passthrough
*/
#define SHELL_PASSTROUGH_FUNC_NAME(_name) agency##_name
/**
* @brief shell passthrough
*
* @param _name
* @param _prompt passthrough
* @param _handler passthrough handler
*/
#define SHELL_PASSTROUGH_FUNC(_name, _prompt, _handler) \
void SHELL_PASSTROUGH_FUNC_NAME(_name)(int p1, int p2) \
{ shellPassthrough(shellGetCurrent(), #_prompt, _handler, p1, (void *)p2); }
2021-05-31 22:39:11 +08:00
/**
* @brief shell passthrouh
*
* @param _attr
* @param _name passthrough
* @param _prompt passthrough
* @param _handler passthrough handler
* @param _desc passthrough
*/
#define SHELL_EXPORT_PASSTROUGH(_attr, _name, _prompt, _handler, _desc) \
SHELL_PASSTROUGH_FUNC(_name, _prompt, _handler) \
SHELL_EXPORT_CMD(_attr|SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN), _name, SHELL_PASSTROUGH_FUNC_NAME(_name), _desc)
2021-05-31 22:39:11 +08:00
unsigned int shellPassthrough(Shell *shell, const char *prompt, ShellPassthrough handler, int argc, char *argv[]);
2021-05-31 22:39:11 +08:00
#endif