diff --git a/src/executing/here_doc/here_doc.c b/src/executing/here_doc/here_doc.c index c1c8d25..eb8582e 100644 --- a/src/executing/here_doc/here_doc.c +++ b/src/executing/here_doc/here_doc.c @@ -6,7 +6,7 @@ /* By: khais +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/03/07 11:42:29 by khais #+# #+# */ -/* Updated: 2025/03/11 11:22:54 by khais ### ########.fr */ +/* Updated: 2025/03/11 11:24:30 by khais ### ########.fr */ /* */ /* ************************************************************************** */ @@ -55,3 +55,17 @@ char *here_doc_random_filename(void) close(randomfd); return (ft_buffer_to_charptr(filename)); } + +/* +** Read from STDIN into some file until a line that is exactly equal to the +** marker is read. +** +** Then unlink the file, and return a filedescriptor to it, seeked to the start. +** +** If NULL is given as argument, or any other error occurs, return -1. +*/ +int here_doc(t_worddesc *marker) +{ + (void)marker; + return (-1); +} diff --git a/src/executing/here_doc/here_doc.h b/src/executing/here_doc/here_doc.h index 9b8ba1c..8d60f16 100644 --- a/src/executing/here_doc/here_doc.h +++ b/src/executing/here_doc/here_doc.h @@ -6,13 +6,16 @@ /* By: khais +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/03/07 11:41:27 by khais #+# #+# */ -/* Updated: 2025/03/11 10:58:19 by khais ### ########.fr */ +/* Updated: 2025/03/11 11:18:47 by khais ### ########.fr */ /* */ /* ************************************************************************** */ #ifndef HERE_DOC_H # define HERE_DOC_H +# include "../../parser/worddesc/worddesc.h" + +int here_doc(t_worddesc *marker); char *here_doc_random_filename(void); #endif // HERE_DOC_H diff --git a/tests/test_here_doc.c b/tests/test_here_doc.c index 40d4255..1c5019d 100644 --- a/tests/test_here_doc.c +++ b/tests/test_here_doc.c @@ -6,7 +6,7 @@ /* By: khais +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/03/07 11:43:32 by khais #+# #+# */ -/* Updated: 2025/03/10 18:23:36 by khais ### ########.fr */ +/* Updated: 2025/03/11 11:19:16 by khais ### ########.fr */ /* */ /* ************************************************************************** */ @@ -34,7 +34,15 @@ static void test_here_doc_filename_generation(void) do_leak_check(); } +static void test_here_doc_null_args(void) +{ + ft_dprintf(STDERR_FILENO, "==> %s <==\n", __FUNCTION__); + assert(-1 == here_doc(NULL)); + do_leak_check(); +} + int main(void) { test_here_doc_filename_generation(); + test_here_doc_null_args(); return (0); }