RT-Thread finsh源码分析: finsh_var.h
2015-08-18 22:02
411 查看
/* * Variable implementation in finsh shell. * * COPYRIGHT (C) 2006 - 2013, RT-Thread Development Team * * This file is part of RT-Thread (http://www.rt-thread.org) * Maintainer: bernard.xiong <bernard.xiong at gmail.com> * * All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * Change Logs: * Date Author Notes * 2010-03-22 Bernard first version */ #ifndef __FINSH_VAR_H__ #define __FINSH_VAR_H__ #include <finsh.h> /* * The variable in finsh is put in data segment as a global variable. * The 'finsh_var' structure presents the structure of variable in data segment. */ /* * finsh_var是全局变量,属于数据段 */ struct finsh_var { //数组长度加1,可以在循环中避免>=或者<=临界问题,增加代码可读性 char name[FINSH_NAME_MAX + 1];/* the name of variable */ //错误类型 u_char type;/* the type of variable */ //联合,模糊定义,动态扩展 /* variable value */ union { char char_value; short short_value; intint_value; longlong_value; void*ptr; }value; }; //声明为全局数据,注意数组未初始化,应该放在.bss段 extern struct finsh_var global_variable[]; int finsh_var_init(void); //数组global_variable初始化 int finsh_var_insert(const char* name, int type); //插入var到数组global_variable int finsh_var_delete(const char* name); //从数组移出var struct finsh_var* finsh_var_lookup(const char* name); //查找var #endif
相关文章推荐
- QT串口工具(1)
- 海外短租,亟待巨头定规矩?
- Linux基本权限与ACL权限
- Android ToggleButton和Switch
- UIP协议一
- SPOJ 题目694 Distinct Substrings(后缀数组,求不同的子串个数)
- Poj 1321 棋盘问题
- iOS 任意圆角button,左圆右直,左直右圆,上圆下直,上直下圆
- 回文判断
- light oj 1248 第六周E题(期望)
- 【MySQL for Mac】终极解决——MySQL在Mac的字符集设置
- 高效e人注册码 EfficientPIM Pro 5.0 Build 505
- 使用apache配置进行简单的HTTP Basic Authentication
- hdu 2566 放大的X
- 试题系列三(求任意两个数的最大公约数)
- 修改ramdisk文件总结
- Path的配置问题
- 高性能缓存服务器Squid架构配置
- RT-Thread finsh源码分析: finsh_error.c
- Android的五种布局