finsh_var.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. * Variable implementation in finsh shell.
  3. *
  4. * COPYRIGHT (C) 2006 - 2013, RT-Thread Development Team
  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. #ifndef __FINSH_VAR_H__
  30. #define __FINSH_VAR_H__
  31. #include <finsh.h>
  32. /*
  33. * The variable in finsh is put in data segment as a global variable.
  34. * The 'finsh_var' structure presents the structure of variable in data segment.
  35. */
  36. struct finsh_var
  37. {
  38. char name[FINSH_NAME_MAX + 1]; /* the name of variable */
  39. u_char type; /* the type of variable */
  40. /* variable value */
  41. union {
  42. char char_value;
  43. short short_value;
  44. int int_value;
  45. long long_value;
  46. void* ptr;
  47. }value;
  48. };
  49. extern struct finsh_var global_variable[];
  50. int finsh_var_init(void);
  51. int finsh_var_insert(const char* name, int type);
  52. int finsh_var_delete(const char* name);
  53. struct finsh_var* finsh_var_lookup(const char* name);
  54. #endif