diff --git a/src/shell.h b/src/shell.h index 1c602e5..8147684 100644 --- a/src/shell.h +++ b/src/shell.h @@ -14,10 +14,6 @@ #include "shell_cfg.h" -#if SHELL_USING_COMPANION == 1 -#include "shell_companion.h" -#endif - #define SHELL_VERSION "3.0.3" /**< 版本号 */ @@ -400,5 +396,24 @@ void shellHandler(Shell *shell, char data); void shellTask(void *param); 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 diff --git a/src/shell_companion.c b/src/shell_companion.c index 85cf4cc..eb494c7 100644 --- a/src/shell_companion.c +++ b/src/shell_companion.c @@ -8,10 +8,9 @@ * @copyright (c) 2020 Letter * */ - #include "shell_companion.h" #include "shell.h" - +#if SHELL_USING_COMPANION == 1 /** * @brief shell添加伴生对象 * @@ -20,7 +19,7 @@ * @param object 伴生对象 * @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 *node = SHELL_MALLOC(sizeof(ShellCompanionObj)); @@ -39,7 +38,7 @@ signed char shellCompanionAdd(struct shell_def *shell, int id, void *object) * @param id 伴生对象ID * @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 *front = companions; @@ -71,7 +70,7 @@ signed char shellCompanionDel(struct shell_def *shell, int id) * @param id 伴生对象ID * @return void* 伴生对象,无匹配对象时返回NULL */ -void *shellCompanionGet(struct shell_def *shell, int id) +void *shellCompanionGet(Shell *shell, int id) { SHELL_ASSERT(shell, return (void *)0); ShellCompanionObj *companions = shell->info.companions; @@ -85,3 +84,4 @@ void *shellCompanionGet(struct shell_def *shell, int id) } return (void *)0; } +#endif /** SHELL_USING_COMPANION == 1 */ diff --git a/src/shell_companion.h b/src/shell_companion.h deleted file mode 100644 index 6c24db1..0000000 --- a/src/shell_companion.h +++ /dev/null @@ -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