minishell
Minishell Project for École 42
Loading...
Searching...
No Matches
process_in_heredoc.c File Reference

Subfunctions of process_in_heredoc() for handling here-documents and input redirection. More...

#include "minishell.h"
Include dependency graph for process_in_heredoc.c:

Functions

bool get_input (int fd, char *delimiter)
 Reads input for a here-document until a specified delimiter.
 
int create_heredoc (char *delimiter)
 Creates a here-document file and gathers input.
 
bool open_inputfile (t_executor *current, t_lexer_list *lexer)
 Handles opening an input file.
 

Detailed Description

Subfunctions of process_in_heredoc() for handling here-documents and input redirection.

Function Documentation

◆ create_heredoc()

int create_heredoc ( char *  delimiter)

Creates a here-document file and gathers input.

Creates a temporary file for a here-document, gathers input for it by calling get_input(). Returns a file descriptor to the created file.

Parameters
delimiterThe delimiter that signals the end of the here-document.
Returns
The file descriptor of the created here-document, or -1 on error.

◆ get_input()

bool get_input ( int  fd,
char *  delimiter 
)

Reads input for a here-document until a specified delimiter.

Reads input from the user, displaying a prompt, until the specified delimiter is entered. The input is written to the given file descriptor. Also handles ctrl-d (end-of-file from readline).

Parameters
fdThe file descriptor to write the input to.
delimiterThe delimiter that signals the end of the here-document.
Returns
True if successful, false on error.

◆ open_inputfile()

bool open_inputfile ( t_executor current,
t_lexer_list lexer 
)

Handles opening an input file.

Handles opening an input file for the given t_executor node, based on the given lexer list token type. It supports input redirection and here-document.

Parameters
currentA pointer to the current t_executor node.
lexerA pointer to the current t_lexer_list node.
Returns
True if the file is opened successfully, false on error.