1
0

shell_startup.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * shell_startup.c
  3. */
  4. #include "private.h"
  5. #include <assert.h>
  6. #include "lub/string.h"
  7. /*----------------------------------------------------------- */
  8. int clish_shell_startup(clish_shell_t *this)
  9. {
  10. const char *banner;
  11. clish_context_t context;
  12. int res = 0;
  13. assert(this->startup);
  14. banner = clish_command__get_detail(this->startup);
  15. if (banner)
  16. tinyrl_printf(this->tinyrl, "%s\n", banner);
  17. context.shell = this;
  18. context.cmd = this->startup;
  19. context.pargv = NULL;
  20. /* Call log initialize */
  21. if (clish_shell__get_log(this) && this->client_hooks->log_fn)
  22. this->client_hooks->log_fn(&context, NULL, 0);
  23. /* Call startup script */
  24. res = clish_shell_execute(&context, NULL);
  25. return res;
  26. }
  27. /*----------------------------------------------------------- */
  28. void clish_shell__set_startup_view(clish_shell_t * this, const char * viewname)
  29. {
  30. clish_view_t *view;
  31. assert(this);
  32. assert(this->startup);
  33. /* Search for the view */
  34. view = clish_shell_find_view(this, viewname);
  35. assert(view);
  36. clish_command__force_view(this->startup, viewname);
  37. }
  38. /*----------------------------------------------------------- */
  39. void clish_shell__set_startup_viewid(clish_shell_t * this, const char * viewid)
  40. {
  41. assert(this);
  42. assert(this->startup);
  43. clish_command__force_viewid(this->startup, viewid);
  44. }
  45. /*----------------------------------------------------------- */
  46. void clish_shell__set_default_shebang(clish_shell_t * this, const char * shebang)
  47. {
  48. assert(this);
  49. lub_string_free(this->default_shebang);
  50. this->default_shebang = lub_string_dup(shebang);
  51. }
  52. /*----------------------------------------------------------- */
  53. const char * clish_shell__get_default_shebang(const clish_shell_t * this)
  54. {
  55. assert(this);
  56. return this->default_shebang;
  57. }
  58. /*----------------------------------------------------------- */