Tient Camille 0 bug whula
This commit is contained in:
parent
4f77dde859
commit
7b3389c75d
BIN
.env.c.swo
BIN
.env.c.swo
Binary file not shown.
BIN
argprinter
BIN
argprinter
Binary file not shown.
77
env.c
77
env.c
@ -6,17 +6,28 @@
|
||||
/* By: erey-bet <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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);
|
||||
}*/
|
||||
|
21
env.h
21
env.h
@ -1,21 +0,0 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* 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
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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/libftx.a
BIN
libftx/libftx.a
Binary file not shown.
@ -6,7 +6,7 @@
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/09/26 14:47:54 by cchauvet #+# #+# */
|
||||
/* Updated: 2023/02/01 16:20:05 by cchauvet ### ########.fr */
|
||||
/* Updated: 2023/02/03 12:34:10 by erey-bet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -67,7 +67,8 @@ char *ft_itoa(int n);
|
||||
char *ft_strmapi(char const *s, char (*f)(unsigned int, char));
|
||||
void ft_striteri(char *s, void (*f)(unsigned int, char*));
|
||||
void ft_putchar_fd(int fd, char c);
|
||||
void ft_putstr_fd(int fd, char *s);
|
||||
void ft_putstr_fd(char *s, int fd);
|
||||
|
||||
void ft_putendl_fd(int fd, char *s);
|
||||
void ft_putnbr_fd(int fd, int n);
|
||||
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -8,6 +8,9 @@
|
||||
|
||||
int ft_file_is_readable(char *path);
|
||||
int ft_file_is_writeable(char *path);
|
||||
t_list **init_env(char **env);
|
||||
char *get_value_index(int index, t_list **head);
|
||||
char *get_value_key(char *key, t_list **head);
|
||||
|
||||
typedef struct cmd
|
||||
{
|
||||
@ -17,4 +20,9 @@ typedef struct cmd
|
||||
char *args;
|
||||
} cmd;
|
||||
|
||||
typedef struct s_data
|
||||
{
|
||||
t_list **env;
|
||||
} t_data;
|
||||
|
||||
#endif
|
||||
|
@ -1,6 +1,6 @@
|
||||
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_SESSION_BUS_ADDRESS=unix:path=/run/user/101231/bus,guid=621c3599211e51a4e50420bf63dcee5f
|
||||
DBUS_STARTER_ADDRESS=unix:path=/run/user/101231/bus,guid=621c3599211e51a4e50420bf63dcee5f
|
||||
DBUS_STARTER_BUS_TYPE=session
|
||||
DESKTOP_SESSION=ubuntu
|
||||
DISPLAY=:0
|
||||
@ -8,28 +8,28 @@ 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
|
||||
GNOME_TERMINAL_SCREEN=/org/gnome/Terminal/screen/277eb9d7_4a54_437b_9556_e8825e1c7429
|
||||
GNOME_TERMINAL_SERVICE=:1.89
|
||||
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
|
||||
INVOCATION_ID=9d85372853b94435bbce5d2edac38c19
|
||||
JOURNAL_STREAM=9:2506910
|
||||
KRB5CCNAME=FILE:/tmp/krb5cc_101231_mfTZPs
|
||||
LANG=en_US.UTF-8
|
||||
LANGUAGE=en
|
||||
LOGNAME=erey-bet
|
||||
MANAGERPID=38750
|
||||
MANAGERPID=763384
|
||||
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
|
||||
SESSION_MANAGER=local/1D2.42angouleme.fr:@/tmp/.ICE-unix/763641,unix/1D2.42angouleme.fr:/tmp/.ICE-unix/763641
|
||||
SHELL=/bin/zsh
|
||||
SHLVL=1
|
||||
SSH_AGENT_PID=39003
|
||||
SHLVL=2
|
||||
SSH_AGENT_PID=763603
|
||||
SSH_AUTH_SOCK=/run/user/101231/keyring/ssh
|
||||
TERM=xterm-256color
|
||||
USER=erey-bet
|
||||
@ -44,6 +44,7 @@ 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_PATH=/org/freedesktop/DisplayManager/Session3
|
||||
XDG_SESSION_TYPE=x11
|
||||
XMODIFIERS='@im=ibus'
|
||||
XMODIFIERS=@im=ibus
|
||||
_=./minishell
|
@ -1,50 +1,50 @@
|
||||
SHELL=/bin/zsh
|
||||
SESSION_MANAGER=local/1D2.42angouleme.fr:@/tmp/.ICE-unix/763641,unix/1D2.42angouleme.fr:/tmp/.ICE-unix/763641
|
||||
QT_ACCESSIBILITY=1
|
||||
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
|
||||
XDG_CONFIG_DIRS=/etc/xdg/xdg-ubuntu:/etc/xdg
|
||||
XDG_SESSION_PATH=/org/freedesktop/DisplayManager/Session3
|
||||
XDG_MENU_PREFIX=gnome-
|
||||
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
|
||||
LANGUAGE=en
|
||||
SSH_AUTH_SOCK=/run/user/101231/keyring/ssh
|
||||
XMODIFIERS=@im=ibus
|
||||
DESKTOP_SESSION=ubuntu
|
||||
SSH_AGENT_PID=763603
|
||||
GTK_MODULES=gail:atk-bridge
|
||||
DBUS_STARTER_BUS_TYPE=session
|
||||
KRB5CCNAME=FILE:/tmp/krb5cc_101231_mfTZPs
|
||||
PWD=/nfs/homes/erey-bet/travaux/Cursus42/minishell
|
||||
LOGNAME=erey-bet
|
||||
XDG_SESSION_DESKTOP=ubuntu
|
||||
XDG_SESSION_TYPE=x11
|
||||
GPG_AGENT_INFO=/run/user/101231/gnupg/S.gpg-agent:0:1
|
||||
XAUTHORITY=/nfs/homes/erey-bet/.Xauthority
|
||||
XDG_GREETER_DATA_DIR=/var/lib/lightdm-data/erey-bet
|
||||
GDM_LANG=en
|
||||
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
|
||||
XDG_CURRENT_DESKTOP=ubuntu:GNOME
|
||||
VTE_VERSION=6003
|
||||
XDG_SEAT_PATH=/org/freedesktop/DisplayManager/Seat0
|
||||
GNOME_TERMINAL_SCREEN=/org/gnome/Terminal/screen/277eb9d7_4a54_437b_9556_e8825e1c7429
|
||||
INVOCATION_ID=9d85372853b94435bbce5d2edac38c19
|
||||
MANAGERPID=763384
|
||||
XDG_SESSION_CLASS=user
|
||||
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-
|
||||
GNOME_TERMINAL_SERVICE=:1.89
|
||||
DISPLAY=:0
|
||||
SHLVL=2
|
||||
QT_IM_MODULE=ibus
|
||||
DBUS_STARTER_ADDRESS=unix:path=/run/user/101231/bus,guid=621c3599211e51a4e50420bf63dcee5f
|
||||
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
|
||||
DOCKER_HOST=unix:///run/user/101231/docker.sock
|
||||
JOURNAL_STREAM=9:2506910
|
||||
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
|
||||
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
|
||||
GDMSESSION=ubuntu
|
||||
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/101231/bus,guid=621c3599211e51a4e50420bf63dcee5f
|
||||
OLDPWD=/nfs/homes/erey-bet/travaux/Cursus42/minishell
|
||||
_=/usr/bin/env
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user