shell_var.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * shell_expand.c
  3. */
  4. #include <stdlib.h>
  5. #include <assert.h>
  6. #include "lub/string.h"
  7. #include "private.h"
  8. /*--------------------------------------------------------- */
  9. void clish_shell_insert_var(clish_shell_t *this, clish_var_t *var)
  10. {
  11. (void)lub_bintree_insert(&this->var_tree, var);
  12. }
  13. /*--------------------------------------------------------- */
  14. clish_var_t *clish_shell_find_var(clish_shell_t *this, const char *name)
  15. {
  16. return lub_bintree_find(&this->var_tree, name);
  17. }
  18. /*----------------------------------------------------------- */
  19. char * clish_shell__expand_text(const clish_shell_t *this,
  20. clish_command_t *cmd, clish_pargv_t *pargv, const char *text)
  21. {
  22. assert(this);
  23. if (!text)
  24. return NULL;
  25. return clish_variable_expand(text, this->viewid, cmd, pargv);
  26. }
  27. /*----------------------------------------------------------- */
  28. char * clish_shell__expand_variable(const clish_shell_t *this,
  29. clish_command_t *cmd, clish_pargv_t *pargv, const char *var)
  30. {
  31. assert(this);
  32. if (!var)
  33. return NULL;
  34. return clish_variable__get_value(var, this->viewid, cmd, pargv);
  35. }
  36. /*--------------------------------------------------------- */
  37. const char *clish_shell__get_viewid(const clish_shell_t *this)
  38. {
  39. assert(this);
  40. return this->viewid;
  41. }
  42. /*----------------------------------------------------------- */