1
0

tclish_script_callback.c 820 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. /*
  2. * tclish_script_callback.c
  3. *
  4. *
  5. * Callback hook to action a TCL script.
  6. */
  7. #ifdef HAVE_CONFIG_H
  8. #include "config.h"
  9. #endif /* HAVE_CONFIG_H */
  10. #ifdef HAVE_LIBTCL
  11. #include <stdio.h>
  12. #include <string.h>
  13. #include <stdlib.h>
  14. #include <tcl.h>
  15. #include "private.h"
  16. /*--------------------------------------------------------- */
  17. bool_t tclish_script_callback(const clish_shell_t * shell, const char *script)
  18. {
  19. bool_t result = BOOL_TRUE;
  20. tclish_cookie_t *this = clish_shell__get_client_cookie(shell);
  21. if (Tcl_CommandComplete(script)) {
  22. if (TCL_OK != Tcl_EvalEx(this->interp,
  23. script,
  24. strlen(script), TCL_EVAL_GLOBAL)) {
  25. result = BOOL_FALSE;
  26. }
  27. tclish_show_result(this->interp);
  28. }
  29. return result;
  30. }
  31. /*--------------------------------------------------------- */
  32. #endif /* HAVE_LIBTCL */