/* * 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 global variable, error code//error type corresponding to the string 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 "};//error code initialization int finsh_error_init () {Global_errno = finsh_ error_ok;return 0;} Set error code Int finsh_error_set (u_char type) {global_errno = type;return 0;} Get error code U_char finsh_errno () {Return global_errno;} Error string returned by error code const char* finsh_error_string (u_char&nbsP;type) {Return finsh_error_string_table[type];}
This article is from the "mountain Ask the Boy" blog, please be sure to keep this source http://linpeng.blog.51cto.com/9779987/1685378
Rt-thread finsh Source Analysis: FINSH_ERROR.C