tgrekov-pipex
HIVE pipex May 2024
Loading...
Searching...
No Matches
main.c File Reference

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tgrekov <tgrekov@student.hive.fi> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/02 13:59:01 by tgrekov #+# #+# */
/* Updated: 2024/05/20 12:27:07 by tgrekov ### ########.fr */
/* */
/* ************************************************************************** */

Definition in file main.c.

#include <fcntl.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>
#include "../mandatory/utils/utils.h"
#include <libft.h>
#include <ft_printf.h>
Include dependency graph for main.c:

Go to the source code of this file.

Functions

int here_doc (char *limiter, int *in_out)
 Capture multiline input from stdin and write to a pipe readable from in_out[0] until a line containing only limiter is reached.
 
char ** get_paths (char **envp)
 Create a null-terminated, unique array of paths from the environment pointer envp. Trailing forward slashes included free of charge.
 
int dispatcher (int n, char ***str_arrs, int *in_out)
 Dispatch n child processes with argument strings str_arrs[1][i], environment pointer str_arrs[2], where stdin for the first process is in_out[0] and stdout for the last process is in_out[1].
 
static void _input (int argc, char **argv, int *is_here_doc, int *trunc_append)
 Check if in here_doc mode, verify arguments count accordingly, and set append or truncate accordingly.
 

Function Documentation

◆ _input()

static void _input ( int  argc,
char **  argv,
int *  is_here_doc,
int *  trunc_append 
)
static

Check if in here_doc mode, verify arguments count accordingly, and set append or truncate accordingly.

Parameters
argc
argv
is_here_doc
trunc_append

Definition at line 41 of file main.c.

References ft_printf(), and ft_strncmp().

Here is the call graph for this function:

◆ dispatcher()

int dispatcher ( int  n,
char ***  str_arrs,
int *  in_out 
)

Dispatch n child processes with argument strings str_arrs[1][i], environment pointer str_arrs[2], where stdin for the first process is in_out[0] and stdout for the last process is in_out[1].

Parameters
nNumber of processes
str_arrsNull-terminated arrays paths, argv, and envp
in_outstdin for the first process and stdout for the last process
Return values
intExit code of the last process, if available, else 1, or if an error was encountered in the parent process, 1.

Definition at line 85 of file dispatcher.c.

References err().

Here is the call graph for this function:

◆ get_paths()

char ** get_paths ( char **  envp)

Create a null-terminated, unique array of paths from the environment pointer envp. Trailing forward slashes included free of charge.

Parameters
envpEnvironment pointer
Return values
char**Null-terminated, deduplicated array of paths from envp, with trailing /

Definition at line 73 of file get_paths.c.

References arr_free(), compare(), copy(), dedupe(), err(), ft_split(), and ft_strncmp().

Here is the call graph for this function:

◆ here_doc()

int here_doc ( char *  limiter,
int *  in_out 
)

Capture multiline input from stdin and write to a pipe readable from in_out[0] until a line containing only limiter is reached.

Parameters
limiterCharacter to stop reading on
in_outInput filedes, output filedes
Return values
int0 on failure, 1 on success

Definition at line 46 of file here_doc.c.

References err(), ft_printf(), ft_strlen(), and get_next_line().

Here is the call graph for this function: