OBELIX: MAIS ASTERIX ARRETE TOUT DE SUITE
This commit is contained in:
parent
00e570d92e
commit
5948237aad
@ -6,7 +6,7 @@
|
|||||||
/* By: erey-bet <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: erey-bet <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/02/20 14:27:36 by erey-bet #+# #+# */
|
/* Created: 2023/02/20 14:27:36 by erey-bet #+# #+# */
|
||||||
/* Updated: 2023/02/28 13:13:23 by erey-bet ### ########.fr */
|
/* Updated: 2023/02/28 13:37:18 by erey-bet ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -27,7 +27,7 @@ int move_folder(char **args, int fd)
|
|||||||
{
|
{
|
||||||
if (chdir(path) == 0)
|
if (chdir(path) == 0)
|
||||||
return (0);
|
return (0);
|
||||||
write(2, "chdir error", 11);
|
write(2, "No suck file or directory", 25);
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -40,7 +40,7 @@ int move_folder(char **args, int fd)
|
|||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
free(join);
|
free(join);
|
||||||
write(2, "chdir error", 11);
|
write(2, "No suck file or directory", 25);
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* By: erey-bet <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: erey-bet <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/02/24 10:17:59 by erey-bet #+# #+# */
|
/* Created: 2023/02/24 10:17:59 by erey-bet #+# #+# */
|
||||||
/* Updated: 2023/02/24 12:44:05 by erey-bet ### ########.fr */
|
/* Updated: 2023/02/28 14:24:47 by erey-bet ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -27,16 +27,18 @@ static int error(int err, char *reason, char *problem, int fd)
|
|||||||
|
|
||||||
int ft_exit(char **args, int fd)
|
int ft_exit(char **args, int fd)
|
||||||
{
|
{
|
||||||
int i;
|
int err;
|
||||||
|
|
||||||
if (args[0] == NULL)
|
if (args[0] == NULL)
|
||||||
return (0);
|
return (0);
|
||||||
i = -1;
|
err = ft_atoi_check;
|
||||||
if (ft_atoi_check(args[0]) == 0)
|
if (err == 1)
|
||||||
return (error(2, "numeric argument required", args[0], fd));
|
return (error(err, "numeric argument required", args[0], fd));
|
||||||
if (args[1] != NULL)
|
if (args[1] != NULL)
|
||||||
return (error(-1, "too many arguments", NULL, fd));
|
return (error(-1, "too many arguments", NULL, fd));
|
||||||
return (ft_atoi(args[0]));
|
if (error > 0)
|
||||||
|
error(err, "numeric argument required", args[0], fd);
|
||||||
|
return (ft_atoi(args[0]) % 256);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* int main(int argc, char *argv[]) */
|
/* int main(int argc, char *argv[]) */
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/02/14 14:27:08 by cchauvet #+# #+# */
|
/* Created: 2023/02/14 14:27:08 by cchauvet #+# #+# */
|
||||||
/* Updated: 2023/02/24 12:32:22 by erey-bet ### ########.fr */
|
/* Updated: 2023/02/28 13:30:32 by erey-bet ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ void print_export(t_list **env, int fd)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void add_export(t_list **env, char *args, int fd, int *err)
|
int add_export(t_list **env, char *args, int fd, int *err)
|
||||||
{
|
{
|
||||||
char *key;
|
char *key;
|
||||||
char *value;
|
char *value;
|
||||||
@ -47,12 +47,19 @@ void add_export(t_list **env, char *args, int fd, int *err)
|
|||||||
if (ft_strchr(args, '=') != NULL)
|
if (ft_strchr(args, '=') != NULL)
|
||||||
{
|
{
|
||||||
key = ft_strndup(args, ft_strnchr(args, '='));
|
key = ft_strndup(args, ft_strnchr(args, '='));
|
||||||
|
if (key == NULL)
|
||||||
|
return (1);
|
||||||
|
if (ft_strlen(key) == 0)
|
||||||
|
{
|
||||||
|
error(args, fd);
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
value = ft_strchr(args, '=') + 1;
|
value = ft_strchr(args, '=') + 1;
|
||||||
}
|
}
|
||||||
if (!possible_key(key))
|
if (!possible_key(key))
|
||||||
{
|
{
|
||||||
*err = error(key, fd);
|
*err = error(key, fd);
|
||||||
return ;
|
return (1);
|
||||||
}
|
}
|
||||||
create_value_by_key_dup(key, value, env);
|
create_value_by_key_dup(key, value, env);
|
||||||
}
|
}
|
||||||
@ -69,16 +76,18 @@ int export(t_list **env, char **args, int fd)
|
|||||||
{
|
{
|
||||||
i = -1;
|
i = -1;
|
||||||
while (args[++i])
|
while (args[++i])
|
||||||
add_export(env, args[i], fd, &err);
|
if (add_export(env, args[i], fd, &err) == 1)
|
||||||
|
err = 1;
|
||||||
}
|
}
|
||||||
return (err);
|
return (err);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*int main(int argc, char *argv[], char **env)
|
int main(int argc, char *argv[], char **env)
|
||||||
{
|
{
|
||||||
t_list **n_env;
|
t_list **n_env;
|
||||||
|
|
||||||
|
(void)argc;
|
||||||
n_env = init_env(env);
|
n_env = init_env(env);
|
||||||
export(n_env, argv + 1, 1);
|
export(n_env, argv + 1, 1);
|
||||||
return (0);
|
return (0);
|
||||||
}*/
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user