1
0

shell_push_file.c 613 B

123456789101112131415161718192021222324252627
  1. #include <stdlib.h>
  2. #include "private.h"
  3. bool_t
  4. clish_shell_push_file(clish_shell_t * this, FILE * file, bool_t stop_on_error)
  5. {
  6. /* allocate a control node */
  7. clish_shell_file_t *node = malloc(sizeof(clish_shell_file_t));
  8. bool_t result = BOOL_TRUE;
  9. if (NULL != node) {
  10. /* intialise the node */
  11. node->file = file;
  12. node->stop_on_error = stop_on_error;
  13. node->next = this->current_file;
  14. /* put the node at the top of the file stack */
  15. this->current_file = node;
  16. /* now switch the terminal's input stream */
  17. tinyrl__set_istream(this->tinyrl, file);
  18. result = BOOL_TRUE;
  19. }
  20. return result;
  21. }