summaryrefslogtreecommitdiffstats
path: root/src/p_redirs.c
blob: aec3ba6bf20710662a8d3840f05548220134be25 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   p_redirs.c                                         :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/02/14 17:19:27 by rbousset          #+#    #+#             */
/*   Updated: 2020/02/14 17:19:29 by rbousset         ###   ########lyon.fr   */
/*                                                                            */
/* ************************************************************************** */

#include <libft.h>
#include <stdint.h>
#include <stddef.h>

#include "d_define.h"
#include "s_struct.h"
#include "u_parse.h"

int8_t	p_redirs(char word[], t_com **com)
{
	struct s_com	*com_ptr;
	char			*ptr;
	t_quote_mode	mode;

	mode = Q_NONE;
	ptr = (char *)word;
	while (*ptr != C_NUL)
	{
		if (*ptr == C_DQUOTE)
			mode = u_meet_dquote(word, ptr, mode);
		else if (*ptr == C_SQUOTE)
			mode = u_meet_squote(word, ptr, mode);
		else if (mode == Q_NONE && (*ptr == '<' || *ptr == '>') == 1)
		{
			if (p_get_redir(ptr, (ptr - word), com) != )
			ptr = word;
		}
		ptr++;
	}
	return (0);
}