1
0

shell_startup.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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_create_view(this, viewname, NULL);
  35. clish_command__force_view(this->startup, view);
  36. }
  37. /*----------------------------------------------------------- */
  38. void clish_shell__set_startup_viewid(clish_shell_t * this, const char * viewid)
  39. {
  40. assert(this);
  41. assert(this->startup);
  42. clish_command__force_viewid(this->startup, viewid);
  43. }
  44. /*----------------------------------------------------------- */
  45. void clish_shell__set_default_shebang(clish_shell_t * this, const char * shebang)
  46. {
  47. assert(this);
  48. lub_string_free(this->default_shebang);
  49. this->default_shebang = lub_string_dup(shebang);
  50. }
  51. /*----------------------------------------------------------- */
  52. const char * clish_shell__get_default_shebang(const clish_shell_t * this)
  53. {
  54. assert(this);
  55. return this->default_shebang;
  56. }
  57. /*----------------------------------------------------------- */