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

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* get_paths.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tgrekov <tgrekov@student.hive.fi> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/22 05:53:12 by tgrekov #+# #+# */
/* Updated: 2024/05/20 12:27:38 by tgrekov ### ########.fr */
/* */
/* ************************************************************************** */

Definition in file get_paths.c.

#include <libft.h>
#include "../utils/utils.h"
Include dependency graph for get_paths.c:

Go to the source code of this file.

Functions

static int compare (void *a, void *b)
 Compare path string a against path string b, which will always have a trailing forward slash.
 
static void * copy (void *str)
 Duplicate a path string and append a forward slash.
 
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.
 

Function Documentation

◆ compare()

static int compare ( void *  a,
void *  b 
)
static

Compare path string a against path string b, which will always have a trailing forward slash.

Parameters
aPath string
bPreviously copied path string with trailing forward slash
Return values
int0 if identical

Definition at line 31 of file get_paths.c.

References ft_strlen(), and ft_strncmp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ copy()

static void * copy ( void *  str)
static

Duplicate a path string and append a forward slash.

Parameters
strPath string
Return values
void*Path string with trailing /

Definition at line 53 of file get_paths.c.

References err(), and ft_strjoin().

Here is the call graph for this function:
Here is the caller 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: