mirror of
https://github.com/NevermindZZT/letter-shell.git
synced 2025-01-21 10:02:54 +08:00
优化 代码结构
This commit is contained in:
parent
a4a8f98f7d
commit
55cb066db8
23
src/shell.h
23
src/shell.h
@ -14,10 +14,6 @@
|
|||||||
|
|
||||||
#include "shell_cfg.h"
|
#include "shell_cfg.h"
|
||||||
|
|
||||||
#if SHELL_USING_COMPANION == 1
|
|
||||||
#include "shell_companion.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define SHELL_VERSION "3.0.3" /**< 版本号 */
|
#define SHELL_VERSION "3.0.3" /**< 版本号 */
|
||||||
|
|
||||||
|
|
||||||
@ -400,5 +396,24 @@ void shellHandler(Shell *shell, char data);
|
|||||||
void shellTask(void *param);
|
void shellTask(void *param);
|
||||||
int shellRun(Shell *shell, const char *cmd);
|
int shellRun(Shell *shell, const char *cmd);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#if SHELL_USING_COMPANION == 1
|
||||||
|
/**
|
||||||
|
* @brief shell伴生对象定义
|
||||||
|
*/
|
||||||
|
typedef struct shell_companion_object
|
||||||
|
{
|
||||||
|
int id; /**< 伴生对象ID */
|
||||||
|
void *obj; /**< 伴生对象 */
|
||||||
|
struct shell_companion_object *next; /**< 下一个伴生对象 */
|
||||||
|
} ShellCompanionObj;
|
||||||
|
|
||||||
|
|
||||||
|
signed char shellCompanionAdd(Shell *shell, int id, void *object);
|
||||||
|
signed char shellCompanionDel(Shell *shell, int id);
|
||||||
|
void *shellCompanionGet(Shell *shell, int id);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -8,10 +8,9 @@
|
|||||||
* @copyright (c) 2020 Letter
|
* @copyright (c) 2020 Letter
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#include "shell_companion.h"
|
|
||||||
#include "shell.h"
|
#include "shell.h"
|
||||||
|
|
||||||
|
#if SHELL_USING_COMPANION == 1
|
||||||
/**
|
/**
|
||||||
* @brief shell添加伴生对象
|
* @brief shell添加伴生对象
|
||||||
*
|
*
|
||||||
@ -20,7 +19,7 @@
|
|||||||
* @param object 伴生对象
|
* @param object 伴生对象
|
||||||
* @return signed char 0 添加成功 -1 添加失败
|
* @return signed char 0 添加成功 -1 添加失败
|
||||||
*/
|
*/
|
||||||
signed char shellCompanionAdd(struct shell_def *shell, int id, void *object)
|
signed char shellCompanionAdd(Shell *shell, int id, void *object)
|
||||||
{
|
{
|
||||||
ShellCompanionObj *companions = shell->info.companions;
|
ShellCompanionObj *companions = shell->info.companions;
|
||||||
ShellCompanionObj *node = SHELL_MALLOC(sizeof(ShellCompanionObj));
|
ShellCompanionObj *node = SHELL_MALLOC(sizeof(ShellCompanionObj));
|
||||||
@ -39,7 +38,7 @@ signed char shellCompanionAdd(struct shell_def *shell, int id, void *object)
|
|||||||
* @param id 伴生对象ID
|
* @param id 伴生对象ID
|
||||||
* @return signed char 0 删除成功 -1 无匹配对象
|
* @return signed char 0 删除成功 -1 无匹配对象
|
||||||
*/
|
*/
|
||||||
signed char shellCompanionDel(struct shell_def *shell, int id)
|
signed char shellCompanionDel(Shell *shell, int id)
|
||||||
{
|
{
|
||||||
ShellCompanionObj *companions = shell->info.companions;
|
ShellCompanionObj *companions = shell->info.companions;
|
||||||
ShellCompanionObj *front = companions;
|
ShellCompanionObj *front = companions;
|
||||||
@ -71,7 +70,7 @@ signed char shellCompanionDel(struct shell_def *shell, int id)
|
|||||||
* @param id 伴生对象ID
|
* @param id 伴生对象ID
|
||||||
* @return void* 伴生对象,无匹配对象时返回NULL
|
* @return void* 伴生对象,无匹配对象时返回NULL
|
||||||
*/
|
*/
|
||||||
void *shellCompanionGet(struct shell_def *shell, int id)
|
void *shellCompanionGet(Shell *shell, int id)
|
||||||
{
|
{
|
||||||
SHELL_ASSERT(shell, return (void *)0);
|
SHELL_ASSERT(shell, return (void *)0);
|
||||||
ShellCompanionObj *companions = shell->info.companions;
|
ShellCompanionObj *companions = shell->info.companions;
|
||||||
@ -85,3 +84,4 @@ void *shellCompanionGet(struct shell_def *shell, int id)
|
|||||||
}
|
}
|
||||||
return (void *)0;
|
return (void *)0;
|
||||||
}
|
}
|
||||||
|
#endif /** SHELL_USING_COMPANION == 1 */
|
||||||
|
@ -1,33 +0,0 @@
|
|||||||
/**
|
|
||||||
* @file shell_companion.h
|
|
||||||
* @author Letter (nevermindzzt@gmail.com)
|
|
||||||
* @brief shell companion object support
|
|
||||||
* @version 3.0.3
|
|
||||||
* @date 2020-07-22
|
|
||||||
*
|
|
||||||
* @copyright (c) 2020 Letter
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
#ifndef __SHELL_COMPANION_H__
|
|
||||||
#define __SHELL_COMPANION_H__
|
|
||||||
|
|
||||||
#include "shell_cfg.h"
|
|
||||||
#include "shell.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief shell伴生对象定义
|
|
||||||
*/
|
|
||||||
typedef struct shell_companion_object
|
|
||||||
{
|
|
||||||
int id; /**< 伴生对象ID */
|
|
||||||
void *obj; /**< 伴生对象 */
|
|
||||||
struct shell_companion_object *next; /**< 下一个伴生对象 */
|
|
||||||
} ShellCompanionObj;
|
|
||||||
|
|
||||||
|
|
||||||
signed char shellCompanionAdd(struct shell_def *shell, int id, void *object);
|
|
||||||
signed char shellCompanionDel(struct shell_def *shell, int id);
|
|
||||||
void *shellCompanionGet(struct shell_def *shell, int id);
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
Loading…
x
Reference in New Issue
Block a user