finsh_error.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * error number for finsh shell.
  3. *
  4. * COPYRIGHT (C) 2013, Shanghai Real-Thread Technology Co., Ltd
  5. *
  6. * This file is part of RT-Thread (http://www.rt-thread.org)
  7. * Maintainer: bernard.xiong <bernard.xiong at gmail.com>
  8. *
  9. * All rights reserved.
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 2 of the License, or
  14. * (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License along
  22. * with this program; if not, write to the Free Software Foundation, Inc.,
  23. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  24. *
  25. * Change Logs:
  26. * Date Author Notes
  27. * 2010-03-22 Bernard first version
  28. */
  29. #include "finsh_error.h"
  30. u_char global_errno;
  31. static const char * finsh_error_string_table[] =
  32. {
  33. "No error",
  34. "Invalid token",
  35. "Expect a type",
  36. "Unknown type",
  37. "Variable exist",
  38. "Expect a operater",
  39. "Memory full",
  40. "Unknown operator",
  41. "Unknown node",
  42. "Expect a character",
  43. "Unexpect end",
  44. "Unknown token",
  45. "Float not supported",
  46. "Unknown symbol",
  47. "Null node"
  48. };
  49. int finsh_error_init()
  50. {
  51. global_errno = FINSH_ERROR_OK;
  52. return 0;
  53. }
  54. int finsh_error_set(u_char type)
  55. {
  56. global_errno = type;
  57. return 0;
  58. }
  59. u_char finsh_errno()
  60. {
  61. return global_errno;
  62. }
  63. const char* finsh_error_string(u_char type)
  64. {
  65. return finsh_error_string_table[type];
  66. }