-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_utils16.c
97 lines (88 loc) · 1.56 KB
/
ft_utils16.c
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#include "minishell.h"
void push_frontlst(t_list *lst, char *str)
{
t_elem *new;
new = malloc(sizeof (t_elem));
if (!new)
exit(0);
new->data = ft_strdup(str);
new->next = lst->first;
new->prec = NULL;
if (lst->first)
lst->first->prec = new;
else
{
lst->last = new;
lst->last->next = NULL;
}
lst->first = new;
}
void afflst(t_list *lst)
{
t_elem *courant;
courant = lst->last;
printf("%s\n", courant->data);
while (courant->prec != NULL)
{
courant = courant->prec;
printf("%s\n", courant->data);
}
}
void afflst_back(t_list *exp)
{
t_elem *count;
count = exp->first;
while (count != NULL)
{
if (count->data != NULL)
printf("%s\n", count->data);
count = count->next;
}
}
void check_q(t_struct *d)
{
char *str;
int i;
if (d->l.line)
str = malloc(ft_strlen(d->l.line));
i = 0;
if (d->l.line && d->l.line[0] == '\'')
{
i++;
while (d->l.line[i])
{
if (d->l.line[i] != '\'' && d->l.line[i] == ' ')
str[i - 1] = d->l.line[i];
else if (d->l.line[i] == '\'' && d->l.line[i + 1] == '\0')
{
str[i - 1] = '\0';
printf("bash: %s: command not found\n", str);
}
else
break ;
i++;
}
}
check_q3(d, i, str);
}
char *check_q2(t_struct *d, int i, char *str)
{
if (d->l.line && d->l.line[0] == '"')
{
i++;
while (d->l.line[i])
{
if (d->l.line[i] != '"' && d->l.line[i] == ' ')
str[i - 1] = d->l.line[i];
else if (d->l.line[i] == '"' && d->l.line[i + 1] == '\0')
{
str[i - 1] = '\0';
printf("bash: %s: command not found\n", str);
}
else
break ;
i++;
}
}
return (str);
}