Compare commits
2 Commits
d7032849d6
...
4c45a2c603
Author | SHA1 | Date | |
---|---|---|---|
|
4c45a2c603 | ||
|
b40762478a |
@ -6,7 +6,7 @@
|
|||||||
/* By: erey-bet <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: erey-bet <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/02/17 13:09:08 by erey-bet #+# #+# */
|
/* Created: 2023/02/17 13:09:08 by erey-bet #+# #+# */
|
||||||
/* Updated: 2023/02/17 17:07:50 by erey-bet ### ########.fr */
|
/* Updated: 2023/02/21 15:38:53 by erey-bet ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -45,11 +45,40 @@ int check_argument(char *str, int *check, int i)
|
|||||||
return (i);
|
return (i);
|
||||||
}
|
}
|
||||||
|
|
||||||
int echo(int fd, char *str)
|
|
||||||
|
char *conca(char **strings)
|
||||||
|
{
|
||||||
|
int len;
|
||||||
|
char *result;
|
||||||
|
char *p;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
i = -1;
|
||||||
|
while (strings[++i] != NULL)
|
||||||
|
len += strlen(strings[i]);
|
||||||
|
result = (char *) malloc(len * 2 + 1);
|
||||||
|
if (result == NULL)
|
||||||
|
return NULL;
|
||||||
|
p = result;
|
||||||
|
i = 0;
|
||||||
|
while (strings[i] != NULL)
|
||||||
|
{
|
||||||
|
ft_strncpy(p, strings[i], ft_strlen(strings[i]));
|
||||||
|
ft_strncpy(p, " ", 1);
|
||||||
|
p += strlen(strings[i]);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
return (result);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int echo(int fd, char **strs)
|
||||||
{
|
{
|
||||||
int check;
|
int check;
|
||||||
int i;
|
int i;
|
||||||
|
char *str;
|
||||||
|
|
||||||
|
str = conca(strs);
|
||||||
check = 0;
|
check = 0;
|
||||||
i = 0;
|
i = 0;
|
||||||
while (is_space(str[i]))
|
while (is_space(str[i]))
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/02/14 13:45:30 by cchauvet #+# #+# */
|
/* Created: 2023/02/14 13:45:30 by cchauvet #+# #+# */
|
||||||
/* Updated: 2023/02/21 15:10:50 by cchauvet ### ########.fr */
|
/* Updated: 2023/02/21 15:43:50 by erey-bet ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -21,6 +21,7 @@
|
|||||||
# include <stdio.h>
|
# include <stdio.h>
|
||||||
# include <unistd.h>
|
# include <unistd.h>
|
||||||
# include <limits.h>
|
# include <limits.h>
|
||||||
|
# include <string.h>
|
||||||
# include <readline/readline.h>
|
# include <readline/readline.h>
|
||||||
# include <readline/history.h>
|
# include <readline/history.h>
|
||||||
# define DEBUG 0
|
# define DEBUG 0
|
||||||
@ -60,7 +61,7 @@ char *get_value(char *str);
|
|||||||
char *get_key(char *str);
|
char *get_key(char *str);
|
||||||
|
|
||||||
/* Echo */
|
/* Echo */
|
||||||
int echo(int fd, char *str);
|
int echo(int fd, char **strs);
|
||||||
/* PWD */
|
/* PWD */
|
||||||
int pwd(int fd);
|
int pwd(int fd);
|
||||||
char *get_pwd(int fd);
|
char *get_pwd(int fd);
|
||||||
|
Loading…
Reference in New Issue
Block a user