1
0

shell_pop_file.c 572 B

12345678910111213141516171819202122232425262728
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include "private.h"
  4. bool_t clish_shell_pop_file(clish_shell_t * this)
  5. {
  6. bool_t result = BOOL_FALSE;
  7. clish_shell_file_t *node = this->current_file;
  8. if (node) {
  9. /* remove the current file from the stack... */
  10. this->current_file = node->next;
  11. /* and close the current file...
  12. */
  13. fclose(node->file);
  14. if (node->next) {
  15. /* now switch the terminal's input stream */
  16. tinyrl__set_istream(this->tinyrl, node->next->file);
  17. result = BOOL_TRUE;
  18. }
  19. /* and free up the memory */
  20. free(node);
  21. }
  22. return result;
  23. }