diff --git a/env.c b/env.c index a043a88..58309b5 100644 --- a/env.c +++ b/env.c @@ -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); -}*/ +} diff --git a/env.o b/env.o new file mode 100644 index 0000000..dc97556 Binary files /dev/null and b/env.o differ diff --git a/libftx/extra/extra.a b/libftx/extra/extra.a new file mode 100644 index 0000000..caeb9df Binary files /dev/null and b/libftx/extra/extra.a differ diff --git a/libftx/extra/ft_contain_only.o b/libftx/extra/ft_contain_only.o new file mode 100644 index 0000000..417b966 Binary files /dev/null and b/libftx/extra/ft_contain_only.o differ diff --git a/libftx/extra/ft_freer.o b/libftx/extra/ft_freer.o new file mode 100644 index 0000000..f672cf4 Binary files /dev/null and b/libftx/extra/ft_freer.o differ diff --git a/libftx/extra/ft_is_in.o b/libftx/extra/ft_is_in.o new file mode 100644 index 0000000..f00ec7d4 Binary files /dev/null and b/libftx/extra/ft_is_in.o differ diff --git a/libftx/extra/ft_random_generator.o b/libftx/extra/ft_random_generator.o new file mode 100644 index 0000000..9817b91 Binary files /dev/null and b/libftx/extra/ft_random_generator.o differ diff --git a/libftx/extra/ft_strchri.o b/libftx/extra/ft_strchri.o new file mode 100644 index 0000000..9047d03 Binary files /dev/null and b/libftx/extra/ft_strchri.o differ diff --git a/libftx/extra/ft_strcmp.o b/libftx/extra/ft_strcmp.o new file mode 100644 index 0000000..0023061 Binary files /dev/null and b/libftx/extra/ft_strcmp.o differ diff --git a/libftx/extra/ft_strfjoin.o b/libftx/extra/ft_strfjoin.o new file mode 100644 index 0000000..c47d615 Binary files /dev/null and b/libftx/extra/ft_strfjoin.o differ diff --git a/libftx/extra/ft_strgen.o b/libftx/extra/ft_strgen.o new file mode 100644 index 0000000..19f5c13 Binary files /dev/null and b/libftx/extra/ft_strgen.o differ diff --git a/libftx/extra/ft_strmerger.o b/libftx/extra/ft_strmerger.o new file mode 100644 index 0000000..b477be0 Binary files /dev/null and b/libftx/extra/ft_strmerger.o differ diff --git a/libftx/extra/ft_strndup.o b/libftx/extra/ft_strndup.o new file mode 100644 index 0000000..1866899 Binary files /dev/null and b/libftx/extra/ft_strndup.o differ diff --git a/libftx/extra/ft_tabrealloc.o b/libftx/extra/ft_tabrealloc.o new file mode 100644 index 0000000..c8fd161 Binary files /dev/null and b/libftx/extra/ft_tabrealloc.o differ diff --git a/libftx/extra/ft_ultoa_base.o b/libftx/extra/ft_ultoa_base.o new file mode 100644 index 0000000..216f89c Binary files /dev/null and b/libftx/extra/ft_ultoa_base.o differ diff --git a/libftx/gnl/get_next_line.a b/libftx/gnl/get_next_line.a new file mode 100644 index 0000000..713cdd5 Binary files /dev/null and b/libftx/gnl/get_next_line.a differ diff --git a/libftx/gnl/get_next_line.o b/libftx/gnl/get_next_line.o new file mode 100644 index 0000000..9d2cf9a Binary files /dev/null and b/libftx/gnl/get_next_line.o differ diff --git a/libftx/libft/ft_atoi.o b/libftx/libft/ft_atoi.o new file mode 100644 index 0000000..e5536f1 Binary files /dev/null and b/libftx/libft/ft_atoi.o differ diff --git a/libftx/libft/ft_bzero.o b/libftx/libft/ft_bzero.o new file mode 100644 index 0000000..01f7b44 Binary files /dev/null and b/libftx/libft/ft_bzero.o differ diff --git a/libftx/libft/ft_calloc.o b/libftx/libft/ft_calloc.o new file mode 100644 index 0000000..692fcbf Binary files /dev/null and b/libftx/libft/ft_calloc.o differ diff --git a/libftx/libft/ft_isalnum.o b/libftx/libft/ft_isalnum.o new file mode 100644 index 0000000..1539030 Binary files /dev/null and b/libftx/libft/ft_isalnum.o differ diff --git a/libftx/libft/ft_isalpha.o b/libftx/libft/ft_isalpha.o new file mode 100644 index 0000000..d9396fc Binary files /dev/null and b/libftx/libft/ft_isalpha.o differ diff --git a/libftx/libft/ft_isascii.o b/libftx/libft/ft_isascii.o new file mode 100644 index 0000000..7265176 Binary files /dev/null and b/libftx/libft/ft_isascii.o differ diff --git a/libftx/libft/ft_isdigit.o b/libftx/libft/ft_isdigit.o new file mode 100644 index 0000000..e2270cf Binary files /dev/null and b/libftx/libft/ft_isdigit.o differ diff --git a/libftx/libft/ft_isprint.o b/libftx/libft/ft_isprint.o new file mode 100644 index 0000000..406bdbf Binary files /dev/null and b/libftx/libft/ft_isprint.o differ diff --git a/libftx/libft/ft_itoa.o b/libftx/libft/ft_itoa.o new file mode 100644 index 0000000..c013963 Binary files /dev/null and b/libftx/libft/ft_itoa.o differ diff --git a/libftx/libft/ft_memchr.o b/libftx/libft/ft_memchr.o new file mode 100644 index 0000000..f264816 Binary files /dev/null and b/libftx/libft/ft_memchr.o differ diff --git a/libftx/libft/ft_memcmp.o b/libftx/libft/ft_memcmp.o new file mode 100644 index 0000000..54b51b8 Binary files /dev/null and b/libftx/libft/ft_memcmp.o differ diff --git a/libftx/libft/ft_memcpy.o b/libftx/libft/ft_memcpy.o new file mode 100644 index 0000000..5217585 Binary files /dev/null and b/libftx/libft/ft_memcpy.o differ diff --git a/libftx/libft/ft_memmove.o b/libftx/libft/ft_memmove.o new file mode 100644 index 0000000..eab259c Binary files /dev/null and b/libftx/libft/ft_memmove.o differ diff --git a/libftx/libft/ft_memset.o b/libftx/libft/ft_memset.o new file mode 100644 index 0000000..35fb8a7 Binary files /dev/null and b/libftx/libft/ft_memset.o differ diff --git a/libftx/libft/ft_putchar_fd.o b/libftx/libft/ft_putchar_fd.o new file mode 100644 index 0000000..12b4285 Binary files /dev/null and b/libftx/libft/ft_putchar_fd.o differ diff --git a/libftx/libft/ft_putendl_fd.o b/libftx/libft/ft_putendl_fd.o new file mode 100644 index 0000000..6c8c4e3 Binary files /dev/null and b/libftx/libft/ft_putendl_fd.o differ diff --git a/libftx/libft/ft_putnbr_fd.o b/libftx/libft/ft_putnbr_fd.o new file mode 100644 index 0000000..13a08a2 Binary files /dev/null and b/libftx/libft/ft_putnbr_fd.o differ diff --git a/libftx/libft/ft_putstr_fd.o b/libftx/libft/ft_putstr_fd.o new file mode 100644 index 0000000..690c6b7 Binary files /dev/null and b/libftx/libft/ft_putstr_fd.o differ diff --git a/libftx/libft/ft_split.o b/libftx/libft/ft_split.o new file mode 100644 index 0000000..4194ea3 Binary files /dev/null and b/libftx/libft/ft_split.o differ diff --git a/libftx/libft/ft_strchr.o b/libftx/libft/ft_strchr.o new file mode 100644 index 0000000..8d96c2a Binary files /dev/null and b/libftx/libft/ft_strchr.o differ diff --git a/libftx/libft/ft_strdup.o b/libftx/libft/ft_strdup.o new file mode 100644 index 0000000..2de40af Binary files /dev/null and b/libftx/libft/ft_strdup.o differ diff --git a/libftx/libft/ft_striteri.o b/libftx/libft/ft_striteri.o new file mode 100644 index 0000000..65ba85b Binary files /dev/null and b/libftx/libft/ft_striteri.o differ diff --git a/libftx/libft/ft_strjoin.o b/libftx/libft/ft_strjoin.o new file mode 100644 index 0000000..6e9755d Binary files /dev/null and b/libftx/libft/ft_strjoin.o differ diff --git a/libftx/libft/ft_strlcat.o b/libftx/libft/ft_strlcat.o new file mode 100644 index 0000000..2ed02b5 Binary files /dev/null and b/libftx/libft/ft_strlcat.o differ diff --git a/libftx/libft/ft_strlcpy.o b/libftx/libft/ft_strlcpy.o new file mode 100644 index 0000000..7909106 Binary files /dev/null and b/libftx/libft/ft_strlcpy.o differ diff --git a/libftx/libft/ft_strlen.o b/libftx/libft/ft_strlen.o new file mode 100644 index 0000000..a1a0894 Binary files /dev/null and b/libftx/libft/ft_strlen.o differ diff --git a/libftx/libft/ft_strmapi.o b/libftx/libft/ft_strmapi.o new file mode 100644 index 0000000..df452ae Binary files /dev/null and b/libftx/libft/ft_strmapi.o differ diff --git a/libftx/libft/ft_strncmp.o b/libftx/libft/ft_strncmp.o new file mode 100644 index 0000000..4bcd226 Binary files /dev/null and b/libftx/libft/ft_strncmp.o differ diff --git a/libftx/libft/ft_strnstr.o b/libftx/libft/ft_strnstr.o new file mode 100644 index 0000000..b669955 Binary files /dev/null and b/libftx/libft/ft_strnstr.o differ diff --git a/libftx/libft/ft_strrchr.o b/libftx/libft/ft_strrchr.o new file mode 100644 index 0000000..8e739d5 Binary files /dev/null and b/libftx/libft/ft_strrchr.o differ diff --git a/libftx/libft/ft_strtrim.o b/libftx/libft/ft_strtrim.o new file mode 100644 index 0000000..51e2f50 Binary files /dev/null and b/libftx/libft/ft_strtrim.o differ diff --git a/libftx/libft/ft_substr.o b/libftx/libft/ft_substr.o new file mode 100644 index 0000000..da7cab4 Binary files /dev/null and b/libftx/libft/ft_substr.o differ diff --git a/libftx/libft/ft_tolower.o b/libftx/libft/ft_tolower.o new file mode 100644 index 0000000..691cd4f Binary files /dev/null and b/libftx/libft/ft_tolower.o differ diff --git a/libftx/libft/ft_toupper.o b/libftx/libft/ft_toupper.o new file mode 100644 index 0000000..d1a9134 Binary files /dev/null and b/libftx/libft/ft_toupper.o differ diff --git a/libftx/libft/libft.a b/libftx/libft/libft.a new file mode 100644 index 0000000..64fb516 Binary files /dev/null and b/libftx/libft/libft.a differ diff --git a/libftx/libftx.a b/libftx/libftx.a new file mode 100644 index 0000000..6919e75 Binary files /dev/null and b/libftx/libftx.a differ diff --git a/libftx/printf/ft_dprintX.o b/libftx/printf/ft_dprintX.o new file mode 100644 index 0000000..7c0bc3c Binary files /dev/null and b/libftx/printf/ft_dprintX.o differ diff --git a/libftx/printf/ft_dprintarg.o b/libftx/printf/ft_dprintarg.o new file mode 100644 index 0000000..b3e6c91 Binary files /dev/null and b/libftx/printf/ft_dprintarg.o differ diff --git a/libftx/printf/ft_dprintflag.o b/libftx/printf/ft_dprintflag.o new file mode 100644 index 0000000..52149fd Binary files /dev/null and b/libftx/printf/ft_dprintflag.o differ diff --git a/libftx/printf/ft_dprintl_base.o b/libftx/printf/ft_dprintl_base.o new file mode 100644 index 0000000..3da300c Binary files /dev/null and b/libftx/printf/ft_dprintl_base.o differ diff --git a/libftx/printf/ft_dprintptr.o b/libftx/printf/ft_dprintptr.o new file mode 100644 index 0000000..720b848 Binary files /dev/null and b/libftx/printf/ft_dprintptr.o differ diff --git a/libftx/printf/ft_dprintstrtab.o b/libftx/printf/ft_dprintstrtab.o new file mode 100644 index 0000000..d3ce17f Binary files /dev/null and b/libftx/printf/ft_dprintstrtab.o differ diff --git a/libftx/printf/ft_dprintul.o b/libftx/printf/ft_dprintul.o new file mode 100644 index 0000000..d964808 Binary files /dev/null and b/libftx/printf/ft_dprintul.o differ diff --git a/libftx/printf/ft_dprintul_base.o b/libftx/printf/ft_dprintul_base.o new file mode 100644 index 0000000..9b9e65c Binary files /dev/null and b/libftx/printf/ft_dprintul_base.o differ diff --git a/libftx/printf/ft_dprintx.o b/libftx/printf/ft_dprintx.o new file mode 100644 index 0000000..6c83e28 Binary files /dev/null and b/libftx/printf/ft_dprintx.o differ diff --git a/libftx/printf/ft_eprintf.o b/libftx/printf/ft_eprintf.o new file mode 100644 index 0000000..6e841d1 Binary files /dev/null and b/libftx/printf/ft_eprintf.o differ diff --git a/libftx/printf/ft_isarg.o b/libftx/printf/ft_isarg.o new file mode 100644 index 0000000..07990c1 Binary files /dev/null and b/libftx/printf/ft_isarg.o differ diff --git a/libftx/printf/ft_isdigit.o b/libftx/printf/ft_isdigit.o new file mode 100644 index 0000000..0b73c21 Binary files /dev/null and b/libftx/printf/ft_isdigit.o differ diff --git a/libftx/printf/ft_printf.a b/libftx/printf/ft_printf.a new file mode 100644 index 0000000..13f9344 Binary files /dev/null and b/libftx/printf/ft_printf.a differ diff --git a/libftx/printf/ft_printf.o b/libftx/printf/ft_printf.o new file mode 100644 index 0000000..375692f Binary files /dev/null and b/libftx/printf/ft_printf.o differ diff --git a/libftx/printf/ft_putchar_fd.o b/libftx/printf/ft_putchar_fd.o new file mode 100644 index 0000000..fd011a7 Binary files /dev/null and b/libftx/printf/ft_putchar_fd.o differ diff --git a/libftx/printf/ft_putstr_fd.o b/libftx/printf/ft_putstr_fd.o new file mode 100644 index 0000000..c1d1ae9 Binary files /dev/null and b/libftx/printf/ft_putstr_fd.o differ diff --git a/libftx/printf/ft_skipflag.o b/libftx/printf/ft_skipflag.o new file mode 100644 index 0000000..a9b81e5 Binary files /dev/null and b/libftx/printf/ft_skipflag.o differ diff --git a/libftx/printf/ft_strlen.o b/libftx/printf/ft_strlen.o new file mode 100644 index 0000000..6912c72 Binary files /dev/null and b/libftx/printf/ft_strlen.o differ diff --git a/libftx/printf/ft_vdprintf.o b/libftx/printf/ft_vdprintf.o new file mode 100644 index 0000000..e99c158 Binary files /dev/null and b/libftx/printf/ft_vdprintf.o differ diff --git a/minishell b/minishell new file mode 100755 index 0000000..c1bc176 Binary files /dev/null and b/minishell differ diff --git a/utils/ft_getstr.o b/utils/ft_getstr.o new file mode 100644 index 0000000..ca97c05 Binary files /dev/null and b/utils/ft_getstr.o differ diff --git a/utils/ft_is_in_quote.o b/utils/ft_is_in_quote.o new file mode 100644 index 0000000..3c3b6ac Binary files /dev/null and b/utils/ft_is_in_quote.o differ diff --git a/utils/ft_strnchr.o b/utils/ft_strnchr.o new file mode 100644 index 0000000..8b0ac81 Binary files /dev/null and b/utils/ft_strnchr.o differ diff --git a/utils/ft_strncpy.o b/utils/ft_strncpy.o new file mode 100644 index 0000000..c5a7006 Binary files /dev/null and b/utils/ft_strncpy.o differ diff --git a/utils/ft_strreplace.c b/utils/ft_strreplace.c index 8a2a2ba..1b25449 100644 --- a/utils/ft_strreplace.c +++ b/utils/ft_strreplace.c @@ -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); } diff --git a/utils/ft_strreplace.o b/utils/ft_strreplace.o new file mode 100644 index 0000000..1422e58 Binary files /dev/null and b/utils/ft_strreplace.o differ