diff --git a/.env.c.swo b/.env.c.swo deleted file mode 100644 index 7b3c45d..0000000 Binary files a/.env.c.swo and /dev/null differ diff --git a/argprinter b/argprinter deleted file mode 100755 index 11c8a1d..0000000 Binary files a/argprinter and /dev/null differ diff --git a/env.c b/env.c index b7a4577..a043a88 100644 --- a/env.c +++ b/env.c @@ -6,17 +6,28 @@ /* By: erey-bet +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/02/02 14:39:56 by erey-bet #+# #+# */ -/* Updated: 2023/02/02 18:25:51 by erey-bet ### ########.fr */ +/* Updated: 2023/02/03 16:04:16 by erey-bet ### ########.fr */ /* */ /* ************************************************************************** */ -#include "env.h" -#include "libftx/libftx.h" +#include "minishell.h" + +int get_index(char *s, char c) +{ + int i; + + i = -1; + while (s[++i]) + if (s[i] == c) + return (i); + return (-1); +} void print_export(t_list **head, int fd) { t_list *current; char *ctn; + int v; current = *head; while (current != NULL) @@ -24,9 +35,12 @@ void print_export(t_list **head, int fd) ctn = current->content; if (*(ft_strchr(ctn, '=') - 1) != '_') { + v = get_index(ctn, '='); write(fd, "declare -x ", 11); - ft_putstr_fd(fd, ctn); - write(fd, "\n", 1); + write(fd, ctn, v + 1); + write(fd, "\"", 1); + ft_putstr_fd(ctn + v + 1, fd); + write(fd, "\"\n", 2); } current = current->next; } @@ -39,7 +53,7 @@ void print_env(t_list **head, int fd) current = *head; while (current != NULL) { - ft_putstr_fd(fd, current->content); + ft_putstr_fd(current->content, fd); write(fd, "\n", 1); current = current->next; } @@ -111,6 +125,50 @@ void add_sort(t_list **head, char *str) } } +char *get_value_index(int index, t_list **head) +{ + t_list *current; + int i; + + current = *head; + i = -1; + while (current != NULL && ++i != index) + current = current->next; + if (i == index) + return (ft_strchr(current->content, '=') + 1); + return (NULL); +} + +int is_start(char *big, char *little) +{ + int i; + + i = 0; + while (big[i]) + { + if (little[i] != big[i]) + return (0); + i++; + if (!little[i]) + return (1); + } + return (0); +} + +char *get_value_key(char *key, t_list **head) +{ + t_list *current; + + current = *head; + while (current != NULL) + { + if (is_start(current->content, key)) + return (ft_strchr(current->content, '=') + 1); + current = current->next; + } + return (NULL); +} + t_list **init_env(char **env) { t_list **head; @@ -122,11 +180,7 @@ t_list **init_env(char **env) return (NULL); i = -1; while (env[++i]) - { - if (ft_strnstr(env[i], "XMODIFIERS=@im=ibus", 200)) - write(1, "", 0); add_sort(head, env[i]); - } return (head); } @@ -134,6 +188,7 @@ t_list **init_env(char **env) { (void)argc; (void)argv; - print_export(init_env(env)); + ft_putstr_fd(get_value_index(10, init_env(env)), 1); + //print_env(init_env(env), 1); return (0); }*/ diff --git a/env.h b/env.h deleted file mode 100644 index 49ab8fb..0000000 --- a/env.h +++ /dev/null @@ -1,21 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* env.h :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: erey-bet +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/01/31 14:39:05 by erey-bet #+# #+# */ -/* Updated: 2023/01/31 14:56:16 by erey-bet ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#ifndef ENV_H -# define ENV_H - -typedef struct s_env { - void *ctn; - void *next; -} t_env; - -#endif diff --git a/env.o b/env.o deleted file mode 100644 index 26d8a69..0000000 Binary files a/env.o and /dev/null differ diff --git a/libftx/extra/extra.a b/libftx/extra/extra.a deleted file mode 100644 index caeb9df..0000000 Binary files a/libftx/extra/extra.a and /dev/null differ diff --git a/libftx/extra/ft_contain_only.o b/libftx/extra/ft_contain_only.o deleted file mode 100644 index 417b966..0000000 Binary files a/libftx/extra/ft_contain_only.o and /dev/null differ diff --git a/libftx/extra/ft_freer.o b/libftx/extra/ft_freer.o deleted file mode 100644 index f672cf4..0000000 Binary files a/libftx/extra/ft_freer.o and /dev/null differ diff --git a/libftx/extra/ft_is_in.o b/libftx/extra/ft_is_in.o deleted file mode 100644 index f00ec7d4..0000000 Binary files a/libftx/extra/ft_is_in.o and /dev/null differ diff --git a/libftx/extra/ft_random_generator.o b/libftx/extra/ft_random_generator.o deleted file mode 100644 index 9817b91..0000000 Binary files a/libftx/extra/ft_random_generator.o and /dev/null differ diff --git a/libftx/extra/ft_strchri.o b/libftx/extra/ft_strchri.o deleted file mode 100644 index 9047d03..0000000 Binary files a/libftx/extra/ft_strchri.o and /dev/null differ diff --git a/libftx/extra/ft_strcmp.o b/libftx/extra/ft_strcmp.o deleted file mode 100644 index 0023061..0000000 Binary files a/libftx/extra/ft_strcmp.o and /dev/null differ diff --git a/libftx/extra/ft_strfjoin.o b/libftx/extra/ft_strfjoin.o deleted file mode 100644 index c47d615..0000000 Binary files a/libftx/extra/ft_strfjoin.o and /dev/null differ diff --git a/libftx/extra/ft_strgen.o b/libftx/extra/ft_strgen.o deleted file mode 100644 index 19f5c13..0000000 Binary files a/libftx/extra/ft_strgen.o and /dev/null differ diff --git a/libftx/extra/ft_strmerger.o b/libftx/extra/ft_strmerger.o deleted file mode 100644 index b477be0..0000000 Binary files a/libftx/extra/ft_strmerger.o and /dev/null differ diff --git a/libftx/extra/ft_strndup.o b/libftx/extra/ft_strndup.o deleted file mode 100644 index 1866899..0000000 Binary files a/libftx/extra/ft_strndup.o and /dev/null differ diff --git a/libftx/extra/ft_tabrealloc.o b/libftx/extra/ft_tabrealloc.o deleted file mode 100644 index c8fd161..0000000 Binary files a/libftx/extra/ft_tabrealloc.o and /dev/null differ diff --git a/libftx/extra/ft_ultoa_base.o b/libftx/extra/ft_ultoa_base.o deleted file mode 100644 index 216f89c..0000000 Binary files a/libftx/extra/ft_ultoa_base.o and /dev/null differ diff --git a/libftx/gnl/get_next_line.a b/libftx/gnl/get_next_line.a deleted file mode 100644 index 713cdd5..0000000 Binary files a/libftx/gnl/get_next_line.a and /dev/null differ diff --git a/libftx/gnl/get_next_line.o b/libftx/gnl/get_next_line.o deleted file mode 100644 index 9d2cf9a..0000000 Binary files a/libftx/gnl/get_next_line.o and /dev/null differ diff --git a/libftx/libft/ft_atoi.o b/libftx/libft/ft_atoi.o deleted file mode 100644 index e5536f1..0000000 Binary files a/libftx/libft/ft_atoi.o and /dev/null differ diff --git a/libftx/libft/ft_bzero.o b/libftx/libft/ft_bzero.o deleted file mode 100644 index 01f7b44..0000000 Binary files a/libftx/libft/ft_bzero.o and /dev/null differ diff --git a/libftx/libft/ft_calloc.o b/libftx/libft/ft_calloc.o deleted file mode 100644 index 692fcbf..0000000 Binary files a/libftx/libft/ft_calloc.o and /dev/null differ diff --git a/libftx/libft/ft_isalnum.o b/libftx/libft/ft_isalnum.o deleted file mode 100644 index 1539030..0000000 Binary files a/libftx/libft/ft_isalnum.o and /dev/null differ diff --git a/libftx/libft/ft_isalpha.o b/libftx/libft/ft_isalpha.o deleted file mode 100644 index d9396fc..0000000 Binary files a/libftx/libft/ft_isalpha.o and /dev/null differ diff --git a/libftx/libft/ft_isascii.o b/libftx/libft/ft_isascii.o deleted file mode 100644 index 7265176..0000000 Binary files a/libftx/libft/ft_isascii.o and /dev/null differ diff --git a/libftx/libft/ft_isdigit.o b/libftx/libft/ft_isdigit.o deleted file mode 100644 index e2270cf..0000000 Binary files a/libftx/libft/ft_isdigit.o and /dev/null differ diff --git a/libftx/libft/ft_isprint.o b/libftx/libft/ft_isprint.o deleted file mode 100644 index 406bdbf..0000000 Binary files a/libftx/libft/ft_isprint.o and /dev/null differ diff --git a/libftx/libft/ft_itoa.o b/libftx/libft/ft_itoa.o deleted file mode 100644 index c013963..0000000 Binary files a/libftx/libft/ft_itoa.o and /dev/null differ diff --git a/libftx/libft/ft_memchr.o b/libftx/libft/ft_memchr.o deleted file mode 100644 index f264816..0000000 Binary files a/libftx/libft/ft_memchr.o and /dev/null differ diff --git a/libftx/libft/ft_memcmp.o b/libftx/libft/ft_memcmp.o deleted file mode 100644 index 54b51b8..0000000 Binary files a/libftx/libft/ft_memcmp.o and /dev/null differ diff --git a/libftx/libft/ft_memcpy.o b/libftx/libft/ft_memcpy.o deleted file mode 100644 index 5217585..0000000 Binary files a/libftx/libft/ft_memcpy.o and /dev/null differ diff --git a/libftx/libft/ft_memmove.o b/libftx/libft/ft_memmove.o deleted file mode 100644 index eab259c..0000000 Binary files a/libftx/libft/ft_memmove.o and /dev/null differ diff --git a/libftx/libft/ft_memset.o b/libftx/libft/ft_memset.o deleted file mode 100644 index 35fb8a7..0000000 Binary files a/libftx/libft/ft_memset.o and /dev/null differ diff --git a/libftx/libft/ft_putchar_fd.o b/libftx/libft/ft_putchar_fd.o deleted file mode 100644 index 12b4285..0000000 Binary files a/libftx/libft/ft_putchar_fd.o and /dev/null differ diff --git a/libftx/libft/ft_putendl_fd.o b/libftx/libft/ft_putendl_fd.o deleted file mode 100644 index 6c8c4e3..0000000 Binary files a/libftx/libft/ft_putendl_fd.o and /dev/null differ diff --git a/libftx/libft/ft_putnbr_fd.o b/libftx/libft/ft_putnbr_fd.o deleted file mode 100644 index 13a08a2..0000000 Binary files a/libftx/libft/ft_putnbr_fd.o and /dev/null differ diff --git a/libftx/libft/ft_putstr_fd.o b/libftx/libft/ft_putstr_fd.o deleted file mode 100644 index 690c6b7..0000000 Binary files a/libftx/libft/ft_putstr_fd.o and /dev/null differ diff --git a/libftx/libft/ft_split.o b/libftx/libft/ft_split.o deleted file mode 100644 index 4194ea3..0000000 Binary files a/libftx/libft/ft_split.o and /dev/null differ diff --git a/libftx/libft/ft_strchr.o b/libftx/libft/ft_strchr.o deleted file mode 100644 index 8d96c2a..0000000 Binary files a/libftx/libft/ft_strchr.o and /dev/null differ diff --git a/libftx/libft/ft_strdup.o b/libftx/libft/ft_strdup.o deleted file mode 100644 index 2de40af..0000000 Binary files a/libftx/libft/ft_strdup.o and /dev/null differ diff --git a/libftx/libft/ft_striteri.o b/libftx/libft/ft_striteri.o deleted file mode 100644 index 65ba85b..0000000 Binary files a/libftx/libft/ft_striteri.o and /dev/null differ diff --git a/libftx/libft/ft_strjoin.o b/libftx/libft/ft_strjoin.o deleted file mode 100644 index 6e9755d..0000000 Binary files a/libftx/libft/ft_strjoin.o and /dev/null differ diff --git a/libftx/libft/ft_strlcat.o b/libftx/libft/ft_strlcat.o deleted file mode 100644 index 2ed02b5..0000000 Binary files a/libftx/libft/ft_strlcat.o and /dev/null differ diff --git a/libftx/libft/ft_strlcpy.o b/libftx/libft/ft_strlcpy.o deleted file mode 100644 index 7909106..0000000 Binary files a/libftx/libft/ft_strlcpy.o and /dev/null differ diff --git a/libftx/libft/ft_strlen.o b/libftx/libft/ft_strlen.o deleted file mode 100644 index a1a0894..0000000 Binary files a/libftx/libft/ft_strlen.o and /dev/null differ diff --git a/libftx/libft/ft_strmapi.o b/libftx/libft/ft_strmapi.o deleted file mode 100644 index df452ae..0000000 Binary files a/libftx/libft/ft_strmapi.o and /dev/null differ diff --git a/libftx/libft/ft_strncmp.o b/libftx/libft/ft_strncmp.o deleted file mode 100644 index 4bcd226..0000000 Binary files a/libftx/libft/ft_strncmp.o and /dev/null differ diff --git a/libftx/libft/ft_strnstr.o b/libftx/libft/ft_strnstr.o deleted file mode 100644 index b669955..0000000 Binary files a/libftx/libft/ft_strnstr.o and /dev/null differ diff --git a/libftx/libft/ft_strrchr.o b/libftx/libft/ft_strrchr.o deleted file mode 100644 index 8e739d5..0000000 Binary files a/libftx/libft/ft_strrchr.o and /dev/null differ diff --git a/libftx/libft/ft_strtrim.o b/libftx/libft/ft_strtrim.o deleted file mode 100644 index 51e2f50..0000000 Binary files a/libftx/libft/ft_strtrim.o and /dev/null differ diff --git a/libftx/libft/ft_substr.o b/libftx/libft/ft_substr.o deleted file mode 100644 index da7cab4..0000000 Binary files a/libftx/libft/ft_substr.o and /dev/null differ diff --git a/libftx/libft/ft_tolower.o b/libftx/libft/ft_tolower.o deleted file mode 100644 index 691cd4f..0000000 Binary files a/libftx/libft/ft_tolower.o and /dev/null differ diff --git a/libftx/libft/ft_toupper.o b/libftx/libft/ft_toupper.o deleted file mode 100644 index d1a9134..0000000 Binary files a/libftx/libft/ft_toupper.o and /dev/null differ diff --git a/libftx/libft/libft.a b/libftx/libft/libft.a deleted file mode 100644 index 64fb516..0000000 Binary files a/libftx/libft/libft.a and /dev/null differ diff --git a/libftx/libftx.a b/libftx/libftx.a deleted file mode 100644 index 6919e75..0000000 Binary files a/libftx/libftx.a and /dev/null differ diff --git a/libftx/libftx.h b/libftx/libftx.h index 3f74279..8d0d553 100644 --- a/libftx/libftx.h +++ b/libftx/libftx.h @@ -6,7 +6,7 @@ /* By: cchauvet