This commit is contained in:
Etienne Rey-bethbeder 2023-02-14 13:54:41 +01:00
parent 7b3389c75d
commit afaf34f869
79 changed files with 38 additions and 7 deletions

37
env.c
View File

@ -169,6 +169,30 @@ char *get_value_key(char *key, t_list **head)
return (NULL);
}
int set_value_key(char *key, t_list **head, char *str)
{
t_list *current;
char *temp;
size_t len;
current = *head;
while (current != NULL)
{
if (is_start(current->content, key))
{
len = ft_strlen(current->content);
temp = current->content;
current->content = ft_strreplace(temp, str, ft_strnchr(temp, '=') + 1, len - get_index(temp, '=') - 1);
free(temp);
if (current->content == NULL)
return (1);
break ;
}
current = current->next;
}
return (0);
}
t_list **init_env(char **env)
{
t_list **head;
@ -184,11 +208,16 @@ t_list **init_env(char **env)
return (head);
}
/*int main(int argc, char *argv[], char **env)
int main(int argc, char *argv[], char **env)
{
t_list **i_env;
(void)argc;
(void)argv;
ft_putstr_fd(get_value_index(10, init_env(env)), 1);
//print_env(init_env(env), 1);
i_env = init_env(env);
ft_putstr_fd(get_value_key("PATH", i_env), 1);
ft_putstr_fd("/n", 1);
set_value_key("PATH", i_env, "BITE");
ft_putstr_fd(get_value_key("PATH", i_env), 1);
return (0);
}*/
}

BIN
env.o Normal file

Binary file not shown.

BIN
libftx/extra/extra.a Normal file

Binary file not shown.

Binary file not shown.

BIN
libftx/extra/ft_freer.o Normal file

Binary file not shown.

BIN
libftx/extra/ft_is_in.o Normal file

Binary file not shown.

Binary file not shown.

BIN
libftx/extra/ft_strchri.o Normal file

Binary file not shown.

BIN
libftx/extra/ft_strcmp.o Normal file

Binary file not shown.

BIN
libftx/extra/ft_strfjoin.o Normal file

Binary file not shown.

BIN
libftx/extra/ft_strgen.o Normal file

Binary file not shown.

BIN
libftx/extra/ft_strmerger.o Normal file

Binary file not shown.

BIN
libftx/extra/ft_strndup.o Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
libftx/gnl/get_next_line.a Normal file

Binary file not shown.

BIN
libftx/gnl/get_next_line.o Normal file

Binary file not shown.

BIN
libftx/libft/ft_atoi.o Normal file

Binary file not shown.

BIN
libftx/libft/ft_bzero.o Normal file

Binary file not shown.

BIN
libftx/libft/ft_calloc.o Normal file

Binary file not shown.

BIN
libftx/libft/ft_isalnum.o Normal file

Binary file not shown.

BIN
libftx/libft/ft_isalpha.o Normal file

Binary file not shown.

BIN
libftx/libft/ft_isascii.o Normal file

Binary file not shown.

BIN
libftx/libft/ft_isdigit.o Normal file

Binary file not shown.

BIN
libftx/libft/ft_isprint.o Normal file

Binary file not shown.

BIN
libftx/libft/ft_itoa.o Normal file

Binary file not shown.

BIN
libftx/libft/ft_memchr.o Normal file

Binary file not shown.

BIN
libftx/libft/ft_memcmp.o Normal file

Binary file not shown.

BIN
libftx/libft/ft_memcpy.o Normal file

Binary file not shown.

BIN
libftx/libft/ft_memmove.o Normal file

Binary file not shown.

BIN
libftx/libft/ft_memset.o Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
libftx/libft/ft_putnbr_fd.o Normal file

Binary file not shown.

BIN
libftx/libft/ft_putstr_fd.o Normal file

Binary file not shown.

BIN
libftx/libft/ft_split.o Normal file

Binary file not shown.

BIN
libftx/libft/ft_strchr.o Normal file

Binary file not shown.

BIN
libftx/libft/ft_strdup.o Normal file

Binary file not shown.

BIN
libftx/libft/ft_striteri.o Normal file

Binary file not shown.

BIN
libftx/libft/ft_strjoin.o Normal file

Binary file not shown.

BIN
libftx/libft/ft_strlcat.o Normal file

Binary file not shown.

BIN
libftx/libft/ft_strlcpy.o Normal file

Binary file not shown.

BIN
libftx/libft/ft_strlen.o Normal file

Binary file not shown.

BIN
libftx/libft/ft_strmapi.o Normal file

Binary file not shown.

BIN
libftx/libft/ft_strncmp.o Normal file

Binary file not shown.

BIN
libftx/libft/ft_strnstr.o Normal file

Binary file not shown.

BIN
libftx/libft/ft_strrchr.o Normal file

Binary file not shown.

BIN
libftx/libft/ft_strtrim.o Normal file

Binary file not shown.

BIN
libftx/libft/ft_substr.o Normal file

Binary file not shown.

BIN
libftx/libft/ft_tolower.o Normal file

Binary file not shown.

BIN
libftx/libft/ft_toupper.o Normal file

Binary file not shown.

BIN
libftx/libft/libft.a Normal file

Binary file not shown.

BIN
libftx/libftx.a Normal file

Binary file not shown.

BIN
libftx/printf/ft_dprintX.o Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
libftx/printf/ft_dprintul.o Normal file

Binary file not shown.

Binary file not shown.

BIN
libftx/printf/ft_dprintx.o Normal file

Binary file not shown.

BIN
libftx/printf/ft_eprintf.o Normal file

Binary file not shown.

BIN
libftx/printf/ft_isarg.o Normal file

Binary file not shown.

BIN
libftx/printf/ft_isdigit.o Normal file

Binary file not shown.

BIN
libftx/printf/ft_printf.a Normal file

Binary file not shown.

BIN
libftx/printf/ft_printf.o Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
libftx/printf/ft_skipflag.o Normal file

Binary file not shown.

BIN
libftx/printf/ft_strlen.o Normal file

Binary file not shown.

BIN
libftx/printf/ft_vdprintf.o Normal file

Binary file not shown.

BIN
minishell Executable file

Binary file not shown.

BIN
utils/ft_getstr.o Normal file

Binary file not shown.

BIN
utils/ft_is_in_quote.o Normal file

Binary file not shown.

BIN
utils/ft_strnchr.o Normal file

Binary file not shown.

BIN
utils/ft_strncpy.o Normal file

Binary file not shown.

View File

@ -1,17 +1,19 @@
#include "utils.h"
char *ft_strreplace(char *str, char *fill, size_t start, size_t stop)
int ft_strreplace(char **str, char *fill, size_t start, size_t stop)
{
char *out;
size_t sum;
out = malloc((ft_strlen(str) + ft_strlen(fill) - (stop - start) + 1 * sizeof(char)));
if (out == NULL)
return (NULL);
return (1);
ft_strncpy(out, str, start);
ft_strncpy(out + start, fill, ft_strlen(fill));
sum = start + ft_strlen(fill);
ft_strncpy(out + sum, str + stop, ft_strlen(str) - stop);
out[sum + ft_strlen(str) - stop] = '\0';
return (out);
free(*str);
*str = out;
return (0);
}

BIN
utils/ft_strreplace.o Normal file

Binary file not shown.