var_dump.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * var_dump.c
  3. */
  4. #include "private.h"
  5. #include "clish/action.h"
  6. #include "lub/xml2c.h"
  7. #ifdef DEBUG
  8. #include "lub/dump.h"
  9. /*--------------------------------------------------------- */
  10. void clish_var_dump(const clish_var_t *this)
  11. {
  12. lub_dump_printf("var(%p)\n", this);
  13. lub_dump_indent();
  14. lub_dump_printf("name : %s\n", LUB_DUMP_STR(this->name));
  15. lub_dump_printf("dynamic : %s\n", LUB_DUMP_BOOL(this->dynamic));
  16. lub_dump_printf("value : %s\n", LUB_DUMP_STR(this->value));
  17. clish_action_dump(this->action);
  18. lub_dump_undent();
  19. }
  20. /*--------------------------------------------------------- */
  21. #endif /* DEBUG */
  22. void clish_var_xml2c(clish_var_t *this)
  23. {
  24. char *esc_name = xml2c_esc(clish_var__get_name(this));
  25. bool_t dynamic = clish_var__get_dynamic(this);
  26. char *esc_value = xml2c_esc(clish_var__get_value(this));
  27. clish_action_t *action;
  28. printf("var = clish_var_new(\"%s\");\n", XML2C_STR(esc_name)); /* name */
  29. printf("lub_bintree_insert(&shell->var_tree, var);\n"); /* Insert VAR to list */
  30. printf("clish_var__set_dynamic(var, %s);\n", XML2C_BOOL(dynamic)); /* dynamic */
  31. if (esc_value)
  32. printf("clish_var__set_value(var, \"%s\");\n", XML2C_STR(esc_value)); /* value */
  33. action = clish_var__get_action(this);
  34. if (action) {
  35. printf("action = clish_var__get_action(var);\n");
  36. clish_action_xml2c(action);
  37. }
  38. printf("\n");
  39. lub_string_free(esc_name);
  40. lub_string_free(esc_value);
  41. }