RT-Thread finsh源码分析: finsh_error.c

/*
 *  error number for finsh shell.
 *
 * COPYRIGHT (C) 2013, Shanghai Real-Thread Technology Co., Ltd
 *
 *  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
 */
#include "finsh_error.h"

u_char global_errno;  //静态全局变量,错误码

//错误类型对应的字符串
static const char * finsh_error_string_table[] =
{
    "No error",
	"Invalid token",
	"Expect a type",
	"Unknown type",
	"Variable exist",
	"Expect a operater",
	"Memory full",
	"Unknown operator",
	"Unknown node",
	"Expect a character",
	"Unexpect end",
	"Unknown token",
	"Float not supported",
	"Unknown symbol",
	"Null node"
};

//错误码初始化
int finsh_error_init()
{
	global_errno = FINSH_ERROR_OK;

	return 0;
}

//设置错误码
int finsh_error_set(u_char type)
{
	global_errno = type;

	return 0;
}

//获取错误码
u_char finsh_errno()
{
	return global_errno;
}

//通过错误码返回错误字符串
const char* finsh_error_string(u_char type)
{
	return finsh_error_string_table[type];
}
时间: 2024-08-04 05:28:19

RT-Thread finsh源码分析: finsh_error.c的相关文章

RT-Thread finsh源码分析: finsh_error.h

/*  *  error number for finsh shell.  *  * COPYRIGHT (C) 2013, Shanghai Real-Thread Technology Co., Ltd  *  *  This file is part of RT-Thread (http://www.rt-thread.org)  *  Maintainer: bernard.xiong <bernard.xiong at gmail.com>  *  *  All rights res

RT-Thread finsh源码分析: finsh_var.c

/*  *  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 

RT-Thread finsh源码分析: finsh_heap.h

/*  *  heap management 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

RT-Thread finsh源码分析: finsh_var.h

/* *  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

Handler、Looper、MessageQueue、Thread源码分析

关于这几个之间的关系以及源码分析的文章应该挺多的了,不过既然学习了,还是觉得整理下,印象更深刻点,嗯,如果有错误的地方欢迎反馈. 转载请注明出处:http://www.cnblogs.com/John-Chen/p/4396268.html 对应关系:   1.Handler 不带Looper的构造器 /** * Use the {@link Looper} for the current thread with the specified callback interface * and se

4.Sentinel源码分析— Sentinel是如何做到降级的?

各位中秋节快乐啊,我觉得在这个月圆之夜有必要写一篇源码解析,以表示我内心的高兴~ Sentinel源码解析系列: 1.Sentinel源码分析-FlowRuleManager加载规则做了什么? 2. Sentinel源码分析-Sentinel是如何进行流量统计的? 3. Sentinel源码分析- QPS流量控制是如何实现的? 在我的第二篇文章里面2. Sentinel源码分析-Sentinel是如何进行流量统计的?里面介绍了整个Sentinel的主流程是怎样的.所以降级的大致流程可以概述为:

5.Sentinel源码分析—Sentinel如何实现自适应限流?

Sentinel源码解析系列: 1.Sentinel源码分析-FlowRuleManager加载规则做了什么? 2. Sentinel源码分析-Sentinel是如何进行流量统计的? 3. Sentinel源码分析- QPS流量控制是如何实现的? 4.Sentinel源码分析- Sentinel是如何做到降级的? 这篇文章主要学习一下Sentinel如何实现自适应限流的. 为什么要做自适应限流,官方给了两个理由: 保证系统不被拖垮 在系统稳定的前提下,保持系统的吞吐量 我再贴一下官方的原理: 能

别翻了,这篇文章绝对让你深刻理解java类的加载以及ClassLoader源码分析【JVM篇二】

目录 1.什么是类的加载(类初始化) 2.类的生命周期 3.接口的加载过程 4.解开开篇的面试题 5.理解首次主动使用 6.类加载器 7.关于命名空间 8.JVM类加载机制 9.双亲委派模型 10.ClassLoader源码分析 11.自定义类加载器 12.加载类的三种方式 13.总结 14.特别注意 @ 前言 你是否真的理解java的类加载机制?点进文章的盆友不如先来做一道非常常见的面试题,如果你能做出来,可能你早已掌握并理解了java的类加载机制,若结果出乎你的意料,那就很有必要来了解了解j

Linux内核源码分析--内核启动之(5)Image内核启动(rest_init函数)(Linux-3.0 ARMv7)【转】

原文地址:Linux内核源码分析--内核启动之(5)Image内核启动(rest_init函数)(Linux-3.0 ARMv7) 作者:tekkamanninja 转自:http://blog.chinaunix.net/uid-25909619-id-4938395.html 前面粗略分析start_kernel函数,此函数中基本上是对内存管理和各子系统的数据结构初始化.在内核初始化函数start_kernel执行到最后,就是调用rest_init函数,这个函数的主要使命就是创建并启动内核线