1
0

tclish_script_callback.c 860 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 "tcl_private.h"
  16. /*--------------------------------------------------------- */
  17. bool_t tclish_script_callback(clish_shell_t * shell,
  18. const clish_command_t * cmd, const char *script, char ** out)
  19. {
  20. bool_t result = BOOL_TRUE;
  21. tclish_cookie_t *this = clish_shell__get_client_cookie(shell);
  22. if (Tcl_CommandComplete(script)) {
  23. if (TCL_OK != Tcl_EvalEx(this->interp,
  24. script,
  25. strlen(script), TCL_EVAL_GLOBAL)) {
  26. result = BOOL_FALSE;
  27. }
  28. tclish_show_result(this->interp);
  29. }
  30. return result;
  31. }
  32. /*--------------------------------------------------------- */
  33. #endif /* HAVE_LIBTCL */