57 lines
721 B
C
57 lines
721 B
C
#include "minishell.h"
|
|
|
|
int ft_get_infile(char **line)
|
|
{
|
|
size_t i;
|
|
char *path;
|
|
|
|
path = NULL;
|
|
i = 0;
|
|
while ((*line)[i] != '\0')
|
|
{
|
|
if ((*line)[i] == '<' && ft_is_in_quote(*line, i) == 0)
|
|
{
|
|
if (path != NULL)
|
|
free(path);
|
|
path = ft_getstr(*line, i);
|
|
if (path == NULL)
|
|
return (-1);
|
|
if (ft_file_is_readable(path) == 0)
|
|
{
|
|
free(path);
|
|
return (-1);
|
|
}
|
|
}
|
|
i++;
|
|
}
|
|
return (open(path, O_RDONLY));
|
|
}
|
|
|
|
t_list **ft_parse_cmd(char *line)
|
|
{
|
|
char infile;
|
|
char outfile;
|
|
t_list **cmds;
|
|
size_t i;
|
|
|
|
(void) outfile;
|
|
(void) cmds;
|
|
i = 0;
|
|
while (line[i] != '\0')
|
|
{
|
|
|
|
i++;
|
|
}
|
|
}
|
|
|
|
int main(int ac, char **av)
|
|
{
|
|
int fd;
|
|
int i;
|
|
|
|
if (ac == 1)
|
|
return (1);
|
|
ft_parse_cmd(av[1]);
|
|
return (1);
|
|
}
|