0.1
This commit is contained in:
parent
f6e9c64b29
commit
1533fb8c65
BIN
.env.c.swp
Normal file
BIN
.env.c.swp
Normal file
Binary file not shown.
5
Makefile
5
Makefile
@ -1,4 +1,4 @@
|
||||
SRCS = main.c
|
||||
SRCS = env.c
|
||||
|
||||
OBJS = ${SRCS:.c=.o}
|
||||
|
||||
@ -6,7 +6,7 @@ NAME = minishell
|
||||
|
||||
CC = clang
|
||||
|
||||
CFLAGS = -Wall -Werror -Wextra
|
||||
CFLAGS = -g -Wall -Werror -Wextra
|
||||
|
||||
LIBS = libftx/libftx.a
|
||||
|
||||
@ -16,6 +16,7 @@ LIBS = libftx/libftx.a
|
||||
all: ${NAME}
|
||||
|
||||
${NAME}: ${OBJS}
|
||||
make -C libftx
|
||||
${CC} ${OBJS} -o ${NAME} ${LIBS}
|
||||
|
||||
clean:
|
||||
|
99
env.c
Normal file
99
env.c
Normal file
@ -0,0 +1,99 @@
|
||||
#include "env.h"
|
||||
#include "libftx/libftx.h"
|
||||
|
||||
int strcmp_alphabet(char *s1, char *s2)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (!s1 || !s2)
|
||||
return (-2);
|
||||
i = 0;
|
||||
while (s1[i] && s2[i])
|
||||
{
|
||||
if (s1[i] < s2[i])
|
||||
return (0);
|
||||
else if (s1[i] > s2[i])
|
||||
return (1);
|
||||
i++;
|
||||
}
|
||||
return (-1);
|
||||
}
|
||||
|
||||
void ft_double_swap(char **a, char **b)
|
||||
{
|
||||
void *c;
|
||||
|
||||
c = *a;
|
||||
*a = *b;
|
||||
*b = c;
|
||||
}
|
||||
|
||||
void add_sort(t_list **head, char *str)
|
||||
{
|
||||
t_list *current;
|
||||
char *last;
|
||||
|
||||
current = *head;
|
||||
while (current->next != NULL)
|
||||
{
|
||||
if (strcmp_alphabet(str, current->content) == 0)
|
||||
break ;
|
||||
current = current->next;
|
||||
}
|
||||
last = current->content;
|
||||
current->content = str;
|
||||
while (current != NULL)
|
||||
{
|
||||
if (current->next == NULL)
|
||||
{
|
||||
current->next = ft_calloc(1, sizeof(t_list));
|
||||
if (current->next == NULL)
|
||||
return ;
|
||||
}
|
||||
current = current->next;
|
||||
if (current->content == NULL)
|
||||
{
|
||||
current->content = last;
|
||||
return ;
|
||||
}
|
||||
else
|
||||
ft_double_swap((char**)(¤t->content), &last);
|
||||
}
|
||||
}
|
||||
|
||||
t_list **init_env(char **env)
|
||||
{
|
||||
t_list **head;
|
||||
int i;
|
||||
|
||||
head = ft_calloc(1, sizeof(t_list*));
|
||||
*head = ft_calloc(1, sizeof(t_list));
|
||||
if (*head == NULL)
|
||||
return (NULL);
|
||||
i = -1;
|
||||
while (env[++i])
|
||||
{
|
||||
if (ft_strnstr(env[i], "XDG_SESSION_CLASS=user", 200))
|
||||
write(1, "", 0);
|
||||
add_sort(head, env[i]);
|
||||
}
|
||||
//current->next = NULL;
|
||||
return(head);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[], char **env)
|
||||
{
|
||||
t_list **new_env;
|
||||
t_list *current;
|
||||
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
new_env = init_env(env);
|
||||
current = *new_env;
|
||||
while (current != NULL)
|
||||
{
|
||||
ft_printf("%s\n", current->content);
|
||||
current = current->next;
|
||||
}
|
||||
return (0);
|
||||
}
|
21
env.h
Normal file
21
env.h
Normal file
@ -0,0 +1,21 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* env.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: erey-bet <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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
|
49
file1
Normal file
49
file1
Normal file
@ -0,0 +1,49 @@
|
||||
COLORTERM=truecolor
|
||||
DBUS_SESSION_BUS_ADDRESS='unix:path=/run/user/101231/bus,guid=2b19cb48c68a1a9a5df2465563da4d2b'
|
||||
DBUS_STARTER_ADDRESS='unix:path=/run/user/101231/bus,guid=2b19cb48c68a1a9a5df2465563da4d2b'
|
||||
DBUS_STARTER_BUS_TYPE=session
|
||||
DESKTOP_SESSION=ubuntu
|
||||
DISPLAY=:0
|
||||
DOCKER_HOST=unix:///run/user/101231/docker.sock
|
||||
GDMSESSION=ubuntu
|
||||
GDM_LANG=en
|
||||
GNOME_DESKTOP_SESSION_ID=this-is-deprecated
|
||||
GNOME_TERMINAL_SCREEN=/org/gnome/Terminal/screen/dd4e2769_33dd_4e18_81b2_70c233dc78ce
|
||||
GNOME_TERMINAL_SERVICE=:1.96
|
||||
GPG_AGENT_INFO=/run/user/101231/gnupg/S.gpg-agent:0:1
|
||||
GTK_MODULES=gail:atk-bridge
|
||||
HOME=/nfs/homes/erey-bet
|
||||
IM_CONFIG_PHASE=1
|
||||
INVOCATION_ID=4f6816c8fd9446809f7d454fd8bdc56a
|
||||
JOURNAL_STREAM=9:166232
|
||||
KRB5CCNAME=FILE:/tmp/krb5cc_101231_TfpJ05
|
||||
LANG=en_US.UTF-8
|
||||
LANGUAGE=en
|
||||
LOGNAME=erey-bet
|
||||
MANAGERPID=38750
|
||||
OLDPWD=/nfs/homes/erey-bet/travaux/Cursus42/minishell
|
||||
PATH=/nfs/homes/erey-bet/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
|
||||
PWD=/nfs/homes/erey-bet/travaux/Cursus42/minishell
|
||||
QT_ACCESSIBILITY=1
|
||||
QT_IM_MODULE=ibus
|
||||
SESSION_MANAGER=local/1C2.42angouleme.fr:@/tmp/.ICE-unix/39041,unix/1C2.42angouleme.fr:/tmp/.ICE-unix/39041
|
||||
SHELL=/bin/zsh
|
||||
SHLVL=1
|
||||
SSH_AGENT_PID=39003
|
||||
SSH_AUTH_SOCK=/run/user/101231/keyring/ssh
|
||||
TERM=xterm-256color
|
||||
USER=erey-bet
|
||||
VTE_VERSION=6003
|
||||
XAUTHORITY=/nfs/homes/erey-bet/.Xauthority
|
||||
XDG_CONFIG_DIRS=/etc/xdg/xdg-ubuntu:/etc/xdg
|
||||
XDG_CURRENT_DESKTOP=ubuntu:GNOME
|
||||
XDG_DATA_DIRS=/usr/share/gnome:/usr/share/ubuntu:/nfs/homes/erey-bet/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/usr/local/share:/usr/share:/var/lib/snapd/desktop
|
||||
XDG_GREETER_DATA_DIR=/var/lib/lightdm-data/erey-bet
|
||||
XDG_MENU_PREFIX=gnome-
|
||||
XDG_RUNTIME_DIR=/run/user/101231
|
||||
XDG_SEAT_PATH=/org/freedesktop/DisplayManager/Seat0
|
||||
XDG_SESSION_CLASS=user
|
||||
XDG_SESSION_DESKTOP=ubuntu
|
||||
XDG_SESSION_PATH=/org/freedesktop/DisplayManager/Session0
|
||||
XDG_SESSION_TYPE=x11
|
||||
XMODIFIERS='@im=ibus'
|
50
file2
Normal file
50
file2
Normal file
@ -0,0 +1,50 @@
|
||||
COLORTERM=truecolor
|
||||
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/101231/bus,guid=2b19cb48c68a1a9a5df2465563da4d2b
|
||||
DBUS_STARTER_ADDRESS=unix:path=/run/user/101231/bus,guid=2b19cb48c68a1a9a5df2465563da4d2b
|
||||
DBUS_STARTER_BUS_TYPE=session
|
||||
DESKTOP_SESSION=ubuntu
|
||||
DISPLAY=:0
|
||||
DOCKER_HOST=unix:///run/user/101231/docker.sock
|
||||
GDMSESSION=ubuntu
|
||||
GDM_LANG=en
|
||||
GNOME_DESKTOP_SESSION_ID=this-is-deprecated
|
||||
GNOME_TERMINAL_SCREEN=/org/gnome/Terminal/screen/dd4e2769_33dd_4e18_81b2_70c233dc78ce
|
||||
GNOME_TERMINAL_SERVICE=:1.96
|
||||
GPG_AGENT_INFO=/run/user/101231/gnupg/S.gpg-agent:0:1
|
||||
GTK_MODULES=gail:atk-bridge
|
||||
HOME=/nfs/homes/erey-bet
|
||||
IM_CONFIG_PHASE=1
|
||||
INVOCATION_ID=4f6816c8fd9446809f7d454fd8bdc56a
|
||||
JOURNAL_STREAM=9:166232
|
||||
KRB5CCNAME=FILE:/tmp/krb5cc_101231_TfpJ05
|
||||
LANG=en_US.UTF-8
|
||||
LANGUAGE=en
|
||||
LOGNAME=erey-bet
|
||||
MANAGERPID=38750
|
||||
OLDPWD=/nfs/homes/erey-bet/travaux/Cursus42/minishell
|
||||
PATH=/nfs/homes/erey-bet/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
|
||||
PWD=/nfs/homes/erey-bet/travaux/Cursus42/minishell
|
||||
QT_ACCESSIBILITY=1
|
||||
QT_IM_MODULE=ibus
|
||||
SESSION_MANAGER=local/1C2.42angouleme.fr:@/tmp/.ICE-unix/39041,unix/1C2.42angouleme.fr:/tmp/.ICE-unix/39041
|
||||
SHELL=/bin/zsh
|
||||
SHLVL=1
|
||||
SSH_AGENT_PID=39003
|
||||
TERM=xterm-256color
|
||||
USER=erey-bet
|
||||
VTE_VERSION=6003
|
||||
XAUTHORITY=/nfs/homes/erey-bet/.Xauthority
|
||||
XDG_CONFIG_DIRS=/etc/xdg/xdg-ubuntu:/etc/xdg
|
||||
XDG_CURRENT_DESKTOP=ubuntu:GNOME
|
||||
XDG_DATA_DIRS=/usr/share/gnome:/usr/share/ubuntu:/nfs/homes/erey-bet/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/usr/local/share:/usr/share:/var/lib/snapd/desktop
|
||||
XDG_GREETER_DATA_DIR=/var/lib/lightdm-data/erey-bet
|
||||
XDG_MENU_PREFIX=gnome-
|
||||
XDG_RUNTIME_DIR=/run/user/101231
|
||||
XDG_SEAT_PATH=/org/freedesktop/DisplayManager/Seat0
|
||||
XDG_SESSION_CLASS=user
|
||||
XDG_SESSION_DESKTOP=ubuntu
|
||||
XDG_SESSION_PATH=/org/freedesktop/DisplayManager/Session0
|
||||
XDG_SESSION_TYPE=x11
|
||||
XMODIFIERS=@im=ibus
|
||||
_=/nfs/homes/erey-bet/travaux/Cursus42/minishell/./minishell
|
||||
SSH_AUTH_SOCK=/run/user/101231/keyring/ssh
|
BIN
libftx/extra/extra.a
Normal file
BIN
libftx/extra/extra.a
Normal file
Binary file not shown.
BIN
libftx/extra/ft_contain_only.o
Normal file
BIN
libftx/extra/ft_contain_only.o
Normal file
Binary file not shown.
BIN
libftx/extra/ft_freer.o
Normal file
BIN
libftx/extra/ft_freer.o
Normal file
Binary file not shown.
BIN
libftx/extra/ft_is_in.o
Normal file
BIN
libftx/extra/ft_is_in.o
Normal file
Binary file not shown.
BIN
libftx/extra/ft_random_generator.o
Normal file
BIN
libftx/extra/ft_random_generator.o
Normal file
Binary file not shown.
BIN
libftx/extra/ft_strchri.o
Normal file
BIN
libftx/extra/ft_strchri.o
Normal file
Binary file not shown.
BIN
libftx/extra/ft_strcmp.o
Normal file
BIN
libftx/extra/ft_strcmp.o
Normal file
Binary file not shown.
BIN
libftx/extra/ft_strfjoin.o
Normal file
BIN
libftx/extra/ft_strfjoin.o
Normal file
Binary file not shown.
BIN
libftx/extra/ft_strgen.o
Normal file
BIN
libftx/extra/ft_strgen.o
Normal file
Binary file not shown.
BIN
libftx/extra/ft_strmerger.o
Normal file
BIN
libftx/extra/ft_strmerger.o
Normal file
Binary file not shown.
BIN
libftx/extra/ft_strndup.o
Normal file
BIN
libftx/extra/ft_strndup.o
Normal file
Binary file not shown.
BIN
libftx/extra/ft_tabrealloc.o
Normal file
BIN
libftx/extra/ft_tabrealloc.o
Normal file
Binary file not shown.
BIN
libftx/extra/ft_ultoa_base.o
Normal file
BIN
libftx/extra/ft_ultoa_base.o
Normal file
Binary file not shown.
BIN
libftx/gnl/get_next_line.a
Normal file
BIN
libftx/gnl/get_next_line.a
Normal file
Binary file not shown.
BIN
libftx/gnl/get_next_line.o
Normal file
BIN
libftx/gnl/get_next_line.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_atoi.o
Normal file
BIN
libftx/libft/ft_atoi.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_bzero.o
Normal file
BIN
libftx/libft/ft_bzero.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_calloc.o
Normal file
BIN
libftx/libft/ft_calloc.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_isalnum.o
Normal file
BIN
libftx/libft/ft_isalnum.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_isalpha.o
Normal file
BIN
libftx/libft/ft_isalpha.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_isascii.o
Normal file
BIN
libftx/libft/ft_isascii.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_isdigit.o
Normal file
BIN
libftx/libft/ft_isdigit.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_isprint.o
Normal file
BIN
libftx/libft/ft_isprint.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_itoa.o
Normal file
BIN
libftx/libft/ft_itoa.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_memchr.o
Normal file
BIN
libftx/libft/ft_memchr.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_memcmp.o
Normal file
BIN
libftx/libft/ft_memcmp.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_memcpy.o
Normal file
BIN
libftx/libft/ft_memcpy.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_memmove.o
Normal file
BIN
libftx/libft/ft_memmove.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_memset.o
Normal file
BIN
libftx/libft/ft_memset.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_putchar_fd.o
Normal file
BIN
libftx/libft/ft_putchar_fd.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_putendl_fd.o
Normal file
BIN
libftx/libft/ft_putendl_fd.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_putnbr_fd.o
Normal file
BIN
libftx/libft/ft_putnbr_fd.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_putstr_fd.o
Normal file
BIN
libftx/libft/ft_putstr_fd.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_split.o
Normal file
BIN
libftx/libft/ft_split.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_strchr.o
Normal file
BIN
libftx/libft/ft_strchr.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_strdup.o
Normal file
BIN
libftx/libft/ft_strdup.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_striteri.o
Normal file
BIN
libftx/libft/ft_striteri.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_strjoin.o
Normal file
BIN
libftx/libft/ft_strjoin.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_strlcat.o
Normal file
BIN
libftx/libft/ft_strlcat.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_strlcpy.o
Normal file
BIN
libftx/libft/ft_strlcpy.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_strlen.o
Normal file
BIN
libftx/libft/ft_strlen.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_strmapi.o
Normal file
BIN
libftx/libft/ft_strmapi.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_strncmp.o
Normal file
BIN
libftx/libft/ft_strncmp.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_strnstr.o
Normal file
BIN
libftx/libft/ft_strnstr.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_strrchr.o
Normal file
BIN
libftx/libft/ft_strrchr.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_strtrim.o
Normal file
BIN
libftx/libft/ft_strtrim.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_substr.o
Normal file
BIN
libftx/libft/ft_substr.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_tolower.o
Normal file
BIN
libftx/libft/ft_tolower.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_toupper.o
Normal file
BIN
libftx/libft/ft_toupper.o
Normal file
Binary file not shown.
BIN
libftx/libft/libft.a
Normal file
BIN
libftx/libft/libft.a
Normal file
Binary file not shown.
BIN
libftx/libftx.a
Normal file
BIN
libftx/libftx.a
Normal file
Binary file not shown.
BIN
libftx/printf/ft_dprintX.o
Normal file
BIN
libftx/printf/ft_dprintX.o
Normal file
Binary file not shown.
BIN
libftx/printf/ft_dprintarg.o
Normal file
BIN
libftx/printf/ft_dprintarg.o
Normal file
Binary file not shown.
BIN
libftx/printf/ft_dprintflag.o
Normal file
BIN
libftx/printf/ft_dprintflag.o
Normal file
Binary file not shown.
BIN
libftx/printf/ft_dprintl_base.o
Normal file
BIN
libftx/printf/ft_dprintl_base.o
Normal file
Binary file not shown.
BIN
libftx/printf/ft_dprintptr.o
Normal file
BIN
libftx/printf/ft_dprintptr.o
Normal file
Binary file not shown.
BIN
libftx/printf/ft_dprintstrtab.o
Normal file
BIN
libftx/printf/ft_dprintstrtab.o
Normal file
Binary file not shown.
BIN
libftx/printf/ft_dprintul.o
Normal file
BIN
libftx/printf/ft_dprintul.o
Normal file
Binary file not shown.
BIN
libftx/printf/ft_dprintul_base.o
Normal file
BIN
libftx/printf/ft_dprintul_base.o
Normal file
Binary file not shown.
BIN
libftx/printf/ft_dprintx.o
Normal file
BIN
libftx/printf/ft_dprintx.o
Normal file
Binary file not shown.
BIN
libftx/printf/ft_isarg.o
Normal file
BIN
libftx/printf/ft_isarg.o
Normal file
Binary file not shown.
BIN
libftx/printf/ft_isdigit.o
Normal file
BIN
libftx/printf/ft_isdigit.o
Normal file
Binary file not shown.
BIN
libftx/printf/ft_printf.a
Normal file
BIN
libftx/printf/ft_printf.a
Normal file
Binary file not shown.
BIN
libftx/printf/ft_printf.o
Normal file
BIN
libftx/printf/ft_printf.o
Normal file
Binary file not shown.
BIN
libftx/printf/ft_putchar_fd.o
Normal file
BIN
libftx/printf/ft_putchar_fd.o
Normal file
Binary file not shown.
BIN
libftx/printf/ft_putstr_fd.o
Normal file
BIN
libftx/printf/ft_putstr_fd.o
Normal file
Binary file not shown.
BIN
libftx/printf/ft_skipflag.o
Normal file
BIN
libftx/printf/ft_skipflag.o
Normal file
Binary file not shown.
BIN
libftx/printf/ft_strlen.o
Normal file
BIN
libftx/printf/ft_strlen.o
Normal file
Binary file not shown.
BIN
libftx/printf/ft_vdprintf.o
Normal file
BIN
libftx/printf/ft_vdprintf.o
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user