add: loop read input
This commit is contained in:
parent
a94b648e05
commit
bea145636d
21
src/main.c
21
src/main.c
@ -1,12 +1,23 @@
|
|||||||
#include "prompt/prompt.h"
|
|
||||||
#include "./env/env.h"
|
#include "./env/env.h"
|
||||||
|
#include "./input/input.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
int main(int ac, char **av, char **env)
|
int main(int ac, char **av, char **env_str)
|
||||||
{
|
{
|
||||||
lst** lst_env;
|
char *line;
|
||||||
|
lst** env;
|
||||||
|
|
||||||
(void) av;
|
(void) av;
|
||||||
(void) ac;
|
(void) ac;
|
||||||
lst_env = env_init((const char **) env);
|
env = env_init((const char **) env_str);
|
||||||
printf(get_prompt(lst_env));
|
if (env == NULL)
|
||||||
|
return (1);
|
||||||
|
line = get_user_input(env);
|
||||||
|
while (line != NULL)
|
||||||
|
{
|
||||||
|
free(line);
|
||||||
|
line = get_user_input(env);
|
||||||
|
}
|
||||||
|
lst_clear(env, &env_del);
|
||||||
|
return (0);
|
||||||
}
|
}
|
||||||
|
25
src/utils/is_in_quote.c
Normal file
25
src/utils/is_in_quote.c
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
#include "utils.h"
|
||||||
|
|
||||||
|
int is_in_quote(const char *str)
|
||||||
|
{
|
||||||
|
int out = 0;
|
||||||
|
|
||||||
|
for (size_t i = 0; str[i] != '\0'; i++)
|
||||||
|
{
|
||||||
|
if (str[i] == '\"')
|
||||||
|
{
|
||||||
|
if (out == 2)
|
||||||
|
out = 0;
|
||||||
|
else
|
||||||
|
out = 2;
|
||||||
|
}
|
||||||
|
else if (str[i] == '\'')
|
||||||
|
{
|
||||||
|
if (out == 1)
|
||||||
|
out = 0;
|
||||||
|
else
|
||||||
|
out = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (out);
|
||||||
|
}
|
5
src/utils/utils.h
Normal file
5
src/utils/utils.h
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
int is_in_quote(const char *str);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user