1 Star 0 Fork 189

lzm2018 / nr_micro_shell

forked from Nrush / nr_micro_shell 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
nr_micro_shell.h 3.83 KB
一键复制 编辑 原始数据 按行查看 历史
Nrush 提交于 2019-10-29 15:38 . .
/**
* @file nr_micro_shell.h
* @author Ji Youzhou
* @version V0.1
* @date 28 Oct 2019
* @brief [brief]
* *****************************************************************************
* @attention
*
* MIT License
*
* Copyright (C) 2019 Ji Youzhou. or its affiliates. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __nr_micro_shell_h
#define __nr_micro_shell_h
#ifdef __cplusplus
extern "C"
{
#endif
/* Includes ------------------------------------------------------------------*/
#include "stdio.h"
#include "nr_micro_shell_config.h"
#include "ansi.h"
#ifndef print_shell
#define shell_printf(fmt, args...) printf(fmt, ##args);
#endif
typedef void (*shell_fun_t)(char, char *);
typedef struct static_cmd_function_struct
{
char cmd[NR_SHELL_CMD_NAME_MAX_LENGTH];
void (*fp)(char argc, char *argv);
char *description;
} static_cmd_st;
typedef struct shell_history_queue_struct
{
unsigned short int fp;
unsigned short int rp;
unsigned short int len;
unsigned short int index;
unsigned short int store_front;
unsigned short int store_rear;
unsigned short int store_num;
char queue[NR_SHELL_MAX_CMD_HISTORY_NUM + 1];
char buf[NR_SHELL_CMD_HISTORY_BUF_LENGTH + 1];
} shell_his_queue_st;
typedef struct nr_shell
{
char user_name[NR_SHELL_USER_NAME_MAX_LENGTH];
const static_cmd_st *static_cmd;
shell_his_queue_st cmd_his;
} shell_st;
void _shell_init(shell_st *shell);
void shell_parser(shell_st *shell, char *str);
char *shell_cmd_complete(shell_st *shell, char *str);
void shell_his_queue_init(shell_his_queue_st *queue);
void shell_his_queue_add_cmd(shell_his_queue_st *queue, char *str);
unsigned short int shell_his_queue_search_cmd(shell_his_queue_st *queue, char *str);
void shell_his_copy_queue_item(shell_his_queue_st *queue, unsigned short i, char *str_buf);
extern const static_cmd_st static_cmd[];
extern shell_st nr_shell;
#define shell_init() \
{ \
ansi_init(&nr_ansi); \
_shell_init(&nr_shell); \
}
#define shell(c) \
{ \
if (ansi_get_char(c, &nr_ansi) == '\n') \
{ \
shell_parser(&nr_shell, nr_ansi.current_line); \
ansi_clear_current_line(&nr_ansi); \
} \
}
#ifdef __cplusplus
}
#endif
#endif
/******************* (C) COPYRIGHT 2019 Ji Youzhou *****END OF FILE*****************/
1
https://gitee.com/lzm2018/nr_micro_shell.git
git@gitee.com:lzm2018/nr_micro_shell.git
lzm2018
nr_micro_shell
nr_micro_shell
master

搜索帮助