maxishell
Implementation of a shell for Linux-like systems
Loading...
Searching...
No Matches
loc_env_var_handler_utils_utils_utils_utils.c
Go to the documentation of this file.
1/* ************************************************************************** */
2/* */
3/* ::: :::::::: */
4/* loc_env_var_handler_utils_utils_utils_uti :+: :+: :+: */
5/* +:+ +:+ +:+ */
6/* By: rmikhayl <marvin@42.fr> +#+ +:+ +#+ */
7/* +#+#+#+#+#+ +#+ */
8/* Created: 2024/11/09 12:32:24 by rmikhayl #+# #+# */
9/* Updated: 2024/11/09 12:32:26 by rmikhayl ### ########.fr */
10/* */
11/* ************************************************************************** */
12
13#include "tokens.h"
14
15char **initialize_result_array(int *count)
16{
17 char **result;
18
19 *count = 0;
20 result = malloc(sizeof(char *));
21 if (!result)
22 return (NULL);
23 return (result);
24}
25
26int toggle_quotes(int in_quotes, char current_char)
27{
28 if (current_char == '"' || current_char == '\'')
29 return (!in_quotes);
30 return (in_quotes);
31}
32
33char **add_segment_on_delimiter(char **result, char **start, \
34 char *str, int *count)
35{
36 result = ft_add_segment(result, *start, str - *start, count);
37 *start = str + 1;
38 return (result);
39}
40
41char **finalize_result_array(char **result, int count)
42{
43 char **temp;
44
45 temp = realloc(result, sizeof(char *) * (count + 1));
46 if (!temp)
47 {
48 free(result);
49 return (NULL);
50 }
51 result = temp;
52 result[count] = NULL;
53 return (result);
54}
int toggle_quotes(int in_quotes, char current_char)
char ** finalize_result_array(char **result, int count)
char ** initialize_result_array(int *count)
char ** add_segment_on_delimiter(char **result, char **start, char *str, int *count)
char ** ft_add_segment(char **result, char *start, size_t length, int *count)