-
Notifications
You must be signed in to change notification settings - Fork 1
/
ssl_stdin_cmd.c
62 lines (57 loc) · 1.74 KB
/
ssl_stdin_cmd.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ssl_stdin_cmd.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: itiievsk <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/09/18 16:44:33 by itiievsk #+# #+# */
/* Updated: 2018/09/18 16:44:35 by itiievsk ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_ssl.h"
void stdin_parse_handler(int argc, char **argv, t_ssl_func handler[],
bool *no_error)
{
int i;
i = 0;
while (argv[i++])
argc++;
if (argc == 1)
{
argv ? clean_array(argv) : 0;
usage();
}
i = 0;
init_functions(handler);
while (i < FUNCTIONS)
{
if (ft_strequ(argv[1], handler[i].func))
{
handler[i].handler(argc, argv);
*no_error = true;
}
i++;
}
}
void stdin_cmd(int argc, int i, t_ssl_func handler[], bool no_error)
{
char *str;
char **argv;
char *temp;
ft_printf("FT_SSL> ");
while (get_next_line(0, &str) > 0)
{
i = 0;
no_error = false;
temp = str;
str = ft_strjoin("ft_ssl ", str);
free(temp);
argv = ft_strsplit(str, ' ');
free(str);
stdin_parse_handler(argc, argv, handler, &no_error);
no_error == false ? wrong_argument(handler, argv, -1, true) : 0;
ft_printf("FT_SSL> ");
clean_array(argv);
}
}